From 582d7ab9eb6879f4b5f3e1b1b7d162f3d53a0e39 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期日, 27 十月 2024 14:12:32 +0800
Subject: [PATCH] Merge branch 'master' into master_ben

---
 Tiger.Business.MES/Transaction/Position.cs                       |    4 ++++
 Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs               |   10 ++++++++--
 Tiger.Business.MES/WorkAction/PackingAction.cs                   |   33 ++++++++++++++++++++++++++++++++-
 Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs |    1 +
 Tiger.IBusiness.MES/Transaction/IPosition.cs                     |    1 +
 5 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/Position.cs b/Tiger.Business.MES/Transaction/Position.cs
index 7c5b570..415cecb 100644
--- a/Tiger.Business.MES/Transaction/Position.cs
+++ b/Tiger.Business.MES/Transaction/Position.cs
@@ -62,6 +62,7 @@
         public WorkBatch CurBatch { get; set; }
         public IWorkBatch WorkBatch => CurBatch;
         public List<MES_WIP_DATA> CurWipSNs { get; set; } = new();
+        public List<MES_WIP_DATA> LastWipSNs { get; set; } = new();
         public string CurSN => (CurWipSNs.Any() ? (CurWipSNs.First().TRAY_SN.IsNullOrEmpty() ? CurWipSNs.First().SN : CurWipSNs.First().TRAY_SN) : "");
         public List<MES_WIP_HIS> CurWipSNHiss { get; set; } = new();
         public List<MES_WIP_DFT> CurDefects { get; set; } = new();
@@ -479,6 +480,9 @@
                     throw dbTran.ErrorException;
                 }
             }
+            //璁板綍鏈�鍚庢垚鍔熻繃绔欑殑鏉$爜
+            LastWipSNs.Clear();
+            LastWipSNs.AddRange(CurWipSNs);
         }
 
         protected void DoSaveToDB()
diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs
index d0cf4fb..885702d 100644
--- a/Tiger.Business.MES/WorkAction/PackingAction.cs
+++ b/Tiger.Business.MES/WorkAction/PackingAction.cs
@@ -230,6 +230,12 @@
                 data.PkgLevel = min.PKG_LEVEL;
                 data.PrintLable = LabelDic[min.PKG_LEVEL];
                 data.RealPrint = data.PkgLevel != CurPkg.Item.PKG_LEVEL || CurPosition is not YadaPacking || (CurPosition as YadaPacking).IsPrintCustomerLabel;
+                //鎵嬪姩缁撴潫鍖呰鏃讹紝濡傛灉鏄疪ealPrint涓篺alse锛屽垯杩斿洖褰撳墠鍖呰淇℃伅鐨勫叆搴撴爣绛惧苟鎵撳嵃
+                if (IsManually && !data.RealPrint && !CurPkg.InStoreLabel.IsNullOrEmpty())
+                {
+                    data.RealPrint = true;
+                    data.PrintLable = CurPkg.InStoreLabel;
+                }
                 CurCmd = data;
                 PrintTimes++;
                 CurStep?.SetStatusMessage(StepStatus.Normal, Biz.L("鎵撳嵃鏍囩"));
@@ -399,6 +405,12 @@
                                     data.PkgLevel = dtl.PKG_LEVEL;
                                     data.PrintLable = LabelDic[dtl.PKG_LEVEL];
                                     data.RealPrint = data.PkgLevel != CurPkg.Item.PKG_LEVEL || CurPosition is not YadaPacking || (CurPosition as YadaPacking).IsPrintCustomerLabel;
+                                    //鎵嬪姩缁撴潫鍖呰鏃讹紝濡傛灉鏄疪ealPrint涓篺alse锛屽垯杩斿洖褰撳墠鍖呰淇℃伅鐨勫叆搴撴爣绛惧苟鎵撳嵃
+                                    if (IsManually && !data.RealPrint && !CurPkg.InStoreLabel.IsNullOrEmpty())
+                                    {
+                                        data.RealPrint = true;
+                                        data.PrintLable = CurPkg.InStoreLabel;
+                                    }
                                     CurCmd = data;
                                     PrintTimes++;
                                     CurStep?.SetStatusMessage(StepStatus.Normal, Biz.L("鎵撳嵃鏍囩"));
@@ -497,6 +509,12 @@
                             data.PkgLevel = dtl.PKG_LEVEL;
                             data.PrintLable = LabelDic[dtl.PKG_LEVEL];
                             data.RealPrint = data.PkgLevel != CurPkg.Item.PKG_LEVEL || CurPosition is not YadaPacking || (CurPosition as YadaPacking).IsPrintCustomerLabel;
+                            //鎵嬪姩缁撴潫鍖呰鏃讹紝濡傛灉鏄疪ealPrint涓篺alse锛屽垯杩斿洖褰撳墠鍖呰淇℃伅鐨勫叆搴撴爣绛惧苟鎵撳嵃
+                            if (IsManually && !data.RealPrint && !CurPkg.InStoreLabel.IsNullOrEmpty())
+                            {
+                                data.RealPrint = true;
+                                data.PrintLable = CurPkg.InStoreLabel;
+                            }
                             CurCmd = data;
                             PrintTimes++;
                             CurStep?.SetStatusMessage(StepStatus.Normal, Biz.L("鎵撳嵃鏍囩"));
