From 3258283603cca12b2373529f1333dfe97dca7c61 Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期五, 28 二月 2025 17:06:39 +0800
Subject: [PATCH] 雅达-添加日志记录和更新扫描成功信息

---
 Tiger.Business.MES/iERP/U9C_MES.cs |  250 +++++++++++++++++++++++++------------------------
 1 files changed, 129 insertions(+), 121 deletions(-)

diff --git a/Tiger.Business.MES/iERP/U9C_MES.cs b/Tiger.Business.MES/iERP/U9C_MES.cs
index be930b5..8f4f490 100644
--- a/Tiger.Business.MES/iERP/U9C_MES.cs
+++ b/Tiger.Business.MES/iERP/U9C_MES.cs
@@ -17,6 +17,7 @@
 using Apache.NMS.ActiveMQ.Commands;
 using System.Security.Cryptography;
 using System.Diagnostics;
+using Tiger.Model.MES.Yada;
 
 namespace Tiger.Business.MES
 {
@@ -27,7 +28,7 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public ApiAction GetBasItem(U9C_MES_Input input)
+        public ApiAction GetBasItem(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"鐗╂枡淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -88,49 +89,50 @@
             db = Biz.Db;
             //var dbTran = db.UseTran(() =>
             //{
-                if (items.Any())
+            if (items.Any())
+            {
+                if (items.Count > 100)
                 {
-                    if (items.Count > 100)
+                    db.Utilities.PageEach(items, 100, pageList =>
                     {
-                        db.Utilities.PageEach(items, 100, pageList =>
-                        {
-                            var y = db.Storageable(pageList, "U9C")
-                                   .WhereColumns(t => new { t.ID, t.GHOST_ROW })
-                                   .ToStorage();
-                            y.AsInsertable.ExecuteCommand();
-                            y.AsUpdateable.ExecuteCommand();
-                        });
-                    }
-                    else {
-                        var y = db.Storageable(items, "U9C")
-                                       .WhereColumns(t => new { t.ID, t.GHOST_ROW })
-                                       .ToStorage();
+                        var y = db.Storageable(pageList, "U9C")
+                               .WhereColumns(t => new { t.ID, t.GHOST_ROW })
+                               .ToStorage();
                         y.AsInsertable.ExecuteCommand();
                         y.AsUpdateable.ExecuteCommand();
-                    }
+                    });
                 }
-                if (itemExts.Any())
+                else
                 {
-                    if (itemExts.Count > 100)
-                    {
-                        db.Utilities.PageEach(itemExts, 100, pageList =>
-                         {
-                             var y = db.Storageable(pageList, "U9C")
-                                    .WhereColumns(t => new { t.ITEM_ID, t.GHOST_ROW })
-                                    .ToStorage();
-                             y.AsInsertable.ExecuteCommand();
-                             y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                         });
-                    }
-                    else
-                    {
-                        var s = db.Storageable(itemExts, "U9C")
-                               .WhereColumns(t => new { t.ITEM_ID, t.GHOST_ROW })
-                               .ToStorage();
-                        s.AsInsertable.ExecuteCommand();
-                        s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                    }
+                    var y = db.Storageable(items, "U9C")
+                                   .WhereColumns(t => new { t.ID, t.GHOST_ROW })
+                                   .ToStorage();
+                    y.AsInsertable.ExecuteCommand();
+                    y.AsUpdateable.ExecuteCommand();
                 }
+            }
+            if (itemExts.Any())
+            {
+                if (itemExts.Count > 100)
+                {
+                    db.Utilities.PageEach(itemExts, 100, pageList =>
+                     {
+                         var y = db.Storageable(pageList, "U9C")
+                                .WhereColumns(t => new { t.ITEM_ID, t.GHOST_ROW })
+                                .ToStorage();
+                         y.AsInsertable.ExecuteCommand();
+                         y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                     });
+                }
+                else
+                {
+                    var s = db.Storageable(itemExts, "U9C")
+                           .WhereColumns(t => new { t.ITEM_ID, t.GHOST_ROW })
+                           .ToStorage();
+                    s.AsInsertable.ExecuteCommand();
+                    s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                }
+            }
             //});
             //if (!dbTran.IsSuccess)
             //{
@@ -243,15 +245,18 @@
                 Work.DoAsync(() =>
                 {
                     List<BIZ_MES_WO> woList = new();
-                    foreach (var wo in items) {
+                    foreach (var wo in items)
+                    {
                         //鍙湁宸ュ崟鐘舵�佷负鍒濆鍖栧拰宸ヨ壓鐘舵�佷负寰呴厤缃墠鑷姩缁戝畾宸ヨ壓璺嚎
-                        if (wo.STATUS == BIZ_MES_WO.STATUSs.Init.GetValue() && wo.ROUTE_STATUS == BIZ_MES_WO.ROUTE_STATUSs.WaitSet.GetValue()) {
+                        if (wo.STATUS == BIZ_MES_WO.STATUSs.Init.GetValue() && wo.ROUTE_STATUS == BIZ_MES_WO.ROUTE_STATUSs.WaitSet.GetValue())
+                        {
                             try
                             {
                                 var rot = Biz.Db.Queryable<MES_PROD_OPER>()
-                                .GroupBy(x => new { x.PROD_CODE, x.ROT_ID})
+                                .GroupBy(x => new { x.PROD_CODE, x.ROT_ID })
                                 .Where(q => q.PROD_CODE == wo.ITEM_CODE)
-                                .Select(it => new {
+                                .Select(it => new
+                                {
                                     PROD_CODE = it.PROD_CODE,
                                     ROT_ID = it.ROT_ID
                                 })
@@ -304,7 +309,7 @@
         /// <param name="input"></param>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        public ApiAction GetCustomer(U9C_MES_Input input)
+        public ApiAction GetCustomer(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"瀹㈡埛淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -342,28 +347,28 @@
             db = Biz.Db;
             //var dbTran = db.UseTran(() =>
             //    {
-                    if (items.Any())
-                    {
-                        if (items.Count > 100)
-                        {
-                           db.Utilities.PageEach(items, 100, pageList =>
-                            {
-                                var y = db.Storageable(pageList, "U9C")
-                                       .WhereColumns(t => new { t.CUST_CODE, t.GHOST_ROW })
-                                       .ToStorage();
-                                y.AsInsertable.ExecuteCommand();
-                                y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                            });
-                        }
-                        else
-                        {
-                            var s = db.Storageable(items, "U9C")
-                                   .WhereColumns(t => new { t.CUST_CODE, t.GHOST_ROW })
-                                   .ToStorage();
-                            s.AsInsertable.ExecuteCommand();
-                            s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                        }
-                    }
+            if (items.Any())
+            {
+                if (items.Count > 100)
+                {
+                    db.Utilities.PageEach(items, 100, pageList =>
+                     {
+                         var y = db.Storageable(pageList, "U9C")
+                                .WhereColumns(t => new { t.CUST_CODE, t.GHOST_ROW })
+                                .ToStorage();
+                         y.AsInsertable.ExecuteCommand();
+                         y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                     });
+                }
+                else
+                {
+                    var s = db.Storageable(items, "U9C")
+                           .WhereColumns(t => new { t.CUST_CODE, t.GHOST_ROW })
+                           .ToStorage();
+                    s.AsInsertable.ExecuteCommand();
+                    s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                }
+            }
 
             //    });
             //if (!dbTran.IsSuccess)
@@ -381,7 +386,7 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public ApiAction GetSupplier(U9C_MES_Input input)
+        public ApiAction GetSupplier(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"渚涘簲鍟嗕俊鎭紑濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -417,27 +422,27 @@
             //var dbTran = db.UseTran(() =>
             // {
             if (items.Any())
+            {
+                if (items.Count > 100)
                 {
-                    if (items.Count > 100)
+                    db.Utilities.PageEach(items, 100, pageList =>
                     {
-                        db.Utilities.PageEach(items, 100, pageList =>
-                        {
-                            var y = db.Storageable(pageList, "U9C")
-                                   .WhereColumns(t => new { t.SUPP_CODE, t.GHOST_ROW })
-                                   .ToStorage();
-                            y.AsInsertable.ExecuteCommand();
-                            y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                        });
-                    }
-                    else
-                    {
-                        var s = db.Storageable(items, "U9C")
+                        var y = db.Storageable(pageList, "U9C")
                                .WhereColumns(t => new { t.SUPP_CODE, t.GHOST_ROW })
                                .ToStorage();
-                        s.AsInsertable.ExecuteCommand();
-                        s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                    }
+                        y.AsInsertable.ExecuteCommand();
+                        y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                    });
                 }
+                else
+                {
+                    var s = db.Storageable(items, "U9C")
+                           .WhereColumns(t => new { t.SUPP_CODE, t.GHOST_ROW })
+                           .ToStorage();
+                    s.AsInsertable.ExecuteCommand();
+                    s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                }
+            }
 
             //});
             //if (!dbTran.IsSuccess)
@@ -455,7 +460,7 @@
         /// </summary>
         /// <param name="input"></param>
         /// <returns></returns>
-        public ApiAction GetCustBarCode(U9C_MES_Input input)
+        public ApiAction GetCustBarCode(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"瀹㈡埛鏉$爜淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -465,6 +470,7 @@
             List<MES_CUST_SN> items = new();
             if (list != null && list.Count > 0)
             {
+                Logger.Scheduler.Info($"鑾峰彇瀹㈡埛鏉$爜淇℃伅锛歔{list.ToJson()}]");
                 foreach (var item in list)
                 {
                     var d = item as System.Dynamic.ExpandoObject;
@@ -495,28 +501,28 @@
             db = Biz.Db;
             //var dbTran = db.UseTran(() =>
             //{
-                if (items.Any())
+            if (items.Any())
+            {
+                if (items.Count > 100)
                 {
-                    if (items.Count > 100)
-                    {
-                      db.Utilities.PageEach(items, 100, pageList =>
-                        {
-                            var y = db.Storageable(pageList, "U9C")
-                                   .WhereColumns(t => new { t.CUST_SN, t.GHOST_ROW })
-                                   .ToStorage();
-                            y.AsInsertable.ExecuteCommand();
-                            y.AsUpdateable.IgnoreColumns(x => x.ID).UpdateColumns(q => new { q.CUST_CODE,q.WORK_ORDER,q.CUST_SN,q.FLOW_SN,q.ITEM_CODE,q.CREATE_TIME,q.UPDATE_TIME,q.UPDATE_USER,q.AUTH_ORG}).ExecuteCommand();
-                        });
-                    }
-                    else
-                    {
-                        var s = db.Storageable(items, "U9C")
-                               .WhereColumns(t => new { t.CUST_SN, t.GHOST_ROW })
-                               .ToStorage();
-                        s.AsInsertable.ExecuteCommand();
-                        s.AsUpdateable.IgnoreColumns(x => x.ID).UpdateColumns(q => new { q.CUST_CODE, q.WORK_ORDER, q.CUST_SN, q.FLOW_SN, q.ITEM_CODE, q.CREATE_TIME, q.UPDATE_TIME, q.UPDATE_USER, q.AUTH_ORG }).ExecuteCommand();
-                    }
+                    db.Utilities.PageEach(items, 100, pageList =>
+                      {
+                          var y = db.Storageable(pageList, "U9C")
+                                 .WhereColumns(t => new { t.CUST_SN, t.GHOST_ROW })
+                                 .ToStorage();
+                          y.AsInsertable.ExecuteCommand();
+                          y.AsUpdateable.IgnoreColumns(x => x.ID).UpdateColumns(q => new { q.CUST_CODE, q.WORK_ORDER, q.CUST_SN, q.FLOW_SN, q.ITEM_CODE, q.CREATE_TIME, q.UPDATE_TIME, q.UPDATE_USER, q.AUTH_ORG }).ExecuteCommand();
+                      });
                 }
+                else
+                {
+                    var s = db.Storageable(items, "U9C")
+                           .WhereColumns(t => new { t.CUST_SN, t.GHOST_ROW })
+                           .ToStorage();
+                    s.AsInsertable.ExecuteCommand();
+                    s.AsUpdateable.IgnoreColumns(x => x.ID).UpdateColumns(q => new { q.CUST_CODE, q.WORK_ORDER, q.CUST_SN, q.FLOW_SN, q.ITEM_CODE, q.CREATE_TIME, q.UPDATE_TIME, q.UPDATE_USER, q.AUTH_ORG }).ExecuteCommand();
+                }
+            }
 
             //});
             //if (!dbTran.IsSuccess)
@@ -529,7 +535,7 @@
             return action;
         }
 
-        public ApiAction GetU9CBasWo(U9C_MES_Input input)
+        public ApiAction GetU9CBasWo(U9C_Base_Input input)
         {
             var action = new ApiAction();
             Logger.Scheduler.Info($"宸ュ崟淇℃伅寮�濮嬪悓姝ャ�傘�傘�傛暟鎹鏌ヨ繘琛屼腑銆傘�傘��");
@@ -561,6 +567,7 @@
                             UPDATE_TIME = di["ModifiedOn"].ToDateTime(),
                             PLAN_START_TIME = di["CreatedOn"].ToDateTime(),
                             STATUS = 0,
+                            WS_CODE = di["Department"] == null ? "" : di["Department"].ToString(),
                             AUTH_ORG = orgs.Where(x => x.ID == orgId).Select(q => q.ORG_CODE).FirstOrDefault(),
                             SALES_ORDER = di["SrcDoc_SrcDocNo"] == null ? "" : di["SrcDoc_SrcDocNo"].ToString(),
                             SALES_REMARK = di["SoLineMemo"] == null ? "" : di["SoLineMemo"].ToString(),
@@ -585,28 +592,28 @@
             db = Biz.Db;
             //var dbTran = db.UseTran(() =>
             //{
-                if (items.Any())
+            if (items.Any())
+            {
+                if (items.Count > 100)
                 {
-                    if (items.Count > 100)
+                    db.Utilities.PageEach(items, 100, pageList =>
                     {
-                        db.Utilities.PageEach(items, 100, pageList =>
-                        {
-                            var y = db.Storageable(pageList, "U9C")
-                                   .WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW })
-                                   .ToStorage();
-                            y.AsInsertable.ExecuteCommand();
-                            y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                        });
-                    }
-                    else
-                    {
-                        var s = db.Storageable(items, "U9C")
+                        var y = db.Storageable(pageList, "U9C")
                                .WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW })
                                .ToStorage();
-                        s.AsInsertable.ExecuteCommand();
-                        s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
-                    }
+                        y.AsInsertable.ExecuteCommand();
+                        y.AsUpdateable.IgnoreColumns(x => x.ID).UpdateColumns(q => new { q.ORDER_NO, q.ORDER_TYPE, q.PLAN_QTY, q.CUST_CODE, q.ITEM_CODE, q.CREATE_TIME, q.UPDATE_TIME, q.PLAN_START_TIME, q.STATUS, q.WS_CODE, q.AUTH_ORG, q.SALES_ORDER, q.SALES_REMARK, q.SERIAL_NO, q.SN_PREFIX, q.CUST_PREFIX, q.SALES_CONTRACT }).ExecuteCommand();
+                    });
                 }
+                else
+                {
+                    var s = db.Storageable(items, "U9C")
+                           .WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW })
+                           .ToStorage();
+                    s.AsInsertable.ExecuteCommand();
+                    s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
+                }
+            }
 
             //});
             //if (!dbTran.IsSuccess)
@@ -632,7 +639,8 @@
                                 var rot = Biz.Db.Queryable<MES_PROD_OPER>()
                                 .GroupBy(x => new { x.PROD_CODE, x.ROT_ID })
                                 .Where(q => q.PROD_CODE == wo.ITEM_CODE)
-                                .Select(it => new {
+                                .Select(it => new
+                                {
                                     PROD_CODE = it.PROD_CODE,
                                     ROT_ID = it.ROT_ID
                                 })

--
Gitblit v1.9.3