Dun.Jason 1 jaar geleden
bovenliggende
commit
13ddce9996

+ 32 - 6
src/Hotline.Api/Controllers/Bi/BiCallController.cs

@@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Mvc;
 using SqlSugar;
 using System.Data;
 using XF.Domain.Constants;
+using XF.Domain.Exceptions;
 using XF.Domain.Repository;
 
 namespace Hotline.Api.Controllers.Bi;
@@ -107,14 +108,23 @@ public class BiCallController : BaseController
          return await _trCallRecordRepositoryEx.GetQueryCalls(dto.StartTime.Value, dto.EndTime.Value);
 
     }
-
+    /// <summary>
+    /// 坐席话务统计分析
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
     [HttpGet("seats")]
     [AllowAnonymous]
     public async Task<IReadOnlyList<BiSeatCallsDto>> QuerySeatCallsAsync([FromQuery] ReportPagedRequest dto)
     {
-        //from config
-        var hangupSeconds = 5;
+        if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+        dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
 
+        //获取配置
+        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]);
+        
         return await _userRepository.Queryable()
               .LeftJoin<TrCallRecord>((u, c) => u.Id == c.UserId)
               .Where(u => !u.IsDeleted && u.UserType == EUserType.Seat)
@@ -124,18 +134,27 @@ public class BiCallController : BaseController
               .Select((u, c) => new BiSeatCallsDto
               {
                   Name = c.UserName,
+                  UserId = c.UserId,
                   InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In, 1, 0)),
                   OutTotal = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.Out, 1, 0)),
                   InAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null, 1, 0)),
                   OutAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.Out && c.AnsweredTime != null, 1, 0)),
-                  InHangupImmediate = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime == null && c.RingTimes < hangupSeconds, 1, 0)),
+                  InHangupImmediate = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime == null && c.RingTimes < noConnectByeTimes, 1, 0)),
                   InHanguped = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime == null, 1, 0)),
                   InDurationAvg = SqlFunc.Ceil(SqlFunc.AggregateAvg(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null, c.Duration, 0))),
                   OutDurationAvg = SqlFunc.Ceil(SqlFunc.AggregateAvg(SqlFunc.IIF(c.CallDirection == ECallDirection.Out && c.AnsweredTime != null, c.Duration, 0))),
-                  InAvailableAnswer = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null && c.Duration >= hangupSeconds, 1, 0)),
-                  InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null && c.Duration < hangupSeconds, 1, 0)),
+                  InAvailableAnswer = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null && c.Duration >= effectiveTimes, 1, 0)),
+                  InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null && c.Duration < connectByeTimes, 1, 0)),
               })
               .MergeTable()
+              .LeftJoin<Work>((it, o) => it.UserId == o.Id)
+              .GroupBy((it, o) => new { it.UserId,it.Name })
+              .Select((it, o) => new BiSeatCallsDto
+              {
+                  Name = it.Name,
+                  UserId = it.UserId,
+
+              })
               .ToListAsync(HttpContext.RequestAborted);
     }
 
@@ -148,6 +167,9 @@ public class BiCallController : BaseController
     [AllowAnonymous]
     public async Task<IReadOnlyList<BiSeatRestDto>> QuerySeatRest([FromQuery]QuerySeatRestRequest dto)
     {
+        if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+        dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+
         return await _telRestRepository.Queryable()
             .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
             .WhereIF(!string.IsNullOrEmpty(dto.StaffNo), x => x.StaffNo.Contains(dto.StaffNo))
@@ -177,6 +199,10 @@ public class BiCallController : BaseController
     [AllowAnonymous]
     public async Task<PagedDto<BiSeatSwitchDto>> QuerySeatSwitch([FromQuery]QuerySeatSwitchRequest dto)
     {
+        if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+
+        dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+
         var (total,items) = await _trCallRecordRepository.Queryable()
             .Where(x => !string.IsNullOrEmpty(x.AgentTransferNumber))
             .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))

+ 5 - 1
src/Hotline.Api/Controllers/Bi/BiKnowledgeController.cs

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
 using SqlSugar;
 using Hotline.Settings;
 using Hotline.Repository.SqlSugar.Extensions;
