From 04dcc3ed97efac23ec778dec4a6afddc6cd9aa65 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期五, 16 八月 2024 00:41:22 +0800
Subject: [PATCH] 包装行为增加称重功能

---
 Tiger.Business.MES/Transaction/PackingNode.cs |   92 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 74 insertions(+), 18 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/PackingNode.cs b/Tiger.Business.MES/Transaction/PackingNode.cs
index 1d3f193..af22a2f 100644
--- a/Tiger.Business.MES/Transaction/PackingNode.cs
+++ b/Tiger.Business.MES/Transaction/PackingNode.cs
@@ -212,7 +212,8 @@
 	                var wipSN = new MES_WIP_DATA()
 	                {
 	                    SN = input.SN,
-	                    STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(),
+                        FLOW_SN = input.SN,
+                        STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(),
 	                    ITEM_CODE = CurBatch.WO.ITEM_CODE,
 	                    WORK_ORDER = CurBatch.Batch.ORDER_NO,
 	                    BATCH_NO = CurBatch.Batch.BATCH_NO,
@@ -242,6 +243,7 @@
                             CurBatch.WoSNs.Add(new()
                             {
                                 WORK_ORDER = CurBatch.Batch.ORDER_NO,
+                                WIP_ID = wipSN.ID,
                                 SN = wipSN.SN,
                                 TRAY_SN = wipSN.TRAY_SN,
                                 STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(),
@@ -304,6 +306,43 @@
                             wipSN.DFT_FLAG = "Y";
                             wipSN.DFT_COUNT++;
                             wipSN.DFT_CODE = input.DFT_CODE;
+                            var dft = CurBatch.Defects.FirstOrDefault(q => q.DFT_CODE == wipSN.DFT_CODE);
+                            var defect = new MES_WIP_DFT()
+                            {
+                                AUTH_ORG = wipSN.AUTH_ORG,
+                                AUTH_PROD = wipSN.LINE_CODE,
+                                WIP_ID = wipSN.ID,
+                                SN = wipSN.SN,
+                                STATUS = MES_WIP_DFT.STATUSs.WaitHandle.GetValue(),
+                                ITEM_CODE = wipSN.ITEM_CODE,
+                                WORK_ORDER = wipSN.WORK_ORDER,
+                                BATCH_NO = wipSN.BATCH_NO,
+                                ROT_CODE = wipSN.ROT_CODE,
+                                NODE_ID = wipSN.NODE_ID,
+                                NODE_NAME = wipSN.NODE_NAME,
+                                FTY_CODE = wipSN.FTY_CODE,
+                                WS_CODE = wipSN.WS_CODE,
+                                LINE_CODE = wipSN.LINE_CODE,
+                                POST_CODE = wipSN.POST_CODE,
+                                OPER_CODE = wipSN.OPER_CODE,
+                                SEGMENT = wipSN.SEGMENT,
+                                DFT_CODE = dft.DFT_CODE,
+                                DFT_NAME = dft.DFT_NAME,
+                                DFT_LEVEL = dft.DFT_LEVEL,
+                                FLOW_SN = wipSN.FLOW_SN,
+                                TRAY_SN = wipSN.TRAY_SN,
+                                INNER_SN = wipSN.INNER_SN,
+                                CARTON_SN = wipSN.CARTON_SN,
+                                PALLET_SN = wipSN.PALLET_SN,
+                                INV_FLAG = wipSN.INV_FLAG,
+                                OPERATION_TIME = DateTime.Now,
+                                SFTS_CODE = wipSN.SFTS_CODE,
+                                SFT_CODE = wipSN.SFT_CODE,
+                                PRD_CODE = wipSN.PRD_CODE,
+                                OBA_BATCH = wipSN.OBA_BATCH,
+                                LOCK_BATCH = wipSN.LOCK_BATCH,
+                            };
+                            CurDefects.Add(defect);
                         }
                     }
 
@@ -318,6 +357,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) 
@@ -326,21 +373,28 @@
 	                    Node = curNode,
 	                    DBSubmitAction = () =>
 	                    {
-	                        var db = GetCommitDB();
-	                        db.Storageable(woSNs, UserCode).ExecuteCommand();
-	                        db.Storageable(wipSNs, UserCode).ExecuteCommand();
-	                        db.Storageable(CurWipSNHiss, UserCode).ExecuteCommand();
-                            //濡傛灉鏄姇鍏ョ珯
-                            if (curNode.IS_INPUT == "Y")
+                            //浣跨敤缁熶竴鐨勪簨鍔B瀵硅薄
+                            var db = GetCommitDB();
+                            //鏁版嵁淇濆瓨閫昏緫
+	                        db.Storageable(_woSns, UserCode).ExecuteCommand();
+	                        db.Storageable(_wipSns, UserCode).ExecuteCommand();
+	                        db.Storageable(_wipHiss, UserCode).ExecuteCommand();
+                            //濡傛灉鏈変笉鑹垯淇濆瓨
+                            if (_defect.Any())
                             {
-                                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.Storageable(_defect, UserCode).ExecuteCommand();
+                            }
+                            //濡傛灉鏄姇鍏ョ珯
+                            if (_curNode.IS_INPUT == "Y")
+                            {
+                                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();
                             }
                         }
 	                };
