服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-09-23 dc4c76b2b5e57d28e3c4bfff9ec86e11efe22d20
Tiger.Business.MES/Transaction/PackingNode.cs
@@ -55,7 +55,7 @@
                    //如果行为被标记成已完成,则重置工序
                    if (TempPkgAction.IsFinished)
                    {
                        action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                        action.Data.OperInfo = CurOperInfo(input.Locale);
                        ResetNode();
                    }
                }
@@ -77,20 +77,21 @@
                            if (!action.IsSuccessed)
                            {
                                var info = WoContext.GetSnOperInfo(input.SN).Data;
                                info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                                info.InputQty = CurOperInfo(input.Locale).InputQty;
                                action.Data.OperInfo = info;
                            }
                            else if (!IsFinishAllSteps)
                            {
                                action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                                action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale));
                            }
                        }
                        //当前岗位在当前工单不是首站,则查找条码已绑定的工单当作当前工单
                        else
                        {
                            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.FLOW_SN == input.SN || s.TRAY_SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).ToList();
                                                .ByAuth(input.AuthOption).Where((q, s) => s.STATUS < BIZ_MES_WO_SN.STATUSs.Finished.GetValue())
                                                .Where((q, s) => s.SN == input.SN || s.FLOW_SN == input.SN || s.TRAY_SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).ToList();
                            //查找到条码已绑定的工单
                            if (!wosns.IsNullOrEmpty())
                            {
@@ -142,12 +143,12 @@
                                    if (!action.IsSuccessed && !CurWipSNs.Any())
                                    {
                                        var info = WoContext.GetSnOperInfo(input.SN).Data;
                                        info.InputQty = OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty;
                                        info.InputQty = CurOperInfo(input.Locale).InputQty;
                                        action.Data.OperInfo = info;
                                    }
                                    else if (!IsFinishAllSteps)
                                    {
                                        action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                                        action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(input.Locale));
                                    }
                                }
                            }
@@ -182,18 +183,18 @@
                        CurBatch?.Update();
                        var submitStep = Steps.Where(q => q.ID == input.CurStepID && !q.IsFinished).FirstOrDefault();
                        //如果客户端返回的当前工步ID找不到未完成的行为工步,则直接开始下一个行为工步
                        if (submitStep.IsNullOrEmpty())
                        {
                            action = BeginNextActionStep(input);
                            action.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                        }
                        else
                        {
                            var result = submitStep.Submit(input);
                            action = submitStep.Submit(input);
                            //如果当前工步已完成,开始执行下一工步
                            if (result.IsSuccessed && submitStep.IsFinished)
                            if (action.IsSuccessed && submitStep.IsFinished)
                            {
                                result = BeginNextActionStep(input);
                                action = BeginNextActionStep(input);
                            }
                            //如果当前工步未完成
                            else
@@ -201,30 +202,29 @@
                                //行为执行出错,工步被重置
                                if (Steps.IsNullOrEmpty())
                                {
                                    result.LocaleMsg = new(Biz.T(result.LocaleMsg, input.Locale) + Biz.T(Biz.L("MES.Transaction.Position.RescanSN"), input.Locale));
                                    action.LocaleMsg = new(Biz.T(action.LocaleMsg, input.Locale) + Biz.T(Biz.L("MES.Transaction.Position.RescanSN"), input.Locale));
                                }
                                else
                                {
                                    result.Data.SetValue(CurBatch, CurStep, CurStep?.ID, IsFinishAllSteps);
                                    action.Data.SetValue(CurBatch, CurStep, CurStep?.ID, IsFinishAllSteps);
                                }
                            }
                            //如果所有工步都完成
                            if (IsFinishAllSteps)
                            {
                                result = DoIfFinishAllSteps(result, input.Locale);
                            }
                            else
                            {
                                result.Data.OperInfo = OperInfoDic[CurBatch.Batch.BATCH_NO];
                            }
                            return result;
                        }
                        //如果所有工步都完成
                        if (IsFinishAllSteps)
                        {
                            action = DoIfFinishAllSteps(action, input.Locale);
                        }
                        else
                        {
                            action.Data.OperInfo = CurOperInfo(input.Locale);
                        }
                    }
                    //没有可执行的工步
                    else
                    {
                        action.Data.ShortMsg = new("重置扫描", ShortMessage.Types.Error);
                        action.Data.OperInfo = OperInfoDic.ContainsKey(CurBatch?.Batch?.BATCH_NO ?? "") ? OperInfoDic[CurBatch.Batch.BATCH_NO] : new();
                        action.Data.OperInfo = CurOperInfo(input.Locale);
                        ResetNode();
                       action.IsSuccessed = false;
                       //action.LocaleMsg = new($"岗位[{CurPosition.POST_CODE}]工步执行异常,请重新扫描产品条码", CurPosition.POST_CODE);
@@ -235,7 +235,7 @@
            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.Data.OperInfo = CurOperInfo(input.Locale);
                //action.CatchExceptionWithLog(ex, $"包装工序:提交操作数据异常");
                action.CatchExceptionWithLog(ex, Biz.L("MES.Transaction.PackingNode.SubmitException"));
            }
