Parcourir la source

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

xf il y a 1 an
Parent
commit
b65cc8c29e

+ 45 - 10
src/Hotline.Api/Controllers/Bi/BiCallController.cs

@@ -34,17 +34,19 @@ public class BiCallController : BaseController
     private readonly ITrCallRecordRepository _trCallRecordRepositoryEx;
     private readonly ISystemSettingCacheManager _systemSettingCacheManager;
     private readonly IRepository<Work> _workRepository;
+    private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
 
 
 
-    public BiCallController(
+	public BiCallController(
         IRepository<TrCallRecord> trCallRecordRepository,
         IRepository<User> userRepository,
         IRepository<TelRest> telRestRepository,
         IMapper mapper,
         ITrCallRecordRepository trCallRecordRepositoryEx,
         ISystemSettingCacheManager systemSettingCacheManager,
-        IRepository<Work> workRepository)
+        ISystemDicDataCacheManager sysDicDataCacheManager,
+		IRepository<Work> workRepository)
     {
         _trCallRecordRepository = trCallRecordRepository;
         _userRepository = userRepository;
@@ -53,7 +55,9 @@ public class BiCallController : BaseController
         _trCallRecordRepositoryEx = trCallRecordRepositoryEx;
         _systemSettingCacheManager = systemSettingCacheManager;
         _workRepository = workRepository;
-    }
+        _sysDicDataCacheManager = sysDicDataCacheManager;
+
+	}
 
     [HttpGet("calls")]
     [AllowAnonymous]
@@ -247,13 +251,44 @@ public class BiCallController : BaseController
         return list;
     }
 
-    /// <summary>
-    /// 热线号码统计
-    /// </summary>
-    /// <param name="StartDate"></param>
-    /// <param name="EndDate"></param>
-    /// <returns></returns>
-    [AllowAnonymous]
+	/// <summary>
+	/// 通话时段统计明细
+	/// </summary>
+	/// <returns></returns>
+	[HttpGet("hourcall_list")]
+	public async Task<object> QueryCallList([FromQuery] DateTime beginDate, DateTime? endDate, string type, string source, 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);
+		return list;
+	}
+
+	/// <summary>
+	/// 通话时段统计明细获取基本信息
+	/// </summary>
+	/// <param name="id"></param>
+	/// <returns></returns>
+	[HttpGet("hourcall_list_base")]
+    public async Task<object> ReTransactBaseData()
+    {
+	    var rsp = new
+	    {
+		    CallForwardingSource = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.CallForwardingSource),
+		    CallForwardingType = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.CallForwardingType),
+		};
+	    return rsp;
+    }
+
+	/// <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)
     {

+ 1 - 1
src/Hotline.Api/Controllers/OrderController.cs

@@ -3747,7 +3747,7 @@ public class OrderController : BaseController
     public async Task<object> ReTransactBaseData(string id)
     {
         var order = await _orderRepository.GetAsync(id, HttpContext.RequestAborted);
-        List<Kv> orgs = new List<Kv> { new Kv { Key = "001", Value = "市民热线服务系统" } };
+        List<Kv> orgs = new();
         if (order == null ) throw UserFriendlyException.SameMessage("无效工单信息!");
 		//中心会签调取方法
 		var org = await _workflowDomainService.GetLevelOneOrgsAsync(order.WorkflowId, HttpContext.RequestAborted);

+ 47 - 8
src/Hotline.Repository.SqlSugar/CallCenter/TrCallRecordRepository.cs

@@ -7,6 +7,7 @@ using Hotline.Share.Enums.CallCenter;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
+using System.Drawing.Printing;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -36,17 +37,20 @@ 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))
-                .Where((it,o)=> o.CallDirection == ECallDirection.In)
+                .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 => it.ColumnName)
                 .OrderBy(it => it.ColumnName)
                 .Select((it, o) => new BiCallDto()
                 {
                     Hour = it.ColumnName.Hour, //小时段
                     Total = SqlFunc.AggregateCount(o.Id),
-                    Answered = SqlFunc.AggregateSum(SqlFunc.IIF(o.AnsweredTime!=null,1,0)), //应答数
-                    Hanguped = SqlFunc.AggregateSum(SqlFunc.IIF(o.AnsweredTime==null && o.EndBy!=null && o.EndBy.Value == EEndBy.To,1,0)),//挂断数
-                }).ToListAsync();
+                    Answered = SqlFunc.AggregateSum(SqlFunc.IIF(o.AnsweredTime != null, 1, 0)), //应答数
+                    Hanguped = SqlFunc.AggregateSum(SqlFunc.IIF(o.AnsweredTime == null && o.EndBy != null && o.EndBy.Value == EEndBy.To, 1, 0)),//挂断数
+                })
+                .MergeTable()
+                .OrderBy(x => x.Hour)
+                .ToListAsync();
             var returnList = list.GroupBy(x => x.Hour)
                .Select(x => new BiCallDto()
                {
@@ -84,8 +88,8 @@ 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))
-                .Where((it, o) => o.CallDirection == ECallDirection.In)
+                .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)
                 .Select((it, o) => new TrCallHourDto()
                 {
@@ -97,6 +101,8 @@ namespace Hotline.Repository.SqlSugar.CallCenter
                     QueueByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(o.QueueTims > 0 && o.RingTimes == 0, 1, 0)), //队列挂断
                     IvrByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(o.BeginIvrTime.HasValue && !o.BeginQueueTime.HasValue && !o.BeginRingTime.HasValue && o.OnState == EOnState.NoOn, 1, 0)), //IVR挂断
                 })
