From 0e17f5d5afb9e21500390cedb83fb5e1af0ded1d Mon Sep 17 00:00:00 2001 From: YangYuGang <1378265336@qq.com> Date: 星期三, 19 三月 2025 18:06:04 +0800 Subject: [PATCH] 分页存储优化 --- Tiger.Business.MES/iERP/U9C_MES.cs | 148 ++++++++++++------------------------------------- 1 files changed, 36 insertions(+), 112 deletions(-) diff --git a/Tiger.Business.MES/iERP/U9C_MES.cs b/Tiger.Business.MES/iERP/U9C_MES.cs index 8f4f490..318ccf2 100644 --- a/Tiger.Business.MES/iERP/U9C_MES.cs +++ b/Tiger.Business.MES/iERP/U9C_MES.cs @@ -91,47 +91,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 +188,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(); + }); } }); @@ -349,25 +316,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(); + }); } // }); @@ -423,25 +379,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(); + }); } //}); @@ -491,6 +436,7 @@ CREATE_TIME = di["CreatedOn"].ToDateTime(), UPDATE_TIME = di["ModifiedOn"].ToDateTime(), AUTH_ORG = _MES_WO?.AUTH_ORG, + CREATE_USER = "U9C" //鍚屾椂缁機REATE_USER鍜孋REATE_TIME璧嬪�硷紝鍒欎笉浼氳鏇存柊锛屼繚鐣欐墍璧嬬殑鍊� }; items.Add(snItem); } @@ -503,25 +449,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(); + }); } //}); @@ -594,25 +529,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(); + }); } //}); -- Gitblit v1.9.3