| | |
| | | //当前岗位在当前工单不是首站,则查找条码已绑定的工单当作当前工单 |
| | | else |
| | | { |
| | | var wosn = Biz.Db.Queryable<BIZ_MES_WO_BATCH, BIZ_MES_WO_SN>((q, s) => new JoinQueryInfos(JoinType.Inner, q.ORDER_NO == s.WORK_ORDER)) |
| | | .ByAuth(input.AuthOption).Where((q, s) => s.SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).First(); |
| | | var wosns = Biz.Db.Queryable<BIZ_MES_WO_BATCH, BIZ_MES_WO_SN>((q, s) => new JoinQueryInfos(JoinType.Inner, q.ORDER_NO == s.WORK_ORDER)) |
| | | .ByAuth(input.AuthOption).Where((q, s) => s.SN == input.SN || s.TRAY_SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).ToList(); |
| | | |
| | | //查找到条码已绑定的工单 |
| | | if (!wosn.IsNullOrEmpty()) |
| | | if (!wosns.IsNullOrEmpty()) |
| | | { |
| | | if (wosn.Batch.ACT_LINE != CurLine.LINE_CODE) |
| | | if (wosns.Count > 1 && wosns.Any(q => q.SN.TRAY_SN != q.SN.OUTER_SN)) |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.LocaleMsg = new($"条码[{0}]是载具条码,请扫描载具中的产品条码继续包装操作"); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.OnlyMinPackage", input.SN); |
| | | return action; |
| | | } |
| | | if (wosns.First().Batch.ACT_LINE != CurLine.LINE_CODE) |
| | | { |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"条码[{0}]已在产线[{1}]投入生产,请在正确岗位扫描"); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotCorrectLine", input.SN, wosn.Batch.ACT_LINE); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotCorrectLine", input.SN, wosns.First().Batch.ACT_LINE); |
| | | return action; |
| | | } |
| | | else |
| | | { |
| | | if (CurBatch?.Batch?.ORDER_NO != wosn.Batch.ORDER_NO) |
| | | if (CurBatch?.Batch?.ORDER_NO != wosns.First().Batch.ORDER_NO) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosn.Batch.ORDER_NO }); |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosns.First().Batch.ORDER_NO }); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.IsSuccessed = result.IsSuccessed; |
| | |
| | | return woStatus; |
| | | } |
| | | //非法过站防呆:进入工序时要增加判断条码是否按流程过站 |
| | | var wipSN = Biz.Db.Queryable<MES_WIP_DATA>().IncludesAllFirstLayer().First(q => q.SN == input.SN && q.WORK_ORDER == CurBatch.WO.ORDER_NO) ?? new MES_WIP_DATA() |
| | | var wipSNs = Biz.Db.Queryable<MES_WIP_DATA>().IncludesAllFirstLayer().Where(q => (q.SN == input.SN || q.TRAY_SN == input.SN) && q.WORK_ORDER == CurBatch.WO.ORDER_NO).ToList(); |
| | | if (wipSNs.IsNullOrEmpty()) |
| | | { |
| | | SN = input.SN, |
| | | STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(), |
| | | ITEM_CODE = CurBatch.WO.ITEM_CODE, |
| | | WORK_ORDER = CurBatch.Batch.ORDER_NO, |
| | | BATCH_NO = CurBatch.Batch.BATCH_NO, |
| | | HOLD_FLAG = "N", |
| | | REWORK_FLAG = CurBatch.WO.ORDER_TYPE == BIZ_MES_WO.ORDER_TYPEs.Rework.GetValue() ? "Y" : "N", |
| | | FINISHED_FLAG = "N", |
| | | INV_FLAG = "N", |
| | | DFT_FLAG = "N", |
| | | DFT_COUNT = 0, |
| | | }; |
| | | var canGotoNext = CurBatch.CanGotoNext(input, wipSN, curNode); |
| | | var wipSN = new MES_WIP_DATA() |
| | | { |
| | | SN = input.SN, |
| | | STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(), |
| | | ITEM_CODE = CurBatch.WO.ITEM_CODE, |
| | | WORK_ORDER = CurBatch.Batch.ORDER_NO, |
| | | BATCH_NO = CurBatch.Batch.BATCH_NO, |
| | | HOLD_FLAG = "N", |
| | | REWORK_FLAG = CurBatch.WO.ORDER_TYPE == BIZ_MES_WO.ORDER_TYPEs.Rework.GetValue() ? "Y" : "N", |
| | | FINISHED_FLAG = "N", |
| | | INV_FLAG = "N", |
| | | DFT_FLAG = "N", |
| | | DFT_COUNT = 0, |
| | | }; |
| | | wipSNs.Add(wipSN); |
| | | } |
| | | var canGotoNext = CurBatch.CanGotoNext(input, wipSNs.First(), curNode); |
| | | if (!canGotoNext.IsSuccessed) |
| | | { |
| | | return canGotoNext; |
| | |
| | | if (Steps.IsNullOrEmpty()) |
| | | { |
| | | //绑定条码到工单 |
| | | if (!CurBatch.WoSNs.Any(q => q.SN == input.SN)) |
| | | { |
| | | CurBatch.WoSNs.Add(new() |
| | | { |
| | | WORK_ORDER = CurBatch.Batch.ORDER_NO, |
| | | SN = input.SN, |
| | | STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(), |
| | | }); |
| | | } |
| | | var woSN = CurBatch.WoSNs.First(q => q.SN == input.SN); |
| | | woSN.AUTH_ORG = CurBatch.WO.AUTH_ORG; |
| | | woSN.AUTH_PROD = CurLine.LINE_CODE; |
| | | woSN.BATCH_NO = CurBatch.Batch.BATCH_NO; |
| | | |
| | | //条码过站 |
| | | wipSN.AUTH_ORG = CurBatch.WO.AUTH_ORG; |
| | | wipSN.AUTH_PROD = CurLine.LINE_CODE; |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.OK.GetValue();//wipSN.STATUS > 0 ? MES_WIP_DATA.STATUSs.OK.GetValue() : wipSN.STATUS; |
| | | wipSN.ROT_CODE = CurBatch.WO.ROUTE_CODE; |
| | | wipSN.NODE_ID = curNode.ID; |
| | | wipSN.NODE_NAME = curNode.NODE_NAME; |
| | | wipSN.FTY_CODE = CurFactory.FTY_CODE; |
| | | wipSN.WS_CODE = CurWorkshop.WS_CODE; |
| | | wipSN.LINE_CODE = CurLine.LINE_CODE; |
| | | wipSN.POST_CODE = CurPosition.POST_CODE; |
| | | wipSN.OPER_CODE = curNode.OPER_CODE; |
| | | wipSN.SEGMENT = curNode.SEGMENT; |
| | | wipSN.OPERATION_TIME = DateTime.Now; |
| | | var curShiftPeriod = GetShiftPeriodForNow(); |
| | | if (!curShiftPeriod.IsNullOrEmpty()) |
| | | foreach (var wipSN in wipSNs) |
| | | { |
| | | wipSN.SFTS_CODE = curShiftPeriod.ShiftSys.SFTS_CODE; |
| | | wipSN.SFT_CODE = curShiftPeriod.Shift.SFT_CODE; |
| | | wipSN.PRD_CODE = curShiftPeriod.Period.PRD_CODE; |
| | | if (!CurBatch.WoSNs.Any(q => q.SN == wipSN.SN)) |
| | | { |
| | | CurBatch.WoSNs.Add(new() |
| | | { |
| | | WORK_ORDER = CurBatch.Batch.ORDER_NO, |
| | | SN = wipSN.SN, |
| | | TRAY_SN = wipSN.TRAY_SN, |
| | | STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(), |
| | | }); |
| | | } |
| | | } |
| | | CurBatch.StartWorking(UserCode); |
| | | |
| | | //如果是投入站 |
| | | if (curNode.IS_INPUT == "Y") |
| | | { |
| | | woSN.STATUS = BIZ_MES_WO_SN.STATUSs.Inputed.GetValue(); |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.Input.GetValue(); |
| | | wipSN.INLINE_DATE = DateTime.Now; |
| | | } |
| | | //如果是产出站 |
| | | if (curNode.IS_OUTPUT == "Y") |
| | | { |
| | | woSN.STATUS = BIZ_MES_WO_SN.STATUSs.Finished.GetValue(); |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.Finished.GetValue(); |
| | | wipSN.OUTLINE_DATE = DateTime.Now; |
| | | } |
| | | //如果有提交不良 |
| | | if (!input.DFT_CODE.IsNullOrEmpty()) |
| | | { |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.NG.GetValue(); |
| | | wipSN.DFT_FLAG = "Y"; |
| | | wipSN.DFT_COUNT++; |
| | | wipSN.DFT_CODE = input.DFT_CODE; |
| | | } |
| | | |
| | | CurWipSNHis = new MES_WIP_HIS(CurWipSN = wipSN, $"工单[{wipSN.WORK_ORDER}]的条码[{wipSN.SN}]在岗位[{wipSN.POST_CODE}]工序[{wipSN.NODE_NAME}]过站成功,状态[{wipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]"); |
| | | |
| | | //初始化工步列表 |
| | | Steps.Clear(); |
| | | |
| | | //更新工单条码明细信息 |
| | | var woSNs = CurBatch.WoSNs.Where(q => wipSNs.Any(w => q.SN == w.SN)).ToList(); |
| | | foreach (var woSN in woSNs) |
| | | { |
| | | woSN.AUTH_ORG = CurBatch.WO.AUTH_ORG; |
| | | woSN.AUTH_PROD = CurLine.LINE_CODE; |
| | | woSN.BATCH_NO = CurBatch.Batch.BATCH_NO; |
| | | } |
| | | |
| | | //条码过站 |
| | | foreach (var wipSN in wipSNs) |
| | | { |
| | | wipSN.AUTH_ORG = CurBatch.WO.AUTH_ORG; |
| | | wipSN.AUTH_PROD = CurLine.LINE_CODE; |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.OK.GetValue();//wipSN.STATUS > 0 ? MES_WIP_DATA.STATUSs.OK.GetValue() : wipSN.STATUS; |
| | | wipSN.ROT_CODE = CurBatch.WO.ROUTE_CODE; |
| | | wipSN.NODE_ID = curNode.ID; |
| | | wipSN.NODE_NAME = curNode.NODE_NAME; |
| | | wipSN.FTY_CODE = CurFactory.FTY_CODE; |
| | | wipSN.WS_CODE = CurWorkshop.WS_CODE; |
| | | wipSN.LINE_CODE = CurLine.LINE_CODE; |
| | | wipSN.POST_CODE = CurPosition.POST_CODE; |
| | | wipSN.OPER_CODE = curNode.OPER_CODE; |
| | | wipSN.SEGMENT = curNode.SEGMENT; |
| | | wipSN.OPERATION_TIME = DateTime.Now; |
| | | var curShiftPeriod = GetShiftPeriodForNow(); |
| | | if (!curShiftPeriod.IsNullOrEmpty()) |
| | | { |
| | | wipSN.SFTS_CODE = curShiftPeriod.ShiftSys.SFTS_CODE; |
| | | wipSN.SFT_CODE = curShiftPeriod.Shift.SFT_CODE; |
| | | wipSN.PRD_CODE = curShiftPeriod.Period.PRD_CODE; |
| | | } |
| | | //如果是投入站 |
| | | if (curNode.IS_INPUT == "Y") |
| | | { |
| | | var woSN = woSNs.First(q => q.SN == wipSN.SN); |
| | | woSN.STATUS = BIZ_MES_WO_SN.STATUSs.Inputed.GetValue(); |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.Input.GetValue(); |
| | | wipSN.INLINE_DATE = DateTime.Now; |
| | | } |
| | | //如果是产出站 |
| | | if (curNode.IS_OUTPUT == "Y") |
| | | { |
| | | var woSN = woSNs.First(q => q.SN == wipSN.SN); |
| | | woSN.STATUS = BIZ_MES_WO_SN.STATUSs.Finished.GetValue(); |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.Finished.GetValue(); |
| | | wipSN.OUTLINE_DATE = DateTime.Now; |
| | | } |
| | | //如果有提交不良 |
| | | if (!input.DFT_CODE.IsNullOrEmpty()) |
| | | { |
| | | wipSN.STATUS = MES_WIP_DATA.STATUSs.NG.GetValue(); |
| | | wipSN.DFT_FLAG = "Y"; |
| | | wipSN.DFT_COUNT++; |
| | | wipSN.DFT_CODE = input.DFT_CODE; |
| | | } |
| | | } |
| | | |
| | | //工单开工 |
| | | CurBatch.StartWorking(UserCode); |
| | | |
| | | //把当前条码增加到当前条码列表 |
| | | CurWipSNs = wipSNs; |
| | | CurWipSNHiss.Clear(); |
| | | foreach (var wipSN in wipSNs) |
| | | { |
| | | CurWipSNHiss.Add(new MES_WIP_HIS(wipSN, $"工单[{wipSN.WORK_ORDER}]条码[{wipSN.SN}]在岗位[{wipSN.POST_CODE}]过站工序[{wipSN.NODE_NAME}]成功")); |
| | | } |
| | | |
| | | //初始化工步列表 |
| | | Steps.Clear(); |
| | | var curStep = new Biz.WorkStep(IWorkStep.Types.Node, this) |
| | | { |
| | | Sequence = Steps.Count + 1, |
| | |
| | | DBSubmitAction = () => |
| | | { |
| | | var db = GetCommitDB(); |
| | | db.Storageable(woSN, UserCode).ExecuteCommand(); |
| | | db.Storageable(wipSN, UserCode).ExecuteCommand(); |
| | | db.Storageable(CurWipSNHis, UserCode).ExecuteCommand(); |
| | | db.Storageable(woSNs, UserCode).ExecuteCommand(); |
| | | db.Storageable(wipSNs, UserCode).ExecuteCommand(); |
| | | db.Storageable(CurWipSNHiss, UserCode).ExecuteCommand(); |
| | | //如果是投入站 |
| | | if (curNode.IS_INPUT == "Y") |
| | | { |
| | | db.Updateable<BIZ_MES_WO>().SetColumns(q => q.INPUT_QTY == q.INPUT_QTY + 1).Where(q => q.ORDER_NO == CurBatch.WO.ORDER_NO).ExecuteCommand(); |
| | | db.Updateable<BIZ_MES_WO_BATCH>().SetColumns(q => q.INPUT_QTY == q.INPUT_QTY + 1).Where(q => q.BATCH_NO == CurBatch.Batch.BATCH_NO).ExecuteCommand(); |
| | | db.Updateable<BIZ_MES_WO>().SetColumns(q => q.INPUT_QTY == q.INPUT_QTY + wipSNs.Count).Where(q => q.ORDER_NO == CurBatch.WO.ORDER_NO).ExecuteCommand(); |
| | | db.Updateable<BIZ_MES_WO_BATCH>().SetColumns(q => q.INPUT_QTY == q.INPUT_QTY + wipSNs.Count).Where(q => q.BATCH_NO == CurBatch.Batch.BATCH_NO).ExecuteCommand(); |
| | | } |
| | | //如果是产出站 |
| | | if (curNode.IS_OUTPUT == "Y") |
| | | { |
| | | db.Updateable<BIZ_MES_WO>().SetColumns(q => q.OUTPUT_QTY == q.OUTPUT_QTY + 1).Where(q => q.ORDER_NO == CurBatch.WO.ORDER_NO).ExecuteCommand(); |
| | | db.Updateable<BIZ_MES_WO_BATCH>().SetColumns(q => q.OUTPUT_QTY == q.OUTPUT_QTY + 1).Where(q => q.BATCH_NO == CurBatch.Batch.BATCH_NO).ExecuteCommand(); |
| | | db.Updateable<BIZ_MES_WO>().SetColumns(q => q.OUTPUT_QTY == q.OUTPUT_QTY + wipSNs.Count).Where(q => q.ORDER_NO == CurBatch.WO.ORDER_NO).ExecuteCommand(); |
| | | db.Updateable<BIZ_MES_WO_BATCH>().SetColumns(q => q.OUTPUT_QTY == q.OUTPUT_QTY + wipSNs.Count).Where(q => q.BATCH_NO == CurBatch.Batch.BATCH_NO).ExecuteCommand(); |
| | | } |
| | | } |
| | | }; |
| | |
| | | SaveStepsCommitActionToDB(); |
| | | |
| | | //保存成功,返回过站消息 |
| | | //action.LocaleMsg = new($"工单[{CurWipSN.WORK_ORDER}]的条码[{CurWipSN.SN}]在岗位[{CurWipSN.POST_CODE}]工序[{CurWipSN.NODE_NAME}]过站成功,状态[{CurWipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]", CurWipSN.WORK_ORDER, CurWipSN.SN, CurWipSN.POST_CODE, CurWipSN.NODE_NAME, CurWipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.ScanSn.PassSuccess", CurWipSN.WORK_ORDER, CurWipSN.SN, CurWipSN.POST_CODE, CurWipSN.NODE_NAME, CurWipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()); |
| | | //action.LocaleMsg = new($"工单[{CurWipSN.WORK_ORDER}]的条码[{CurWipSN.SN}]在岗位[{CurWipSN.POST_CODE}]工序[{CurWipSN.NODE_NAME}]过站成功,状态[{CurWipSN.STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()}]"); |
| | | action.LocaleMsg = new("MES.Transaction.CollectNode.ScanSn.PassSuccess", CurWipSNs.First().WORK_ORDER, CurSN, CurWipSNs.First().POST_CODE, CurWipSNs.First().NODE_NAME,CurWipSNs.First().STATUS.GetEnumDesc<MES_WIP_DATA.STATUSs>()); |
| | | //重置工序 |
| | | ResetNode(); |
| | | return action; |
| | |
| | | case "NodeSubmit": |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"正在进行条码[{CurWipSN.SN}]的过站业务,不允许手动结束包装"); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.WorkingOnNodeSubmit", CurWipSN.SN); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.WorkingOnNodeSubmit", CurSN); |
| | | break; |
| | | default: |
| | | break; |