From 24c0e02411353dd5ea2c17449ef4cd1a0db1ce82 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 19 十二月 2024 17:04:14 +0800
Subject: [PATCH] 入库标签也是出货标签时也需要HWDate, LOTNO

---
 Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs b/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
index e066dbd..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,7 @@
         #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
 
@@ -36,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;
@@ -67,6 +70,7 @@
         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 (Label.IsNullOrEmpty())
             {
@@ -76,14 +80,14 @@
             {
 	            //璁剧疆鎵撳嵃鍙橀噺鍊�
 	            Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
-	            if (CurPosition.Context.ContainsKey("CurPackage"))
+	            if (!CurPkg.IsNullOrEmpty())
 	            {
-                    (CurPosition.Context["CurPackage"] as WipPkg).InStoreActID = NodeAct.ID;
-                    (CurPosition.Context["CurPackage"] as WipPkg).InStoreLabel = Label;
+                    CurPkg.InStoreActID = NodeAct.ID;
+                    CurPkg.InStoreLabel = Label;
 	            }
 	
 	            //鍒ゆ柇鏄惁闇�瑕佹墦鍗板叆搴撴爣绛�
-	            NoNeedInStorePrint = (!CurPosition.Context.ContainsKey("CurPackage") || !(CurPosition.Context["CurPackage"] as WipPkg).IsFinished) 
+	            NoNeedInStorePrint = (CurPkg.IsNullOrEmpty() || !CurPkg.IsFinished) 
 	                                    || (CurPosition is YadaPacking && (CurPosition as YadaPacking).IsPrintCustomerLabel);
 	            if (NoNeedInStorePrint)
 	            {
@@ -140,7 +144,6 @@
         {
             var action = new ApiAction<SubmitOutput>(new SubmitOutput());
 
-            var CurPkg = CurPosition.Context.ContainsKey("CurPackage") ? CurPosition.Context["CurPackage"] as WipPkg : null;
             //璁板綍琛屼负鎿嶄綔璁板綍
             var wipActs = new List<MES_WIP_ACT>();
             foreach (var wipSn in CurPosition.CurWipSNs)
@@ -181,7 +184,7 @@
                     ACT_VALUE_1 = CurPkg?.IsFinished == true ? "Y" : "N",
                     ACT_VALUE_2 = CurPkg?.ToJson(),
                     ACT_VALUE_3 = Label?.ToJson(),
-                    ACT_VALUE_4 = "InStroe",
+                    ACT_VALUE_4 = "InStore",
                     ACT_RESULT = "Y",
                     ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(),
                     TRACE_INFO = NoNeedInStorePrint ? $"鏃犻渶鎵撳嵃鍏ュ簱鏍囩" : $"鏍囩{Label?.LABEL_NAME}[{Label?.LABEL_CODE}]鎵撳嵃鎴愬姛",

--
Gitblit v1.9.3