From 17077d5f5dc14c5ff5e6d757efa49c53e2b9afad Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期一, 28 十月 2024 15:12:32 +0800
Subject: [PATCH] 优化打印行为

---
 Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs |   55 +++++++++++++++------------
 Tiger.Business.MES/WorkAction/PrintLabel.cs        |   35 ++++++++++-------
 2 files changed, 52 insertions(+), 38 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs b/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
index 6fbe831..d370304 100644
--- a/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
+++ b/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
@@ -55,7 +55,7 @@
         /// <returns></returns>
         public Locale GetBeginMsg()
         {
-            var msg = new Locale("MES.WorkAction.PrintInStoreLabel.BeginMsg", CurPosition.CurSN, Label.LABEL_CODE, Label.LABEL_NAME);
+            var msg = new Locale("MES.WorkAction.PrintInStoreLabel.BeginMsg", CurPosition.CurSN, Label?.LABEL_CODE, Label?.LABEL_NAME);
             //var msg = new Locale($"寮�濮嬫墦鍗版潯鐮乕{CurPosition.CurWipSN.SN}]鐨勫叆搴撴爣绛綶{Label.LABEL_CODE}: {Label.LABEL_NAME}]");
             return msg;
         }
@@ -68,29 +68,36 @@
         {
             var action = new ApiAction<SubmitOutput>(new SubmitOutput());
 
-            //璁剧疆鎵撳嵃鍙橀噺鍊�
-            Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
-            if (CurPosition.Context.ContainsKey("CurPackage"))
-            {
-                (CurPosition.Context["CurPackage"] as WipPkg).InStoreLabel = Label;
-            }
-
-            //鍒ゆ柇鏄惁闇�瑕佹墦鍗板叆搴撴爣绛�
-            NoNeedInStorePrint = (!CurPosition.Context.ContainsKey("CurPackage") || !(CurPosition.Context["CurPackage"] as WipPkg).IsFinished) 
-                                    || (CurPosition is YadaPacking && (CurPosition as YadaPacking).IsPrintCustomerLabel);
-            if (NoNeedInStorePrint)
+            if (Label.IsNullOrEmpty())
             {
                 action = End(input);
             } 
             else
             {
-	            action.Data.Data = Label;
+	            //璁剧疆鎵撳嵃鍙橀噺鍊�
+	            Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
+	            if (CurPosition.Context.ContainsKey("CurPackage"))
+	            {
+	                (CurPosition.Context["CurPackage"] as WipPkg).InStoreLabel = Label;
+	            }
 	
-	            //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
-	            CurStep.Message = Biz.L("鎵撳嵃寮�濮�");
-	            CurStep.Status = StepStatus.Normal;
-	            action.IsSuccessed = true;
-	            action.Data.ShortMsg = new("鎵撳嵃寮�濮�", ShortMessage.Types.Success);
+	            //鍒ゆ柇鏄惁闇�瑕佹墦鍗板叆搴撴爣绛�
+	            NoNeedInStorePrint = (!CurPosition.Context.ContainsKey("CurPackage") || !(CurPosition.Context["CurPackage"] as WipPkg).IsFinished) 
+	                                    || (CurPosition is YadaPacking && (CurPosition as YadaPacking).IsPrintCustomerLabel);
+	            if (NoNeedInStorePrint)
+	            {
+	                action = End(input);
+	            } 
+	            else
+	            {
+		            action.Data.Data = Label;
+		
+		            //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
+		            CurStep.Message = Biz.L("鎵撳嵃寮�濮�");
+		            CurStep.Status = StepStatus.Normal;
+		            action.IsSuccessed = true;
+		            action.Data.ShortMsg = new("鎵撳嵃寮�濮�", ShortMessage.Types.Success);
+	            }
             }
             return action;
         }