+                .MergeTable()
+                .OrderBy(x=>x.Hour)
                 .ToListAsync();
 
            var resultList = list.GroupBy(x => x.Hour)
@@ -113,7 +119,40 @@ namespace Hotline.Repository.SqlSugar.CallCenter
             return resultList;
         }
 
-        public async Task<List<CallHotLineDto>> GetCallHotLineList(DateTime beginDate, DateTime endDate,string lineNum, int noConnectByeTimes, int effectiveTimes, int connectByeTimes,int ringTims)
+		/// <summary>
+		/// 通话时段统计明细
+		/// </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)
+        {
+	        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))
+				.Select(x=> new { 
+                    CPN = x.CPN,
+                    CDPN= x.CDPN,
+					CreatedTime = x.CreatedTime
+				})
+                .ToPageListAsync(pageIndex, pageSize, total);
+            return new { Data = res , Total = total.Value};
+		}
+
+		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);
             var list =await Db.Queryable<TrCallRecord>()

+ 2 - 2
src/Hotline.Repository.SqlSugar/Extensions/SqlSugarStartupExtensions.cs

@@ -207,8 +207,8 @@ namespace Hotline.Repository.SqlSugar.Extensions
             /***写AOP等方法***/
             db.Aop.OnLogExecuting = (sql, pars) =>
             {
-                //Log.Information("Sql: {0}", sql);
-                //Log.Information("SqlParameters: {0}", string.Join(',', pars.Select(d => d.Value)));
+                Log.Information("Sql: {0}", sql);
+                Log.Information("SqlParameters: {0}", string.Join(',', pars.Select(d => d.Value)));
             };
             db.Aop.OnError = (exp) =>//SQL报错
             {

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

@@ -12,6 +12,7 @@ namespace Hotline.CallCenter.Calls
 
         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);
+
+	}
 }

+ 10 - 0
src/Hotline/Settings/SysDicTypeConsts.cs

@@ -219,4 +219,14 @@ public class SysDicTypeConsts
     /// 行政司法指定部门
     /// </summary>
     public const string JudicialManagementOrg = "JudicialManagementOrg";
+
+	/// <summary>
+	/// 通话转接来源
+	/// </summary>
+	public const string CallForwardingSource = "CallForwardingSource";
+
+	/// <summary>
+	/// 通话转接分类
+	/// </summary>
+	public const string CallForwardingType = "CallForwardingType";
 }