From afb978473576768ae60e20c389c0c434eeef22a8 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 12 Jul 2023 14:05:31 +0800 Subject: [PATCH] =?UTF-8?q?mes->wms=E5=85=A5=E5=BA=93=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/WmsWareHouseConst.cs | 1 + .../Dto/Inputs/MESCreateInstockInput.cs | 2 +- .../Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj | 1 + .../Tnb.WarehouseMgr/WareHouseService.cs | 1 + .../Tnb.WarehouseMgr/WmsInStockService.cs | 26 ++++++++++++++----- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index 1e0c4ff8..b2506920 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -242,5 +242,6 @@ namespace Tnb.WarehouseMgr.Entities.Consts + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/MESCreateInstockInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/MESCreateInstockInput.cs index bffe960a..74fcb491 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/MESCreateInstockInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/MESCreateInstockInput.cs @@ -127,7 +127,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto.Inputs /// /// 条码编号 /// - public int barcode_qty { get; set; } + public int codeqty { get; set; } /// /// 批次 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj b/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj index b70c9cce..11628acf 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj +++ b/WarehouseMgr/Tnb.WarehouseMgr/Tnb.WarehouseMgr.csproj @@ -10,6 +10,7 @@ + diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 010e52b9..214f946a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -576,6 +576,7 @@ namespace Tnb.WarehouseMgr catch (Exception) { await _db.Ado.RollbackTranAsync(); + throw; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 35b2aa13..921be7b4 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -20,6 +20,7 @@ using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.Common.Utils; +using Tnb.ProductionMgr.Interfaces; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; @@ -42,13 +43,15 @@ namespace Tnb.WarehouseMgr private readonly IUserManager _userManager; private readonly IWareHouseService _wareHouseService; private readonly IBillRullService _billRullService; + private readonly IPrdInstockService _prdInstockService; private static Dictionary _dicBillCodes = new(); public WmsInStockService( ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, IUserManager userManager, IBillRullService billRullService, - IWareHouseService wareHouseService + IWareHouseService wareHouseService, + IPrdInstockService prdInstockService ) { _db = repository.AsSugarClient(); @@ -56,6 +59,7 @@ namespace Tnb.WarehouseMgr _userManager = userManager; _billRullService = billRullService; _wareHouseService = wareHouseService; + _prdInstockService = prdInstockService; } /// /// 根据入库申请单ID获取申请单明细信息 @@ -215,17 +219,27 @@ namespace Tnb.WarehouseMgr } } await _db.Updateable(instockDetails).ExecuteCommandAsync(); + var instock = await _db.Queryable().SingleAsync(it => it.id == input.requireId); + if (instock.IsNull()) ArgumentNullException.ThrowIfNull(nameof(instock)); + if (instock?.sync_status != WmsWareHouseConst.SYNC_STATUS_NONEEDSYNC) + { + //如果是自动单据,需要回更上层系统 + Dictionary pars = new() { { nameof(WmsInstockH.source_id), instock!.source_id } }; + var callBackRes = await _prdInstockService.SyncInstock(pars); + instock.sync_status = callBackRes == true ? WmsWareHouseConst.SYNC_STATUS__SYNCCOMPLETE : WmsWareHouseConst.SYNC_STATUS__SYNCFAILED; + await _db.Updateable(instock).UpdateColumns(it => it.sync_status).ExecuteCommandAsync(); + } var allInstockDetails = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) { - await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); - //如果是自动单据,需要回更上层系统 + instock.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; } else { //任务没有结束,更新状态为工作中 - await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync(); + instock.status = WmsWareHouseConst.BILLSTATUS_ON_ID; } + await _db.Updateable(instock).UpdateColumns(it => it.status).ExecuteCommandAsync(); } await _db.Ado.CommitTranAsync(); @@ -293,7 +307,6 @@ namespace Tnb.WarehouseMgr foreach (var instockcode in instockcodes!) { instockcode.id = SnowflakeIdHelper.NextId(); - var materialId = instockcode.material_id; var materialCode = instockcode.material_code; var codeBatch = instockcode.code_batch; var b = items.Find(x => x.material_code == materialCode && x.code_batch == codeBatch); @@ -301,7 +314,7 @@ namespace Tnb.WarehouseMgr { var c = DeepCopyHelper.DeepCopy(b); c.id = SnowflakeIdHelper.NextId(); - c.bill_d_id = instockcodes.Find(x => x.material_code == materialCode && x.code_batch == codeBatch)?.id!; + c.bill_d_id = instockds?.Find(x => x.material_code == materialCode && x.code_batch == codeBatch)?.id ?? ""; c.barcode = instockcode.barcode; c.codeqty = instockcode.codeqty; c.is_end = 0;// 未结束 @@ -432,7 +445,6 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCOdes.Select(x => x.bill_d_id).Contains(it.id)).ExecuteCommandAsync(); await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync(); } - } } }