@@ -376,7 +430,6 @@
                 //鏈畬鎴愭墍鏈夊伐姝�
                 if (!IsFinishAllSteps)
                 {
-                    var result = new ApiAction<SubmitOutput>(new SubmitOutput());
                     //鏈畬鎴愭墍鏈夊伐搴忚妭鐐瑰伐姝�
                     if (!IsFinishNodeSteps)
                     {
@@ -385,14 +438,14 @@
                         NextSteps.Clear();
                         NextSteps.Add(next);
                         //鏍规嵁鍚庣画宸ユ杩斿洖ApiAction
-                        result.Data.SetValue(CurBatch, CurStep, next.ID, IsFinishAllSteps);
+                        action.Data.SetValue(CurBatch, CurStep, next.ID, IsFinishAllSteps);
 
                         //鏍规嵁宸ュ簭鑺傜偣宸ユ鐨勫簭鍙疯繑鍥炵浉搴旂殑鎿嶄綔鎻愮ず
                         switch (next.Sequence)
                         {
                             case 2:
                                 //action.LocaleMsg = new($"璇锋墽琛岀浜屾");
-                                result.LocaleMsg = new("MES.Transaction.CollectNode.绗簩姝ユ搷浣滄彁绀�");
+                                action.LocaleMsg = new("MES.Transaction.CollectNode.绗簩姝ユ搷浣滄彁绀�");
                                 break;
                             default:
                                 break;
@@ -401,9 +454,8 @@
                     //宸插畬鎴愭墍鏈夊伐搴忚妭鐐瑰伐姝ワ紝寮�濮嬫墽琛岃涓哄伐姝�
                     else
                     {
-                        result = BeginNextActionStep(input);
+                        action = BeginNextActionStep(input);
                     }
-                    return result;
                 }
                 //宸插畬鎴愭墍鏈夊伐姝�
                 if (IsFinishAllSteps)
@@ -435,7 +487,11 @@
             //action.LocaleMsg = new($"宸ュ崟[{CurWipSN.WORK_ORDER}]鐨勬潯鐮乕{CurWipSN.SN}]鍦ㄥ矖浣峓{CurWipSN.POST_CODE}]宸ュ簭[{CurWipSN.NODE_NAME}]杩囩珯鎴愬姛锛岀姸鎬乕{CurWipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]");
             action.LocaleMsg = new("MES.Transaction.CollectNode.ScanSn.PassSuccess", CurWipSNs.First().WORK_ORDER, CurSN, CurWipSNs.First().POST_CODE, CurWipSNs.First().NODE_NAME,CurWipSNs.First().STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>());
             //閲嶇疆宸ュ簭
-            ResetNode();
+            //if (!isClone)
+            {
+                ResetNode();
+            }
+            
             return action;
         }
 

--
Gitblit v1.9.3