From 9ee80fe00f1a7c13d4a3810234b64fbbb6506012 Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Mon, 6 Nov 2023 16:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=AD=E7=AE=A1=E6=8C=A4=E5=87=BA=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IPrdInstockService.cs | 8 ++ .../Tnb.ProductionMgr/PrdInstockService.cs | 110 ++++++++++++++++++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 24 ++-- 3 files changed, 135 insertions(+), 7 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs index 5cca73d3..9f0cb544 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdInstockService.cs @@ -1,3 +1,4 @@ +using Tnb.ProductionMgr.Entities; using Tnb.ProductionMgr.Entities.Dto; namespace Tnb.ProductionMgr.Interfaces @@ -28,5 +29,12 @@ namespace Tnb.ProductionMgr.Interfaces /// /// public Task InstockTypeOne(InstockInput inut); + + /// + /// 短管挤出入库申请 + /// + /// + /// + public Task InstockTubeOne(PrdReport prdReport); } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs index a854e8d2..0ae748de 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdInstockService.cs @@ -389,5 +389,115 @@ namespace Tnb.ProductionMgr if(!result2.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); return result2.IsSuccess ? "申请成功" : result2.ErrorMessage; } + + [HttpPost] + public async Task InstockTubeOne(PrdReport prdReport) + { + var db = _repository.AsSugarClient(); + string location_code = "JMXHC-01"; + string warehouse_id = "26103348825381"; + + PrdInstockH prdInstockH = null; + List prdInstockDs = new List() { }; + DbResult result2 = new DbResult(); + BasMaterial basMaterial = await db.Queryable().SingleAsync(x=>x.id==prdReport.material_id); + DbResult result = await db.Ado.UseTranAsync(async () => + { + OrganizeEntity workline = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorklineCode); + OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(prdReport.station, DictConst.RegionCategoryWorkshopCode); + + prdInstockH = new PrdInstockH() + { + bill_type = DictConst.CHANCHENGPINRUKUDAN, + bill_date = DateTime.Now, + create_id = _userManager.UserId, + 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, + warehouse_id = warehouse_id, + status = 0, + }; + + prdInstockDs.Add(new PrdInstockD() + { + instock_id = prdInstockH.id, + report_id = prdReport.create_id, + material_id = prdReport.material_id, + material_code = basMaterial.code, + unit_id = prdReport.unit_id, + barcode = prdReport.barcode, + code_batch = prdReport.barcode+"0001", + quantity = (int)prdReport.reported_qty, + }); + }); + + if (result.IsSuccess) + { + MESCreateInstockInput mesCreateInstockInput = new MESCreateInstockInput(); + mesCreateInstockInput.instock = new MESWmsInstockHInput() + { + org_id = _userManager.GetUserInfo().Result.organizeId, + bill_date = DateTime.Now, + bill_type = DictConst.CHANCHENGPINRUKUDAN, + warehouse_id = warehouse_id, + source_id = prdInstockH.id, + create_id = _userManager.UserId, + carry_code = prdReport.material_box_code, + location_code = location_code, + is_check = 1, + }; + mesCreateInstockInput.instockds = new List(); + mesCreateInstockInput.instockcodes = new List(); + mesCreateInstockInput.instockds.Add(new MESWmsInstockDInput() + { + material_id = prdReport.material_id, + material_code = basMaterial.code, + unit_id = prdReport.unit_id, + code_batch = prdReport.barcode, + pr_qty = (int)prdReport.reported_qty, + }); + + mesCreateInstockInput.instockcodes.Add(new MESWmsInstockCodeInput() + { + material_id = prdReport.material_id, + material_code = basMaterial.code, + unit_id = prdReport.unit_id, + barcode = prdReport.barcode, + code_batch = prdReport.barcode+"0001", + codeqty = (int)prdReport.reported_qty, + }); + string domain = (App.HttpContext.Request.IsHttps ? "https://" : "http://") + App.HttpContext.Request.Host; + Dictionary header = new Dictionary() + { + ["Authorization"] = App.HttpContext.Request.Headers["Authorization"] + }; + var sendResult = HttpUtils.RequestPost(domain + WebApiConst.MES_CREATE_INSTOCK,JsonConvert.SerializeObject(mesCreateInstockInput),header); + Log.Information(sendResult); + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if (authResponse.code != 200 || !authResponse.data.ObjToBool()) + { + throw Oops.Bah(authResponse.msg); + } + else + { + result2 = await db.Ado.UseTranAsync(async () => + { + await _repository.InsertAsync(prdInstockH); + + if (prdInstockDs.Count > 0) + { + await db.Insertable(prdInstockDs).ExecuteCommandAsync(); + } + }); + + } + } + + return result2.IsSuccess ? "true" : "false"; + } } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 5d9d1af0..1a02c437 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -70,6 +70,7 @@ namespace Tnb.ProductionMgr private static Dictionary _dicProcess = new Dictionary(); private readonly ISqlSugarClient _db; private readonly IBillRullService _billRuleService; + private readonly IPrdInstockService _prdInstockService; private readonly IQcCheckPlanService _qcCheckPlanService; public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); @@ -79,6 +80,7 @@ namespace Tnb.ProductionMgr IDictionaryDataService dictionaryDataService, IRunService runService, IBillRullService billRullService, + IPrdInstockService prdInstockService, IVisualDevService visualDevService, IQcCheckPlanService qcCheckPlanService ) @@ -92,6 +94,7 @@ namespace Tnb.ProductionMgr OverideFuncs.DeleteAsync = Delete; OverideFuncs.GetListAsync = GetList; _billRuleService = billRullService; + _prdInstockService = prdInstockService; _qcCheckPlanService=qcCheckPlanService; } @@ -1442,12 +1445,12 @@ namespace Tnb.ProductionMgr public async Task PrdReport(PrdReportCrInput input) { var db = _repository.AsSugarClient(); + var prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); + var equip = await db.Queryable().SingleAsync(x=>x.id==prdMoTask.eqp_id); + var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id); DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () => { var row = -1; - var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id); - var prdMoTask = await db.Queryable().SingleAsync(x => x.id == input.mo_task_id); - var equip = await db.Queryable().SingleAsync(x=>x.id==prdMoTask.eqp_id); var prdMo = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mo_id); var mbomProcess = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mbom_process_id); @@ -1725,13 +1728,20 @@ namespace Tnb.ProductionMgr // } // } - if (equip.tube == "1") - { - - } + }); + if (result.IsSuccess) + { + if (equip.tube == "1") + { + string resultMsg = await _prdInstockService.InstockTubeOne(report); + if (resultMsg == "true") return true; + throw Oops.Bah(resultMsg); + } + } + if (!result.IsSuccess) throw Oops.Bah(result.ErrorMessage); return result.IsSuccess; }