From 6d3c288e1ee74725b4c6c595e6880114a537dd04 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Thu, 23 Nov 2023 09:36:17 +0800 Subject: [PATCH] 1 --- .../Tnb.ProductionMgr/PrdInstockService.cs | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index 047513d0..dcd9a6e6 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -317,6 +317,7 @@ namespace Tnb.ProductionMgr throw Oops.Bah("未找到提报记录"); } + PrdInstockH? prdInstockH = null; List prdInstockDs = new() { }; DbResult result2 = new(); @@ -432,6 +433,9 @@ namespace Tnb.ProductionMgr List prdInstockDs = new() { }; DbResult result2 = new(); BasMaterial basMaterial = await db.Queryable().SingleAsync(x => x.id == prdReport.material_id); + string create_id = prdReport.create_id; + UserEntity user = await db.Queryable().SingleAsync(x => x.Id == create_id); + string org_id = user.OrganizeId; DbResult result = await db.Ado.UseTranAsync(async () => { OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode); @@ -441,14 +445,14 @@ namespace Tnb.ProductionMgr { bill_type = DictConst.CHANCHENGPINRUKUDAN, bill_date = DateTime.Now, - create_id = _userManager.UserId, + create_id = create_id, location_code = location_code, carry_code = prdReport.material_box_code, is_check = 1, station_id = prdReport.station, workline_id = workline?.Id ?? "", workshop_id = workshop?.Id ?? "", - org_id = _userManager.GetUserInfo().Result.organizeId, + org_id = org_id, warehouse_id = warehouse_id, status = 0, }; @@ -461,7 +465,7 @@ namespace Tnb.ProductionMgr material_code = basMaterial.code, unit_id = prdReport.unit_id, barcode = prdReport.barcode, - code_batch = prdReport.barcode + "0001", + code_batch = prdReport.mo_task_code, quantity = (int)prdReport.reported_qty, }); }); @@ -472,12 +476,12 @@ namespace Tnb.ProductionMgr { instock = new MESWmsInstockHInput() { - org_id = _userManager.GetUserInfo().Result.organizeId, + org_id = org_id, bill_date = DateTime.Now, bill_type = DictConst.CHANCHENGPINRUKUDAN, warehouse_id = warehouse_id, source_id = prdInstockH.id, - create_id = _userManager.UserId, + create_id = create_id, carry_code = prdReport.material_box_code, location_code = location_code, is_check = 1, @@ -500,19 +504,19 @@ namespace Tnb.ProductionMgr material_code = basMaterial.code, unit_id = prdReport.unit_id, barcode = prdReport.barcode, - code_batch = prdReport.barcode + "0001", + code_batch = prdReport.mo_task_code, codeqty = (int)prdReport.reported_qty, }); // string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; string domain = "http://tnb.tuotong-tech.com"; Dictionary header = new() { - ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + // ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] }; string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header); Log.Information(sendResult); AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); - result2 = authResponse.code != 200 || !authResponse.data.ObjToBool() + result2 = authResponse.code != 200 || !(bool)authResponse.data ? throw Oops.Bah(authResponse.msg) : await db.Ado.UseTranAsync(async () => { @@ -543,6 +547,9 @@ namespace Tnb.ProductionMgr List prdInstockDs = new() { }; DbResult result2 = new(); BasMaterial basMaterial = await db.Queryable().SingleAsync(x => x.id == prdReport.material_id); + string create_id = prdReport.create_id; + UserEntity user = await db.Queryable().SingleAsync(x => x.Id == create_id); + string org_id = user.OrganizeId; DbResult result = await db.Ado.UseTranAsync(async () => { OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode); @@ -552,14 +559,14 @@ namespace Tnb.ProductionMgr { bill_type = DictConst.CHANCHENGPINRUKUDAN, bill_date = DateTime.Now, - create_id = _userManager.UserId, + create_id = create_id, location_code = location_code, carry_code = prdReport.material_box_code, is_check = 1, station_id = prdReport.station, workline_id = workline?.Id ?? "", workshop_id = workshop?.Id ?? "", - org_id = _userManager.GetUserInfo().Result.organizeId, + org_id = org_id, warehouse_id = warehouse_id, status = 0, }; @@ -572,7 +579,7 @@ namespace Tnb.ProductionMgr material_code = basMaterial.code, unit_id = prdReport.unit_id, barcode = prdReport.barcode, - code_batch = prdReport.barcode + "0001", + code_batch = prdReport.mo_task_code, quantity = (int)prdReport.reported_qty, }); }); @@ -583,12 +590,12 @@ namespace Tnb.ProductionMgr { instock = new MESWmsInstockHInput() { - org_id = _userManager.GetUserInfo().Result.organizeId, + org_id = org_id, bill_date = DateTime.Now, bill_type = DictConst.CHANCHENGPINRUKUDAN, warehouse_id = warehouse_id, source_id = prdInstockH.id, - create_id = _userManager.UserId, + create_id = create_id, carry_code = prdReport.material_box_code, location_code = location_code, is_check = 1, @@ -601,7 +608,7 @@ namespace Tnb.ProductionMgr material_id = prdReport.material_id, material_code = basMaterial.code, unit_id = prdReport.unit_id, - code_batch = prdReport.barcode, + code_batch = prdReport.mo_task_code, pr_qty = (int)prdReport.reported_qty, }); @@ -611,19 +618,19 @@ namespace Tnb.ProductionMgr material_code = basMaterial.code, unit_id = prdReport.unit_id, barcode = prdReport.barcode, - code_batch = prdReport.barcode + "0001", + code_batch = prdReport.mo_task_code, codeqty = (int)prdReport.reported_qty, }); // string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; string domain = "http://tnb.tuotong-tech.com"; Dictionary header = new() { - ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + // ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] }; string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header); Log.Information(sendResult); AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); - result2 = authResponse.code != 200 || !authResponse.data.ObjToBool() + result2 = authResponse.code != 200 || !(bool)authResponse.data ? throw Oops.Bah(authResponse.msg) : await db.Ado.UseTranAsync(async () => { @@ -708,10 +715,14 @@ namespace Tnb.ProductionMgr List prdReports = await db.Queryable().Where(x => reportIds.Contains(x.id)).ToListAsync(); + if (prdReports == null || prdReports.Count<=0) { throw Oops.Bah("未找到提报记录"); } + string create_id = prdReports[0].create_id; + UserEntity user = await db.Queryable().SingleAsync(x => x.Id == create_id); + string org_id = user.OrganizeId; PrdInstockH? prdInstockH = null; List prdInstockDs = new() { }; @@ -727,14 +738,14 @@ namespace Tnb.ProductionMgr { bill_type = DictConst.CHANCHENGPINRUKUDAN, bill_date = DateTime.Now, - create_id = _userManager.UserId, + create_id = create_id, location_code = basLocation.location_code, carry_code = prdOutPacking.code, is_check = 1, station_id = station.Id, workline_id = workline?.Id ?? "", workshop_id = workshop?.Id ?? "", - org_id = _userManager.GetUserInfo().Result.organizeId, + org_id = org_id, // warehouse_id = basLocation?.wh_id, warehouse_id = warehouse_id, status = 0, @@ -750,7 +761,7 @@ namespace Tnb.ProductionMgr material_code = basMaterial.code, unit_id = prdReport.unit_id, barcode = prdReport.barcode, - code_batch = prdReport.barcode + "0001", + code_batch = prdReport.mo_task_code, quantity = (int)prdReport.reported_qty, }); } @@ -762,13 +773,13 @@ namespace Tnb.ProductionMgr { instock = new MESWmsInstockHInput() { - org_id = _userManager.GetUserInfo().Result.organizeId, + org_id = org_id, bill_date = DateTime.Now, bill_type = DictConst.CHANCHENGPINRUKUDAN, // warehouse_id = basLocation?.wh_id, warehouse_id = warehouse_id, source_id = prdInstockH.id, - create_id = _userManager.UserId, + create_id = create_id, carry_code = prdOutPacking.code, location_code = basLocation.location_code, is_check = 1, @@ -784,7 +795,7 @@ namespace Tnb.ProductionMgr material_id = prdReport.material_id, material_code = basMaterial.code, unit_id = prdReport.unit_id, - code_batch = prdReport.barcode, + code_batch = prdReport.mo_task_code, pr_qty = (int)prdReport.reported_qty, }); @@ -794,7 +805,7 @@ namespace Tnb.ProductionMgr material_code = basMaterial.code, unit_id = prdReport.unit_id, barcode = prdReport.barcode, - code_batch = prdReport.barcode + "0001", + code_batch = prdReport.mo_task_code, codeqty = (int)prdReport.reported_qty, }); } @@ -803,12 +814,12 @@ namespace Tnb.ProductionMgr string domain = "http://tnb.tuotong-tech.com"; Dictionary header = new() { - ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + // ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] }; string sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK, JsonConvert.SerializeObject(mesCreateInstockInput), header); Log.Information(sendResult); AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); - result2 = authResponse.code != 200 || !authResponse.data.ObjToBool() + result2 = authResponse.code != 200 || !(bool)authResponse.data ? throw Oops.Bah(authResponse.msg) : await db.Ado.UseTranAsync(async () => {