|
@@ -72,9 +72,10 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
private readonly IRepository<SystemArea> _systemAreaRepository;
|
|
|
private readonly IRepository<Hotspot> _hotspotRepository;
|
|
|
private readonly IRepository<WorkflowStep> _workflowStepRepository;
|
|
|
+ private readonly IRepository<SystemDicData> _systemDicDataRepository;
|
|
|
|
|
|
|
|
|
- public OrderApplication(
|
|
|
+ public OrderApplication(
|
|
|
IOrderDomainService orderDomainService,
|
|
|
IOrderRepository orderRepository,
|
|
|
IWorkflowDomainService workflowDomainService,
|
|
@@ -94,8 +95,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
IRepository<OrderSpecialDetail> orderSpecialDetailRepository,
|
|
|
IRepository<SystemArea> systemAreaRepository,
|
|
|
IRepository<Hotspot> hotspotRepository,
|
|
|
- IRepository<WorkflowStep> workflowStepRepository
|
|
|
- )
|
|
|
+ IRepository<WorkflowStep> workflowStepRepository,
|
|
|
+ IRepository<SystemDicData> systemDicDataRepository
|
|
|
+ )
|
|
|
{
|
|
|
_orderDomainService = orderDomainService;
|
|
|
_workflowDomainService = workflowDomainService;
|
|
@@ -117,7 +119,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
_systemAreaRepository = systemAreaRepository;
|
|
|
_hotspotRepository = hotspotRepository;
|
|
|
_workflowStepRepository = workflowStepRepository;
|
|
|
- }
|
|
|
+ _systemDicDataRepository = systemDicDataRepository;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新工单办理期满时间(延期调用,其他不调用)
|
|
@@ -1454,15 +1458,155 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
}
|
|
|
return query;
|
|
|
}
|
|
|
- #region private
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 接受外部工单(除省平台)
|
|
|
- /// </summary>
|
|
|
- /// <param name="dto"></param>
|
|
|
- /// <param name="cancellationToken"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private async Task<AddOrderResponse> ReceiveOrderFromOtherPlatformAsync(AddOrderDto dto, List<FileDto> files,
|
|
|
+ /// <summary>
|
|
|
+ /// 热点受理类型统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<(List<SystemDicData> acceptTypes, object items)> HotspotAndAcceptTypeStatistics(HotspotAndAcceptTypeStatisticsReq dto)
|
|
|
+ {
|
|
|
+ dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
|
+ var dicList = _systemDicDataRepository.Queryable().Where(x => x.DicTypeCode == "AcceptType").OrderBy(x => x.Sort).MergeTable();
|
|
|
+ var endIndex = (2 * dto.HotspotLevel).ToString();
|
|
|
+ var hotspotList = _hotspotRepository.Queryable().Where(x => SqlFunc.Length(x.Id) == int.Parse(endIndex))
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ HotspotId = x.Id,
|
|
|
+ HotspotName = x.HotSpotFullName,
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+ var orderList = _orderRepository.Queryable().Where(x => x.CreationTime >= dto.StartTime && x.CreationTime < dto.EndTime)
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ HotspotId = x.HotspotId.Substring(0, int.Parse(endIndex)),
|
|
|
+ AcceptTypeCode = x.AcceptTypeCode,
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+ var hotListAndOrder = hotspotList.LeftJoin(orderList, (it, o) => it.HotspotId == o.HotspotId)
|
|
|
+ .GroupBy((it, o) => new
|
|
|
+ {
|
|
|
+ it.HotspotId,
|
|
|
+ it.HotspotName,
|
|
|
+ AcceptTypeCode = o.AcceptTypeCode,
|
|
|
+ })
|
|
|
+ .OrderBy((it, o) => it.HotspotId)
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ HotspotId = it.HotspotId,
|
|
|
+ HotspotName = it.HotspotName,
|
|
|
+ AcceptTypeCode = o.AcceptTypeCode,
|
|
|
+ Count = SqlFunc.AggregateCount(it.HotspotId)
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+ var returnList = await dicList.LeftJoin(hotListAndOrder, (pp, dd) => pp.DicDataValue == dd.AcceptTypeCode)
|
|
|
+ .GroupBy((pp, dd) => new
|
|
|
+ {
|
|
|
+ HotspotId = dd.HotspotId,
|
|
|
+ HotspotName = dd.HotspotName,
|
|
|
+ AcceptTypeCode = pp.DicDataValue,
|
|
|
+ AcceptType = pp.DicDataName,
|
|
|
+ })
|
|
|
+ .OrderBy((pp, dd) => dd.HotspotId)
|
|
|
+ .Select((pp, dd) => new
|
|
|
+ {
|
|
|
+ HotspotId = dd.HotspotId,
|
|
|
+ HotspotName = dd.HotspotName,
|
|
|
+ AcceptTypeCode = pp.DicDataValue,
|
|
|
+ AcceptType = pp.DicDataName,
|
|
|
+ Count = SqlFunc.AggregateSum(dd.Count)
|
|
|
+ }).ToPivotListAsync(q => q.AcceptTypeCode, q => new { q.HotspotName, q.HotspotId }, q => q.Sum(x => x.Count));
|
|
|
+
|
|
|
+ var titleList = await _systemDicDataRepository.Queryable().Where(x => x.DicTypeCode == "AcceptType").OrderBy(x => x.Sort).ToListAsync();
|
|
|
+ return (titleList, returnList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 热点受理类型统计--导出
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<DataTable> HotspotAndAcceptTypeStatisticsExport(HotspotAndAcceptTypeStatisticsReq dto)
|
|
|
+ {
|
|
|
+ dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
|
+ var dicList = _systemDicDataRepository.Queryable().Where(x => x.DicTypeCode == "AcceptType").OrderBy(x => x.Sort).MergeTable();
|
|
|
+ var endIndex = (2 * dto.HotspotLevel).ToString();
|
|
|
+ var hotspotList = _hotspotRepository.Queryable().Where(x => SqlFunc.Length(x.Id) == int.Parse(endIndex))
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ HotspotId = x.Id,
|
|
|
+ HotspotName = x.HotSpotFullName,
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+ var orderList = _orderRepository.Queryable().Where(x => x.CreationTime >= dto.StartTime && x.CreationTime < dto.EndTime)
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ HotspotId = x.HotspotId.Substring(0, int.Parse(endIndex)),
|
|
|
+ AcceptTypeCode = x.AcceptTypeCode,
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+ var hotListAndOrder = hotspotList.LeftJoin(orderList, (it, o) => it.HotspotId == o.HotspotId)
|
|
|
+ .GroupBy((it, o) => new
|
|
|
+ {
|
|
|
+ it.HotspotId,
|
|
|
+ it.HotspotName,
|
|
|
+ AcceptTypeCode = o.AcceptTypeCode,
|
|
|
+ })
|
|
|
+ .OrderBy((it, o) => it.HotspotId)
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ HotspotId = it.HotspotId,
|
|
|
+ HotspotName = it.HotspotName,
|
|
|
+ AcceptTypeCode = o.AcceptTypeCode,
|
|
|
+ Count = SqlFunc.AggregateCount(it.HotspotId)
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+
|
|
|
+ var returnList = await dicList.LeftJoin(hotListAndOrder, (pp, dd) => pp.DicDataValue == dd.AcceptTypeCode)
|
|
|
+ .GroupBy((pp, dd) => new
|
|
|
+ {
|
|
|
+ HotspotId = dd.HotspotId,
|
|
|
+ HotspotName = dd.HotspotName,
|
|
|
+ AcceptTypeCode = pp.DicDataValue,
|
|
|
+ AcceptType = pp.DicDataName,
|
|
|
+ })
|
|
|
+ .OrderBy((pp, dd) => dd.HotspotId)
|
|
|
+ .Select((pp, dd) => new
|
|
|
+ {
|
|
|
+ HotspotId = dd.HotspotId,
|
|
|
+ HotspotName = dd.HotspotName,
|
|
|
+ AcceptTypeCode = pp.DicDataValue,
|
|
|
+ AcceptType = pp.DicDataName,
|
|
|
+ Count = SqlFunc.AggregateSum(dd.Count)
|
|
|
+ }).ToPivotTableAsync(q => q.AcceptTypeCode, q => new { q.HotspotName }, q => q.Sum(x => x.Count));
|
|
|
+ //returnList.Rows.RemoveAt(returnList.Rows.Count-1);
|
|
|
+ return returnList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 热点受理类型统计明细
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public ISugarQueryable<Order> HotspotAndAcceptTypeStatisticsDetail(HotspotAndAcceptTypeStatisticsDetailReq dto)
|
|
|
+ {
|
|
|
+ dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
|
+ var query = _orderRepository.Queryable()
|
|
|
+ .Where(x => x.HotspotId.StartsWith(dto.HotspotId) && x.CreationTime >= dto.StartTime && x.CreationTime < dto.EndTime)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.AcceptTypeCode), x => x.AcceptTypeCode.StartsWith(dto.AcceptTypeCode))
|
|
|
+ .OrderByDescending(x => x.CreationTime);
|
|
|
+ return query;
|
|
|
+ }
|
|
|
+
|
|
|
+ #region private
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 接受外部工单(除省平台)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private async Task<AddOrderResponse> ReceiveOrderFromOtherPlatformAsync(AddOrderDto dto, List<FileDto> files,
|
|
|
ISessionContext current, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(dto.ExternalId))
|