From 5695f1eb41693f799de0c76efd22909df34ff6d0 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期五, 27 十二月 2024 21:27:30 +0800 Subject: [PATCH] 优化标准上下架逻辑 --- Tiger.Business.WMS/WMS_ITEM_Biz.cs | 63 +++++++++++++++++++++++++++++++ 1 files changed, 63 insertions(+), 0 deletions(-) diff --git a/Tiger.Business.WMS/WMS_ITEM_Biz.cs b/Tiger.Business.WMS/WMS_ITEM_Biz.cs index 3f5ae9e..db4265f 100644 --- a/Tiger.Business.WMS/WMS_ITEM_Biz.cs +++ b/Tiger.Business.WMS/WMS_ITEM_Biz.cs @@ -321,6 +321,7 @@ /// <returns></returns> public Result<TakeDownInfo> TakeDown(IInventory inventory, AuthOption option, WMS_ITEM.STATUSs status, bool clearLocation = true) { + return TakeDown(inventory, inventory.Items.ToDictionary(k => k.SN, v => v.QTY), option, status, clearLocation); var result = new Result<TakeDownInfo>(Result.Flags.Success, new TakeDownInfo()); try { @@ -358,6 +359,68 @@ } /// <summary> + /// 涓嬫灦 + /// </summary> + /// <param name="inventory">瑕佷笅鏋剁殑搴撳瓨瀵硅薄</param> + /// <param name="qtyList">瑕佷笅鏋剁殑鏈�灏忓寘瑁呮暟閲忓瓧鍏革紝key锛歴n锛寁alue锛歲ty</param> + /// <param name="option">鎺堟潈鏌ヨ閫夐」</param> + /// <param name="status">涓嬫灦鍚庣姸鎬�</param> + /// <param name="clearLocation">鏄惁娓呯悊鍌ㄥ尯璐ф灦鍌ㄤ綅淇℃伅</param> + /// <returns></returns> + public Result<TakeDownInfo> TakeDown(IInventory inventory, Dictionary<string, decimal> qtyList, AuthOption option, WMS_ITEM.STATUSs status, bool clearLocation = true) + { + var result = new Result<TakeDownInfo>(Result.Flags.Success, new TakeDownInfo()); + try + { + //濡傛灉瑕佷笅鏋剁殑鏁伴噺瀛楀吀涓虹┖鍒欒涓烘槸鍏ㄩ儴涓嬫灦 + qtyList = qtyList.IsNullOrEmpty(inventory.Items.ToDictionary(k => k.SN, v => v.QTY)); + + foreach (var item in inventory.Items) + { + if (qtyList.ContainsKey(item.SN) && qtyList[item.SN] > 0) + { + var downQty = qtyList[item.SN]; + if (item.QTY > downQty) + { + item.QTY -= downQty; + var pkg = inventory.Packages.First(q => q.SN == item.SN); + pkg.QTY = item.QTY; + } + else + { + item.STATUS = status.GetValue(); + var pkg = inventory.Packages.First(q => q.SN == item.SN); + pkg.PARENT_SN = null; + pkg.Parent = null; + if (clearLocation) + { + //item.WH_ID = null; + item.REGION_ID = null; + item.SHELF_ID = null; + item.LOCATION_ID = null; + //pkg.WH_ID = null; + pkg.REGION_ID = null; + pkg.SHELF_ID = null; + pkg.LOCATION_ID = null; + } + } + inventory.History.Add(new WMS_ITEM_HIS(item, $"鏉$爜[{inventory.SN}]浠庡偍浣峓{inventory?.Location?.LOCATION_CODE}]涓嬫灦鏁伴噺[{downQty}]鎴愬姛锛岀姸鎬乕{item.STATUS.GetEnumDesc<WMS_ITEM.STATUSs>()}]锛屾搷浣滃崟鎹甗{item.TRANS_NO}]")); + } + } + inventory.Packages = WMS_ITEM_PKG.UpdateQty(inventory.Packages); + + result.Data.Items = inventory.Items; + result.Data.History = inventory.History; + result.Data.Packages = inventory.Packages; + } + catch (Exception ex) + { + result.CatchExceptionWithLog(ex, Biz.L("WMS.WmsItem.TakeDown.Exception", inventory.SN, inventory?.Location?.LOCATION_CODE)); + } + return result; + } + + /// <summary> /// 涓嬫灦鐗╂枡鎺ㄨ崘锛岃繑鍥炲浐瀹氫釜鏁扮殑鏈�灏忓寘瑁呯墿鏂欏簱瀛樺垪琛� /// </summary> /// <param name="order">棰嗘枡鍗曞彿</param> -- Gitblit v1.9.3