|
|
@ -194,7 +194,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<VmiBalanceDto>> Balance(RequestDto input) |
|
|
|
public async Task<PagedResultDto<VmiBalanceNewDto>> Balance(RequestDto input) |
|
|
|
{ |
|
|
|
|
|
|
|
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService"); |
|
|
@ -208,7 +208,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
} |
|
|
|
|
|
|
|
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 query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).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) }).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) });
|
|
|
@ -216,7 +216,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
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); |
|
|
|
return new PagedResultDto<VmiBalanceNewDto>(totalCount, entities); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -231,14 +231,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
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 query = db.Set<VmiLog>().FromSqlRaw("select VinCode,ErpToLoc,RealPartCode,ChangedQty ,BillTime 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 query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).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) }).Where(p => p.Qty != 0); |
|
|
|
var entities = query2.ToList(); |
|
|
|
|
|
|
|
// var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);
|
|
|
@ -1318,11 +1318,33 @@ namespace Win.Sfs.SettleAccount.Entities.BQ |
|
|
|
[Display(Name = "数量", Order = 4)] |
|
|
|
public decimal Qty { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
[Display(Name = "最后更新时间", Order = 5)] |
|
|
|
public DateTime? LastTime { get; set; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public class VmiBalanceNewDto |
|
|
|
{ |
|
|
|
[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? BillTime { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|