|
@@ -782,30 +782,74 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
|
|
|
//部门
|
|
|
var listOrg = await _orderVisitDetailRepository.Queryable()
|
|
|
- .Includes(x => x.OrderVisit)
|
|
|
- .Where(x => x.OrderVisit.VisitTime >= StartDate && x.OrderVisit.VisitTime <= EndDate && x.VisitTarget == EVisitTarget.Org && x.OrderVisit.VisitState == EVisitState.Visited)
|
|
|
- .Select(x => new Satisfaction
|
|
|
- {
|
|
|
- Dissatisfied = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(x.OrgProcessingResults, "key", "1") || SqlFunc.JsonListObjectAny(x.OrgProcessingResults, "key", "2"), 1, 0)),
|
|
|
- Satisfied = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(x.OrgProcessingResults, "key", "1") || SqlFunc.JsonListObjectAny(x.OrgProcessingResults, "key", "2"), 0, 1)),
|
|
|
- }).ToListAsync();
|
|
|
+ .LeftJoin<OrderVisit>((it, o) => it.VisitId == o.Id)
|
|
|
+ .Where((it, o) => it.VisitTarget == EVisitTarget.Org && o.VisitTime >= StartDate && o.VisitTime <= EndDate && o.VisitState == EVisitState.Visited)
|
|
|
+ .Select((it, o) => new Satisfaction
|
|
|
+ {
|
|
|
+ Dissatisfied = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(it.OrgProcessingResults, "key", "1") || SqlFunc.JsonListObjectAny(it.OrgProcessingResults, "key", "2"), 1, 0)),
|
|
|
+ Satisfied = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(it.OrgProcessingResults, "key", "1") || SqlFunc.JsonListObjectAny(it.OrgProcessingResults, "key", "2"), 0, 1)),
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
|
|
|
if (centerReportVisitd.Visitd > 0 && listOrg != null && listOrg.Count > 0 && listOrg[0].Satisfied > 0)
|
|
|
centerReportVisitd.OrgRate = Math.Round((listOrg[0].Satisfied / (double)centerReportVisitd.Visitd) * 100, 2);
|
|
|
|
|
|
//坐席
|
|
|
var listSet = await _orderVisitDetailRepository.Queryable()
|
|
|
- .Includes(x => x.OrderVisit)
|
|
|
- .Where(x => x.OrderVisit.VisitTime >= StartDate && x.OrderVisit.VisitTime <= EndDate && x.VisitTarget == EVisitTarget.Seat && x.OrderVisit.VisitState == EVisitState.Visited)
|
|
|
- .Select(x => new Satisfaction
|
|
|
+ .LeftJoin<OrderVisit>((it, o) => it.VisitId == o.Id)
|
|
|
+ .Where((it, o) => it.VisitTarget == EVisitTarget.Seat && o.VisitTime >= StartDate && o.VisitTime <= EndDate && o.VisitState == EVisitState.Visited)
|
|
|
+ .Select((it, o) => new Satisfaction
|
|
|
{
|
|
|
- Dissatisfied = SqlFunc.AggregateSum(SqlFunc.IIF(x.SeatEvaluate == ESeatEvaluate.VeryNoSatisfied || x.SeatEvaluate == ESeatEvaluate.NoSatisfied, 1, 0)),
|
|
|
- Satisfied = SqlFunc.AggregateSum(SqlFunc.IIF(x.SeatEvaluate != ESeatEvaluate.VeryNoSatisfied && x.SeatEvaluate != ESeatEvaluate.NoSatisfied, 1, 0)),
|
|
|
+ Dissatisfied = SqlFunc.AggregateSum(SqlFunc.IIF(it.SeatEvaluate == ESeatEvaluate.VeryNoSatisfied || it.SeatEvaluate == ESeatEvaluate.NoSatisfied, 1, 0)),
|
|
|
+ Satisfied = SqlFunc.AggregateSum(SqlFunc.IIF(it.SeatEvaluate != ESeatEvaluate.VeryNoSatisfied && it.SeatEvaluate != ESeatEvaluate.NoSatisfied, 1, 0)),
|
|
|
}).ToListAsync();
|
|
|
|
|
|
if (centerReportVisitd.Visitd > 0 && listSet != null && listSet.Count > 0 && listSet[0].Satisfied > 0)
|
|
|
centerReportVisitd.SeatsRate = Math.Round((listSet[0].Satisfied / (double)centerReportVisitd.Visitd) * 100, 2);
|
|
|
|
|
|
+ centerReportStatisticsDto.CenterReportVisitd = centerReportVisitd;
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 信件分布情况
|
|
|
+ //市直部门
|
|
|
+ var listOrgStatisticsCityAll = await _orderRepository.Queryable()
|
|
|
+ .LeftJoin<SystemOrganize>((it, o) => it.CurrentHandleOrgCode == o.Id)
|
|
|
+ .Where((it, o) => (o.OrgType == EOrgType.City || o.OrgType == EOrgType.Province) && it.CreationTime >= StartDate && it.CreationTime <= EndDate)
|
|
|
+ .GroupBy((it, o) => new
|
|
|
+ {
|
|
|
+ it.CurrentHandleOrgCode,
|
|
|
+ o.Name
|
|
|
+ })
|
|
|
+ .Select((it, o) => new OrgStatistics
|
|
|
+ {
|
|
|
+ CountNum = SqlFunc.AggregateCount(it.CurrentHandleOrgCode),
|
|
|
+ OrgName = o.Name
|
|
|
+ }).ToListAsync();
|
|
|
+
|
|
|
+ centerReportStatisticsDto.OrgStatisticsCityAll = new OrgStatisticsAll
|
|
|
+ {
|
|
|
+ OrgStatistics = listOrgStatisticsCityAll
|
|
|
+ };
|
|
|
+
|
|
|
+ //区县部门
|
|
|
+ var listOrgStatisticsAreaAll = await _orderRepository.Queryable()
|
|
|
+ .LeftJoin<SystemOrganize>((it, o) => it.CurrentHandleOrgCode == o.Id)
|
|
|
+ .Where((it, o) => o.OrgType == EOrgType.County && it.CreationTime >= StartDate && it.CreationTime <= EndDate)
|
|
|
+ .GroupBy((it, o) => new
|
|
|
+ {
|
|
|
+ it.CurrentHandleOrgCode,
|
|
|
+ o.Name
|
|
|
+ })
|
|
|
+ .Select((it, o) => new OrgStatistics
|
|
|
+ {
|
|
|
+ CountNum = SqlFunc.AggregateCount(it.CurrentHandleOrgCode),
|
|
|
+ OrgName = o.Name
|
|
|
+ }).ToListAsync();
|
|
|
+
|
|
|
+ centerReportStatisticsDto.OrgStatisticsAreaAll = new OrgStatisticsAll
|
|
|
+ {
|
|
|
+ OrgStatistics = listOrgStatisticsAreaAll
|
|
|
+ };
|
|
|
#endregion
|
|
|
|
|
|
return centerReportStatisticsDto;
|