|
@@ -42,19 +42,22 @@ using PanGu.Match;
|
|
|
using Hotline.Settings.Hotspots;
|
|
|
using Hotline.Share.Enums.FlowEngine;
|
|
|
using Hotline.Authentications;
|
|
|
+using Hotline.Repository.SqlSugar;
|
|
|
using MediatR;
|
|
|
using Hotline.Share.Mq;
|
|
|
using JiebaNet.Segmenter;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using WordInfo = PanGu.WordInfo;
|
|
|
using Hotline.Schedulings;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
using XF.Domain.Entities;
|
|
|
|
|
|
namespace Hotline.Application.Orders;
|
|
|
|
|
|
public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
{
|
|
|
- private readonly IOrderDomainService _orderDomainService;
|
|
|
+
|
|
|
+ private readonly IOrderDomainService _orderDomainService;
|
|
|
private readonly IWorkflowDomainService _workflowDomainService;
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
private readonly ITimeLimitDomainService _timeLimitDomainService;
|
|
@@ -76,10 +79,12 @@ 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;
|
|
|
+ private readonly IRepository<OrderSendBackAudit> _orderSendBackAuditRepository;
|
|
|
|
|
|
|
|
|
- public OrderApplication(
|
|
|
+ public OrderApplication(
|
|
|
IOrderDomainService orderDomainService,
|
|
|
IOrderRepository orderRepository,
|
|
|
IWorkflowDomainService workflowDomainService,
|
|
@@ -102,7 +107,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
IRepository<WorkflowStep> workflowStepRepository,
|
|
|
IRepository<SystemDicData> systemDicDataRepository,
|
|
|
IRepository<WorkflowTrace> workflowTraceRepository,
|
|
|
- IRepository<OrderScreen> orderScreenRepository)
|
|
|
+ IRepository<OrderPublish> orderPublishRepository,
|
|
|
+ IRepository<OrderScreen> orderScreenRepository,
|
|
|
+ IRepository<OrderSendBackAudit> orderSendBackAuditRepository)
|
|
|
{
|
|
|
_orderDomainService = orderDomainService;
|
|
|
_workflowDomainService = workflowDomainService;
|
|
@@ -127,7 +134,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
_systemDicDataRepository = systemDicDataRepository;
|
|
|
_workflowTraceRepository = workflowTraceRepository;
|
|
|
_orderScreenRepository = orderScreenRepository;
|
|
|
-
|
|
|
+ _orderPublishRepository = orderPublishRepository;
|
|
|
+ _orderSendBackAuditRepository = orderSendBackAuditRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -342,7 +350,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
var seg = new Segment();
|
|
|
ICollection<WordInfo> splitWords = seg.DoSegment(inputStr);
|
|
|
var words = new List<string>();
|
|
|
- for (int i = 0; i < splitWords.Count; i++)
|
|
|
+ for (int i = 0;i < splitWords.Count;i++)
|
|
|
{
|
|
|
var word = splitWords.ElementAt(i);
|
|
|
if (word is { WordType: WordType.SimplifiedChinese, Word.Length: > 1 })
|
|
@@ -442,38 +450,156 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 回访来源统计
|
|
|
+ /// 发布量统计
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
- /// <exception cref="NotImplementedException"></exception>
|
|
|
- public async Task<IList<OrderVisitSourceChannelDto>> QueryOrderVisitSourceChannelAsync(QueryOrderVisitSourceChannelDto dto)
|
|
|
+ /// <exception cref="UserFriendlyException"></exception>
|
|
|
+ public async Task<(int, IList<PublishedOrderStatisticsDto>)> QueryPublishedOrderAsync(QueryOrderPublishStatisticsDto dto, bool isFull)
|
|
|
{
|
|
|
- var startDate = new DateTime();
|
|
|
- var endDate = new DateTime();
|
|
|
- switch (dto.DateType)
|
|
|
+ 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>();
|
|
|
+
|
|
|
+ if (isFull)
|
|
|
{
|
|
|
- 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;
|
|
|
+ items = await query.ToListAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (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();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 发布量统计(部门)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <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 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),
|
|
|
+ });
|
|
|
+
|
|
|
+ if (isFull)
|
|
|
+ {
|
|
|
+ items = await query.ToListAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ (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);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ /// <exception cref="NotImplementedException"></exception>
|
|
|
+ public async Task<IList<OrderVisitSourceChannelDto>> QueryOrderVisitSourceChannelAsync(QueryOrderVisitSourceChannelDto dto)
|
|
|
+ {
|
|
|
var result = await _orderVisitRepository.Queryable()
|
|
|
.LeftJoin<Order>((visit, order) => order.Id == visit.OrderId)
|
|
|
- .Where((visit, order) => visit.VisitTime >= startDate && visit.VisitTime <= endDate)
|
|
|
+ .Where((visit, order) => visit.VisitTime >= dto.StartTime && visit.VisitTime <= dto.EndTime)
|
|
|
.GroupBy((visit, order) => new { order.SourceChannel })
|
|
|
.Select((visit, order) => new OrderVisitSourceChannelDto
|
|
|
{
|
|
@@ -509,7 +635,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
visit.VisitTime = dto.VisitTime;
|
|
|
visit.VisitType = dto.VisitType;
|
|
|
|
|
|
- for (int i = 0; i < visit.OrderVisitDetails.Count; i++)
|
|
|
+ for (int i = 0;i < visit.OrderVisitDetails.Count;i++)
|
|
|
{
|
|
|
var detail = visit.OrderVisitDetails[i];
|
|
|
var detaildto = dto.OrderVisitDetailDto.FirstOrDefault(x => x.Id == detail.Id);
|
|
@@ -1201,10 +1327,10 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
dt.Columns.Remove("Column1");
|
|
|
|
|
|
//计算小计
|
|
|
- for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ for (int i = 0;i < dt.Rows.Count;i++)
|
|
|
{
|
|
|
int sumcount = 0;
|
|
|
- for (int j = 1; j < dt.Columns.Count - 1; j++)
|
|
|
+ for (int j = 1;j < dt.Columns.Count - 1;j++)
|
|
|
{
|
|
|
sumcount += Convert.ToInt32(dt.Rows[i][j].ToString());
|
|
|
}
|
|
@@ -1215,10 +1341,10 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
DataRow totalRow = dt.NewRow();
|
|
|
if (dt.Columns[0].ColumnName == "HotspotName") totalRow["HotspotName"] = "合计";
|
|
|
else totalRow["一级热点"] = "合计";
|
|
|
- for (int i = 1; i < dt.Columns.Count; i++)
|
|
|
+ for (int i = 1;i < dt.Columns.Count;i++)
|
|
|
{
|
|
|
int sumcount = 0;
|
|
|
- for (int j = 0; j < dt.Rows.Count; j++)
|
|
|
+ for (int j = 0;j < dt.Rows.Count;j++)
|
|
|
{
|
|
|
sumcount += Convert.ToInt32(dt.Rows[j][i].ToString());
|
|
|
}
|
|
@@ -1515,144 +1641,144 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
- /// <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<(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();
|
|
|
|
|
|
- /// <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 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;
|
|
|
- }
|
|
|
+ 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();
|
|
|
|
|
|
- /// <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))
|
|
|
+ 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;
|
|
|
- }
|
|
|
+ return query;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 甄别申请统计
|
|
@@ -1701,15 +1827,84 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 中心受理统计(日期)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public ISugarQueryable<OrderCenterAcceptVo> OrderCenterAccept(OrderCenterAcceptPagedRequest dto)
|
|
|
+ {
|
|
|
+ if (dto.EndTime.HasValue)
|
|
|
+ dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
|
|
|
+ var sendBack = _orderSendBackAuditRepository.Queryable()
|
|
|
+ .Where(x => x.State == ESendBackAuditState.End)
|
|
|
+ .GroupBy(x => x.OrderId).Select(x => new { OrderId = x.OrderId } );
|
|
|
+
|
|
|
+ var query = _orderRepository.Queryable()
|
|
|
+ .LeftJoin(sendBack,(d,s)=> d.Id == s.OrderId)
|
|
|
+ .WhereIF(dto.StartTime.HasValue && dto.EndTime.HasValue, d => d.CreationTime >= dto.StartTime && d.CreationTime <= dto.EndTime)
|
|
|
+ .WhereIF(dto.TypeCode != null && dto.TypeCode == 1, d => d.IdentityType == EIdentityType.Citizen)
|
|
|
+ .WhereIF(dto.TypeCode != null && dto.TypeCode == 2, d => d.IdentityType == EIdentityType.Enterprise)
|
|
|
+ .GroupBy(d => d.CreationTime.ToString("yyyy-MM-dd"))
|
|
|
+ .Select((d,s) => new OrderCenterAcceptVo
|
|
|
+ {
|
|
|
+ Time = d.CreationTime.ToString("yyyy-MM-dd"),
|
|
|
+ AcceptNum = SqlFunc.AggregateCount(1),
|
|
|
+ ValidNum = SqlFunc.AggregateSum(SqlFunc.IIF( d.AcceptType != "无效" , 1, 0)),
|
|
|
+ RepetitionNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.DuplicateIds == null || SqlFunc.JsonArrayLength(d.DuplicateIds) > 0, 1, 0)),
|
|
|
+ InvalidNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.AcceptType == "无效", 1, 0)),
|
|
|
+ HandleNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.Status >= EOrderStatus.Filed, 1, 0)),
|
|
|
+ NoHandleNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.Status < EOrderStatus.Filed, 1, 0)),
|
|
|
+ BackNum = SqlFunc.AggregateSum(SqlFunc.IIF(!string.IsNullOrEmpty(s.OrderId), 1, 0)),
|
|
|
+ DutyDeskNum = SqlFunc.AggregateDistinctCount(d.AcceptorId)
|
|
|
+ });
|
|
|
+ return query;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 中心受理统计(值班坐席)
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public ISugarQueryable<OrderCenterAcceptUserVo> OrderCenterAcceptUser(OrderCenterAcceptPagedRequest dto)
|
|
|
+ {
|
|
|
+ if (dto.EndTime.HasValue)
|
|
|
+ dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
|
|
|
+ var sendBack = _orderSendBackAuditRepository.Queryable()
|
|
|
+ .Where(x => x.State == ESendBackAuditState.End)
|
|
|
+ .GroupBy(x => x.OrderId).Select(x => new { OrderId = x.OrderId });
|
|
|
+
|
|
|
+ var query = _orderRepository.Queryable()
|
|
|
+ .LeftJoin(sendBack, (d, s) => d.Id == s.OrderId)
|
|
|
+ .WhereIF(dto.StartTime.HasValue && dto.EndTime.HasValue, d => d.CreationTime >= dto.StartTime && d.CreationTime <= dto.EndTime)
|
|
|
+ .WhereIF(dto.TypeCode != null && dto.TypeCode == 1, d => d.IdentityType == EIdentityType.Citizen)
|
|
|
+ .WhereIF(dto.TypeCode != null && dto.TypeCode == 2, d => d.IdentityType == EIdentityType.Enterprise)
|
|
|
+ .GroupBy(d => d.AcceptorName)
|
|
|
+ .Select((d, s) => new OrderCenterAcceptUserVo
|
|
|
+ {
|
|
|
+ AcceptUserName = d.AcceptorName,
|
|
|
+ AcceptNum = SqlFunc.AggregateCount(1),
|
|
|
+ ValidNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.AcceptType != "无效", 1, 0)),
|
|
|
+ RepetitionNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.DuplicateIds == null || SqlFunc.JsonArrayLength(d.DuplicateIds) > 0, 1, 0)),
|
|
|
+ InvalidNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.AcceptType == "无效", 1, 0)),
|
|
|
+ HandleNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.Status >= EOrderStatus.Filed, 1, 0)),
|
|
|
+ NoHandleNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.Status < EOrderStatus.Filed, 1, 0)),
|
|
|
+ BackNum = SqlFunc.AggregateSum(SqlFunc.IIF(!string.IsNullOrEmpty(s.OrderId), 1, 0))
|
|
|
+ });
|
|
|
+ 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>
|
|
|
+ /// <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))
|
|
@@ -1801,65 +1996,66 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
/// <returns></returns>
|
|
|
public async Task<List<SendOrderReportOutDto>> SendOrderReportAsync(QuerySendOrderRequest dto)
|
|
|
{
|
|
|
- var items = await _workflowTraceRepository.Queryable()
|
|
|
- .LeftJoin<Workflow>((x, w) => x.WorkflowId == w.Id)
|
|
|
- //.LeftJoin<WorkflowStepHandler>((x, w, wsh) => x.StepId == wsh.WorkflowStepId && wsh.IsActualHandler == true)
|
|
|
- .InnerJoin<SchedulingUser>((x, w, su) => x.HandlerId == su.UserId)
|
|
|
- .Where((x, w, su) => w.ModuleCode == "OrderHandle" && x.BusinessType == EBusinessType.Send && x.Status == EWorkflowStepStatus.Handled)
|
|
|
- .Where((x, w, su) => x.CreationTime >= dto.StartTime.Value)
|
|
|
- .Where((x, w, su) => x.CreationTime <= dto.EndTime.Value)
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.UserName), (x, w, su) => su.UserName == dto.UserName)
|
|
|
- .GroupBy((x, w, su) => new { su.UserId, su.UserName })
|
|
|
- //.Having((x, w, wsh, su) => SqlFunc.AggregateCount(x.WorkflowId) == 1)
|
|
|
- .Select((x, w, su) => new BiOrderSendVo
|
|
|
- {
|
|
|
- UserId = su.UserId,
|
|
|
- UserName = su.UserName,
|
|
|
- SendOrderNum = SqlFunc.AggregateDistinctCount(w.ExternalId),
|
|
|
- NoSendOrderNum = SqlFunc.AggregateSum(SqlFunc.IIF(x.HandlerId == null || x.HandlerId == "", 1, 0)),
|
|
|
- }).ToListAsync();
|
|
|
-
|
|
|
- var items2 = await _workflowTraceRepository.Queryable()
|
|
|
- .LeftJoin<Workflow>((x, w) => x.WorkflowId == w.Id)
|
|
|
- //.LeftJoin<WorkflowStepHandler>((x, w, wfsh) => x.StepId == wfsh.WorkflowStepId && wfsh.IsActualHandler == true)
|
|
|
- .InnerJoin<SchedulingUser>((x, w, su) => x.HandlerId == su.UserId)
|
|
|
- .Where((x, w, su) => w.ModuleCode == "OrderHandle" && x.BusinessType == EBusinessType.Send && x.Status == EWorkflowStepStatus.Handled)
|
|
|
- .Where((x, w, su) => x.CreationTime >= dto.StartTime.Value)
|
|
|
- .Where((x, w, su) => x.CreationTime <= dto.EndTime.Value)
|
|
|
- .GroupBy((x, w, su) => x.WorkflowId)
|
|
|
- .Having((x, w, su) => SqlFunc.AggregateCount(x.WorkflowId) > 1)
|
|
|
- .Select((x, w, su) => new { Id = x.WorkflowId, CreationTime = SqlFunc.AggregateMin(x.CreationTime) })
|
|
|
- .MergeTable()
|
|
|
- .LeftJoin<WorkflowTrace>((a, wt) => a.Id == wt.WorkflowId)
|
|
|
- .LeftJoin<Workflow>((a, wt, wf) => wt.WorkflowId == wf.Id)
|
|
|
- //.LeftJoin<WorkflowStepHandler>((a, wt, wf, wsh) => wt.StepId == wsh.WorkflowStepId && wsh.CreationTime == a.CreationTime)
|
|
|
- .InnerJoin<SchedulingUser>((a, wt, wf, su) => wt.HandlerId == su.UserId)
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.UserName), ((a, wt, wf, su) => su.UserName == dto.UserName))
|
|
|
- .GroupBy((a, wt, wf, su) => new { su.UserId, su.UserName })
|
|
|
- .Select((a, wt, wf, su) => new BiOrderSendVo
|
|
|
- {
|
|
|
- UserId = su.UserId,
|
|
|
- UserName = su.UserName,
|
|
|
- SendOrderNum = 0,
|
|
|
- NoSendOrderNum = 0,
|
|
|
- ReSendOrderNum = SqlFunc.AggregateDistinctCount(wf.ExternalId),
|
|
|
- }).ToListAsync();
|
|
|
-
|
|
|
- var res = (from t1 in items
|
|
|
- join t2 in items2 on t1.UserId equals t2.UserId into t1_t2
|
|
|
- from item in t1_t2.DefaultIfEmpty()
|
|
|
- select new SendOrderReportOutDto
|
|
|
- {
|
|
|
- UserId = t1.UserId,
|
|
|
- UserName = t1.UserName,
|
|
|
- SendOrderNum = t1.SendOrderNum,
|
|
|
- NoSendOrderNum = t1.NoSendOrderNum,
|
|
|
- ReSendOrderNum = t1_t2.Select(x => x.ReSendOrderNum).FirstOrDefault(),
|
|
|
- ChainRate = t1_t2.Select(x => x.ReSendOrderNum).FirstOrDefault() > 0 ?
|
|
|
- ((double.Parse(t1.SendOrderNum.ToString()) - double.Parse(t1_t2.Select(x => x.ReSendOrderNum).FirstOrDefault().ToString())) / double.Parse(t1.SendOrderNum.ToString()) * 100).ToString("F2") + "%" : "100.00%",
|
|
|
- }).ToList();
|
|
|
+ var items = await _workflowTraceRepository.Queryable()
|
|
|
+ .LeftJoin<Workflow>((x, w) => x.WorkflowId == w.Id)
|
|
|
+ //.LeftJoin<WorkflowStepHandler>((x, w, wsh) => x.StepId == wsh.WorkflowStepId && wsh.IsActualHandler == true)
|
|
|
+ .InnerJoin<SchedulingUser>((x, w, su) => x.HandlerId == su.UserId)
|
|
|
+ .Where((x, w, su) => w.ModuleCode == "OrderHandle" && x.BusinessType == EBusinessType.Send && x.Status == EWorkflowStepStatus.Handled)
|
|
|
+ .Where((x, w, su) => x.CreationTime >= dto.StartTime.Value)
|
|
|
+ .Where((x, w, su) => x.CreationTime <= dto.EndTime.Value)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UserName), (x, w, su) => su.UserName == dto.UserName)
|
|
|
+ .GroupBy((x, w, su) => new { su.UserId, su.UserName })
|
|
|
+ //.Having((x, w, wsh, su) => SqlFunc.AggregateCount(x.WorkflowId) == 1)
|
|
|
+ .Select((x, w, su) => new BiOrderSendVo
|
|
|
+ {
|
|
|
+ UserId = su.UserId,
|
|
|
+ UserName = su.UserName,
|
|
|
+ SendOrderNum = SqlFunc.AggregateDistinctCount(w.ExternalId),
|
|
|
+ NoSendOrderNum = SqlFunc.AggregateSum(SqlFunc.IIF(x.HandlerId == null || x.HandlerId == "", 1, 0)),
|
|
|
+ }).ToListAsync();
|
|
|
+
|
|
|
+ var items2 = await _workflowTraceRepository.Queryable()
|
|
|
+ .LeftJoin<Workflow>((x, w) => x.WorkflowId == w.Id)
|
|
|
+ //.LeftJoin<WorkflowStepHandler>((x, w, wfsh) => x.StepId == wfsh.WorkflowStepId && wfsh.IsActualHandler == true)
|
|
|
+ .InnerJoin<SchedulingUser>((x, w, su) => x.HandlerId == su.UserId)
|
|
|
+ .Where((x, w, su) => w.ModuleCode == "OrderHandle" && x.BusinessType == EBusinessType.Send && x.Status == EWorkflowStepStatus.Handled)
|
|
|
+ .Where((x, w, su) => x.CreationTime >= dto.StartTime.Value)
|
|
|
+ .Where((x, w, su) => x.CreationTime <= dto.EndTime.Value)
|
|
|
+ .GroupBy((x, w, su) => x.WorkflowId)
|
|
|
+ .Having((x, w, su) => SqlFunc.AggregateCount(x.WorkflowId) > 1)
|
|
|
+ .Select((x, w, su) => new { Id = x.WorkflowId, CreationTime = SqlFunc.AggregateMin(x.CreationTime) })
|
|
|
+ .MergeTable()
|
|
|
+ .LeftJoin<WorkflowTrace>((a, wt) => a.Id == wt.WorkflowId)
|
|
|
+ .LeftJoin<Workflow>((a, wt, wf) => wt.WorkflowId == wf.Id)
|
|
|
+ //.LeftJoin<WorkflowStepHandler>((a, wt, wf, wsh) => wt.StepId == wsh.WorkflowStepId && wsh.CreationTime == a.CreationTime)
|
|
|
+ .InnerJoin<SchedulingUser>((a, wt, wf, su) => wt.HandlerId == su.UserId)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UserName), ((a, wt, wf, su) => su.UserName == dto.UserName))
|
|
|
+ .GroupBy((a, wt, wf, su) => new { su.UserId, su.UserName })
|
|
|
+ .Select((a, wt, wf, su) => new BiOrderSendVo
|
|
|
+ {
|
|
|
+ UserId = su.UserId,
|
|
|
+ UserName = su.UserName,
|
|
|
+ SendOrderNum = 0,
|
|
|
+ NoSendOrderNum = 0,
|
|
|
+ ReSendOrderNum = SqlFunc.AggregateDistinctCount(wf.ExternalId),
|
|
|
+ }).ToListAsync();
|
|
|
+
|
|
|
+ var res = (from t1 in items
|
|
|
+ join t2 in items2 on t1.UserId equals t2.UserId into t1_t2
|
|
|
+ from item in t1_t2.DefaultIfEmpty()
|
|
|
+ select new SendOrderReportOutDto
|
|
|
+ {
|
|
|
+ UserId = t1.UserId,
|
|
|
+ UserName = t1.UserName,
|
|
|
+ SendOrderNum = t1.SendOrderNum,
|
|
|
+ NoSendOrderNum = t1.NoSendOrderNum,
|
|
|
+ ReSendOrderNum = t1_t2.Select(x => x.ReSendOrderNum).FirstOrDefault(),
|
|
|
+ ChainRate = t1_t2.Select(x => x.ReSendOrderNum).FirstOrDefault() > 0 ?
|
|
|
+ ((double.Parse(t1.SendOrderNum.ToString()) - double.Parse(t1_t2.Select(x => x.ReSendOrderNum).FirstOrDefault().ToString())) / double.Parse(t1.SendOrderNum.ToString()) * 100).ToString("F2") + "%" : "100.00%",
|
|
|
+ }).ToList();
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
#endregion
|
|
|
}
|