|
|
@ -293,6 +293,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiLog>> Log(LogRequestDto input) |
|
|
|
{ |
|
|
|
if (input.UseHistory) |
|
|
|
{ |
|
|
|
return await Log2(input).ConfigureAwait(false); |
|
|
|
} |
|
|
|
//按季度计算查询需要 union 的表名
|
|
|
|
var start = DateTime.Parse(input.Filters.FirstOrDefault(o => o.Column == "changedTime" && o.Action == EnumFilterAction.BiggerThanOrEqual).Value); |
|
|
|
var end = DateTime.Parse(input.Filters.FirstOrDefault(o => o.Column == "changedTime" && o.Action == EnumFilterAction.SmallThan).Value); |
|
|
@ -348,7 +352,34 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 3.1库存事务导出
|
|
|
|
/// 3.1 库存事务查询(不分表)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiLog>> Log2(LogRequestDto input) |
|
|
|
{ |
|
|
|
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService"); |
|
|
|
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options; |
|
|
|
using var db = new SettleAccountDbContext(options); |
|
|
|
var query = db.Set<VmiLog>().FromSqlRaw("select * from Set_VmiLog WITH(NOLOCK)"); |
|
|
|
var filters = input.Filters.ToLambda<VmiLog>(); |
|
|
|
if (input.Filters.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiLog>()); |
|
|
|
} |
|
|
|
if (input.LogTypes.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(o => input.LogTypes.Contains(o.LogType)); |
|
|
|
} |
|
|
|
var totalCount = query.Count(); |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); |
|
|
|
var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
return new PagedResultDto<VmiLog>(totalCount, entities); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 3.2库存事务导出
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<string> LogExport(RequestDto input) |
|
|
@ -565,7 +596,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
var batchSize = 10000; |
|
|
|
var fetchSize = 0; |
|
|
|
var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService"); |
|
|
|
while(true) |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
var balanceList = new List<Tuple<VmiBalance, int>>(); |
|
|
|
var sw = new Stopwatch(); |
|
|
@ -678,7 +709,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<Tuple<T, List<ValidationResult>>> ImportInternal<T>(byte[] data) |
|
|
|
{ |
|
|
|
var list = new List<Tuple<T, List<ValidationResult>>>(); |
|
|
@ -839,6 +869,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
public class LogRequestDto : RequestDto |
|
|
|
{ |
|
|
|
public List<VmiLogType> LogTypes { get; set; } = new List<VmiLogType>(); |
|
|
|
public bool UseHistory { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
public class VmiBalanceSumDto |
|
|
|