服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
2024-12-04 29861afeb7708546e38e18b129880c0807def565
优化了一些已知问题
已修改6个文件
76 ■■■■■ 文件已修改
Tiger.Business.MES/Common/WorkBatch.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/CollectNode.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/PackingNode.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/TestNode.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Transaction/YadaPacking.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Model.Net/Entitys/MES/BIZ_MES_WO_SN.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business.MES/Common/WorkBatch.cs
@@ -166,20 +166,22 @@
                action.LocaleMsg = new("MES.WorkBatch.WoStatusCanNotWork", WO.ORDER_NO, Batch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>());
            }
            //工单批次投入数量减去报废数量如果大于等于计划数量,则不允许生产
            if (curNode.IS_FIRST_NODE == "Y" && WoSNs.Count(q => q.BATCH_NO == Batch.BATCH_NO && BIZ_MES_WO_SN.STATUSs.NotInput.GetValue() < q.STATUS && q.STATUS <= BIZ_MES_WO_SN.STATUSs.Finished.GetValue()) >= Batch.PLAN_QTY)
            var batchInput = WoSNs.Where(q => q.BATCH_NO == Batch.BATCH_NO && BIZ_MES_WO_SN.STATUSs.NotInput.GetValue() < q.STATUS && q.STATUS <= BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY);
            if (curNode.IS_FIRST_NODE == "Y" && batchInput >= Batch.PLAN_QTY)
            {
                action.IsSuccessed = false;
                action.Data.SetValue(this, null);
                //action.LocaleMsg = new($"工单批次[{0}]已投入 {1},其中报废 {2},以满足计划数量[{3}],无需继续投入");
                action.LocaleMsg = new("MES.WorkBatch.BatchInputEnough", Batch.BATCH_NO, WoSNs.Count(q => q.BATCH_NO == Batch.BATCH_NO), WoSNs.Count(q => q.BATCH_NO == Batch.BATCH_NO && q.STATUS > BIZ_MES_WO_SN.STATUSs.Finished.GetValue()), Batch.PLAN_QTY);
                action.LocaleMsg = new("MES.WorkBatch.BatchInputEnough", Batch.BATCH_NO, batchInput, WoSNs.Where(q => q.BATCH_NO == Batch.BATCH_NO && q.STATUS > BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY), Batch.PLAN_QTY);
            }
            //工单投入数量减去报废数量如果大于等于计划数量,则不允许生产
            if (curNode.IS_FIRST_NODE == "Y" && WoSNs.Count(q =>q.WORK_ORDER == WO.ORDER_NO && BIZ_MES_WO_SN.STATUSs.NotInput.GetValue() < q.STATUS && q.STATUS <= BIZ_MES_WO_SN.STATUSs.Finished.GetValue()) >= WO.PLAN_QTY)
            var woInput = WoSNs.Where(q => q.WORK_ORDER == WO.ORDER_NO && BIZ_MES_WO_SN.STATUSs.NotInput.GetValue() < q.STATUS && q.STATUS <= BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY);
            if (curNode.IS_FIRST_NODE == "Y" && woInput >= WO.PLAN_QTY)
            {
                action.IsSuccessed = false;
                action.Data.SetValue(this, null);
                //action.LocaleMsg = new($"工单[{0}]已投入 {1},其中报废 {2},以满足计划数量[{3}],无需继续投入");
                action.LocaleMsg = new("MES.WorkBatch.WoInputEnough", WO.ORDER_NO, WoSNs.Count(q => q.WORK_ORDER == WO.ORDER_NO), WoSNs.Count(q => q.WORK_ORDER == WO.ORDER_NO && q.STATUS > BIZ_MES_WO_SN.STATUSs.Finished.GetValue()), WO.PLAN_QTY);
                action.LocaleMsg = new("MES.WorkBatch.WoInputEnough", WO.ORDER_NO, woInput, WoSNs.Where(q => q.WORK_ORDER == WO.ORDER_NO && q.STATUS > BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY), WO.PLAN_QTY);
            }
            return action;
