瀏覽代碼

Merge branch 'test' of http://110.188.24.182:10023/Fengwo/hotline into test

xf 4 月之前
父節點
當前提交
d7ff4abe05

+ 53 - 7
src/Hotline.Application/Orders/OrderApplication.cs

@@ -33,6 +33,7 @@ using Hotline.Share.Enums.Quality;
 using Hotline.Share.Enums.Settings;
 using Hotline.Share.Mq;
 using Hotline.Share.Requests;
+using Hotline.Statistics;
 using Hotline.Tools;
 using Hotline.Users;
 using Mapster;
@@ -95,6 +96,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
     private readonly IOrderDelayRepository _orderDelayRepository;
     private readonly IRepository<OrderSecondaryHandling> _orderSecondaryHandlingRepository;
     private readonly IRepository<SchedulingUser> _schedulingUserRepository;
+    private readonly IRepository<StatisticsHotspotSatisfied> _statisticsHotspotSatisfiedRepository;
 
 	public OrderApplication(
         IOrderDomainService orderDomainService,
@@ -135,6 +137,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         IRepository<OrderPublishHistory> orderPublishHistoryRepository,
         IRepository<OrderSecondaryHandling> orderSecondaryHandlingRepository,
         IRepository<SchedulingUser> schedulingUserRepository,
+        IRepository<StatisticsHotspotSatisfied> statisticsHotspotSatisfiedRepository,
 		IOrderDelayRepository orderDelayRepository)
     {
         _orderDomainService = orderDomainService;
@@ -176,6 +179,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         _orderDelayRepository = orderDelayRepository;
         _orderSecondaryHandlingRepository = orderSecondaryHandlingRepository;
         _schedulingUserRepository = schedulingUserRepository;
+        _statisticsHotspotSatisfiedRepository = statisticsHotspotSatisfiedRepository;
     }
 
     /// <summary>
@@ -1771,8 +1775,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
     public async Task<List<VisitAndOrgSatisfactionStatisticsDto>> VisitAndOrgSatisfactionStatistics(PagedKeywordSonRequest dto)
     {
         bool IsCenter = _sessionContextProvider.SessionContext.OrgIsCenter;
-        int orgLevel = _sessionContextProvider.SessionContext.OrgLevel;
-        string orgLevelStr = ((orgLevel + 1) * 3).ToString();
+        var orgLevel = _sessionContextProvider.SessionContext.OrgLevel;
         var list = _orderVisitDetailRepository.Queryable()
             .Where(x => x.OrderVisit.VisitTime >= dto.StartTime.Value && x.OrderVisit.VisitTime <= dto.EndTime.Value &&
                         x.VisitTarget == EVisitTarget.Org && x.OrderVisit.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(x.VisitOrgCode))
@@ -1840,13 +1843,13 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         {
             data = await list.GroupBy(x => new
             {
-                VisitOrgCode = x.VisitOrgCode//.Substring(SqlFunc.MappingColumn<int>("0"),SqlFunc.MappingColumn<int>(orgLevelStr))
+                x.VisitOrgCode
             })
                 .Select(x => new VisitAndOrgSatisfactionStatisticsDto()
                 {
-                    OrgCode = x.VisitOrgCode,//.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(orgLevelStr)),
+                    OrgCode = x.VisitOrgCode,
                     TotalSumCount =
-                        SqlFunc.AggregateCount(x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(orgLevelStr))),
+                        SqlFunc.AggregateCount(x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
                     VerySatisfiedCount = SqlFunc.IIF(dto.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))), //非常满意数
@@ -1887,7 +1890,6 @@ public class OrderApplication : IOrderApplication, IScopeDependency
                 })
                 .ToListAsync();
         }
-
         return data;
     }
 
@@ -2275,7 +2277,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
 
         var data = new List<VisitAndHotspotSatisfactionStatisticsDto>();
 
