From a8fcfbb5e5ed9a07b1a30ef2d7ef9d407e9b04dd Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期三, 02 四月 2025 21:44:54 +0800
Subject: [PATCH] 更新ASN实体

---
 Tiger.Business.WMS/Transaction/Out_Default.cs |   53 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/Out_Default.cs b/Tiger.Business.WMS/Transaction/Out_Default.cs
index 77518d0..20872e8 100644
--- a/Tiger.Business.WMS/Transaction/Out_Default.cs
+++ b/Tiger.Business.WMS/Transaction/Out_Default.cs
@@ -9,6 +9,7 @@
 using System.Threading.Tasks;
 using Tiger.Model;
 using Tiger.IBusiness;
+using Tiger.Model.Entitys.MES.Position;
 
 namespace Tiger.Business.WMS.Transaction
 {
@@ -19,7 +20,7 @@
     {
         public IOut_Default Init(string id, string userCode, string apiHost, string orgCode)
         {
-            base.Init(id, apiHost, userCode, orgCode);
+            base.Init(id, userCode, apiHost, orgCode);
             Logger.Console.Info($"Start {this.GetType().Name} Transaction[ID: {TransID}]");
             return this;
         }
@@ -52,7 +53,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN));
             }
@@ -70,12 +71,12 @@
                 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;
 
@@ -85,7 +86,7 @@
                         action.IsSuccessed = false;
                         //action.LocaleMsg = Biz.L($"鐘舵�乕{0}]寮傚父锛岃閲嶆柊鎵弿");
                         action.LocaleMsg = Biz.L("WMS.Default.ScanItem.StatusException", string.Join(',', inv.StatusList.Select(x => x.GetDesc())));
-                        return action;
+                        return SetOutPutMqttMsg(action, input.Locale);
                     }
                     //鍌ㄤ綅楠岃瘉
                     if (inv.Location.IsNullOrEmpty())
@@ -93,7 +94,7 @@
                         action.IsSuccessed = false;
                         //action.LocaleMsg = Biz.L($"鏉$爜[{0}]搴撳瓨淇℃伅寮傚父: 娌℃湁鍌ㄤ綅淇℃伅锛岃鍏堜笂鏋跺悗鍐嶆壂鎻�(鍌ㄤ綅Id: {1})");
                         action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationIsNull", inv.CurPkg.SN, inv.CurPkg.LOCATION_ID);
-                        return action;
+                        return SetOutPutMqttMsg(action, input.Locale);
                     }
                     //鐗╂枡楠岃瘉
                     if (inv.ItemInfo.IsNullOrEmpty() || inv.ItemInfo.IS_ACTIVE == "N")
@@ -101,7 +102,7 @@
                         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);
                     }
                     CurInvItem = inv;
 
@@ -112,7 +113,7 @@
                         action.Data.Command = Command = "ComfirmQty";
                         //action.LocaleMsg = Biz.L("璇风‘璁ゆ潯鐮乕{0}]瑕佷笅鏋剁殑鏁伴噺");
                         action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ComfirmOutQty", input.SN);
-                        return action;
+                        return SetOutPutMqttMsg(action, input.Locale);
                     }
                 }
 
@@ -128,7 +129,7 @@
                         action.Data.Command = Command = "ComfirmQty";
                         //action.LocaleMsg = Biz.L("涓嬫灦鏁伴噺涓嶈兘灏忎簬绛変簬闆讹紝璇烽噸鏂扮‘璁ゆ潯鐮乕{0}]鐨勪笅鏋舵暟閲�");
                         action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmOutQty", input.SN);
-                        return action;
+                        return SetOutPutMqttMsg(action, input.Locale);
                     }
                     else if (qtyList.Any(q => q.QTY > CurInvItem.Items.First(i => i.SN == q.SN).QTY))
                     {
@@ -137,7 +138,7 @@
                         action.Data.Command = Command = "ComfirmQty";
                         //action.LocaleMsg = Biz.L("涓嬫灦鏁伴噺涓嶈兘瓒呰繃鍘熸潯鐮佹暟閲忥紝璇烽噸鏂扮‘璁ゆ潯鐮乕{0}]鐨勪笅鏋舵暟閲�");
                         action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ReComfirmExceedOutQty", input.SN);
-                        return action;
+                        return SetOutPutMqttMsg(action, input.Locale);
                     }
                     else
                     {
@@ -152,13 +153,18 @@
                     item.TRANS_CODE = "Out_Default";
                     item.TRANS_NO = $"Out_Default_{DateTime.Now:yyyyMMdd}";
                 }
+                foreach (var item in CurInvItem.Packages)
+                {
+                    item.TRANS_CODE = "Out_Default";
+                    item.TRANS_NO = $"Out_Default_{DateTime.Now:yyyyMMdd}";
+                }
                 Result downResult = TakeDown(downDic, input.AuthOption, WMS_ITEM.STATUSs.OffShelf);
                 if (!downResult.IsSuccessed)
                 {
                     action.IsSuccessed = false;
                     action.LocaleMsg = downResult.LocaleMsg;
-                    ResetScan();
-                    return action;
+                    ResetTrans();
+                    return SetOutPutMqttMsg(action, input.Locale);
                 }
 
                 //鐏伅
@@ -172,11 +178,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>
@@ -256,7 +262,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿璐ф灦/鍌ㄤ綅[{0}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code));
             }
@@ -267,11 +273,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 DefaultScanItemOutput()
@@ -291,18 +302,18 @@
             action.LocaleMsg = Biz.L("WMS.Default.ScanItem.TakeDownSucceeded", CurInvItem.SN, CurInvItem.Location?.LOCATION_CODE);
 
             //閲嶇疆宸ュ簭
-            ResetScan();
-            return action;
+            ResetTrans();
+            return SetOutPutMqttMsg(action, locale);
         }
 
         #endregion
 
         /// <summary>
-        /// 閲嶇疆褰撳墠鎿嶄綔锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉�
+        /// 閲嶇疆浜嬪姟鏁版嵁锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉�
         /// </summary>
-        public override void ResetScan()
+        public override void ResetTrans()
         {
-            base.ResetScan();
+            base.ResetTrans();
             Command = null;
             CurInvItem = null;
             CurScanShelf = null;

--
Gitblit v1.9.3