+using XF.Domain.Exceptions;
 
 namespace Hotline.Api.Controllers.Bi
 {
@@ -25,7 +26,10 @@ namespace Hotline.Api.Controllers.Bi
 		[HttpGet("data_list")]
 		public async Task<PagedDto<KnowledgeBiDataListVo>> DataList([FromQuery] KnowledgeBiDataListDto dto)
 		{
-			var query = _knowledgeRepository.Queryable(false,true,false)
+            if (!dto.CreationTimeStart.HasValue || !dto.CreationTimeEnd.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+            dto.CreationTimeEnd = dto.CreationTimeEnd.Value.AddDays(1).AddSeconds(-1);
+
+            var query = _knowledgeRepository.Queryable(false,true,false)
 				.LeftJoin<SystemOrganize>((x,o)=>x.SourceOrganizeId == o.Id)
 				.WhereIF(dto.CreationTimeStart.HasValue, (x,o) => x.CreationTime >= dto.CreationTimeStart)
 				.WhereIF(dto.CreationTimeEnd.HasValue, (x,o)=> x.CreationTime <= dto.CreationTimeEnd)

+ 28 - 0
src/Hotline.Api/Controllers/Bi/BiOrderController.cs

@@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using SharpCompress.Archives;
 using SqlSugar;
+using System.Transactions;
 using XF.Domain.Exceptions;
 using XF.Domain.Repository;
 
@@ -144,6 +145,9 @@ namespace Hotline.Api.Controllers.Bi
         public async Task<PagedDto<OrderBiCentreDataListVo>> CentreDataList([FromQuery] ReportPagedRequest dto)
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+
             var query = _orderRepository.Queryable(false, false, false)
                 .WhereIF(dto.StartTime.HasValue, x => x.CreationTime >= dto.StartTime)
                 .WhereIF(dto.EndTime.HasValue, x => x.CreationTime <= dto.EndTime)
@@ -190,6 +194,9 @@ namespace Hotline.Api.Controllers.Bi
         public async Task<PagedDto<HotspotDataLsitVo>> HotspotSubtotalDataLsit([FromQuery] HotspotSubtotalReportPagedRequest dto)
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+
             var query = _hotspotTypeRepository.Queryable(false, true)
                 .LeftJoin<Order>((x, o) => o.HotspotSpliceName != null && (x.HotSpotFullName == o.HotspotSpliceName || o.HotspotSpliceName.Contains(x.HotSpotFullName)) && o.IsDeleted == false)
                 .WhereIF(dto.StartTime.HasValue, (x, o) => o.CreationTime >= dto.StartTime)
@@ -218,6 +225,14 @@ namespace Hotline.Api.Controllers.Bi
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
             if (dto.Type == 0 && (!dto.ChainStartTime.HasValue || !dto.ChainEndTime.HasValue)) throw UserFriendlyException.SameMessage("请选择环比时间!");
+
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+
+            if (dto.Type==0)
+            {
+                dto.ChainEndTime = dto.ChainEndTime.Value.AddDays(1).AddSeconds(-1);
+            }
+
             var items = await _hotspotTypeRepository.Queryable(false, true)
                 .LeftJoin<Order>((x, o) => o.HotspotSpliceName != null && (x.HotSpotName == o.HotspotSpliceName || o.HotspotSpliceName.Contains(x.HotSpotName)) && o.IsDeleted == false)
                 .WhereIF(dto.StartTime.HasValue, (x, o) => o.CreationTime >= dto.StartTime)
@@ -304,6 +319,9 @@ namespace Hotline.Api.Controllers.Bi
         public async Task<object> QueryVisitNoSatisfied([FromQuery] QueryVisitNoSatiisfiedRequest dto)
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+
             var dissatisfiedReason = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.DissatisfiedReason);
             List<dynamic>? list = new List<dynamic>();
             //DataTable dt = new DataTable();
@@ -344,6 +362,9 @@ namespace Hotline.Api.Controllers.Bi
         public async Task<PagedDto<OrderVisitDetailDto>> BiQueryVisitNoSatisfiedDetail([FromQuery] BiQueryVisitNoSatisfiedDetailDto dto)
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+
             var (total, items) = await _orderVisitDetailRepository.Queryable()
                 .Includes(x => x.OrderVisit, d => d.Order)
                 .Includes(x => x.OrderVisit, d => d.Employee)
@@ -369,6 +390,9 @@ namespace Hotline.Api.Controllers.Bi
         public async Task<IReadOnlyList<BiOrderDelayDataDto>> QueryOrderDelayDataList([FromQuery] QueryOrderDelayDataListRequest dto)
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
+
             var list = await _orderDelayRepository.Queryable()
                 .LeftJoin<SystemOrganize>((x, o) => x.ApplyOrgCode == o.Id)
                 .WhereIF(dto.StartTime.HasValue, (x, o) => x.CreationTime >= dto.StartTime)
@@ -398,6 +422,7 @@ namespace Hotline.Api.Controllers.Bi
         public async Task<PagedDto<OrderBiSpecialListVo>> SpecialDataList([FromQuery] ReportPagedRequest dto)
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
             var query = _orderSpecialRepository.Queryable()
                 .WhereIF(dto.StartTime.HasValue, x => x.CreationTime >= dto.StartTime)
                 .WhereIF(dto.EndTime.HasValue, x => x.CreationTime <= dto.EndTime)
@@ -434,6 +459,7 @@ namespace Hotline.Api.Controllers.Bi
         public async Task<PagedDto<OrderSpecialDto>> List([FromQuery] OrderSpecialListDto dto)
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
             var (total, items) = await _orderSpecialRepository.Queryable()
                 .Includes(x => x.Order)
                 .WhereIF(!string.IsNullOrEmpty(dto.Keyword),
@@ -457,6 +483,7 @@ namespace Hotline.Api.Controllers.Bi
         public async Task<PagedDto<AcceptTypeTop10Vo>> AcceptTypeTop10List([FromQuery] ReportPagedRequest dto)
         {
             if (!dto.StartTime.HasValue || !dto.EndTime.HasValue) throw UserFriendlyException.SameMessage("请选择时间!");
+            dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
             dto.PageIndex = 1;
             dto.PageSize = 10;
             var query = _orderRepository.Queryable(false, false, false)
@@ -531,6 +558,7 @@ namespace Hotline.Api.Controllers.Bi
         [HttpGet("hotport-org-statistics")]
         public async Task<object> HotPortJoinOrgStatistics([FromQuery] HotPortJoinOrgStatisticsRequest dto)
         {
+            dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
             return await _orderRepository.HotPortJoinOrgStatistics(dto.StartTime, dto.EndTime);
         }
 

+ 0 - 1
src/Hotline.Api/Controllers/UserController.cs

@@ -149,7 +149,6 @@ public class UserController : BaseController
     /// 分页查询用户
     /// </summary>
     /// <returns></returns>
-    [Permission(EPermission.QueryPagedUser)]
     [HttpGet("paged")]
     public async Task<PagedDto<UserDto>> QueryPaged([FromQuery] UserPagedDto dto)
     {

+ 1 - 1
src/Hotline.Repository.SqlSugar/CallCenter/TrCallRecordRepository.cs

@@ -43,7 +43,7 @@ namespace Hotline.Repository.SqlSugar.CallCenter
                 .Select((it, o) => new BiCallDto()
                 {
                     Hour = it.ColumnName.Hour, //小时段
-                    Total = SqlFunc.AggregateCount(it.ColumnName),
+                    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();

+ 1 - 0
src/Hotline.Share/Dtos/CallCenter/BiCallDto.cs

@@ -16,6 +16,7 @@ namespace Hotline.Share.Dtos.CallCenter
         public int Hour { get; set; }
 
         public int Total { get; set; }
+    };
 
         /// <summary>
         /// 应答量

+ 5 - 0
src/Hotline.Share/Dtos/CallCenter/BiSeatCallsDto.cs

@@ -10,6 +10,11 @@ public class BiSeatCallsDto
     /// </summary>
     public string Name { get; set; }
 
+    /// <summary>
+    /// 用户ID
+    /// </summary>
+    public string UserId { get; set; }
+
     /// <summary>
     /// 工号
     /// </summary>