-        if (IsCenter && list != null)
+		if (IsCenter && list != null)
         {
             data = await list.GroupBy((x, h) => new
             {
@@ -2352,6 +2354,50 @@ public class OrderApplication : IOrderApplication, IScopeDependency
                 .ToListAsync();
         }
 
+        //老系统数据
+        if (await _statisticsHotspotSatisfiedRepository.Queryable().Where(x=>x.Time >= dto.StartTime.Value && x.Time <= dto.EndTime.Value).AnyAsync())
+        {
+	        var oldList =await  _statisticsHotspotSatisfiedRepository.Queryable()
+				 .InnerJoin<Hotspot>((x, h) =>
+					 h.Id == x.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")) &&
+					 h.ParentId == null)
+				.GroupBy((x, h) => new
+				{
+					HotspotName = h.HotSpotName,
+					HotspotId = h.Id
+				})
+				.Select((x, h) => new VisitAndHotspotSatisfactionStatisticsDto()
+				{
+					HotspotName = h.HotSpotName,
+					HotspotId = h.Id,
+					TotalSumCount = SqlFunc.AggregateSum(x.Total) ,
+					VerySatisfiedCount = SqlFunc.AggregateSum(x.VerySatisfaction), //非常满意数
+					SatisfiedCount = SqlFunc.AggregateSum(x.Satisfaction), //满意数
+					RegardedAsSatisfiedCount = SqlFunc.AggregateSum(x.TreatSatisfaction), //视为满意
+					DefaultSatisfiedCount = SqlFunc.AggregateSum(x.DefaultSatisfaction), //默认满意
+					NoSatisfiedCount = SqlFunc.AggregateSum(x.Dissatisfaction), //不满意
+					NoEvaluateCount = SqlFunc.AggregateSum(x.NotEvaluated), //未做评价
+					NoPutThroughCount = SqlFunc.AggregateSum(x.BlockCall), //未接通
+				})
+				.ToListAsync();
+
+	        data = (from t1 in data
+					   join t2 in oldList on t1.HotspotId equals t2.HotspotId into t1_t2
+		        from item in t1_t2.DefaultIfEmpty()
+		        select new VisitAndHotspotSatisfactionStatisticsDto()
+		        {
+			        HotspotName = t1.HotspotName,
+			        HotspotId = t1.HotspotId,
+			        TotalSumCount = t1.TotalSumCount + t1_t2.Select(x=>x.TotalSumCount).FirstOrDefault(),
+			        VerySatisfiedCount = t1.VerySatisfiedCount + t1_t2.Select(x => x.VerySatisfiedCount).FirstOrDefault(),//非常满意数
+					SatisfiedCount = t1.SatisfiedCount + t1_t2.Select(x => x.SatisfiedCount).FirstOrDefault(), //满意数
+					RegardedAsSatisfiedCount = t1.RegardedAsSatisfiedCount + t1_t2.Select(x => x.RegardedAsSatisfiedCount).FirstOrDefault(), //视为满意
+					DefaultSatisfiedCount = t1.DefaultSatisfiedCount + t1_t2.Select(x => x.DefaultSatisfiedCount).FirstOrDefault(), //默认满意
+					NoSatisfiedCount = t1.NoSatisfiedCount + t1_t2.Select(x => x.NoSatisfiedCount).FirstOrDefault(), //不满意
+					NoEvaluateCount = t1.NoEvaluateCount + t1_t2.Select(x => x.NoEvaluateCount).FirstOrDefault(), //未做评价
+					NoPutThroughCount = t1.NoPutThroughCount + t1_t2.Select(x => x.NoPutThroughCount).FirstOrDefault(), //未接通
+		        }).ToList();
+		}
         return data;
     }
 

+ 1 - 1
src/Hotline.Application/StatisticalReport/CallReport/YiBinCallReportApplication.cs

@@ -287,7 +287,7 @@ public class YiBinCallReportApplication : CallReportApplicationBase, ICallReport
     /// <returns></returns>
     public override async Task<List<QueryCallOutDateStatisticsDetailResp>> QueryCallOutDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto)
     {
-        return null;
+        return await _trCallRecordRepositoryEx.QueryCallOutDateStatisticsDetail(dto.StartTime.Value, dto.EndTime.Value);
     }
 
 

+ 13 - 0
src/Hotline.Repository.SqlSugar/CallCenter/TrCallRecordRepository.cs

@@ -344,5 +344,18 @@ namespace Hotline.Repository.SqlSugar.CallCenter
                 .OrderBy(x => x.Date);
             return await query.ToListAsync();
         }
+
+        public async Task<List<QueryCallOutDateStatisticsDetailResp>> QueryCallOutDateStatisticsDetail(DateTime startTime,DateTime endTime)
+        {
+            //var query = Db.Queryable<TrCallRecord>()
+            //    .Where(x => x.CreatedTime >= startTime && x.CreatedTime <= endTime && SqlFunc.Length(x.Gateway) > 4 && x.CallDirection == ECallDirection.Out)
+            //    .GroupBy(x => x.CreatedTime.ToString("yyyy-MM-dd"))
+            //    .Select(x => new QueryCallOutDateStatisticsDetailResp()
+            //    {
+            //        Date = x.CreatedTime.ToString("yyyy-MM-dd"),
+            //        PersonCallOutCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.))
+            //    });
+            return null;
+        }
     }
 }

+ 9 - 0
src/Hotline/CallCenter/Calls/ITrCallRecordRepository.cs

@@ -59,5 +59,14 @@ namespace Hotline.CallCenter.Calls
         /// <param name="endTime"></param>
         /// <returns></returns>
         Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail(DateTime startTime, DateTime endTime);
+
+
+        /// <summary>
+        /// 呼出话务统计明细
+        /// </summary>
+        /// <param name="startTime"></param>
+        /// <param name="endTime"></param>
+        /// <returns></returns>
+        Task<List<QueryCallOutDateStatisticsDetailResp>> QueryCallOutDateStatisticsDetail(DateTime startTime, DateTime endTime);
     }
 }