Browse Source

更新版本

master
zhaoxinyu 11 months ago
parent
commit
1bc87014ca
  1. 194
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  2. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

194
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -208,29 +208,10 @@ 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 =_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);
dtos=dtos.OrderByDescending(p => p.BillTime).ToList();
return new PagedResultDto<VmiBalanceSumDetailDto>(totalCount, dtos);
}
@ -240,30 +221,9 @@ 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 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);
dtos=dtos.OrderByDescending(p => p.BillTime).ToList();
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);
@ -278,49 +238,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<PagedResultDto<VmiBalanceSumMainDto>> BalanceSum(RequestDto input)
{
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>
@ -328,47 +252,17 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public async Task<string> BalanceSumExport(RequestDto input)
{
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);
if (entities.Count > 1000000)
{
throw new UserFriendlyException("导出行数超过100W不能导出,请重新录入查询条件导出", "400");
}
if (entities.Count > 1000000)
{
throw new UserFriendlyException("导出行数超过100W不能导出,请重新录入查询条件导出", "400");
}
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;
//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>
@ -465,79 +359,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<PagedResultDto<VmiLog>> Log(LogRequestDto input)
{
//var accountday = _codeRepository.FirstOrDefault(p => p.Project == "库存账期").Value;
//var begin= input.Filters.FirstOrDefault(p => p.Column == "BillTime" && p.Action == EnumFilterAction.BiggerThanOrEqual);
//if(begin != null){
// var begintime=DateTime.Parse(begin.Value);
// int version=GetVersionByBillTime(begintime, accountday);
// input.Filters.Add(new FilterCondition("Version",version.ToString(), EnumFilterAction.BiggerThanOrEqual,EnumFilterLogic.And));
//}
//var end = input.Filters.FirstOrDefault(p => p.Column == "BillTime" && p.Action == EnumFilterAction.SmallThan);
//if(end != null) {
// var endtime = DateTime.Parse(end.Value);
// int version = GetVersionByBillTime(endtime, accountday);
// input.Filters.Add(new FilterCondition("Version", version.ToString(), EnumFilterAction.SmallThan, EnumFilterLogic.And)); ;
//}
//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);
//var tables = new List<string>();
//var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
//using var connection = new SqlConnection(connectionString);
//connection.Open();
//for (var time = start; time <= end; time = time.AddMonths(1))
//{
// var tableName = $"Set_VmiLog_{time.Year}_{(time.Month - 1) / 3 + 1}";
// if (!tables.Contains(tableName))
// {
// var command = connection.CreateCommand();
// command.CommandText = $"select OBJECT_ID('{tableName}', 'U')";
// var result = command.ExecuteScalar().ToString();
// if (result != string.Empty)
// {
// tables.Add(tableName);
// }
// else
// {
// this._logger.LogInformation($"{tableName}不存在");
// }
// }
//}
//var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
//using var db = new SettleAccountDbContext(options);
//var sql = string.Empty;
//if (tables.Any())
//{
// //生成 union all 的 SQL使用 FromSqlRaw 查询,如果没有分表则使用原始表
// sql = $"select * from {tables.First()} WITH(NOLOCK)";
// tables.Skip(1).ForEach(o => sql += $" union all select * from {o} WITH(NOLOCK)");
//}
//else
//{
// sql = "select * from Set_VmiLog WITH(NOLOCK)";
//}
//var query = string.IsNullOrEmpty(sql) ? db.Set<VmiLog>().AsQueryable() : db.Set<VmiLog>().FromSqlRaw(sql);
//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);
var entities = await _logRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount).ConfigureAwait(false);
var totalCount = await _logRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
@ -594,8 +416,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }).ConfigureAwait(false);
//var content = this.GetContent(entities, "库存事务_");
//await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
return fileName;
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -954,7 +954,7 @@ namespace Win.Sfs.SettleAccount
private void CreateMapBalanceSumDetail()
{
CreateMap<VmiBalanceSumDetail, VmiBalanceSumDetailDto>()
.ForMember(x => x.BillTime, y => y.MapFrom(d => d.ShippingTime))
.ForMember(x => x.BillTime, y => y.MapFrom(d => d.ReceiveTime))
.ForMember(x => x.Qty, y => y.MapFrom(d => d.SumQty)).
ReverseMap();
}

Loading…
Cancel
Save