| | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | action = SavePkgData(input, action); |
| | | if (action.IsSuccessed) |
| | | { |
| | | action.Data.ShortMsg = new("扫描成功", ShortMessage.Types.Success); |
| | | } |
| | | } |
| | | break; |
| | | //Print:打印,打印当前包装层级的标签 |
| | |
| | | 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); |
| | | CurPosition.ResetNode(); |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | // Weighing:称重,完成包装后对整个包装成称重 |
| | | case "Weighing": |
| | | if (CurCmd.ExecCode == "Weighing") |
| | | { |
| | | if (!pInput.WeightInfo.IsNullOrEmpty() && pInput.WeightInfo.Weight > 0) |
| | | { |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | CurPkg.WeightInfo.Weight = pInput.WeightInfo.Weight; |
| | | CurPkg.WeightInfo.Unit = pInput.WeightInfo.Unit; |
| | | NeedWeighing = false; |
| | | |
| | | //称重成功,继续行为 |
| | | var dtl = PkgRule.Details.FirstOrDefault(q => q.PKG_LEVEL == FinishLevel + 1); |
| | | //最外层包装已处理完成则直接结束行为 |
| | | if (CurPkg.Item.PKG_LEVEL == FinishLevel) |
| | | { |
| | | action = End(); |
| | | } |
| | | //最外层包装未打印扫描则继续 |
| | | else |
| | | { |
| | | //如果为空则不需要打印 |
| | | if (LabelDic[dtl.PKG_LEVEL].IsNullOrEmpty()) |
| | | { |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | | data.ExecCode = "Scan"; |
| | | 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); |
| | | } |
| | | else |
| | | { |
| | | //设置打印变量值 |
| | | LabelDic[dtl.PKG_LEVEL] = CurPosition.SetLabelVariables(LabelPV, LabelDic[dtl.PKG_LEVEL]); |
| | | |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | | data.ExecCode = "Print"; |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | data.PrintLable = LabelDic[dtl.PKG_LEVEL]; |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | action.Data.Data = data; |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.Data.Data = CurCmd; |
| | | 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; |
| | |
| | | { |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | //打印后称重 |
| | | if (NeedWeighing) |
| | | { |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | |
| | | 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.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); |
| | | } |
| | |
| | | //添加明细后判断当前包装层级的明细数量是否等于包装数量,若相等则标记当前包装层级为完成并尝试打印标签 |
| | | if (CurPkgItem.Items.Count(q => q.IsFinished) == CurPkgItem.PKG_QTY || CurStep.IsNullOrEmpty()) |
| | | { |
| | | //行为设定的OPTION_1-9是包装不同层级的标签模板代码,如果为空则不需要打印 |
| | | if (LabelDic[dtl.PKG_LEVEL].IsNullOrEmpty()) |
| | | //打印前称重:如果当前的包装明细的上一层包装对象是最外层包装且需要称重时,先称重,合格后在发印或者扫描最外层包装标签 |
| | | if (CurPkgItem.PKG_LEVEL == CurPkg.Item.PKG_LEVEL && NeedWeighing) |
| | | { |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | | data.ExecCode = "Scan"; |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | data.ExecCode = "Weighing"; |
| | | data.PkgLevel = CurPkgItem.PKG_LEVEL; |
| | | CurCmd = data; |
| | | action.Data.Data = data; |
| | | //action.LocaleMsg = new($"请扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseScanLabel", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); |
| | | } |
| | | action.Data.ShortMsg = new("上称称重", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"请把外包装上称称重"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighing"); |
| | | } |
| | | else |
| | | { |
| | | //设置打印变量值 |
| | | LabelDic[dtl.PKG_LEVEL] = CurPosition.SetLabelVariables(LabelPV, LabelDic[dtl.PKG_LEVEL]); |
| | | |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | | data.ExecCode = "Print"; |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | data.PrintLable = LabelDic[dtl.PKG_LEVEL]; |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | action.Data.Data = data; |
| | | //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); |
| | | //如果为空则不需要打印 |
| | | if (LabelDic[dtl.PKG_LEVEL].IsNullOrEmpty()) |
| | | { |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | | data.ExecCode = "Scan"; |
| | | 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); |
| | | } |
| | | else |
| | | { |
| | | //设置打印变量值 |
| | | LabelDic[dtl.PKG_LEVEL] = CurPosition.SetLabelVariables(LabelPV, LabelDic[dtl.PKG_LEVEL]); |
| | | |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | | data.ExecCode = "Print"; |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | data.PrintLable = LabelDic[dtl.PKG_LEVEL]; |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | action.Data.Data = data; |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | //当前包装层级的明细数量未达到包装数量,则完成本次扫描,等待下个产品进站 |
| | |
| | | //数据异常 |
| | | 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; |
| | |
| | | |
| | | private List<MES_WIP_PKG> GetPackageList(WipPkgItem parent) |
| | | { |
| | | List<MES_WIP_PKG> list = new() { parent.Package }; |
| | | List<MES_WIP_PKG> list = new(); |
| | | if (!parent.Package.IsNullOrEmpty()) |
| | | { |
| | | list.Add(parent.Package); |
| | | } |
| | | foreach (var item in parent.Items) |
| | | { |
| | | item.Package.PARENT_SN = parent.Package.SN; |
| | | item.Package.PARENT_SN = parent.Package?.SN; |
| | | list.AddRange(GetPackageList(item)); |
| | | } |
| | | return list; |
| | |
| | | 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); |
| | | |
| | |
| | | wipActs.Add(wipAct); |
| | | } |
| | | } |
| | | //记录外包装的称重数据 |
| | | CurPkg.Item.Package.WEIGHT = CurPkg.WeightInfo.Weight; |
| | | CurPkg.Item.Package.WEIGHT_UNIT = CurPkg.WeightInfo.Unit; |
| | | |
| | | //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值 |
| | | var _wipActs = wipActs.Clone(); |
| | |
| | | } |
| | | if (_pkgList.Any()) |
| | | { |
| | | db.Insertable(_pkgList, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_pkgList, CurPosition.UserCode).ExecuteCommand(); |
| | | foreach (var pkg in _pkgList) |
| | | { |
| | | //包装信息保存到在制品信息表 |
| | |
| | | CurPosition.NeedTemporaryStoreDBCommitAction = false; |
| | | //删除工序上下文中的包装记录 |
| | | CurPosition.Context.Remove("CurPackage"); |
| | | //action.LocaleMsg = new($"条码[{CurPkg.Item.Package?.SN}]包装完成"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPkg.Item.Package.SN); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | CurPosition.Context.Add("CurPackage", CurPkg); |
| | | } |
| | | //action.LocaleMsg = new($"条码[{CurPosition.CurSN}]包装完成"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurSN); |
| | | } |
| | | |
| | | IsFinished = true; |
| | | action.LocaleMsg = new($"产品条码[{CurPosition.CurSN}]包装完成"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PackingSuccess", CurPosition.CurSN); |
| | | action.Data.ShortMsg = new("包装完成", ShortMessage.Types.Success); |
| | | |
| | | return action; |
| | | } |
| | | |