| | |
| | | using Tiger.IBusiness.MES.WorkAction; |
| | | using Tiger.Model; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using static Tiger.Model.WMS_ITEM_PKG; |
| | | using Tiger.Model.Minsun; |
| | | |
| | | namespace Tiger.Business.MES.WorkAction |
| | | { |
| | |
| | | public Dictionary<int, BAS_LABEL_TEMP> LabelDic { get; set; } = new(); |
| | | public List<BAS_LABEL_PV> LabelPV { get; set; } = new(); |
| | | public int FinishLevel = 0; |
| | | public bool NeedWeighing { get; set; } = false; |
| | | #endregion Propertys & Variables |
| | | |
| | | #region Functions |
| | |
| | | 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?? "").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(); |
| | | //获取是否包装完后需要称重 |
| | | NeedWeighing = Setting.OPTION_2 == "Y"; |
| | | //如果工序上下文中没有包装记录则新建一个,有则获取当前的包装记录 |
| | | 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); |
| | | } |
| | |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("打印标签", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new Locale($"开始第{PrintTimes}次打印第{min.PKG_LEVEL}层包装[{min.PkgType.PKG_NAME}]的标签[{LabelDic[min.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[min.PKG_LEVEL].LABEL_NAME}]"); |
| | | action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, min.PKG_LEVEL, min.PkgType.PKG_NAME, LabelDic[min.PKG_LEVEL]?.LABEL_CODE, LabelDic[min.PKG_LEVEL].LABEL_NAME); |
| | | } |
| | |
| | | case "Scan": |
| | | if (CurCmd.IsNullOrEmpty() || CurCmd.ExecCode == "Scan" || (CurCmd.ExecCode == "Print" && CurCmd.PkgLevel == pInput.PkgLevel)) |
| | | { |
| | | //客户端扫描成功 |
| | | if (pInput.IsFinish) |
| | | { |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | action = SavePkgData(input, action); |
| | | } |
| | | //客户端扫描失败 |
| | | else |
| | | if (!pInput.IsFinish || pInput.PkgSN.IsNullOrEmpty()) |
| | | { |
| | | var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); |
| | | action.Data.ShortMsg = new("扫描错误", ShortMessage.Types.Error); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"条码扫描失败,请重新扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanFail", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); |
| | | return action; |
| | | } |
| | | //验证当前包装条码是否已经被扫描过 |
| | | if (GetPackageList(CurPkg.Item).Any(q => q.SN == pInput.PkgSN)) |
| | | { |
| | | var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); |
| | | action.Data.ShortMsg = new("扫描错误", ShortMessage.Types.Error); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"条码[{pInput.PkgSN}]无需重复扫描,请扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanRepeat", pInput.PkgSN, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); |
| | | return action; |
| | | } |
| | | //客户端扫描成功 |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | action = SavePkgData(input, action); |
| | | if (action.IsSuccessed) |
| | | { |
| | | action.Data.ShortMsg = new("扫描成功", ShortMessage.Types.Success); |
| | | } |
| | | } |
| | | break; |
| | |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | CurCmd = data; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("扫描标签", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new($"请扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseScanLabel", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); |
| | | } |
| | |
| | | { |
| | | PrintTimes++; |
| | | action.Data.Data = CurCmd; |
| | | action.Data.ShortMsg = new("重新打印", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new Locale($"开始{PrintTimes}次打印第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签[{LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[dtl.PKG_LEVEL].LABEL_NAME}]"); |
| | | action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME); |
| | | } |
| | |
| | | { |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | action.Data.ShortMsg = new("打印失败", ShortMessage.Types.Failed); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"尝试第{PrintTimes}次打印第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签[{LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[dtl.PKG_LEVEL].LABEL_NAME}]失败,工序已重置,请重新扫描进站产品条码"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PrintFail3Times", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME); |
| | |
| | | { |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | action = End(); |
| | | if (NeedWeighing) |
| | | { |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | | data.ExecCode = "Weighing"; |
| | | data.PkgLevel = CurPkgItem.PKG_LEVEL; |
| | | CurCmd = data; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("包装成功", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"请把包装[{CurPkgItem.Package.SN}]上称称重"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighing", CurPkgItem.Package.SN); |
| | | } |
| | | else |
| | | { |
| | | action = End(); |
| | | } |
| | | } |
| | | break; |
| | | // Complete:完成,完成全部包装后结束行为 |
| | | case "Weighing": |
| | | if (CurCmd.ExecCode == "Weighing") |
| | | { |
| | | if (!pInput.WeightInfo.IsNullOrEmpty() && pInput.WeightInfo.Weight > 0) |
| | | { |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | CurPkgItem.Package.WEIGHT = pInput.WeightInfo.Weight; |
| | | CurPkgItem.Package.WEIGHT_UNIT = pInput.WeightInfo.Unit; |
| | | action = End(); |
| | | } |
| | | else |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.Data.ShortMsg = new("称重失败", ShortMessage.Types.Failed); |
| | | //action.LocaleMsg = new($"包装[{CurPkgItem.Package.SN}]称重数据异常,请重新上称称重"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighingAgain", CurPkgItem.Package.SN); |
| | | return action; |
| | | } |
| | | } |
| | | break; |
| | | // 手动结束包装,保存暂存的包装数据 |
| | |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | CurCmd = data; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("扫描标签", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new($"请扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseScanLabel", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); |
| | | } |
| | |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("打印标签", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new Locale($"开始第{PrintTimes}次打印第{min.PKG_LEVEL}层包装[{min.PkgType.PKG_NAME}]的标签[{LabelDic[min.PKG_LEVEL]?.LABEL_CODE}: {LabelDic[min.PKG_LEVEL].LABEL_NAME}]"); |
| | | action.LocaleMsg = new Locale("MES.WorkAction.PackingAction.BeginPrint", PrintTimes, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME, LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, LabelDic[dtl.PKG_LEVEL].LABEL_NAME); |
| | | } |
| | |
| | | PKG_QTY = dtl.PKG_QTY, |
| | | LABEL_CODE = LabelDic[dtl.PKG_LEVEL]?.LABEL_CODE, |
| | | IsFinished = true, |
| | | Package = new() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | 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, |
| | | 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, |
| | | } |
| | | }; |
| | | |
| | | CurPkgItem.Package = Biz.Db.Queryable<MES_WIP_PKG>().Where(q => q.SN == pInput.PkgSN && q.AUTH_ORG == CurPosition.WorkBatch.WO.AUTH_ORG).First() ?? new() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | SN = pInput.PkgSN, |
| | | }; |
| | | CurPkgItem.Package.WIP_ID = CurPosition.CurWipSNs.Count == 1 ? CurPosition.CurWipSNs.First().ID : null; |
| | | CurPkgItem.Package.PKG_TYPE = dtl.PkgType.PKG_NAME; |
| | | CurPkgItem.Package.ITEM_CODE = CurPosition.CurWipSNs.First().ITEM_CODE; |
| | | CurPkgItem.Package.QTY = CurPosition.CurWipSNs.First().QTY; |
| | | CurPkgItem.Package.UNIT = dtl.PkgType.PKG_NAME; |
| | | CurPkgItem.Package.WORK_ORDER = CurPosition.CurWipSNs.First().WORK_ORDER; |
| | | CurPkgItem.Package.BATCH_NO = CurPosition.CurWipSNs.First().BATCH_NO; |
| | | CurPkgItem.Package.ROT_CODE = CurPosition.CurWipSNs.First().ROT_CODE; |
| | | CurPkgItem.Package.NODE_ID = CurPosition.CurWipSNs.First().NODE_ID; |
| | | CurPkgItem.Package.NODE_NAME = CurPosition.CurWipSNs.First().NODE_NAME; |
| | | CurPkgItem.Package.FTY_CODE = CurPosition.CurWipSNs.First().FTY_CODE; |
| | | CurPkgItem.Package.WS_CODE = CurPosition.CurWipSNs.First().WS_CODE; |
| | | CurPkgItem.Package.LINE_CODE = CurPosition.CurWipSNs.First().LINE_CODE; |
| | | CurPkgItem.Package.POST_CODE = CurPosition.CurWipSNs.First().POST_CODE; |
| | | CurPkgItem.Package.OPER_CODE = CurPosition.CurWipSNs.First().OPER_CODE; |
| | | CurPkgItem.Package.SEGMENT = CurPosition.CurWipSNs.First().SEGMENT; |
| | | FinishLevel++; |
| | | action = SavePkgData(input, action); |
| | | } |
| | |
| | | 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(); |
| | | } |
| | | } |
| | | //当前处理的包装层级已经处理完,继续往上保存 |
| | |
| | | //数据异常 |
| | | else |
| | | { |
| | | action.Data.ShortMsg = new("包装错误", ShortMessage.Types.Error); |
| | | var pdtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"客户端提交的包装层级[{pdtl.PKG_LEVEL}]({pdtl.PkgType.PKG_NAME})数据不是正在处理的包装层级[{dtl.PKG_LEVEL}]({dtl.PkgType.PKG_NAME}),工序已重置,请重新扫描进站产品条码"); |
| | |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | action.Data.ShortMsg = new("包装异常", ShortMessage.Types.Exception); |
| | | var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); |
| | | action.CatchExceptionWithLog(ex, $"包装行为:扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码[{input.SN}]后保存数据失败"); |
| | | action.IsSuccessed = false; |
| | |
| | | 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"; |
| | | data.PkgLevel = CurPkg.Item.PKG_LEVEL; |
| | | CurCmd = data; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("保存包装数据", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new($"第{CurPkg.Item.PKG_LEVEL}层包装[{CurPkg.Item.PKG_NAME}]已经全部完成,保存包装数据"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PackageComplete", CurPkg.Item.PKG_LEVEL, CurPkg.Item.PKG_NAME); |
| | | |
| | | //手动结束包装则标记行为完成 |
| | | if (CurStep.IsNullOrEmpty()) |
| | | { |
| | | IsFinished = true; |
| | | } |
| | | //if (CurStep.IsNullOrEmpty()) |
| | | //{ |
| | | // IsFinished = true; |
| | | //} |
| | | |
| | | return action; |
| | | } |
| | |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | //记录行为操作记录 |
| | | var wipAct = new MES_WIP_ACT() |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | | //不是手动结束包装则保存行为操作记录 |
| | | if (!CurStep.IsNullOrEmpty()) |
| | | { |
| | | 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}]包装完成", |
| | | }; |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | | { |
| | | var wipAct = new MES_WIP_ACT() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | WIP_ID = wipSn.ID, |
| | | 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, |
| | | 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, |
| | | 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(); |
| | | if (_wipActs.Any()) |
| | | { |
| | | 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.INNER_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.Data.ShortMsg = new("包装完成", ShortMessage.Types.Success); |
| | | action.LocaleMsg = new($"条码[{CurPkg.Item.Package.SN}]包装完成"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPkg.Item.Package.SN); |
| | | return action; |
| | | } |
| | | |