From 9d0cecc1f62938724b44879e19a84ae615e73965 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 25 Sep 2024 11:40:49 +0800 Subject: [PATCH] bug --- .../IThirdApiRecordService.cs | 2 +- .../Tnb.BasicData/ThirdApiRecordService.cs | 11 ++++---- .../Entity/WmsRawmatOutstockH.cs | 14 ++++++++++ .../WmsMaterialSignHService.cs | 26 ++++++++++++------- .../WmsMaterialTransferService.cs | 14 +++++----- .../WmsRawmatOutstockService.cs | 26 +++++++++++-------- 6 files changed, 60 insertions(+), 33 deletions(-) diff --git a/BasicData/Tnb.BasicData.Interfaces/IThirdApiRecordService.cs b/BasicData/Tnb.BasicData.Interfaces/IThirdApiRecordService.cs index 1940089d..62b6b3c0 100644 --- a/BasicData/Tnb.BasicData.Interfaces/IThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData.Interfaces/IThirdApiRecordService.cs @@ -11,6 +11,6 @@ namespace Tnb.BasicData.Interfaces /// /// 手动 自动 /// - Task Send(List records, string send_type,ISqlSugarClient db=null); + Task Send(List records, string send_type,ISqlSugarClient db=null); } } \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs index 988a4166..2bcd0724 100644 --- a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs @@ -44,7 +44,8 @@ namespace Tnb.BasicData public async Task Send(string id) { ThirdWebapiRecord record = await _repository.GetSingleAsync(x=>x.id==id); - return await Send(Arrays.AsList(record), "手动"); + ThirdResult thirdResult = await Send(Arrays.AsList(record), "手动"); + return thirdResult.msgResult; } [HttpGet] @@ -88,14 +89,14 @@ namespace Tnb.BasicData return "失败"; } - public async Task Send(List records, string send_type,ISqlSugarClient db=null) + public async Task Send(List records, string send_type,ISqlSugarClient db=null) { ThirdResult thirdResult = null; bool tranFlag = true; try { if (records == null || records.IsEmpty()) - return ""; + return new ThirdResult(); if (db == null) { @@ -272,9 +273,9 @@ namespace Tnb.BasicData Log.Error(e.Message,e); if(tranFlag) await db.Ado.RollbackTranAsync(); } - - return thirdResult.Code == 200 ? "成功" : "失败"; + + return thirdResult; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatOutstockH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatOutstockH.cs index 8d80aebe..6b3ccedd 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatOutstockH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsRawmatOutstockH.cs @@ -83,5 +83,19 @@ public partial class WmsRawmatOutstockH : BaseEntity /// 下发状态 /// public string? issuance_status { get; set; } + + /// + /// erp领出仓库 + /// + public string? erp_outstock { get; set; } + /// + /// erp领用仓库 + /// + public string? erp_instock { get; set; } + + /// + /// erp成本域 + /// + public string? erp_org_costregion { get; set; } = "1001A1100000001MNB3H"; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs index 7f02709d..5bbf8f19 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs @@ -488,10 +488,10 @@ namespace Tnb.WarehouseMgr //string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? WmsWareHouseConst.ERPUSERID; string erpCreateId = WmsWareHouseConst.ERPUSERID; List erpWarehouserelaHs = await _db.Queryable().Where(x => x.id != null).ToListAsync(); - BasWarehouse outWarehouse = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_outstock); - BasWarehouse inWarehouse = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_instock); - string inwhcode = inWarehouse?.whcode ?? ""; - string outwhcode = outWarehouse?.whcode ?? ""; + // BasWarehouse outWarehouse = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_outstock); + // BasWarehouse inWarehouse = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_instock); + // string inwhcode = inWarehouse?.whcode ?? ""; + // string outwhcode = outWarehouse?.whcode ?? ""; List> requestData = new List>(); @@ -504,11 +504,11 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("corpvid", erpOrg.corpoid); erpRequestData.Add("cothercalbodyoid", erpOrg.pk_org); // erpRequestData.Add("cotherwhid", erpExtendFields.Find(x => x.table_id == wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? ""); - erpRequestData.Add("cotherwhid", erpWarehouserelaHs.Find(x => x.wms_warehousecode == inwhcode)?.erp_warehouseid ?? ""); + erpRequestData.Add("cotherwhid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_instock)?.erp_warehouseid ?? ""); erpRequestData.Add("creationtime", nowStr); erpRequestData.Add("creator", erpCreateId); erpRequestData.Add("ctrantypeid", "0001H11000000000D31X"); - erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.wms_warehousecode == outwhcode)?.erp_warehouseid ?? ""); + erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_outstock)?.erp_warehouseid ?? ""); erpRequestData.Add("dbilldate", nowStr); erpRequestData.Add("dmakedate", nowStr); erpRequestData.Add("ntotalnum", wmsMaterialSignDs.Sum(r => r.sign_qty)); @@ -522,7 +522,7 @@ namespace Tnb.WarehouseMgr erpRequestDataDetails.Add(new Dictionary() { ["cbodytranstypecode"] = "4I-02", - ["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.wms_warehousecode == outwhcode)?.erp_warehouseid ?? "", + ["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_outstock)?.erp_warehouseid ?? "", ["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == wmsMaterialTransferd.material_id)?.cmaterialoid ?? "", ["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == wmsMaterialTransferd.material_id)?.cmaterialvid ?? "", ["corpoid"] = erpOrg.corpoid, @@ -562,7 +562,11 @@ namespace Tnb.WarehouseMgr BasFactoryConfig callErp2 = await _db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP); if(callErp2.value=="1"){ - await _thirdApiRecordService.Send(new List { thirdWebapiRecord }, "自动", _db); + ThirdResult thirdResult = await _thirdApiRecordService.Send(new List { thirdWebapiRecord }, "自动", _db); + if (thirdResult.Code!=200) + { + throw Oops.Bah(thirdResult.msgResult); + } } if (wmsMaterialTransfer.type == WmsWareHouseConst.MATERIALTRANSFER_JZGLRK_CODE @@ -638,7 +642,11 @@ namespace Tnb.WarehouseMgr Logger.LogInformation("【WmsMaterialSignHService ModifyAsync】同步其它入库单到erp成功"); if(callErp2.value=="1"){ - await _thirdApiRecordService.Send(new List { thirdWebapiRecord2 }, "自动", _db); + ThirdResult thirdResult = await _thirdApiRecordService.Send(new List { thirdWebapiRecord2 }, "自动", _db); + if (thirdResult.Code!=200) + { + throw Oops.Bah(thirdResult.msgResult); + } } } break; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index b8a27fe3..db93871f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -1205,10 +1205,10 @@ namespace Tnb.WarehouseMgr // string erpCreateId = erpExtendFields.Find(x => x.table_id == userId)?.user_id ?? WmsWareHouseConst.ERPUSERID; string erpCreateId = WmsWareHouseConst.ERPUSERID; List erpWarehouserelaHs = await _db.Queryable().Where(x => x.id != null).ToListAsync(); - BasWarehouse outWarehouse = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_outstock); - BasWarehouse inWarehouse = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_instock); - string inwhcode = inWarehouse?.whcode ?? ""; - string outwhcode = outWarehouse?.whcode ?? ""; + // BasWarehouse outWarehouse = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_outstock); + // BasWarehouse inWarehouse = await _db.Queryable().SingleAsync(x => x.id == wmsMaterialTransfer.warehouse_instock); + // string inwhcode = inWarehouse?.whcode ?? ""; + // string outwhcode = outWarehouse?.whcode ?? ""; List> requestData = new List>(); @@ -1221,11 +1221,11 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("corpvid", erpOrg.corpoid); erpRequestData.Add("cothercalbodyoid", erpOrg.pk_org); // erpRequestData.Add("cotherwhid", erpExtendFields.Find(x => x.table_id == wmsMaterialTransfer.warehouse_instock)?.cotherwhid ?? ""); - erpRequestData.Add("cotherwhid", erpWarehouserelaHs.Find(x => x.wms_warehousecode == inwhcode)?.erp_warehouseid ?? ""); + erpRequestData.Add("cotherwhid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_instock)?.erp_warehouseid ?? ""); erpRequestData.Add("creationtime", nowStr); erpRequestData.Add("creator", erpCreateId); erpRequestData.Add("ctrantypeid", "0001H11000000000D31X"); - erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.wms_warehousecode == outwhcode)?.erp_warehouseid ?? ""); + erpRequestData.Add("cwarehouseid", erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_outstock)?.erp_warehouseid ?? ""); erpRequestData.Add("dbilldate", nowStr); erpRequestData.Add("dmakedate", nowStr); erpRequestData.Add("ntotalnum", wmsCarryCodes.Sum(r => r.codeqty)); @@ -1239,7 +1239,7 @@ namespace Tnb.WarehouseMgr erpRequestDataDetails.Add(new Dictionary() { ["cbodytranstypecode"] = "4I-02", - ["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.wms_warehousecode == outwhcode)?.erp_warehouseid ?? "", + ["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.erp_warehousecode == wmsMaterialTransfer.erp_warehouse_outstock)?.erp_warehouseid ?? "", ["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == wmsMaterialTransferd.material_id)?.cmaterialoid ?? "", ["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == wmsMaterialTransferd.material_id)?.cmaterialvid ?? "", ["corpoid"] = erpOrg.corpoid, diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatOutstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatOutstockService.cs index 1fc4358f..21f29e23 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatOutstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatOutstockService.cs @@ -89,6 +89,7 @@ namespace Tnb.WarehouseMgr .Where(r => r.carry_id == input.wmsDistaskH.carry_id) .Where(r => r.material_id == wmsRawmatOutstockD.material_id && r.code_batch == wmsRawmatOutstockD.batchno) .ToListAsync(); + List supplierIds = wmsCarryCodes.Select(x => x.auxprop_gys).Distinct().ToList(); decimal qty = wmsCarryCodes.Sum(r => r.codeqty); @@ -96,7 +97,7 @@ namespace Tnb.WarehouseMgr List materialIds = wmsCarryCodes.Select(x => x.material_id).ToList(); List unitDatas = await _db.Queryable() .LeftJoin((x, y) => x.Id == y.DictionaryTypeId) - .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && unitCodes.Contains(y.EnCode)) + .Where((x, y) => x.EnCode == DictConst.MeasurementUnit && (unitCodes.Contains(y.EnCode) || unitCodes.Contains(y.Id))) .Select((x, y) => y) .ToListAsync(); @@ -107,11 +108,12 @@ namespace Tnb.WarehouseMgr .FirstAsync(); OrganizeEntity dept = await _db.Queryable().Where(x=>x.EnCode==wmsRawmatOutstockH.department).FirstAsync(); - string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID; + // string supplierId = WmsWareHouseConst.TIANYIGONGYINGSHANG_ID; List tableIds = new List(); tableIds.Add(WmsWareHouseConst.AdministratorOrgId); tableIds.AddRange(materialIds); - tableIds.Add(supplierId); + // tableIds.Add(supplierId); + tableIds.AddRange(supplierIds); tableIds.Add(dept?.Id); tableIds.Add(tranTypeDataEntity?.Id); tableIds.AddRange(unitDatas.Select(x => x.Id).ToList()); @@ -128,10 +130,11 @@ namespace Tnb.WarehouseMgr List> requestData = new List>(); Dictionary erpRequestData = new Dictionary(); erpRequestData.Add("billmaker", erpCreateId); - erpRequestData.Add("ccostdomainoid", null); + erpRequestData.Add("ccostdomainoid", wmsRawmatOutstockH.erp_org_costregion ?? "1001A1100000001MNB3H"); erpRequestData.Add("cdrawcalbodyoid", erpOrg.pk_org); erpRequestData.Add("cdrawcalbodyvid", erpOrg.pk_org_v); - // erpRequestData.Add("cdrawwarehouseid", null); + erpRequestData.Add("cdrawwarehouseid", wmsRawmatOutstockH.erp_instock); + erpRequestData.Add("cwarehouseid", wmsRawmatOutstockH.erp_outstock); erpRequestData.Add("cdptid", erpExtendFields.Find(x=>x.table_id==dept?.Id)?.cdptid ?? ""); erpRequestData.Add("cdptvid", erpExtendFields.Find(x=>x.table_id==dept?.Id)?.cdptvid ?? ""); erpRequestData.Add("cfanaceorgoid", erpOrg.corpoid); @@ -141,7 +144,6 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("creationtime", nowStr); erpRequestData.Add("creator", erpCreateId); erpRequestData.Add("ctrantypeid", erpExtendFields.Find(x=>x.table_id==tranTypeDataEntity?.Id)?.transaction_type_id ?? "");//先写死 - erpRequestData.Add("cwarehouseid", wmsErpWarehouserelaHs.Find(x=>x.wms_warehousecode==wmsRawmatOutstockH.warehouse_id)?.erp_warehouseid ?? ""); erpRequestData.Add("dbilldate", wmsRawmatOutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss")); erpRequestData.Add("dmakedate", nowStr); erpRequestData.Add("fbillflag", 2); @@ -160,14 +162,15 @@ namespace Tnb.WarehouseMgr erpRequestDataDetails.Add(new Dictionary() { ["cbodytranstypecode"] = wmsRawmatOutstockH.outstock_type, + ["cbodywarehouseid"] = wmsRawmatOutstockH.erp_outstock, ["cmaterialoid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialoid ?? "", ["cmaterialvid"] = erpExtendFields.Find(x => x.table_id == item.material_id)?.cmaterialvid ?? "", ["corpoid"] = erpOrg.corpoid, ["corpvid"] = erpOrg.corpvid, ["crowno"] = wmsRawmatOutstockD.lineno, - ["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id)?.Id ?? ""))?.cunitid ?? "", - ["cvendorid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_id ?? "", - ["cvendorvid"] = erpExtendFields.Find(x => x.table_id == supplierId)?.supplier_vid ?? "", + ["cunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == item.unit_id || x.Id==item.unit_id)?.Id ?? ""))?.cunitid ?? "", + ["cvendorid"] = erpExtendFields.Find((x=>x.table_id==item.auxprop_gys))?.supplier_id ?? "", + ["cvendorvid"] = erpExtendFields.Find((x=>x.table_id==item.auxprop_gys))?.supplier_vid ?? "", ["dbizdate"] = wmsRawmatOutstockH.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"), ["nshouldnum"] = item.codeqty, ["nnum"] = item.codeqty, @@ -186,10 +189,11 @@ namespace Tnb.WarehouseMgr thirdWebapiRecord.third_name = WmsWareHouseConst.BIP; thirdWebapiRecord.name = "材料出库单(自制)"; thirdWebapiRecord.method = "POST"; - thirdWebapiRecord.url = config.value + "uapws/rest/materialOut/self/save"; - // thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/transIn/save"; + // thirdWebapiRecord.url = config.value + "uapws/rest/materialOut/self/save"; + thirdWebapiRecord.url = WmsWareHouseConst.BIP_DOMAIN + "uapws/rest/materialOut/self/save"; thirdWebapiRecord.request_data = JsonConvert.SerializeObject(erpRequestData); thirdWebapiRecord.create_time = DateTime.Now; + thirdWebapiRecord.remark = $"材料出库wms_rawmat_outstock_h:{wmsRawmatOutstockH.bill_code}"; await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync(); BasFactoryConfig callErp = await _db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP);