瀏覽代碼

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

tangjiang 4 月之前
父節點
當前提交
a8941795ba

+ 66 - 1
src/Hotline.Api/Controllers/Bi/BiCallController.cs

@@ -529,11 +529,76 @@ public class BiCallController : BaseController
     /// <param name="dto"></param>
     /// <returns></returns>
     [HttpGet("query-calldate-statistics")]
-    [AllowAnonymous]
     public async Task<List<QueryCallDateStatisticsDetailResp>> QueryCallDateStatisticsDetail([FromQuery] QueryCallDateStatisticsDetailDto dto)
     {
         return await _callReportApplication.QueryCallDateStatisticsDetail(dto);
     }
 
+    /// <summary>
+    /// 话务日期统计明细导出
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpPost("query-calldate-statistics/export")]
+    public async Task<FileStreamResult> QueryCallDateStatisticsDetailExport([FromBody]ExportExcelDto<QueryCallDateStatisticsDetailDto> dto)
+         => ExcelStreamResult(
+            _exportApplication.GetExcelStream(
+                dto,
+                await _callReportApplication.QueryCallDateStatisticsDetail(dto.QueryDto)
+                )
+            , "话务日期统计明细");
+
+    /// <summary>
+    /// 个人服务话务明细
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpGet("query-person-calldate-statistics")]
+    public async Task<List<QueryPersonCallDateStatisticsDetailResp>> QueryPersonCallDateStatisticsDetail([FromQuery]QueryCallDateStatisticsDetailDto dto)
+    {
+        return await _callReportApplication.QueryPersonCallDateStatisticsDetail(dto);
+    }
+
+    /// <summary>
+    /// 个人服务话务明细导出
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpPost("query-person-calldate-statistics/export")]
+    public async Task<FileStreamResult> QueryPersonCallDateStatisticsDetailExport([FromBody]ExportExcelDto<QueryCallDateStatisticsDetailDto> dto)
+     => ExcelStreamResult(
+            _exportApplication.GetExcelStream(
+                dto,
+                await _callReportApplication.QueryPersonCallDateStatisticsDetail(dto.QueryDto)
+                )
+            , "个人服务话务明细");
+
+
+    /// <summary>
+    /// 企业服务话务明细
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpGet("query-enterprise-calldate-statistics")]
+    public async Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail([FromQuery]QueryCallDateStatisticsDetailDto dto)
+    {
+        return await _callReportApplication.QueryEnterpriseCallDateStatisticsDetail(dto);
+    }
+
+    /// <summary>
+    /// 企业服务话务明细导出
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpPost("query-enterprise-calldate-statistics/export")]
+    public async Task<FileStreamResult> QueryEnterpriseCallDateStatisticsDetailExport([FromBody]ExportExcelDto<QueryCallDateStatisticsDetailDto> dto)
+    => ExcelStreamResult(
+            _exportApplication.GetExcelStream(
+                dto,
+                await _callReportApplication.QueryPersonCallDateStatisticsDetail(dto.QueryDto)
+                )
+            , "企业服务话务明细");
+
+
     #endregion
 }

+ 10 - 0
src/Hotline.Application/StatisticalReport/CallReport/CallReportApplicationBase.cs

@@ -247,6 +247,16 @@ public abstract class CallReportApplicationBase : ICallReportApplication
             .ToPagedListAsync(dto.PageIndex, dto.PageSize, cancellationToken);
     }
 
+    public virtual Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto)
+    {
+        throw new NotImplementedException();
+    }
+
+    public virtual Task<List<QueryPersonCallDateStatisticsDetailResp>> QueryPersonCallDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto)
+    {
+        throw new NotImplementedException();
+    }
+
     /// <summary>
     /// 坐席话务统计分析
     /// </summary>

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

@@ -257,11 +257,28 @@ public class YiBinCallReportApplication : CallReportApplicationBase, ICallReport
     /// <returns></returns>
     public override async Task<List<QueryCallDateStatisticsDetailResp>> QueryCallDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto)
     {
-        //
-
         return await _trCallRecordRepositoryEx.QueryCallDateStatisticsDetail(dto.StartTime.Value,dto.EndTime.Value);
     }
 
+    /// <summary>
+    /// 个人服务话务明细
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    public override async Task<List<QueryPersonCallDateStatisticsDetailResp>> QueryPersonCallDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto)
+    {
+        return await _trCallRecordRepositoryEx.QueryPersonCallDateStatisticsDetail(dto.StartTime.Value, dto.EndTime.Value);
+    }
+
+    /// <summary>
+    /// 企业服务话务明细
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    public override async Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto)
+    {
+        return await _trCallRecordRepositoryEx.QueryEnterpriseCallDateStatisticsDetail(dto.StartTime.Value, dto.EndTime.Value);
+    }
 
 
 

