|
|
@ -72,6 +72,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
private readonly INormalEfCoreRepository<VmiBalance, Guid> _balanceRepository; |
|
|
|
private readonly INormalEfCoreRepository<VmiLog, Guid> _logRepository; |
|
|
|
private readonly INormalEfCoreRepository<CodeSetting, Guid> _codeRepository; |
|
|
|
private readonly INormalEfCoreRepository<VmiBalanceSumDetail, Guid> _vmiBalanceSumDetailRepository; |
|
|
|
private readonly INormalEfCoreRepository<VmiBalanceSum, Guid> _vmiBalanceSumRepository; |
|
|
|
|
|
|
|
|
|
|
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|
|
|
private readonly IHubContext<PageHub> _hubContext; |
|
|
|
private readonly ICurrentUser _currentUser; |
|
|
@ -83,9 +87,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
public VmiAppService(IConfiguration cfg, |
|
|
|
IServiceProvider serviceProvider, |
|
|
|
IGuidGenerator guidGenerator, |
|
|
|
INormalEfCoreRepository<VmiBalanceSum, Guid> vmiBalanceSumRepository, |
|
|
|
INormalEfCoreRepository<VmiBalance, Guid> balanceRepository, |
|
|
|
INormalEfCoreRepository<VmiLog, Guid> logRepository, |
|
|
|
INormalEfCoreRepository<CodeSetting, Guid> codeRepository, |
|
|
|
INormalEfCoreRepository<VmiBalanceSumDetail, Guid> vmiBalanceSumDetailRepository, |
|
|
|
IBlobContainer<MyFileContainer> fileContainer, |
|
|
|
Volo.Abp.ObjectMapping.IObjectMapper maper, |
|
|
|
IHubContext<PageHub> hubContext, |
|
|
@ -98,6 +104,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
) |
|
|
|
|
|
|
|
{ |
|
|
|
_vmiBalanceSumRepository = vmiBalanceSumRepository; |
|
|
|
_vmiBalanceSumDetailRepository = vmiBalanceSumDetailRepository; |
|
|
|
_maper = maper; |
|
|
|
this._codeRepository = codeRepository; |
|
|
|
this._cfg = cfg; |
|
|
@ -200,21 +208,25 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiBalanceSumDetailDto>> Balance(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<VmiBalanceSumDetail>().AsQueryable(); |
|
|
|
|
|
|
|
var filters = input.Filters.ToLambda<VmiBalanceSumDetailDto>(); |
|
|
|
if (input.Filters.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiBalanceSumDetailDto>()); |
|
|
|
} |
|
|
|
var totalCount = query.Count(); |
|
|
|
//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<VmiBalanceSumDetail>().AsQueryable();
|
|
|
|
|
|
|
|
var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
// _maper.Map(VmiBalanceSumDetail,v)
|
|
|
|
//var filters = input.Filters.ToLambda<VmiBalanceSumDetailDto>();
|
|
|
|
//if (input.Filters.Count > 0)
|
|
|
|
//{
|
|
|
|
// query =_vmiBalanceSumDetailRepository.Where(filters);
|
|
|
|
//}
|
|
|
|
//var totalCount = query.Count();
|
|
|
|
|
|
|
|
//var entities = await query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false);
|
|
|
|
//// _maper.Map(VmiBalanceSumDetail,v)
|
|
|
|
///
|
|
|
|
|
|
|
|
var entities = await _vmiBalanceSumDetailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false); |
|
|
|
var totalCount = await _vmiBalanceSumDetailRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dtos = _maper.Map<List<VmiBalanceSumDetail>, List<VmiBalanceSumDetailDto>>(entities); |
|
|
|
|
|
|
@ -227,25 +239,31 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[HttpPost] |
|
|
|
public async Task<string> BalanceExport(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 VinCode,ErpToLoc,RealPartCode,ChangedQty ,BillTime,LogType 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, o.LogType }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime),Se = o.Sum(o => o.LogType == VmiLogType.Type100 ? 1 : 0), ReturnGoods = o.Sum(o => o.LogType == VmiLogType.Type400 ? 1 : 0) }).Where(p => p.Qty != 0); |
|
|
|
var entities = query2.ToList(); |
|
|
|
|
|
|
|
//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 ,BillTime,LogType 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, o.LogType }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime),Se = o.Sum(o => o.LogType == VmiLogType.Type100 ? 1 : 0), ReturnGoods = o.Sum(o => o.LogType == VmiLogType.Type400 ? 1 : 0) }).Where(p => p.Qty != 0);
|
|
|
|
//var entities = query2.ToList();
|
|
|
|
|
|
|
|
// var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);
|
|
|
|
|
|
|
|
var entities = await _vmiBalanceSumDetailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount, true).ConfigureAwait(false); |
|
|
|
//var totalCount = await _vmiBalanceSumDetailRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
|
|
|
|
|
|
|
|
var dtos = _maper.Map<List<VmiBalanceSumDetail>, List<VmiBalanceSumDetailDto>>(entities); |
|
|
|
|
|
|
|
var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx"; |
|
|
|
var content = this.GetContent(entities, "库存余额"); |
|
|
|
var content = this.GetContent(dtos, "库存余额"); |
|
|
|
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); |
|
|
|
return fileName; |
|
|
|
} |
|
|
@ -259,56 +277,74 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
public async Task<PagedResultDto<VmiBalanceSumMainDto>> 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<VmiBalanceSum>().AsQueryable(); |
|
|
|
var filters = input.Filters.ToLambda<VmiBalanceSumMainDto>(); |
|
|
|
if (input.Filters.Count > 0) |
|
|
|
{ |
|
|
|
query = query.Where(input.Filters.ToLambda<VmiBalanceSumMainDto>()); |
|
|
|
} |
|
|
|
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting); |
|
|
|
|
|
|
|
var totalCount = query.Count(); |
|
|
|
|
|
|
|
//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 query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false); |
|
|
|
|
|
|
|
var entities = await _vmiBalanceSumRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false); |
|
|
|
var totalCount = await _vmiBalanceSumRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
var dtos = _maper.Map<List<VmiBalanceSum>, List<VmiBalanceSumMainDto>>(entities); |
|
|
|
return new PagedResultDto<VmiBalanceSumMainDto>(totalCount, dtos); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//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<VmiBalanceSum>().AsQueryable();
|
|
|
|
// var filters = input.Filters.ToLambda<VmiBalanceSumMainDto>();
|
|
|
|
// if (input.Filters.Count > 0)
|
|
|
|
// {
|
|
|
|
// query = query.Where(input.Filters.ToLambda<VmiBalanceSumMainDto>());
|
|
|
|
// }
|
|
|
|
// query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
|
|
|
|
|
|
|
|
// var totalCount = query.Count();
|
|
|
|
|
|
|
|
// //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 query.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 1.2库存余额汇总导出
|
|
|
|
/// </summary>
|
|
|
|
[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<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.ChangedQty) }); |
|
|
|
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, "库存汇总"); |
|
|
|
var entities = await _vmiBalanceSumRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount, true).ConfigureAwait(false); |
|
|
|
// var totalCount = await _vmiBalanceSumRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
|
var dtos = _maper.Map<List<VmiBalanceSum>, List<VmiBalanceSumMainDto>>(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 }).Select(o => new VmiBalanceSumDto { ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty) });
|
|
|
|
//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(dtos, "库存汇总"); |
|
|
|
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false); |
|
|
|
return fileName; |
|
|
|
|
|
|
|