| | |
| | | |
| | | #region Functions |
| | | /// <summary> |
| | | /// 开始执行工序行为 |
| | | /// 初始化工序行为 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> Begin(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting) |
| | | public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting) |
| | | { |
| | | CurStep = curStep; |
| | | CurPosition = position; |
| | | NodeAct = nodeAct; |
| | | Setting = setting; |
| | | var action = new ApiAction<SubmitOutput>(); |
| | | |
| | | Label = Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == setting.LABEL_CODE).IncludesAllFirstLayer().First(); |
| | | LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取行为开始的提示信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Locale GetBeginMsg() |
| | | { |
| | | var msg = new Locale("MES.WorkAction.PrintLabel.BeginMsg", CurPosition.CurWipSN.SN, Label.LABEL_CODE, Label.LABEL_NAME); |
| | | //var msg = new Locale($"开始打印条码[{CurPosition.CurWipSN.SN}]的标签[{Label.LABEL_CODE}: {Label.LABEL_NAME}]"); |
| | | return msg; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 尝试开始执行工序行为 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> TryBegin(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | foreach (var item in Label.Variables) |
| | | { |
| | | switch (item.VAR_TYPE.GetEnum<BAS_LABEL_VAR.VAR_TYPEs>()) |
| | |
| | | break; |
| | | } |
| | | } |
| | | action.Data.StepActCode = nodeAct.Definition.ACT_CODE; |
| | | action.Data.Data = Label; |
| | | |
| | | //如果根据输入可以开始执行当前行为则标记为成功,否则失败 |
| | | action.IsSuccessed = true; |
| | | return action; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 工序行为提交数据 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> Submit(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(); |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | //提交数据执行成功 |
| | | if (input.Data.ToBoolean()) |
| | | { |
| | | action = End(); |
| | | } |
| | | //提交数据执行失败 |
| | | else |
| | | { |
| | | //重置当前工序 |
| | | CurPosition.ResetSteps(); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"标签{Label.LABEL_NAME}[{Label.LABEL_CODE}]打印失败,请重新扫描产品条码", Label.LABEL_NAME); |
| | | //action.LocaleMsg = new($"标签{Label.LABEL_NAME}[{Label.LABEL_CODE}]打印失败", Label.LABEL_NAME); |
| | | action.LocaleMsg = new("MES.WorkAction.PrintLabel.PrintFail", Label.LABEL_NAME, Label.LABEL_CODE); |
| | | //如果行为设置为出错需要重置工序操作 |
| | | if (NodeAct.NEED_RESET == "Y") |
| | | { |
| | | CurPosition.ResetSteps(); |
| | | } |
| | | } |
| | | return action; |
| | | } |
| | |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> End() |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(); |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | //记录行为操作记录 |
| | | var wipAct = new MES_WIP_ACT() |
| | | { |
| | | HIS_ID = CurPosition.CurWipSN.HIS_ID, |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | HIS_ID = CurPosition.CurWipSNHis.ID, |
| | | SN = CurPosition.CurWipSN.SN, |
| | | STATUS = CurPosition.CurWipSN.STATUS, |
| | | ITEM_CODE = CurPosition.CurWipSN.ITEM_CODE, |
| | |
| | | case "GetSN": |
| | | return CurPosition.CurWipSN.SN; |
| | | case "GetBAS_ITEM": |
| | | return Biz.Db.Queryable<BAS_ITEM>().Where(q => q.ITEM_CODE == CurPosition.CurWipSN.ITEM_CODE).First()?.ToJson(); |
| | | return CurPosition.WorkBatch.Product.ToJson(); |
| | | case "GetCustomer": |
| | | return CurPosition.WorkBatch.Batch.ToJson(); |
| | | default: |