| | |
| | | PkgRule = Biz.Db.Queryable<BAS_PKG_RULE>().Where(q => q.RULE_CODE == setting.PKG_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Details).First(); |
| | | } |
| | | //根据行为设置获取多层包装的标签打印模板字典 |
| | | //for (int i = 1; i < 10; i++) |
| | | //{ |
| | | // var code = Setting.GetType().GetProperty($"OPTION_{i}")?.GetValue(Setting)?.ToString() ?? ""; |
| | | // var label = code.IsNullOrEmpty() ? null : Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == code).IncludesAllFirstLayer().First(); |
| | | // LabelDic.Add(i, label); |
| | | //} |
| | | var codes = Setting.OPTION_1?.ToString().JsonToObject<List<WipPkgItem>>(); |
| | | var codes = (Setting.OPTION_1?? "").JsonToObject<List<WipPkgItem>>(); |
| | | foreach (var code in codes) |
| | | { |
| | | var label = code.LABEL_CODE.IsNullOrEmpty() ? null : Biz.Db.Queryable<BAS_LABEL_TEMP>().Where(q => q.LABEL_CODE == code.LABEL_CODE).IncludesAllFirstLayer().First(); |
| | | LabelDic.Add(code.PKG_LEVEL, label); |
| | | } |
| | | LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); |
| | | //如果工序上下文中没有包装记录则新建一个,有则获取当前的包装记录 |
| | | if (CurPosition.Context.ContainsKey("CurPackage") && !CurPosition.Context["CurPackage"].IsNullOrEmpty()) |
| | | { |
| | |
| | | //行为设定的OPTION_1是第一层包装的标签模板代码,如果为空则不需要打印 |
| | | if (LabelDic[min.PKG_LEVEL].IsNullOrEmpty()) |
| | | { |
| | | var msg = new Locale("MES.WorkAction.PackingAction.BeginMsg", min.PKG_LEVEL, min.PkgType.PKG_NAME, CurPosition.CurWipSN.SN); |
| | | var msg = new Locale("MES.WorkAction.PackingAction.BeginMsg", min.PKG_LEVEL, min.PkgType.PKG_NAME, CurPosition.CurSN); |
| | | //var msg = new Locale($"已扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码[{CurPosition.CurWipSN.SN}]"); |
| | | return msg; |
| | | } |
| | |
| | | action.LocaleMsg = GetBeginMsg(); |
| | | |
| | | var min = PkgRule.Details.OrderBy(q => q.PKG_LEVEL).First(); |
| | | //行为设定的OPTION_1-9是包装不同层级的标签模板代码,如果为空则不需要打印 |
| | | //根据包装不同层级的标签模板代码,如果为空则不需要打印 |
| | | if (LabelDic[min.PKG_LEVEL].IsNullOrEmpty()) |
| | | { |
| | | input.Data = new PackingActionInput() |
| | |
| | | ExecCode = "Scan", |
| | | IsFinish = true, |
| | | PkgLevel = min.PKG_LEVEL, |
| | | PkgSN = CurPosition.CurWipSN.SN, |
| | | PkgSN = CurPosition.CurSN, |
| | | }.ToJson(); |
| | | action = Submit(input); |
| | | } |
| | |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | SN = pInput.PkgSN, |
| | | PKG_TYPE = dtl.PkgType.PKG_NAME, |
| | | ITEM_CODE = CurPosition.CurWipSN.ITEM_CODE, |
| | | QTY = CurPosition.CurWipSN.QTY, |
| | | ITEM_CODE = CurPosition.CurWipSNs.First().ITEM_CODE, |
| | | QTY = CurPosition.CurWipSNs.First().QTY, |
| | | UNIT = dtl.PkgType.PKG_NAME, |
| | | WORK_ORDER = CurPosition.CurWipSN.WORK_ORDER, |
| | | BATCH_NO = CurPosition.CurWipSN.BATCH_NO, |
| | | ROT_CODE = CurPosition.CurWipSN.ROT_CODE, |
| | | NODE_ID = CurPosition.CurWipSN.NODE_ID, |
| | | NODE_NAME = CurPosition.CurWipSN.NODE_NAME, |
| | | FTY_CODE = CurPosition.CurWipSN.FTY_CODE, |
| | | WS_CODE = CurPosition.CurWipSN.WS_CODE, |
| | | LINE_CODE = CurPosition.CurWipSN.LINE_CODE, |
| | | POST_CODE = CurPosition.CurWipSN.POST_CODE, |
| | | OPER_CODE = CurPosition.CurWipSN.OPER_CODE, |
| | | SEGMENT = CurPosition.CurWipSN.SEGMENT, |
| | | WORK_ORDER = CurPosition.CurWipSNs.First().WORK_ORDER, |
| | | BATCH_NO = CurPosition.CurWipSNs.First().BATCH_NO, |
| | | ROT_CODE = CurPosition.CurWipSNs.First().ROT_CODE, |
| | | NODE_ID = CurPosition.CurWipSNs.First().NODE_ID, |
| | | NODE_NAME = CurPosition.CurWipSNs.First().NODE_NAME, |
| | | FTY_CODE = CurPosition.CurWipSNs.First().FTY_CODE, |
| | | WS_CODE = CurPosition.CurWipSNs.First().WS_CODE, |
| | | LINE_CODE = CurPosition.CurWipSNs.First().LINE_CODE, |
| | | POST_CODE = CurPosition.CurWipSNs.First().POST_CODE, |
| | | OPER_CODE = CurPosition.CurWipSNs.First().OPER_CODE, |
| | | SEGMENT = CurPosition.CurWipSNs.First().SEGMENT, |
| | | } |
| | | }; |
| | | FinishLevel++; |
| | |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | SN = pInput.PkgSN, |
| | | PKG_TYPE = dtl.PkgType.PKG_NAME, |
| | | ITEM_CODE = CurPosition.CurWipSN.ITEM_CODE, |
| | | ITEM_CODE = CurPosition.CurWipSNs.First().ITEM_CODE, |
| | | QTY = CurPkgItem.Items.Sum(q => q.Package.QTY), |
| | | UNIT = dtl.PkgType.PKG_NAME, |
| | | WORK_ORDER = CurPosition.CurWipSN.WORK_ORDER, |
| | | BATCH_NO = CurPosition.CurWipSN.BATCH_NO, |
| | | ROT_CODE = CurPosition.CurWipSN.ROT_CODE, |
| | | NODE_ID = CurPosition.CurWipSN.NODE_ID, |
| | | NODE_NAME = CurPosition.CurWipSN.NODE_NAME, |
| | | FTY_CODE = CurPosition.CurWipSN.FTY_CODE, |
| | | WS_CODE = CurPosition.CurWipSN.WS_CODE, |
| | | LINE_CODE = CurPosition.CurWipSN.LINE_CODE, |
| | | POST_CODE = CurPosition.CurWipSN.POST_CODE, |
| | | OPER_CODE = CurPosition.CurWipSN.OPER_CODE, |
| | | SEGMENT = CurPosition.CurWipSN.SEGMENT, |
| | | WORK_ORDER = CurPosition.CurWipSNs.First().WORK_ORDER, |
| | | BATCH_NO = CurPosition.CurWipSNs.First().BATCH_NO, |
| | | ROT_CODE = CurPosition.CurWipSNs.First().ROT_CODE, |
| | | NODE_ID = CurPosition.CurWipSNs.First().NODE_ID, |
| | | NODE_NAME = CurPosition.CurWipSNs.First().NODE_NAME, |
| | | FTY_CODE = CurPosition.CurWipSNs.First().FTY_CODE, |
| | | WS_CODE = CurPosition.CurWipSNs.First().WS_CODE, |
| | | LINE_CODE = CurPosition.CurWipSNs.First().LINE_CODE, |
| | | POST_CODE = CurPosition.CurWipSNs.First().POST_CODE, |
| | | OPER_CODE = CurPosition.CurWipSNs.First().OPER_CODE, |
| | | SEGMENT = CurPosition.CurWipSNs.First().SEGMENT, |
| | | }; |
| | | FinishLevel++; |
| | | //完成包装的层级小于最外层包装层级 |
| | |
| | | //最外层包装已经完成包装,保存包装数据到数据库 |
| | | else |
| | | { |
| | | action = SaveToDB(); |
| | | action = CompletePkg(); |
| | | } |
| | | } |
| | | //当前处理的包装层级已经处理完,继续往上保存 |
| | |
| | | return list; |
| | | } |
| | | |
| | | public ApiAction<SubmitOutput> SaveToDB() |
| | | public ApiAction<SubmitOutput> CompletePkg() |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | var pkgList = GetPackageList(CurPkg.Item); |
| | | |
| | | //保存数据库 |
| | | var db = Biz.Db; |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | db.Insertable(pkgList, CurPosition.UserCode).ExecuteCommand(); |
| | | }); |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | | throw dbTran.ErrorException; |
| | | } |
| | | |
| | | //删除工序上下文中的包装记录 |
| | | CurPosition.Context.Remove("CurPackage"); |
| | | |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | | data.ExecCode = "Complete"; |
| | |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | //记录行为操作记录 |
| | | var wipAct = new MES_WIP_ACT() |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | | { |
| | | 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, |
| | | WORK_ORDER = CurPosition.CurWipSN.WORK_ORDER, |
| | | BATCH_NO = CurPosition.CurWipSN.BATCH_NO, |
| | | ROT_CODE = CurPosition.CurWipSN.ROT_CODE, |
| | | NODE_ID = CurPosition.CurWipSN.NODE_ID, |
| | | NODE_NAME = CurPosition.CurWipSN.NODE_NAME, |
| | | ACT_ID = NodeAct.ID, |
| | | ACT_NAME = NodeAct.ACT_NAME, |
| | | FTY_CODE = CurPosition.CurWipSN.FTY_CODE, |
| | | WS_CODE = CurPosition.CurWipSN.WS_CODE, |
| | | LINE_CODE = CurPosition.CurWipSN.LINE_CODE, |
| | | POST_CODE = CurPosition.CurWipSN.POST_CODE, |
| | | OPER_CODE = CurPosition.CurWipSN.OPER_CODE, |
| | | SEGMENT = CurPosition.CurWipSN.SEGMENT, |
| | | TRAY_SN = CurPosition.CurWipSN.TRAY_SN, |
| | | OPERATION_TIME = DateTime.Now, |
| | | SFTS_CODE = CurPosition.CurWipSN.SFTS_CODE, |
| | | SFT_CODE = CurPosition.CurWipSN.SFT_CODE, |
| | | PRD_CODE = CurPosition.CurWipSN.PRD_CODE, |
| | | ACT_TYPE = NodeAct.ACT_TYPE, |
| | | ACT_SN = CurPosition.CurWipSN.SN, |
| | | ACT_RESULT = "Y", |
| | | TRACE_INFO = $"产品条码[{CurPosition.CurWipSN.SN}]包装完成", |
| | | }; |
| | | var wipAct = new MES_WIP_ACT() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID, |
| | | SN = wipSn.SN, |
| | | STATUS = wipSn.STATUS, |
| | | ITEM_CODE = wipSn.ITEM_CODE, |
| | | WORK_ORDER = wipSn.WORK_ORDER, |
| | | BATCH_NO = wipSn.BATCH_NO, |
| | | 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, |
| | | TRAY_SN = wipSn.TRAY_SN, |
| | | OPERATION_TIME = DateTime.Now, |
| | | SFTS_CODE = wipSn.SFTS_CODE, |
| | | SFT_CODE = wipSn.SFT_CODE, |
| | | PRD_CODE = wipSn.PRD_CODE, |
| | | ACT_TYPE = NodeAct.ACT_TYPE, |
| | | ACT_SN = wipSn.SN, |
| | | ACT_RESULT = "Y", |
| | | TRACE_INFO = $"产品条码[{string.Join(",", CurPosition.CurSN)}]包装完成", |
| | | }; |
| | | wipActs.Add(wipAct); |
| | | } |
| | | |
| | | //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值 |
| | | var _wipActs = wipActs.Clone(); |
| | | var _pkgList = CurPkg.IsFinished ? GetPackageList(CurPkg.Item) : new(); |
| | | //保存数据 |
| | | CurStep.DBSubmitAction = () => |
| | | { |
| | | var db = CurPosition.GetCommitDB(); |
| | | db.Storageable(wipAct, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); |
| | | if (_pkgList.Any()) |
| | | { |
| | | db.Insertable(_pkgList, CurPosition.UserCode).ExecuteCommand(); |
| | | foreach (var pkg in _pkgList) |
| | | { |
| | | //包装信息保存到在制品信息表 |
| | | db.Updateable<MES_WIP_DATA>() |
| | | .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN) |
| | | .SetColumns(q => q.CONTAINER_SN == q.CARTON_SN) |
| | | .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN) |
| | | .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN) |
| | | .ExecuteCommand(); |
| | | //包装信息保存到工单条码明细表 |
| | | db.Updateable<BIZ_MES_WO_SN>() |
| | | .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN) |
| | | .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN) |
| | | .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN) |
| | | .ExecuteCommand(); |
| | | } |
| | | } |
| | | }; |
| | | |
| | | //如果工序上下文中没有包装记录则新建一个 |
| | | if (CurPosition.Context.ContainsKey("CurPackage")) |
| | | if (CurPkg.IsFinished) |
| | | { |
| | | CurPosition.Context["CurPackage"] = CurPkg; |
| | | //最外层包装已经完成包装,则把工序中暂存标记设为false,统一提交包装内产品的过站记录 |
| | | CurPosition.NeedTemporaryStoreDBCommitAction = false; |
| | | //删除工序上下文中的包装记录 |
| | | CurPosition.Context.Remove("CurPackage"); |
| | | } |
| | | else |
| | | { |
| | | CurPosition.Context.Add("CurPackage", CurPkg); |
| | | //最外层包装未完成包装,则把工序中暂存标记设为true,待全部包装完成再统一提交包装内产品的过站记录 |
| | | CurPosition.NeedTemporaryStoreDBCommitAction = true; |
| | | //如果工序上下文中没有包装记录则新建一个 |
| | | if (CurPosition.Context.ContainsKey("CurPackage")) |
| | | { |
| | | CurPosition.Context["CurPackage"] = CurPkg; |
| | | } |
| | | else |
| | | { |
| | | CurPosition.Context.Add("CurPackage", CurPkg); |
| | | } |
| | | } |
| | | |
| | | IsFinished = true; |
| | | action.LocaleMsg = new($"产品条码[{CurPosition.CurWipSN.SN}]包装完成"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurWipSN.SN); |
| | | action.LocaleMsg = new($"产品条码[{CurPosition.CurSN}]包装完成"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurSN); |
| | | return action; |
| | | } |
| | | |