From 3f386cbcc5f488fcea63463cc5fcdede4fdcfb24 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期三, 21 八月 2024 01:45:13 +0800
Subject: [PATCH] 一些更改

---
 Tiger.Business.MES/WorkAction/PackingAction.cs |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs
index 4c47c62..e6db837 100644
--- a/Tiger.Business.MES/WorkAction/PackingAction.cs
+++ b/Tiger.Business.MES/WorkAction/PackingAction.cs
@@ -175,6 +175,7 @@
                 CurCmd = data;
                 PrintTimes++;
                 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}]");
                 action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, min.PKG_LEVEL, min.PkgType.PKG_NAME, LabelDic[min.PKG_LEVEL]?.LABEL_CODE, LabelDic[min.PKG_LEVEL].LABEL_NAME);
             }
@@ -203,6 +204,7 @@
                         if (!pInput.IsFinish || pInput.PkgSN.IsNullOrEmpty())
                         {
                             var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel);
+                            action.Data.ShortMsg = new("鎵弿閿欒", ShortMessage.Types.Error);
                             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);
@@ -212,6 +214,7 @@
                         if (GetPackageList(CurPkg.Item).Any(q => q.SN == pInput.PkgSN))
                         {
                             var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel);
+                            action.Data.ShortMsg = new("鎵弿閿欒", ShortMessage.Types.Error);
                             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);
@@ -221,6 +224,10 @@
                         CurCmd = null;
                         PrintTimes = 0;
                         action = SavePkgData(input, action);
+                        if (action.IsSuccessed)
+                        {
+                            action.Data.ShortMsg = new("鎵弿鎴愬姛", ShortMessage.Types.Success);
+                        }
                     }
                     break;
                 //Print锛氭墦鍗帮紝鎵撳嵃褰撳墠鍖呰灞傜骇鐨勬爣绛�
@@ -238,6 +245,7 @@
                             data.PkgLevel = dtl.PKG_LEVEL;
                             CurCmd = data;
                             action.Data.Data = data;
+                            action.Data.ShortMsg = new("鎵弿鏍囩", ShortMessage.Types.Normal);
                             //action.LocaleMsg = new($"璇锋壂鎻忕{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�");
                             action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseScanLabel", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME);
                         } 
@@ -249,6 +257,7 @@
                             {
                                 PrintTimes++;
                                 action.Data.Data = CurCmd;
+                                action.Data.ShortMsg = new("閲嶆柊鎵撳嵃", ShortMessage.Types.Normal);
                                 //action.LocaleMsg = new Locale($"寮�濮媨PrintTimes}娆℃墦鍗扮{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛綶{LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[dtl.PKG_LEVEL].LABEL_NAME}]");
                                 action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME);
                             }
@@ -256,6 +265,7 @@
                             {
                                 CurCmd = null;
                                 PrintTimes = 0;
+                                action.Data.ShortMsg = new("鎵撳嵃澶辫触", ShortMessage.Types.Failed);
                                 action.IsSuccessed = false;
                                 //action.LocaleMsg = new($"灏濊瘯绗瑊PrintTimes}娆℃墦鍗扮{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛綶{LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[dtl.PKG_LEVEL].LABEL_NAME}]澶辫触锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜");
                                 action.LocaleMsg = new("MES.WorkAction.PackingAction.PrintFail3Times", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME);
@@ -277,6 +287,7 @@
                             data.PkgLevel = CurPkgItem.PKG_LEVEL;
                             CurCmd = data;
                             action.Data.Data = data;
+                            action.Data.ShortMsg = new("鍖呰鎴愬姛", ShortMessage.Types.Success);
                             //action.LocaleMsg = new($"璇锋妸鍖呰[{CurPkgItem.Package.SN}]涓婄О绉伴噸");
                             action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighing", CurPkgItem.Package.SN);
                         }
@@ -301,6 +312,7 @@
                         else
                         {
                             action.IsSuccessed = false;
+                            action.Data.ShortMsg = new("绉伴噸澶辫触", ShortMessage.Types.Failed);
                             //action.LocaleMsg = new($"鍖呰[{CurPkgItem.Package.SN}]绉伴噸鏁版嵁寮傚父锛岃閲嶆柊涓婄О绉伴噸");
                             action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighingAgain", CurPkgItem.Package.SN);
                             return action;
@@ -331,6 +343,7 @@
                             data.PkgLevel = dtl.PKG_LEVEL;
                             CurCmd = data;
                             action.Data.Data = data;
+                            action.Data.ShortMsg = new("鎵弿鏍囩", ShortMessage.Types.Normal);
                             //action.LocaleMsg = new($"璇锋壂鎻忕{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�");
                             action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseScanLabel", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME);
                         }