@@ -717,6 +735,12 @@
                                     data.PkgLevel = dtl.PKG_LEVEL;
                                     data.PrintLable = LabelDic[dtl.PKG_LEVEL];
                                     data.RealPrint = data.PkgLevel != CurPkg.Item.PKG_LEVEL || CurPosition is not YadaPacking || (CurPosition as YadaPacking).IsPrintCustomerLabel;
+                                    //鎵嬪姩缁撴潫鍖呰鏃讹紝濡傛灉鏄疪ealPrint涓篺alse锛屽垯杩斿洖褰撳墠鍖呰淇℃伅鐨勫叆搴撴爣绛惧苟鎵撳嵃
+                                    if (IsManually && !data.RealPrint && !CurPkg.InStoreLabel.IsNullOrEmpty())
+                                    {
+                                        data.RealPrint = true;
+                                        data.PrintLable = CurPkg.InStoreLabel;
+                                    }
                                     CurCmd = data;
                                     PrintTimes++;
                                     CurStep?.SetStatusMessage(StepStatus.Normal, Biz.L("鎵撳嵃鏍囩"));
@@ -923,6 +947,7 @@
                 if (CurPkg.IsFinished)
                 {
                     var _pkgList = CurPosition.GetPackageList(CurPkg.Item).Clone();
+                    var _lastWipID = CurPosition.LastWipSNs?.FirstOrDefault()?.ID;
 
                     //鏈�澶栧眰鍖呰宸茬粡瀹屾垚鍖呰锛屽垯鎶婂伐搴忎腑鏆傚瓨鏍囪璁句负false锛岀粺涓�鎻愪氦鍖呰鍐呬骇鍝佺殑杩囩珯璁板綍
                     CurPosition.NeedTemporaryStoreDBCommitAction = false;
@@ -959,6 +984,12 @@
                                 .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
                                 .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && q.ACT_ID == actID && wipIDs.Contains(q.WIP_ID))
                                 .ExecuteCommand();
+                            db.Updateable<MES_WIP_ACT>()
+                                .SetColumns(q => q.ACT_VALUE_1 == (CurPkg.IsFinished ? "Y" : "N"))
+                                .SetColumns(q => q.ACT_VALUE_2 == CurPkg.ToJson())
+                                .SetColumns(q => q.ACT_VALUE_3 == (CurPkg.IsFinished ? LabelDic[CurPkg.Item.PKG_LEVEL].ToJson() : ""))
+                                .Where(q => q.WORK_ORDER == wo && q.NODE_ID == nodeID && q.ACT_ID == actID && q.WIP_ID == _lastWipID)
+                                .ExecuteCommand();
                             //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃
                             db.Updateable<BIZ_MES_WO_SN>()
                                 .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
@@ -968,7 +999,7 @@
                         }
                     });
                     //濡傛灉褰撳墠鏉$爜宸茬粡瀹屽伐锛屾鏌ュ綋鍓嶅伐鍗曟壒娆″拰宸ュ崟鏄惁瀹屽伐
-                    if (CurPkg.IsReachedEndNode)
+                    //if (CurPkg.IsReachedEndNode)
                     {
                         CurPosition.WorkBatch.CheckIsComplete(CurPosition.UserCode);
                     }
diff --git a/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs b/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
index 84c318f..6fbe831 100644
--- a/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
+++ b/Tiger.Business.MES/WorkAction/PrintInStoreLabel.cs
@@ -68,6 +68,14 @@
         {
             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)
@@ -76,8 +84,6 @@
             } 
             else
             {
-	            //璁剧疆鎵撳嵃鍙橀噺鍊�
-	            Label = CurPosition.SetLabelVariables(LabelPV, Label, this);
 	            action.Data.Data = Label;
 	
 	            //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
diff --git a/Tiger.IBusiness.MES/Transaction/IPosition.cs b/Tiger.IBusiness.MES/Transaction/IPosition.cs
index 00e49f9..e3116a0 100644
--- a/Tiger.IBusiness.MES/Transaction/IPosition.cs
+++ b/Tiger.IBusiness.MES/Transaction/IPosition.cs
@@ -20,6 +20,7 @@
         public MES_POSITION CurPosition { get; set; }
         public IWorkBatch WorkBatch { get; }
         public List<MES_WIP_DATA> CurWipSNs { get; set; }
+        public List<MES_WIP_DATA> LastWipSNs { get; set; }
         public string CurSN { get; }
         public List<MES_WIP_HIS> CurWipSNHiss { get; set; }
         public Dictionary<string, object> Context { get; set; }
diff --git a/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs b/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs
index dd09f36..82074a3 100644
--- a/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs
+++ b/Tiger.Model.Net/Entitys/MES/ParameterEntity/PositionParameter.cs
@@ -177,6 +177,7 @@
         public WeightInfo WeightInfo { get; set; } = new WeightInfo();
         public bool IsFinished => Item.IsFinished;
         public bool IsReachedEndNode { get; set; } = false;
+        public BAS_LABEL_TEMP InStoreLabel { get; set; }
     }
 
     /// <summary>

--
Gitblit v1.9.3