From 879014e6dcd2e3897eea4a7585fb7c87183d9ffd Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期三, 16 十月 2024 15:31:57 +0800 Subject: [PATCH] 增加行为禁用功能 --- Tiger.Business.MES/Common/WorkStep.cs | 41 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Tiger.Business.MES/Common/WorkStep.cs b/Tiger.Business.MES/Common/WorkStep.cs index 581fbd3..6b790d7 100644 --- a/Tiger.Business.MES/Common/WorkStep.cs +++ b/Tiger.Business.MES/Common/WorkStep.cs @@ -28,6 +28,9 @@ #region Propertys & Variables public string ID { get; set; } = Guid.NewGuid().ToString("N"); public string Name { get; set; } + private DateTime BeginAt; + private DateTime EndAt; + public TimeSpan ElapsedTime => EndAt - BeginAt; public IWorkStep.NodeTypes NodeType { get; set; } public MES_WO_NODE Node { get; set; } public MES_WO_OPER OperSetting { get; set; } @@ -38,6 +41,12 @@ public int Sequence { get; set; } public List<string> PrepNodeIDs { get; set; } = new(); public string NodeID => NodeType == IWorkStep.NodeTypes.Action ? NodeAct.ID : Node.ID; + private bool _IsActive = true; + public bool IsActive + { + get => NodeType == IWorkStep.NodeTypes.Action ? ActSetting.IS_ACTIVE == "Y" : _IsActive; + set { _IsActive = value; } + } private bool _IsFinished = false; public bool IsFinished { @@ -75,7 +84,24 @@ /// <returns></returns> public ApiAction<SubmitOutput> TryBegin(SubmitInput input) { - return CurAction.TryBegin(input); + BeginAt = DateTime.Now; + //宸ユ琛屼负鍚敤鍒欐甯告墽琛� + if (IsActive) + { + return CurAction.TryBegin(input); + } + //宸ユ琛屼负涓嶅惎鐢紝鍚﹀垯宸ユ榛樿瀹屾垚 + else + { + CurAction.IsFinished = true; + var action = new ApiAction<SubmitOutput>(new SubmitOutput()); + this.Message = Biz.L($"琛屼负鏈惎鐢�"); + this.Status = StepStatus.InActive; + action.Data.ShortMsg = new($"琛屼负鏈惎鐢�", ShortMessage.Types.Success); + //action.LocaleMsg = new($"{0}琛屼负鏈惎鐢�"); + action.LocaleMsg = new("MES.WorkAction.NotActive", NodeAct.ACT_NAME); + return action; + } } /// <summary> @@ -103,7 +129,18 @@ /// <returns></returns> public ApiAction<SubmitOutput> End(SubmitInput input) { - return CurAction.End(input); + var result = CurAction.End(input); + EndAt = DateTime.Now; + return result; + } + + /// <summary> + /// 鑾峰彇宸ユ褰撳墠鑰楁椂 + /// </summary> + /// <returns></returns> + public TimeSpan GetElapsedTime() + { + return DateTime.Now - BeginAt; } /// <summary> -- Gitblit v1.9.3