@@ -350,6 +352,7 @@
                    action.IsSuccessed = false;
                    action.Data.SetValue(this, null);
                    var nextList = Nodes.Where(q => q.IS_FIRST_NODE == "Y");
                    //action.LocaleMsg = new($"条码[{0}]在工序[{1}]过站扫描错误,请先通过以下工序:{2}");
                    action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", input.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (GetNodeSetting(q)?.CAN_SKIP == "Y" ? $"({Biz.T(Biz.L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
                    return action;
                }
@@ -386,22 +389,25 @@
                        action.IsSuccessed = false;
                        action.Data.SetValue(this, null);
                        var nextList = reflowNodes.Where(q => wipSN.REFLOW_NODE.IsNullOrEmpty() || wipSN.REFLOW_NODE == q.NODE_NAME);
                        //action.LocaleMsg = new($"工序[{0}]不是条码[{1}]在工序[{2}]维修后可回流的工序,请选择回流到以下工序:{3}");
                        action.LocaleMsg = new("MES.WorkBatch.ReflowToNodeException", nextNode.NODE_NAME, input.SN, curNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (GetNodeSetting(q)?.CAN_SKIP == "Y" ? $"({Biz.T(Biz.L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
                        return action;
                    }
                }
                //不良品入站:如果产品有不良记录且目标工序不是维修工序且不允许不良品入站,则报错
                else if (wipSN.Defects.Any(q => q.WORK_ORDER == WO.ORDER_NO && q.STATUS < MES_WIP_DFT.STATUSs.Resolved.GetValue())
                     && nextSetting.ALLOW_DFT_IN != "Y" && nextNode.Operation.OPER_TYPE != MES_OPERATION.OPER_TYPEs.Repair.GetValue())
                {
                    action.IsSuccessed = false;
                    action.Data.SetValue(this, null);
                    action.LocaleMsg = new("MES.WorkBatch.PleaseGotoRepair", curNode.NODE_NAME, input.SN);
                    return action;
                }
                //正常工序过站
                else
                {
                    //不良品入站:如果产品有不良记录且目标工序不是维修工序且不允许不良品入站,则报错
                    if (wipSN.Defects.Any(q => q.STATUS < MES_WIP_DFT.STATUSs.Resolved.GetValue())
                     && nextSetting.ALLOW_DFT_IN != "Y" && nextNode.Operation.OPER_TYPE != MES_OPERATION.OPER_TYPEs.Repair.GetValue())
                    {
                        action.IsSuccessed = false;
                        action.Data.SetValue(this, null);
                        //action.LocaleMsg = new($"工序[{0}]不允许不良品入站,条码[{1}]存在不良记录,请先按流程指引操作或者进入维修");
                        action.LocaleMsg = new("MES.WorkBatch.PleaseGotoRepair", curNode.NODE_NAME, input.SN);
                        return action;
                    }
                    //添加条码当前工序的下一个可执行工序
                    var nextNodes = GetNextNodes(curNode, wipSN);
                    //如果下一个可执行工序包含目标工序则允许进站
@@ -416,7 +422,8 @@
                    {
                        action.IsSuccessed = false;
                        action.Data.SetValue(this, null);
                        var nextList = nextNodes.Where(q => NodeSets.Any(s => s.NODE_ID == q.ID && s.IS_ACTIVE == "Y" && s.CAN_SKIP != "Y"));
                        var nextList = nextNodes.Where(q => NodeSets.Any(s => s.NODE_ID == q.ID && s.IS_ACTIVE == "Y"));
                        //action.LocaleMsg = new($"条码[{0}]在工序[{1}]过站扫描错误,请先通过以下工序:{2}");
                        action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", input.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (GetNodeSetting(q)?.CAN_SKIP == "Y" ? $"({Biz.T(Biz.L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
                        return action;
                    }
@@ -446,6 +453,7 @@
                            action.IsSuccessed = false;
                            action.Data.SetValue(this, null);
                            var nextList = nextNodes.Where(q => NodeSets.Any(s => s.NODE_ID == q.ID && s.IS_ACTIVE == "Y"));
                            //action.LocaleMsg = new($"条码[{0}]在工序[{1}]过站扫描错误,请先通过以下工序:{2}");
                            action.LocaleMsg = new("MES.WorkBatch.GotoNextNodeException", input.SN, nextNode.NODE_NAME, string.Join(", ", nextList.Select(q => q.NODE_NAME + (GetNodeSetting(q)?.CAN_SKIP == "Y" ? $"({Biz.T(Biz.L("MES.WorkBatch.Optional"), input.Locale)})" : ""))));
                            return action;
                        }
@@ -464,7 +472,7 @@
        private List<MES_WO_NODE> GetNextNodes(MES_WO_NODE parent, MES_WIP_DATA wipSN)
        {
            var result = new List<MES_WO_NODE>();
            var nextNodes = Nodes.Where(q => q.Operation.OPER_TYPE != MES_OPERATION.OPER_TYPEs.Repair.GetValue()
            var nextNodes =  Nodes.Where(q => q.Operation.OPER_TYPE != MES_OPERATION.OPER_TYPEs.Repair.GetValue()
                                                                && Edges.Any(e => e.SRC_NODE == parent.ID && e.TGT_NODE == q.ID)
                                                                && !wipSN.History.Any(h => h.WORK_ORDER == WO.ORDER_NO && h.UNBIND_FLAG != "Y" && h.NODE_ID == q.ID && h.IsFinished)
                                                             ).ToList();
@@ -669,10 +677,16 @@
                while (curpkg.Any());
                db.Updateable(pkgs, user).ExecuteCommand();
                //MES_WIP_DFT,在上仓库装配和维修之前,先把不良记录标记为已处理
                db.Updateable<MES_WIP_DFT>(user)
                           .SetColumns(q => q.STATUS == MES_WIP_DFT.STATUSs.Resolved.GetValue())
                           .Where(q => q.WORK_ORDER == wo.ORDER_NO && wipIDs.Contains(q.WIP_ID))
                db.Updateable<MES_WIP_DATA>(user)
                           .SetColumns(q => q.DFT_FLAG == "N")
                           .SetColumns(q => q.DFT_COUNT == 0)
                           .SetColumns(q => q.DFT_CODE == null)
                           .Where(q => q.WORK_ORDER == wo.ORDER_NO && wipIDs.Contains(q.ID))
                           .ExecuteCommand();
                db.Updateable<MES_WIP_DFT>(user)
                          .SetColumns(q => q.STATUS == MES_WIP_DFT.STATUSs.Resolved.GetValue())
                          .Where(q => q.WORK_ORDER == wo.ORDER_NO && wipIDs.Contains(q.WIP_ID))
                          .ExecuteCommand();
            });
            if (!dbTran.IsSuccess)
            {
Tiger.Business.MES/Transaction/CollectNode.cs
@@ -271,7 +271,6 @@
                            FLOW_SN = input.SN,
                            STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(),
                            ITEM_CODE = CurBatch.WO.ITEM_CODE,
                            QTY = 1,
                            WORK_ORDER = CurBatch.Batch.ORDER_NO,
                            BATCH_NO = CurBatch.Batch.BATCH_NO,
                            FTY_CODE = CurFactory.FTY_CODE,
@@ -331,7 +330,6 @@
                                FLOW_SN = wipSN.SN,
                                TRAY_SN = wipSN.TRAY_SN,
                                STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(),
                                QTY = 1,
                            });
                        }
                    }
Tiger.Business.MES/Transaction/PackingNode.cs
@@ -313,7 +313,6 @@
                            FLOW_SN = input.SN,
                            STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(),
                            ITEM_CODE = CurBatch.WO.ITEM_CODE,
                            QTY = 1,
                            WORK_ORDER = CurBatch.Batch.ORDER_NO,
                            BATCH_NO = CurBatch.Batch.BATCH_NO,
                            FTY_CODE = CurFactory.FTY_CODE,
@@ -376,7 +375,6 @@
                                FLOW_SN = wipSN.SN,
                                TRAY_SN = wipSN.TRAY_SN,
                                STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(),
                                QTY = 1,
                            });
                        }
                    }
