From 7630f581e6ed2fabd50ab6ecd444691f1e99b881 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 25 十一月 2024 16:35:47 +0800 Subject: [PATCH] 工单暂停逻辑更新,WorkBatch更新工单更新 --- Tiger.Model.Net/Entitys/MES/BIZ_MES_WO_BATCH.cs | 10 ++++++++++ Tiger.Business.MES/Transaction/YadaPacking.cs | 23 ++++++++++++++++++----- Tiger.Business.MES/BIZ/BIZ_MES_WO.cs | 10 ++++++++-- Tiger.Business.MES/Common/WorkBatch.cs | 10 +++++++--- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs index 2755254..83b2e39 100644 --- a/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs +++ b/Tiger.Business.MES/BIZ/BIZ_MES_WO.cs @@ -225,6 +225,8 @@ var _wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.WorkOrder).FirstAsync(); if (_wo != null) { + _wo.CHANGE_TIME = _wo.STATUS == BIZ_MES_WO.STATUSs.Paused.GetValue() && input.Status == BIZ_MES_WO.STATUSs.Working.GetValue() ? DateTime.Now : _wo.CHANGE_TIME; + _wo.CHANGE_USER = _wo.STATUS == BIZ_MES_WO.STATUSs.Paused.GetValue() && input.Status == BIZ_MES_WO.STATUSs.Working.GetValue() ? input.UserId : _wo.CHANGE_USER; _wo.STATUS = input.Status < 0 ? _wo.STATUS : input.Status; _wo.ROUTE_STATUS = input.RouteStatus; } @@ -269,6 +271,8 @@ var _woBatch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(x => x.BATCH_NO == input.WoBatch).FirstAsync(); if (_woBatch != null) { + _woBatch.CHANGE_TIME = _woBatch.STATUS == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue() && input.Status == BIZ_MES_WO_BATCH.STATUSs.Working.GetValue()? DateTime.Now: _woBatch.CHANGE_TIME; + _woBatch.CHANGE_USER = _woBatch.STATUS == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue() && input.Status == BIZ_MES_WO_BATCH.STATUSs.Working.GetValue() ? input.UserId: _woBatch.CHANGE_USER; _woBatch.STATUS = input.Status < 0 ? _woBatch.STATUS : input.Status; if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Paused.GetValue()) { @@ -286,6 +290,8 @@ _woBatch.RELEASE_TIME = DateTime.Now; _woBatch.RELEASE_USER = input.UserId; _woBatch.ACT_LINE = input.ActLine; + _woBatch.CHANGE_USER = input.UserId; + _woBatch.CHANGE_TIME = DateTime.Now; } } else @@ -301,11 +307,11 @@ //濡傛灉鏄笅鍙� if (input.Status == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue()) { - db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.RELEASE_USER, x.RELEASE_TIME, x.ACT_LINE, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); + db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.RELEASE_USER, x.RELEASE_TIME, x.ACT_LINE, x.UPDATE_USER, x.UPDATE_TIME, x.CHANGE_USER,x.CHANGE_TIME }).ExecuteCommand(); } else { - db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME }).ExecuteCommand(); + db.Updateable(_woBatch, input.UserId).UpdateColumns(x => new { x.STATUS, x.UPDATE_USER, x.UPDATE_TIME, x.CHANGE_USER, x.CHANGE_TIME }).ExecuteCommand(); } }); if (!dbTran.IsSuccess) diff --git a/Tiger.Business.MES/Common/WorkBatch.cs b/Tiger.Business.MES/Common/WorkBatch.cs index d431e97..413ac6f 100644 --- a/Tiger.Business.MES/Common/WorkBatch.cs +++ b/Tiger.Business.MES/Common/WorkBatch.cs @@ -12,6 +12,7 @@ using Tiger.Business.MES; using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser; using Org.BouncyCastle.Ocsp; +using System.IO; namespace Tiger.Business { @@ -64,6 +65,7 @@ public void Update(bool updateAll = false) { + var strat = DateTime.Now; var wo = Biz.Db.Queryable<BIZ_MES_WO>().Where(q => q.ORDER_NO == OrderNo).IncludesAllFirstLayer().First(); var batch = Biz.Db.Queryable<BIZ_MES_WO_BATCH>().Where(q => q.BATCH_NO == Batch.BATCH_NO).First(); if (WoContext.WoBatchDic.ContainsKey(batch.BATCH_NO)) @@ -72,7 +74,7 @@ { WoContext.WoBatchDic.Remove(Batch.BATCH_NO); } - else if(updateAll || wo.UPDATE_TIME > WO.UPDATE_TIME || batch.UPDATE_TIME > Batch.UPDATE_TIME) + else if(updateAll || wo.CHANGE_TIME > WO.CHANGE_TIME || batch.CHANGE_TIME > Batch.CHANGE_TIME) { GetBatchInfo(); } @@ -84,10 +86,12 @@ } WO = wo; Batch = batch; + ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss} ##### : {(DateTime.Now - strat).TotalSeconds}s", ConsoleColor.Yellow); } private void GetBatchInfo() { + ConsoleExt.WriteLine($"{DateTime.Now:HH:mm:ss} !!!!! ", ConsoleColor.Cyan); Product = Biz.Db.Queryable<BAS_ITEM>().Where(q => q.ITEM_CODE == WO.ITEM_CODE && q.AUTH_ORG == WO.AUTH_ORG).IncludesAllFirstLayer().First(); Customer = Biz.Db.Queryable<BAS_CUSTOMER>().Where(q => q.CUST_CODE == WO.CUST_CODE).First(); WoSNs = Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.WORK_ORDER == OrderNo).ToList(); @@ -198,8 +202,8 @@ var db = Biz.Db; var dbTran = db.UseTran(() => { - db.Updateable(WO, user).UpdateColumns(q => new { q.UPDATE_TIME, q.UPDATE_USER, q.STATUS, q.ACT_START_TIME }).ExecuteCommand(); - db.Updateable(Batch, user).UpdateColumns(q => new { q.UPDATE_TIME, q.UPDATE_USER, q.STATUS, q.ACT_START_TIME }).ExecuteCommand(); + db.Updateable(WO, user).UpdateColumns(q => new { q.STATUS, q.ACT_START_TIME }).ExecuteCommand(); + db.Updateable(Batch, user).UpdateColumns(q => new { q.STATUS, q.ACT_START_TIME }).ExecuteCommand(); }); if (!dbTran.IsSuccess) { diff --git a/Tiger.Business.MES/Transaction/YadaPacking.cs b/Tiger.Business.MES/Transaction/YadaPacking.cs index a186824..28182e7 100644 --- a/Tiger.Business.MES/Transaction/YadaPacking.cs +++ b/Tiger.Business.MES/Transaction/YadaPacking.cs @@ -39,6 +39,8 @@ public PackingAction TempPkgAction { get; set; } public bool IsPrintCustomerLabel { get; set; } public string ShippingOrder { get; set; } + public DateTime curtime = DateTime.Now; + public DateTime prevtime = DateTime.Now; #endregion Propertys & Variables #region Functions @@ -49,6 +51,7 @@ /// <returns></returns> public async Task<ApiAction<SubmitOutput>> Submit(SubmitInput input) { + ConsoleExt.WriteLine($"{curtime = prevtime = DateTime.Now:HH:mm:ss} ***** 1 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; var action = new ApiAction<SubmitOutput>(new SubmitOutput()); try { @@ -91,13 +94,13 @@ var wosns = Biz.Db.Queryable<BIZ_MES_WO_BATCH, BIZ_MES_WO_SN>((q, s) => new JoinQueryInfos(JoinType.Inner, q.ORDER_NO == s.WORK_ORDER && q.BATCH_NO == s.BATCH_NO)) .ByAuth(input.AuthOption)//.Where((q, s) => s.STATUS < BIZ_MES_WO_SN.STATUSs.Finished.GetValue()) .Where((q, s) => s.SN == input.SN || s.FLOW_SN == input.SN || s.TRAY_SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).ToList(); - + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 2 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //鍏堝垽鏂綋鍓嶅伐鍗曚笉涓虹┖涓斿綋鍓嶅矖浣嶅湪褰撳墠宸ュ崟鏄笉鏄绔欙紝濡傛灉鏄垯涓嶅厑璁稿彉鏇村綋鍓嶅伐鍗曪紝灏濊瘯鎶婃潯鐮佺粦瀹氬埌褰撳墠宸ュ崟 if (!CurBatch.IsNullOrEmpty() && CurBatch.IsFirstNode(PostCode)) { //鏇存柊CurBatch CurBatch?.Update(); - + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 3 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; var wosn = wosns.FirstOrDefault(q => q.Batch.ORDER_NO == CurBatch.WO.ORDER_NO && (q.SN.STATUS == BIZ_MES_WO_SN.STATUSs.Finished.GetValue() || q.SN.STATUS == BIZ_MES_WO_SN.STATUSs.Scrap.GetValue())); if (!wosn.IsNullOrEmpty()) { @@ -111,6 +114,7 @@ { //鎻愪氦鏁版嵁 action = NodeSubmit(action, input); + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 4 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //鏇存柊宸ュ簭淇℃伅 if (!action.IsSuccessed) { @@ -231,20 +235,23 @@ { //鏇存柊CurBatch CurBatch?.Update(); - + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 5 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; var submitStep = Steps.Where(q => q.ID == input.CurStepID && !q.IsFinished).FirstOrDefault(); //濡傛灉瀹㈡埛绔繑鍥炵殑褰撳墠宸ユID鎵句笉鍒版湭瀹屾垚鐨勮涓哄伐姝ワ紝鍒欑洿鎺ュ紑濮嬩笅涓�涓涓哄伐姝� if (submitStep.IsNullOrEmpty()) { action = BeginNextActionStep(input); + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 6 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; } else { action = submitStep.Submit(input); + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 7 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //濡傛灉褰撳墠宸ユ宸插畬鎴愶紝寮�濮嬫墽琛屼笅涓�宸ユ if (action.IsSuccessed && submitStep.IsFinished) { action = BeginNextActionStep(input); + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 8 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; } //濡傛灉褰撳墠宸ユ鏈畬鎴� else @@ -289,6 +296,7 @@ //action.CatchExceptionWithLog(ex, $"鍖呰宸ュ簭锛氭彁浜ゆ搷浣滄暟鎹紓甯�"); action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException")); } + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 9 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; return action; } @@ -300,6 +308,7 @@ /// <returns></returns> public ApiAction<SubmitOutput> NodeSubmit(ApiAction<SubmitOutput> action, SubmitInput input) { + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 10 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; var curNode = CurBatch.GetNode(PostCode); try { @@ -383,7 +392,7 @@ //璁剧疆褰撳墠鎸囦护涓烘甯镐骇鍝佽繃绔� NodeCmd = "NodeSubmit"; - + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 11 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //鑾峰彇鍑鸿揣鐘舵�� DbClient db = Biz.DataSource["YadaU9C"].Client; var ship = db.Queryable<mes_ShipList>().Where(q => q.MoDoc == CurBatch.WO.ORDER_NO && q.Status == 2 && SqlFunc.DateIsSame(q.BusinessDate, DateTime.Now)).First(); @@ -398,7 +407,7 @@ } } ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : ""; - + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 12 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //缁戝畾鏉$爜鍒板伐鍗� foreach (var wipSN in wipSNs) { @@ -542,6 +551,7 @@ var _curNodeSetting = curNodeSetting.Clone(); var _Batch = CurBatch.Batch.Clone(); + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 13 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //鍒濆鍖栧伐姝ュ垪琛� Steps.Clear(); var curStep = new WorkStep(IWorkStep.NodeTypes.Node, this) @@ -665,6 +675,7 @@ //action.CatchExceptionWithLog(ex, $"{curNode.NODE_NAME}锛氬伐搴忚妭鐐瑰伐姝ユ彁浜ゆ暟鎹紓甯革紝璇锋鏌ュ伐搴忚妭鐐硅缃�"); action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.NodeSubmitException", curNode.NODE_NAME)); } + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 13.1 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; return action; } @@ -678,6 +689,7 @@ var curPkg = Context.ContainsKey("CurPackage") ? Context["CurPackage"] as WipPkg : null; var operInfo = SetOperNodeInfo(CurOperInfo(locale)); Action endAction = null; + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 14 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //濡傛灉褰撳墠鏉$爜宸茬粡璧板埌娴佺▼缁堢偣鍒欒褰曟潯鐮佸畬宸� if (operInfo.IsReachedEndNode) @@ -745,6 +757,7 @@ //淇濆瓨鏁版嵁搴� SaveStepsCommitActionToDB(endAction); + ConsoleExt.WriteLine($"{curtime = DateTime.Now:HH:mm:ss} ***** 15 : {(curtime - prevtime).TotalSeconds}s", ConsoleColor.Green); prevtime = curtime; //淇濆瓨鎴愬姛锛岃繑鍥炶繃绔欐秷鎭� operInfo.InputQty += CurWipSNs.Count; diff --git a/Tiger.Model.Net/Entitys/MES/BIZ_MES_WO_BATCH.cs b/Tiger.Model.Net/Entitys/MES/BIZ_MES_WO_BATCH.cs index dff689f..877898d 100644 --- a/Tiger.Model.Net/Entitys/MES/BIZ_MES_WO_BATCH.cs +++ b/Tiger.Model.Net/Entitys/MES/BIZ_MES_WO_BATCH.cs @@ -99,6 +99,16 @@ [DisplayName("涓嬪彂浜�")] public string RELEASE_USER { get; set; } /// <summary> + /// 鍙樻洿鏃堕棿 + /// </summary> + [DisplayName("鍙樻洿鏃堕棿")] + public DateTime CHANGE_TIME { get; set; } = DateTime.MinValue; + /// <summary> + /// 鍙樻洿浜� + /// </summary> + [DisplayName("鍙樻洿浜�")] + public string CHANGE_USER { get; set; } + /// <summary> /// 璁″垝鏁伴噺 /// </summary> [DisplayName("璁″垝鏁伴噺")] -- Gitblit v1.9.3