From f4327aac4db2b625aa8254206ea37b46126b5592 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期四, 26 十二月 2024 21:25:33 +0800 Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/Server/TigerApi6_2024 --- Tiger.Business.MES/iERP/U9C_MES.cs | 187 ++++++++++++++++++++++------------------------ 1 files changed, 90 insertions(+), 97 deletions(-) diff --git a/Tiger.Business.MES/iERP/U9C_MES.cs b/Tiger.Business.MES/iERP/U9C_MES.cs index c337fc4..be930b5 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 { @@ -77,48 +78,49 @@ Accuracy = (di["Accuracy"] ?? "").ToString(), Remark = (di["Remark"] ?? "").ToString(), Packaging = (di["Packaging"] ?? "").ToString(), + SapCode = (di["Code1"] ?? "").ToString(), }; itemExts.Add(extInfo); } } } Logger.Scheduler.Info($"鐗╂枡淇℃伅瀛樺叆瀹炰綋涓紝鎬绘暟锛歔{items.Count}]"); - var dbTran = db.UseTran(() => - { + db = Biz.Db; + //var dbTran = db.UseTran(() => + //{ 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.IgnoreColumns(x => x.ID).ExecuteCommand(); + }); } else { @@ -129,13 +131,14 @@ s.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); } } - }); - if (!dbTran.IsSuccess) - { - action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); - Logger.Scheduler.Error(action.Message); - } + //}); + //if (!dbTran.IsSuccess) + //{ + // action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); + // Logger.Scheduler.Error(action.Message); + //} Logger.Scheduler.Info($"鐗╂枡淇℃伅瀛樺叆鏁版嵁搴擄紝鎬绘暟锛歔{items.Count}]"); + action.Message = $"鐗╂枡淇℃伅瀛樺叆鏁版嵁搴擄紝鎬绘暟锛歔{items.Count}]"; return action; } @@ -205,15 +208,15 @@ db.Storageable(LastRun, "U9C_MES_GetWo").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.ORDER_NO, t.GHOST_ROW }) .ToStorage(); - y.BulkCopy(); - y.BulkUpdate(); + y.AsInsertable.ExecuteCommand(); + y.AsUpdateable.IgnoreColumns(x => x.ID).ExecuteCommand(); }); } else @@ -282,11 +285,7 @@ { if (woList.Any()) { - var s = _db.Storageable(woList, "U9C") - .WhereColumns(t => new { t.ORDER_NO, t.GHOST_ROW }) - .ToStorage(); - s.AsInsertable.ExecuteCommand(); - s.AsUpdateable.IgnoreColumns(x => x.ID).UpdateColumns(x => new { x.ROUTE_STATUS}).ExecuteCommand(); + _db.Updateable(woList, "U9C").UpdateColumns(x => new { x.ROUTE_STATUS }).ExecuteCommand(); } }); @@ -341,22 +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(); + //var dbTran = db.UseTran(() => + // { 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 @@ -369,13 +365,14 @@ } } - }); - if (!dbTran.IsSuccess) - { - action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); - Logger.Scheduler.Error(action.Message); - } + // }); + //if (!dbTran.IsSuccess) + //{ + // action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); + // Logger.Scheduler.Error(action.Message); + //} Logger.Scheduler.Info($"瀹㈡埛淇℃伅瀛樺叆鏁版嵁搴擄紝鎬绘暟锛歔{items.Count}]"); + action.Message = $"瀹㈡埛淇℃伅瀛樺叆鏁版嵁搴擄紝鎬绘暟锛歔{items.Count}]"; return action; } @@ -417,22 +414,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()) + //var dbTran = db.UseTran(() => + // { + 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 @@ -445,13 +439,14 @@ } } - }); - if (!dbTran.IsSuccess) - { - action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); - Logger.Scheduler.Error(action.Message); - } + //}); + //if (!dbTran.IsSuccess) + //{ + // action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); + // Logger.Scheduler.Error(action.Message); + //} Logger.Scheduler.Info($"渚涘簲鍟嗕俊鎭瓨鍏ユ暟鎹簱锛屾�绘暟锛歔{items.Count}]"); + action.Message = $"渚涘簲鍟嗕俊鎭瓨鍏ユ暟鎹簱锛屾�绘暟锛歔{items.Count}]"; return action; } @@ -498,22 +493,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(); + //var dbTran = db.UseTran(() => + //{ 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).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 @@ -522,17 +514,18 @@ .WhereColumns(t => new { t.CUST_SN, t.GHOST_ROW }) .ToStorage(); s.AsInsertable.ExecuteCommand(); - s.AsUpdateable.IgnoreColumns(x => x.ID).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) - { - action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); - Logger.Scheduler.Error(action.Message); - } + //}); + //if (!dbTran.IsSuccess) + //{ + // action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); + // Logger.Scheduler.Error(action.Message); + //} Logger.Scheduler.Info($"瀹㈡埛鏉$爜淇℃伅瀛樺叆鏁版嵁搴擄紝鎬绘暟锛歔{items.Count}]"); + action.Message = $"瀹㈡埛鏉$爜淇℃伅瀛樺叆鏁版嵁搴擄紝鎬绘暟锛歔{items.Count}]"; return action; } @@ -576,7 +569,7 @@ CUST_PREFIX = di["OutBarHead"] == null ? "" : di["OutBarHead"].ToString(), SALES_CONTRACT = di["Contracts"] == null ? "" : di["Contracts"].ToString(), }; - if (!Biz.Db.Queryable<BIZ_MES_WO>().Any(x => x.ORDER_NO == woItem.ORDER_NO && (x.STATUS > BIZ_MES_WO.STATUSs.Init.GetValue() || x.ROUTE_STATUS > BIZ_MES_WO.ROUTE_STATUSs.WaitSet.GetValue()))) + if (!Biz.Db.Queryable<BIZ_MES_WO>().Any(x => x.ORDER_NO == woItem.ORDER_NO && x.STATUS > BIZ_MES_WO.STATUSs.Imported.GetValue())) { items.Add(woItem); } @@ -590,19 +583,19 @@ } Logger.Scheduler.Info($"宸ュ崟淇℃伅瀛樺叆瀹炰綋涓紝鎬绘暟锛歔{items.Count}]"); db = Biz.Db; - var dbTran = db.UseTran(() => - { + //var dbTran = db.UseTran(() => + //{ 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 @@ -615,12 +608,12 @@ } } - }); - if (!dbTran.IsSuccess) - { - action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); - Logger.Scheduler.Error(action.Message); - } + //}); + //if (!dbTran.IsSuccess) + //{ + // action.CatchExceptionWithLog(dbTran.ErrorException, $"鏁版嵁澶勭悊澶辫触"); + // Logger.Scheduler.Error(action.Message); + //} action.Message = $"宸ュ崟淇℃伅瀛樺叆鏁版嵁搴擄紝鎬绘暟锛歔{items.Count}]"; Logger.Scheduler.Info($"{action.Message}"); if (action.IsSuccessed && items.Count > 0) -- Gitblit v1.9.3