+ 14 - 0
src/Hotline.Application/StatisticalReport/ICallReportApplication.cs

@@ -55,5 +55,19 @@ namespace Hotline.Application.StatisticalReport
         /// <param name="dto"></param>
         /// <returns></returns>
         Task<List<QueryCallDateStatisticsDetailResp>> QueryCallDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto);
+
+        /// <summary>
+        /// 个人服务话务明细
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        Task<List<QueryPersonCallDateStatisticsDetailResp>> QueryPersonCallDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto);
+
+        /// <summary>
+        /// 企业服务话务明细
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail(QueryCallDateStatisticsDetailDto dto);
     }
 }

+ 50 - 11
src/Hotline.Repository.SqlSugar/CallCenter/TrCallRecordRepository.cs

@@ -286,24 +286,63 @@ namespace Hotline.Repository.SqlSugar.CallCenter
                 .OrderByDescending(x => x.CreatedTime);
         }
 
+        
         public async Task<List<QueryCallDateStatisticsDetailResp>> QueryCallDateStatisticsDetail(DateTime startTime, DateTime endTime)
         {
-            return await Db.Queryable<TrCallRecord>()
+            var query =  Db.Queryable<TrCallRecord>()
                 .Where(x => x.CreatedTime >= startTime && x.CreatedTime <= endTime && SqlFunc.Length(x.Gateway) > 4 && x.CallDirection == ECallDirection.In)
                 .GroupBy(x => x.CreatedTime.ToString("yyyy-MM-dd"))
-                .Select(x => new QueryCallDateStatisticsDetailResp() {
+                .Select(x => new QueryCallDateStatisticsDetailResp()
+                {
                     Date = x.CreatedTime.ToString("yyyy-MM-dd"),
-                    PersonCallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.LastOrDefault()=='1',1,0)),
-                    EnterpriseCallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.LastOrDefault()=='2',1,0)),
-                    AiCallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Gateway == "82826886",1,0)),
-                    PersonCallInPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.LastOrDefault()=='1' && x.OnState == EOnState.On ,1,0)),
-                    EnterpriseCallInPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.LastOrDefault()=='2' && x.OnState== EOnState.On,1,0)),
+                    PersonCallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1", 1, 0)),
+                    EnterpriseCallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "2", 1, 0)),
+                    AiCallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Gateway == "82826886", 1, 0)),
+                    PersonCallInPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.OnState == EOnState.On, 1, 0)),
+                    EnterpriseCallInPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "2" && x.OnState == EOnState.On, 1, 0)),
                     AiCallInPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Gateway == "82826886", 1, 0)),
-                    PersonRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.LastOrDefault() == '1' && x.QueueTims > 0 && x.RingTimes == 0 && x.OnState == EOnState.NoOn, 1, 0)),//个人服务挂断
-                    EnterpriseRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.LastOrDefault() == '2' && x.QueueTims > 0 && x.RingTimes == 0 && x.OnState == EOnState.NoOn,1,0)), //企业挂断
+                    PersonRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.QueueTims > 0 && x.OnState == EOnState.NoOn, 1, 0)),//个人服务挂断
+                    EnterpriseRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "2" && x.QueueTims > 0 && x.RingTimes == 0 && x.OnState == EOnState.NoOn, 1, 0)), //企业挂断
                     IvrRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn, 1, 0)), //IVR挂断
-                }).ToListAsync();
-                
+                })
+                .OrderBy(x=>x.Date);
+                return await query.ToListAsync();
+        }
+
+        public async Task<List<QueryPersonCallDateStatisticsDetailResp>> QueryPersonCallDateStatisticsDetail(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.In)
+                .GroupBy(x => x.CreatedTime.ToString("yyyy-MM-dd"))
+                .Select(x => new QueryPersonCallDateStatisticsDetailResp()
+                {
+                    Date = x.CreatedTime.ToString("yyyy-MM-dd"),
+                    PersonCallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1", 1, 0)),
+                    PersonCallInPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.OnState == EOnState.On, 1, 0)),
+                    PersonRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.QueueTims > 0  && x.OnState == EOnState.NoOn, 1, 0)),//个人服务挂断
+                    PersonQueueOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.QueueTims > 0 && x.RingTimes == 0 && x.OnState == EOnState.NoOn, 1, 0)),//个人服务队列挂断
+                    PersonWaitOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length -1,1) =="1" && x.RingTimes>0 && x.OnState == EOnState.NoOn,1,0)) //个人服务等待挂断
+                })
+                .OrderBy(x => x.Date);
+            return await query.ToListAsync();
+        }
+
+        public async Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail(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.In)
+                .GroupBy(x => x.CreatedTime.ToString("yyyy-MM-dd"))
+                .Select(x => new QueryEnterpriseCallDateStatisticsDetailResp()
+                {
+                    Date = x.CreatedTime.ToString("yyyy-MM-dd"),
+                    EnterpriseCallInCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "2", 1, 0)),
+                    EnterpriseCallInPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "2" && x.OnState == EOnState.On, 1, 0)),
+                    EnterpriseRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "2" && x.QueueTims > 0 && x.RingTimes == 0 && x.OnState == EOnState.NoOn, 1, 0)), //企业挂断
+                    EnterpriseQueueOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.QueueTims > 0 && x.RingTimes == 0 && x.OnState == EOnState.NoOn, 1, 0)),//个人服务队列挂断
+                    EnterpriseWaitOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.RingTimes > 0 && x.OnState == EOnState.NoOn, 1, 0)) //个人服务等待挂断
+                })
+                .OrderBy(x => x.Date);
+            return await query.ToListAsync();
         }
     }
 }

+ 89 - 0
src/Hotline.Share/Dtos/CallCenter/BiQueryCallsDto.cs

@@ -305,4 +305,93 @@ public class QueryCallDateStatisticsDetailResp
     /// </summary>
     public string CallPutthorughRateText => CallPutthorughRate + "%";
 }
+
+
+public class QueryPersonCallDateStatisticsDetailResp
+{
+    /// <summary>
+    /// 日期
+    /// </summary>
+    public string Date { get; set; }
+
+    /// <summary>
+    /// 个人服务呼入总量
+    /// </summary>
+    public int PersonCallInCount { get; set; }
+
+    /// <summary>
+    /// 个人服务接通量
+    /// </summary>
+    public int PersonCallInPutthroughCount { get; set; }
+
+    /// <summary>
+    /// 个人服务挂断总量
+    /// </summary>
+    public int PersonRingOffCount { get; set; }
+
+    /// <summary>
+    /// 个人服务队列挂断
+    /// </summary>
+    public int PersonQueueOffCount { get; set; }
+   
+    /// <summary>
+    /// 个人服务等待挂断
+    /// </summary>
+    public int PersonWaitOffCount { get; set; }
+
+    /// <summary>
+    /// 个人服务接通率
+    /// </summary>
+    public double PersonCallPutthorughRate => PersonCallInPutthroughCount == 0 ? 0 : Math.Round(((double)(PersonCallInPutthroughCount)) / (PersonCallInCount) * 100, 2);
+
+    /// <summary>
+    ///  个人服务接通率
+    /// </summary>
+    public string PersonCallPutthorughRateText => PersonCallPutthorughRate + "%";
+}
+
+
+public class QueryEnterpriseCallDateStatisticsDetailResp
+{
+    /// <summary>
+    /// 日期
+    /// </summary>
+    public string Date { get; set; }
+   
+    /// <summary>
+    /// 企业服务呼入总量
+    /// </summary>
+    public int EnterpriseCallInCount { get; set; }
+
+    /// <summary>
+    /// 企业服务接通量
+    /// </summary>
+    public int EnterpriseCallInPutthroughCount { get; set; }
+
+    /// <summary>
+    /// 企业服务挂断总量
+    /// </summary>
+    public int EnterpriseRingOffCount { get; set; }
+
+    /// <summary>
+    /// 企业服务队列挂断
+    /// </summary>
+    public int EnterpriseQueueOffCount { get; set; }
+
+    /// <summary>
+    /// 企业服务等待挂断
+    /// </summary>
+    public int EnterpriseWaitOffCount { get; set; }
+
+    /// <summary>
+    /// 企业服务接通率
+    /// </summary>
+    public double EnterpriseCallPutthorughRate => EnterpriseCallInPutthroughCount == 0 ? 0 : Math.Round(((double)(EnterpriseCallInPutthroughCount)) / (EnterpriseCallInCount) * 100, 2);
+
+    /// <summary>
+    ///  个人服务接通率
+    /// </summary>
+    public string EnterpriseCallPutthorughRateText => EnterpriseCallPutthorughRate + "%";
+}
+
 #endregion

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

@@ -42,5 +42,22 @@ namespace Hotline.CallCenter.Calls
         /// <param name="endTime"></param>
         /// <returns></returns>
         Task<List<QueryCallDateStatisticsDetailResp>> QueryCallDateStatisticsDetail(DateTime startTime, DateTime endTime);
+
+
+        /// <summary>
+        /// 个人服务话务明细
+        /// </summary>
+        /// <param name="startTime"></param>
+        /// <param name="endTime"></param>
+        /// <returns></returns>
+        Task<List<QueryPersonCallDateStatisticsDetailResp>> QueryPersonCallDateStatisticsDetail(DateTime startTime, DateTime endTime);
+
+        /// <summary>
+        /// 企业服务话务明细
+        /// </summary>
+        /// <param name="startTime"></param>
+        /// <param name="endTime"></param>
+        /// <returns></returns>
+        Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail(DateTime startTime, DateTime endTime);
     }
 }