| | |
| | | { |
| | | #region Propertys & Variables |
| | | #region 固定写法,工序中的必要信息 |
| | | public DbClient MainDB { get; set; } |
| | | public bool IsFinished { get; set; } = false; |
| | | public IWorkStep CurStep { get; set; } |
| | | public IPosition CurPosition { get; set; } |
| | |
| | | public MES_CUST_SN FlowCSN { get; set; } |
| | | public MES_CUST_SN CustCSN { get; set; } |
| | | public BAS_LABEL_TEMP Label { get; set; } |
| | | public List<BAS_LABEL_PV> LabelPV { get; set; } |
| | | public List<BAS_PROCESS_VAR> LabelPV { get; set; } |
| | | public List<mes_MOPickList> MoPickList { get; set; } |
| | | public BAS_ITEM_CUST CustInfo { get; set; } |
| | | #endregion Propertys & Variables |
| | |
| | | public void Init(IWorkStep curStep, IPosition position, MES_WO_NODE_ACT nodeAct, MES_WO_ACTION setting) |
| | | { |
| | | #region 固定写法,给默认变量赋值 |
| | | MainDB = position.MainDB; |
| | | CurStep = curStep; |
| | | CurPosition = position; |
| | | NodeAct = nodeAct; |
| | |
| | | #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(); |
| | | Label = MainDB.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == setting.LABEL_CODE).IncludesAllFirstLayer().First(); |
| | | LabelPV = MainDB.Queryable<BAS_PROCESS_VAR>().ToList(); |
| | | |
| | | //获取当前产品在当前客户的关系 |
| | | CustInfo = Biz.Db.Queryable<BAS_ITEM_CUST>().Where(q => q.ITEM_ID == CurPosition.WorkBatch.WO.ItemInfo.ID && q.CUST_CODE == CurPosition.WorkBatch.WO.CUST_CODE).First(); |
| | | CustInfo = MainDB.Queryable<BAS_ITEM_CUST>().Where(q => q.ITEM_ID == CurPosition.WorkBatch.WO.ItemInfo.ID && q.CUST_CODE == CurPosition.WorkBatch.WO.CUST_CODE).First(); |
| | | |
| | | CurStep.Message = Biz.L("扫描厂内条码或客户条码"); |
| | | CurStep.Status = StepStatus.Normal; |
| | |
| | | } |
| | | |
| | | var wipSn = CurPosition.CurWipSNs.First(); |
| | | FlowCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == wipSn.SN || q.CUST_SN == wipSn.SN).First(); |
| | | FlowCSN = MainDB.Queryable<MES_CUST_SN>().Where(q => q.FLOW_SN == wipSn.SN || q.CUST_SN == wipSn.SN).First(); |
| | | //找不到生产记录,认为扫描错误 |
| | | if (FlowCSN.IsNullOrEmpty()) |
| | | { |
| | |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | //查询是否存在已导入的客户条码 |
| | | CustCSN = Biz.Db.Queryable<MES_CUST_SN>().Where(q => q.CUST_SN == input.Data).First(); |
| | | CustCSN = MainDB.Queryable<MES_CUST_SN>().Where(q => q.CUST_SN == input.Data).First(); |
| | | |
| | | var isOK = true; |
| | | //客户条码扫到厂内条码 |
| | | if (isOK && FlowCSN.FLOW_SN == input.Data) |
| | | { |
| | | CurStep.SetStatusMessage(StepStatus.Error, Biz.L("请扫描正确的客户标签")); |
| | | action.Data.ShortMsg = new("请扫描正确的客户标签", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = isOK = false; |
| | | //action.LocaleMsg = new($"厂内条码[{0}]绑定客户条码[{1}]失败,厂内条码与客户条码不能一样,请扫描正确的客户标签"); |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.TheSameSN", FlowCSN.FLOW_SN, input.Data); |
| | | } |
| | | //客户条码已绑定其他厂内条码 |
| | | if (!CustCSN.IsNullOrEmpty() && !CustCSN.FLOW_SN.IsNullOrEmpty() && CustCSN.FLOW_SN != FlowCSN.FLOW_SN) |
| | | if (isOK && !CustCSN.IsNullOrEmpty() && !CustCSN.FLOW_SN.IsNullOrEmpty() && CustCSN.FLOW_SN != FlowCSN.FLOW_SN) |
| | | { |
| | | CurStep.SetStatusMessage(StepStatus.Error, Biz.L("请扫描正确的客户标签")); |
| | | action.Data.ShortMsg = new("请扫描正确的客户标签", ShortMessage.Types.Failed); |
| | |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.BindingOtherSN", CurPosition.CurWipSNs.First().SN, CustCSN.CUST_SN, CustCSN.FLOW_SN); |
| | | } |
| | | //客户条码不属于当前工单的客户 |
| | | if (!CustCSN.IsNullOrEmpty() && CustCSN.CUST_CODE.IsNullOrEmpty(CurPosition.WorkBatch.WO.CUST_CODE) != CurPosition.WorkBatch.WO.CUST_CODE) |
| | | if (isOK && !CustCSN.IsNullOrEmpty() && CustCSN.CUST_CODE.IsNullOrEmpty(CurPosition.WorkBatch.WO.CUST_CODE) != CurPosition.WorkBatch.WO.CUST_CODE) |
| | | { |
| | | CurStep.SetStatusMessage(StepStatus.Error, Biz.L("请扫描正确的客户标签")); |
| | | action.Data.ShortMsg = new("请扫描正确的客户标签", ShortMessage.Types.Failed); |
| | |
| | | action.LocaleMsg = new("MES.WorkAction.ThreeInOne.NotSameCustomer", CustCSN.CUST_SN, CustCSN.CUST_CODE, CurPosition.WorkBatch.WO.CUST_CODE); |
| | | } |
| | | //验证产品客户标签条码规则 |
| | | if (CustInfo.IsNullOrEmpty() && !CustInfo.RULE_CODE.IsNullOrEmpty() && !Biz.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty()) |
| | | if (isOK && !CustInfo.IsNullOrEmpty() && !CustInfo.RULE_CODE.IsNullOrEmpty() && !Cache.CodeRule[CustInfo.RULE_CODE].IsNullOrEmpty()) |
| | | { |
| | | var result = Biz.CodeRule[CustInfo.RULE_CODE].Verify(CustCSN.CUST_SN); |
| | | var result = Cache.CodeRule[CustInfo.RULE_CODE].Verify(CustCSN.CUST_SN); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | CurStep.SetStatusMessage(StepStatus.Error, Biz.L("请扫描正确的客户标签")); |
| | |
| | | |
| | | //记录行为操作记录 |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | | var wipVars = new List<MES_WIP_ACT_VAR>(); |
| | | var woSns = new List<BIZ_MES_WO_SN>(); |
| | | var snHiss = new List<MES_WIP_HIS>(); |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | |
| | | PRD_CODE = wipSn.PRD_CODE, |
| | | ACT_TYPE = NodeAct.ACT_TYPE, |
| | | ACT_SN = wipSn.SN, |
| | | ACT_VALUE_1 = Label.LABEL_CODE, |
| | | ACT_VALUE_2 = Label.Variables.ToJson(), |
| | | ACT_VALUE_1 = Label?.LABEL_CODE, |
| | | ACT_VALUE_2 = Label?.Variables.ToJson(), |
| | | ACT_VAR_DIC = CurStep.ActionDic.ToJson(), |
| | | ACT_RESULT = "Y", |
| | | ELAPSED_TIME = CurStep.GetElapsedTime().TotalMilliseconds.ToInt64(), |
| | | TRACE_INFO = $"厂内条码[{FlowCSN.FLOW_SN}]绑定客户条码[{FlowCSN.CUST_SN}]成功", |
| | | }; |
| | | wipActs.Add(wipAct); |
| | | foreach (var item in NodeAct.Variables) |
| | | { |
| | | var wipVar = new MES_WIP_ACT_VAR() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID, |
| | | WIP_ID = wipSn.ID, |
| | | SN = wipSn.SN, |
| | | ITEM_CODE = wipSn.ITEM_CODE, |
| | | WORK_ORDER = wipSn.WORK_ORDER, |
| | | BATCH_NO = wipSn.BATCH_NO, |
| | | CUST_CODE = CurPosition.WorkBatch.WO.CUST_CODE, |
| | | ROT_CODE = wipSn.ROT_CODE, |
| | | NODE_ID = wipSn.NODE_ID, |
| | | NODE_NAME = wipSn.NODE_NAME, |
| | | ACT_ID = NodeAct.ID, |
| | | ACT_NAME = NodeAct.ACT_NAME, |
| | | FTY_CODE = wipSn.FTY_CODE, |
| | | WS_CODE = wipSn.WS_CODE, |
| | | LINE_CODE = wipSn.LINE_CODE, |
| | | POST_CODE = wipSn.POST_CODE, |
| | | OPER_CODE = wipSn.OPER_CODE, |
| | | SEGMENT = wipSn.SEGMENT, |
| | | FLOW_SN = wipSn.FLOW_SN, |
| | | TRAY_SN = wipSn.TRAY_SN, |
| | | INNER_SN = wipSn.INNER_SN, |
| | | CARTON_SN = wipSn.CARTON_SN, |
| | | PALLET_SN = wipSn.PALLET_SN, |
| | | OPERATION_TIME = DateTime.Now, |
| | | SFTS_CODE = wipSn.SFTS_CODE, |
| | | SFT_CODE = wipSn.SFT_CODE, |
| | | PRD_CODE = wipSn.PRD_CODE, |
| | | VAR_CODE = item.VAR_CODE, |
| | | VAR_NAME = item.VAR_NAME, |
| | | VAR_CONTROL = item.VAR_CONTROL, |
| | | VALUE_TYPE = item.VALUE_TYPE, |
| | | PROCESS_VAR = item.PROCESS_VAR, |
| | | INPUT_VALUE = CurStep.ActionDic.GetOrDefault(item.VAR_CODE), |
| | | TRACE_INFO = CurStep.ActionDic.ToJson(), |
| | | }; |
| | | wipVars.Add(wipVar); |
| | | } |
| | | } |
| | | |
| | | //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值 |
| | |
| | | var _snHiss = snHiss.Clone(); |
| | | var _woSns = woSns.Clone(); |
| | | var _wipActs = wipActs.Clone(); |
| | | var _wipVars = wipVars.Clone(); |
| | | var _FlowCSN = FlowCSN.Clone(); |
| | | var _CustCSN = CustCSN.Clone(); |
| | | //保存数据 |
| | |
| | | db.Storageable(_snHiss, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_woSns, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_wipVars, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_FlowCSN, CurPosition.UserCode).ExecuteCommand(); |
| | | if (!_CustCSN.IsNullOrEmpty()) |
| | | { |