From 806b3cb3448ad15a5d563937fdac2ffae37342a7 Mon Sep 17 00:00:00 2001
From: YangYuGang <1378265336@qq.com>
Date: 星期三, 23 四月 2025 22:11:25 +0800
Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/Server/TigerApi6_2024

---
 Tiger.Business.WMS/Transaction/Yada/Out_BIZ_WMS_PREP.cs |  100 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 62 insertions(+), 38 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..243c7dc 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));
             }
@@ -412,6 +415,14 @@
                     action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ItemIsLock", inv.CurPkg.SN);
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
+                //楠岃瘉鏉$爜鏄惁琚叾浠栫敤鎴峰拰鍗曟嵁閿佸畾
+                if (inv.Items.Any(q => q.IS_LOCKED == "Y"))
+                {
+                    action.IsSuccessed = false;
+                    //action.LocaleMsg = Biz.L("鏉$爜[{0}]宸茶閿佸畾锛岃閲嶆柊鎵弿");
+                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.ItemIsLock", inv.CurPkg.SN);
+                    return SetOutPutMqttMsg(action, input.Locale);
+                }
                 //鍌ㄤ綅楠岃瘉
                 if (inv.Location.IsNullOrEmpty())
                 {
@@ -429,13 +440,22 @@
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
                 //鍒ゆ柇鏄惁鍦ㄥ鏂欎腑鐨勭墿鏂�
-                if (!CurPREP.Order.Details.Any(q => q.ITEM_CODE == inv.ItemInfo.ITEM_CODE))
+                if (inv.ItemInfo.ITEM_CODE != CurPrepDtl.ITEM_CODE)
                 {
                     action.IsSuccessed = false;
-                    //action.LocaleMsg = Biz.L($"褰撳墠澶囨枡浠诲姟[{0}]涓嶅寘鍚潯鐮乕{1}]鐨勭墿鏂欑紪鐮乕{2}]锛岃鏀惧洖鍘熷偍浣�");
-                    action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanItem.NoNeedItemCode", inv.ItemInfo.ITEM_CODE.IsNullOrEmpty(inv.Barcode.ItemCode));
+                    //action.LocaleMsg = Biz.L($"鏉$爜[{0}]涓嶆槸褰撳墠閫変腑鐨勭墿鏂欒[{1}]锛岃鏀惧洖鍘熷偍浣嶆垨鑰呴噸鏂伴�夋嫨涓嬫灦鐗╂枡琛�");
+                    action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanItem.NoNeedItemCode", inv.CurPkg.SN, CurPrepDtl.ITEM_CODE);
                     return action;
                 }
+                //鍒ゆ柇鏄惁鍦ㄥ鏂欎腑鐨勭墿鏂�
+                //if (!CurPREP.Order.Details.Any(q => q.ITEM_CODE == inv.ItemInfo.ITEM_CODE))
+                //{
+                //    action.IsSuccessed = false;
+                //    //action.LocaleMsg = Biz.L($"褰撳墠澶囨枡浠诲姟[{0}]涓嶅寘鍚潯鐮乕{1}]鐨勭墿鏂欑紪鐮乕{2}]锛岃鏀惧洖鍘熷偍浣�");
+                //    action.LocaleMsg = Biz.L("WMS.Out_BIZ_WMS_PREP.ScanItem.NoNeedItemCode", inv.ItemInfo.ITEM_CODE.IsNullOrEmpty(inv.Barcode.ItemCode));
+                //    return action;
+                //}
+                
                 //ProcessingOrderDetail = input.SN;
                 //if (WMSContext.TransactionDic.Where(q => !string.IsNullOrWhiteSpace(q.Value.ProcessingSn)).Any(q => q.Value.ProcessingSn == ProcessingSn && q.Value.TransID != this.TransID))
                 //{
@@ -450,9 +470,11 @@
                     ORDER_BATCH = CurPREP.Order.CurBatch.BATCH.ToString(),
                     SN = q.SN,
                     ITEM_CODE = q.ITEM_CODE,
+                    UNIT = q.UNIT,
                     QTY = q.QTY,
                     QTY_DLVY = q.QTY,
                     STATUS = q.STATUS,
+                    LOTNO = q.LOTNO,
                     WH_CODE = CurInvItem.Warehouse.WH_CODE,
                     REGION_CODE = CurInvItem.Region.REGION_CODE,
                     SHELF_CODE = CurInvItem.Shelf.SHELF_CODE,
@@ -475,7 +497,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 +518,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 +553,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 +603,7 @@
                 {
                     action.IsSuccessed = false;
                     action.LocaleMsg = downResult.LocaleMsg;
-                    ResetScanInfo();
+                    ResetScan();
                     return SetOutPutMqttMsg(action, input.Locale);
                 }
                 else//澶勭悊澶囨枡浠诲姟鏁版嵁
@@ -600,7 +622,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 +654,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 +745,7 @@
             catch (Exception ex)
             {
                 //鍙栨秷褰撳墠鎿嶄綔
-                ResetScan();
+                ResetTrans();
                 //action.CatchExceptionWithLog(ex, $"鎵弿璐ф灦/鍌ㄤ綅[{0}]寮傚父");
                 action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanShelf.ScanException", Code));
             }
@@ -775,30 +785,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