diff --git a/BasicData/Tnb.BasicData.Entities/Dto/ErpReportDto.cs b/BasicData/Tnb.BasicData.Entities/Dto/ErpReportDto.cs new file mode 100644 index 00000000..0ec18610 --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Dto/ErpReportDto.cs @@ -0,0 +1,9 @@ +namespace Tnb.BasicData.Entities.Dto +{ + public class ErpReportDto + { + public string pk_wr { get; set; } + public string pk_wr_product { get; set; } + public string report_id { get; set; } + } +} \ No newline at end of file diff --git a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs index 92be7c92..c348f387 100644 --- a/BasicData/Tnb.BasicData/ThirdApiRecordService.cs +++ b/BasicData/Tnb.BasicData/ThirdApiRecordService.cs @@ -15,6 +15,7 @@ using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; using Tnb.BasicData.Entities.Dto; +using Tnb.ProductionMgr.Entities; namespace Tnb.BasicData { @@ -154,6 +155,45 @@ namespace Tnb.BasicData } } + if (thirdResult.Code == 200 && record.third_name == "BIP" && record.name == "生产报告") + { + Dictionary requestData = JsonConvert.DeserializeObject>(record.request_data); + + string reportId = requestData.ContainsKey("report_id") ? requestData["report_id"].ToString() : ""; + if (string.IsNullOrEmpty(reportId)) + { + Log.Error($"请求记录id{record.id}生产报告提报id为空"); + } + + JObject data = (JObject)thirdResult.msg; + JToken children = data.SelectToken("children")[0]; + var responsetDtos = children.Select(x => new ErpReportDto() + { + pk_wr_product = x["valueIndex"]["pk_wr_product"].ToString(), + pk_wr = x["valueIndex"]["pk_wr"].ToString(), + report_id = reportId + }).ToList(); + + int updateRow = 0; + foreach (var item in responsetDtos) + { + if (!string.IsNullOrEmpty(item.pk_wr) && !string.IsNullOrEmpty(item.pk_wr_product)) + { + updateRow += await db.Updateable() + .SetColumns(x => x.erp_pk_wr == item.pk_wr) + .SetColumns(x => x.erp_pk_wr_product == item.pk_wr_product) + .Where(x => x.id == item.report_id) + .ExecuteCommandAsync(); + } + } + + + if (updateRow <= 0) + { + Log.Error($"请求记录{record.id}更新失败"); + } + } + await db.Ado.CommitTranAsync(); } catch (Exception e) diff --git a/BasicData/Tnb.BasicData/Tnb.BasicData.csproj b/BasicData/Tnb.BasicData/Tnb.BasicData.csproj index 349cdb7c..43fe244f 100644 --- a/BasicData/Tnb.BasicData/Tnb.BasicData.csproj +++ b/BasicData/Tnb.BasicData/Tnb.BasicData.csproj @@ -10,6 +10,7 @@ + diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs index 3b411656..3500a358 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs @@ -159,5 +159,14 @@ public partial class PrdReport : BaseEntity /// 质检结果 /// public string check_result { get; set; } + + /// + /// 表头主键 + /// + public string erp_pk_wr { get; set; } + /// + /// 表体主键 + /// + public string erp_pk_wr_product { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 4cbb8a90..83ebe8fc 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2481,6 +2481,7 @@ namespace Tnb.ProductionMgr erpRequestData.Add("vtrantypeid","0001A11000000002LVX8"); erpRequestData.Add("vdef1",null); erpRequestData.Add("vdef2",null); + erpRequestData.Add("report_id",report.id); List> erpRequestDataDetails = new List>(); diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index ed2a305e..9fd8f8d0 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -823,6 +823,45 @@ namespace Tnb.ProductionMgr } } + if (thirdResult.Code == 200 && record.third_name == "BIP" && record.name == "生产报告") + { + Dictionary requestData = JsonConvert.DeserializeObject>(record.request_data); + + string reportId = requestData.ContainsKey("report_id") ? requestData["report_id"].ToString() : ""; + if (string.IsNullOrEmpty(reportId)) + { + Log.Error($"请求记录id{record.id}生产报告提报id为空"); + } + + JObject data = (JObject)thirdResult.msg; + JToken children = data.SelectToken("children")[0]; + var responsetDtos = children.Select(x => new ErpReportDto() + { + pk_wr_product = x["valueIndex"]["pk_wr_product"].ToString(), + pk_wr = x["valueIndex"]["pk_wr"].ToString(), + report_id = reportId + }).ToList(); + + int updateRow = 0; + foreach (var item in responsetDtos) + { + if (!string.IsNullOrEmpty(item.pk_wr) && !string.IsNullOrEmpty(item.pk_wr_product)) + { + updateRow += await _db.Updateable() + .SetColumns(x => x.erp_pk_wr == item.pk_wr) + .SetColumns(x => x.erp_pk_wr_product == item.pk_wr_product) + .Where(x => x.id == item.report_id) + .ExecuteCommandAsync(); + } + } + + + if (updateRow <= 0) + { + Log.Error($"请求记录{record.id}更新失败"); + } + } + } await _db.Ado.CommitTranAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs index e050eaf0..67188b14 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialSignHService.cs @@ -272,7 +272,7 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("cdptvid","0001A11000000007GGO8");//部门先写死 erpRequestData.Add("corpoid", erpOrg.corpoid); erpRequestData.Add("corpvid", erpOrg.corpvid); - erpRequestData.Add("cotherwhid", wmsErpWarehouserelaHs.Find(x=>x.wms_warehousecode==wmsRawmatTransferoutstockD.warehouse_instock_code)?.erp_warehouseid ?? ""); + erpRequestData.Add("cotherwhid", wmsRawmatTransferoutstockD.warehouse_instock_code); erpRequestData.Add("cwarehouseid", wmsErpWarehouserelaHs.Find(x=>x.erp_warehousecode==wmsRawmatTransferoutstockD.erp_wh_type)?.erp_warehouseid ?? ""); erpRequestData.Add("creationtime", nowStr); erpRequestData.Add("creator", erpCreateId); @@ -297,7 +297,7 @@ namespace Tnb.WarehouseMgr erpRequestDataDetails.Add(new Dictionary() { ["cbodytranstypecode"] = "4Y-01", - ["cbodywarehouseid"] = erpWarehouserelaHs.Find(x => x.wms_warehousecode==wmsRawmatTransferoutstockD.warehouse_instock_code)?.erp_warehouseid ?? "", + ["cbodywarehouseid"] = wmsRawmatTransferoutstockD.warehouse_instock_code, ["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, diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs index 37355a59..9303fbf3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdInstockHService.cs @@ -349,7 +349,8 @@ namespace Tnb.WarehouseMgr WmsPrdInstockH instock = await _db.Queryable().SingleAsync(x=>x.id==wmsPrdInstockD.prd_instock_id); BasWarehouse scWarehouse = await _db.Queryable().SingleAsync(x=>x.id==wmsPrdInstockD.scwarehouse_id); BasWarehouse kcWarehouse = await _db.Queryable().SingleAsync(x=>x.id==wmsPrdInstockD.warehouse_id); - //todo 产成品入库 + PrdReport prdReport = await _db.Queryable().SingleAsync(x => x.id == instock.prd_report_id); + List allInstockDetails = await _db.Queryable().Where(it => it.prd_instock_id == instock.id).ToListAsync(); List materialIds = Arrays.AsList(instock.material_id); @@ -397,7 +398,7 @@ namespace Tnb.WarehouseMgr erpRequestData.Add("pk_group", erpOrg.pk_group); erpRequestData.Add("vbillcode", instock.bill_code); erpRequestData.Add("vtrantypecode", "46-01"); - erpRequestData.Add("csourcebillhid", "");//todo 后面填 + erpRequestData.Add("csourcebillhid", prdReport?.erp_pk_wr ?? "");//todo 后面填 List> erpRequestDataDetails = new List>(); @@ -414,8 +415,8 @@ namespace Tnb.WarehouseMgr ["cproductid"] = erpExtendFields.Find(x => x.table_id == instock.material_id)?.cmaterialoid ?? "", ["fproductclass"] = 1, ["crowno"] = (allInstockDetails.FindIndex(x => x.id == item.id) + 1) * 10, - ["csourcebillhid"] = "", - ["csourcebillbid"] = "", + ["csourcebillhid"] = prdReport?.erp_pk_wr ?? "", + ["csourcebillbid"] = prdReport?.erp_pk_wr_product ?? "", ["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 ?? "",