소스 검색

修复热线号码统计

qinchaoyue 5 달 전
부모
커밋
1bd4f16502

+ 20 - 6
src/Hotline.Application.Tests/Application/ZiGongCallReportApplicationTest.cs

@@ -1,4 +1,5 @@
 using Hotline.Application.StatisticalReport.CallReport;
+using Hotline.Caching.Interfaces;
 using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Requests;
@@ -15,12 +16,12 @@ namespace Hotline.Application.Tests.Application;
 public class ZiGongCallReportApplicationTest
 {
     private readonly ZiGongCallReportApplication _ziGongCallReportApplication;
-    private CancellationToken cancellation;
+    private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
 
-    public ZiGongCallReportApplicationTest(ZiGongCallReportApplication ziGongCallReportApplication)
+    public ZiGongCallReportApplicationTest(ZiGongCallReportApplication ziGongCallReportApplication, ISystemDicDataCacheManager systemDicDataCacheManager)
     {
         _ziGongCallReportApplication = ziGongCallReportApplication;
-        cancellation = new CancellationToken();
+        _systemDicDataCacheManager = systemDicDataCacheManager;
     }
 
     [Fact]
@@ -44,7 +45,7 @@ public class ZiGongCallReportApplicationTest
             EndTime = DateTime.Now
         };
 
-        var result = await _ziGongCallReportApplication.QuerySeatCallAsync(inDto, cancellation);
+        var result = await _ziGongCallReportApplication.QuerySeatCallAsync(inDto, CancellationToken.None);
         result.ShouldNotBeNull();
     }
 
@@ -66,7 +67,7 @@ public class ZiGongCallReportApplicationTest
             ToNo = toNo,
             EndBy = endBy?.ToEnum<EEndBy>()
         };
-        var (total, items) = await _ziGongCallReportApplication.QueryCallsStatisticsDetailAsync(inDto, cancellation);
+        var (total, items) = await _ziGongCallReportApplication.QueryCallsStatisticsDetailAsync(inDto, CancellationToken.None);
         total.ShouldNotBe(0);
         items.Any(m => m.OrderNo.NotNullOrEmpty()).ShouldBeTrue();
         items.Any(m => m.OrderTitle.NotNullOrEmpty()).ShouldBeTrue();
@@ -89,7 +90,7 @@ public class ZiGongCallReportApplicationTest
             StartTime = "2024-07-29".ObjToDate(),
             EndTime = "2024-07-29 23:59:59".ObjToDate(),
         };
-        var result = await _ziGongCallReportApplication.QueryCallsDetailStatisticsAsync(inDto, cancellation);
+        var result = await _ziGongCallReportApplication.QueryCallsDetailStatisticsAsync(inDto, CancellationToken.None);
         result.Any(m => m.InConnectionRate.IsNullOrEmpty()).ShouldBeFalse();
         result.ShouldNotBeNull();
     }
@@ -161,4 +162,17 @@ public class ZiGongCallReportApplicationTest
         bhour.Total.ShouldBe(hour.Count, "Count 列表和详情的数量对不上");
 
     }
+
+    [Fact]
+    public async Task GetCallHotLineList_Test()
+    {
+        var dto = new BiQueryGateWayDto
+        {
+            StartTime = DateTime.Now.AddMonths(-1),
+            EndTime = DateTime.Now
+        };
+        var result = await _ziGongCallReportApplication.GetCallHotLineListAsync(dto, CancellationToken.None);
+        var hotlines = _systemDicDataCacheManager.CallForwardingSource.Select(m => m.DicDataValue).ToList();
+        result.Any(m => !hotlines.Contains(m.GateWay)).ShouldBeFalse();
+    }
 }

+ 5 - 2
src/Hotline.Application/StatisticalReport/CallReport/CallReportApplicationBase.cs

