fix 优化查询
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
using System.Text.Json.Serialization;
|
|
||||||
using Dlhis.Entity.Canteen.Enums;
|
using Dlhis.Entity.Canteen.Enums;
|
||||||
using Dlhis.ExcelHelper;
|
using Dlhis.ExcelHelper;
|
||||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Dlhis.Canteen.Order.Response;
|
namespace Dlhis.Canteen.Order.Response;
|
||||||
|
|
||||||
@@ -16,12 +16,12 @@ public class ShiftAndBusinessPlaceAnalysisResponse
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消费人数
|
/// 消费人数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Total { get; set; }
|
public int UserCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消费次数
|
/// 消费次数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CostCount => Pagination.Total;
|
public int CostCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分页数据
|
/// 分页数据
|
||||||
|
|||||||
@@ -185,13 +185,20 @@ public class BalanceSummaryService : IBalanceSummaryService
|
|||||||
})
|
})
|
||||||
.ToPageListAsync(request);
|
.ToPageListAsync(request);
|
||||||
|
|
||||||
var amount = await QueryableShiftAndBusinessPlaceAnalysis(request).SumAsync(record => SqlFunc.Abs(record.Amount));
|
var data = await QueryableShiftAndBusinessPlaceAnalysis(request)
|
||||||
var userCount = await QueryableShiftAndBusinessPlaceAnalysis(request).Select(record => record.UserCode).Distinct().CountAsync();
|
.Select(record => new
|
||||||
|
{
|
||||||
|
Amount = SqlFunc.AggregateSum(record.Amount),
|
||||||
|
UserCount = SqlFunc.AggregateDistinctCount(record.UserCode),
|
||||||
|
CostCount = SqlFunc.AggregateCount(record.Id),
|
||||||
|
})
|
||||||
|
.FirstAsync();
|
||||||
|
|
||||||
return new ShiftAndBusinessPlaceAnalysisResponse
|
return new ShiftAndBusinessPlaceAnalysisResponse
|
||||||
{
|
{
|
||||||
Amount = amount,
|
Amount = data?.Amount ?? 0,
|
||||||
Total = userCount,
|
UserCount = data?.UserCount ?? 0,
|
||||||
|
CostCount = data?.CostCount ?? 0,
|
||||||
Pagination = page,
|
Pagination = page,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user