@@ -115,7 +122,7 @@
                 action.Data.ShortMsg = new("鎵撳嵃澶辫触", ShortMessage.Types.Failed);
                 action.IsSuccessed = false;
                 //action.LocaleMsg = new($"鍏ュ簱鏍囩{Label.LABEL_NAME}[{Label.LABEL_CODE}]鎵撳嵃澶辫触", Label.LABEL_NAME);
-                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.PrintFail", Label.LABEL_NAME, Label.LABEL_CODE);
+                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.PrintFail", Label?.LABEL_NAME, Label?.LABEL_CODE);
                 //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
                 if (NodeAct.NEED_RESET == "Y")
                 {
@@ -169,11 +176,11 @@
                     PRD_CODE = wipSn.PRD_CODE,
                     ACT_TYPE = NodeAct.ACT_TYPE,
                     ACT_SN = wipSn.SN,
-                    ACT_VALUE_1 = Label.LABEL_CODE,
-                    ACT_VALUE_2 = Label.Variables.ToJson(),
+                    ACT_VALUE_1 = Label?.LABEL_CODE,
+                    ACT_VALUE_2 = Label?.ToJson(),
                     ACT_RESULT = "Y",
                     ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(),
-                    TRACE_INFO = NoNeedInStorePrint ? $"鏃犻渶鎵撳嵃鍏ュ簱鏍囩" : $"鏍囩{Label.LABEL_NAME}[{Label.LABEL_CODE}]鎵撳嵃鎴愬姛",
+                    TRACE_INFO = NoNeedInStorePrint ? $"鏃犻渶鎵撳嵃鍏ュ簱鏍囩" : $"鏍囩{Label?.LABEL_NAME}[{Label?.LABEL_CODE}]鎵撳嵃鎴愬姛",
                 };
                 wipActs.Add(wipAct);
             }
@@ -194,7 +201,7 @@
                 CurStep.Status = StepStatus.Finished;
                 action.Data.ShortMsg = new("鏃犻渶鎵撳嵃", ShortMessage.Types.Success);
                 //action.LocaleMsg = new($"鏃犻渶鎵撳嵃鍏ュ簱鏍囩{0}[{1}]");
-                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.NoNeedPrint", Label.LABEL_NAME, Label.LABEL_CODE);
+                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.NoNeedPrint", Label?.LABEL_NAME, Label?.LABEL_CODE);
             } 
             else
             {
@@ -202,7 +209,7 @@
 	            CurStep.Status = StepStatus.Finished;
 	            action.Data.ShortMsg = new("鎵撳嵃瀹屾垚", ShortMessage.Types.Success);
                 //action.LocaleMsg = new($"鍏ュ簱鏍囩{0}[{1}鎵撳嵃鎴愬姛");
-                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.PrintSuccess", Label.LABEL_NAME, Label.LABEL_CODE);
+                action.LocaleMsg = new("MES.WorkAction.PrintInStoreLabel.PrintSuccess", Label?.LABEL_NAME, Label?.LABEL_CODE);
             }
             return action;
         }
diff --git a/Tiger.Business.MES/WorkAction/PrintLabel.cs b/Tiger.Business.MES/WorkAction/PrintLabel.cs
index a818341..ca49e4b 100644
--- a/Tiger.Business.MES/WorkAction/PrintLabel.cs
+++ b/Tiger.Business.MES/WorkAction/PrintLabel.cs
@@ -53,7 +53,7 @@
         /// <returns></returns>
         public Locale GetBeginMsg()
         {
-            var msg = new Locale("MES.WorkAction.PrintLabel.BeginMsg", CurPosition.CurSN, Label.LABEL_CODE, Label.LABEL_NAME);
+            var msg = new Locale("MES.WorkAction.PrintLabel.BeginMsg", CurPosition.CurSN, Label?.LABEL_CODE, Label?.LABEL_NAME);
             //var msg = new Locale($"寮�濮嬫墦鍗版潯鐮乕{CurPosition.CurWipSN.SN}]鐨勬爣绛綶{Label.LABEL_CODE}: {Label.LABEL_NAME}]");
             return msg;
         }
