From 9fe67118a220448d5d9647733d6c8308f069e4da Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期日, 13 十月 2024 16:05:23 +0800
Subject: [PATCH] 增加工艺路线必须要有结束节点,及其流程相应优化 增加工单批次自动关单 增加判断条码是未投入生产还是已经完工产出

---
 Tiger.Business.MES/WorkAction/PackingAction.cs |   52 ++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs
index 3a074e2..b296a5a 100644
--- a/Tiger.Business.MES/WorkAction/PackingAction.cs
+++ b/Tiger.Business.MES/WorkAction/PackingAction.cs
@@ -1,4 +1,5 @@
-锘縰sing Rhea.Common;
+锘縰sing Microsoft.CodeAnalysis.Differencing;
+using Rhea.Common;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -218,6 +219,7 @@
                 CurCmd = data;
                 PrintTimes++;
                 CurStep?.SetStatusMessage(StepStatus.Normal, Biz.L("鎵撳嵃鏍囩"));
+                action.IsSuccessed = true;
                 action.Data.Data = data;
                 action.Data.ShortMsg = new("鎵撳嵃鏍囩", ShortMessage.Types.Normal);
                 //action.LocaleMsg = new Locale($"寮�濮嬬{PrintTimes}娆℃墦鍗扮{min.PKG_LEVEL}灞傚寘瑁匸{min.PkgType.PKG_NAME}]鐨勬爣绛綶{LabelDic[min.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[min.PKG_LEVEL].LABEL_NAME}]");
@@ -225,7 +227,7 @@
             }
 
             //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
-            action.IsSuccessed = true;
+            //action.IsSuccessed = true;
             return action;
         }
 
@@ -253,6 +255,7 @@
                             action.IsSuccessed = false;
                             //action.LocaleMsg = new($"鏉$爜鎵弿澶辫触锛岃閲嶆柊鎵弿绗瑊dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�");
                             action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanFail", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME);
+                            CurPosition.ResetNode();
                             return action;
                         }
                         //楠岃瘉褰撳墠鍖呰鏉$爜鏄惁宸茬粡琚壂鎻忚繃
@@ -264,17 +267,18 @@
                             action.IsSuccessed = false;
                             //action.LocaleMsg = new($"鏉$爜[{pInput.PkgSN}]鏃犻渶閲嶅鎵弿锛岃鎵弿绗瑊dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�");
                             action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanRepeat", pInput.PkgSN, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME);
+                            CurPosition.ResetNode();
                             return action;
                         }
                         //瀹㈡埛绔壂鎻忔垚鍔�
                         CurCmd = null;
                         PrintTimes = 0;
                         action = SavePkgData(input, action);
-                        if (action.IsSuccessed)
-                        {
-                            CurStep?.SetStatusMessage(StepStatus.Success, Biz.L("鎵弿鎴愬姛"));
-                            action.Data.ShortMsg = new("鎵弿鎴愬姛", ShortMessage.Types.Success);
-                        }
+                        //if (action.IsSuccessed)
+                        //{
+                        //    CurStep?.SetStatusMessage(StepStatus.Success, Biz.L("鎵弿鎴愬姛"));
+                        //    action.Data.ShortMsg = new("鎵弿鎴愬姛", ShortMessage.Types.Success);
+                        //}
                     }
                     break;
                 //Print锛氭墦鍗帮紝鎵撳嵃褰撳墠鍖呰灞傜骇鐨勬爣绛�
@@ -748,6 +752,27 @@
             return list;
         }
 
+        public List<MES_WIP_PKG> GetMinPackageList(WipPkgItem parent)
+        {
+            List<MES_WIP_PKG> list = new();
+            if (parent.Items.Any())
+            {
+	            foreach (var item in parent.Items)
+	            {
+	                item.Package.PARENT_SN = parent.Package?.SN;
+	                list.AddRange(GetMinPackageList(item));
+	            }
+            } 
+            else
+            {
+                if (!parent.Package.IsNullOrEmpty())
+                {
+                    list.Add(parent.Package);
+                }
+            }
+            return list;
+        }
+
         public ApiAction<SubmitOutput> CompletePkg()
         {
             var action = new ApiAction<SubmitOutput>(new SubmitOutput());
@@ -827,6 +852,7 @@
                         ACT_TYPE = NodeAct.ACT_TYPE,
                         ACT_SN = wipSn.SN,
                         ACT_RESULT = "Y",
+                        ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(),
                         TRACE_INFO = $"浜у搧鏉$爜[{string.Join("锛�", CurPosition.CurSN)}]鍖呰瀹屾垚",
                     };
                     wipActs.Add(wipAct);
@@ -868,10 +894,13 @@
             else
             {
                 var _pkgList = CurPkg.IsFinished ? GetPackageList(CurPkg.Item) : new();
+               
+                //鏈�澶栧眰鍖呰宸茬粡瀹屾垚鍖呰锛屽垯鎶婂伐搴忎腑鏆傚瓨鏍囪璁句负false锛岀粺涓�鎻愪氦鍖呰鍐呬骇鍝佺殑杩囩珯璁板綍
+                CurPosition.NeedTemporaryStoreDBCommitAction = false;
                 //淇濆瓨鏁版嵁
-                var db = Biz.Db;
-                var dbTran = db.UseTran(() =>
+                CurPosition.SaveStepsCommitActionToDB(() =>
                 {
+                    var db = CurPosition.GetCommitDB();
                     if (_pkgList.Any())
                     {
                         db.Storageable(_pkgList, CurPosition.UserCode).ExecuteCommand();
@@ -893,11 +922,6 @@
                         }
                     }
                 });
-                if (!dbTran.IsSuccess)
-                {
-                    //鎶涘嚭寮傚父
-                    throw dbTran.ErrorException;
-                }
             }
 
             if (CurPkg.IsFinished)

--
Gitblit v1.9.3