fix 临时注释慢查询
This commit is contained in:
@@ -436,14 +436,12 @@ public class BalanceService : IBalanceService
|
|||||||
.Where(x => x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
|
.Where(x => x.Status == CanteenBusinessPlaceStatusEnumType.Opened)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
//所有消费数据
|
|
||||||
var bs = await _dbContext.Queryable<BalanceRecordEntity>()
|
|
||||||
.Where(x => x.Type == BalanceRecordTypeEnumType.Out)
|
|
||||||
.Where(x => x.Status == BalanceRecordStatusEnumType.Valid)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
//可消费人数
|
//可消费人数
|
||||||
var consumerable = bs.DistinctBy(x => x.UserCode).Count();
|
var consumerable = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||||
|
.Where(x => x.Type == BalanceRecordTypeEnumType.Out && x.Status == BalanceRecordStatusEnumType.Valid)
|
||||||
|
.Select(x => x.UserCode)
|
||||||
|
.Distinct()
|
||||||
|
.CountAsync();
|
||||||
|
|
||||||
//消费走势
|
//消费走势
|
||||||
var months = await GetConsumptionTrendsAsync(1);
|
var months = await GetConsumptionTrendsAsync(1);
|
||||||
@@ -655,11 +653,12 @@ public class BalanceService : IBalanceService
|
|||||||
|
|
||||||
private async Task<List<ConsumptionTrendResponse>> GetConsumptionTrendsAsync(int type)
|
private async Task<List<ConsumptionTrendResponse>> GetConsumptionTrendsAsync(int type)
|
||||||
{
|
{
|
||||||
var bs = await _dbContext.Queryable<BalanceRecordEntity>()
|
//todo
|
||||||
.Where(x => x.Type == BalanceRecordTypeEnumType.Out)
|
|
||||||
.ToListAsync();
|
|
||||||
//消费总额
|
//消费总额
|
||||||
var totalAmount = Math.Round(Math.Abs(bs.Sum(x => x.Amount)), 2);
|
var totalAmount = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||||
|
.Where(x => x.Type == BalanceRecordTypeEnumType.Out && x.Status == BalanceRecordStatusEnumType.Valid)
|
||||||
|
.SumAsync(x => SqlFunc.Abs(x.Amount));
|
||||||
|
|
||||||
var list = new List<ConsumptionTrendResponse>();
|
var list = new List<ConsumptionTrendResponse>();
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
@@ -669,13 +668,10 @@ public class BalanceService : IBalanceService
|
|||||||
|
|
||||||
foreach (var month in months)
|
foreach (var month in months)
|
||||||
{
|
{
|
||||||
var currentAmount = Math.Round(Math.Abs(bs.Where(x => x.CostDateTime.ToString("yyyy-MM") == month)
|
|
||||||
.Sum(x => x.Amount)), 2);
|
|
||||||
|
|
||||||
var res = new ConsumptionTrendResponse
|
var res = new ConsumptionTrendResponse
|
||||||
{
|
{
|
||||||
DateTime = month,
|
DateTime = month,
|
||||||
CurrentAmount = currentAmount,
|
CurrentAmount = 0,
|
||||||
TotalAmount = totalAmount
|
TotalAmount = totalAmount
|
||||||
};
|
};
|
||||||
list.Add(res);
|
list.Add(res);
|
||||||
@@ -688,13 +684,10 @@ public class BalanceService : IBalanceService
|
|||||||
|
|
||||||
foreach (var day in days)
|
foreach (var day in days)
|
||||||
{
|
{
|
||||||
var currentAmount = Math.Round(Math.Abs(bs.Where(x => x.CostDateTime.ToString("yyyy-MM-dd") == day)
|
|
||||||
.Sum(x => x.Amount)), 2);
|
|
||||||
|
|
||||||
var res = new ConsumptionTrendResponse
|
var res = new ConsumptionTrendResponse
|
||||||
{
|
{
|
||||||
DateTime = day,
|
DateTime = day,
|
||||||
CurrentAmount = currentAmount,
|
CurrentAmount = 0,
|
||||||
TotalAmount = totalAmount
|
TotalAmount = totalAmount
|
||||||
};
|
};
|
||||||
list.Add(res);
|
list.Add(res);
|
||||||
|
|||||||
Reference in New Issue
Block a user