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/Yada/In_BIZ_U9_RECEIPT.cs |   83 ++++++++++++++++++++---------------------
 1 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs b/Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs
index ba35d1e..609996a 100644
--- a/Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs
+++ b/Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs
@@ -63,7 +63,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN));
             }
@@ -192,7 +192,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);
                 }
 
@@ -223,7 +223,7 @@
                 {
                     action.IsSuccessed = false;
                     action.LocaleMsg = putonResult.LocaleMsg;
-                    ResetScan();
+                    ResetTrans();
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
 
@@ -234,53 +234,51 @@
                     sn.IS_IN = "Y";
                 }
                 //濡傛灉褰撳墠琛屼笂鏋跺畬鎴愭爣璁颁负寰呭鏍�
-                Action approveAction = null;
                 receiptDtl.QTY_IN = receipt.SnList.Where(q => q.LINE_NO == receiptDtl.LINE_NO && q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue()).Sum(q => q.QTY);
                 if (receiptDtl.QTY_IN == receiptDtl.QTY_OK)
                 {
                     receiptDtl.STATUS = BIZ_U9_RECEIPT.STATUSs.Review.GetValue();
-                    //褰撳墠鍗曟嵁鏄庣粏宸茬粡鍏ㄩ儴涓婃灦瀹屾垚锛屽彲浠ヨ皟鐢║9琛屽鎺ュ彛
-                    approveAction = () =>
+                    //褰撳墠鍗曟嵁鏄庣粏琛屽凡缁忓叏閮ㄤ笂鏋跺畬鎴愶紝鍙互璋冪敤U9琛屽鎺ュ彛锛屽鏋滆瀹″け璐ュ垯鎶ラ敊锛屾渶鍚庝竴涓笂鏋跺け璐�
+                    var iInput = new SubmitLineInput
                     {
-                        var iInput = new SubmitLineInput
+                        userId = UserCode,
+                        IsLogin = true,
+                        param = new()
                         {
-                            userId = UserCode,
-                            IsLogin = true,
-                            param = new()
-                            {
-                                RcvLineID = receiptDtl.ID,
-                                RcvDocNo = receiptDtl.ORDER_NO,
-                                DocLineNo = receiptDtl.LINE_NO,
-                                OrgCode = receiptDtl.AUTH_ORG,
-                            }
-                        };
-                        var result = DI.Resolve<IWMS_U9C>().ReceivementApproveLine(iInput).Result;
-                        if (!result.IsSuccessed)
-                        {
-                            throw new Exception(Biz.T(result.LocaleMsg, input.Locale));
-                        }
-                        else
-                        {
-                            //鏇存柊鍗曟嵁淇℃伅
-                            MainDB.Updateable<BIZ_U9_RECEIPT_DTL>().SetColumns(q => q.STATUS == BIZ_U9_RECEIPT.STATUSs.Finished.GetValue()).Where(q => q.ID == receiptDtl.ID).ExecuteCommand();
-                            if (!MainDB.Queryable<BIZ_U9_RECEIPT_DTL>().Any(q => q.STATUS < BIZ_U9_RECEIPT.STATUSs.Finished.GetValue() && q.ORDER_NO == receipt.ORDER_NO))
-                            {
-                                MainDB.Updateable<BIZ_U9_RECEIPT>().SetColumns(q => q.STATUS == BIZ_U9_RECEIPT.STATUSs.Finished.GetValue()).Where(q => q.ID == receipt.ID).ExecuteCommand();
-                            }
+                            RcvLineID = receiptDtl.ID,
+                            RcvDocNo = receiptDtl.ORDER_NO,
+                            DocLineNo = receiptDtl.LINE_NO,
+                            OrgCode = receiptDtl.AUTH_ORG,
                         }
                     };
+                    var result = await DI.Resolve<IWMS_U9C>().ReceivementApproveLine(iInput);
+                    if (!result.IsSuccessed)
+                    {
+                        action.IsSuccessed = false;
+                        action.LocaleMsg = result.LocaleMsg;
+                        return SetOutPutMqttMsg(action, input.Locale);
+                    }
+                    else
+                    {
+                        receiptDtl.STATUS = BIZ_U9_RECEIPT.STATUSs.Finished.GetValue();
+                    }
                 }
                 else
                 {
                     receiptDtl.STATUS = BIZ_U9_RECEIPT.STATUSs.Storing.GetValue();
                 }
+                //鏇存柊鍗曟嵁鐘舵��
                 if (receipt.Details.Any(q => q.STATUS < BIZ_U9_RECEIPT.STATUSs.Review.GetValue()))
                 {
                     receipt.STATUS = BIZ_U9_RECEIPT.STATUSs.Storing.GetValue();
                 }
-                else
+                else if (receipt.Details.Any(q => q.STATUS < BIZ_U9_RECEIPT.STATUSs.Finished.GetValue()))
                 {
                     receipt.STATUS = BIZ_U9_RECEIPT.STATUSs.Review.GetValue();
+                }
+                else
+                {
+                    receipt.STATUS = BIZ_U9_RECEIPT.STATUSs.Finished.GetValue();
                 }
 
                 //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊�
@@ -296,12 +294,12 @@
                 });
 
                 //瀹屾垚鎵�鏈夊鐞嗗悗浣跨敤浜嬪姟淇濆瓨鏁版嵁
-                action = DoIfFinish(action, input.Locale, approveAction);
+                action = DoIfFinish(action, input.Locale);
             }
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿鏉$爜[{input.SN}]澶嶆牳寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN));
             }
@@ -392,7 +390,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿璐ф灦/鍌ㄤ綅[{0}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code));
             }
@@ -433,29 +431,30 @@
             action.LocaleMsg = Biz.L("WMS.Default.ScanItem.PutOnSucceeded", CurInvItem.SN, CurInvItem.Location.LOCATION_CODE);
 
             //閲嶇疆宸ュ簭
-            ResetScanInfo();
+            ResetScan();
             return SetOutPutMqttMsg(action, locale);
         }
 
         #endregion
 
         /// <summary>
-        /// 閲嶇疆褰撳墠鎿嶄綔锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉�
+        /// 閲嶇疆浜嬪姟鏁版嵁锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉�
         /// </summary>
-        public override void ResetScan()
+        public override void ResetTrans()
         {
-            base.ResetScan();
-            ResetScanInfo();
+            ResetScan();
             CurScanShelf = null;
+            base.ResetTrans();
         }
 
         /// <summary>
-        /// 閲嶇疆鎵爜淇℃伅
+        /// 閲嶇疆鏈鎵爜淇℃伅
         /// </summary>
-        public void ResetScanInfo()
+        public override void ResetScan()
         {
-            Command = null;
+            Command = "Normal";
             CurInvItem = null;
+            base.ResetScan();
         }
 
         public override bool Close(bool needSaveHistoryLog = false)

--
Gitblit v1.9.3