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/WorkAction/PackingAction.cs |  102 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 71 insertions(+), 31 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs
index a8fbe4d..bdc2ef7 100644
--- a/Tiger.Business.MES/WorkAction/PackingAction.cs
+++ b/Tiger.Business.MES/WorkAction/PackingAction.cs
@@ -219,6 +219,7 @@
                 CurCmd = data;
                 PrintTimes++;
                 CurStep?.SetStatusMessage(StepStatus.Normal, Biz.L("鎵撳嵃鏍囩"));
+                action.IsSuccessed = true;
                 action.Data.Data = data;
                 action.Data.ShortMsg = new("鎵撳嵃鏍囩", ShortMessage.Types.Normal);
                 //action.LocaleMsg = new Locale($"寮�濮嬬{PrintTimes}娆℃墦鍗扮{min.PKG_LEVEL}灞傚寘瑁匸{min.PkgType.PKG_NAME}]鐨勬爣绛綶{LabelDic[min.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[min.PKG_LEVEL].LABEL_NAME}]");
@@ -226,7 +227,7 @@
             }
 
             //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
-            action.IsSuccessed = true;
+            //action.IsSuccessed = true;
             return action;
         }
 
@@ -254,6 +255,7 @@
                             action.IsSuccessed = false;
                             //action.LocaleMsg = new($"鏉$爜鎵弿澶辫触锛岃閲嶆柊鎵弿绗瑊dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�");
                             action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanFail", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME);
+                            CurPosition.ResetNode();
                             return action;
                         }
                         //楠岃瘉褰撳墠鍖呰鏉$爜鏄惁宸茬粡琚壂鎻忚繃
@@ -265,6 +267,7 @@
                             action.IsSuccessed = false;
                             //action.LocaleMsg = new($"鏉$爜[{pInput.PkgSN}]鏃犻渶閲嶅鎵弿锛岃鎵弿绗瑊dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�");
                             action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanRepeat", pInput.PkgSN, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME);
+                            CurPosition.ResetNode();
                             return action;
                         }
                         //瀹㈡埛绔壂鎻忔垚鍔�
@@ -815,6 +818,7 @@
                 var wipActs = new List<MES_WIP_ACT>();
                 foreach (var wipSn in CurPosition.CurWipSNs)
                 {
+
                     var wipAct = new MES_WIP_ACT()
                     {
                         AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG,
@@ -876,13 +880,27 @@
                                 .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                                 .SetColumns(q => q.INNER_SN == q.CARTON_SN)
                                 .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
-                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN)
+                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.ID == pkg.WIP_ID)
+                                .ExecuteCommand();
+                            //鍖呰淇℃伅淇濆瓨鍒扮敓浜ц繃绋嬭褰�
+                            db.Updateable<MES_WIP_HIS>()
+                                .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
+                                .SetColumns(q => q.INNER_SN == q.CARTON_SN)
+                                .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
+                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.ID == pkg.WIP_ID && q.NODE_ID == pkg.NODE_ID)
+                                .ExecuteCommand();
+                            //鍖呰淇℃伅淇濆瓨鍒扮敓浜ц涓鸿褰�
+                            db.Updateable<MES_WIP_ACT>()
+                                .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
+                                .SetColumns(q => q.INNER_SN == q.CARTON_SN)
+                                .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
+                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.ID == pkg.WIP_ID && q.NODE_ID == pkg.NODE_ID && q.ACT_ID == NodeAct.ID)
                                 .ExecuteCommand();
                             //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃
                             db.Updateable<BIZ_MES_WO_SN>()
                                 .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
                                 .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN)
-                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN)
+                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.WIP_ID == pkg.WIP_ID)
                                 .ExecuteCommand();
                         }
                     }
