|
@@ -98,6 +98,336 @@ namespace Hotline.Application.StatisticalReport
|
|
|
_orderSecondaryHandlingApplication = orderSecondaryHandlingApplication;
|
|
|
_timeLimitDomainService = timeLimitDomainService;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 部门办件统计表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<List<DepartmentalProcessingStatisticsDataDto>> DepartmentalProcessingStatisticsNew(DepartmentalProcessingStatisticsRequest dto)
|
|
|
+ {
|
|
|
+ dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
|
+ var IsCenter = _sessionContext.OrgIsCenter;
|
|
|
+
|
|
|
+ //信件总量:信件总量=已办件数+在办件数,工单需去重
|
|
|
+ //已办件数:该部门已办理完成的工单总数(含参与会签的工单),若工单被部门多次办理,只统计一次
|
|
|
+ //在办件数:该部门还未办理的工单数(若是一级部门,需包含中心向该部门发起回签的工单)。(特殊说明:部门或者中心发起了会签,会签中还未汇总,应算发起会签部门的在办里面)
|
|
|
+
|
|
|
+ #region 已办件数
|
|
|
+ //已办件数
|
|
|
+ var queryHandle = _workflowTraceRepository.Queryable()
|
|
|
+ .LeftJoin<Order>((t, o) => t.ExternalId == o.Id)
|
|
|
+ .Where((t, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && t.ModuleCode == WorkflowModuleConsts.OrderHandle)
|
|
|
+ //节点状态为已办理、是会签办理或者无会签状态、并且是工单办理
|
|
|
+ // .Where((t, o) => t.Status >= EWorkflowStepStatus.Handled && t.CountersignPosition <= ECountersignPosition.Multi)
|
|
|
+ .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (t, o) => o.Source == ESource.ProvinceStraight)
|
|
|
+ .Select((t, o) => new
|
|
|
+ {
|
|
|
+ OrgCode = IsCenter == true ? t.HandlerOrgId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : t.HandlerOrgId.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
|
|
|
+ o.Id,
|
|
|
+ t.Status,
|
|
|
+ t.CountersignPosition,
|
|
|
+ t.HandleTime,
|
|
|
+ t.StepExpiredTime
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .WhereIF(IsCenter == false, it => it.OrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .GroupBy(d => new { d.OrgCode, d.Id, d.Status, d.CountersignPosition, d.HandleTime, d.StepExpiredTime })
|
|
|
+ .MergeTable()
|
|
|
+ .GroupBy(d => new { d.OrgCode })
|
|
|
+ .Select(d => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = d.OrgCode,
|
|
|
+ YbOrderCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.Status >= EWorkflowStepStatus.Handled && d.CountersignPosition <= ECountersignPosition.Multi, 1, 0)),// 0,//已办
|
|
|
+ ZbOrderCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.Status <= EWorkflowStepStatus.Handled, 1, 0)),//待办
|
|
|
+ Archived = 0,
|
|
|
+ ToBeArchived = 0,
|
|
|
+ WaitPublished = 0,
|
|
|
+ PublishedOpen = 0,
|
|
|
+ PublishedNoOpen = 0,
|
|
|
+ YbOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(d.CountersignPosition >= ECountersignPosition.None && d.Status >= EWorkflowStepStatus.Handled && d.HandleTime < d.StepExpiredTime, 1, 0)),
|
|
|
+ ZbOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(d.CountersignPosition >= ECountersignPosition.None && d.Status < EWorkflowStepStatus.Handled && DateTime.Now >= d.StepExpiredTime, 1, 0)),// 0,
|
|
|
+ CompleteOnTime = SqlFunc.AggregateSum(SqlFunc.IIF(d.CountersignPosition >= ECountersignPosition.None && d.Status == EWorkflowStepStatus.Handled && d.HandleTime <= d.StepExpiredTime, 1, 0)),// 0,
|
|
|
+ HqybOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(d.CountersignPosition > ECountersignPosition.None && d.Status >= EWorkflowStepStatus.Handled && d.HandleTime > d.StepExpiredTime, 1, 0)),
|
|
|
+ HqzbOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(d.CountersignPosition > ECountersignPosition.None && d.Status < EWorkflowStepStatus.Handled && DateTime.Now >= d.StepExpiredTime, 1, 0)),
|
|
|
+ DelayEnd = SqlFunc.AggregateSum(SqlFunc.IIF(d.CountersignPosition > ECountersignPosition.None && d.Status >= EWorkflowStepStatus.Handled, 1, 0)),
|
|
|
+ DelayWait = SqlFunc.AggregateSum(SqlFunc.IIF(d.CountersignPosition > ECountersignPosition.None && d.Status < EWorkflowStepStatus.Handled, 1, 0)),
|
|
|
+ OrderDelayCount = 0,
|
|
|
+ ScreenCount = 0,
|
|
|
+ ScreenApproval = 0,
|
|
|
+ ScreenPass = 0,
|
|
|
+ ScreenNotPass = 0,
|
|
|
+ SatisfactionCount = 0,
|
|
|
+ NotSatisfactionCount = 0,
|
|
|
+ })
|
|
|
+ .MergeTable();
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 待办件数
|
|
|
+ ////待办件数
|
|
|
+ //var queryWaitHandle = _workflowTraceRepository.Queryable()
|
|
|
+ //.LeftJoin<Order>((t, o) => t.ExternalId == o.Id)
|
|
|
+ //.Where((t, o) => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && t.ModuleCode == WorkflowModuleConsts.OrderHandle)
|
|
|
+ ////节点状态为待受理、待办理、是会签办理或者无会签状态、并且是工单办理
|
|
|
+ //.Where((t, o) => t.Status <= EWorkflowStepStatus.Handled)//&& t.CountersignPosition <= ECountersignPosition.Multi
|
|
|
+ //.WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, (t, o) => o.Source == ESource.ProvinceStraight)
|
|
|
+ //.Select((t, o) => new
|
|
|
+ //{
|
|
|
+ // OrgCode = IsCenter == true ? t.HandlerOrgId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : t.HandlerOrgId.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
|
|
|
+ // o.Id
|
|
|
+ //})
|
|
|
+ // .MergeTable()
|
|
|
+ // .WhereIF(IsCenter == false, it => it.OrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ //.GroupBy(d => new { d.OrgCode, d.Id })
|
|
|
+ //.MergeTable()
|
|
|
+ //.GroupBy(d => new { d.OrgCode })
|
|
|
+ // .Select(d => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ // {
|
|
|
+ // OrgCode = d.OrgCode,
|
|
|
+ // YbOrderCountNum = 0,
|
|
|
+ // ZbOrderCountNum = SqlFunc.AggregateSum(SqlFunc.IIF(d.Id != null, 1, 0)),//待办
|
|
|
+ // Archived = 0,
|
|
|
+ // ToBeArchived = 0,
|
|
|
+ // WaitPublished = 0,
|
|
|
+ // PublishedOpen = 0,
|
|
|
+ // PublishedNoOpen = 0,
|
|
|
+ // YbOverdue = 0,
|
|
|
+ // ZbOverdue = 0,
|
|
|
+ // CompleteOnTime = 0,
|
|
|
+ // HqybOverdue = 0,
|
|
|
+ // HqzbOverdue = 0,
|
|
|
+ // DelayEnd = 0,
|
|
|
+ // DelayWait = 0,
|
|
|
+ // OrderDelayCount = 0,
|
|
|
+ // ScreenCount = 0,
|
|
|
+ // ScreenApproval = 0,
|
|
|
+ // ScreenPass = 0,
|
|
|
+ // ScreenNotPass = 0,
|
|
|
+ // SatisfactionCount = 0,
|
|
|
+ // NotSatisfactionCount = 0,
|
|
|
+ // })
|
|
|
+ //.MergeTable();
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 已归档、发布
|
|
|
+ var queryOrder = _orderRepository.Queryable()
|
|
|
+ .Where(it => it.CreationTime >= dto.StartTime && it.CreationTime <= dto.EndTime && it.Status >= EOrderStatus.Filed)
|
|
|
+ .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, it => it.Source == ESource.ProvinceStraight)
|
|
|
+ .Select(it => new
|
|
|
+ {
|
|
|
+ it.Id,
|
|
|
+ OrgCode = IsCenter == true ? it.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : it.ActualHandleOrgCode.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
|
|
|
+ it.ActualHandleOrgCode,
|
|
|
+ it.Status,//工单状态
|
|
|
+ it.ExpiredTime,//期满时间
|
|
|
+ it.ActualHandleTime,//办理时间
|
|
|
+ it.CounterSignType,//会签
|
|
|
+ it.IsPublicity
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .WhereIF(IsCenter == false, it => it.OrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .GroupBy(it => new
|
|
|
+ {
|
|
|
+ it.OrgCode
|
|
|
+ })
|
|
|
+ .Select(it => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = it.OrgCode,
|
|
|
+ YbOrderCountNum = 0,
|
|
|
+ ZbOrderCountNum = 0,
|
|
|
+ Archived = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Filed, 1, 0)),//已归档
|
|
|
+ ToBeArchived = 0,
|
|
|
+ WaitPublished = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status == EOrderStatus.Filed, 1, 0)),//待发布 --已归档的就是待发布
|
|
|
+ PublishedOpen = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Published && it.IsPublicity, 1, 0)),//已发布公开
|
|
|
+ PublishedNoOpen = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Published && !it.IsPublicity, 1, 0)),//已发布不公开
|
|
|
+ YbOverdue = 0,
|
|
|
+ ZbOverdue = 0,
|
|
|
+ CompleteOnTime = 0,
|
|
|
+ HqybOverdue = 0,
|
|
|
+ HqzbOverdue = 0,
|
|
|
+ DelayEnd = 0,
|
|
|
+ DelayWait = 0,
|
|
|
+ OrderDelayCount = 0,
|
|
|
+ ScreenCount = 0,
|
|
|
+ ScreenApproval = 0,
|
|
|
+ ScreenPass = 0,
|
|
|
+ ScreenNotPass = 0,
|
|
|
+ SatisfactionCount = 0,
|
|
|
+ NotSatisfactionCount = 0
|
|
|
+ })
|
|
|
+ .MergeTable();
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 延期
|
|
|
+ //延期
|
|
|
+ var orderDelay = _orderDelayRepository.Queryable()
|
|
|
+ .Includes(x => x.Order)
|
|
|
+ .Where(x => x.Order.CreationTime >= dto.StartTime && x.Order.CreationTime <= dto.EndTime)
|
|
|
+ .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, x => x.Order.Source == ESource.ProvinceStraight)
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ x.Id,
|
|
|
+ x.OrderId,
|
|
|
+ OrgCode = IsCenter == true ? x.ApplyOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : x.ApplyOrgCode.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
|
|
|
+ x.DelayState
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .WhereIF(IsCenter == false, x => x.OrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .GroupBy(x => new { x.OrgCode })
|
|
|
+ .Select(x => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = x.OrgCode,
|
|
|
+ YbOrderCountNum = 0,
|
|
|
+ ZbOrderCountNum = 0,
|
|
|
+ Archived = 0,
|
|
|
+ ToBeArchived = 0,
|
|
|
+ WaitPublished = 0,
|
|
|
+ PublishedOpen = 0,
|
|
|
+ PublishedNoOpen = 0,
|
|
|
+ YbOverdue = 0,
|
|
|
+ ZbOverdue = 0,
|
|
|
+ CompleteOnTime = 0,
|
|
|
+ HqybOverdue = 0,
|
|
|
+ HqzbOverdue = 0,
|
|
|
+ DelayEnd = 0,
|
|
|
+ DelayWait = 0,
|
|
|
+ OrderDelayCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.DelayState == EDelayState.Pass, 1, 0)),
|
|
|
+ ScreenCount = 0,
|
|
|
+ ScreenApproval = 0,
|
|
|
+ ScreenPass = 0,
|
|
|
+ ScreenNotPass = 0,
|
|
|
+ SatisfactionCount = 0,
|
|
|
+ NotSatisfactionCount = 0,
|
|
|
+ })
|
|
|
+ .MergeTable();
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 甄别
|
|
|
+ //甄别
|
|
|
+ var orderScreen = _orderScreenRepository.Queryable()
|
|
|
+ .Includes(x => x.Order)
|
|
|
+ .Where(x => x.Order.CreationTime >= dto.StartTime && x.Order.CreationTime <= dto.EndTime)
|
|
|
+ .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, x => x.Order.Source == ESource.ProvinceStraight)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.OrgName), x => x.CreatorName.Contains(dto.OrgName))
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ x.Id,
|
|
|
+ x.OrderId,
|
|
|
+ OrgCode = IsCenter == true ? x.CreatorOrgId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : x.CreatorOrgId.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
|
|
|
+ x.Status
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .WhereIF(IsCenter == false, it => it.OrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .GroupBy(x => new { x.OrgCode })
|
|
|
+ .Select(x => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = x.OrgCode,
|
|
|
+ YbOrderCountNum = 0,//已办
|
|
|
+ ZbOrderCountNum = 0,//在办
|
|
|
+ Archived = 0,
|
|
|
+ ToBeArchived = 0,
|
|
|
+ WaitPublished = 0,
|
|
|
+ PublishedOpen = 0,
|
|
|
+ PublishedNoOpen = 0,
|
|
|
+ YbOverdue = 0,
|
|
|
+ ZbOverdue = 0,
|
|
|
+ CompleteOnTime = 0,
|
|
|
+ HqybOverdue = 0,
|
|
|
+ HqzbOverdue = 0,
|
|
|
+ DelayEnd = 0,
|
|
|
+ DelayWait = 0,
|
|
|
+ OrderDelayCount = 0,
|
|
|
+ ScreenCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Id != null, 1, 0)),
|
|
|
+ ScreenApproval = SqlFunc.AggregateSum(SqlFunc.IIF(x.Status == EScreenStatus.Approval || x.Status == EScreenStatus.Apply, 1, 0)),
|
|
|
+ ScreenPass = SqlFunc.AggregateSum(SqlFunc.IIF(x.Status == EScreenStatus.End, 1, 0)),
|
|
|
+ ScreenNotPass = SqlFunc.AggregateSum(SqlFunc.IIF(x.Status == EScreenStatus.Refuse, 1, 0)),
|
|
|
+ SatisfactionCount = 0,
|
|
|
+ NotSatisfactionCount = 0,
|
|
|
+ })
|
|
|
+ .MergeTable();
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 满意度
|
|
|
+ //满意度
|
|
|
+ var orderVisit = _orderVisitDetailRepository.Queryable()
|
|
|
+ .Includes(x => x.OrderVisit, x => x.Order)
|
|
|
+ .Where(x => x.OrderVisit.Order.CreationTime >= dto.StartTime && x.OrderVisit.Order.CreationTime <= dto.EndTime
|
|
|
+ && x.VisitTarget == EVisitTarget.Org && x.OrderVisit.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(x.VisitOrgCode))
|
|
|
+ .WhereIF(dto.IsProvince.HasValue && dto.IsProvince == true, x => x.OrderVisit.Order.Source == ESource.ProvinceStraight)
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ x.Id,
|
|
|
+ x.VisitId,
|
|
|
+ x.OrderVisit.OrderId,
|
|
|
+ OrgCode = IsCenter == true ? x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : x.VisitOrgCode.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
|
|
|
+ x.OrgProcessingResults
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .WhereIF(IsCenter == false, it => it.OrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .GroupBy(x => new { x.OrgCode })
|
|
|
+ .Select(x => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = x.OrgCode,
|
|
|
+ YbOrderCountNum = 0,//已办
|
|
|
+ ZbOrderCountNum = 0,//在办
|
|
|
+ Archived = 0,
|
|
|
+ ToBeArchived = 0,
|
|
|
+ WaitPublished = 0,
|
|
|
+ PublishedOpen = 0,
|
|
|
+ PublishedNoOpen = 0,
|
|
|
+ YbOverdue = 0,
|
|
|
+ ZbOverdue = 0,
|
|
|
+ CompleteOnTime = 0,
|
|
|
+ HqybOverdue = 0,
|
|
|
+ HqzbOverdue = 0,
|
|
|
+ DelayEnd = 0,
|
|
|
+ DelayWait = 0,
|
|
|
+ OrderDelayCount = 0,
|
|
|
+ ScreenCount = 0,
|
|
|
+ ScreenApproval = 0,
|
|
|
+ ScreenPass = 0,
|
|
|
+ ScreenNotPass = 0,
|
|
|
+ SatisfactionCount = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") != "2", 1, 0)),
|
|
|
+ NotSatisfactionCount = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "2", 1, 0))
|
|
|
+ })
|
|
|
+ .MergeTable();
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ //var list = _orderRepository.UnionAll(queryHandle, queryOrder, orderDelay, orderScreen, orderVisit).MergeTable()
|
|
|
+ // .LeftJoin<SystemOrganize>((p, o) => p.OrgCode == o.Id)
|
|
|
+ // .Select((p, o) => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ // {
|
|
|
+ // OrgCode = p.OrgCode,
|
|
|
+ // OrgName = o.Name,
|
|
|
+ // OrgType = o.OrgType,
|
|
|
+ // YbOrderCountNum = p.YbOrderCountNum,
|
|
|
+ // ZbOrderCountNum = p.ZbOrderCountNum,
|
|
|
+ // Archived = p.Archived,
|
|
|
+ // ToBeArchived = p.ToBeArchived,
|
|
|
+ // WaitPublished = p.WaitPublished,
|
|
|
+ // PublishedOpen = p.PublishedOpen,
|
|
|
+ // PublishedNoOpen = p.PublishedNoOpen,
|
|
|
+ // YbOverdue = p.YbOverdue,
|
|
|
+ // ZbOverdue = p.ZbOverdue,
|
|
|
+ // CompleteOnTime = p.CompleteOnTime,
|
|
|
+ // HqybOverdue = p.HqybOverdue,
|
|
|
+ // HqzbOverdue = p.HqzbOverdue,
|
|
|
+ // DelayEnd = p.DelayEnd,
|
|
|
+ // DelayWait = p.DelayWait,
|
|
|
+ // OrderDelayCount = p.OrderDelayCount,
|
|
|
+ // ScreenCount = p.ScreenCount,
|
|
|
+ // ScreenApproval = p.ScreenApproval,
|
|
|
+ // ScreenPass = p.ScreenPass,
|
|
|
+ // ScreenNotPass = p.ScreenNotPass,
|
|
|
+ // SatisfactionCount = p.SatisfactionCount,
|
|
|
+ // NotSatisfactionCount = p.NotSatisfactionCount
|
|
|
+ // })
|
|
|
+ // .MergeTable()
|
|
|
+ // .WhereIF(string.IsNullOrEmpty(dto.OrgName) == false, x => x.OrgName.Contains(dto.OrgName)).ToSqlString();
|
|
|
+ ////.ToListAsync();
|
|
|
+ //// return list;
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 部门办件统计表
|