From b9253963225e603ea9e598117c7baf92a704fd54 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Fri, 20 Oct 2023 13:30:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=91=E7=A5=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90=E4=B8=AD=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/models/_options.js | 1 + .../Entities/BQ/VmiAsyncBalanceService.cs | 33 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js index 1720a60f..00d0d30c 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js @@ -172,6 +172,7 @@ const invState = { { value: 7, label: "撤销扣减进行中" }, { value: 8, label: "已提交QAD" }, { value: 9, label: "红冲" }, + { value: 10, label: "生成发票中" }, ], }; 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 1184b5c5..753166e7 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 @@ -76,6 +76,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ var batchSize = 10000; var fetchSize = 0; var connectionString = serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); + Dictionary balanceCachedList = null; for (var i = 0; i < 1000; i++) { //1:新建 2:更新 @@ -105,13 +106,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ break; } //缓存余额表 - sw.Stop(); - 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($"缓存结束:{balanceCachedList.Count}条,耗时 {sw.ElapsedMilliseconds / 1000} 秒,{sw.ElapsedMilliseconds} 豪秒"); - sw.Restart(); + var sw2 = new Stopwatch(); + sw2.Start(); + Func keySelector = o => $"{o.DeliverBillType}.{o.CodeType}.{o.RealPartCode}.{o.VinCode}.{o.ErpToLoc}.{o.OrderNum}.{o.factory}.{o.Configcode}"; + //if (balanceCachedList == null) + //{ + balanceCachedList = vmiBalanceRepo.AsNoTracking().ToDictionary(keySelector); + //} + sw2.Stop(); + this._logger.LogInformation($"缓存结束:{balanceCachedList.Count}条,耗时 {sw2.ElapsedMilliseconds / 1000} 秒,{sw2.ElapsedMilliseconds} 豪秒"); //设置数量为实际返回数量 fetchSize = messages.Count; //反序列化获取库存事务 @@ -250,14 +253,24 @@ namespace Win.Sfs.SettleAccount.Entities.BQ //批量插入负库存补货记录 await context.BulkInsertAsync(vmiReplenishedList).ConfigureAwait(false); //批量插入库存余额 - await context.BulkInsertAsync(balanceList.Where(o => o.Item2 == 1 && o.Item1.Qty != decimal.Zero).Select(o => o.Item1).ToList()).ConfigureAwait(false); + var addList = balanceList.Where(o => o.Item2 == 1 && o.Item1.Qty != decimal.Zero).Select(o => o.Item1).ToList(); + await context.BulkInsertAsync(addList).ConfigureAwait(false); //批量更新库存余额 - await context.BulkUpdateAsync(balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty != decimal.Zero).Select(o => o.Item1).ToList()).ConfigureAwait(false); + var editList = balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty != decimal.Zero).Select(o => o.Item1).ToList(); + await context.BulkUpdateAsync(editList).ConfigureAwait(false); //批量删除库存余额 - await context.BulkDeleteAsync(balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty == decimal.Zero).Select(o => o.Item1).ToList()).ConfigureAwait(false); + var removeList = balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty == decimal.Zero).Select(o => o.Item1).ToList(); + await context.BulkDeleteAsync(removeList).ConfigureAwait(false); //批量删除消息 await context.BulkDeleteAsync(messages).ConfigureAwait(false); transaction.Commit(); + ////更新余额缓存 + //var sw3 = new Stopwatch(); + //sw3.Start(); + //addList.ForEach(o => balanceCachedList.Add(keySelector(o), o)); + //removeList.ForEach(o => balanceCachedList.Remove(keySelector(o))); + //sw3.Stop(); + //this._logger.LogInformation($"更新缓存:{balanceList.Count}条,耗时 {sw3.ElapsedMilliseconds / 1000} 秒,{sw3.ElapsedMilliseconds} 豪秒"); } catch (Exception ex) {