|
@@ -2009,14 +2009,13 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
string orgLevelStr = (dto.OrgCode.Length + 3).ToString();
|
|
|
var oldData = new List<VisitAndOrgSatisfactionStatisticsDto>();
|
|
|
|
|
|
- #region 主部门查询
|
|
|
var mainList = await _systemOrganizeRepository.Queryable().Where(x => x.Id.StartsWith(dto.OrgCode))
|
|
|
.LeftJoin<OrderVisitDetail>((x, it) => x.Id == it.VisitOrgCode)
|
|
|
.Where((x, it) => it.OrderVisit.VisitTime >= dto.StartTime.Value &&
|
|
|
it.OrderVisit.VisitTime <= dto.EndTime.Value &&
|
|
|
it.VisitTarget == EVisitTarget.Org && it.OrderVisit.VisitState == EVisitState.Visited)
|
|
|
- .Where((x, it) => it.VisitOrgCode == dto.OrgCode)
|
|
|
- //.WhereIF(dto.OrgCode != "001", (x, it) => it.VisitOrgCode.StartsWith(dto.OrgCode))
|
|
|
+ .Where((x, it) => it.VisitOrgCode.StartsWith(dto.OrgCode) )
|
|
|
+ //&& it.VisitOrgCode != dto.OrgCode
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.LineNum),
|
|
|
(x, it) => it.OrderVisit.Order.CallRecord.Gateway.Contains(dto.LineNum))
|
|
|
.WhereIF(dto.TypeCode != null && dto.TypeCode == 1,
|
|
@@ -2027,78 +2026,6 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
(x, it) => it.VisitOrgCode.StartsWith(_sessionContextProvider.SessionContext.OrgId))
|
|
|
.WhereIF(dto.VisitType != null, (x, it) => it.OrderVisit.VisitType == dto.VisitType)
|
|
|
.GroupBy((x, it) => new
|
|
|
- {
|
|
|
- VisitOrgCode = it.VisitOrgCode
|
|
|
- })
|
|
|
- .Select((x, it) => new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
- {
|
|
|
- OrgCode = it.VisitOrgCode,
|
|
|
- TotalSumCount = SqlFunc.AggregateCount(it.VisitOrgCode),
|
|
|
- VerySatisfiedCount = SqlFunc.IIF(dto.TypeId == 1,
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgProcessingResults, "Key") == "5", 1, 0)),
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgHandledAttitude, "Key") == "5", 1,
|
|
|
- 0))), //非常满意数
|
|
|
- SatisfiedCount = SqlFunc.IIF(dto.TypeId == 1,
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgProcessingResults, "Key") == "4", 1, 0)),
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgHandledAttitude, "Key") == "4", 1,
|
|
|
- 0))), //满意数
|
|
|
- RegardedAsSatisfiedCount = SqlFunc.IIF(dto.TypeId == 1,
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgProcessingResults, "Key") == "-1", 1, 0)),
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgHandledAttitude, "Key") == "-1", 1,
|
|
|
- 0))), //视为满意
|
|
|
- DefaultSatisfiedCount = SqlFunc.IIF(dto.TypeId == 1,
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgProcessingResults, "Key") == "0", 1, 0)),
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgHandledAttitude, "Key") == "0", 1,
|
|
|
- 0))), //默认满意
|
|
|
- NoSatisfiedCount = SqlFunc.IIF(dto.TypeId == 1,
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgProcessingResults, "Key") == "2", 1, 0)),
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgHandledAttitude, "Key") == "2", 1,
|
|
|
- 0))), //不满意
|
|
|
- NoEvaluateCount = SqlFunc.IIF(dto.TypeId == 1,
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgProcessingResults, "Key") == "7", 1, 0)),
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgHandledAttitude, "Key") == "7", 1,
|
|
|
- 0))), //未做评价
|
|
|
- NoPutThroughCount = SqlFunc.IIF(dto.TypeId == 1,
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgProcessingResults, "Key") == "6", 1, 0)),
|
|
|
- SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(it.OrgHandledAttitude, "Key") == "6", 1,
|
|
|
- 0))) //未接通
|
|
|
- })
|
|
|
- .MergeTable()
|
|
|
- .LeftJoin<SystemOrganize>((x, it) =>
|
|
|
- x.OrgCode == it.Id && (it.Level == org.Level || it.Level == (org.Level + 1)))
|
|
|
- .Select((x, it) => new VisitAndOrgSatisfactionStatisticsDto()
|
|
|
- {
|
|
|
- OrgName = it.Name,
|
|
|
- OrgCode = x.OrgCode,
|
|
|
- OrgType = it.OrgType,
|
|
|
- TotalSumCount = x.TotalSumCount,
|
|
|
- VerySatisfiedCount = x.VerySatisfiedCount, //非常满意数
|
|
|
- SatisfiedCount = x.SatisfiedCount, //满意数
|
|
|
- RegardedAsSatisfiedCount = x.RegardedAsSatisfiedCount, //视为满意
|
|
|
- DefaultSatisfiedCount = x.DefaultSatisfiedCount, //默认满意
|
|
|
- NoSatisfiedCount = x.NoSatisfiedCount, //不满意
|
|
|
- NoEvaluateCount = x.NoEvaluateCount, //未做评价
|
|
|
- NoPutThroughCount = x.NoPutThroughCount, //未接通
|
|
|
- }).ToListAsync();
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 下级部门查询
|
|
|
- var juniorList = await _systemOrganizeRepository.Queryable().Where(x => x.Id.StartsWith(dto.OrgCode))
|
|
|
- .LeftJoin<OrderVisitDetail>((x, it) => x.Id == it.VisitOrgCode)
|
|
|
- .Where((x, it) => it.OrderVisit.VisitTime >= dto.StartTime.Value &&
|
|
|
- it.OrderVisit.VisitTime <= dto.EndTime.Value &&
|
|
|
- it.VisitTarget == EVisitTarget.Org && it.OrderVisit.VisitState == EVisitState.Visited)
|
|
|
- .Where((x, it) => it.VisitOrgCode.StartsWith(dto.OrgCode) && it.VisitOrgCode != dto.OrgCode)
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.LineNum),
|
|
|
- (x, it) => it.OrderVisit.Order.CallRecord.Gateway.Contains(dto.LineNum))
|
|
|
- .WhereIF(dto.TypeCode != null && dto.TypeCode == 1,
|
|
|
- (x, it) => it.OrderVisit.Order.IdentityType == EIdentityType.Citizen)
|
|
|
- .WhereIF(dto.TypeCode != null && dto.TypeCode == 2,
|
|
|
- (x, it) => it.OrderVisit.Order.IdentityType == EIdentityType.Enterprise)
|
|
|
- .WhereIF(IsCenter == false,
|
|
|
- (x, it) => it.VisitOrgCode.StartsWith(_sessionContextProvider.SessionContext.OrgId))
|
|
|
- .WhereIF(dto.VisitType != null, (x, it) => it.OrderVisit.VisitType == dto.VisitType)
|
|
|
- .GroupBy((x, it) => new
|
|
|
{
|
|
|
VisitOrgCode = it.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(orgLevelStr))
|
|
|
})
|
|
@@ -2154,10 +2081,6 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
- #endregion
|
|
|
-
|
|
|
- mainList.AddRange(juniorList);
|
|
|
-
|
|
|
#region 老系统数据
|
|
|
if (await _statisticsDepartSatisfiedRepository.Queryable().Where(x => x.Time >= dto.StartTime.Value && x.Time <= dto.EndTime.Value).AnyAsync())
|
|
|
{
|