From d2f14f6bb44c6dd19cc0816a033452b6de56184b Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期日, 06 四月 2025 18:09:45 +0800
Subject: [PATCH] 增加备料任务调用U9接口方法

---
 Tiger.Business.WMS/Transaction/Yada/Out_BIZ_WMS_PREP.cs |   75 ++++++++++++++++++++-----------------
 1 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/Yada/Out_BIZ_WMS_PREP.cs b/Tiger.Business.WMS/Transaction/Yada/Out_BIZ_WMS_PREP.cs
index 4847c35..adcf836 100644
--- a/Tiger.Business.WMS/Transaction/Yada/Out_BIZ_WMS_PREP.cs
+++ b/Tiger.Business.WMS/Transaction/Yada/Out_BIZ_WMS_PREP.cs
@@ -12,6 +12,8 @@
 using Tiger.Business.WMS.Common;
 using Org.BouncyCastle.Ocsp;
 using Tiger.Model.Sharetronic.Shelf;
+using MailKit.Search;
+using Tiger.Business.WMS.Extensions;
 
 namespace Tiger.Business.WMS.Transaction
 {
@@ -29,7 +31,7 @@
         }
 
         #region Propertys & Variables
-        private Preparation CurPREP;
+        public Preparation CurPREP { get; set; }
         private List<BIZ_WMS_PREP_SN> CurSn = new();
         private BIZ_WMS_PREP_DTL CurPrepDtl = new();
         public List<SuggestItem> Suggests { get; set; } = new();
@@ -95,7 +97,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN));
             }
@@ -141,7 +143,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"澶囨枡浠诲姟鎵弿鍗曟嵁寮傚父(Data: {0})");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Out_BIZ_WMS_PREP.ScanOrderException", input?.Data));
             }
@@ -156,6 +158,7 @@
         {
             var action = new ApiAction<BIZ_WMS_PREP>();
             CurPREP.Order = MainDB.Queryable<BIZ_WMS_PREP>().Where(q => q.ID == CurPREP.Order.ID).IncludesAllFirstLayer().First();
+
             action.Data = CurPREP.Order;
             return action;
         }
@@ -177,11 +180,11 @@
                     action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanItem.NotSelectItem");
                     return action;
                 }
-                if (prepDtl.QTY_PREP > GetActReqQty(prepDtl))
+                if (prepDtl.QTY_PREP > CurPREP.BizType.GetActReqQty(prepDtl))
                 {
                     action.IsSuccessed = false;
                     //action.LocaleMsg = Biz.L("褰撳墠閫夋嫨鐗╂枡琛孾{0}]宸插鏂欐暟閲廩{1}]锛屼互婊¤冻瀹為檯闇�姹傛暟閲廩{2}]锛屾棤闇�缁х画澶囨枡");
-                    action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.SelectItem.PrepFinish", prepDtl.ITEM_CODE, prepDtl.QTY_PREP, GetActReqQty(prepDtl));
+                    action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.SelectItem.PrepFinish", prepDtl.ITEM_CODE, prepDtl.QTY_PREP, CurPREP.BizType.GetActReqQty(prepDtl));
                     return action;
                 }
                 //鍒犻櫎鐗╂枡姹犱腑涓婁竴娆″垎閰嶇殑鐗╂枡
