|
@@ -801,18 +801,59 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
|
|
|
bool IsCenter = _sessionContext.OrgIsCenter;
|
|
|
|
|
|
- var list = await _orderVisitDetailRepository.Queryable()
|
|
|
+ var list = _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))
|
|
|
.WhereIF(string.IsNullOrEmpty(LineNum) == false, x => x.OrderVisit.Order.CallRecord.Gateway.Contains(LineNum))
|
|
|
- .WhereIF(IsCenter == false, x => x.VisitOrgCode.StartsWith(_sessionContext.OrgId))
|
|
|
- .GroupByIF(IsCenter, x => new
|
|
|
+ .WhereIF(IsCenter == false, x => x.VisitOrgCode.StartsWith(_sessionContext.OrgId));
|
|
|
+
|
|
|
+ var data = new List<VisitAndOrgSatisfactionStatisticsDto>();
|
|
|
+
|
|
|
+ if (IsCenter && list != null)
|
|
|
+ {
|
|
|
+ data = await list.GroupBy(x => new
|
|
|
+ {
|
|
|
+ VisitOrgCode = x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))
|
|
|
+ })
|
|
|
+ .Select(x => new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
{
|
|
|
- VisitOrgCode = x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))
|
|
|
+ OrgCode = x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ TotalSumCount = SqlFunc.AggregateCount(x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
|
|
|
+ VerySatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "5", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "5", 1, 0))),//非常满意数
|
|
|
+ SatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "4", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "4", 1, 0))), //满意数
|
|
|
+ RegardedAsSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "-1", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "-1", 1, 0))),//视为满意
|
|
|
+ DefaultSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "0", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "0", 1, 0))),//默认满意
|
|
|
+ NoSatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "2", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "2", 1, 0))),//不满意
|
|
|
+ NoEvaluateCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "7", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "7", 1, 0))),//未做评价
|
|
|
+ NoPutThroughCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "6", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.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();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data = await list.GroupBy(x => new
|
|
|
+ {
|
|
|
+ x.VisitOrgCode
|
|
|
+ })
|
|
|
.Select(x => new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
{
|
|
|
- OrgCode = x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ OrgCode = x.VisitOrgCode,
|
|
|
TotalSumCount = SqlFunc.AggregateCount(x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
|
|
|
VerySatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "5", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "5", 1, 0))),//非常满意数
|
|
|
SatisfiedCount = SqlFunc.IIF(TypeId == 1, SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "4", 1, 0)), SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "4", 1, 0))), //满意数
|
|
@@ -839,48 +880,50 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
NoPutThroughCount = it.NoPutThroughCount,//未接通
|
|
|
})
|
|
|
.ToListAsync();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
var countySumModel = new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
{
|
|
|
OrgName = "区县合计",
|
|
|
- TotalSumCount = list.Where(x => x.OrgType == EOrgType.County).Sum(x => x.TotalSumCount),
|
|
|
- VerySatisfiedCount = list.Where(x => x.OrgType == EOrgType.County).Sum(x => x.VerySatisfiedCount),
|
|
|
- SatisfiedCount = list.Where(x => x.OrgType == EOrgType.County).Sum(x => x.SatisfiedCount),
|
|
|
- RegardedAsSatisfiedCount = list.Where(x => x.OrgType == EOrgType.County).Sum(x => x.RegardedAsSatisfiedCount),
|
|
|
- DefaultSatisfiedCount = list.Where(x => x.OrgType == EOrgType.County).Sum(x => x.DefaultSatisfiedCount),
|
|
|
- NoSatisfiedCount = list.Where(x => x.OrgType == EOrgType.County).Sum(x => x.NoSatisfiedCount),
|
|
|
- NoEvaluateCount = list.Where(x => x.OrgType == EOrgType.County).Sum(x => x.NoEvaluateCount),
|
|
|
- NoPutThroughCount = list.Where(x => x.OrgType == EOrgType.County).Sum(x => x.NoPutThroughCount),
|
|
|
+ TotalSumCount = data.Where(x => x.OrgType == EOrgType.County).Sum(x => x.TotalSumCount),
|
|
|
+ VerySatisfiedCount = data.Where(x => x.OrgType == EOrgType.County).Sum(x => x.VerySatisfiedCount),
|
|
|
+ SatisfiedCount = data.Where(x => x.OrgType == EOrgType.County).Sum(x => x.SatisfiedCount),
|
|
|
+ RegardedAsSatisfiedCount = data.Where(x => x.OrgType == EOrgType.County).Sum(x => x.RegardedAsSatisfiedCount),
|
|
|
+ DefaultSatisfiedCount = data.Where(x => x.OrgType == EOrgType.County).Sum(x => x.DefaultSatisfiedCount),
|
|
|
+ NoSatisfiedCount = data.Where(x => x.OrgType == EOrgType.County).Sum(x => x.NoSatisfiedCount),
|
|
|
+ NoEvaluateCount = data.Where(x => x.OrgType == EOrgType.County).Sum(x => x.NoEvaluateCount),
|
|
|
+ NoPutThroughCount = data.Where(x => x.OrgType == EOrgType.County).Sum(x => x.NoPutThroughCount),
|
|
|
};
|
|
|
|
|
|
var citySumModel = new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
{
|
|
|
OrgName = "市直合计",
|
|
|
- TotalSumCount = list.Where(x => x.OrgType == EOrgType.City).Sum(x => x.TotalSumCount),
|
|
|
- VerySatisfiedCount = list.Where(x => x.OrgType == EOrgType.City).Sum(x => x.VerySatisfiedCount),
|
|
|
- SatisfiedCount = list.Where(x => x.OrgType == EOrgType.City).Sum(x => x.SatisfiedCount),
|
|
|
- RegardedAsSatisfiedCount = list.Where(x => x.OrgType == EOrgType.City).Sum(x => x.RegardedAsSatisfiedCount),
|
|
|
- DefaultSatisfiedCount = list.Where(x => x.OrgType == EOrgType.City).Sum(x => x.DefaultSatisfiedCount),
|
|
|
- NoSatisfiedCount = list.Where(x => x.OrgType == EOrgType.City).Sum(x => x.NoSatisfiedCount),
|
|
|
- NoEvaluateCount = list.Where(x => x.OrgType == EOrgType.City).Sum(x => x.NoEvaluateCount),
|
|
|
- NoPutThroughCount = list.Where(x => x.OrgType == EOrgType.City).Sum(x => x.NoPutThroughCount),
|
|
|
+ TotalSumCount = data.Where(x => x.OrgType == EOrgType.City).Sum(x => x.TotalSumCount),
|
|
|
+ VerySatisfiedCount = data.Where(x => x.OrgType == EOrgType.City).Sum(x => x.VerySatisfiedCount),
|
|
|
+ SatisfiedCount = data.Where(x => x.OrgType == EOrgType.City).Sum(x => x.SatisfiedCount),
|
|
|
+ RegardedAsSatisfiedCount = data.Where(x => x.OrgType == EOrgType.City).Sum(x => x.RegardedAsSatisfiedCount),
|
|
|
+ DefaultSatisfiedCount = data.Where(x => x.OrgType == EOrgType.City).Sum(x => x.DefaultSatisfiedCount),
|
|
|
+ NoSatisfiedCount = data.Where(x => x.OrgType == EOrgType.City).Sum(x => x.NoSatisfiedCount),
|
|
|
+ NoEvaluateCount = data.Where(x => x.OrgType == EOrgType.City).Sum(x => x.NoEvaluateCount),
|
|
|
+ NoPutThroughCount = data.Where(x => x.OrgType == EOrgType.City).Sum(x => x.NoPutThroughCount),
|
|
|
};
|
|
|
|
|
|
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),
|
|
|
+ TotalSumCount = data.Sum(x => x.TotalSumCount),
|
|
|
+ VerySatisfiedCount = data.Sum(x => x.VerySatisfiedCount),
|
|
|
+ SatisfiedCount = data.Sum(x => x.SatisfiedCount),
|
|
|
+ RegardedAsSatisfiedCount = data.Sum(x => x.RegardedAsSatisfiedCount),
|
|
|
+ DefaultSatisfiedCount = data.Sum(x => x.DefaultSatisfiedCount),
|
|
|
+ NoSatisfiedCount = data.Sum(x => x.NoSatisfiedCount),
|
|
|
+ NoEvaluateCount = data.Sum(x => x.NoEvaluateCount),
|
|
|
+ NoPutThroughCount = data.Sum(x => x.NoPutThroughCount),
|
|
|
};
|
|
|
|
|
|
|
|
|
- return new VisitAndOrgSatisfactionStatisticsResultDto { DataList = list, CountySumModel = countySumModel, CitySumModel = citySumModel, SumModel = sumModel };
|
|
|
+ return new VisitAndOrgSatisfactionStatisticsResultDto { DataList = data, CountySumModel = countySumModel, CitySumModel = citySumModel, SumModel = sumModel };
|
|
|
}
|
|
|
|
|
|
|