From 3f364634b79a0f97a550c54f67313dfc0cfd4cb5 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期三, 27 十一月 2024 22:16:01 +0800
Subject: [PATCH] 一大波签入来了

---
 Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs |   76 ++++++++++++++++++++++++++-----------
 1 files changed, 53 insertions(+), 23 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs b/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
index 545a495..2a79431 100644
--- a/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
+++ b/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
@@ -17,6 +17,7 @@
     {
         #region Propertys & Variables
         #region 鍥哄畾鍐欐硶锛屽伐搴忎腑鐨勫繀瑕佷俊鎭�
+        public DbClient MainDB { get; set; }
         public bool IsFinished { get; set; } = false;
         public IWorkStep CurStep { get; set; }
         public IPosition CurPosition { get; set; }
@@ -25,6 +26,8 @@
         #endregion
         public BAS_LABEL_TEMP Label { get; set; }
         public List<BAS_LABEL_PV> LabelPV { get; set; }
+        public WipPkg CurPkg { get; set; }
+        public bool NoNeedInStorePrint { get; set; }
         #endregion Propertys & Variables
 
         #region Functions
@@ -35,14 +38,15 @@
         public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting)
         {
             #region 鍥哄畾鍐欐硶锛岀粰榛樿鍙橀噺璧嬪��
+            MainDB = position.MainDB;
             CurStep = curStep;
             CurPosition = position;
             NodeAct = nodeAct;
             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();
+            Label = MainDB.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == setting.LABEL_CODE).IncludesAllFirstLayer().First();
+            LabelPV = MainDB.Queryable<BAS_LABEL_PV>().ToList();
 
             CurStep.Message = Biz.L("绛夊緟鏍囩鎵撳嵃");
             CurStep.Status = StepStatus.Normal;
@@ -54,7 +58,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;
         }
@@ -66,8 +70,9 @@
         public ApiAction<SubmitOutput> TryBegin(SubmitInput input)
         {
             var action = new ApiAction<SubmitOutput>(new SubmitOutput());
+            CurPkg = CurPosition.Context.ContainsKey("CurPackage") ? CurPosition.Context["CurPackage"] as WipPkg : null;
 
-            if (CurPosition is YadaPacking && !(CurPosition as YadaPacking).IsPrintCustomerLabel)
+            if (Label.IsNullOrEmpty())
             {
                 action = End(input);
             } 
@@ -75,13 +80,29 @@
             {
 	            //璁剧疆鎵撳嵃鍙橀噺鍊�
 	            Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
-	            action.Data.Data = Label;
+	            if (!CurPkg.IsNullOrEmpty())
+	            {
+                    CurPkg.InStoreActID = NodeAct.ID;
+                    CurPkg.InStoreLabel = Label;
+	            }
 	
-	            //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
-	            CurStep.Message = Biz.L("鎵撳嵃寮�濮�");
-	            CurStep.Status = StepStatus.Normal;
-	            action.IsSuccessed = true;
-	            action.Data.ShortMsg = new("鎵撳嵃寮�濮�", ShortMessage.Types.Success);
+	            //鍒ゆ柇鏄惁闇�瑕佹墦鍗板叆搴撴爣绛�
+	            NoNeedInStorePrint = (CurPkg.IsNullOrEmpty() || !CurPkg.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;
         }
@@ -106,7 +127,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")
                 {
@@ -160,16 +181,14 @@
                     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 = CurPkg?.IsFinished == true ? "Y" : "N",
+                    ACT_VALUE_2 = CurPkg?.ToJson(),
+                    ACT_VALUE_3 = Label?.ToJson(),
+                    ACT_VALUE_4 = "InStore",
                     ACT_RESULT = "Y",
                     ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(),
-                    TRACE_INFO = $"鏍囩{Label.LABEL_NAME}[{Label.LABEL_CODE}]鎵撳嵃鎴愬姛",
+                    TRACE_INFO = NoNeedInStorePrint ? $"鏃犻渶鎵撳嵃鍏ュ簱鏍囩" : $"鏍囩{Label?.LABEL_NAME}[{Label?.LABEL_CODE}]鎵撳嵃鎴愬姛",
                 };
-                if (CurPosition is YadaPacking && !(CurPosition as YadaPacking).IsPrintCustomerLabel)
-                {
-                    wipAct.TRACE_INFO = $"鏃犻渶鎵撳嵃鍏ュ簱鏍囩";
-                }
                 wipActs.Add(wipAct);
             }
 
@@ -183,11 +202,22 @@
             };
 
             IsFinished = true;
-            CurStep.Message = Biz.L("鎵撳嵃瀹屾垚");
-            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.PrintInStoreLabel.PrintSuccess", Label.LABEL_NAME, Label.LABEL_CODE);
+            if (NoNeedInStorePrint)
+            {
+                CurStep.Message = Biz.L("鏃犻渶鎵撳嵃");
+                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);
+            } 
+            else
+            {
+	            CurStep.Message = Biz.L("鎵撳嵃瀹屾垚");
+	            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);
+            }
             return action;
         }
 

--
Gitblit v1.9.3