|
@@ -435,32 +435,32 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 发布量统计
|
|
|
+ /// 发布量统计(按账号)
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
public async Task<(int, IList<PublishedOrderStatisticsDto>)> QueryPublishedOrderAsync(QueryOrderPublishStatisticsDto dto, bool isFull)
|
|
|
{
|
|
|
- var publicCount = await GetPublishCount(dto, true);
|
|
|
-
|
|
|
- var privateCount = await GetPublishCount(dto, false);
|
|
|
-
|
|
|
var query = _orderRepository.Queryable()
|
|
|
- .Where(order => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime)
|
|
|
- .WhereIF(dto.ProcessType != null, order => order.ProcessType == dto.ProcessType)
|
|
|
- .GroupBy(order => order.AcceptorName)
|
|
|
- .Select(order => new QueryPublishedOrderDataDto
|
|
|
- {
|
|
|
- Count = SqlFunc.AggregateCount(order.Id),
|
|
|
- Name = SqlFunc.AggregateMax(order.AcceptorName),
|
|
|
- Id = SqlFunc.AggregateMax(order.AcceptorId),
|
|
|
- });
|
|
|
-
|
|
|
- int total = 0;
|
|
|
-
|
|
|
- var items = new List<QueryPublishedOrderDataDto>();
|
|
|
+ .Includes(order =>order.OrderPublish)
|
|
|
+ .LeftJoin<User>((order, user) => order.WaitForPublisherId == user.Id)
|
|
|
+ .Where((order, user) => order.FiledTime >= dto.StartTime && order.FiledTime <= dto.EndTime && !string.IsNullOrEmpty(order.WaitForPublisherId))
|
|
|
+ .WhereIF(dto.ProcessType != null, (order, user) => order.ProcessType == dto.ProcessType)
|
|
|
+ .GroupBy((order, user) => new { order.WaitForPublisherId, user.Name })
|
|
|
+ .Select((order, user) => new PublishedOrderStatisticsDto
|
|
|
+ {
|
|
|
+ Id = order.WaitForPublisherId,
|
|
|
+ Name = user.Name,
|
|
|
+ TotalCount = SqlFunc.AggregateCount(order.Id),
|
|
|
+ WaitCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.OrderPublish == null, 1, 0)),
|
|
|
+ PublicCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.OrderPublish.PublishState == true, 1, 0)),
|
|
|
+ PrivateCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.OrderPublish.PublishState == false, 1, 0))
|
|
|
+ });
|
|
|
|
|
|
+ var sql = query.ToSql();
|
|
|
+ var total = 0;
|
|
|
+ var items = new List<PublishedOrderStatisticsDto>();
|
|
|
if (isFull)
|
|
|
{
|
|
|
items = await query.ToListAsync();
|
|
@@ -470,37 +470,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
(total, items) = await query.ToPagedListAsync(dto.PageIndex, dto.PageSize);
|
|
|
}
|
|
|
|
|
|
- var result = new List<PublishedOrderStatisticsDto>();
|
|
|
- foreach (var item in items)
|
|
|
- {
|
|
|
- var statisticsDto = new PublishedOrderStatisticsDto
|
|
|
- {
|
|
|
- Name = item.Name,
|
|
|
- TotalCount = item.Count,
|
|
|
- PrivateCount = privateCount.Where(m => m.Id == item.Id).FirstOrDefault()?.Count ?? 0,
|
|
|
- PublicCount = publicCount.Where(m => m.Id == item.Id).FirstOrDefault()?.Count ?? 0,
|
|
|
- };
|
|
|
- statisticsDto.WaitCount = statisticsDto.TotalCount - statisticsDto.PrivateCount - statisticsDto.PublicCount;
|
|
|
- result.Add(statisticsDto);
|
|
|
- }
|
|
|
- return (total, result);
|
|
|
- }
|
|
|
-
|
|
|
- private async Task<List<QueryPublishedOrderDataDto>> GetPublishCount(QueryOrderPublishStatisticsDto dto, bool isPublic)
|
|
|
- {
|
|
|
- return await _orderPublishRepository.Queryable()
|
|
|
- .LeftJoin<Order>((publish, order) => publish.OrderId == order.Id)
|
|
|
- .Where((publish, order) => publish.CreationTime >= dto.StartTime && publish.CreationTime <= dto.EndTime)
|
|
|
- .Where((publish, order) => publish.PublishState == isPublic)
|
|
|
- .WhereIF(dto.ProcessType != null, (publish, order) => order.ProcessType == dto.ProcessType)
|
|
|
- .GroupBy((publish, order) => new { publish.CreatorId })
|
|
|
- .Select((publish, order) => new QueryPublishedOrderDataDto
|
|
|
- {
|
|
|
- Count = SqlFunc.AggregateCount(order.Id),
|
|
|
- Id = SqlFunc.AggregateMax(order.AcceptorId),
|
|
|
- Name = SqlFunc.AggregateMax(order.AcceptorName)
|
|
|
- })
|
|
|
- .ToListAsync();
|
|
|
+ return (total, items);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -511,22 +481,22 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
/// <exception cref="UserFriendlyException"></exception>
|
|
|
public async Task<(int, IList<PublishedOrderStatisticsDto>)> QueryPublishedOrderDepartmentAsync(QueryOrderPublishStatisticsAllDto dto, bool isFull)
|
|
|
{
|
|
|
- var publicCount = await GetPublishCountDepartment(dto, true);
|
|
|
- var privateCount = await GetPublishCountDepartment(dto, false);
|
|
|
-
|
|
|
var total = 0;
|
|
|
- var items = new List<QueryPublishedOrderDataDto>();
|
|
|
+ var items = new List<PublishedOrderStatisticsDto>();
|
|
|
|
|
|
var query = _orderRepository.Queryable()
|
|
|
- .Where(order => order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime)
|
|
|
- .GroupBy(order => order.ActualHandleOrgName)
|
|
|
- .Select(order => new QueryPublishedOrderDataDto
|
|
|
- {
|
|
|
- Count = SqlFunc.AggregateCount(order.Id),
|
|
|
- Name = SqlFunc.AggregateMax(order.ActualHandleOrgName),
|
|
|
- Id = SqlFunc.AggregateMax(order.ActualHandleOrgCode),
|
|
|
- });
|
|
|
-
|
|
|
+ .Includes(order => order.OrderPublish)
|
|
|
+ .Where(order => order.FiledTime >= dto.StartTime && order.FiledTime <= dto.EndTime && order.ActualHandleOrgName != null)
|
|
|
+ .GroupBy(order => new { Name = order.ActualHandleOrgName, PublishTime = order.CreationTime.ToString("YYYY-MM-DD") })
|
|
|
+ .Select(order => new PublishedOrderStatisticsDto
|
|
|
+ {
|
|
|
+ Name = order.ActualHandleOrgName,
|
|
|
+ PublishTime = order.CreationTime.ToString("YYYY-MM-DD"),
|
|
|
+ TotalCount = SqlFunc.AggregateCount(order.Id),
|
|
|
+ // WaitCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.OrderPublish == null, 1, 0)),
|
|
|
+ PublicCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.OrderPublish.PublishState == true, 1, 0)),
|
|
|
+ PrivateCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.OrderPublish.PublishState == false, 1, 0))
|
|
|
+ });
|
|
|
if (isFull)
|
|
|
{
|
|
|
items = await query.ToListAsync();
|
|
@@ -536,44 +506,10 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
(total, items) = await query.ToPagedListAsync(dto.PageIndex, dto.PageSize);
|
|
|
}
|
|
|
|
|
|
- var result = new List<PublishedOrderStatisticsDto>();
|
|
|
- foreach (var item in items)
|
|
|
- {
|
|
|
- var privateItem = privateCount?.Where(m => m.Id == item.Id).FirstOrDefault();
|
|
|
- var publicItem = publicCount?.Where(m => m.Id == item.Id).FirstOrDefault();
|
|
|
- var statisticsDto = new PublishedOrderStatisticsDto
|
|
|
- {
|
|
|
- Name = item.Name,
|
|
|
- TotalCount = item.Count,
|
|
|
- PrivateCount = privateItem?.Count ?? 0,
|
|
|
- PublicCount = publicItem?.Count ?? 0,
|
|
|
- };
|
|
|
- if (publicItem is not null) statisticsDto.PublishTime = publicItem.CreationTime;
|
|
|
- if (privateItem is not null) statisticsDto.PublishTime = privateItem.CreationTime;
|
|
|
- statisticsDto.WaitCount = statisticsDto.TotalCount - statisticsDto.PrivateCount - statisticsDto.PublicCount;
|
|
|
- result.Add(statisticsDto);
|
|
|
- }
|
|
|
- return (total, result);
|
|
|
+ items.ForEach(m => m.WaitCount = m.TotalCount - m.PublicCount - m.PrivateCount);
|
|
|
+ return (total, items);
|
|
|
}
|
|
|
|
|
|
- private async Task<List<QueryPublishedOrderDataDto>> GetPublishCountDepartment(QueryOrderPublishStatisticsAllDto dto, bool isPublic)
|
|
|
- {
|
|
|
- return await _orderPublishRepository.Queryable()
|
|
|
- .LeftJoin<Order>((publish, order) => publish.OrderId == order.Id)
|
|
|
- .Where((publish, order) => publish.CreationTime >= dto.StartTime && publish.CreationTime <= dto.EndTime)
|
|
|
- .Where((publish, order) => publish.PublishState == isPublic)
|
|
|
- .GroupBy((publish, order) => order.ActualHandleOrgCode)
|
|
|
- .Select((publish, order) => new QueryPublishedOrderDataDto
|
|
|
- {
|
|
|
- Count = SqlFunc.AggregateCount(order.Id),
|
|
|
- Id = SqlFunc.AggregateMax(order.ActualHandleOrgCode),
|
|
|
- Name = SqlFunc.AggregateMax(order.ActualHandleOrgName),
|
|
|
- CreationTime = SqlFunc.AggregateMax(publish.CreationTime)
|
|
|
- })
|
|
|
- .ToListAsync();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 回访来源统计
|
|
|
/// </summary>
|