@@ -25,18 +25,20 @@ namespace Hotline.Application.StatisticalReport.CallReport;
 public abstract class CallReportApplicationBase : ICallReportApplication
 {
     private readonly ISystemSettingCacheManager _systemSettingCacheManager;
+    private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
     private readonly ICallNativeRepository _callNativeRepository;
     private readonly IRepository<User> _userRepository;
     private readonly IRepository<Work> _workRepository;
     private readonly IRepository<TelRest> _telRestRepository;
 
-    protected CallReportApplicationBase(ISystemSettingCacheManager systemSettingCacheManager, ICallNativeRepository callNativeRepository, IRepository<User> userRepository, IRepository<Work> workRepository, IRepository<TelRest> telRestRepository)
+    protected CallReportApplicationBase(ISystemSettingCacheManager systemSettingCacheManager, ICallNativeRepository callNativeRepository, IRepository<User> userRepository, IRepository<Work> workRepository, IRepository<TelRest> telRestRepository, ISystemDicDataCacheManager systemDicDataCacheManager)
     {
         _systemSettingCacheManager = systemSettingCacheManager;
         _callNativeRepository = callNativeRepository;
         _userRepository = userRepository;
         _workRepository = workRepository;
         _telRestRepository = telRestRepository;
+        _systemDicDataCacheManager = systemDicDataCacheManager;
     }
 
     public virtual async Task<List<CallHotLineDto>> GetCallHotLineListAsync(BiQueryGateWayDto dto, CancellationToken requestAborted)
@@ -45,7 +47,8 @@ public abstract class CallReportApplicationBase : ICallReportApplication
         int effectiveTimes = _systemSettingCacheManager.EffectiveTimes;
         int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
         int ringTimes = _systemSettingCacheManager.RingTimes;
-        return await _callNativeRepository.GetCallHotLineListAsync(dto, noConnectByeTimes, effectiveTimes, connectByeTimes, ringTimes);
+        var hotlines = _systemDicDataCacheManager.CallForwardingSource.Select(m => m.DicDataValue).ToList();
+        return await _callNativeRepository.GetCallHotLineListAsync(dto, noConnectByeTimes, effectiveTimes, connectByeTimes, ringTimes, hotlines);
     }
 
     public virtual async Task<List<TrCallHourDto>> GetCallHourListAsync(BiQueryHourCallDto dto, CancellationToken requestAborted)

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

@@ -11,7 +11,7 @@ namespace Hotline.Application.StatisticalReport.CallReport;
 [Injection(AppScopes = EAppScope.LuZhou)]
 public class LuZhouCallReportApplication : CallReportApplicationBase, ICallReportApplication, IScopeDependency
 {
-    public LuZhouCallReportApplication(ISystemSettingCacheManager systemSettingCacheManager, ICallNativeRepository callNativeRepository, IRepository<User> userRepository, IRepository<Work> workRepository, IRepository<TelRest> telRestRepository) : base(systemSettingCacheManager, callNativeRepository, userRepository, workRepository, telRestRepository)
+    public LuZhouCallReportApplication(ISystemSettingCacheManager systemSettingCacheManager, ICallNativeRepository callNativeRepository, IRepository<User> userRepository, IRepository<Work> workRepository, IRepository<TelRest> telRestRepository, ISystemDicDataCacheManager systemDicDataCacheManager) : base(systemSettingCacheManager, callNativeRepository, userRepository, workRepository, telRestRepository, systemDicDataCacheManager)
     {
     }
 }

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

@@ -41,7 +41,8 @@ public class YiBinCallReportApplication : CallReportApplicationBase, ICallReport
         IRepository<TelRest> telRestRepository,
         ICallNativeRepository callNativeRepository,
         ITrCallRecordRepository trCallRecordRepositoryEx,
