From eb29ee75c7f2f4154b7a3d0c475f94e0b964e996 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期三, 02 四月 2025 18:17:48 +0800
Subject: [PATCH] 优化事务基础写法

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

diff --git a/Tiger.Business.WMS/Transaction/Out_Default.cs b/Tiger.Business.WMS/Transaction/Out_Default.cs
index aab2fe5..20872e8 100644
--- a/Tiger.Business.WMS/Transaction/Out_Default.cs
+++ b/Tiger.Business.WMS/Transaction/Out_Default.cs
@@ -53,7 +53,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN));
             }
@@ -71,7 +71,7 @@
                 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;
@@ -153,12 +153,17 @@
                     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();
+                    ResetTrans();
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
 
@@ -173,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 SetOutPutMqttMsg(action, input.Locale);
+            return SetOutPutMqttMsg(action, input.Locale);
         }
 
         /// <summary>
@@ -257,7 +262,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿璐ф灦/鍌ㄤ綅[{0}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code));
             }
@@ -268,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()
@@ -292,18 +302,18 @@
             action.LocaleMsg = Biz.L("WMS.Default.ScanItem.TakeDownSucceeded", CurInvItem.SN, CurInvItem.Location?.LOCATION_CODE);
 
             //閲嶇疆宸ュ簭
-            ResetScan();
+            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