Ver código fonte

Merge branch 'dev' into dev_dss

Dun.Jason 1 ano atrás
pai
commit
51ad8736ec

+ 4 - 4
src/Hotline.Api/Controllers/Bi/BiCallController.cs

@@ -241,13 +241,13 @@ public class BiCallController : BaseController
     /// <returns></returns>
     [HttpGet("hourcall")]
     [AllowAnonymous]
-    public async Task<List<TrCallHourDto>> QueryHourCall([FromQuery]DateTime beginDate,DateTime? endDate)
+    public async Task<List<TrCallHourDto>> QueryHourCall([FromQuery]DateTime beginDate,DateTime? endDate, string source)
     {
         //获取配置
         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]);
-        var list = await _trCallRecordRepositoryEx.GetCallHourList(beginDate,endDate,noConnectByeTimes,effectiveTimes,connectByeTimes);
+        var list = await _trCallRecordRepositoryEx.GetCallHourList(beginDate,endDate,noConnectByeTimes,effectiveTimes,connectByeTimes,source);
         return list;
     }
 
@@ -256,13 +256,13 @@ public class BiCallController : BaseController
 	/// </summary>
 	/// <returns></returns>
 	[HttpGet("hourcall_list")]
-	public async Task<object> QueryCallList([FromQuery] DateTime beginDate, DateTime? endDate, string type, string source, int pageIndex, int pageSize)
+	public async Task<object> QueryCallList([FromQuery] DateTime beginDate, DateTime? endDate, string type, string source, TimeSpan? startHourTo , int pageIndex, int pageSize)
 	{
 		//获取配置
 		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]);
-		var list = await _trCallRecordRepositoryEx.GetCallList(beginDate, endDate, noConnectByeTimes, effectiveTimes, connectByeTimes, type, source, pageIndex, pageSize);
+		var list = await _trCallRecordRepositoryEx.GetCallList(beginDate, endDate, noConnectByeTimes, effectiveTimes, connectByeTimes, type, source, startHourTo,pageIndex, pageSize);
 		return list;
 	}
 

+ 26 - 17
src/Hotline.Repository.SqlSugar/CallCenter/TrCallRecordRepository.cs

@@ -63,7 +63,7 @@ namespace Hotline.Repository.SqlSugar.CallCenter
             return returnList;
         }
 
