From 756e6c531d49a4565e47949120cb33bae431566e Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期四, 24 四月 2025 09:45:22 +0800
Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/Server/TigerApi6_2024

---
 Tiger.Business.WMS/Transaction/In_Default.cs |   51 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/In_Default.cs b/Tiger.Business.WMS/Transaction/In_Default.cs
index a5ad68b..cb890a6 100644
--- a/Tiger.Business.WMS/Transaction/In_Default.cs
+++ b/Tiger.Business.WMS/Transaction/In_Default.cs
@@ -65,7 +65,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN));
             }
@@ -83,7 +83,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;
@@ -111,11 +111,7 @@
 
                     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,
@@ -127,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,
@@ -141,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)
@@ -190,7 +185,7 @@
                         {
                             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";
@@ -278,7 +273,7 @@
                     action.IsSuccessed = false;
                     //action.LocaleMsg = Biz.L("鍌ㄤ綅[{0}]鍙兘瀛樻斁涓�涓墿鏂�");
                     action.LocaleMsg = Biz.L("WMS.Default.ScanItem.LocationSingleFailure", nLocation.LOCATION_CODE);
-                    ResetScan();
+                    ResetTrans();
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
 
@@ -288,12 +283,17 @@
                     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}";
+                }
                 Result putonResult = PutOn(input.AuthOption, nLocation.LOCATION_CODE);
                 if (!putonResult.IsSuccessed)
                 {
                     action.IsSuccessed = false;
                     action.LocaleMsg = putonResult.LocaleMsg;
-                    ResetScan();
+                    ResetTrans();
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
 
@@ -303,7 +303,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿鏉$爜[{input.SN}]澶嶆牳寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN));
             }
@@ -394,7 +394,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿璐ф灦/鍌ㄤ綅[{0}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code));
             }
@@ -405,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
@@ -437,11 +442,11 @@
         #endregion
 
         /// <summary>
-        /// 閲嶇疆褰撳墠鎿嶄綔锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉�
+        /// 閲嶇疆浜嬪姟鏁版嵁锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉�
         /// </summary>
-        public override void ResetScan()
+        public override void ResetTrans()
         {
-            base.ResetScan();
+            base.ResetTrans();
             ResetScanInfo();
             CurScanShelf = null;
         }

--
Gitblit v1.9.3