From 69a1f63305d303745b831d55168cd2c8990f6fa9 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期六, 21 九月 2024 09:56:17 +0800
Subject: [PATCH] 修复包装行为,手动结束包装不称重和创建package对象异常

---
 Tiger.Business.MES/WorkAction/ThreeInOne.cs |   59 +++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/ThreeInOne.cs b/Tiger.Business.MES/WorkAction/ThreeInOne.cs
index 1299575..4d2a068 100644
--- a/Tiger.Business.MES/WorkAction/ThreeInOne.cs
+++ b/Tiger.Business.MES/WorkAction/ThreeInOne.cs
@@ -27,6 +27,7 @@
         public BAS_LABEL_TEMP Label { get; set; }
         public List<BAS_LABEL_PV> LabelPV { get; set; }
         public List<mes_MOPickList> MoPickList { get; set; }
+        public BAS_ITEM_CUST CustInfo { get; set; }
         #endregion Propertys & Variables
 
         #region Functions
@@ -43,9 +44,16 @@
             Setting = setting;
             #endregion
 
+            //鑾峰彇鎵撳嵃妯℃澘
             Label = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == setting.LABEL_CODE).IncludesAllFirstLayer().First();
             LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList();
+            //鑾峰彇宸ュ崟澶囨枡淇℃伅
             MoPickList = Biz.DataSource["YadaU9C"].Client.Queryable<mes_MOPickList>().Where(q => q.MoDocNo == CurPosition.WorkBatch.WO.ORDER_NO).ToList();
+            //鑾峰彇褰撳墠浜у搧鍦ㄥ綋鍓嶅鎴风殑鍏崇郴
+            CustInfo = Biz.Db.Queryable<BAS_ITEM_CUST>().Where(q => q.ITEM_ID == CurPosition.WorkBatch.WO.ItemInfo.ID && q.CUST_CODE == CurPosition.WorkBatch.WO.CUST_CODE).First();
+
+            CurStep.Message = Biz.L("鎵弿鍘傚唴鏉$爜");
+            CurStep.Status = StepStatus.Normal;
         }
 
         /// <summary>
@@ -143,7 +151,7 @@
 	            else
 	            {
 	                //璁剧疆鎵撳嵃鍙橀噺鍊�
-	                Label = CurPosition.SetLabelVariables(LabelPV, Label);
+	                Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
 	                action.Data.Data = new
 	                {
 	                    NeedPrint = true,
@@ -178,38 +186,41 @@
                 CUST_SN = input.Data,
             };
 
+            var isOK = true;
             //瀹㈡埛鏉$爜宸茬粦瀹氬叾浠栧巶鍐呮潯鐮�
             if (!CurCSN.FLOW_SN.IsNullOrEmpty() && CurCSN.FLOW_SN != CurPosition.CurWipSNs.First().SN)
             {
-                CurStep.Message = Biz.L("缁戝畾澶辫触");
-                CurStep.Status = StepStatus.Error;
-                action.Data.ShortMsg = new("缁戝畾澶辫触", ShortMessage.Types.Failed);
-                action.IsSuccessed = false;
+                CurStep.SetStatusMessage(StepStatus.Error, Biz.L("瀹㈡埛鏍囩缁戝畾澶辫触"));
+                action.Data.ShortMsg = new("瀹㈡埛鏍囩缁戝畾澶辫触", ShortMessage.Types.Failed);
+                action.IsSuccessed = isOK = false;
                 //action.LocaleMsg = new($"鍘傚唴鏉$爜[{0}]缁戝畾瀹㈡埛鏉$爜[{1}]澶辫触锛屽鎴锋潯鐮佸凡缁戝畾鍘傚唴鏉$爜[{2}]");
                 action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingOtherSN", CurPosition.CurWipSNs.First().SN, CurCSN.CUST_SN, CurCSN.FLOW_SN);
-                //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
-                if (NodeAct.NEED_RESET == "Y")
-                {
-                    CurPosition.ResetNode();
-                }
             }
             //瀹㈡埛鏉$爜涓嶅睘浜庡綋鍓嶅伐鍗曠殑瀹㈡埛
-            else if (CurCSN.CUST_CODE.IsNullOrEmpty(CurPosition.WorkBatch.WO.CUST_CODE) != CurPosition.WorkBatch.WO.CUST_CODE)
+            if (CurCSN.CUST_CODE.IsNullOrEmpty(CurPosition.WorkBatch.WO.CUST_CODE) != CurPosition.WorkBatch.WO.CUST_CODE)
             {
-                CurStep.Message = Biz.L("缁戝畾澶辫触");
-                CurStep.Status = StepStatus.Error;
-                action.Data.ShortMsg = new("缁戝畾澶辫触", ShortMessage.Types.Failed);
-                action.IsSuccessed = false;
+                CurStep.SetStatusMessage(StepStatus.Error, Biz.L("瀹㈡埛鏍囩缁戝畾澶辫触"));
+                action.Data.ShortMsg = new("瀹㈡埛鏍囩缁戝畾澶辫触", ShortMessage.Types.Failed);
+                action.IsSuccessed = isOK = false;
                 //action.LocaleMsg = new($"瀹㈡埛鏉$爜[{0}]灞炰簬瀹㈡埛[{1}]锛屼笌褰撳墠宸ュ崟鐨勫鎴穂{2}]涓嶄竴鑷�");
                 action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotSameCustomer", CurCSN.CUST_SN, CurCSN.CUST_CODE, CurPosition.WorkBatch.WO.CUST_CODE);
-                //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
-                if (NodeAct.NEED_RESET == "Y")
+            }
+            //楠岃瘉浜у搧瀹㈡埛鏍囩鏉$爜瑙勫垯
+            if (!CustInfo.RULE_CODE.IsNullOrEmpty() && !Biz.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty())
+            {
+                var result = Biz.CodeRule[CustInfo.RULE_CODE].Verify(CurCSN.CUST_SN);
+                if (!result.IsSuccessed)
                 {
-                    CurPosition.ResetNode();
+                    CurStep.SetStatusMessage(StepStatus.Error, Biz.L("瀹㈡埛鏍囩缁戝畾澶辫触"));
+                    action.Data.ShortMsg = new("瀹㈡埛鏍囩缁戝畾澶辫触", ShortMessage.Types.Failed);
+                    action.IsSuccessed = isOK = false;
+                    //action.LocaleMsg = new Locale($"鏍囩鏉$爜[{0}]鏈�氳繃瀹㈡埛鏍囩瑙勫垯[{1}]楠岃瘉");
+                    action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.CustSnVerifyError", CurCSN.CUST_SN, CustInfo.RULE_CODE);
                 }
             }
-            //鎻愪氦鏁版嵁鎵ц澶辫触
-            else
+
+            //楠岃瘉閫氳繃鍒欎繚瀛�
+            if (isOK)
             {
                 CurCSN.CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE;
                 CurCSN.FLOW_SN = CurPosition.CurWipSNs.First().SN;
@@ -217,6 +228,14 @@
                 CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE;
                 action = End(input);
             }
+            else
+            {
+                //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
+                if (NodeAct.NEED_RESET == "Y")
+                {
+                    CurPosition.ResetNode();
+                }
+            }
 
             return action;
         }

--
Gitblit v1.9.3