| | |
| | | public MES_WO_ACTION Setting { get; set; } |
| | | #endregion |
| | | public BAS_PKG_RULE PkgRule { get; set; } |
| | | public BAS_PKG_PROD PkgProd { get; set; } |
| | | public WipPkg CurPkg { get; set; } |
| | | public WipPkgItem CurPkgItem { get; set; } |
| | | public PackingActionOutput CurCmd { get; set; } |
| | |
| | | LabelPV = Biz.Db.Queryable<BAS_LABEL_PV>().ToList(); |
| | | //获取是否包装完后需要称重 |
| | | NeedWeighing = Setting.OPTION_2 == "Y"; |
| | | //获取包装规则的称重范围 |
| | | PkgProd = Biz.Db.Queryable<BAS_PKG_PROD>().Where(q => q.PKG_RULE_ID == PkgRule.ID && q.ITEM_CODE == CurPosition.WorkBatch.WO.ITEM_CODE).First(); |
| | | //如果工序上下文中没有包装记录则新建一个,有则获取当前的包装记录 |
| | | if (CurPosition.Context.ContainsKey("CurPackage") && !CurPosition.Context["CurPackage"].IsNullOrEmpty()) |
| | | { |
| | |
| | | data.PrintLable = LabelDic[min.PKG_LEVEL]; |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | CurStep.Message = Biz.L("打印标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | 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}]"); |
| | |
| | | if (!pInput.IsFinish || pInput.PkgSN.IsNullOrEmpty()) |
| | | { |
| | | var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); |
| | | CurStep.Message = Biz.L("扫描错误"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.ShortMsg = new("扫描错误", ShortMessage.Types.Error); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"条码扫描失败,请重新扫描第{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); |
| | | CurStep.Message = Biz.L("扫描错误"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.ShortMsg = new("扫描错误", ShortMessage.Types.Error); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"条码[{pInput.PkgSN}]无需重复扫描,请扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码"); |
| | |
| | | action = SavePkgData(input, action); |
| | | if (action.IsSuccessed) |
| | | { |
| | | CurStep.Message = Biz.L("扫描成功"); |
| | | CurStep.Status = StepStatus.Success; |
| | | action.Data.ShortMsg = new("扫描成功", ShortMessage.Types.Success); |
| | | } |
| | | } |
| | |
| | | data.ExecCode = "Scan"; |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | CurCmd = data; |
| | | CurStep.Message = Biz.L("扫描标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("扫描标签", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new($"请扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码"); |
| | |
| | | if (PrintTimes < 3 && !CurCmd.IsNullOrEmpty()) |
| | | { |
| | | PrintTimes++; |
| | | CurStep.Message = Biz.L("重新打印"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | 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}]"); |
| | |
| | | { |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | CurStep.Message = Biz.L("打印失败"); |
| | | CurStep.Status = StepStatus.Error; |
| | | 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}]失败,工序已重置,请重新扫描进站产品条码"); |
| | |
| | | { |
| | | if (!pInput.WeightInfo.IsNullOrEmpty() && pInput.WeightInfo.Weight > 0) |
| | | { |
| | | //验证重量数据是否符合设置好的重量范围 |
| | | if (!PkgProd.IsNullOrEmpty() && (pInput.WeightInfo.Weight < PkgProd.MIN_WEIGHT || PkgProd.MIN_WEIGHT < pInput.WeightInfo.Weight)) |
| | | { |
| | | action.IsSuccessed = false; |
| | | CurStep.Message = Biz.L("重量超限"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.Data = CurCmd; |
| | | action.Data.ShortMsg = new("重量超限", ShortMessage.Types.Failed); |
| | | //action.LocaleMsg = new($"外包装重量[{0}]超出产品[{1}]在包装规则[{2}]中的预设范围[{3} - {4}],请处理后重新上称称重"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PackageOverWeight", pInput.WeightInfo.Weight + pInput.WeightInfo.Unit.IsNullOrEmpty("", " " + pInput.WeightInfo.Unit), CurPosition.WorkBatch.WO.ITEM_CODE, PkgRule.RULE_NAME, PkgProd.MIN_WEIGHT + PkgProd.MIN_UNIT.IsNullOrEmpty("", " " + PkgProd.MIN_UNIT), PkgProd.MAX_WEIGHT + PkgProd.MAX_UNIT.IsNullOrEmpty("", " " + PkgProd.MAX_UNIT)); |
| | | return action; |
| | | } |
| | | |
| | | CurCmd = null; |
| | | PrintTimes = 0; |
| | | CurPkg.WeightInfo.Weight = pInput.WeightInfo.Weight; |
| | |
| | | //最外层包装已处理完成则直接结束行为 |
| | | if (CurPkg.Item.PKG_LEVEL == FinishLevel) |
| | | { |
| | | action = End(); |
| | | action = End(input); |
| | | } |
| | | //最外层包装未打印扫描则继续 |
| | | else |
| | |
| | | data.ExecCode = "Scan"; |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | CurCmd = data; |
| | | action.Data.Data = data; |
| | | CurStep.Message = Biz.L("扫描标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | 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); |
| | |
| | | data.PrintLable = LabelDic[dtl.PKG_LEVEL]; |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | action.Data.Data = data; |
| | | CurStep.Message = Biz.L("打印标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | 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; |
| | | CurStep.Message = Biz.L("称重失败"); |
| | | CurStep.Status = StepStatus.Error; |
| | | 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); |
| | | //action.LocaleMsg = new($"外包装称重数据异常,请重新上称称重"); |
| | | action.LocaleMsg = new("MES.WorkAction.PackingAction.PleaseWeighingAgain"); |
| | | return action; |
| | | } |
| | | } |
| | |
| | | data.ExecCode = "Weighing"; |
| | | data.PkgLevel = CurPkgItem.PKG_LEVEL; |
| | | CurCmd = data; |
| | | CurStep.Message = Biz.L("包装成功"); |
| | | CurStep.Status = StepStatus.Success; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("包装成功", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"请把包装[{CurPkgItem.Package.SN}]上称称重"); |
| | |
| | | } |
| | | else |
| | | { |
| | | action = End(); |
| | | action = End(input); |
| | | } |
| | | } |
| | | break; |
| | |
| | | data.ExecCode = "Scan"; |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | CurCmd = data; |
| | | CurStep.Message = Biz.L("扫描标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("扫描标签", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new($"请扫描第{dtl.PKG_LEVEL}层包装[{dtl.PkgType.PKG_NAME}]的标签条码"); |
| | |
| | | data.PrintLable = LabelDic[dtl.PKG_LEVEL]; |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | CurStep.Message = Biz.L("打印标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | 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}]"); |
| | |
| | | data.ExecCode = "Weighing"; |
| | | data.PkgLevel = CurPkgItem.PKG_LEVEL; |
| | | CurCmd = data; |
| | | CurStep.Message = Biz.L("上称称重"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("上称称重", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"请把外包装上称称重"); |
| | |
| | | data.ExecCode = "Scan"; |
| | | data.PkgLevel = dtl.PKG_LEVEL; |
| | | CurCmd = data; |
| | | action.Data.Data = data; |
| | | CurStep.Message = Biz.L("扫描标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | 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); |
| | |
| | | data.PrintLable = LabelDic[dtl.PKG_LEVEL]; |
| | | CurCmd = data; |
| | | PrintTimes++; |
| | | action.Data.Data = data; |
| | | CurStep.Message = Biz.L("打印标签"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | 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 = End(); |
| | | action = End(input); |
| | | } |
| | | } |
| | | //数据异常 |
| | | else |
| | | { |
| | | CurStep.Message = Biz.L("包装错误"); |
| | | CurStep.Status = StepStatus.Error; |
| | | action.Data.ShortMsg = new("包装错误", ShortMessage.Types.Error); |
| | | var pdtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); |
| | | action.IsSuccessed = false; |
| | |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | CurStep.Message = Biz.L("包装异常"); |
| | | CurStep.Status = StepStatus.Error; |
| | | 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}]后保存数据失败"); |
| | |
| | | data.ExecCode = "Complete"; |
| | | data.PkgLevel = CurPkg.Item.PKG_LEVEL; |
| | | CurCmd = data; |
| | | CurStep.Message = Biz.L("保存包装数据"); |
| | | CurStep.Status = StepStatus.Normal; |
| | | action.Data.Data = data; |
| | | action.Data.ShortMsg = new("保存包装数据", ShortMessage.Types.Normal); |
| | | //action.LocaleMsg = new($"第{CurPkg.Item.PKG_LEVEL}层包装[{CurPkg.Item.PKG_NAME}]已经全部完成,保存包装数据"); |
| | |
| | | /// 结束执行工序行为 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> End() |
| | | public ApiAction<SubmitOutput> End(SubmitInput input) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | |
| | | } |
| | | |
| | | IsFinished = true; |
| | | CurStep.Message = Biz.L("包装完成"); |
| | | CurStep.Status = StepStatus.Finished; |
| | | action.Data.ShortMsg = new("包装完成", ShortMessage.Types.Success); |
| | | |
| | | return action; |