Browse Source

精简库存同步日志[CI SKIP]

master
wanggang 1 year ago
parent
commit
298851147d
  1. 47
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs

47
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<VmiMessage>();
var vmiLogRepo = context.Set<VmiLog>();
var vmiBalanceRepo = context.Set<VmiBalance>(); //读取可消费消息列表
var vmiBalanceRepo = context.Set<VmiBalance>();
//读取可消费消息列表
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)
{

Loading…
Cancel
Save