-        IMapper mapper) : base(systemSettingCacheManager, callNativeRepository, userRepository, workRepository, telRestRepository)
+        IMapper mapper,
+        ISystemDicDataCacheManager systemDicDataCacheManager) : base(systemSettingCacheManager, callNativeRepository, userRepository, workRepository, telRestRepository, systemDicDataCacheManager)
     {
         _trCallRecordRepository = trCallRecordRepository;
         _systemSettingCacheManager = systemSettingCacheManager;

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

@@ -11,7 +11,7 @@ namespace Hotline.Application.StatisticalReport.CallReport;
 [Injection(AppScopes = EAppScope.ZiGong)]
 public class ZiGongCallReportApplication : CallReportApplicationBase, ICallReportApplication, IScopeDependency
 {
-    public ZiGongCallReportApplication(ISystemSettingCacheManager systemSettingCacheManager, ICallNativeRepository callNativeRepository, IRepository<User> userRepository, IRepository<Work> workRepository, IRepository<TelRest> telRestRepository) : base(systemSettingCacheManager, callNativeRepository, userRepository, workRepository, telRestRepository)
+    public ZiGongCallReportApplication(ISystemSettingCacheManager systemSettingCacheManager, ICallNativeRepository callNativeRepository, IRepository<User> userRepository, IRepository<Work> workRepository, IRepository<TelRest> telRestRepository, ISystemDicDataCacheManager systemDicDataCacheManager) : base(systemSettingCacheManager, callNativeRepository, userRepository, workRepository, telRestRepository, systemDicDataCacheManager)
     {
     }
 }

+ 2 - 1
src/Hotline.Repository.SqlSugar/CallCenter/CallNativeRepository.cs

@@ -226,10 +226,11 @@ public class CallNativeRepository : BaseRepository<CallNative>, ICallNativeRepos
         return new TotalData<BiSeatSwitchDto>(res, total.Value);
     }
 
-    public async Task<List<CallHotLineDto>> GetCallHotLineListAsync(BiQueryGateWayDto dto, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, int ringTims)
+    public async Task<List<CallHotLineDto>> GetCallHotLineListAsync(BiQueryGateWayDto dto, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, int ringTims, List<string> hotLines)
     {
         var list = await Db.Queryable<CallNative>()
             .Where(x => x.BeginIvrTime >= dto.StartTime && x.BeginIvrTime <= dto.EndTime && SqlFunc.Length(x.ToNo) > 4 && x.CallState != ECallState.Invalid)
+            .Where(x => hotLines.Contains(x.ToNo))
             .WhereIF(!string.IsNullOrEmpty(dto.Gateway), x => x.ToNo == dto.Gateway)
             .GroupBy(x => x.ToNo)
             .Select(x => new CallHotLineDto()

+ 2 - 0
src/Hotline/Caching/Interfaces/ISysDicDataCacheManager.cs

@@ -14,5 +14,7 @@ namespace Hotline.Caching.Interfaces
         void RemoveSysDicDataCache(string code);
         IReadOnlyList<SystemDicData> AcceptType { get; }
         IReadOnlyList<SystemDicData> LeaderSMS { get; }
+
+        IReadOnlyList<SystemDicData> CallForwardingSource { get; }
     }
 }

+ 2 - 0
src/Hotline/Caching/Services/SysDicDataCacheManager.cs

@@ -34,6 +34,8 @@ namespace Hotline.Caching.Services
 
         public IReadOnlyList<SystemDicData> LeaderSMS => GetSysDicDataCache(SysDicTypeConsts.LeaderSMS);
 
+        public IReadOnlyList<SystemDicData> CallForwardingSource => GetSysDicDataCache(SysDicTypeConsts.CallForwardingSource);
+
         public void RemoveSysDicDataCache(string code)
         {
             _cacheSysDicData.Remove(code);

+ 1 - 1
src/Hotline/CallCenter/Calls/ICallNativeRepository.cs

@@ -10,5 +10,5 @@ public interface ICallNativeRepository : IRepository<CallNative>
     Task<List<QueryCallsDetailDto>> QueryCallsHourDetail(DateTime beginDate, DateTime endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, int CallInOverConnRingTime, int SeatChaoTime, string? Line);
     Task<List<TrCallHourDto>?> GetCallHourList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, string source);
     Task<TotalData<BiSeatSwitchDto>> GetCallList(QueryCallListDto dto, int noConnectByeTimes, int effectiveTimes,int connectByeTimes);
-    Task<List<CallHotLineDto>> GetCallHotLineListAsync(BiQueryGateWayDto dto, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, int ringTimes);
+    Task<List<CallHotLineDto>> GetCallHotLineListAsync(BiQueryGateWayDto dto, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, int ringTimes, List<string> hotLines);
 }