From 87422530bec9baf531d2e0715b9c786a4d35667f Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期四, 02 一月 2025 15:59:44 +0800 Subject: [PATCH] Add new properties and classes for process and code handling --- Tiger.Business.MES/WorkAction/WipExtInfo.cs | 76 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 72 insertions(+), 4 deletions(-) diff --git a/Tiger.Business.MES/WorkAction/WipExtInfo.cs b/Tiger.Business.MES/WorkAction/WipExtInfo.cs index 7f445e4..4360065 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,7 +87,10 @@ action.LocaleMsg = GetBeginMsg(); //濡傛灉杩斿洖鎴愬姛鍒欒涓哄綋鍓嶈涓哄彲浠ュ紑濮嬫墽琛岋紝鍚﹀垯杩斿洖澶辫触 + CurStep.Message = Biz.L("缁戝畾寮�濮�"); + CurStep.Status = StepStatus.Normal; action.IsSuccessed = true; + action.Data.ShortMsg = new("缁戝畾寮�濮�", ShortMessage.Types.Success); return action; } @@ -115,12 +123,18 @@ //楠岃瘉鎵弿鐨勬潯鐮佹槸鍚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}]鏍囩鏉$爜涓嶈兘涓虹┖锛岃閲嶆柊鎵弿"); action.LocaleMsg = new Locale("MES.WorkAction.WipExtInfo.SnEmptyError", ExtInfo.FIELD_NAME); } 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}]鏍囩鏉$爜"); action.LocaleMsg = new Locale("MES.WorkAction.WipExtInfo.ScanProdSnError", input.SN, ExtInfo.FIELD_NAME); @@ -130,13 +144,16 @@ 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; //action.LocaleMsg = new($"浜у搧[{CurPosition.CurWipSN.SN}]缁戝畾[{ExtInfo.FIELD_NAME}]鏍囩鏉$爜[{input.SN}]淇濆瓨寮傚父锛屽伐搴忓凡閲嶇疆锛岃閲嶆柊鎵弿杩涚珯浜у搧鏉$爜"); @@ -150,12 +167,13 @@ /// 缁撴潫鎵ц宸ュ簭琛屼负 /// </summary> /// <returns></returns> - public ApiAction<SubmitOutput> End() + public ApiAction<SubmitOutput> End(SubmitInput input) { var action = new ApiAction<SubmitOutput>(new SubmitOutput()); //璁板綍琛屼负鎿嶄綔璁板綍 var wipActs = new List<MES_WIP_ACT>(); + var wipVars = new List<MES_WIP_ACT_VAR>(); foreach (var wipSn in CurPosition.CurWipSNs) { var wipAct = new MES_WIP_ACT() @@ -192,24 +210,74 @@ ACT_TYPE = NodeAct.ACT_TYPE, ACT_SN = wipSn.SN, ACT_VALUE_1 = CurWipExt.ToJson(), + ACT_VAR_DIC = CurStep.ActionDic.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); + foreach (var item in NodeAct.Variables) + { + var wipVar = new MES_WIP_ACT_VAR() + { + AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, + AUTH_PROD = CurPosition.CurLine.LINE_CODE, + HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID, + WIP_ID = wipSn.ID, + SN = wipSn.SN, + ITEM_CODE = wipSn.ITEM_CODE, + WORK_ORDER = wipSn.WORK_ORDER, + BATCH_NO = wipSn.BATCH_NO, + CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE, + ROT_CODE = wipSn.ROT_CODE, + NODE_ID = wipSn.NODE_ID, + NODE_NAME = wipSn.NODE_NAME, + ACT_ID = NodeAct.ID, + ACT_NAME = NodeAct.ACT_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, + 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, + OPERATION_TIME = DateTime.Now, + SFTS_CODE = wipSn.SFTS_CODE, + SFT_CODE = wipSn.SFT_CODE, + PRD_CODE = wipSn.PRD_CODE, + VAR_CODE = item.VAR_CODE, + VAR_NAME = item.VAR_NAME, + VAR_CONTROL = item.VAR_CONTROL, + VALUE_TYPE = item.VALUE_TYPE, + PROCESS_VAR = item.PROCESS_VAR, + INPUT_VALUE = CurStep.ActionDic.GetOrDefault(item.VAR_CODE), + TRACE_INFO = CurStep.ActionDic.ToJson(), + }; + wipVars.Add(wipVar); + } } //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊� var _wipActs = wipActs.Clone(); + var _wipVars = wipVars.Clone(); var _CurWipExt = CurWipExt.Clone(); //淇濆瓨鏁版嵁 CurStep.DBSubmitAction = () => { var db = CurPosition.GetCommitDB(); db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); + db.Storageable(_wipVars, CurPosition.UserCode).ExecuteCommand(); db.Storageable(_CurWipExt, CurPosition.UserCode).ExecuteCommand(); }; 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()); return action; -- Gitblit v1.9.3