| | |
| | | using System.Linq; |
| | | using Newtonsoft.Json; |
| | | using Tiger.IBusiness; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Tiger.Business.MES; |
| | | using Org.BouncyCastle.Ocsp; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using static Tiger.Business.Biz; |
| | | using System.ComponentModel; |
| | | |
| | | namespace Tiger.Business |
| | | { |
| | |
| | | /// <summary> |
| | | /// 工步 |
| | | /// </summary> |
| | | public partial class WorkStep |
| | | public partial class WorkStep : IWorkStep |
| | | { |
| | | public WorkStep(string id, Types type) |
| | | public WorkStep(IWorkStep.NodeTypes type, IPosition position) |
| | | { |
| | | ID = id; |
| | | Type = type; |
| | | NodeType = type; |
| | | CurPosition = position; |
| | | } |
| | | |
| | | #region Propertys & Variables |
| | | public string ID { get; set; } = Guid.NewGuid().ToString("N"); |
| | | public enum Types { Node, Action } |
| | | public Types Type { get; set; } |
| | | public int Sequence { get; set; } |
| | | //public bool IsFinished { get; set; } = false; |
| | | public string Name { get; set; } |
| | | public IWorkStep.NodeTypes NodeType { get; set; } |
| | | public MES_WO_NODE Node { get; set; } |
| | | public MES_WO_OPER OperSetting { get; set; } |
| | | public MES_WO_NODE_ACT NodeAct { get; set; } |
| | | public MES_WO_ACTION Setting { get; set; } |
| | | public MES_WO_ACTION ActSetting { get; set; } |
| | | public IPosition CurPosition { get; set; } |
| | | public IWorkAction CurAction { get; set; } |
| | | public bool IsFinished => (Type == Types.Action && CurAction.IsFinished) || Type == Types.Node; |
| | | 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 _IsFinished = false; |
| | | //public bool IsFinished |
| | | //{ |
| | | // get => NodeType == IWorkStep.NodeTypes.Action ? CurAction.IsFinished : _IsFinished; |
| | | // set { _IsFinished = value; } |
| | | //} |
| | | public StepStatus Status { get; set; } = StepStatus.Normal; |
| | | public bool IsFinished => Status == StepStatus.Finished; |
| | | private Locale _Message; |
| | | public Locale Message |
| | | { |
| | | get => _Message; |
| | | set { _MsgHistory.Add(_Message = value); } |
| | | } |
| | | private List<Locale> _MsgHistory = new(); |
| | | public List<Locale> MsgHistory => _MsgHistory; |
| | | public Action DBSubmitAction { get; set; } = () => { }; |
| | | #endregion |
| | | |
| | | #region Functions |
| | | public ApiAction<SubmitOutput> Begin(IPosition position) |
| | | /// <summary> |
| | | /// 初始化工步 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public void Init() |
| | | { |
| | | CurPosition = position; |
| | | CurAction = DI.Resolve(NodeAct.Definition.SERVICE_TYPE) as IWorkAction; |
| | | //CurAction = DI.Resolve("Tiger.IBusiness.IPrintLabel,Tiger.IBusiness") as IWorkAction; |
| | | return CurAction.Begin(ID, position, NodeAct, Setting); |
| | | CurAction.Init(this, CurPosition, NodeAct, ActSetting); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 尝试开始执行工步 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> TryBegin(SubmitInput input) |
| | | { |
| | | return CurAction.TryBegin(input); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取行为开始的提示信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Locale GetBeginMsg() |
| | | { |
| | | return CurAction.GetBeginMsg(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 工步提交数据 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> Submit(SubmitInput input) |
| | | { |
| | | return CurAction.Submit(input); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 结束工步执行 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> End(SubmitInput input) |
| | | { |
| | | return CurAction.End(input); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前工步的信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public WorkStepInfo GetInfo(string locale) |
| | | { |
| | | return new WorkStepInfo() { |
| | | ID = ID, |
| | | Name = Name, |
| | | Sequence = Sequence, |
| | | NodeID = NodeID, |
| | | NodeType = NodeType.ToString(), |
| | | Node = Node, |
| | | OperSetting = OperSetting, |
| | | NodeAct = NodeAct, |
| | | ActSetting = ActSetting, |
| | | Status = Status.ToString(), |
| | | Message = Message.IsNullOrEmpty() ? "" : Biz.T(Message, locale), |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | } |