服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-08-16 eec9f268552af1d0ce8c95312930770669f1cc18
Tiger.Business.MES/Transaction/TestNode.cs
@@ -38,6 +38,7 @@
        public async Task<ApiAction<SubmitOutput>> Submit(SubmitInput input)
        {
            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
            try
            {
                //工步列表为空或者工序节点工步有未完成时,优先完成工序节点工步
@@ -47,7 +48,10 @@
                    if (!CurBatch.IsNullOrEmpty() && CurBatch.IsFirstNode(PostCode))
                    {
                        action = NodeSubmit(action, input);
                        return action;
                        //更新工序信息
                        var info = WoContext.GetSnOperInfo(input.SN).Data;
                        info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                        action.Data.OperInfo = info;
                    }
                    //当前岗位在当前工单不是首站,则查找条码已绑定的工单当作当前工单
                    else
@@ -60,10 +64,11 @@
                        {
                            if (wosns.First().Batch.ACT_LINE != CurLine.LINE_CODE)
                            {
                                action.Data.ShortMsg = new("产线错误", ShortMessage.Types.Error);
                                action.Data.OperInfo = new();
                                action.IsSuccessed = false;
                                //action.LocaleMsg = new($"条码[{0}]已在产线[{1}]投入生产,请在正确岗位扫描");
                                action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.NotCorrectLine", input.SN, wosns.First().Batch.ACT_LINE);
                                return action;
                            }
                            else
                            {
@@ -73,6 +78,8 @@
                                    var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosns.First().Batch.ORDER_NO });
                                    if (!result.IsSuccessed)
                                    {
                                        action.Data.ShortMsg = new("工单异常", ShortMessage.Types.Error);
                                        action.Data.OperInfo = new();
                                        action.IsSuccessed = result.IsSuccessed;
                                        action.LocaleMsg = result.LocaleMsg;
                                        return action;
@@ -80,7 +87,7 @@
                                }
                                //条码过站
                                action = NodeSubmit(action, input);
                                return action;
                                action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO]);
                            }
                        }
                        //查找不到条码已绑定的工单
@@ -89,31 +96,32 @@
                            //没有当前工单,则先选择工单后再扫描条码
                            if (CurBatch.IsNullOrEmpty())
                            {
                                action.Data.ShortMsg = new("未选择工单", ShortMessage.Types.Error);
                                action.Data.OperInfo = new();
                                action.IsSuccessed = false;
                                //action.LocaleMsg = new($"未选择工单,请先选择要生产的工单");
                                action.LocaleMsg = new("MES.Transaction.TestNode.Submit.NotSelectOrderException");
                                return action;
                            }
                            //有当前工单且不是投入,则提示条码未投入生产,请先去首站扫描
                            else
                            {
                                action.Data.ShortMsg = new("未投入生产", ShortMessage.Types.Error);
                                action.Data.OperInfo = new();
                                action.IsSuccessed = false;
                                //action.LocaleMsg = new($"条码[{input.SN}]尚未投入生产,请先去首站扫描", input.SN);
                                action.LocaleMsg = new("MES.Transaction.TestNode.Submit.NotInputException", input.SN);
                                return action;
                            }
                        }
                    }
                }
                //完成第一步,后开始执行当前工序的行为列表
                //完成工序节点工步后,后开始执行当前工序的行为工步
                //完成工序节点工步后,开始执行当前工序的行为工步
                else if (IsFinishNodeSteps && !IsFinishAllSteps)
                {
                    var submitStep = Steps.Where(q => q.ID == input.CurStepID && !q.IsFinished).FirstOrDefault();
                    if (submitStep.IsNullOrEmpty())
                    {
                        action = BeginNextActionStep(input);
                        return action;
                        action.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                    }
                    else
                    {
@@ -139,19 +147,27 @@
                        //如果所有工步都完成
                        if (IsFinishAllSteps)
                        {
                            return DoIfFinishAllSteps(result);
                            result = DoIfFinishAllSteps(result);
                        }
                        result.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                        return result;
                    }
                }
                //没有可执行的工步
                ResetNode();
                action.IsSuccessed = false;
                //action.LocaleMsg = new($"岗位[{CurPosition.POST_CODE}]工步执行异常,请重新扫描产品条码", CurPosition.POST_CODE);
                action.LocaleMsg = new("MES.Transaction.TestNode.Submit.WorkStepException", CurPosition.POST_CODE);
                else
                {
                    action.Data.ShortMsg = new("重置扫描", ShortMessage.Types.Error);
                    action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                    ResetNode();
                   action.IsSuccessed = false;
                   //action.LocaleMsg = new($"岗位[{CurPosition.POST_CODE}]工步执行异常,请重新扫描产品条码", CurPosition.POST_CODE);
                   action.LocaleMsg = new("MES.Transaction.TestNode.Submit.WorkStepException", CurPosition.POST_CODE);
                }
            }
            catch (Exception ex)
            {
                action.Data.ShortMsg = new("工序异常", ShortMessage.Types.Error);
                action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                //action.CatchExceptionWithLog(ex, $"测试工序:提交操作数据异常");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.TestNode.SubmitException"));
            }
@@ -173,9 +189,10 @@
                var woStatus = CurBatch.CheckCanProduce(curNode);
                if (!woStatus.IsSuccessed)
                {
                    woStatus.Data.ShortMsg = new("工单异常", ShortMessage.Types.Error);
                    return woStatus;
                }
                //非法过站防呆:进入工序时要增加判断条码是否按流程过站
                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())
                {
@@ -196,9 +213,33 @@
                    };
                    wipSNs.Add(wipSN);
                }
                //如果条码不是当前工单或者产线的则报错
                if (wipSNs.Any(q => q.WORK_ORDER != CurBatch.WO.ORDER_NO || q.LINE_CODE != CurLine.LINE_CODE))
                {
                    if (wipSNs.First().LINE_CODE == CurLine.LINE_CODE)
                    {
                        action.Data.ShortMsg = new("工单错误", ShortMessage.Types.Error);
                        action.IsSuccessed = false;
                        //action.LocaleMsg = new($"产品[{CurSN}]不属于当前工单,请切换到工单[{wipSNs.First().WORK_ORDER}]后再扫描");
                        action.LocaleMsg = new("MES.Transaction.TestNode.NodeSubmit.WoError", CurSN, wipSNs.First().WORK_ORDER);
                        return action;
                    }
                    else
                    {
                        action.Data.ShortMsg = new("产线错误", ShortMessage.Types.Error);
                        action.IsSuccessed = false;
                        //action.LocaleMsg = new($"产品[{CurSN}]已在产线[{wipSNs.First().LINE_CODE}]投产,请到产线[{wipSNs.First().LINE_CODE}]扫描");
                        action.LocaleMsg = new("MES.Transaction.TestNode.NodeSubmit.LineError", CurSN, wipSNs.First().LINE_CODE);
                        return action;
                    }
                }
                //非法过站防呆:进入工序时要增加判断条码是否按流程过站
                var canGotoNext = CurBatch.CanGotoNext(input, wipSNs.First(), curNode);
                if (!canGotoNext.IsSuccessed)
                {
                    woStatus.Data.ShortMsg = new("进站错误", ShortMessage.Types.Error);
                    return canGotoNext;
                }
@@ -436,6 +477,7 @@
            }
            catch (Exception ex)
            {
                action.Data.ShortMsg = new("工步异常", ShortMessage.Types.Error);
                ResetNode();
                //action.CatchExceptionWithLog(ex, $"{curNode.NODE_NAME}:工序节点工步提交数据异常,请检查工序节点设置");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.TestNode.NodeSubmitException", curNode.NODE_NAME));
@@ -454,6 +496,8 @@
            SaveStepsCommitActionToDB();
            //保存成功,返回过站消息
            OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty += CurWipSNs.Count;
            action.Data.ShortMsg = new("过站成功", ShortMessage.Types.Success);
            //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>());
            //重置工序