From f6c758a94829953aa75bbe888c6dfa99d077c8df Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期四, 12 九月 2024 15:19:42 +0800
Subject: [PATCH] 优化三码合一行为,验证客户条码行为

---
 Tiger.Business.MES/WorkAction/ThreeInOne.cs       |   52 +++++++++++------
 Tiger.Api/Language.db                             |    0 
 Tiger.IBusiness/MES/WorkAction/IVerifyCustomSN.cs |    2 
 Tiger.Business.MES/WorkAction/VerifyCustomSN.cs   |   67 ++++++++++------------
 4 files changed, 64 insertions(+), 57 deletions(-)

diff --git a/Tiger.Api/Language.db b/Tiger.Api/Language.db
index 93a802f..5e31dd8 100644
--- a/Tiger.Api/Language.db
+++ b/Tiger.Api/Language.db
Binary files differ
diff --git a/Tiger.Business.MES/WorkAction/ThreeInOne.cs b/Tiger.Business.MES/WorkAction/ThreeInOne.cs
index 7fbdc25..37669c1 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
@@ -48,6 +49,8 @@
             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;
@@ -183,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;
@@ -222,6 +228,14 @@
                 CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE;
                 action = End(input);
             }
+            else
+            {
+                //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
+                if (NodeAct.NEED_RESET == "Y")
+                {
+                    CurPosition.ResetNode();
+                }
+            }
 
             return action;
         }
