|
|
@ -193,18 +193,32 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiBalanceSumDto>> BalanceSum(RequestDto 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<VmiBalance>().FromSqlRaw("select * from Set_VmiBalance"); |
|
|
|
var filters = input.Filters.ToLambda<VmiBalance>(); |
|
|
|
var query = db.Set<VmiLog>().FromSqlRaw("select * from Set_VmiLog"); |
|
|
|
var filters = input.Filters.ToLambda<VmiLog>(); |
|
|
|
if (input.Filters.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiBalance>()); |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiLog>()); |
|
|
|
} |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); |
|
|
|
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) }); |
|
|
|
var totalCount = query2.Count(); |
|
|
|
query2 = string.IsNullOrEmpty(input.Sorting) ? query2 : DynamicQueryableExtensions.OrderBy(query2, input.Sorting); |
|
|
|
|
|
|
|
//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<VmiBalance>().FromSqlRaw("select * from Set_VmiBalance");
|
|
|
|
//var filters = input.Filters.ToLambda<VmiBalance>();
|
|
|
|
//if (input.Filters.Count > 0)
|
|
|
|
//{
|
|
|
|
// query = query.Where(input.Filters.ToLambda<VmiBalance>());
|
|
|
|
//}
|
|
|
|
//var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) });
|
|
|
|
//var totalCount = query2.Count();
|
|
|
|
//query2 = string.IsNullOrEmpty(input.Sorting) ? query2 : DynamicQueryableExtensions.OrderBy(query2, input.Sorting);
|
|
|
|
var entities = await query2.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
return new PagedResultDto<VmiBalanceSumDto>(totalCount, entities); |
|
|
|
} |
|
|
@ -215,14 +229,69 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[HttpPost] |
|
|
|
public async Task<string> BalanceSumExport(RequestDto 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<VmiBalance>().FromSqlRaw("select * from Set_VmiBalance"); |
|
|
|
var filters = input.Filters.ToLambda<VmiBalance>(); |
|
|
|
var query = db.Set<VmiLog>().FromSqlRaw("select * from Set_VmiLog"); |
|
|
|
var filters = input.Filters.ToLambda<VmiLog>(); |
|
|
|
if (input.Filters.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiBalance>()); |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiLog>()); |
|
|
|
} |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); |
|
|
|
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) }); |
|
|
|
var totalCount = query2.Count(); |
|
|
|
var entities = await query2.ToListAsync().ConfigureAwait(false); var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx"; |
|
|
|
var content = this.GetContent(entities, "库存汇总"); |
|
|
|
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); |
|
|
|
return fileName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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<VmiBalance>().FromSqlRaw("select * from Set_VmiBalance");
|
|
|
|
//var filters = input.Filters.ToLambda<VmiBalance>();
|
|
|
|
//if (input.Filters.Count > 0)
|
|
|
|
//{
|
|
|
|
// query = query.Where(input.Filters.ToLambda<VmiBalance>());
|
|
|
|
//}
|
|
|
|
//query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
|
|
|
|
//var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) });
|
|
|
|
//var totalCount = query2.Count();
|
|
|
|
//var entities = await query2.ToListAsync().ConfigureAwait(false); var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx";
|
|
|
|
//var content = this.GetContent(entities, "库存汇总");
|
|
|
|
//await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
|
|
|
|
//return fileName;
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 1.2库存余额汇总导出
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<string> BalanceSumByLogExport(RequestDto 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"); |
|
|
|
var filters = input.Filters.ToLambda<VmiLog>(); |
|
|
|
if (input.Filters.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiLog>()); |
|
|
|
} |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); |
|
|
|
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty) }); |
|
|
@ -233,6 +302,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
return fileName; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 快照列表
|
|
|
|
/// </summary>
|
|
|
@ -1051,4 +1129,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[Display(Name = "数量", Order = 10)] |
|
|
|
public decimal Qty { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|