From aecffc1fac016281d4c835fafe23c002906acef5 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期四, 02 一月 2025 10:27:38 +0800 Subject: [PATCH] Handle packaging barcodes and improve weighing logic --- Tiger.Business.MES/Common/WorkStep.cs | 81 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 78 insertions(+), 3 deletions(-) diff --git a/Tiger.Business.MES/Common/WorkStep.cs b/Tiger.Business.MES/Common/WorkStep.cs index 581fbd3..16e993e 100644 --- a/Tiger.Business.MES/Common/WorkStep.cs +++ b/Tiger.Business.MES/Common/WorkStep.cs @@ -11,6 +11,7 @@ using Newtonsoft.Json; using Tiger.IBusiness; using Tiger.Model.Entitys.MES.Position; +using Tiger.Business.MES.Transaction; namespace Tiger.Business { @@ -28,6 +29,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; } @@ -35,9 +39,16 @@ public MES_WO_ACTION ActSetting { get; set; } public IPosition CurPosition { get; set; } public IWorkAction CurAction { get; set; } + public Dictionary<string, string> ActionDic { get; set; } = new(); 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 { @@ -66,6 +77,10 @@ { CurAction = DI.Resolve(NodeAct.Definition.SERVICE_TYPE) as IWorkAction; //CurAction = DI.Resolve("Tiger.IBusiness.IPrintLabel,Tiger.IBusiness") as IWorkAction; + + //璁剧疆琛屼负瀛楀吀 + ActionDic = NodeAct.Variables.ToDictionary(k => k.VAR_CODE, v => v.DEFAULT); + CurAction.Init(this, CurPosition, NodeAct, ActSetting); } @@ -75,7 +90,25 @@ /// <returns></returns> public ApiAction<SubmitOutput> TryBegin(SubmitInput input) { - return CurAction.TryBegin(input); + BeginAt = DateTime.Now; + //宸ユ琛屼负鍚敤鍒欐甯告墽琛� + if (IsActive) + { + UpdateActionDic(input.ActionDic); + return ResetActionDic(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> @@ -94,7 +127,8 @@ /// <returns></returns> public ApiAction<SubmitOutput> Submit(SubmitInput input) { - return CurAction.Submit(input); + UpdateActionDic(input.ActionDic); + return ResetActionDic(CurAction.Submit(input)); } /// <summary> @@ -103,7 +137,48 @@ /// <returns></returns> public ApiAction<SubmitOutput> End(SubmitInput input) { - return CurAction.End(input); + UpdateActionDic(input.ActionDic); + var result = CurAction.End(input); + EndAt = DateTime.Now; + return ResetActionDic(result); + } + + /// <summary> + /// 鑾峰彇宸ユ褰撳墠鑰楁椂 + /// </summary> + /// <returns></returns> + public void UpdateActionDic(Dictionary<string, string> newDic) + { + foreach (var item in newDic ?? new()) + { + if (ActionDic.ContainsKey(item.Key)) + { + ActionDic[item.Key] = item.Value; + } + else + { + ActionDic.Add(item.Key, item.Value); + } + } + } + + /// <summary> + /// 鑾峰彇宸ユ褰撳墠鑰楁椂 + /// </summary> + /// <returns></returns> + public ApiAction<SubmitOutput> ResetActionDic(ApiAction<SubmitOutput> output) + { + output.Data.ActionDic = ActionDic; + return output; + } + + /// <summary> + /// 鑾峰彇宸ユ褰撳墠鑰楁椂 + /// </summary> + /// <returns></returns> + public TimeSpan GetElapsedTime() + { + return DateTime.Now - BeginAt; } /// <summary> -- Gitblit v1.9.3