|
@@ -33,6 +33,7 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
|
|
|
private readonly IRepository<SystemOrganize> _systemOrganizeRepository;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
+ private readonly IRepository<OrderVisitDetail> _orderVisitDetailRepository;
|
|
|
|
|
|
public EnforcementOrderController(IRepository<EnforcementOrderHander> enforcementOrderHanderRepository,
|
|
|
IRepository<EnforcementOrders> enforcementOrdersRepository,
|
|
@@ -42,7 +43,8 @@ namespace Hotline.Api.Controllers
|
|
|
IWorkflowApplication workflowApplication,
|
|
|
ISystemDicDataCacheManager sysDicDataCacheManager,
|
|
|
IRepository<SystemOrganize> systemOrganizeRepository,
|
|
|
- ISessionContext sessionContext)
|
|
|
+ ISessionContext sessionContext,
|
|
|
+ IRepository<OrderVisitDetail> orderVisitDetailRepository)
|
|
|
{
|
|
|
_enforcementOrderHanderRepository = enforcementOrderHanderRepository;
|
|
|
_enforcementOrdersRepository = enforcementOrdersRepository;
|
|
@@ -53,6 +55,7 @@ namespace Hotline.Api.Controllers
|
|
|
_sysDicDataCacheManager = sysDicDataCacheManager;
|
|
|
_systemOrganizeRepository = systemOrganizeRepository;
|
|
|
_sessionContext = sessionContext;
|
|
|
+ _orderVisitDetailRepository = orderVisitDetailRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -289,7 +292,7 @@ namespace Hotline.Api.Controllers
|
|
|
PassTheBuckOrder = 0
|
|
|
};
|
|
|
|
|
|
- return new { List = items, Total = total , OrderCount = orderCount };
|
|
|
+ return new { List = items, Total = total, OrderCount = orderCount };
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -308,23 +311,95 @@ namespace Hotline.Api.Controllers
|
|
|
.LeftJoin<SystemArea>((x, o) => x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
|
|
|
.Where((x, o) => x.Order.Status >= EOrderStatus.Filed)
|
|
|
.GroupBy((x, o) => new
|
|
|
- {
|
|
|
- AreaCode = x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
- o.AreaName,
|
|
|
- })
|
|
|
+ {
|
|
|
+ AreaCode = x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ o.AreaName,
|
|
|
+ })
|
|
|
.Select((x, o) => new
|
|
|
- {
|
|
|
- AreaCode = x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
- AreaName = o.AreaName,
|
|
|
- OrderCountNum = SqlFunc.AggregateCount(x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
|
|
|
- TheClueIsTrue = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsTheClueTrue.HasValue && x.IsTheClueTrue.Value == true, 1, 0)),
|
|
|
- TheClueIsNotTrue = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsTheClueTrue.HasValue && x.IsTheClueTrue.Value == false, 1, 0)),
|
|
|
- EnforcementOrder = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsEnforcementOrder, 1, 0))
|
|
|
- }).MergeTable()
|
|
|
+ {
|
|
|
+ AreaCode = x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ AreaName = o.AreaName,
|
|
|
+ OrderCountNum = SqlFunc.AggregateCount(x.Order.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
|
|
|
+ TheClueIsTrue = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsTheClueTrue.HasValue && x.IsTheClueTrue.Value == true, 1, 0)),
|
|
|
+ TheClueIsNotTrue = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsTheClueTrue.HasValue && x.IsTheClueTrue.Value == false, 1, 0)),
|
|
|
+ EnforcementOrder = SqlFunc.AggregateSum(SqlFunc.IIF(x.IsEnforcementOrder, 1, 0))
|
|
|
+ }).MergeTable()
|
|
|
.Where(x => x.AreaCode != "519800" && x.AreaCode != "519900")
|
|
|
.OrderByDescending(it => it.OrderCountNum)
|
|
|
.ToListAsync();
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 部门满意度统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="StartDate"></param>
|
|
|
+ /// <param name="EndDate"></param>
|
|
|
+ /// <param name="TypeId">1:办件结果 2:办件态度</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("enforcement_visit_org_satisfaction_statistics")]
|
|
|
+ public async Task<object> GetVisitAndOrgSatisfactionStatisticsAsync(DateTime StartDate, DateTime EndDate, int TypeId)
|
|
|
+ {
|
|
|
+ EndDate = EndDate.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ var list =
|
|
|
+ await _enforcementOrdersRepository.Queryable()
|
|
|
+ .LeftJoin<OrderVisit>((x,o)=>x.Id==o.OrderId)
|
|
|
+ .LeftJoin<OrderVisitDetail>((x, o,p) => o.Id == p.VisitId)
|
|
|
+ .Where((x, o, p) => o.VisitTime >= StartDate && o.VisitTime <= EndDate && p.VisitTarget == EVisitTarget.Org
|
|
|
+ && o.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(p.VisitOrgCode))
|
|
|
+
|
|
|
+ .GroupBy((x, o, p) => new
|
|
|
+ {
|
|
|
+ VisitOrgCode = p.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))
|
|
|
+ })
|
|
|
+ .Select((x, o, p) => new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
+ {
|
|
|
+ OrgCode = p.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ TotalSumCount = SqlFunc.AggregateCount(p.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
|
|
|
+ VerySatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "5", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "5", 1, 0))),//非常满意数
|
|
|
+ SatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "4", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "4", 1, 0))), //满意数
|
|
|
+ RegardedAsSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "-1", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "-1", 1, 0))),//视为满意
|
|
|
+ DefaultSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "0", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "0", 1, 0))),//默认满意
|
|
|
+ NoSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "2", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "2", 1, 0))),//不满意
|
|
|
+ NoEvaluateCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "7", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "7", 1, 0))),//未做评价
|
|
|
+ NoPutThroughCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgProcessingResults, "Key") == "6", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(p.OrgHandledAttitude, "Key") == "6", 1, 0))),//未接通
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .LeftJoin<SystemOrganize>((it, o) => it.OrgCode == o.Id)
|
|
|
+ .Select((it, o) => new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
+ {
|
|
|
+ OrgName = o.Name,
|
|
|
+ OrgCode = it.OrgCode,
|
|
|
+ OrgType = o.OrgType,
|
|
|
+ TotalSumCount = it.TotalSumCount,
|
|
|
+ VerySatisfiedCount = it.VerySatisfiedCount,//非常满意数
|
|
|
+ SatisfiedCount = it.SatisfiedCount, //满意数
|
|
|
+ RegardedAsSatisfiedCount = it.RegardedAsSatisfiedCount,//视为满意
|
|
|
+ DefaultSatisfiedCount = it.DefaultSatisfiedCount,//默认满意
|
|
|
+ NoSatisfiedCount = it.NoSatisfiedCount,//不满意
|
|
|
+ NoEvaluateCount = it.NoEvaluateCount,//未做评价
|
|
|
+ NoPutThroughCount = it.NoPutThroughCount,//未接通
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+ var sumModel = new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
+ {
|
|
|
+ OrgName = "总计",
|
|
|
+ TotalSumCount = list.Sum(x => x.TotalSumCount),
|
|
|
+ VerySatisfiedCount = list.Sum(x => x.VerySatisfiedCount),
|
|
|
+ SatisfiedCount = list.Sum(x => x.SatisfiedCount),
|
|
|
+ RegardedAsSatisfiedCount = list.Sum(x => x.RegardedAsSatisfiedCount),
|
|
|
+ DefaultSatisfiedCount = list.Sum(x => x.DefaultSatisfiedCount),
|
|
|
+ NoSatisfiedCount = list.Sum(x => x.NoSatisfiedCount),
|
|
|
+ NoEvaluateCount = list.Sum(x => x.NoEvaluateCount),
|
|
|
+ NoPutThroughCount = list.Sum(x => x.NoPutThroughCount),
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ return new { DataList = list, SumModel = sumModel };
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|