From 76e5a482a1be93af036ff6d75d367c7401810682 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期一, 14 十月 2024 17:04:27 +0800
Subject: [PATCH] 增加雅达生产报工行为(缺报工逻辑)

---
 Tiger.Business.MES/Transaction/PackingNode.cs |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/PackingNode.cs b/Tiger.Business.MES/Transaction/PackingNode.cs
index ebb5779..6087d6d 100644
--- a/Tiger.Business.MES/Transaction/PackingNode.cs
+++ b/Tiger.Business.MES/Transaction/PackingNode.cs
@@ -165,29 +165,30 @@
                             //鏌ユ壘涓嶅埌鏉$爜宸茬粦瀹氱殑宸ュ崟
                             else
                             {
-                                //娌℃湁褰撳墠宸ュ崟锛屽垯鍏堥�夋嫨宸ュ崟鍚庡啀鎵弿鏉$爜
-                                if (CurBatch.IsNullOrEmpty())
+                                var lastSn = wosns.OrderByDescending(q => q.SN.UPDATE_TIME).FirstOrDefault();
+                                if (!lastSn.IsNullOrEmpty())
                                 {
-                                    action.Data.ShortMsg = new("鏈�夋嫨宸ュ崟", ShortMessage.Types.Error);
+                                    action.Data.ShortMsg = new($"浜у搧{lastSn.SN.STATUS.GetEnumDesc<BIZ_MES_WO_SN.STATUSs>()}", ShortMessage.Types.Error);
                                     action.Data.OperInfo = new();
                                     action.IsSuccessed = false;
-                                    //action.LocaleMsg = new($"鏈�夋嫨宸ュ崟锛岃鍏堥�夋嫨瑕佺敓浜х殑宸ュ崟");
-                                    action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotSelectOrderException");
+                                    //action.LocaleMsg = new($"杩涚珯鎵弿閿欒锛屾潯鐮乕{0}]{1}", input.SN);
+                                    action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.SnStatusError", input.SN, lastSn.SN.STATUS.GetEnumDesc<BIZ_MES_WO_SN.STATUSs>());
                                 }
-                                //鏈夊綋鍓嶅伐鍗曚笖涓嶆槸鎶曞叆锛屽垯鎻愮ず鏉$爜鏈姇鍏ョ敓浜э紝璇峰厛鍘婚绔欐壂鎻�
                                 else
                                 {
-                                    var lastSn = wosns.OrderByDescending(q => q.SN.UPDATE_TIME).FirstOrDefault();
-                                    if (!lastSn.IsNullOrEmpty())
+                                    //娌℃湁褰撳墠宸ュ崟锛屽垯鍏堥�夋嫨宸ュ崟鍚庡啀鎵弿鏉$爜
+                                    if (CurBatch.IsNullOrEmpty())
                                     {
-                                        action.Data.ShortMsg = new($"浜у搧{lastSn.SN.STATUS.GetEnumDesc<BIZ_MES_WO_SN.STATUSs>()}", ShortMessage.Types.Error);
+                                        action.Data.ShortMsg = new("鏈�夋嫨宸ュ崟", ShortMessage.Types.Error);
                                         action.Data.OperInfo = new();
                                         action.IsSuccessed = false;
-                                        //action.LocaleMsg = new($"杩涚珯鎵弿閿欒锛屾潯鐮乕{0}]{1}", input.SN);
-                                        action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotInputException", input.SN);
+                                        //action.LocaleMsg = new($"鏈�夋嫨宸ュ崟锛岃鍏堥�夋嫨瑕佺敓浜х殑宸ュ崟");
+                                        action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotSelectOrderException");
                                     }
+                                    //鏈夊綋鍓嶅伐鍗曚笖涓嶆槸鎶曞叆锛屽垯鎻愮ず鏉$爜鏈姇鍏ョ敓浜э紝璇峰厛鍘婚绔欐壂鎻�
                                     else
                                     {
+
                                         action.Data.ShortMsg = new("鏈姇鍏ョ敓浜�", ShortMessage.Types.Error);
                                         action.Data.OperInfo = new();
                                         action.IsSuccessed = false;
@@ -621,12 +622,18 @@
         /// <returns></returns>
         public ApiAction<SubmitOutput> DoIfFinishAllSteps(ApiAction<SubmitOutput> action, string locale)
         {
+            var curPkg = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null;
             var operInfo = SetOperNodeInfo(CurOperInfo(locale));
             Action endAction = null;
 
             //濡傛灉褰撳墠鏉$爜宸茬粡璧板埌娴佺▼缁堢偣鍒欒褰曟潯鐮佸畬宸�
-            if (action.Data.OperInfo.IsReachedEndNode)
+            if (operInfo.IsReachedEndNode)
             {
+                //鏍囪褰撳墠鍖呰淇℃伅涓虹粓鐐圭珯
+                if (!curPkg.IsNullOrEmpty())
+                {
+                    curPkg.IsReachedEndNode = true;
+                }
                 //鏇存柊宸ュ崟鏉$爜鏄庣粏淇℃伅
                 var woSNs = CurBatch.WoSNs.Where(q => CurWipSNs.Any(w => q.WIP_ID == w.ID)).ToList();
                 foreach (var woSN in woSNs)
@@ -669,16 +676,22 @@
             }
 
             //淇濆瓨鏁版嵁搴�
-            SaveStepsCommitActionToDB();
+            SaveStepsCommitActionToDB(endAction);
 
             //淇濆瓨鎴愬姛锛岃繑鍥炶繃绔欐秷鎭�
             CurOperInfo(locale).InputQty += CurWipSNs.Count;
-            action.Data.Data = new PackingActionOutput() { PkgInfo = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null };
+            action.Data.Data = new PackingActionOutput() { PkgInfo = curPkg };
             action.Data.OperInfo = operInfo;
             action.Data.ShortMsg = new(CurWipSNs.Any(q => q.DFT_FLAG == "Y") ? "涓嶈壇杩囩珯" : "鑹搧杩囩珯", ShortMessage.Types.Success);
             //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.PackingNode.ScanSn.PassSuccess", CurWipSNs.First().WORK_ORDER, CurSN, CurWipSNs.First().POST_CODE, CurWipSNs.First().NODE_NAME, CurWipSNs.First().STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>());
 
+            //濡傛灉褰撳墠鏉$爜宸茬粡瀹屽伐锛屾鏌ュ綋鍓嶅伐鍗曟壒娆″拰宸ュ崟鏄惁瀹屽伐
+            if (action.Data.OperInfo.IsReachedEndNode)
+            {
+                CurBatch.CheckIsComplete(UserCode);
+            }
+
             //閲嶇疆宸ュ簭
             ResetNode();
 

--
Gitblit v1.9.3