| | |
| | | using Tiger.IBusiness.MES.WorkAction; |
| | | using Tiger.Model; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using Tiger.Model.MES.Yada; |
| | | |
| | | namespace Tiger.Business.MES.WorkAction |
| | | { |
| | |
| | | public MES_CUST_SN CurCSN { get; set; } |
| | | public BAS_LABEL_TEMP Label { get; set; } |
| | | public List<BAS_LABEL_PV> LabelPV { get; set; } |
| | | public List<mes_MOPickList> MoPickList { get; set; } |
| | | #endregion Propertys & Variables |
| | | |
| | | #region Functions |
| | |
| | | Setting = setting; |
| | | #endregion |
| | | |
| | | //获取打印模板 |
| | | 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(); |
| | | //获取工单备料信息 |
| | | MoPickList = Biz.DataSource["YadaU9C"].Client.Queryable<mes_MOPickList>().Where(q => q.MoDocNo == CurPosition.WorkBatch.WO.ORDER_NO).ToList(); |
| | | |
| | | CurStep.Message = Biz.L("扫描厂内条码"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | //只允许单个产品进行客户条码绑定 |
| | | if (CurPosition.CurWipSNs.Count > 1) |
| | | { |
| | | action.Data.ShortMsg = new("请扫描产品", ShortMessage.Types.Error); |
| | | CurStep.Message = Biz.L("请扫描单个产品"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.ShortMsg = new("请扫描单个产品", ShortMessage.Types.Error); |
| | | //action.LocaleMsg = new($"条码[{0}]是包装/载具条码,请重新扫描单个厂内条码进行客户条码绑定"); |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotProductSN", CurPosition.CurSN); |
| | | //重置工序操作 |
| | |
| | | //厂内条码已绑定客户条码,直接结束行为 |
| | | if (!CurCSN.IsNullOrEmpty()) |
| | | { |
| | | CurCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | |
| | | End(); |
| | | //客户条码已绑定当前工单或者其批次属于当前工单上料物料的推荐批次 |
| | | if (CurCSN.WORK_ORDER == CurPosition.WorkBatch.WO.ORDER_NO || MoPickList.Any(q => q.Code == CurCSN.ITEM_CODE && q.SuggestedBatch == CurCSN.WORK_ORDER)) |
| | | { |
| | | CurCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | action.Data.Data = new |
| | | { |
| | | NeedPrint = false, |
| | | NeedScan = false, |
| | | Label = "", |
| | | }; |
| | | action = End(input); |
| | | } |
| | | else |
| | | { |
| | | action.Data.Data = new |
| | | { |
| | | NeedPrint = false, |
| | | NeedScan = false, |
| | | Label = "", |
| | | }; |
| | | CurStep.Message = Biz.L("投料错误"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.ShortMsg = new("投料错误", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"产品的客户条码[{0}]属于工单[{1}]不适用于当前工单[{2}]的生产"); |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.InputSnError", CurCSN.CUST_SN, CurCSN.WORK_ORDER, CurPosition.WorkBatch.WO.ORDER_NO); |
| | | //如果行为设置为出错需要重置工序操作 |
| | | if (NodeAct.NEED_RESET == "Y") |
| | | { |
| | | CurPosition.ResetNode(); |
| | | } |
| | | return action; |
| | | } |
| | | } |
| | | //厂内条码未绑定客户条码 |
| | | else |
| | |
| | | action.Data.Data = new |
| | | { |
| | | NeedPrint = false, |
| | | Label = "", |
| | | NeedScan = true, |
| | | Label = "", |
| | | }; |
| | | action.Data.ShortMsg = new("扫描客户标签", ShortMessage.Types.Normal); |
| | | CurStep.Message = Biz.L("扫描客户标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | action.Data.ShortMsg = new("扫描客户标签", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new Locale($"请扫描厂内条码[{0}]需要绑定客户条码"); |
| | | action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.BeginScan", wipSn.SN); |
| | | } |
| | |
| | | action.Data.Data = new |
| | | { |
| | | NeedPrint = true, |
| | | Label, |
| | | NeedScan = true, |
| | | Label, |
| | | }; |
| | | action.Data.ShortMsg = new("打印客户标签", ShortMessage.Types.Normal); |
| | | CurStep.Message = Biz.L("扫描已打印的客户标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | action.Data.ShortMsg = new("扫描已打印的客户标签", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new Locale($"开始打印厂内条码[{0}]对应的客户条码"); |
| | | action.LocaleMsg = new Locale("MES.WorkAction.ThreeInOne.BeginPrint", wipSn.SN); |
| | | } |
| | |
| | | //客户条码已绑定其他厂内条码 |
| | | if (!CurCSN.FLOW_SN.IsNullOrEmpty() && CurCSN.FLOW_SN != CurPosition.CurWipSNs.First().SN) |
| | | { |
| | | CurStep.Message = Biz.L("绑定失败"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.ShortMsg = new("绑定失败", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"厂内条码[{0}]绑定客户条码[{1}]失败,客户条码已绑定厂内条码[{2}]"); |
| | |
| | | //客户条码不属于当前工单的客户 |
| | | else if (CurCSN.CUST_CODE.IsNullOrEmpty(CurPosition.WorkBatch.WO.CUST_CODE) != CurPosition.WorkBatch.WO.CUST_CODE) |
| | | { |
| | | CurStep.Message = Biz.L("绑定失败"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.ShortMsg = new("绑定失败", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"客户条码[{0}]属于客户[{1}],与当前工单的客户[{2}]不一致"); |
| | |
| | | CurCSN.FLOW_SN = CurPosition.CurWipSNs.First().SN; |
| | | CurCSN.WORK_ORDER = CurPosition.WorkBatch.WO.ORDER_NO; |
| | | CurCSN.ITEM_CODE = CurPosition.WorkBatch.WO.ITEM_CODE; |
| | | action = End(); |
| | | action = End(input); |
| | | } |
| | | |
| | | return action; |
| | |
| | | /// 结束执行工序行为 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> End() |
| | | public ApiAction<SubmitOutput> End(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | //记录行为操作记录 |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | | var woSns = new List<BIZ_MES_WO_SN>(); |
| | | var snHiss = new List<MES_WIP_HIS>(); |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | | { |
| | | //更新在制品信息SN为客户条码 |
| | | wipSn.SN = CurCSN.CUST_SN; |
| | | //更新在制品信息历史得SN为客户条码 |
| | | var his = CurPosition.CurWipSNHiss.First(q => q.WIP_ID == wipSn.ID); |
| | | his.SN = CurCSN.CUST_SN; |
| | | snHiss.Add(his); |
| | | //更新工单条码表的 |
| | | var woSn = CurPosition.WorkBatch.WoSNs.First(q => q.WIP_ID == wipSn.ID); |
| | | woSn.SN = CurCSN.CUST_SN; |
| | | woSns.Add(woSn); |
| | | var wipAct = new MES_WIP_ACT() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | |
| | | } |
| | | |
| | | //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值 |
| | | var _wipSns = CurPosition.CurWipSNs.Clone(); |
| | | var _snHiss = snHiss.Clone(); |
| | | var _woSns = woSns.Clone(); |
| | | var _wipActs = wipActs.Clone(); |
| | | var _CurCSN = CurCSN.Clone(); |
| | | //保存数据 |
| | | CurStep.DBSubmitAction = () => |
| | | { |
| | | var db = CurPosition.GetCommitDB(); |
| | | db.Storageable(_wipSns, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_snHiss, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_woSns, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_CurCSN, CurPosition.UserCode).ExecuteCommand(); |
| | | }; |
| | | |
| | | IsFinished = true; |
| | | CurStep.Message = Biz.L("客户条码已绑定"); |
| | | CurStep.Status = StepStatus.Finished; |
| | | action.Data.ShortMsg = new("客户条码已绑定", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"厂内条码[{0}]已绑定客户条码[{1}]完成", Label.LABEL_NAME); |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingComplete", CurCSN.FLOW_SN, CurCSN.CUST_SN); |