@@ -294,7 +294,7 @@
                        action.Data.ShortMsg = new("工单错误", ShortMessage.Types.Error);
                        action.IsSuccessed = false;
                        //action.LocaleMsg = new($"产品[{CurSN}]不属于当前工单,请切换到工单[{wipSNs.First().WORK_ORDER}]后再扫描");
                        action.LocaleMsg = new("MES.Transaction.PackingNode.NodeSubmit.WoError", CurSN, wipSNs.First().WORK_ORDER);
                        action.LocaleMsg = new("MES.Transaction.PackingNode.NodeSubmit.WoError", input.SN, wipSNs.First().WORK_ORDER);
                        return action;
                    }
                    else
@@ -302,7 +302,7 @@
                        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.PackingNode.NodeSubmit.LineError", CurSN, wipSNs.First().LINE_CODE);
                        action.LocaleMsg = new("MES.Transaction.PackingNode.NodeSubmit.LineError", input.SN, wipSNs.First().LINE_CODE);
                        return action;
                    }
                }
@@ -503,6 +503,7 @@
                    }
                    //完成第一个工序节点工步
                    curStep.IsFinished = true;
                    curStep.Status = StepStatus.Finished;
                    CurStep = curStep;
                } 
@@ -511,6 +512,7 @@
                    var curStep = Steps.Where(q => q.NodeType == IWorkStep.NodeTypes.Node && !q.IsFinished).OrderBy(q => q.Sequence).First();
                    //完成当前工序节点工步
                    curStep.IsFinished = true;
                    curStep.Status = StepStatus.Finished;
                    CurStep = curStep;
                }
@@ -573,8 +575,8 @@
            SaveStepsCommitActionToDB();
            //保存成功,返回过站消息
            OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], locale);
            CurOperInfo(locale).InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(CurOperInfo(locale));
            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>());
@@ -599,16 +601,24 @@
                {
                    if (Context.ContainsKey("CurPackage"))
                    {
                        var CurPkg = Context["CurPackage"] as WipPkg;
                        int shipQty = input.Data.ToInt32();
                        //有填出货数量则验证当前包装数量必须等于(出货数量/包装规则数量)的余数
                        if (shipQty > 0)
                        {
                        }
                        NodeCmd = "PkgSubmit";
                        TempPkgAction = new PackingAction();
                        TempPkgAction.Init(this);
                        int curQty = CurPkg.Item.TotalQty;
                        int ruleQty = TempPkgAction.PkgRule.GetTotalQty();
                        //有填出货数量则验证当前包装数量必须等于(出货数量/包装规则数量)的余数
                        if (shipQty > 0 &&  curQty != shipQty % ruleQty)
                        {
                            action.IsSuccessed = false;
                            //action.LocaleMsg = new($"出货数量设定为[{0}],目前包装了[{1}],包装尾数的数量必需是[{2}],请装够数量后再结束包装");
                            action.LocaleMsg = new("MES.Transaction.PackingNode.NotMatchShipQty", shipQty, curQty, shipQty % ruleQty);
                            return action;
                        }
                        action = TempPkgAction.Submit(null);
                    }
                    else