From 36746596927952a6b860129a62eec9059bf083a7 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期六, 26 四月 2025 18:06:27 +0800 Subject: [PATCH] 优化了备料逻辑 --- Tiger.Business.WMS/Transaction/In_Default.cs | 83 ++++++++++++++++++++++------------------- 1 files changed, 45 insertions(+), 38 deletions(-) diff --git a/Tiger.Business.WMS/Transaction/In_Default.cs b/Tiger.Business.WMS/Transaction/In_Default.cs index 9f0f1cd..cb890a6 100644 --- a/Tiger.Business.WMS/Transaction/In_Default.cs +++ b/Tiger.Business.WMS/Transaction/In_Default.cs @@ -13,6 +13,8 @@ using Tiger.Business.WMS.Sharetronic.Shelf; //using Microsoft.IdentityModel.Tokens; using Tiger.Model.MES.Yada; +using static IronPython.Modules.PythonThread; +using Tiger.Model.Entitys.MES.Position; namespace Tiger.Business.WMS.Transaction { @@ -63,7 +65,7 @@ catch (Exception ex) { //鍙栨秷褰撳墠鎿嶄綔 - ResetScan(); + ResetTrans(); //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]寮傚父"); action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN)); } @@ -81,13 +83,13 @@ if (CurInvItem.IsNullOrEmpty()) { //瑙f瀽鏉$爜 - Result<IInventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true); + Result<IInventory> result = GetInventory(input.SN, input.AuthOption, true); if (!result.IsSuccessed) { action.IsSuccessed = false; action.LocaleMsg = result.LocaleMsg; - return action; - } + return SetOutPutMqttMsg(action, input.Locale); + } var inv = result.Data as Inventory; //楠岃瘉鏉$爜鏄惁姝g‘ @@ -96,7 +98,7 @@ action.IsSuccessed = false; //action.LocaleMsg = Biz.L("鐘舵�乕{0}]寮傚父锛岃閲嶆柊鎵弿"); action.LocaleMsg = Biz.L("WMS.Default.ScanItem.StatusException", string.Join(',', inv.StatusList.Select(q => q.GetDesc()))); - return action; + return SetOutPutMqttMsg(action, input.Locale); } //鐗╂枡楠岃瘉 if (inv.ItemInfo.IsNullOrEmpty() || inv.ItemInfo.IS_ACTIVE == "N") @@ -104,16 +106,12 @@ action.IsSuccessed = false; //action.LocaleMsg = Biz.L("鐗╂枡缂栫爜[{0}]涓嶅瓨鍦ㄦ垨鑰呰鐗╂枡鏈惎鐢�"); action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ItemCodeNotExistsOrNotActive", inv.ItemInfo?.ITEM_CODE.IsNullOrEmpty(inv.Barcode.ItemCode)); - return action; + return SetOutPutMqttMsg(action, input.Locale); } if (inv.Items.Count == 0) { - List<WMS_ITEM_HIS> ItemHistorys = new List<WMS_ITEM_HIS>(); - WMS_ITEM Item; - WMS_ITEM_PKG ItemPkgs; - - Item = new() + var newItem = new WMS_ITEM() { SN = inv.Barcode.SN, ITEM_CODE = inv.Barcode.ItemCode, @@ -125,9 +123,8 @@ UNIT = inv.Barcode.Unit, }; - WMS_ITEM_HIS his = new(Item, $"鏍囧噯涓婃灦鍏ュ簱"); - ItemHistorys.Add(his); - ItemPkgs = new() + WMS_ITEM_HIS his = new(newItem, $"鏍囧噯涓婃灦鍏ュ簱"); + var newPkg = new WMS_ITEM_PKG() { SN = inv.Barcode.SN, AUTH_ORG = input.AuthOption.CurOrg, @@ -139,19 +136,19 @@ var noExt = inv.Items.Where(q => !inv.ItemsExt.Any(s => s.SN == q.SN)).ToList(); //鎵╁睍琛ㄤ笉瀛樺湪鏃舵柊寤� - foreach (var item in noExt) + foreach (var ext in noExt) { inv.ItemsExt.Add(new() { - SN = item.SN, + SN = ext.SN, META_SN = inv.Barcode.MetaSn, QR_CODE = inv.Barcode.MetaSn }); } - inv.Items.Add(Item); + inv.Items.Add(newItem); inv.History.Add(his); - inv.Packages.Add(ItemPkgs); + inv.Packages.Add(newPkg); } //闆呰揪涓嶄粠鏉$爜涓婃洿鏂版暟閲� //else if (inv.Items.Count == 1) @@ -188,13 +185,13 @@ { var item = CurInvItem.Items.First(q => q.SN == qty.Code); item.QTY = qty.WhQty; - item.SUPP_LOTNO = qty.Segment7; + item.SUPP_LOTNO = CurInvItem.Barcode.LotNo; } action.Data.Data = CurInvItem.Items.Select(q => new { q.SN, q.QTY }); action.Data.Command = Command = "ComfirmQty"; //action.LocaleMsg = Biz.L("璇风‘璁ゆ潯鐮乕{0}]鐨勬暟閲忔槸鍚︽纭�"); action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ComfirmQty", input.SN); - return action; + return SetOutPutMqttMsg(action, input.Locale); } } @@ -208,8 +205,8 @@ action.Data.Data = CurInvItem.Items.Select(q => new { q.SN, q.QTY }); action.Data.Command = Command = "ComfirmQty"; //action.LocaleMsg = Biz.L("鏁伴噺涓嶈兘灏忎簬绛変簬闆讹紝璇烽噸鏂扮‘璁ゆ潯鐮乕{0}]鐨勬暟閲�"); - action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmQty", input.SN); - return action; + action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmQty", input.SN); + return SetOutPutMqttMsg(action, input.Locale); } else { @@ -235,7 +232,7 @@ { action.IsSuccessed = false; action.LocaleMsg = Biz.L(shelfApiResult.GetData<string>()); - return action; + return SetOutPutMqttMsg(action, input.Locale); } var reaultShelf = shelfApiResult.GetData<ShelfChangeModel>(); @@ -245,7 +242,7 @@ action.IsSuccessed = false; //action.LocaleMsg = Biz.L($"璐ф灦[{0}]涓笉瀛樺湪id涓篬{1}]鐨勫偍浣嶏紝璇峰厛缁存姢璐ф灦淇℃伅"); action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationNotExistsInShelf", CurScanShelf.Shelf.SHELF_CODE, reaultShelf.ledAddr); - return action; + return SetOutPutMqttMsg(action, input.Locale); } var locationData = MainDB.Queryable<WMS_ITEM>().Where(q => q.LOCATION_ID == nLocation.ID).First(); if (!locationData.IsNullOrEmpty()) @@ -253,7 +250,7 @@ action.IsSuccessed = false; //action.LocaleMsg = Biz.L("鍌ㄤ綅[{0}]宸插瓨鏈夌墿鏂橻{1}]锛岃妫�鏌ョ郴缁熷簱瀛樹俊鎭�"); action.LocaleMsg = Biz.L($"WMS.Default.ScanShelf.ItemAlreadyExistsInLocation", nLocation.LOCATION_CODE, locationData.SN); - return action; + return SetOutPutMqttMsg(action, input.Locale); } CurScanShelf.LocationCode = nLocation.LOCATION_CODE; } @@ -264,7 +261,7 @@ action.IsSuccessed = false; //action.LocaleMsg = Biz.L("璇疯緭鍏ユ垨鎵弿鏈夋晥鐨勮揣鏋�/鍌ㄤ綅鐮�"); action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ShelfCanNotEmpty"); - return action; + return SetOutPutMqttMsg(action, input.Locale); } nLocation = await MainDB.Queryable<WMS_LOCATION>().Where(t => t.LOCATION_CODE == CurScanShelf.LocationCode && t.AUTH_ORG == OrgCode).FirstAsync(); @@ -276,12 +273,17 @@ action.IsSuccessed = false; //action.LocaleMsg = Biz.L("鍌ㄤ綅[{0}]鍙兘瀛樻斁涓�涓墿鏂�"); action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationSingleFailure", nLocation.LOCATION_CODE); - ResetScan(); - return action; + ResetTrans(); + return SetOutPutMqttMsg(action, input.Locale); } //鎵ц涓婃灦鏁版嵁澶勭悊 foreach (var item in CurInvItem.Items) + { + item.TRANS_CODE = "In_Default"; + item.TRANS_NO = $"In_Default_{DateTime.Now:yyyyMMdd}"; + } + foreach (var item in CurInvItem.Packages) { item.TRANS_CODE = "In_Default"; item.TRANS_NO = $"In_Default_{DateTime.Now:yyyyMMdd}"; @@ -291,8 +293,8 @@ { action.IsSuccessed = false; action.LocaleMsg = putonResult.LocaleMsg; - ResetScan(); - return action; + ResetTrans(); + return SetOutPutMqttMsg(action, input.Locale); } //瀹屾垚鎵�鏈夊鐞嗗悗浣跨敤浜嬪姟淇濆瓨鏁版嵁 @@ -301,11 +303,11 @@ catch (Exception ex) { //鍙栨秷褰撳墠鎿嶄綔 - ResetScan(); + ResetTrans(); //action.CatchExceptionWithLog(ex, $"鎵弿鏉$爜[{input.SN}]澶嶆牳寮傚父"); action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN)); } - return action; + return SetOutPutMqttMsg(action, input.Locale); } /// <summary> @@ -392,7 +394,7 @@ catch (Exception ex) { //鍙栨秷褰撳墠鎿嶄綔 - ResetScan(); + ResetTrans(); //action.CatchExceptionWithLog(ex, $"鎵弿璐ф灦/鍌ㄤ綅[{0}]寮傚父"); action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code)); } @@ -403,11 +405,16 @@ /// 瀹屾垚鎵�鏈夊鐞嗗悗浣跨敤浜嬪姟淇濆瓨鏁版嵁 /// </summary> /// <param name="action"></param> + /// <param name="locale"></param> + /// <param name="doAfterSave"></param> /// <returns></returns> - public ApiAction<ScanOutput> DoIfFinish(ApiAction<ScanOutput> action, string locale) + public ApiAction<ScanOutput> DoIfFinish(ApiAction<ScanOutput> action, string locale, Action doAfterSave = null) { //淇濆瓨鏁版嵁搴� SaveCommitListToDB(); + + //淇濆瓨鏁版嵁鎴愬姛鍚庢墽琛� + doAfterSave?.Invoke(); // 杩斿洖鏁版嵁 action.Data.Data = new DefaultInStoreOutput @@ -429,17 +436,17 @@ //閲嶇疆鎵爜淇℃伅 ResetScanInfo(); - return action; + return SetOutPutMqttMsg(action, locale); } #endregion /// <summary> - /// 閲嶇疆褰撳墠鎿嶄綔锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉� + /// 閲嶇疆浜嬪姟鏁版嵁锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉� /// </summary> - public override void ResetScan() + public override void ResetTrans() { - base.ResetScan(); + base.ResetTrans(); ResetScanInfo(); CurScanShelf = null; } -- Gitblit v1.9.3