From 31c6d37a388e80719a3575717917fcf9689a1a93 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期三, 09 十月 2024 16:06:10 +0800
Subject: [PATCH] 修复工序设置没有错误字段的bug

---
 Tiger.Business.MES/WorkAction/PackingAction.cs |   46 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs
index 789e0be..a8fbe4d 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;
@@ -270,11 +271,11 @@
                         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 +749,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());
@@ -869,10 +891,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();
@@ -894,11 +919,6 @@
                         }
                     }
                 });
-                if (!dbTran.IsSuccess)
-                {
-                    //鎶涘嚭寮傚父
-                    throw dbTran.ErrorException;
-                }
             }
 
             if (CurPkg.IsFinished)

--
Gitblit v1.9.3