|
|
@ -165,11 +165,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiBalance>> Balance(RequestDto input) |
|
|
|
public async Task<PagedResultDto<VmiBalanceDto>> Balance(RequestDto input) |
|
|
|
{ |
|
|
|
var entities = await _balanceRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false); |
|
|
|
var totalCount = await _balanceRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); |
|
|
|
return new PagedResultDto<VmiBalance>(totalCount, entities); |
|
|
|
|
|
|
|
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, o.VinCode }).Select(o => new VmiBalanceDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), LastTime = o.Max(o => o.ChangedTime) }).Where(p => p.Qty != 0); |
|
|
|
var totalCount = query2.Count(); |
|
|
|
//query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
|
|
|
|
//var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode,o.VinCode }).Select(o => new VmiBalanceDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty),LastTime=o.Max(o=>o.ChangedTime) });
|
|
|
|
//var totalCount = query2.Count();
|
|
|
|
var entities = await query2.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
//var entities = await _balanceRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
|
|
|
|
//var totalCount = await _balanceRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
|
|
|
|
return new PagedResultDto<VmiBalanceDto>(totalCount, entities); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -178,7 +196,20 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[HttpPost] |
|
|
|
public async Task<string> BalanceExport(RequestDto input) |
|
|
|
{ |
|
|
|
var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false); |
|
|
|
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 VinCode,ErpToLoc,RealPartCode,ChangedQty ,ChangedTime 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, o.VinCode }).Select(o => new VmiBalanceDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), LastTime = o.Max(o => o.ChangedTime) }).Where(p=>p.Qty!=0); |
|
|
|
var entities = query2.ToList(); |
|
|
|
|
|
|
|
// var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).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); |
|
|
@ -194,6 +225,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
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); |
|
|
@ -229,9 +264,6 @@ 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); |
|
|
@ -250,16 +282,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
return fileName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
|
|
|
|
//var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
|
|
|
|
//using var db = new SettleAccountDbContext(options);
|
|
|
@ -1129,6 +1151,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[Display(Name = "数量", Order = 10)] |
|
|
|
public decimal Qty { get; set; } |
|
|
|
} |
|
|
|
public class VmiBalanceDto |
|
|
|
{ |
|
|
|
[Display(Name = "生产码", Order = 1)] |
|
|
|
public string VinCode { get; set; } |
|
|
|
|
|
|
|
[Display(Name = "ERP库位", Order = 2)] |
|
|
|
public string ErpToLoc { get; set; } |
|
|
|
|
|
|
|
[Display(Name = "厂内零件号", Order = 3)] |
|
|
|
public string RealPartCode { get; set; }//原始
|
|
|
|
|
|
|
|
[Display(Name = "数量", Order = 4)] |
|
|
|
public decimal Qty { get; set; } |
|
|
|
|
|
|
|
[Display(Name = "最后更新时间", Order = 5)] |
|
|
|
public DateTime? LastTime { get; set; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|