@@ -66,15 +66,22 @@
         {
             var action = new ApiAction<SubmitOutput>(new SubmitOutput());
 
-            //璁剧疆鎵撳嵃鍙橀噺鍊�
-            Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
-            action.Data.Data = Label;
+            if (Label.IsNullOrEmpty())
+            {
+                action = End(input);
+            }
+            else
+            {
+                //璁剧疆鎵撳嵃鍙橀噺鍊�
+                Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
+                action.Data.Data = Label;
 
-            //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
-            CurStep.Message = Biz.L("鎵撳嵃寮�濮�");
-            CurStep.Status = StepStatus.Normal;
-            action.IsSuccessed = true;
-            action.Data.ShortMsg = new("鎵撳嵃寮�濮�", ShortMessage.Types.Success);
+                //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
+                CurStep.Message = Biz.L("鎵撳嵃寮�濮�");
+                CurStep.Status = StepStatus.Normal;
+                action.IsSuccessed = true;
+                action.Data.ShortMsg = new("鎵撳嵃寮�濮�", ShortMessage.Types.Success);
+            }
             return action;
         }
 
@@ -98,7 +105,7 @@
                 action.Data.ShortMsg = new("鎵撳嵃澶辫触", ShortMessage.Types.Failed);
                 action.IsSuccessed = false;
                 //action.LocaleMsg = new($"鏍囩{Label.LABEL_NAME}[{Label.LABEL_CODE}]鎵撳嵃澶辫触", Label.LABEL_NAME);
-                action.LocaleMsg = new("MES.WorkAction.PrintLabel.PrintFail", Label.LABEL_NAME, Label.LABEL_CODE);
+                action.LocaleMsg = new("MES.WorkAction.PrintLabel.PrintFail", Label?.LABEL_NAME, Label?.LABEL_CODE);
                 //濡傛灉琛屼负璁剧疆涓哄嚭閿欓渶瑕侀噸缃伐搴忔搷浣�
                 if (NodeAct.NEED_RESET == "Y")
                 {
@@ -152,11 +159,11 @@
                     PRD_CODE = wipSn.PRD_CODE,
                     ACT_TYPE = NodeAct.ACT_TYPE,
                     ACT_SN = wipSn.SN,
-                    ACT_VALUE_1 = Label.LABEL_CODE,
-                    ACT_VALUE_2 = Label.Variables.ToJson(),
+                    ACT_VALUE_1 = Label?.LABEL_CODE,
+                    ACT_VALUE_2 = Label?.ToJson(),
                     ACT_RESULT = "Y",
                     ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(),
-                    TRACE_INFO = $"鏍囩{Label.LABEL_NAME}[{Label.LABEL_CODE}]鎵撳嵃鎴愬姛",
+                    TRACE_INFO = $"鏍囩{Label?.LABEL_NAME}[{Label?.LABEL_CODE}]鎵撳嵃鎴愬姛",
                 };
                 wipActs.Add(wipAct);
             }
@@ -175,7 +182,7 @@
             CurStep.Status = StepStatus.Finished;
             action.Data.ShortMsg = new("鎵撳嵃瀹屾垚", ShortMessage.Types.Success);
             //action.LocaleMsg = new($"鏍囩{Label.LABEL_NAME}[{Label.LABEL_CODE}]鎵撳嵃鎴愬姛", Label.LABEL_NAME);
-            action.LocaleMsg = new("MES.WorkAction.PrintLabel.PrintSuccess", Label.LABEL_NAME, Label.LABEL_CODE);
+            action.LocaleMsg = new("MES.WorkAction.PrintLabel.PrintSuccess", Label?.LABEL_NAME, Label?.LABEL_CODE);
             return action;
         }
 

--
Gitblit v1.9.3