From 298851147d2b187522b4cb4982257c258eaf173d Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Fri, 20 Oct 2023 10:13:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E5=BA=93=E5=AD=98=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=97=A5=E5=BF=97[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/BQ/VmiAsyncBalanceService.cs | 47 +++++++------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs index 6e2369f9..1184b5c5 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs @@ -95,7 +95,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ context.Database.UseTransaction(transaction); var vmiMessageRepo = context.Set(); var vmiLogRepo = context.Set(); - var vmiBalanceRepo = context.Set(); //读取可消费消息列表 + var vmiBalanceRepo = context.Set(); + //读取可消费消息列表 var messages = vmiMessageRepo.AsNoTracking().Where(o => !o.isConsumed).OrderBy(o => o.Number).Take(batchSize).ToList(); //没有可消费消息则返回 if (!messages.Any()) @@ -105,12 +106,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ } //缓存余额表 sw.Stop(); - this._logger.LogInformation($"缓存开始:{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000} 秒,{sw.ElapsedMilliseconds} 豪秒"); sw.Restart(); var balanceCachedList = vmiBalanceRepo.AsNoTracking() .ToDictionary(o => $"{o.DeliverBillType}.{o.CodeType}.{o.RealPartCode}.{o.VinCode}.{o.ErpToLoc}.{o.OrderNum}.{o.factory}.{o.Configcode}"); sw.Stop(); - this._logger.LogInformation($"缓存结束:{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000} 秒,{sw.ElapsedMilliseconds} 豪秒"); + this._logger.LogInformation($"缓存结束:{balanceCachedList.Count}条,耗时 {sw.ElapsedMilliseconds / 1000} 秒,{sw.ElapsedMilliseconds} 豪秒"); sw.Restart(); //设置数量为实际返回数量 fetchSize = messages.Count; @@ -140,9 +140,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ command.ExecuteNonQuery(); } } - //sw.Stop(); - //this._logger.LogInformation($"计时:{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000} 秒,{sw.ElapsedMilliseconds} 豪秒"); - //sw.Restart(); foreach (var item in list) { var message = item.VmiMessage; @@ -158,29 +155,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ o.OrderNum == log.OrderNum && o.factory == log.factory && o.Configcode == log.Configcode); - //sw.Stop(); - ////this._logger.LogInformation($"计时:{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000} 秒,{sw.ElapsedMilliseconds} 豪秒"); - //sw.Restart(); //数据库查找 if (balance == null) { - sw.Stop(); - //this._logger.LogInformation($"查询开始:{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000} 秒,{sw.ElapsedMilliseconds} 豪秒"); - sw.Restart(); - //balance = vmiBalanceRepo.AsNoTracking().FirstOrDefault( - // // balanceCachedList.Find( - // o => o.DeliverBillType == log.DeliverBillType && - // o.CodeType == log.CodeType && - // o.RealPartCode == log.RealPartCode && - // o.VinCode == log.VinCode && - // o.ErpToLoc == log.ErpToLoc && - // o.OrderNum == log.OrderNum && - // o.factory == log.factory && - // o.Configcode == log.Configcode); balance = balanceCachedList.GetValueOrDefault($"{log.DeliverBillType}.{log.CodeType}.{log.RealPartCode}.{log.VinCode}.{log.ErpToLoc}.{log.OrderNum}.{log.factory}.{log.Configcode}"); - sw.Stop(); - this._logger.LogInformation($"查询结束:{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000} 秒,{sw.ElapsedMilliseconds} 豪秒"); - sw.Restart(); + //if (balance == null) + //{ + // balance = vmiBalanceRepo.AsNoTracking().FirstOrDefault( + // // balanceCachedList.Find( + // o => o.DeliverBillType == log.DeliverBillType && + // o.CodeType == log.CodeType && + // o.RealPartCode == log.RealPartCode && + // o.VinCode == log.VinCode && + // o.ErpToLoc == log.ErpToLoc && + // o.OrderNum == log.OrderNum && + // o.factory == log.factory && + // o.Configcode == log.Configcode); + //} } if (balance == null) {//不存在库存记录 @@ -249,13 +240,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ // 更新库存 balance.Qty = currentQty + log.ChangedQty; } - //sw.Stop(); - ////this._logger.LogInformation($"准备1:{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000 / 60}分钟,{sw.ElapsedMilliseconds / 1000}秒"); - //sw.Restart(); } - //sw.Stop(); - //this._logger.LogInformation($"准备{fetchSize}条,耗时 {sw.ElapsedMilliseconds / 1000 / 60}分钟,{sw.ElapsedMilliseconds / 1000}秒"); - //sw.Restart(); //更新事务分表 foreach (var item in tables) {