From 63edbc746dfc920bcc6ccb6efe42577bf1c5ec26 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期日, 01 九月 2024 01:45:10 +0800
Subject: [PATCH] WorkStep语言更新

---
 Tiger.Business/MES/Biz.Route.cs |   40 ++++++++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/Tiger.Business/MES/Biz.Route.cs b/Tiger.Business/MES/Biz.Route.cs
index c2da126..38f5200 100644
--- a/Tiger.Business/MES/Biz.Route.cs
+++ b/Tiger.Business/MES/Biz.Route.cs
@@ -333,6 +333,9 @@
                                 ALLOW_DFT_IN = "N",
                                 IS_INPUT = "N",
                                 IS_OUTPUT = "N",
+                                AUTH_ORG = node.AUTH_ORG,
+                                AUTH_PROD = node.AUTH_PROD,
+                                AUTH_WH = node.AUTH_WH,
                             });
                         }
                     }
@@ -340,7 +343,7 @@
                     List<MES_PROD_ACTION> actList = new List<MES_PROD_ACTION>();
                     foreach (var act in routeData.acts)
                     {
-                        if (!Db.Queryable<MES_PROD_ACTION>().Any(q => q.NODE_ID == act.ID && q.ROT_ID == routeData.route.ID))
+                        if (!Db.Queryable<MES_PROD_ACTION>().Any(q => q.ACT_ID == act.ID && q.ROT_ID == routeData.route.ID))
                         {
                             actList.Add(new()
                             {
@@ -359,6 +362,9 @@
                                 PKG_CODE = "",
                                 IS_ACTIVE = "Y",
                                 SETUP_FINISH = "N",
+                                AUTH_ORG = act.AUTH_ORG,
+                                AUTH_PROD = act.AUTH_PROD,
+                                AUTH_WH = act.AUTH_WH,
                             });
                         }
                     }
@@ -373,9 +379,11 @@
                             y.AsInsertable.ExecuteCommand();
                             y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
                         }
-                        db.Deleteable<MES_PROD_OPER>().Where(x => x.PROD_CODE == routeData.route.PROD_CODE && !SqlFunc.ContainsArray(nodeIds, x.NODE_ID)).ExecuteCommand();
-                        db.Deleteable<MES_PROD_ACTION>().Where(x => x.PROD_CODE == routeData.route.PROD_CODE && !SqlFunc.ContainsArray(nodeIds, x.NODE_ID)).ExecuteCommand();
-                        db.Deleteable<MES_PROD_ACTION>().Where(x => x.PROD_CODE == routeData.route.PROD_CODE && !SqlFunc.ContainsArray(actIds, x.ACT_ID)).ExecuteCommand();
+                        if (!routeData.route.PROD_CODE.IsNullOrEmpty())
+                        {
+                            db.Deleteable<MES_PROD_OPER>().Where(x => x.PROD_CODE == routeData.route.PROD_CODE && !SqlFunc.ContainsArray(nodeIds, x.NODE_ID)).ExecuteCommand();
+                            db.Deleteable<MES_PROD_ACTION>().Where(x => x.PROD_CODE == routeData.route.PROD_CODE && !SqlFunc.ContainsArray(actIds, x.ACT_ID)).ExecuteCommand();
+                        }
                         db.Deleteable<MES_ROUTE_NODE>(false).Where(x => x.ROT_ID == routeData.route.ID).ExecuteCommand();
                         db.Deleteable<MES_ROUTE_EDGE>(false).Where(x => x.ROT_ID == routeData.route.ID).ExecuteCommand();
                         db.Deleteable<MES_ROUTE_NODE_ACT>(false).Where(x => x.ROT_ID == routeData.route.ID).ExecuteCommand();
@@ -391,13 +399,16 @@
                         {
                             db.Insertable(routeData.acts).ExecuteCommand();
                         }
-                        if (operList.Count > 0)
+                        if (!routeData.route.PROD_CODE.IsNullOrEmpty())
                         {
-                            db.Insertable(operList).ExecuteCommand();
-                        }
-                        if (actList.Count > 0)
-                        {
-                            db.Insertable(actList).ExecuteCommand();
+                            if (operList.Count > 0)
+                            {
+                                db.Insertable(operList).ExecuteCommand();
+                            }
+                            if (actList.Count > 0)
+                            {
+                                db.Insertable(actList).ExecuteCommand();
+                            }
                         }
                     });
                     if (!dbTran.IsSuccess)
@@ -784,6 +795,9 @@
                                 ALLOW_DFT_IN = "N",
                                 IS_INPUT = "N",
                                 IS_OUTPUT = "N",
+                                AUTH_ORG = node.AUTH_ORG,
+                                AUTH_PROD = node.AUTH_PROD,
+                                AUTH_WH = node.AUTH_WH,
                             });
                         }
                     }
@@ -791,7 +805,7 @@
                     List<MES_WO_ACTION> actList = new List<MES_WO_ACTION>();
                     foreach (var act in routeData.acts)
                     {
-                        if (!Db.Queryable<MES_WO_ACTION>().Any(q => q.NODE_ID == act.ID))
+                        if (!Db.Queryable<MES_WO_ACTION>().Any(q => q.ACT_ID == act.ID))
                         {
                             actList.Add(new()
                             {
@@ -811,6 +825,9 @@
                                 PKG_CODE = "",
                                 IS_ACTIVE = "Y",
                                 SETUP_FINISH = "N",
+                                AUTH_ORG = act.AUTH_ORG,
+                                AUTH_PROD = act.AUTH_PROD,
+                                AUTH_WH = act.AUTH_WH,
                             });
                         }
                     }
@@ -826,7 +843,6 @@
                         //    y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
                         //}
                         db.Deleteable<MES_WO_OPER>().Where(x => x.WORK_ORDER == routeData.route.WORK_ORDER && !SqlFunc.ContainsArray(nodeIds, x.NODE_ID)).ExecuteCommand();
-                        db.Deleteable<MES_WO_ACTION>().Where(x => x.WORK_ORDER == routeData.route.WORK_ORDER && !SqlFunc.ContainsArray(nodeIds, x.NODE_ID)).ExecuteCommand();
                         db.Deleteable<MES_WO_ACTION>().Where(x => x.WORK_ORDER == routeData.route.WORK_ORDER && !SqlFunc.ContainsArray(actIds, x.ACT_ID)).ExecuteCommand();
                         db.Deleteable<MES_WO_NODE>(false).Where(x => x.WORK_ORDER == routeData.route.WORK_ORDER).ExecuteCommand();
                         db.Deleteable<MES_WO_EDGE>(false).Where(x => x.WORK_ORDER == routeData.route.WORK_ORDER).ExecuteCommand();

--
Gitblit v1.9.3