Tiger.Business.MES/Transaction/TestNode.cs
@@ -266,7 +266,6 @@
                            FLOW_SN = input.SN,
                            STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(),
                            ITEM_CODE = CurBatch.WO.ITEM_CODE,
                            QTY = 1,
                            WORK_ORDER = CurBatch.Batch.ORDER_NO,
                            BATCH_NO = CurBatch.Batch.BATCH_NO,
                            FTY_CODE = CurFactory.FTY_CODE,
@@ -326,7 +325,6 @@
                                FLOW_SN = wipSN.SN,
                                TRAY_SN = wipSN.TRAY_SN,
                                STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(),
                                QTY = 1,
                            });
                        }
                    }
Tiger.Business.MES/Transaction/YadaPacking.cs
@@ -349,7 +349,6 @@
                            FLOW_SN = input.SN,
                            STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(),
                            ITEM_CODE = CurBatch.WO.ITEM_CODE,
                            QTY = 1,
                            WORK_ORDER = CurBatch.Batch.ORDER_NO,
                            BATCH_NO = CurBatch.Batch.BATCH_NO,
                            FTY_CODE = CurFactory.FTY_CODE,
@@ -423,25 +422,9 @@
                    ShippingOrder = IsPrintCustomerLabel ? ship?.ShipDoc ?? "" : "";
                    //缓存出货数量
                    Context.SetOrAdd("CurShipQty", CurShipQty);
                    //if (Context.ContainsKey("CurShipQty"))
                    //{
                    //    Context["CurShipQty"] = CurShipQty;
                    //}
                    //else
                    //{
                    //    Context.Add("CurShipQty", CurShipQty);
                    //}
                    //缓存出货箱数
                    Context.SetOrAdd("CurWaitShipmentCarton", WaitShipmentCarton);
                    Context.SetOrAdd("CurWaitShipment", WaitShipment);
                    //if (Context.ContainsKey("CurWaitShipmentCarton"))
                    //{
                    //    Context["CurWaitShipmentCarton"] = WaitShipmentCarton;
                    //}
                    //else
                    //{
                    //    Context.Add("CurWaitShipmentCarton", WaitShipmentCarton);
                    //}
                    debug.Log(new StackFrame(true), "***** 12", info => { ConsoleExt.WriteLine(info.ToString()); });
                    //绑定条码到工单
@@ -457,7 +440,6 @@
                                FLOW_SN = wipSN.SN,
                                TRAY_SN = wipSN.TRAY_SN,
                                STATUS = BIZ_MES_WO_SN.STATUSs.NotInput.GetValue(),
                                QTY = 1,
                            });
                        }
                    }
Tiger.Model.Net/Entitys/MES/BIZ_MES_WO_SN.cs
@@ -72,7 +72,7 @@
        /// 数量
        /// </summary>
        [DisplayName("数量")]
        public double QTY { get; set; }
        public double QTY { get; set; } = 1;
        /// <summary>
        /// 备注
        /// </summary>