@@ -346,6 +359,7 @@
                             CurCmd = data;
                             PrintTimes++;
                             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}]");
                             action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME);
                         }
@@ -522,6 +536,7 @@
                     //鏁版嵁寮傚父
                     else
                     {
+                        action.Data.ShortMsg = new("鍖呰閿欒", ShortMessage.Types.Error);
                         var pdtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel);
                         action.IsSuccessed = false;
                         //action.LocaleMsg = new($"瀹㈡埛绔彁浜ょ殑鍖呰灞傜骇[{pdtl.PKG_LEVEL}]({pdtl.PkgType.PKG_NAME})鏁版嵁涓嶆槸姝e湪澶勭悊鐨勫寘瑁呭眰绾{dtl.PKG_LEVEL}]({dtl.PkgType.PKG_NAME})锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜");
@@ -532,6 +547,7 @@
             }
             catch (System.Exception ex)
             {
+                action.Data.ShortMsg = new("鍖呰寮傚父", ShortMessage.Types.Exception);
                 var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel);
                 action.CatchExceptionWithLog(ex, $"鍖呰琛屼负锛氭壂鎻忕{dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮乕{input.SN}]鍚庝繚瀛樻暟鎹け璐�");
                 action.IsSuccessed = false;
@@ -544,10 +560,14 @@
 
         private List<MES_WIP_PKG> GetPackageList(WipPkgItem parent)
         {
-            List<MES_WIP_PKG> list = new() { parent.Package };
+            List<MES_WIP_PKG> list = new();
+            if (!parent.Package.IsNullOrEmpty())
+            {
+                list.Add(parent.Package);
+            }
             foreach (var item in parent.Items)
             {
-                item.Package.PARENT_SN = parent.Package.SN;
+                item.Package.PARENT_SN = parent.Package?.SN;
                 list.AddRange(GetPackageList(item));
             }
             return list;
@@ -562,6 +582,7 @@
             data.PkgLevel = CurPkg.Item.PKG_LEVEL;
             CurCmd = data;
             action.Data.Data = data;
+            action.Data.ShortMsg = new("淇濆瓨鍖呰鏁版嵁", ShortMessage.Types.Normal);
             //action.LocaleMsg = new($"绗瑊CurPkg.Item.PKG_LEVEL}灞傚寘瑁匸{CurPkg.Item.PKG_NAME}]宸茬粡鍏ㄩ儴瀹屾垚锛屼繚瀛樺寘瑁呮暟鎹�");
             action.LocaleMsg = new("MES.WorkAction.PackingAction.PackageComplete", CurPkg.Item.PKG_LEVEL, CurPkg.Item.PKG_NAME);
 
@@ -642,7 +663,7 @@
                 }
                 if (_pkgList.Any())
                 {
-                    db.Insertable(_pkgList, CurPosition.UserCode).ExecuteCommand();
+                    db.Storageable(_pkgList, CurPosition.UserCode).ExecuteCommand();
                     foreach (var pkg in _pkgList)
                     {
                         //鍖呰淇℃伅淇濆瓨鍒板湪鍒跺搧淇℃伅琛�
@@ -668,6 +689,8 @@
                 CurPosition.NeedTemporaryStoreDBCommitAction = false;
                 //鍒犻櫎宸ュ簭涓婁笅鏂囦腑鐨勫寘瑁呰褰�
                 CurPosition.Context.Remove("CurPackage");
+                //action.LocaleMsg = new($"鏉$爜[{CurPkg.Item.Package?.SN}]鍖呰瀹屾垚");
+                action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPkg.Item.Package.SN);
             }
             else
             {
@@ -682,11 +705,13 @@
                 {
                     CurPosition.Context.Add("CurPackage", CurPkg);
                 }
+                //action.LocaleMsg = new($"鏉$爜[{CurPosition.CurSN}]鍖呰瀹屾垚");
+                action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurSN);
             }
 
             IsFinished = true;
-            action.LocaleMsg = new($"浜у搧鏉$爜[{CurPosition.CurSN}]鍖呰瀹屾垚");
-            action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurSN);
+            action.Data.ShortMsg = new("鍖呰瀹屾垚", ShortMessage.Types.Success);
+            
             return action;
         }
 

--
Gitblit v1.9.3