From de99d955d820ae4905eec32a34fe59d0bbab0d02 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 08 八月 2024 18:52:29 +0800
Subject: [PATCH] WoContext增加从工单批次字典中删除一个工单批次对象

---
 Tiger.Business/MES/Biz.WorkBatch.cs |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Tiger.Business/MES/Biz.WorkBatch.cs b/Tiger.Business/MES/Biz.WorkBatch.cs
index a34b4a8..77a846b 100644
--- a/Tiger.Business/MES/Biz.WorkBatch.cs
+++ b/Tiger.Business/MES/Biz.WorkBatch.cs
@@ -41,6 +41,7 @@
             public List<MES_WO_NODE_POST> NodePosts { get; set; }
             public List<MES_WO_NODE_DFTG> NodeDftgs { get; set; }
             public List<BAS_DEFECT_GRP> DefectGroups { get; set; }
+            public List<BAS_DEFECT> Defects => DefectGroups.SelectMany(q => q.Defects).ToList();
             /// <summary>
             /// 浜嬪姟閿�
             /// </summary>
@@ -55,7 +56,7 @@
             public WorkBatch Init(string lineCode)
             {
                 LineCode = lineCode;
-                WO = Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == OrderNo).First();
+                WO = Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == OrderNo).IncludesAllFirstLayer().First();
                 Product = Biz.Db.Queryable<BAS_ITEM>().Where(q => q.ITEM_CODE == WO.ITEM_CODE && q.AUTH_ORG == WO.AUTH_ORG).First();
                 Batch = Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(q => q.ORDER_NO == OrderNo && q.ACT_LINE == LineCode).First();
                 Customer = Biz.Db.Queryable<BAS_CUSTOMER>().Where(q => q.CUST_CODE == WO.CUST_CODE).First();    
@@ -114,7 +115,7 @@
             {
                 var action = new ApiAction<SubmitOutput>(new SubmitOutput(), true);
 
-                WO = Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == OrderNo).First();
+                WO = Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == OrderNo).IncludesAllFirstLayer().First();
                 Batch = Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(q => q.ORDER_NO == OrderNo && q.ACT_LINE == LineCode).First();
                 //宸ュ崟鎵规鐘舵�佷笉鏄凡涓嬪彂鎴栬�呯敓浜т腑锛屽垯涓嶅厑璁哥敓浜�
                 if (Batch.STATUS != BIZ_MES_WO_BATCH.STATUSs.Release.GetValue() && Batch.STATUS != BIZ_MES_WO_BATCH.STATUSs.Working.GetValue())
@@ -244,7 +245,7 @@
                         action.IsSuccessed = false;
                         action.Data.SetValue(this, null);
                         var nextList = Nodes.Where(q => q.IS_FIRST_NODE == "Y");
-                        action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", wipSN.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (q.CAN_SKIP == "Y" ? $"({T(L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
+                        action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", input.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (q.CAN_SKIP == "Y" ? $"({T(L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
                         return action;
                     }
                 }
@@ -279,7 +280,7 @@
                             action.IsSuccessed = false;
                             action.Data.SetValue(this, null);
                             var nextList = reflowNodes.Where(q => wipSN.REFLOW_NODE.IsNullOrEmpty() || wipSN.REFLOW_NODE == q.NODE_NAME);
-                            action.LocaleMsg = new("MES.WorkBatch.ReflowToNodeException", nextNode.NODE_NAME, wipSN.SN, curNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (q.CAN_SKIP == "Y" ? $"({T(L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
+                            action.LocaleMsg = new("MES.WorkBatch.ReflowToNodeException", nextNode.NODE_NAME, input.SN, curNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (q.CAN_SKIP == "Y" ? $"({T(L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
                             return action;
                         }
                     }
@@ -289,7 +290,7 @@
                     {
                         action.IsSuccessed = false;
                         action.Data.SetValue(this, null);
-                        action.LocaleMsg = new("MES.WorkBatch.PleaseGotoRepair", curNode.NODE_NAME, wipSN.SN);
+                        action.LocaleMsg = new("MES.WorkBatch.PleaseGotoRepair", curNode.NODE_NAME, input.SN);
                         return action;
                     }
                     //姝e父宸ュ簭杩囩珯
@@ -310,7 +311,7 @@
                             action.IsSuccessed = false;
                             action.Data.SetValue(this, null);
                             var nextList = nextNodes.Where(q => NodeSets.Any(s => s.NODE_ID == q.ID && s.IS_ACTIVE == "Y" && s.CAN_SKIP != "Y"));
-                            action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", wipSN.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (q.CAN_SKIP == "Y" ? $"({T(L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
+                            action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", input.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (q.CAN_SKIP == "Y" ? $"({T(L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
                             return action;
                         }
                         //濡傛灉褰撳墠宸ュ簭娌℃湁蹇呴』鎵ц鐨勫悗缁伐搴忥紝鍒欏湪鍓嶇疆宸ュ簭鏌ユ壘杩樻湁娌℃湁鍚庣画宸ュ簭娌″畬鎴愮殑宸ュ簭锛屾湁鍒欏皾璇曟墽琛�
@@ -339,7 +340,7 @@
                                 action.IsSuccessed = false;
                                 action.Data.SetValue(this, null);
                                 var nextList = nextNodes.Where(q => NodeSets.Any(s => s.NODE_ID == q.ID && s.IS_ACTIVE == "Y"));
-                                action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", wipSN.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (q.CAN_SKIP == "Y" ? $"({T(L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
+                                action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", input.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (q.CAN_SKIP == "Y" ? $"({T(L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
                                 return action;
                             }
                         }

--
Gitblit v1.9.3