| | |
| | | } |
| | | } |
| | | 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; |
| | | // Complete:完成,完成全部包装后结束行为 |
| | | case "Complete": |
| | | if (CurCmd.ExecCode == "Complete") |
| | | { |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | //打印后称重 |
| | | if (NeedWeighing) |
| | | { |
| | | var data = new PackingActionOutput() { PkgInfo = CurPkg }; |
| | |
| | | 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; |
| | |
| | | //添加明细后判断当前包装层级的明细数量是否等于包装数量,若相等则标记当前包装层级为完成并尝试打印标签 |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | //当前包装层级的明细数量未达到包装数量,则完成本次扫描,等待下个产品进站 |
| | |
| | | wipActs.Add(wipAct); |
| | | } |
| | | } |
| | | //记录外包装的称重数据 |
| | | CurPkg.Item.Package.WEIGHT = CurPkg.WeightInfo.Weight; |
| | | CurPkg.Item.Package.WEIGHT_UNIT = CurPkg.WeightInfo.Unit; |
| | | |
| | | //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值 |
| | | var _wipActs = wipActs.Clone(); |