From 6e78892c440406c94fa1190d8daa04480620f13a Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期六, 28 十二月 2024 01:31:02 +0800
Subject: [PATCH] 通用导入Excel更新

---
 Tiger.Business.MES/WorkAction/WipExtInfo.cs |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/Tiger.Business.MES/WorkAction/WipExtInfo.cs b/Tiger.Business.MES/WorkAction/WipExtInfo.cs
index 14a059c..238d3fe 100644
--- a/Tiger.Business.MES/WorkAction/WipExtInfo.cs
+++ b/Tiger.Business.MES/WorkAction/WipExtInfo.cs
@@ -16,6 +16,7 @@
     {
         #region Propertys & Variables
         #region 鍥哄畾鍐欐硶锛屽伐搴忎腑鐨勫繀瑕佷俊鎭�
+        public DbClient MainDB { get; set; }
         public bool IsFinished { get; set; } = false;
         public IWorkStep CurStep { get; set; }
         public IPosition CurPosition { get; set; }
@@ -34,6 +35,7 @@
         public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting)
         {
             #region 鍥哄畾鍐欐硶锛岀粰榛樿鍙橀噺璧嬪��
+            MainDB = position.MainDB;
             CurStep = curStep;
             CurPosition = position;
             NodeAct = nodeAct;
@@ -42,9 +44,9 @@
 
             //鑾峰彇鎵╁睍瀛楁瀹氫箟
             var seq = Setting.ITEM_CODE.ToInt32();
-            ExtInfo = Biz.Db.Queryable<BAS_WIP_EXT>().Where(q => q.SEQ == seq).First();
+            ExtInfo = MainDB.Queryable<BAS_WIP_EXT>().Where(q => q.SEQ == seq).First();
             //鑾峰彇褰撳墠SN鐨勬墿灞曚俊鎭�
-            CurWipExt = Biz.Db.Queryable<MES_WIP_EXT>().Where(q => CurPosition.CurWipSNs.Any(w => w.SN == q.SN)).ToList();
+            CurWipExt = MainDB.Queryable<MES_WIP_EXT>().Where(q => CurPosition.CurWipSNs.Any(w => w.SN == q.SN)).ToList();
             foreach (var wipSN in CurPosition.CurWipSNs)
             {
                 if (!CurWipExt.Any(q => q.SN == wipSN.SN))
@@ -58,6 +60,9 @@
                     });
                 }
             }
+
+            CurStep.Message = Biz.L("鎵弿瑕佺粦瀹氱殑鏍囩");
+            CurStep.Status = StepStatus.Normal;
         }
 
         /// <summary>
@@ -82,6 +87,8 @@
             action.LocaleMsg = GetBeginMsg();
 
             //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触
+            CurStep.Message = Biz.L("缁戝畾寮�濮�");
+            CurStep.Status = StepStatus.Normal;
             action.IsSuccessed = true;
             action.Data.ShortMsg = new("缁戝畾寮�濮�", ShortMessage.Types.Success);
             return action;
@@ -116,6 +123,8 @@
                 //楠岃瘉鎵弿鐨勬潯鐮佹槸鍚N鐨勬墿灞曚俊鎭殑鏍囩
                 if (input.SN.IsNullOrEmpty())
                 {
+                    CurStep.Message = Biz.L("缁戝畾澶辫触");
+                    CurStep.Status = StepStatus.Error;
                     action.Data.ShortMsg = new("缁戝畾澶辫触", ShortMessage.Types.Failed);
                     action.IsSuccessed = isOK = false;
                     //action.LocaleMsg = new Locale($"閿欒锛歔{ExtInfo.FIELD_NAME}]鏍囩鏉$爜涓嶈兘涓虹┖锛岃閲嶆柊鎵弿");
@@ -123,6 +132,8 @@
                 }
                 if (CurPosition.CurWipSNs.Any(w => w.SN == input.SN))
                 {
+                    CurStep.Message = Biz.L("缁戝畾澶辫触");
+                    CurStep.Status = StepStatus.Error;
                     action.Data.ShortMsg = new("缁戝畾澶辫触", ShortMessage.Types.Failed);
                     action.IsSuccessed = isOK = false;
                     //action.LocaleMsg = new Locale($"閿欒锛氭壂鎻忓埌浜у搧鏉$爜[{input.SN}]锛岃閲嶆柊鎵弿[{ExtInfo.FIELD_NAME}]鏍囩鏉$爜");
@@ -133,13 +144,15 @@
                 if (isOK)
                 {
                     CurWipExt.GetType().GetProperty($"FIELD_{ExtInfo.SEQ.ToString("00")}")?.SetValue(CurWipExt, input.SN);
-                    action = End();
+                    action = End(input);
                 }
 
                 //閮芥病鏈夌墿鏂欓獙璇侀�氳繃锛屽垯杩斿洖閿欒淇℃伅
             }
             catch (System.Exception ex)
             {
+                CurStep.Message = Biz.L("缁戝畾寮傚父");
+                CurStep.Status = StepStatus.Error;
                 action.Data.ShortMsg = new("缁戝畾寮傚父", ShortMessage.Types.Exception);
                 action.CatchExceptionWithLog(ex, $"鎵╁睍淇℃伅缁戝畾琛屼负锛氫骇鍝乕{CurPosition.CurSN}]缁戝畾[{ExtInfo.FIELD_NAME}]鏍囩鏉$爜[{input.SN}]淇濆瓨寮傚父");
                 action.IsSuccessed = false;
@@ -154,7 +167,7 @@
         /// 缁撴潫鎵ц宸ュ簭琛屼负
         /// </summary>
         /// <returns></returns>
-        public ApiAction<SubmitOutput> End()
+        public ApiAction<SubmitOutput> End(SubmitInput input)
         {
             var action = new ApiAction<SubmitOutput>(new SubmitOutput());
 
@@ -197,6 +210,7 @@
                     ACT_SN = wipSn.SN,
                     ACT_VALUE_1 = CurWipExt.ToJson(),
                     ACT_RESULT = "Y",
+                    ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(),
                     TRACE_INFO = $"浜у搧[{CurPosition.CurSN}]缁戝畾[{ExtInfo.FIELD_NAME}]鏍囩鏉$爜[{CurWipExt.GetType().GetProperty($"FIELD_{ExtInfo.SEQ.ToString("00")}")?.GetValue(CurWipExt)?.ToString()}]淇濆瓨鎴愬姛",
                 };
                 wipActs.Add(wipAct);
@@ -214,6 +228,8 @@
             };
 
             IsFinished = true;
+            CurStep.Message = Biz.L("缁戝畾瀹屾垚");
+            CurStep.Status = StepStatus.Finished;
             action.Data.ShortMsg = new("缁戝畾瀹屾垚", ShortMessage.Types.Success);
             //action.LocaleMsg = new($"浜у搧[{CurPosition.CurWipSN.SN}]缁戝畾[{ExtInfo.FIELD_NAME}]鏍囩鏉$爜[{CurWipExt.GetType().GetProperty($"FIELD_{ExtInfo.SEQ.ToString("00")}")?.GetValue(CurWipExt)?.ToString()}]淇濆瓨鎴愬姛");
             action.LocaleMsg = new("MES.WorkAction.WipExtInfo.SaveSuccess", CurPosition.CurSN, ExtInfo.FIELD_NAME, CurWipExt.GetType().GetProperty($"FIELD_{ExtInfo.SEQ.ToString("00")}")?.GetValue(CurWipExt)?.ToString());

--
Gitblit v1.9.3