| | |
| | | using System.Threading.Tasks; |
| | | using Tiger.Model; |
| | | using Tiger.Model.Entitys.MES.Position; |
| | | using static System.Net.Mime.MediaTypeNames; |
| | | |
| | | namespace Tiger.Business.MES.Transaction |
| | | { |
| | |
| | | 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 && q.ACT_LINE == CurLine.LINE_CODE && (q.STATUS == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue() || q.STATUS == BIZ_MES_WO_BATCH.STATUSs.Working.GetValue())) |
| | | .Select((q, s) => new { Batch = q, SN = s }).First(); |
| | | .ByAuth(input.AuthOption).Where((q, s) => s.SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).First(); |
| | | |
| | | //查找到条码已绑定的工单 |
| | | if (!wosn.IsNullOrEmpty()) |
| | | { |
| | | if (CurBatch?.Batch?.ORDER_NO != wosn.Batch.ORDER_NO) |
| | | if (wosn.Batch.ACT_LINE != CurLine.LINE_CODE) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosn.Batch.ORDER_NO }); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.IsSuccessed = result.IsSuccessed; |
| | | action.LocaleMsg = result.LocaleMsg; |
| | | return action; |
| | | } |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"条码[{0}]已在产线[{1}]投入生产,请在正确岗位扫描"); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotCorrectLine", input.SN, wosn.Batch.ACT_LINE); |
| | | return action; |
| | | } |
| | | //条码过站 |
| | | action = NodeSubmit(action, input); |
| | | return action; |
| | | else |
| | | { |
| | | if (CurBatch?.Batch?.ORDER_NO != wosn.Batch.ORDER_NO) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosn.Batch.ORDER_NO }); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.IsSuccessed = result.IsSuccessed; |
| | | action.LocaleMsg = result.LocaleMsg; |
| | | return action; |
| | | } |
| | | } |
| | | //条码过站 |
| | | action = NodeSubmit(action, input); |
| | | return action; |
| | | } |
| | | } |
| | | //查找不到条码已绑定的工单 |
| | | else |
| | |
| | | try |
| | | { |
| | | var curNode = CurBatch.GetNode(PostCode); |
| | | //判断工单实时状态判断 |
| | | var woStatus = CurBatch.CheckStatus(); |
| | | //判断工单实时状态判断是否可以生产 |
| | | var woStatus = CurBatch.CheckCanProduce(curNode); |
| | | if (!woStatus.IsSuccessed) |
| | | { |
| | | return woStatus; |
| | |
| | | db.Storageable(woSN, UserCode).ExecuteCommand(); |
| | | db.Storageable(wipSN, UserCode).ExecuteCommand(); |
| | | db.Storageable(CurWipSNHis, 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(); |
| | | } |
| | | //如果是产出站 |
| | | 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(); |
| | | } |
| | | } |
| | | }; |
| | | Steps.Add(curStep); |
| | |
| | | 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 && q.ACT_LINE == CurLine.LINE_CODE && (q.STATUS == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue() || q.STATUS == BIZ_MES_WO_BATCH.STATUSs.Working.GetValue())) |
| | | .Select((q, s) => new { Batch = q, SN = s }).First(); |
| | | .ByAuth(input.AuthOption).Where((q, s) => s.SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).First(); |
| | | |
| | | //查找到条码已绑定的工单 |
| | | if (!wosn.IsNullOrEmpty()) |
| | | { |
| | | if (CurBatch?.Batch?.ORDER_NO != wosn.Batch.ORDER_NO) |
| | | if (wosn.Batch.ACT_LINE != CurLine.LINE_CODE) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosn.Batch.ORDER_NO }); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.IsSuccessed = result.IsSuccessed; |
| | | action.LocaleMsg = result.LocaleMsg; |
| | | return action; |
| | | } |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"条码[{0}]已在产线[{1}]投入生产,请在正确岗位扫描"); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotCorrectLine", input.SN, wosn.Batch.ACT_LINE); |
| | | return action; |
| | | } |
| | | else |
| | | { |
| | | if (CurBatch?.Batch?.ORDER_NO != wosn.Batch.ORDER_NO) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosn.Batch.ORDER_NO }); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.IsSuccessed = result.IsSuccessed; |
| | | action.LocaleMsg = result.LocaleMsg; |
| | | return action; |
| | | } |
| | | } |
| | | //条码过站 |
| | | action = NodeSubmit(action, input); |
| | | return action; |
| | | } |
| | | //条码过站 |
| | | action = NodeSubmit(action, input); |
| | | return action; |
| | | } |
| | | //查找不到条码已绑定的工单 |
| | | else |
| | |
| | | try |
| | | { |
| | | var curNode = CurBatch.GetNode(PostCode); |
| | | //判断工单实时状态判断 |
| | | var woStatus = CurBatch.CheckStatus(); |
| | | //判断工单实时状态判断是否可以生产 |
| | | var woStatus = CurBatch.CheckCanProduce(curNode); |
| | | if (!woStatus.IsSuccessed) |
| | | { |
| | | return woStatus; |
| | |
| | | db.Storageable(woSN, UserCode).ExecuteCommand(); |
| | | db.Storageable(wipSN, UserCode).ExecuteCommand(); |
| | | db.Storageable(CurWipSNHis, 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(); |
| | | } |
| | | //如果是产出站 |
| | | 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(); |
| | | } |
| | | } |
| | | }; |
| | | Steps.Add(curStep); |
| | | |
| | |
| | | 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 && q.ACT_LINE == CurLine.LINE_CODE && (q.STATUS == BIZ_MES_WO_BATCH.STATUSs.Release.GetValue() || q.STATUS == BIZ_MES_WO_BATCH.STATUSs.Working.GetValue())) |
| | | .Select((q, s) => new { Batch = q, SN = s }).First(); |
| | | .ByAuth(input.AuthOption).Where((q, s) => s.SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).First(); |
| | | |
| | | //查找到条码已绑定的工单 |
| | | if (!wosn.IsNullOrEmpty()) |
| | | { |
| | | if (CurBatch?.Batch?.ORDER_NO != wosn.Batch.ORDER_NO) |
| | | if (wosn.Batch.ACT_LINE != CurLine.LINE_CODE) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosn.Batch.ORDER_NO }); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.IsSuccessed = result.IsSuccessed; |
| | | action.LocaleMsg = result.LocaleMsg; |
| | | return action; |
| | | } |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"条码[{0}]已在产线[{1}]投入生产,请在正确岗位扫描"); |
| | | action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotCorrectLine", input.SN, wosn.Batch.ACT_LINE); |
| | | return action; |
| | | } |
| | | //条码过站 |
| | | action = NodeSubmit(action, input); |
| | | return action; |
| | | else |
| | | { |
| | | if (CurBatch?.Batch?.ORDER_NO != wosn.Batch.ORDER_NO) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosn.Batch.ORDER_NO }); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.IsSuccessed = result.IsSuccessed; |
| | | action.LocaleMsg = result.LocaleMsg; |
| | | return action; |
| | | } |
| | | } |
| | | //条码过站 |
| | | action = NodeSubmit(action, input); |
| | | return action; |
| | | } |
| | | } |
| | | //查找不到条码已绑定的工单 |
| | | else |
| | |
| | | try |
| | | { |
| | | var curNode = CurBatch.GetNode(PostCode); |
| | | //判断工单实时状态判断 |
| | | var woStatus = CurBatch.CheckStatus(); |
| | | //判断工单实时状态判断是否可以生产 |
| | | var woStatus = CurBatch.CheckCanProduce(curNode); |
| | | if (!woStatus.IsSuccessed) |
| | | { |
| | | return woStatus; |
| | |
| | | db.Storageable(woSN, UserCode).ExecuteCommand(); |
| | | db.Storageable(wipSN, UserCode).ExecuteCommand(); |
| | | db.Storageable(CurWipSNHis, 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(); |
| | | } |
| | | //如果是产出站 |
| | | 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(); |
| | | } |
| | | } |
| | | }; |
| | | Steps.Add(curStep); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检查工单实时状态,判断可以生产:工单跟批次状态不是已下发或者生产中,则不允许生产 |
| | | /// 检查工单在当前工序节点是否可以生产 |
| | | /// </summary> |
| | | /// <param name="curNode"></param> |
| | | /// <returns></returns> |
| | | public ApiAction<SubmitOutput> CheckStatus() |
| | | public ApiAction<SubmitOutput> CheckCanProduce(MES_WO_NODE curNode) |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput(), true); |
| | | |
| | |
| | | //action.LocaleMsg = new($"工单[{WO.ORDER_NO}]状态[{Batch.STATUS.GetEnum<BIZ_MES_WO.STATUSs>().GetName()}]不是允许生产的状态,请扫描允许生产的产品条码"); |
| | | action.LocaleMsg = new("MES.WorkBatch.WoStatusCanNotWork", WO.ORDER_NO, Batch.STATUS.GetEnum<BIZ_MES_WO.STATUSs>().GetName()); |
| | | } |
| | | //工单批次投入数量减去报废数量如果大于等于计划数量,则不允许生产 |
| | | if (curNode.IS_INPUT == "Y" && Batch.INPUT_QTY - Batch.SCRAP_QTY >= Batch.PLAN_QTY) |
| | | { |
| | | action.IsSuccessed = false; |
| | | action.Data.SetValue(this, null); |
| | | action.LocaleMsg = new($"工单批次[{0}]已投入 {1},其中报废 {2},以满足计划数量[{3}],无需继续投入"); |
| | | action.LocaleMsg = new("MES.WorkBatch.WoInputEnough", Batch.BATCH_NO, Batch.INPUT_QTY, Batch.SCRAP_QTY, Batch.PLAN_QTY); |
| | | } |
| | | |
| | | return action; |
| | | } |