From 9f487ef04f1cb9e1086d4e72346e3e2237ffd5c2 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 28 十二月 2024 15:51:16 +0800
Subject: [PATCH] 工单计划导入更新

---
 Tiger.Business.MES/Transaction/PackingNode.cs |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/PackingNode.cs b/Tiger.Business.MES/Transaction/PackingNode.cs
index 47d5edc..4621164 100644
--- a/Tiger.Business.MES/Transaction/PackingNode.cs
+++ b/Tiger.Business.MES/Transaction/PackingNode.cs
@@ -264,6 +264,8 @@
             {
                 action.Data.ShortMsg = new("宸ュ簭寮傚父", ShortMessage.Types.Error);
                 action.Data.OperInfo = CurOperInfo(input.Locale);
+                RemoveCurSnFromCurPackage(Context.ContainsKey("CurPackage") ? (Context["CurPackage"] as WipPkg).Item : null);
+                ResetNode();
                 //action.CatchExceptionWithLog(ex, $"鍖呰宸ュ簭锛氭彁浜ゆ搷浣滄暟鎹紓甯�");
                 action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException"));
             }
@@ -623,6 +625,7 @@
             catch (Exception ex)
             {
                 action.Data.ShortMsg = new("宸ユ寮傚父", ShortMessage.Types.Error);
+                RemoveCurSnFromCurPackage(Context.ContainsKey("CurPackage") ? (Context["CurPackage"] as WipPkg).Item : null);
                 ResetNode();
                 //action.CatchExceptionWithLog(ex, $"{curNode.NODE_NAME}锛氬伐搴忚妭鐐瑰伐姝ユ彁浜ゆ暟鎹紓甯革紝璇锋鏌ュ伐搴忚妭鐐硅缃�");
                 action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.NodeSubmitException", curNode.NODE_NAME));
@@ -858,6 +861,26 @@
             NodeCmd = null;
         }
 
+        public void RemoveCurSnFromCurPackage(WipPkgItem pkgItem)
+        {
+            if (!pkgItem.IsNullOrEmpty())
+            {
+                var delItem = pkgItem.Items.Where(q => CurWipSNs.Any(sn => q.WipSNs.ContainsKey(sn.ID))).ToList();
+                if (delItem.Any())
+                {
+                    pkgItem.Items.RemoveAll(q => CurWipSNs.Any(sn => q.WipSNs.ContainsKey(sn.ID)));
+                    pkgItem.IsFinished = false;
+                }
+                else
+                {
+                    foreach (var item in pkgItem.Items)
+                    {
+                        RemoveCurSnFromCurPackage(item);
+                    }
+                }
+            }
+        }
+
         public override bool Close(bool needSaveHistoryLog = false)
         {
             //needSaveHistoryLog = true;

--
Gitblit v1.9.3