diff --git a/Tiger.Business.MES/WorkAction/VerifyCustomSN.cs b/Tiger.Business.MES/WorkAction/VerifyCustomSN.cs
index 3be4358..5e1aab4 100644
--- a/Tiger.Business.MES/WorkAction/VerifyCustomSN.cs
+++ b/Tiger.Business.MES/WorkAction/VerifyCustomSN.cs
@@ -1,4 +1,5 @@
-锘縰sing Rhea.Common;
+锘縰sing Org.BouncyCastle.Ocsp;
+using Rhea.Common;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -12,7 +13,7 @@
 
 namespace Tiger.Business.MES.WorkAction
 {
-    public class VerifyCustomSN : IVerifyItem
+    public class VerifyCustomSN : IVerifyCustomSN
     {
         #region Propertys & Variables
         #region 鍥哄畾鍐欐硶锛屽伐搴忎腑鐨勫繀瑕佷俊鎭�
@@ -22,7 +23,7 @@
         public MES_WO_NODE_ACT NodeAct { get; set; }
         public MES_WO_ACTION Setting { get; set; }
         #endregion
-
+        public BAS_ITEM_CUST CustInfo { get; set; }
         #endregion Propertys & Variables
 
         #region Functions
@@ -39,8 +40,10 @@
             Setting = setting;
             #endregion
 
-            CurStep.Message = Biz.L("楠岃瘉浜у搧鏁版嵁");
-            CurStep.Status = StepStatus.Normal;
+            //鑾峰彇褰撳墠浜у搧鍦ㄥ綋鍓嶅鎴风殑鍏崇郴
+            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.SetStatusMessage(StepStatus.Normal, Biz.L("楠岃瘉鏄惁瀹㈡埛鏍囩"));
         }
 
         /// <summary>
@@ -49,8 +52,8 @@
         /// <returns></returns>
         public Locale GetBeginMsg()
         {
-            var msg = new Locale("MES.WorkAction.VerifyItem.BeginMsg");
-            //var msg = new Locale($"寮�濮嬮獙璇佷骇鍝乕{CurPosition.CurWipSN.SN}]");
+            var msg = new Locale("MES.WorkAction.VerifyCustomSN.BeginMsg", CurPosition.CurSN);
+            //var msg = new Locale($"寮�濮嬮獙璇佹潯鐮乕{0}]鏄惁瀹㈡埛鏍囩");
             return msg;
         }
 
@@ -85,7 +88,7 @@
             if (!action.IsSuccessed)
             {
                 //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
-                if (NodeAct.NEED_RESET == "Y")
+                //if (NodeAct.NEED_RESET == "Y")
                 {
                     CurPosition.ResetNode();
                 }
@@ -99,23 +102,17 @@
             {
                 var isOK = true;
                 //楠岃瘉閫昏緫
-                //if (input.SN.IsNullOrEmpty())
+                if (!CustInfo.RULE_CODE.IsNullOrEmpty() && !Biz.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty())
                 {
-                    CurStep.Message = Biz.L("楠岃瘉澶辫触");
-                    CurStep.Status = StepStatus.Error;
-                    action.Data.ShortMsg = new("楠岃瘉澶辫触", ShortMessage.Types.Failed);
-                    action.IsSuccessed = isOK = false;
-                    //action.LocaleMsg = new Locale($"閿欒锛歔{ExtInfo.FIELD_NAME}]鏍囩鏉$爜涓嶈兘涓虹┖锛岃閲嶆柊鎵弿");
-                    //action.LocaleMsg = new Locale("MES.WorkAction.VerifyItem.SnEmptyError", ExtInfo.FIELD_NAME);
-                }
-                //if (CurPosition.CurWipSNs.Any(w => w.SN == input.SN))
-                {
-                    CurStep.Message = Biz.L("楠岃瘉澶辫触");
-                    CurStep.Status = StepStatus.Error;
-                    action.Data.ShortMsg = new("楠岃瘉澶辫触", ShortMessage.Types.Failed);
-                    action.IsSuccessed = isOK = false;
-                    //action.LocaleMsg = new Locale($"閿欒锛氭壂鎻忓埌浜у搧鏉$爜[{input.SN}]锛岃閲嶆柊鎵弿[{ExtInfo.FIELD_NAME}]鏍囩鏉$爜");
-                    //action.LocaleMsg = new Locale("MES.WorkAction.VerifyItem.ScanProdSnError", input.SN, ExtInfo.FIELD_NAME);
+                    var result = Biz.CodeRule[CustInfo.RULE_CODE].Verify(CurPosition.CurSN);
+                    if (!result.IsSuccessed)
+                    {
+                        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.VerifyCustomSN.CustSnVerifyError", CurPosition.CurSN, CustInfo.RULE_CODE);
+                    }
                 }
 
                 //楠岃瘉閫氳繃鍒欎繚瀛�
@@ -123,18 +120,15 @@
                 {
                     action = End(input);
                 }
-
-                //閮芥病鏈夌墿鏂欓獙璇侀�氳繃锛屽垯杩斿洖閿欒淇℃伅
             }
             catch (System.Exception ex)
             {
-                CurStep.Message = Biz.L("楠岃瘉寮傚父");
-                CurStep.Status = StepStatus.Error;
-                action.Data.ShortMsg = new("楠岃瘉寮傚父", ShortMessage.Types.Exception);
-                action.CatchExceptionWithLog(ex, $"楠岃瘉寮傚父");
+                CurStep.SetStatusMessage(StepStatus.Error, Biz.L("瀹㈡埛鏍囩楠岃瘉寮傚父"));
+                action.Data.ShortMsg = new("瀹㈡埛鏍囩楠岃瘉寮傚父", ShortMessage.Types.Exception);
+                action.CatchExceptionWithLog(ex, $"瀹㈡埛鏍囩楠岃瘉寮傚父");
                 action.IsSuccessed = false;
-                //action.LocaleMsg = new($"浜у搧[{CurPosition.CurSN}]楠岃瘉寮傚父锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜");
-                //action.LocaleMsg = new("MES.WorkAction.VerifyItem.SaveExtInfoException", CurPosition.CurSN);
+                //action.LocaleMsg = new($"鏍囩鏉$爜[{0}]楠岃瘉寮傚父锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜");
+                action.LocaleMsg = new("MES.WorkAction.VerifyCustomSN.CustSnVerifyException", CurPosition.CurSN);
                 CurPosition.ResetNode();
             }
             return action;
@@ -201,11 +195,10 @@
             };
 
             IsFinished = true;
-            CurStep.Message = Biz.L("楠岃瘉閫氳繃");
-            CurStep.Status = StepStatus.Finished;
-            action.Data.ShortMsg = new("楠岃瘉閫氳繃", ShortMessage.Types.Success);
-            //action.LocaleMsg = new($"浜у搧[{CurPosition.CurSN}]楠岃瘉閫氳繃");
-            action.LocaleMsg = new("MES.WorkAction.VerifyItem.VerifySuccess", CurPosition.CurSN);
+            CurStep.SetStatusMessage(StepStatus.Finished, Biz.L("瀹㈡埛鏍囩楠岃瘉閫氳繃"));
+            action.Data.ShortMsg = new("瀹㈡埛鏍囩楠岃瘉閫氳繃", ShortMessage.Types.Success);
+            //action.LocaleMsg = new($"瀹㈡埛鏍囩鏉$爜[{0}]楠岃瘉閫氳繃");
+            action.LocaleMsg = new("MES.WorkAction.VerifyCustomSN.VerifySuccess", CurPosition.CurSN);
             return action;
         }
 
diff --git a/Tiger.IBusiness/MES/WorkAction/IVerifyItem.cs b/Tiger.IBusiness/MES/WorkAction/IVerifyCustomSN.cs
similarity index 72%
rename from Tiger.IBusiness/MES/WorkAction/IVerifyItem.cs
rename to Tiger.IBusiness/MES/WorkAction/IVerifyCustomSN.cs
index a927f9a..9acc6e1 100644
--- a/Tiger.IBusiness/MES/WorkAction/IVerifyItem.cs
+++ b/Tiger.IBusiness/MES/WorkAction/IVerifyCustomSN.cs
@@ -5,7 +5,7 @@
 
 namespace Tiger.IBusiness.MES.WorkAction
 {
-    public interface IVerifyItem : IWorkAction
+    public interface IVerifyCustomSN : IWorkAction
     {
 
     }

--
Gitblit v1.9.3