服务端的TigerApi 框架,基于.NET6 2024 版本
Tiger.Business.MES/iERP/U9C_MES.cs
@@ -28,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($"物料信息开始同步。。。数据检查进行中。。。");
@@ -65,6 +65,7 @@
                            AUTH_ORG = orgs.Where(x => x.ID == orgId).Select(q => q.ORG_CODE).FirstOrDefault(),
                            CUST_PROD_CODE = di["CustomerItem"] == null ? "" : di["CustomerItem"].ToString(),
                            RULE_CODE = di["BarRule"] == null ? "" : di["BarRule"].ToString(),
                            DEFAULT_LOCATION = di["BinCode"] == null ? "" : di["BinCode"].ToString(),
                        };
                        items.Add(basItem);
                        var extInfo = new BAS_ITEM_EXT()
@@ -80,6 +81,7 @@
                            Remark = (di["Remark"] ?? "").ToString(),
                            Packaging = (di["Packaging"] ?? "").ToString(),
                            SapCode = (di["Code1"] ?? "").ToString(),
                            ReceiptMode = (di["ReceiptMode"] ?? "").ToInt32(),
                        };
                        itemExts.Add(extInfo);
                    }
@@ -91,47 +93,25 @@
            //{
            if (items.Any())
            {
                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())
            {
                if (itemExts.Count > 100)
                db.Utilities.PageEach(itemExts, 100, pageList =>
                {
                    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")
                    var y = db.Storageable(pageList, "U9C")
                           .WhereColumns(t => new { t.ITEM_ID, t.GHOST_ROW })
                           .ToStorage();
                    s.AsInsertable.ExecuteCommand();
                    s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
                }
                    y.AsInsertable.ExecuteCommand();
                    y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand();
                });
            }
            //});
            //if (!dbTran.IsSuccess)
@@ -210,25 +190,14 @@
                db.Storageable(LastRun, "U9C_MES_GetWo").ExecuteCommand();
                if (items.Any())
                {
                    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).ExecuteCommand();
                    });
                }
            });
@@ -309,7 +278,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($"客户信息开始同步。。。数据检查进行中。。。");
@@ -349,25 +318,14 @@
            //    {
            if (items.Any())
            {
                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.CUST_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.CUST_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();
                });
            }
            //    });
@@ -386,7 +344,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($"供应商信息开始同步。。。数据检查进行中。。。");
@@ -423,25 +381,14 @@
            // {
            if (items.Any())
            {
                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();
                });
            }
            //});
@@ -460,7 +407,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($"客户条码信息开始同步。。。数据检查进行中。。。");
@@ -470,6 +417,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;
@@ -490,6 +438,7 @@
                                CREATE_TIME = di["CreatedOn"].ToDateTime(),
                                UPDATE_TIME = di["ModifiedOn"].ToDateTime(),
                                AUTH_ORG = _MES_WO?.AUTH_ORG,
                                CREATE_USER = "U9C" //同时给CREATE_USER和CREATE_TIME赋值,则不会被更新,保留所赋的值
                            };
                            items.Add(snItem);
                        }
@@ -502,25 +451,14 @@
            //{
            if (items.Any())
            {
                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.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")
                    var y = db.Storageable(pageList, "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();
                }
                    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.UPDATE_TIME, q.UPDATE_USER, q.AUTH_ORG }).ExecuteCommand();
                });
            }
            //});
@@ -534,7 +472,7 @@
            return action;
        }
        public ApiAction GetU9CBasWo(U9C_MES_Input input)
        public ApiAction GetU9CBasWo(U9C_Base_Input input)
        {
            var action = new ApiAction();
            Logger.Scheduler.Info($"工单信息开始同步。。。数据检查进行中。。。");
@@ -593,25 +531,14 @@
            //{
            if (items.Any())
            {
                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).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")
                    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();
                });
            }
            //});
@@ -687,29 +614,6 @@
                    }
                });
            }
            return action;
        }
        /// <summary>
        /// 同步物料条码信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public ApiAction GetMaterialBarCode(U9C_MES_Input input)
        {
            var action = new ApiAction();
            Logger.Scheduler.Info($"物料条码信息开始同步。。。数据检查进行中。。。");
            Logger.Scheduler.Info($"{input.triggerDetail}");
            DbClient db = Biz.DataSource["YadaU9C"].Client;
            try
            {
                var list = db.Queryable<mes_MaterialBarCode>().Where("ModifiedOn > @startTime And ModifiedOn < @endTime", new { startTime = input.startTime, endTime = input.endTime }).ToList();
            }
            catch (Exception ex)
            {
                action.CatchExceptionWithLog(ex, Biz.L(ex.Message));
            }
            return action;
        }
    }