@@ -890,35 +908,57 @@
             }
             else
             {
-                var _pkgList = CurPkg.IsFinished ? GetPackageList(CurPkg.Item) : new();
-               
-                //鏈�澶栧眰鍖呰宸茬粡瀹屾垚鍖呰锛屽垯鎶婂伐搴忎腑鏆傚瓨鏍囪璁句负false锛岀粺涓�鎻愪氦鍖呰鍐呬骇鍝佺殑杩囩珯璁板綍
-                CurPosition.NeedTemporaryStoreDBCommitAction = false;
-                //淇濆瓨鏁版嵁
-                CurPosition.SaveStepsCommitActionToDB(() =>
+                if (CurPkg.IsFinished)
                 {
-                    var db = CurPosition.GetCommitDB();
-                    if (_pkgList.Any())
-                    {
-                        db.Storageable(_pkgList, CurPosition.UserCode).ExecuteCommand();
-                        foreach (var pkg in _pkgList)
-                        {
-                            //鍖呰淇℃伅淇濆瓨鍒板湪鍒跺搧淇℃伅琛�
-                            db.Updateable<MES_WIP_DATA>()
-                                .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
-                                .SetColumns(q => q.INNER_SN == q.CARTON_SN)
-                                .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
-                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN)
-                                .ExecuteCommand();
-                            //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃
-                            db.Updateable<BIZ_MES_WO_SN>()
-                                .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
-                                .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN)
-                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN)
-                                .ExecuteCommand();
-                        }
-                    }
-                });
+	                var _pkgList = GetPackageList(CurPkg.Item);
+	               
+	                //鏈�澶栧眰鍖呰宸茬粡瀹屾垚鍖呰锛屽垯鎶婂伐搴忎腑鏆傚瓨鏍囪璁句负false锛岀粺涓�鎻愪氦鍖呰鍐呬骇鍝佺殑杩囩珯璁板綍
+	                CurPosition.NeedTemporaryStoreDBCommitAction = false;
+	                //淇濆瓨鏁版嵁
+	                CurPosition.SaveStepsCommitActionToDB(() =>
+	                {
+	                    var db = CurPosition.GetCommitDB();
+	                    if (_pkgList.Any())
+	                    {
+	                        db.Storageable(_pkgList, CurPosition.UserCode).ExecuteCommand();
+	                        foreach (var pkg in _pkgList)
+	                        {
+	                            //鍖呰淇℃伅淇濆瓨鍒板湪鍒跺搧淇℃伅琛�
+	                            db.Updateable<MES_WIP_DATA>()
+	                                .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
+	                                .SetColumns(q => q.INNER_SN == q.CARTON_SN)
+	                                .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
+	                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.ID == pkg.WIP_ID)
+	                                .ExecuteCommand();
+                                //鍖呰淇℃伅淇濆瓨鍒扮敓浜ц繃绋嬭褰�
+                                db.Updateable<MES_WIP_HIS>()
+                                    .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
+                                    .SetColumns(q => q.INNER_SN == q.CARTON_SN)
+                                    .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
+                                    .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.ID == pkg.WIP_ID && q.NODE_ID == pkg.NODE_ID)
+                                    .ExecuteCommand();
+                                //鍖呰淇℃伅淇濆瓨鍒扮敓浜ц涓鸿褰�
+                                db.Updateable<MES_WIP_ACT>()
+                                    .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
+                                    .SetColumns(q => q.INNER_SN == q.CARTON_SN)
+                                    .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN)
+                                    .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.ID == pkg.WIP_ID && q.NODE_ID == pkg.NODE_ID && q.ACT_ID == NodeAct.ID)
+                                    .ExecuteCommand();
+                                //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃
+                                db.Updateable<BIZ_MES_WO_SN>()
+	                                .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN)
+	                                .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN)
+	                                .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.WIP_ID == pkg.WIP_ID)
+	                                .ExecuteCommand();
+	                        }
+	                    }
+	                });
+	                //濡傛灉褰撳墠鏉$爜宸茬粡瀹屽伐锛屾鏌ュ綋鍓嶅伐鍗曟壒娆″拰宸ュ崟鏄惁瀹屽伐
+	                if (CurPkg.IsReachedEndNode)
+	                {
+	                    CurPosition.WorkBatch.CheckIsComplete(CurPosition.UserCode);
+	                }
+                }
             }
 
             if (CurPkg.IsFinished)

--
Gitblit v1.9.3