服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-09-13 12b0846ee59a358fbf5bc392f74794b8ef13d8eb
Tiger.Business.MES/Transaction/PackingNode.cs
@@ -69,6 +69,9 @@
                        //先判断当前工单不为空且当前岗位在当前工单是不是首站,如果是则不允许变更当前工单,尝试把条码绑定到当前工单
                        if (!CurBatch.IsNullOrEmpty() && CurBatch.IsFirstNode(PostCode))
                        {
                            //更新CurBatch
                            CurBatch?.Update();
                            //提交数据
                            action = NodeSubmit(action, input);
                            //更新工序信息
                            if (!action.IsSuccessed)
@@ -86,7 +89,7 @@
                        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())
@@ -100,9 +103,18 @@
                                    action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.OnlyMinPackage", input.SN);
                                    return action;
                                }
                                if (Context.ContainsKey("CurPackage") && !Context["CurPackage"].IsNullOrEmpty() && (Context["CurPackage"] as WipPkg).WorkBatch != wosns.First().Batch.BATCH_NO)
                                {
                                    action.Data.ShortMsg = new("工单批次错误", ShortMessage.Types.Error);
                                    action.Data.OperInfo = new();
                                    action.IsSuccessed = false;
                                    //action.LocaleMsg = new($"正在包装工单批次[{0}]的产品,请先完成当前包装后再扫描其他批次[{1}]的产品[{2}]");
                                    action.LocaleMsg = new("MES.Transaction.PackingNode.Submit.BatchError", (Context["CurPackage"] as WipPkg).WorkBatch, wosns.First().Batch.BATCH_NO, CurSN);
                                    return action;
                                }
                                if (wosns.First().Batch.ACT_LINE != CurLine.LINE_CODE)
                                {
                                    action.Data.ShortMsg = new("产线错误", ShortMessage.Types.Error);
                                    action.Data.ShortMsg = new("产线投产错误", ShortMessage.Types.Error);
                                    action.Data.OperInfo = new();
                                    action.IsSuccessed = false;
                                    //action.LocaleMsg = new($"条码[{0}]已在产线[{1}]投入生产,请在正确岗位扫描");
@@ -123,8 +135,10 @@
                                           return action;
                                       }
                                   }
                                   //条码过站
                                   action = NodeSubmit(action, input);
                                    //更新CurBatch
                                    CurBatch?.Update();
                                    //条码过站
                                    action = NodeSubmit(action, input);
                                    if (!action.IsSuccessed && !CurWipSNs.Any())
                                    {
                                        var info = WoContext.GetSnOperInfo(input.SN).Data;
@@ -164,6 +178,9 @@
                    //完成工序节点工步后,后开始执行当前工序的行为工步
                    else if (IsFinishNodeSteps && !IsFinishAllSteps)
                    {
                        //更新CurBatch
                        CurBatch?.Update();
                        var submitStep = Steps.Where(q => q.ID == input.CurStepID && !q.IsFinished).FirstOrDefault();
                        if (submitStep.IsNullOrEmpty())
                        {
@@ -243,8 +260,8 @@
                    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();
                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()
@@ -277,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
@@ -285,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;
                    }
                }
@@ -311,6 +328,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(),
                            });
@@ -437,7 +455,8 @@
                    Steps.Clear();
                   var curStep = new Biz.WorkStep(IWorkStep.NodeTypes.Node, this) 
                    {
                       Sequence = Steps.Count + 1,
                        Name = "扫描产品",
                        Sequence = Steps.Count + 1,
                       Node = curNode,
                        OperSetting = CurBatch.NodeSets.FirstOrDefault(q => q.NODE_ID == curNode.ID),
                        DBSubmitAction = () =>
@@ -570,7 +589,7 @@
        /// 包装工序:手动结束包装
        /// </summary>
        /// <returns></returns>
        public async Task<ApiAction<SubmitOutput>> CompletePkg()
        public async Task<ApiAction<SubmitOutput>> CompletePkg(ApiAction input)
        {
            var action = new ApiAction<SubmitOutput>(new SubmitOutput());
            try
@@ -580,10 +599,24 @@
                {
                    if (Context.ContainsKey("CurPackage"))
                    {
                        var CurPkg = Context["CurPackage"] as WipPkg;
                        int shipQty = input.Data.ToInt32();
                        NodeCmd = "PkgSubmit";
                        TempPkgAction = new PackingAction();
                        TempPkgAction.Init(null, this, null, null);
                        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);
                        }
                        action = TempPkgAction.Submit(null);
                    }
                    else