|
@@ -52,6 +52,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
private readonly IRepository<OrderSpecialDetail> _orderSpecialDetailRepository;
|
|
|
private readonly IRepository<WorkflowStepHandler> _workflowStepHandler;
|
|
|
private readonly IRepository<WorkflowTrace> _workflowTraceRepository;
|
|
|
+ private readonly IRepository<OrderScreen> _orderScreenRepository;
|
|
|
|
|
|
public BiOrderController(
|
|
|
IOrderRepository orderRepository,
|
|
@@ -71,7 +72,9 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
IRepository<OrderSpecialDetail> orderSpecialDetailRepository,
|
|
|
IRepository<WorkflowStepHandler> workflowStepHandler,
|
|
|
- IRepository<WorkflowTrace> workflowTraceRepository
|
|
|
+ IRepository<WorkflowTrace> workflowTraceRepository,
|
|
|
+ IRepository<OrderScreen> orderScreenRepository,
|
|
|
+ IRepository<WorkflowStepHandler> workflowStepHandleRepository
|
|
|
)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
@@ -92,7 +95,8 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
_orderSpecialDetailRepository = orderSpecialDetailRepository;
|
|
|
_workflowStepHandler = workflowStepHandler;
|
|
|
_workflowTraceRepository = workflowTraceRepository;
|
|
|
-
|
|
|
+ _orderScreenRepository = orderScreenRepository;
|
|
|
+ _workflowStepHandleRepository = workflowStepHandleRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1298,11 +1302,9 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
})
|
|
|
.MergeTable()
|
|
|
.LeftJoin<SystemOrganize>((it, o) => it.OrgCode == o.Id)
|
|
|
-
|
|
|
.WhereIF(TypeCode == 1, (it, o) => it.OrgCode == "001")
|
|
|
.WhereIF(TypeCode == 2, (it, o) => it.OrgCode != "001")
|
|
|
.WhereIF(IsCenter == false, (it, o) => it.OrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
-
|
|
|
.GroupBy((it, o) => new
|
|
|
{
|
|
|
it.OrgCode,
|
|
@@ -1502,13 +1504,12 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
var IsCenter = _sessionContext.OrgIsCenter;
|
|
|
|
|
|
//工单
|
|
|
- var query = _orderRepository.Queryable()
|
|
|
- .Where(it => it.CreationTime >= StartDate && it.CreationTime <= EndDate)
|
|
|
+ var queryOrder = _orderRepository.Queryable()
|
|
|
+ .Where(it => it.CreationTime >= StartDate && it.CreationTime <= EndDate && it.Status > EOrderStatus.WaitForAccept)
|
|
|
.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,//期满时间
|
|
@@ -1518,72 +1519,11 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
.MergeTable()
|
|
|
.WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode == "001", it => it.OrgCode == OrgCode)
|
|
|
.WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode != "001", it => it.OrgCode.StartsWith(OrgCode))
|
|
|
- .MergeTable();
|
|
|
-
|
|
|
- //发布
|
|
|
- var queryPublish = _orderPublishRepository.Queryable()
|
|
|
- .Where(p => p.CreationTime >= StartDate && p.CreationTime <= EndDate)
|
|
|
- .GroupBy(it => new
|
|
|
- {
|
|
|
- it.OrderId,
|
|
|
- it.PublishState
|
|
|
- })
|
|
|
- .Select(it => new DepartmentalProcessingStatisticsDto
|
|
|
- {
|
|
|
- Id = it.OrderId,
|
|
|
- PublishState = it.PublishState
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //会签(已办超期、待办超期)
|
|
|
- var queryCountersign = _workflowCountersignRepository.Queryable()
|
|
|
- .LeftJoin<WorkflowCountersignMember>((x, o) => x.Id == o.WorkflowCountersignId)
|
|
|
- .Where(x => x.CreationTime >= StartDate && x.CreationTime <= EndDate)
|
|
|
- .GroupBy((x, o) => o.Key)
|
|
|
- .Select((x, o) => new DepartmentalProcessingStatisticsDataDto
|
|
|
- {
|
|
|
- OrgCode = o.Key,
|
|
|
- HQYBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(o.IsHandled, 1, 0)),
|
|
|
- HQZBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(!o.IsHandled, 1, 0)),
|
|
|
- DelayEnd = SqlFunc.AggregateSum(SqlFunc.IIF(!o.IsHandled, 1, 0)),
|
|
|
- DelayWait = SqlFunc.AggregateSum(SqlFunc.IIF(!o.IsHandled, 1, 0)),
|
|
|
- }).MergeTable();
|
|
|
-
|
|
|
- _workflowStepHandleRepository.Queryable()
|
|
|
- .Where(d => d.WorkflowStep.ModuleCode == WorkflowModuleConsts.OrderHandle &&
|
|
|
- d.WorkflowStep.CountersignPosition == ECountersignPosition.Multi &&
|
|
|
- d.WorkflowStep.CountersignPosition == ECountersignPosition.Single &&
|
|
|
- d.WorkflowStep.CreationTime >= StartDate && d.WorkflowStep.CreationTime <= EndDate)
|
|
|
- .GroupBy(d => new { d.OrgId, d.OrgName })
|
|
|
- .Select(d => new DepartmentalProcessingStatisticsDataDto
|
|
|
- {
|
|
|
- OrgCode = d.OrgId,
|
|
|
- HQYBOverdue =
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(
|
|
|
- d.WorkflowStep.Status == EWorkflowStepStatus.Handled && d.WorkflowStep.HandleTime > d.WorkflowStep.StepExpiredTime, 1, 0)),
|
|
|
- HQZBOverdue =
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(
|
|
|
- d.WorkflowStep.Status != EWorkflowStepStatus.Handled && DateTime.Now >= d.WorkflowStep.StepExpiredTime, 1, 0)),
|
|
|
- DelayEnd = SqlFunc.AggregateSum(SqlFunc.IIF(d.WorkflowStep.Status == EWorkflowStepStatus.Handled, 1, 0)),
|
|
|
- DelayWait = SqlFunc.AggregateSum(SqlFunc.IIF(d.WorkflowStep.Status != EWorkflowStepStatus.Handled, 1, 0)),
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- var queryPush = query.LeftJoin(queryPublish, (it, o) => it.Id == o.Id).Where(it => it.OrgCode != null);
|
|
|
-
|
|
|
- return await queryPush.GroupBy((it, o) => new
|
|
|
- {
|
|
|
- it.OrgCode
|
|
|
- })
|
|
|
- .Select((it, o) => new
|
|
|
+ .GroupBy(it => new
|
|
|
+ {
|
|
|
+ it.OrgCode
|
|
|
+ })
|
|
|
+ .Select(it => new DepartmentalProcessingStatisticsDataDto
|
|
|
{
|
|
|
//办件信息完整
|
|
|
OrgCode = it.OrgCode,
|
|
@@ -1595,18 +1535,143 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
YBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Filed && it.ActualHandleTime > it.ExpiredTime, 1, 0)),//已办超期
|
|
|
ZBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status < EOrderStatus.Filed && it.ExpiredTime < SqlFunc.GetDate(), 1, 0)),//待办超期
|
|
|
|
|
|
- HQYBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Filed && it.CounterSignType != null && it.ActualHandleTime > it.ExpiredTime, 1, 0)),//会签已办超期
|
|
|
- HQZBOverdue = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status < EOrderStatus.Filed && it.CounterSignType != null && it.ExpiredTime < SqlFunc.GetDate(), 1, 0)),//会签待办超期
|
|
|
-
|
|
|
//归档完整
|
|
|
Archived = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Filed, 1, 0)),//已归档
|
|
|
ToBeArchived = 0,//待归档
|
|
|
+ })
|
|
|
+ .MergeTable();
|
|
|
+
|
|
|
+ //发布
|
|
|
+ var queryPublish = _orderPublishRepository.Queryable()
|
|
|
+ .LeftJoin<Order>((x, o) => x.OrderId == o.Id)
|
|
|
+ .Where((x, o) => x.CreationTime >= StartDate && x.CreationTime <= EndDate)
|
|
|
+ .Select((x, o) => new
|
|
|
+ {
|
|
|
+ o.Id,
|
|
|
+ OrgCode = IsCenter == true ? o.ActualHandleOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : o.ActualHandleOrgCode.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
|
|
|
+
|
|
|
+ PublishState = x.PublishState,
|
|
|
+ Status = o.Status
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .GroupBy(it => new { it.OrgCode })
|
|
|
+ .Select(it => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = it.OrgCode,
|
|
|
+ WaitPublished = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status == EOrderStatus.Filed, 1, 0)),//待发布 --已归档的就是待发布
|
|
|
+ PublishedOpen = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Published && it.PublishState, 1, 0)),//已发布公开
|
|
|
+ PublishedNoOpen = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Published && !it.PublishState, 1, 0)),//已发布不公开
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode == "001", it => it.OrgCode == OrgCode)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode != "001", it => it.OrgCode.StartsWith(OrgCode))
|
|
|
+ .MergeTable();
|
|
|
+
|
|
|
+ //会签(已办超期、待办超期)
|
|
|
+ var queryCountersign = _workflowStepHandleRepository.Queryable()
|
|
|
+ .LeftJoin<WorkflowStep>((x, o) => x.WorkflowStepId == o.Id)
|
|
|
+ .Where((x, o) => o.ModuleCode == WorkflowModuleConsts.OrderHandle &&
|
|
|
+ o.CountersignPosition == ECountersignPosition.Multi &&
|
|
|
+ o.CountersignPosition == ECountersignPosition.Single &&
|
|
|
+ o.CreationTime >= StartDate && o.CreationTime <= EndDate)
|
|
|
+ .Select((x, o) => new
|
|
|
+ {
|
|
|
+ OrgCode = IsCenter == true ? x.OrgId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : x.OrgId.Substring(0, _sessionContext.RequiredOrgId.Length + 3),// d.OrgId,
|
|
|
+ HandleTime = o.HandleTime,
|
|
|
+ StepExpiredTime = o.StepExpiredTime,
|
|
|
+ Status = o.Status
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .GroupBy(d => new { d.OrgCode })
|
|
|
+ .Select(d => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = OrgCode,
|
|
|
+ HQYBOverdue =
|
|
|
+ SqlFunc.AggregateSum(SqlFunc.IIF(
|
|
|
+ d.Status == EWorkflowStepStatus.Handled && d.HandleTime > d.StepExpiredTime, 1, 0)),
|
|
|
+ HQZBOverdue =
|
|
|
+ SqlFunc.AggregateSum(SqlFunc.IIF(
|
|
|
+ d.Status != EWorkflowStepStatus.Handled && DateTime.Now >= d.StepExpiredTime, 1, 0)),
|
|
|
+ DelayEnd = SqlFunc.AggregateSum(SqlFunc.IIF(d.Status == EWorkflowStepStatus.Handled, 1, 0)),
|
|
|
+ DelayWait = SqlFunc.AggregateSum(SqlFunc.IIF(d.Status != EWorkflowStepStatus.Handled, 1, 0)),
|
|
|
+ })
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode == "001", it => it.OrgCode == OrgCode)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode != "001", it => it.OrgCode.StartsWith(OrgCode))
|
|
|
+ .MergeTable();
|
|
|
+
|
|
|
+ //延期
|
|
|
+ var orderDelay = _orderDelayRepository.Queryable()
|
|
|
+ .Where(x => x.CreationTime >= StartDate)
|
|
|
+ .Where(x => x.CreationTime <= EndDate)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgName), x => x.ApplyOrgName.Contains(OrgName))
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ 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()
|
|
|
+ .GroupBy(x => new { x.OrgCode })
|
|
|
+ .Select(x => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = x.OrgCode,
|
|
|
+ OrderDelayCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.DelayState != EDelayState.Withdraw, 1, 0))
|
|
|
+ })
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode == "001", it => it.OrgCode == OrgCode)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode != "001", it => it.OrgCode.StartsWith(OrgCode))
|
|
|
+ .MergeTable();
|
|
|
+
|
|
|
+ //甄别
|
|
|
+ var orderScreen = _orderScreenRepository.Queryable()
|
|
|
+ .Where(x => x.CreationTime >= StartDate)
|
|
|
+ .Where(x => x.CreationTime <= EndDate)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgName), x => x.CreatorOrgId.Contains(OrgName))
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ x.Id,
|
|
|
+ OrgCode = IsCenter == true ? x.CreatorOrgId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) : x.CreatorOrgId.Substring(0, _sessionContext.RequiredOrgId.Length + 3),
|
|
|
+ Status = x.Status
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .GroupBy(x => new { x.OrgCode })
|
|
|
+ .Select(x => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = x.OrgCode,
|
|
|
+ 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)),
|
|
|
+ })
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode == "001", it => it.OrgCode == OrgCode)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode != "001", it => it.OrgCode.StartsWith(OrgCode))
|
|
|
+ .MergeTable();
|
|
|
+
|
|
|
+ //满意度
|
|
|
+ var orderVisit = _orderVisitDetailRepository.Queryable()
|
|
|
+ .Where(x => x.OrderVisit.VisitTime >= StartDate && x.OrderVisit.VisitTime <= EndDate && x.VisitTarget == EVisitTarget.Org
|
|
|
+ && x.OrderVisit.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(x.VisitOrgCode))
|
|
|
+ .WhereIF(string.IsNullOrEmpty(OrgName) == false, x => x.VisitOrgName.Contains(OrgName))
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ 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()
|
|
|
+ .GroupBy(x => new { x.OrgCode })
|
|
|
+ .Select(x => new DepartmentalProcessingStatisticsDataDto
|
|
|
+ {
|
|
|
+ OrgCode = x.OrgCode,
|
|
|
+ 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))
|
|
|
+ })
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode == "001", it => it.OrgCode == OrgCode)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(OrgCode) && OrgCode != "001", it => it.OrgCode.StartsWith(OrgCode))
|
|
|
+ .MergeTable();
|
|
|
+
|
|
|
+ /// queryOrder.FullJoin(queryPublish,(o,p)=>o.OrgCode==p.OrgCode).FullJoin(queryCountersign,)
|
|
|
+
|
|
|
|
|
|
- //发布完整
|
|
|
- WaitPublished = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status == EOrderStatus.Filed, 1, 0)),//待发布 --已归档的就是待发布
|
|
|
- PublishedOpen = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Published && o.PublishState, 1, 0)),//已发布公开
|
|
|
- PublishedNoOpen = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Published && !o.PublishState, 1, 0)),//已发布不公开
|
|
|
- }).ToListAsync();
|
|
|
+ return null;
|
|
|
+ //return new { query = query, queryPublish = queryPublish, queryCountersign = queryCountersign, orderDelay = orderDelay, orderScreen = orderScreen, orderVisit = orderVisit };
|
|
|
}
|
|
|
|
|
|
/// <summary>
|