@@ -215,7 +218,7 @@
                     if (Suggests.Count > 0)
                     {
                         var inv = Suggests.First();
-                        var actQty = CurPrepDtl.QTY_PREP > GetActReqQty(CurPrepDtl) ? 0 : (GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
+                        var actQty = CurPrepDtl.QTY_PREP > CurPREP.BizType.GetActReqQty(CurPrepDtl) ? 0 : (CurPREP.BizType.GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
                         if (inv != null && actQty > 0)
                         {
                             inv.poolItem = inv.Item.GetPoolItem(OrgCode, nameof(CurPREP.Order), CurPrepDtl.ORDER_NO, CurPrepDtl.ORDER_LINE, actQty, true);
@@ -232,7 +235,7 @@
                 if (CurPREP.Order.CurBatch.DLVY_MODE == BIZ_WMS_PREP_BTH.DLVY_MODEs.Supply.GetValue())
                 {
                     //鎺ㄨ崘鐗╂枡
-                    var actQty = CurPrepDtl.QTY_PREP > GetActReqQty(CurPrepDtl) ? 0 : (GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
+                    var actQty = CurPrepDtl.QTY_PREP > CurPREP.BizType.GetActReqQty(CurPrepDtl) ? 0 : (CurPREP.BizType.GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
                     Result<List<SuggestItem>> result = Suggest(CurPrepDtl.ORDER_NO, CurPrepDtl.ITEM_CODE, null, inputDtl.WH_ID, inputDtl.REGION_ID, inputDtl.SHELF_ID, input.AuthOption, actQty);
                     action.LocaleMsg = result.LocaleMsg;
                     if (result.IsException)
@@ -272,7 +275,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"澶囨枡浠诲姟閫夋嫨瑕佺墿鏂欒寮傚父(Data: {0})");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Out_BIZ_WMS_PREP.SelectItemException", input?.Data));
             }
@@ -475,7 +478,7 @@
                 //鍒ゆ柇鏄惁瓒呭彂
                 isExceed = false;
                 //璁$畻鍓╀綑闇�姹傛暟閲忓拰鏉$爜涓殑鍙戝嚭鏁伴噺
-                var actQty = CurPrepDtl.QTY_PREP > GetActReqQty(CurPrepDtl) ? 0 : (GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
+                var actQty = CurPrepDtl.QTY_PREP > CurPREP.BizType.GetActReqQty(CurPrepDtl) ? 0 : (CurPREP.BizType.GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
                 if (actQty < CurInvItem.CurPkg.QTY)
                 {
                     isExceed = true;
@@ -496,7 +499,7 @@
                 {
                     //action.LocaleMsg = Biz.L($"鏉$爜[{0}]鎵弿鎴愬姛锛屽鏂欑墿鏂橻{1}]闇�姹俒{2}]杩橀渶澶囨枡[{3}]锛屾潯鐮侀渶瑕佹埅鏂欙紝鍙戝嚭鏁伴噺[{4}]");
                     //action.LocaleMsg = Biz.L($"鏉$爜[{0}]鎵弿鎴愬姛锛屽鏂欑墿鏂橻{1}]闇�姹俒{2}]杩橀渶澶囨枡[{3}]锛岃閫夋嫨瑕佽秴鍙戣繕鏄埅鏂欙紵");
-                    action.LocaleMsg = Biz.L($"WMS.Out_BIZ_WMS_PREP.ScanItem.Success{(isNeedCut ? "" : "Confirm")}", CurInvItem.SN, CurInvItem.ItemInfo.ITEM_CODE, GetActReqQty(CurPrepDtl), actQty);
+                    action.LocaleMsg = Biz.L($"WMS.Out_BIZ_WMS_PREP.ScanItem.Success{(isNeedCut ? "" : "Confirm")}", CurInvItem.SN, CurInvItem.ItemInfo.ITEM_CODE, CurPREP.BizType.GetActReqQty(CurPrepDtl), actQty);
                     action.Data.Command = "ConfirmExceed";
                     action.Data.Data = new  
                     {
@@ -531,11 +534,11 @@
                 var sns = (input.Data ?? "").JsonToObject<List<BIZ_WMS_PREP_SN>>() ?? new List<BIZ_WMS_PREP_SN>();
                 if (!sns.Any())
                 {
-                    var actQty = CurPrepDtl.QTY_PREP > GetActReqQty(CurPrepDtl) ? 0 : (GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
+                    var actQty = CurPrepDtl.QTY_PREP > CurPREP.BizType.GetActReqQty(CurPrepDtl) ? 0 : (CurPREP.BizType.GetActReqQty(CurPrepDtl) - CurPrepDtl.QTY_PREP);
                     action.IsSuccessed = false;
                     //action.LocaleMsg = Biz.L($"鏉$爜[{0}]鎵弿鎴愬姛锛屽鏂欑墿鏂橻{1}]闇�姹俒{2}]杩橀渶澶囨枡[{3}]锛屾潯鐮侀渶瑕佹埅鏂欙紝鍙戝嚭鏁伴噺[{4}]");
                     //action.LocaleMsg = Biz.L($"鏉$爜[{0}]鎵弿鎴愬姛锛屽鏂欑墿鏂橻{1}]闇�姹俒{2}]杩橀渶澶囨枡[{3}]锛岃閫夋嫨瑕佽秴鍙戣繕鏄埅鏂欙紵");
-                    action.LocaleMsg = Biz.L($"WMS.Out_BIZ_WMS_PREP.ScanItem.Success{(isNeedCut ? "" : "Confirm")}", CurInvItem.SN, CurInvItem.ItemInfo.ITEM_CODE, GetActReqQty(CurPrepDtl), actQty);
+                    action.LocaleMsg = Biz.L($"WMS.Out_BIZ_WMS_PREP.ScanItem.Success{(isNeedCut ? "" : "Confirm")}", CurInvItem.SN, CurInvItem.ItemInfo.ITEM_CODE, CurPREP.BizType.GetActReqQty(CurPrepDtl), actQty);
                     action.Data.Command = "ConfirmExceed";
                     action.Data.Data = new
                     {
@@ -581,7 +584,7 @@
                 {
                     action.IsSuccessed = false;
                     action.LocaleMsg = downResult.LocaleMsg;
-                    ResetScanInfo();
+                    ResetScan();
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
                 else//澶勭悊澶囨枡浠诲姟鏁版嵁
@@ -600,7 +603,7 @@
                     CurPrepDtl.QTY_PREP += CurSn.Sum(q => q.QTY_DLVY);
                     CurPREP.Order.STATUS = BIZ_WMS_PREP.STATUSs.Picking.GetValue();
                     CurPREP.Order.CurBatch.STATUS = BIZ_WMS_PREP_BTH.STATUSs.Picking.GetValue();
-                    CurPREP.Order.CurBatch.PICK_TIME = DateTime.Now;
+                    CurPREP.Order.CurBatch.PICK_TIME = CurPREP.Order.CurBatch.PICK_TIME < new DateTime(2000, 1, 1) ? DateTime.Now : CurPREP.Order.CurBatch.PICK_TIME;
 
                     //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊�
                     var _CurSn = CurSn.Clone();
@@ -632,23 +635,11 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
-                //娓呯悊鏆傚瓨鏁版嵁鎻愪氦鎿嶄綔
-                DBCommitList.Clear();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿鏉$爜[{input.SN}]澶嶆牳寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN));
             }
             return SetOutPutMqttMsg(action, input.Locale);
-        }
-
-        /// <summary>
-        /// 瀹為檯闇�姹傛暟閲忚绠楁柟娉�
-        /// </summary>
-        /// <param name="dtl"></param>
-        /// <returns></returns>
-        private double GetActReqQty(BIZ_WMS_PREP_DTL dtl)
-        {
-            return dtl.QTY_REQ;
         }
 
         /// <summary>
@@ -735,7 +726,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿璐ф灦/鍌ㄤ綅[{0}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code));
             }
@@ -775,30 +766,44 @@
             action.LocaleMsg = Biz.L("WMS.Default.ScanItem.TakeDownSucceeded", CurInvItem.SN, CurInvItem.Location?.LOCATION_CODE);
 
             //閲嶇疆宸ュ簭
-            ResetScanInfo();
+            ResetScan();
             return SetOutPutMqttMsg(action, locale);
+        }
+
+        /// <summary>
+        /// 璋冪敤鍙戞枡鍗曟嵁鐨凟RP鎺ュ彛
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        public async Task<ApiAction> CommitToERP(BaseInput input)
+        {
+            var action = await CurPREP.Order.BIZ_TYPE.GetEnum<BIZ_WMS_PREP.BIZ_TYPEs>() .CommitToERP(this, input);
+            return action;
         }
 
         #endregion
 
         /// <summary>
-        /// 閲嶇疆褰撳墠鎿嶄綔锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉�
+        /// 閲嶇疆浜嬪姟鏁版嵁锛屾湁闇�瑕佸垯閲嶅啓姝ゆ柟娉�
         /// </summary>
-        public override void ResetScan()
+        public override void ResetTrans()
         {
-            base.ResetScan();
-            ResetScanInfo();
+            ResetScan();
             CurPREP = new(MainDB, UserCode, OrgCode);
+            CurPrepDtl = new();
             CurScanShelf = null;
+            base.ResetTrans();
         }
 
         /// <summary>
-        /// 閲嶇疆鎵爜淇℃伅
+        /// 閲嶇疆鏈鎵爜淇℃伅
         /// </summary>
-        public void ResetScanInfo()
+        public override void ResetScan()
         {
             Command = "Normal";
             CurInvItem = null;
+            CurSn = new();
+            base.ResetScan();
         }
 
         public override bool Close(bool needSaveHistoryLog = false)

--
Gitblit v1.9.3