From 8ccb8c4d10bff43b884005426110b5ec234a1cbb Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期三, 07 八月 2024 15:44:09 +0800
Subject: [PATCH] 更新MES工序事务跟工序行为中保存数据操作的写法

---
 Tiger.Business.MES/Transaction/CollectNode.cs |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/CollectNode.cs b/Tiger.Business.MES/Transaction/CollectNode.cs
index b95fab6..3c688ed 100644
--- a/Tiger.Business.MES/Transaction/CollectNode.cs
+++ b/Tiger.Business.MES/Transaction/CollectNode.cs
@@ -321,6 +321,14 @@
                         CurWipSNHiss.Add(new MES_WIP_HIS(wipSN, $"宸ュ崟[{wipSN.WORK_ORDER}]鏉$爜[{wipSN.SN}]鍦ㄥ矖浣峓{wipSN.POST_CODE}]杩囩珯宸ュ簭[{wipSN.NODE_NAME}]鎴愬姛"));
                     }
 
+                    //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊�
+                    var _woSns = woSNs.Clone();
+                    var _wipSns = wipSNs.Clone();
+                    var _wipHiss = CurWipSNHiss.Clone();
+                    var _defect = CurDefects.Clone();
+                    var _curNode = curNode.Clone();
+                    var _Batch = CurBatch.Batch.Clone();
+
                     //鍒濆鍖栧伐姝ュ垪琛�
                     Steps.Clear();
                     var curStep = new Biz.WorkStep(IWorkStep.Types.Node, this)
@@ -329,26 +337,28 @@
                         Node = curNode,
                         DBSubmitAction = () =>
                         {
+                            //浣跨敤缁熶竴鐨勪簨鍔B瀵硅薄
                             var db = GetCommitDB();
-                            db.Storageable(woSNs, UserCode).ExecuteCommand();
-                            db.Storageable(wipSNs, UserCode).ExecuteCommand();
-                            db.Storageable(CurWipSNHiss, UserCode).ExecuteCommand();
+                            //鏁版嵁淇濆瓨閫昏緫
+                            db.Storageable(_woSns, UserCode).ExecuteCommand();
+                            db.Storageable(_wipSns, UserCode).ExecuteCommand();
+                            db.Storageable(_wipHiss, UserCode).ExecuteCommand();
                             //濡傛灉鏈変笉鑹垯淇濆瓨
-                            if (CurDefects.Any())
+                            if (_defect.Any())
                             {
-                                db.Storageable(CurDefects, UserCode).ExecuteCommand();
+                                db.Storageable(_defect, UserCode).ExecuteCommand();
                             }
                             //濡傛灉鏄姇鍏ョ珯
-                            if (curNode.IS_INPUT == "Y")
+                            if (_curNode.IS_INPUT == "Y")
                             {
-                                db.Updateable<BIZ_MES_WO>().SetColumns(q => q.INPUT_QTY == q.INPUT_QTY + wipSNs.Count).Where(q => q.ORDER_NO == CurBatch.WO.ORDER_NO).ExecuteCommand();
-                                db.Updateable<BIZ_MES_WO_BATCH>().SetColumns(q => q.INPUT_QTY == q.INPUT_QTY + wipSNs.Count).Where(q => q.BATCH_NO == CurBatch.Batch.BATCH_NO).ExecuteCommand();
+                                db.Updateable<BIZ_MES_WO>().SetColumns(q => q.INPUT_QTY == q.INPUT_QTY + _woSns.Count).Where(q => q.ORDER_NO == _Batch.ORDER_NO).ExecuteCommand();
+                                db.Updateable<BIZ_MES_WO_BATCH>().SetColumns(q => q.INPUT_QTY == q.INPUT_QTY + _woSns.Count).Where(q => q.BATCH_NO == _Batch.BATCH_NO).ExecuteCommand();
                             }
                             //濡傛灉鏄骇鍑虹珯
-                            if (curNode.IS_OUTPUT == "Y")
+                            if (_curNode.IS_OUTPUT == "Y")
                             {
-                                db.Updateable<BIZ_MES_WO>().SetColumns(q => q.OUTPUT_QTY == q.OUTPUT_QTY + wipSNs.Count).Where(q => q.ORDER_NO == CurBatch.WO.ORDER_NO).ExecuteCommand();
-                                db.Updateable<BIZ_MES_WO_BATCH>().SetColumns(q => q.OUTPUT_QTY == q.OUTPUT_QTY + wipSNs.Count).Where(q => q.BATCH_NO == CurBatch.Batch.BATCH_NO).ExecuteCommand();
+                                db.Updateable<BIZ_MES_WO>().SetColumns(q => q.OUTPUT_QTY == q.OUTPUT_QTY + _woSns.Count).Where(q => q.ORDER_NO == _Batch.ORDER_NO).ExecuteCommand();
+                                db.Updateable<BIZ_MES_WO_BATCH>().SetColumns(q => q.OUTPUT_QTY == q.OUTPUT_QTY + _woSns.Count).Where(q => q.BATCH_NO == _Batch.BATCH_NO).ExecuteCommand();
                             }
                         }
                     };

--
Gitblit v1.9.3