-        public async Task<List<TrCallHourDto>?> GetCallHourList(DateTime beginDate,DateTime? endDate,int noConnectByeTimes,int effectiveTimes,int connectByeTimes)
+        public async Task<List<TrCallHourDto>?> GetCallHourList(DateTime beginDate,DateTime? endDate,int noConnectByeTimes,int effectiveTimes,int connectByeTimes, string source)
         {
             //计算小时差
             if (!endDate.HasValue)
@@ -89,8 +89,9 @@ namespace Hotline.Repository.SqlSugar.CallCenter
 
             var list = await Db.Reportable(dts).ToQueryable<DateTime>()
                 .LeftJoin<TrCallRecord>((it, o) => o.CreatedTime >= it.ColumnName && o.CreatedTime < it.ColumnName.AddHours(1) && o.CallDirection == ECallDirection.In)
-                //.Where((it, o) => o.CallDirection == ECallDirection.In)
-                .GroupBy((it,o) => it.ColumnName)
+				 //.Where((it, o) => o.CallDirection == ECallDirection.In)
+				 .WhereIF(!string.IsNullOrEmpty(source), (it,o) => o.CDPN == source)
+				.GroupBy((it,o) => it.ColumnName)
                 .Select((it, o) => new TrCallHourDto()
                 {
                     DateTimeTo = it.ColumnName, 
@@ -109,7 +110,9 @@ namespace Hotline.Repository.SqlSugar.CallCenter
                 .Select(x=> new TrCallHourDto() { 
                     Hour = x.Key,
                     HourTo = x.Key.ToString().PadLeft(2, '0') + ":00 - " + (x.Key).ToString().PadLeft(2, '0') + ":59",
-                    EffectiveCount = x.Sum(d=>d.EffectiveCount),
+                    StartHourTo= x.Key.ToString().PadLeft(2, '0') + ":00",
+                    EndHourTo = x.Key.ToString().PadLeft(2, '0') + ":59",
+					EffectiveCount = x.Sum(d=>d.EffectiveCount),
                     ConnectByeCount = x.Sum(d=>d.ConnectByeCount),
                     NoConnectByeCount = x.Sum(d=>d.NoConnectByeCount),
                     QueueByeCount = x.Sum(d=>d.QueueByeCount),
@@ -123,26 +126,32 @@ namespace Hotline.Repository.SqlSugar.CallCenter
 		/// 通话时段统计明细
 		/// </summary>
 		/// <returns></returns>
-        public async Task<object> GetCallList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, string type, string source ,int pageIndex, int pageSize)
+        public async Task<object> GetCallList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, string type, string source , TimeSpan? startHourTo, int pageIndex, int pageSize)
         {
+            TimeSpan endHourTo = DateTime.Now.TimeOfDay;
+			if (startHourTo.HasValue)
+	        {
+                 endHourTo = startHourTo.Value.Add(new TimeSpan(1, 0, 0));
+			}
 	        endDate = endDate.Value.Date.AddDays(1).AddSeconds(-1);
 	        RefAsync<int> total = 0;
 			var res = await Db.Queryable<TrCallRecord>()
                 .Where(x => x.CreatedTime >= beginDate && x.CreatedTime <= endDate)
                 .Where(x => x.CallDirection == ECallDirection.In)
                 .WhereIF(!string.IsNullOrEmpty(source), x => x.CDPN == source)
-                .WhereIF(!string.IsNullOrEmpty(type) && ("QueueBye".Equals(type) || "queueByeCount".Equals(type)), x => x.QueueTims > 0 && x.RingTimes == 0)
-                .WhereIF(!string.IsNullOrEmpty(type) &&("IvrBye".Equals(type)|| "ivrByeCount".Equals(type)) , x => x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn)
-                .WhereIF(!string.IsNullOrEmpty(type) && ("Effective".Equals(type) || "effectiveCount".Equals(type)), x => x.Duration >= effectiveTimes)
-                .WhereIF(!string.IsNullOrEmpty(type) && "Invalid".Equals(type) , x => x.Duration < effectiveTimes)
-                .WhereIF(!string.IsNullOrEmpty(type) && "connectByeCount".Equals(type) , x => x.Duration > 0 && x.Duration <= connectByeTimes)
-                .WhereIF(!string.IsNullOrEmpty(type) && "noConnectByeCount".Equals(type), x => x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0)
-                .WhereIF(!string.IsNullOrEmpty(type) && "count".Equals(type), x => 
-                (x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0)
-                ||(x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0)
-				||(x.Duration >= effectiveTimes)
-				||(x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn)
-				||(x.QueueTims > 0 && x.RingTimes == 0))
+                .WhereIF(!string.IsNullOrEmpty(type) && ("QueueBye".Equals(type) || "queueByeCount".Equals(type)), x => x.QueueTims > 0 && x.RingTimes == 0) //队列挂断
+				.WhereIF(!string.IsNullOrEmpty(type) &&("IvrBye".Equals(type)|| "ivrByeCount".Equals(type)) , x => x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn)//IVR挂断
+				.WhereIF(!string.IsNullOrEmpty(type) && ("Effective".Equals(type) || "effectiveCount".Equals(type)), x => x.Duration >= effectiveTimes) //有效接通
+				.WhereIF(!string.IsNullOrEmpty(type) && "Invalid".Equals(type) , x => x.Duration > 0 && x.Duration < effectiveTimes)//无效接通
+				.WhereIF(!string.IsNullOrEmpty(type) && "connectByeCount".Equals(type) , x => x.Duration > 0 && x.Duration <= connectByeTimes)  //接通秒挂
+				.WhereIF(!string.IsNullOrEmpty(type) && "noConnectByeCount".Equals(type), x => x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0)  //未接通秒挂
+				.WhereIF(!string.IsNullOrEmpty(type) && "count".Equals(type), x => 
+                (x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0)  //未接通秒挂
+				|| (x.Duration > 0 && x.Duration <= connectByeTimes)  //接通秒挂
+				|| (x.Duration >= effectiveTimes)//有效接通
+				|| (x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn) //IVR挂断
+				|| (x.QueueTims > 0 && x.RingTimes == 0))//队列挂断
+				.WhereIF(startHourTo.HasValue, x=>SqlFunc.ToTime(x.CreatedTime.ToString("HH:mm:ss")) >= startHourTo.Value && SqlFunc.ToTime(x.CreatedTime.ToString("HH:mm:ss")) < endHourTo)
 				.Select(x=> new { 
                     CPN = x.CPN,
                     CDPN= x.CDPN,

+ 5 - 1
src/Hotline.Share/Dtos/CallCenter/TrCallDto.cs

@@ -14,7 +14,11 @@ namespace Hotline.Share.Dtos.CallCenter
 
         public string HourTo { get; set; }
 
-        public DateTime DateTimeTo { get; set; }
+        public string StartHourTo { get; set; }
+
+        public string EndHourTo { get; set; }
+
+		public DateTime DateTimeTo { get; set; }
 
         /// <summary>
         /// 总计

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

@@ -7,12 +7,12 @@ namespace Hotline.CallCenter.Calls
     {
 
         Task<List<BiCallDto>?> GetQueryCalls(DateTime beginDate, DateTime endDate);
-        Task<List<TrCallHourDto>?> GetCallHourList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes,int connectByeTimes);
+        Task<List<TrCallHourDto>?> GetCallHourList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes,int connectByeTimes, string source);
 
 
         Task<List<CallHotLineDto>> GetCallHotLineList(DateTime beginDate, DateTime endDate, string lineNum, int noConnectByeTimes, int effectiveTimes, int connectByeTimes,int ringTims);
 
-        Task<object> GetCallList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, string type, string source, int pageIndex, int pageSize);
+        Task<object> GetCallList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, string type, string source, TimeSpan? startHourTo, int pageIndex, int pageSize);
 
 	}
 }