瀏覽代碼

BiSeatCalls

xf 1 年之前
父節點
當前提交
f2a6e13fee

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

@@ -1,6 +1,7 @@
 using Hotline.CallCenter.Calls;
 using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Enums.CallCenter;
+using Hotline.Share.Enums.User;
 using Hotline.Share.Requests;
 using Hotline.Users;
 using Microsoft.AspNetCore.Authorization;
@@ -63,7 +64,7 @@ public class BiCallController : BaseController
             })
             .OrderBy(d => d.Hour)
             .ToListAsync(HttpContext.RequestAborted);
-        
+
         if (items.Count < 24)
         {
             for (var i = 0; i < 24; i++)
@@ -83,9 +84,31 @@ public class BiCallController : BaseController
     [AllowAnonymous]
     public async Task<IReadOnlyList<BiSeatCallsDto>> QuerySeatCallsAsync([FromQuery] ReportPagedRequest dto)
     {
-        //_userRepository.Queryable()
-        //    .LeftJoin<TrCallRecord>()
+        //from config
+        var hangupSeconds = 5;
 
-        throw new NotImplementedException();
+        return await _userRepository.Queryable()
+              .LeftJoin<TrCallRecord>((u, c) => u.Id == c.UserId)
+              .Where(u => !u.IsDeleted && u.UserType == EUserType.Seat)
+              .WhereIF(dto.StartTime.HasValue, (_, c) => c.CreatedTime >= dto.StartTime.Value)
+              .WhereIF(dto.EndTime.HasValue, (_, c) => c.CreatedTime <= dto.EndTime.Value)
+              .GroupBy((u, c) => new { c.UserName, c.TelNo })
+              .Select((u, c) => new BiSeatCallsDto
+              {
+                  Name = c.UserName,
+                  TelNo = c.TelNo,
+                  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)),
+                  InHanguped = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime == null, 1, 0)),
+                  InDurationAvg = SqlFunc.AggregateAvg(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null, c.Duration, 0)),
+                  OutDurationAvg = 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)),
+              })
+              .MergeTable()
+              .ToListAsync(HttpContext.RequestAborted);
     }
 }

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

@@ -21,6 +21,7 @@ using Hotline.Share.Enums.CallCenter;
 using System;
 using Hotline.Settings.CommonOpinions;
 using Hotline.Share.Enums.Identity;
+using Hotline.Share.Enums.User;
 using XF.Domain.Repository;
 
 namespace Hotline.Api.Controllers;
@@ -427,7 +428,8 @@ public class UserController : BaseController
     {
         return new
         {
-            GenderOptions = EnumExts.GetDescriptions<EGender>()
+            GenderOptions = EnumExts.GetDescriptions<EGender>(),
+            UserTypeOptions = EnumExts.GetDescriptions<EUserType>(),
         };
     }
 

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

@@ -606,7 +606,7 @@ public class WorkflowController : BaseController
             query = query.Where((c, w, o) => c.StarterId == _sessionContext.RequiredUserId);
 
         var items = await query
-            .OrderByDescending((c, w, o) => w.ExpiredTime)
+            .OrderByDescending((c, w, o) => o.ExpiredTime)
             .Select((c, w, o) => new { c, o })
             .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
 

+ 7 - 2
src/Hotline.Share/Dtos/CallCenter/BiSeatCallsDto.cs

@@ -15,6 +15,11 @@ public class BiSeatCallsDto
     /// </summary>
     public string StaffNo { get; set; }
 
+    /// <summary>
+    /// 分机号
+    /// </summary>
+    public string TelNo { get; set; }
+
     /// <summary>
     /// 呼入总量
     /// </summary>
@@ -68,12 +73,12 @@ public class BiSeatCallsDto
     /// <summary>
     /// 登录时长(分钟)
     /// </summary>
-    public int LoginDuration { get; set; }
+    public double LoginDuration { get; set; }
 
     /// <summary>
     /// 小修+摘机时长
     /// </summary>
-    public int RestDuration { get; set; }
+    public double RestDuration { get; set; }
 
     /// <summary>
     /// 呼入接通率

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

@@ -5,7 +5,7 @@ using XF.Domain.Repository;
 
 namespace Hotline.CallCenter.Calls
 {
-    public class TrCallRecord: CreationEntity
+    public class TrCallRecord : CreationEntity
     {
         /// <summary>
         /// IPPBX用户名
@@ -45,6 +45,7 @@ namespace Hotline.CallCenter.Calls
         public string? TelNo { get; set; }
         public string? UserId { get; set; }
         public string? UserName { get; set; }
+        public string? StaffNo { get; set; }
         /// <summary>
         /// 通话录音绝对路径
         /// </summary>
@@ -84,7 +85,7 @@ namespace Hotline.CallCenter.Calls
         /// <summary>
         /// IVR结束时间
         /// </summary>
-        public DateTime? EndIvrTime{ get; set; }
+        public DateTime? EndIvrTime { get; set; }
         /// <summary>
         /// 开始等待时间
         /// </summary>

+ 0 - 1
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -81,7 +81,6 @@ namespace Hotline.FlowEngine.Workflows
                 Steps = new(),
                 Traces = new(),
                 WorkflowDefinition = definition,
-                //CenterToOrgTime = DateTime.Now,
                 ExternalId = externalId ?? string.Empty,
                 FlowedOrgIds = new List<string> { userCode },
                 FlowedUserIds = new List<string> { userId },