服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-09-13 12b0846ee59a358fbf5bc392f74794b8ef13d8eb
Tiger.Business.MES/Transaction/CollectNode.cs
@@ -46,6 +46,9 @@
                    //先判断当前工单不为空且当前岗位在当前工单是不是首站,如果是则不允许变更当前工单,尝试把条码绑定到当前工单
                    if (!CurBatch.IsNullOrEmpty() && CurBatch.IsFirstNode(PostCode))
                    {
                        //更新CurBatch
                        CurBatch?.Update();
                        //提交数据
                        action = NodeSubmit(action, input);
                        //更新工序信息
                        if (!action.IsSuccessed)
@@ -56,14 +59,14 @@
                        }
                        else if (!IsFinishAllSteps)
                        {
                            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO]);
                            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], 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.TRAY_SN == input.SN).Select((q, s) => new { Batch = q, SN = s }).ToList();
                                                        .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();
                        //查找到条码已绑定的工单
                        if (!wosns.IsNullOrEmpty())
@@ -91,6 +94,8 @@
                                        return action;
                                    }
                                }
                                //更新CurBatch
                                CurBatch?.Update();
                                //条码过站
                                action = NodeSubmit(action, input);
                                if (!action.IsSuccessed && !CurWipSNs.Any())
@@ -101,7 +106,7 @@
                                }
                                else if (!IsFinishAllSteps)
                                {
                                    action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO]);
                                    action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], input.Locale);
                                }
                            }
                        }
@@ -132,6 +137,9 @@
                //完成工序节点工步后,后开始执行当前工序的行为工步
                else if (IsFinishNodeSteps && !IsFinishAllSteps)
                {
                    //更新CurBatch
                    CurBatch?.Update();
                    var submitStep = Steps.Where(q => q.ID == input.CurStepID && !q.IsFinished).FirstOrDefault();
                    if (submitStep.IsNullOrEmpty())
                    {
@@ -162,7 +170,7 @@
                        //如果所有工步都完成
                        if (IsFinishAllSteps)
                        {
                            result = DoIfFinishAllSteps(result);
                            result = DoIfFinishAllSteps(result, input.Locale);
                        }
                        else
                        {
@@ -212,7 +220,7 @@
                    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();
                var wipSNs = Biz.Db.Queryable<MES_WIP_DATA>().IncludesAllFirstLayer().Where(q => q.SN == input.SN || q.FLOW_SN == input.SN || q.TRAY_SN == input.SN).ToList();
                if (wipSNs.IsNullOrEmpty())
                {
                    var wipSN = new MES_WIP_DATA()
@@ -245,7 +253,7 @@
                        action.Data.ShortMsg = new("工单错误", ShortMessage.Types.Error);
                        action.IsSuccessed = false;
                        //action.LocaleMsg = new($"产品[{CurSN}]不属于当前工单,请切换到工单[{wipSNs.First().WORK_ORDER}]后再扫描");
                        action.LocaleMsg = new("MES.Transaction.CollectNode.NodeSubmit.WoError", CurSN, wipSNs.First().WORK_ORDER);
                        action.LocaleMsg = new("MES.Transaction.CollectNode.NodeSubmit.WoError", input.SN, wipSNs.First().WORK_ORDER);
                        return action;
                    }
                    else
@@ -253,7 +261,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.CollectNode.NodeSubmit.LineError", CurSN, wipSNs.First().LINE_CODE);
                        action.LocaleMsg = new("MES.Transaction.CollectNode.NodeSubmit.LineError", input.SN, wipSNs.First().LINE_CODE);
                        return action;
                    }
                }
@@ -279,6 +287,7 @@
                                WORK_ORDER = CurBatch.Batch.ORDER_NO,
                                WIP_ID = wipSN.ID,
                                SN = wipSN.SN,
                                FLOW_SN = wipSN.SN,
                                TRAY_SN = wipSN.TRAY_SN,
                                STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(),
                            });
@@ -405,6 +414,7 @@
                    Steps.Clear();
                    var curStep = new Biz.WorkStep(IWorkStep.NodeTypes.Node, this)
                    {
                        Name = "扫描产品",
                        Sequence = Steps.Count + 1,
                        Node = curNode,
                        OperSetting = CurBatch.NodeSets.FirstOrDefault(q => q.NODE_ID == curNode.ID),
@@ -452,7 +462,7 @@
                    }
                    //完成第一个工序节点工步
                    curStep.IsFinished = true;
                    curStep.Status = StepStatus.Finished;
                    CurStep = curStep;
                }
                else if (!IsFinishNodeSteps)
@@ -460,7 +470,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;
                }
@@ -498,7 +508,7 @@
                if (IsFinishAllSteps)
                {
                    action.Data.SetValue(CurBatch, CurStep, "", IsFinishAllSteps);
                    action = DoIfFinishAllSteps(action);
                    action = DoIfFinishAllSteps(action, input.Locale);
                }
            }
            catch (Exception ex)
@@ -516,14 +526,14 @@
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        public ApiAction<SubmitOutput> DoIfFinishAllSteps(ApiAction<SubmitOutput> action)
        public ApiAction<SubmitOutput> DoIfFinishAllSteps(ApiAction<SubmitOutput> action, string locale)
        {
            //保存数据库
            SaveStepsCommitActionToDB();
            //保存成功,返回过站消息
            OperInfoDic[CurBatch.Batch.BATCH_NO].InputQty += CurWipSNs.Count;
            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO]);
            action.Data.OperInfo = SetOperNodeInfo(OperInfoDic[CurBatch.Batch.BATCH_NO], 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>());