|
@@ -47,6 +47,8 @@ using Hotline.Share.Mq;
|
|
|
using JiebaNet.Segmenter;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using WordInfo = PanGu.WordInfo;
|
|
|
+using Hotline.Schedulings;
|
|
|
+using XF.Domain.Entities;
|
|
|
|
|
|
namespace Hotline.Application.Orders;
|
|
|
|
|
@@ -72,6 +74,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
private readonly IRepository<SystemArea> _systemAreaRepository;
|
|
|
private readonly IRepository<Hotspot> _hotspotRepository;
|
|
|
private readonly IRepository<WorkflowStep> _workflowStepRepository;
|
|
|
+ private readonly IRepository<WorkflowTrace> _workflowTraceRepository;
|
|
|
private readonly IRepository<SystemDicData> _systemDicDataRepository;
|
|
|
|
|
|
|
|
@@ -96,8 +99,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
IRepository<SystemArea> systemAreaRepository,
|
|
|
IRepository<Hotspot> hotspotRepository,
|
|
|
IRepository<WorkflowStep> workflowStepRepository,
|
|
|
- IRepository<SystemDicData> systemDicDataRepository
|
|
|
- )
|
|
|
+ IRepository<SystemDicData> systemDicDataRepository,
|
|
|
+ IRepository<WorkflowTrace> workflowTraceRepository)
|
|
|
{
|
|
|
_orderDomainService = orderDomainService;
|
|
|
_workflowDomainService = workflowDomainService;
|
|
@@ -120,8 +123,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
_hotspotRepository = hotspotRepository;
|
|
|
_workflowStepRepository = workflowStepRepository;
|
|
|
_systemDicDataRepository = systemDicDataRepository;
|
|
|
-
|
|
|
- }
|
|
|
+ _workflowTraceRepository = workflowTraceRepository;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新工单办理期满时间(延期调用,其他不调用)
|
|
@@ -284,7 +287,13 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
DateTime stTime = _timeLimitDomainService.WorkDay(DateTime.Now);
|
|
|
var IsCenter = _sessionContext.OrgIsCenter;
|
|
|
|
|
|
- return _orderRepository.Queryable(canView: !IsCenter).Includes(d => d.OrderDelays)
|
|
|
+ return _orderRepository.Queryable(canView: false).Includes(d => d.OrderDelays)
|
|
|
+ .Where(d => SqlFunc.Subqueryable<WorkflowStep>()
|
|
|
+ .Where(step => step.ExternalId == d.Id &&
|
|
|
+ ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == _sessionContext.RequiredUserId) ||
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == _sessionContext.RequiredOrgId) ||
|
|
|
+ (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && _sessionContext.Roles.Contains(step.RoleId))))
|
|
|
+ .Any())
|
|
|
.WhereIF(dto.IsProvince.HasValue, d => d.IsProvince == dto.IsProvince)
|
|
|
//.WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.Title.Contains(dto.Keyword!) || d.No.Contains(dto.Keyword!))
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.No), x => x.No.Contains(dto.No))
|
|
@@ -1423,12 +1432,12 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
CentreArchive = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Filed && it.ProcessType == EProcessType.Zhiban && it.AcceptType != "无效", 1, 0)), //中心归档件
|
|
|
//CentreCareOf = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Filed && (it.FileUserRole == EFileUserType.Org || it.FileUserRole == EFileUserType.Dispatch), 1, 0)), //转办信件
|
|
|
CentreCareOf = SqlFunc.AggregateSum(SqlFunc.IIF(it.AcceptType != "无效" && (it.ProcessType == EProcessType.Jiaoban || (it.ActualHandleStepName == "派单组" && it.Status < EOrderStatus.Filed) || (it.ActualHandleStepName == "班长审批" && it.Status < EOrderStatus.Filed)), 1, 0)),
|
|
|
- NoCentreCareOf = SqlFunc.AggregateSum(SqlFunc.IIF(it.AcceptType != "无效" && (it.Status <= EOrderStatus.SpecialToUnAccept), 1, 0)), //坐席待办 //中心领导?市领导? 是否在统计条件中
|
|
|
+ NoCentreCareOf = SqlFunc.AggregateSum(SqlFunc.IIF(it.AcceptType != "无效" && (it.Status <= EOrderStatus.HandOverToUnAccept), 1, 0)), //坐席待办 //中心领导?市领导? 是否在统计条件中
|
|
|
//CentreCareOf = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Filed && it.ProcessType == EProcessType.Jiaoban, 1, 0)),
|
|
|
//NoCentreCareOf = SqlFunc.AggregateSum(SqlFunc.IIF((int)x.Status < 300 && x.ExpiredTime > x.FiledTime, 1, 0)),
|
|
|
Invalid = SqlFunc.AggregateSum(SqlFunc.IIF(it.AcceptType == "无效", 1, 0)),
|
|
|
Repeat = SqlFunc.AggregateSum(SqlFunc.IIF(it.DuplicateIds != null && SqlFunc.JsonArrayLength(it.DuplicateIds) > 0, 1, 0)),
|
|
|
- Subtotal = SqlFunc.AggregateSum(SqlFunc.IIF((it.Status >= EOrderStatus.Filed && it.ProcessType == EProcessType.Zhiban && it.AcceptType != "无效") || (it.AcceptType != "无效" && (it.ProcessType == EProcessType.Jiaoban || (it.ActualHandleStepName == "派单组" && it.Status < EOrderStatus.Filed) || (it.ActualHandleStepName == "班长审批" && it.Status < EOrderStatus.Filed))) || (it.Status <= EOrderStatus.SpecialToUnAccept) || it.AcceptType == "无效" || (it.DuplicateIds != null && SqlFunc.JsonArrayLength(it.DuplicateIds) > 0), 1, 0))
|
|
|
+ Subtotal = SqlFunc.AggregateSum(SqlFunc.IIF((it.Status >= EOrderStatus.Filed && it.ProcessType == EProcessType.Zhiban && it.AcceptType != "无效") || (it.AcceptType != "无效" && (it.ProcessType == EProcessType.Jiaoban || (it.ActualHandleStepName == "派单组" && it.Status < EOrderStatus.Filed) || (it.ActualHandleStepName == "班长审批" && it.Status < EOrderStatus.Filed))) || (it.Status <= EOrderStatus.HandOverToUnAccept) || it.AcceptType == "无效" || (it.DuplicateIds != null && SqlFunc.JsonArrayLength(it.DuplicateIds) > 0), 1, 0))
|
|
|
}).MergeTable();
|
|
|
switch (dto.SortField)
|
|
|
{
|
|
@@ -1691,5 +1700,72 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
return _mapper.Map<AddOrderResponse>(order);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 派单量统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <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();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
}
|