|
@@ -76,10 +76,11 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
private readonly IRepository<WorkflowStep> _workflowStepRepository;
|
|
|
private readonly IRepository<WorkflowTrace> _workflowTraceRepository;
|
|
|
private readonly IRepository<SystemDicData> _systemDicDataRepository;
|
|
|
+ private readonly IRepository<OrderPublish> _orderPublishRepository;
|
|
|
private readonly IRepository<OrderScreen> _orderScreenRepository;
|
|
|
|
|
|
|
|
|
- public OrderApplication(
|
|
|
+ public OrderApplication(
|
|
|
IOrderDomainService orderDomainService,
|
|
|
IOrderRepository orderRepository,
|
|
|
IWorkflowDomainService workflowDomainService,
|
|
@@ -102,6 +103,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
IRepository<WorkflowStep> workflowStepRepository,
|
|
|
IRepository<SystemDicData> systemDicDataRepository,
|
|
|
IRepository<WorkflowTrace> workflowTraceRepository,
|
|
|
+ IRepository<OrderPublish> orderPublishRepository)
|
|
|
+ IRepository<WorkflowTrace> workflowTraceRepository,
|
|
|
IRepository<OrderScreen> orderScreenRepository)
|
|
|
{
|
|
|
_orderDomainService = orderDomainService;
|
|
@@ -129,6 +132,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
_orderScreenRepository = orderScreenRepository;
|
|
|
|
|
|
}
|
|
|
+ _orderPublishRepository = orderPublishRepository;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新工单办理期满时间(延期调用,其他不调用)
|
|
@@ -441,6 +446,85 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 发布量统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <exception cref="UserFriendlyException"></exception>
|
|
|
+ public async Task<IList<PublishedOrderStatisticsDto>> QueryPublishedOrderAsync(QueryOrderVisitSourceChannelDto dto)
|
|
|
+ {
|
|
|
+ var startDate = new DateTime();
|
|
|
+ var endDate = new DateTime();
|
|
|
+ switch (dto.DateType)
|
|
|
+ {
|
|
|
+ case EDateType.Day:
|
|
|
+ (startDate, endDate) = dto.StartTime.GetDayStartAndEnd();
|
|
|
+ break;
|
|
|
+ case EDateType.Week:
|
|
|
+ (startDate, endDate) = dto.StartTime.GetWeekStartAndEnd();
|
|
|
+ break;
|
|
|
+ case EDateType.Month:
|
|
|
+ (startDate, endDate) = dto.StartTime.GetMonthStartAndEnd();
|
|
|
+ break;
|
|
|
+ case EDateType.TimeLimit:
|
|
|
+ if (dto.EndTime is null) throw new UserFriendlyException("结束时间错误");
|
|
|
+ startDate = dto.StartTime;
|
|
|
+ endDate = dto.EndTime.Value;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ var publicCount = await _orderPublishRepository.Queryable()
|
|
|
+ .LeftJoin<Hotline.Orders.Order>((publish, order) => publish.OrderId == order.Id)
|
|
|
+ .Where((publish, order) => publish.CreationTime >= startDate && publish.CreationTime <= endDate && publish.PublishState == true)
|
|
|
+ .GroupBy((publish, order) => new { publish.CreatorId})
|
|
|
+ .Select((publish, order) => new QueryPublishedOrderDataDto {
|
|
|
+ Count = SqlFunc.AggregateCount(order.Id),
|
|
|
+ AcceptorId = SqlFunc.AggregateMax(order.AcceptorId),
|
|
|
+ AcceptorName = SqlFunc.AggregateMax(order.AcceptorName)
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ var privateCount = await _orderPublishRepository.Queryable()
|
|
|
+ .LeftJoin<Hotline.Orders.Order>((publish, order) => publish.OrderId == order.Id)
|
|
|
+ .Where((publish, order) => publish.CreationTime >= startDate && publish.CreationTime <= endDate && publish.PublishState == false)
|
|
|
+ .GroupBy((publish, order) => new { publish.CreatorId })
|
|
|
+ .Select((publish, order) => new QueryPublishedOrderDataDto
|
|
|
+ {
|
|
|
+ Count = SqlFunc.AggregateCount(order.Id),
|
|
|
+ AcceptorId = SqlFunc.AggregateMax(order.AcceptorId),
|
|
|
+ AcceptorName = SqlFunc.AggregateMax(order.AcceptorName)
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ var allCount = await _orderRepository.Queryable()
|
|
|
+ .Where(order => order.CreationTime >= startDate && order.CreationTime <= endDate)
|
|
|
+ .GroupBy(order => order.AcceptorName)
|
|
|
+ .Select(order => new QueryPublishedOrderDataDto
|
|
|
+ {
|
|
|
+ Count = SqlFunc.AggregateCount(order.Id),
|
|
|
+ AcceptorName = SqlFunc.AggregateMax(order.AcceptorName),
|
|
|
+ AcceptorId = SqlFunc.AggregateMax(order.AcceptorId),
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ var result = new List<PublishedOrderStatisticsDto>();
|
|
|
+ foreach (var item in allCount)
|
|
|
+ {
|
|
|
+ var statisticsDto = new PublishedOrderStatisticsDto
|
|
|
+ {
|
|
|
+ Name = item.AcceptorName,
|
|
|
+ TotalCount = item.Count,
|
|
|
+ PrivateCount = privateCount.Where(m => m.AcceptorId == item.AcceptorId).FirstOrDefault()?.Count ?? 0,
|
|
|
+ PublicCount = publicCount.Where(m => m.AcceptorId == item.AcceptorId).FirstOrDefault()?.Count ?? 0,
|
|
|
+ };
|
|
|
+ statisticsDto.WaitCount = statisticsDto.TotalCount - statisticsDto.PrivateCount - statisticsDto.PublicCount;
|
|
|
+ result.Add(statisticsDto);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 回访来源统计
|
|
|
/// </summary>
|
|
@@ -1861,5 +1945,6 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
#endregion
|
|
|
}
|