Dun.Jason 1 rok temu
rodzic
commit
ba27f44d1e

+ 18 - 5
src/Hotline.Api/Controllers/Bi/BiCallController.cs

@@ -210,9 +210,22 @@ public class BiCallController : BaseController
         return list;
     }
 
-
-    //public async Task QueryGateWay(DateTime StartDate,DateTime EndDate)
-    //{
-
-    //}
+    /// <summary>
+    /// 热线号码统计
+    /// </summary>
+    /// <param name="StartDate"></param>
+    /// <param name="EndDate"></param>
+    /// <returns></returns>
+    [AllowAnonymous]
+    [HttpGet("gateway-query")]
+    public async Task<List<CallHotLineDto>> QueryGateWay(DateTime beginDate, DateTime endDate,string gateway)
+    {
+        //获取配置
+        int noConnectByeTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.NoConnectByeTimes)?.SettingValue[0]);
+        int effectiveTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.EffectiveTimes)?.SettingValue[0]);
+        int connectByeTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.ConnectByeTimes)?.SettingValue[0]);
+        int ringTims = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.RingTims)?.SettingValue[0]);
+        var list = await _trCallRecordRepositoryEx.GetCallHotLineList(beginDate, endDate, gateway, noConnectByeTimes, effectiveTimes, connectByeTimes, ringTims);
+        return list;
+    }
 }

+ 18 - 4
src/Hotline.Repository.SqlSugar/CallCenter/TrCallRecordRepository.cs

@@ -72,12 +72,26 @@ namespace Hotline.Repository.SqlSugar.CallCenter
             return resultList;
         }
 
-        public async Task GetCallHotLineList(DateTime beginDate, DateTime endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes)
+        public async Task<List<CallHotLineDto>> GetCallHotLineList(DateTime beginDate, DateTime endDate,string lineNum, int noConnectByeTimes, int effectiveTimes, int connectByeTimes,int ringTims)
         {
             endDate = endDate.AddDays(1).AddSeconds(-1);
-            Db.Queryable<TrCallRecord>()
-                .Where(x => x.CreatedTime >= beginDate && x.CreatedTime <= endDate);
-                //.GroupBy(x=>x.);
+            var list =await Db.Queryable<TrCallRecord>()
+                .Where(x => x.CreatedTime >= beginDate && x.CreatedTime <= endDate)
+                .WhereIF(!string.IsNullOrEmpty(lineNum), x => x.Gateway == lineNum)
+                .GroupBy(x => x.Gateway)
+                .Select(x => new CallHotLineDto()
+                {
+                    GateWay = x.Gateway,
+                    CallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.CallDirection == ECallDirection.In, 1, 0)),//接通
+                    ConnectCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.CallDirection == ECallDirection.In && x.OnState == EOnState.On, 1, 0)),//接通
+                    NoConnectByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.CallDirection == ECallDirection.In && x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0, 1, 0)), //未接通秒挂
+                    EffectiveCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.CallDirection == ECallDirection.In && x.Duration >= effectiveTimes, 1, 0)),//有效接通
+                    DurationSum = SqlFunc.AggregateSum(SqlFunc.IIF(x.CallDirection == ECallDirection.In && x.OnState == EOnState.On,x.Duration,0)),//通话总时长
+                    ConnectByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.CallDirection == ECallDirection.In && x.Duration > 0 && x.Duration <= connectByeTimes, 1, 0)), //接通秒挂
+                    TimelyAnswerCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.CallDirection == ECallDirection.In && x.OnState == EOnState.On && x.RingTimes<= ringTims,1,0))//及时应答
+                }).ToListAsync();
+
+            return list;
         }
 
 

+ 87 - 0
src/Hotline.Share/Dtos/CallCenter/TrCallDto.cs

@@ -43,4 +43,91 @@ namespace Hotline.Share.Dtos.CallCenter
         /// </summary>
         public int IvrByeCount { get; set; }
     }
+
+    public class CallHotLineDto
+    {
+        /// <summary>
+        /// 热线号
+        /// </summary>
+        public string GateWay { get; set; }
+        /// <summary>
+        /// 呼入
+        /// </summary>
+        public int CallInCount { get; set; }
+        
+        /// <summary>
+        /// 接通
+        /// </summary>
+        public int ConnectCount { get; set; }
+
+        /// <summary>
+        /// 未接通秒挂
+        /// </summary>
+        public int NoConnectByeCount { get; set; }
+        /// <summary>
+        /// 接通率
+        /// </summary>
+        public double CallInConnectRate => CalcCallInConnectRate();
+
+
+        public double CalcCallInConnectRate()
+        {
+            if (CallInCount!=0 && ConnectCount!=0)
+            {
+                return Math.Round((ConnectCount / (double)CallInCount) * 100, 2);
+            }
+            return 0;
+        }
+
+
+        /// <summary>
+        /// 有效接通
+        /// </summary>
+        public int EffectiveCount { get; set; }
+
+        /// <summary>
+        /// 平均时长
+        /// </summary>
+        public double AveDuration => CalcAveDuration();
+
+        public double CalcAveDuration()
+        {
+            if ((EffectiveCount + ConnectByeCount)!=0 && DurationSum != 0)
+            {
+                return Math.Round((double)DurationSum / (EffectiveCount + ConnectByeCount), 1);
+            }
+            return 0;
+        }
+
+
+        /// <summary>
+        /// 通话时总长
+        /// </summary>
+        public double DurationSum { get; set; }
+
+        /// <summary>
+        /// 接通秒挂
+        /// </summary>
+        public int ConnectByeCount { get; set; }
+
+        /// <summary>
+        /// 及时应答数
+        /// </summary>
+        public int TimelyAnswerCount { get; set; }
+
+
+        /// <summary>
+        /// 有效率
+        /// </summary>
+        public double EffectiveRate => CalcEffectiveRate();
+
+        public double CalcEffectiveRate()
+        {
+            if (TimelyAnswerCount != 0 && ConnectCount!=0)
+            {
+                return Math.Round((TimelyAnswerCount / (double)ConnectCount) * 100, 2);
+            }
+            return 0;
+        }
+    }
 }

+ 2 - 1
src/Hotline/CallCenter/Calls/ITrCallRecordRepository.cs

@@ -9,7 +9,8 @@ namespace Hotline.CallCenter.Calls
         Task<List<TrCallHourDto>?> GetCallHourList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes,int connectByeTimes);
 
 
-        Task GetCallHotLineList(DateTime beginDate, DateTime endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes);
+        Task<List<CallHotLineDto>> GetCallHotLineList(DateTime beginDate, DateTime endDate, string lineNum, int noConnectByeTimes, int effectiveTimes, int connectByeTimes,int ringTims);
 
+        
     }
 }

+ 4 - 0
src/XF.Domain/Constants/SettingConstants.cs

@@ -120,6 +120,10 @@ namespace XF.Domain.Constants
         /// </summary>
         public const string ConnectByeTimes = "ConnectByeTimes";
         /// <summary>
+        /// 及时应答时间
+        /// </summary>
+        public const string RingTims = "RingTims";
+        /// <summary>
         /// 大屏数据展示推送间隔时间
         /// </summary>
         public const string BsDataShowChangedTimes = "BsDataShowChangedTimes";