From 96e980330268e93e4b65e428f2a26e74ca992ed7 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 28 十月 2024 11:11:32 +0800 Subject: [PATCH] 计划任务改写 --- Tiger.Business.MES/iERP/U9C_MES.cs | 84 ++++++++++++++++++------------------------ 1 files changed, 36 insertions(+), 48 deletions(-) diff --git a/Tiger.Business.MES/iERP/U9C_MES.cs b/Tiger.Business.MES/iERP/U9C_MES.cs index c337fc4..ba786d4 100644 --- a/Tiger.Business.MES/iERP/U9C_MES.cs +++ b/Tiger.Business.MES/iERP/U9C_MES.cs @@ -16,6 +16,7 @@ using Tiger.Model.Entitys.MES.Position; using Apache.NMS.ActiveMQ.Commands; using System.Security.Cryptography; +using System.Diagnostics; namespace Tiger.Business.MES { @@ -87,38 +88,37 @@ { if (items.Any()) { - if (items.Count > 150) + if (items.Count > 100) { - db.Utilities.PageEach(items, 1000, pageList => + db.Utilities.PageEach(items, 100, pageList => { var y = db.Storageable(pageList, "U9C") .WhereColumns(t => new { t.ID, t.GHOST_ROW }) .ToStorage(); - y.BulkCopy(); - y.BulkUpdate(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.ExecuteCommand(); }); } - else - { - var s = db.Storageable(items, "U9C") - .WhereColumns(t => new { t.ID, t.GHOST_ROW }) - .ToStorage(); - s.AsInsertable.ExecuteCommand(); - s.AsUpdateable.ExecuteCommand(); + else { + 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 > 150) + if (itemExts.Count > 100) { - db.Utilities.PageEach(itemExts, 1000, pageList => - { - var y = db.Storageable(pageList, "U9C") - .WhereColumns(t => new { t.ITEM_ID, t.GHOST_ROW }) - .ToStorage(); - y.BulkCopy(); - y.BulkUpdate(); - }); + 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.ExecuteCommand(); + }); } else { @@ -340,23 +340,19 @@ } } Logger.Scheduler.Info($"瀹㈡埛淇℃伅瀛樺叆瀹炰綋涓紝鎬绘暟锛歔{items.Count}]"); - db = Biz.Db; - var LastRun = db.Queryable<SYS_PARAM>().Where(q => q.PRMG_CODE == "Interface_LastRun" && q.PARAM_CODE == "GetCust_LastRun").Single(); - LastRun.PARAM_VALUE = (input.endTime.ToDateTime() - DateTime.Now).TotalMinutes > 0 ? LastRun.PARAM_VALUE : input.endTime; var dbTran = db.UseTran(() => { - db.Storageable(LastRun, "U9C_MES_GetCustomer").ExecuteCommand(); if (items.Any()) { - if (items.Count > 150) + if (items.Count > 100) { - db.Utilities.PageEach(items, 1000, pageList => + db.Utilities.PageEach(items, 100, pageList => { var y = db.Storageable(pageList, "U9C") .WhereColumns(t => new { t.CUST_CODE, t.GHOST_ROW }) .ToStorage(); - y.BulkCopy(); - y.BulkUpdate(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); }); } else @@ -416,23 +412,19 @@ } } Logger.Scheduler.Info($"渚涘簲鍟嗕俊鎭瓨鍏ュ疄浣撲腑锛屾�绘暟锛歔{items.Count}]"); - db = Biz.Db; - var LastRun = db.Queryable<SYS_PARAM>().Where(q => q.PRMG_CODE == "Interface_LastRun" && q.PARAM_CODE == "Vender_LastTime").Single(); - LastRun.PARAM_VALUE = (input.endTime.ToDateTime() - DateTime.Now).TotalMinutes > 0 ? LastRun.PARAM_VALUE : input.endTime; var dbTran = db.UseTran(() => { - db.Storageable(LastRun, "U9C_MES_GetCustomer").ExecuteCommand(); if (items.Any()) { - if (items.Count > 150) + if (items.Count > 100) { - db.Utilities.PageEach(items, 1000, pageList => + db.Utilities.PageEach(items, 100, pageList => { var y = db.Storageable(pageList, "U9C") .WhereColumns(t => new { t.SUPP_CODE, t.GHOST_ROW }) .ToStorage(); - y.BulkCopy(); - y.BulkUpdate(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); }); } else @@ -497,23 +489,19 @@ } } Logger.Scheduler.Info($"瀹㈡埛鏉$爜淇℃伅瀛樺叆瀹炰綋涓紝鎬绘暟锛歔{items.Count}]"); - db = Biz.Db; - var LastRun = db.Queryable<SYS_PARAM>().Where(q => q.PRMG_CODE == "Interface_LastRun" && q.PARAM_CODE == "GetCustBar_LastTime").Single(); - LastRun.PARAM_VALUE = (input.endTime.ToDateTime() - DateTime.Now).TotalMinutes > 0 ? LastRun.PARAM_VALUE : input.endTime; var dbTran = db.UseTran(() => { - db.Storageable(LastRun, "U9C_MES_GetCustomer").ExecuteCommand(); if (items.Any()) { - if (items.Count > 150) + if (items.Count > 100) { - db.Utilities.PageEach(items, 1000, pageList => + db.Utilities.PageEach(items, 100, pageList => { var y = db.Storageable(pageList, "U9C") .WhereColumns(t => new { t.CUST_SN, t.GHOST_ROW }) .ToStorage(); - y.BulkCopy(); - y.BulkUpdate(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); }); } else @@ -594,15 +582,15 @@ { if (items.Any()) { - if (items.Count > 150) + if (items.Count > 100) { - db.Utilities.PageEach(items, 1000, pageList => + db.Utilities.PageEach(items, 100, pageList => { var y = db.Storageable(pageList, "U9C") .WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW }) .ToStorage(); - y.BulkCopy(); - y.BulkUpdate(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); }); } else -- Gitblit v1.9.3