Dun.Jason 1 năm trước cách đây
mục cha
commit
4c665d36ad

+ 44 - 3
src/Hotline.Api/Controllers/Bi/BiCallController.cs

@@ -1,10 +1,14 @@
 using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Tels;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Share.Dtos;
 using Hotline.Share.Dtos.CallCenter;
+using Hotline.Share.Dtos.Users;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Enums.User;
 using Hotline.Share.Requests;
 using Hotline.Users;
+using MapsterMapper;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
 using SqlSugar;
@@ -20,15 +24,18 @@ public class BiCallController : BaseController
     private readonly IRepository<TrCallRecord> _trCallRecordRepository;
     private readonly IRepository<User> _userRepository;
     private readonly IRepository<TelRest> _telRestRepository;
+    private readonly IMapper _mapper;
 
     public BiCallController(
         IRepository<TrCallRecord> trCallRecordRepository,
         IRepository<User> userRepository,
-        IRepository<TelRest> telRestRepository)
+        IRepository<TelRest> telRestRepository,
+        IMapper mapper)
     {
         _trCallRecordRepository = trCallRecordRepository;
         _userRepository = userRepository;
         _telRestRepository = telRestRepository;
+        _mapper = mapper;
     }
 
     [HttpGet("calls")]
@@ -116,10 +123,14 @@ public class BiCallController : BaseController
               .ToListAsync(HttpContext.RequestAborted);
     }
 
-    
+    /// <summary>
+    /// 小休统计
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
     [HttpGet("rests")]
     [AllowAnonymous]
-    public async Task<IReadOnlyList<BiSeatRestDto>> QuerySeatRestAsync([FromQuery]QuerySeatRestRequest dto)
+    public async Task<IReadOnlyList<BiSeatRestDto>> QuerySeatRest([FromQuery]QuerySeatRestRequest dto)
     {
         return await _telRestRepository.Queryable()
             .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
@@ -140,4 +151,34 @@ public class BiCallController : BaseController
             .MergeTable()
             .ToListAsync(HttpContext.RequestAborted);
     }
+
+    /// <summary>
+    /// 坐席转接统计
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpGet("seatswitch")]
+    [AllowAnonymous]
+    public async Task<PagedDto<BiSeatSwitchDto>> QuerySeatSwitch([FromQuery]QuerySeatSwitchRequest dto)
+    {
+        var (total,items) = await _trCallRecordRepository.Queryable()
+            .Where(x => string.IsNullOrEmpty(x.AgentTransferNumber))
+            .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
+            .WhereIF(!string.IsNullOrEmpty(dto.CDPN), x => x.CDPN.Contains(dto.CDPN))
+            .WhereIF(dto.StartTime.HasValue,x=>x.CreatedTime >= dto.StartTime.Value)
+            .WhereIF(dto.EndTime.HasValue,x=>x.CreatedTime <= dto.EndTime.Value)
+            .Select(x=> new BiSeatSwitchDto { 
+                UserId = x.UserId,
+                CPN = x.CPN,
+                CDPN = x.CDPN,
+                CreatedTime = x.CreatedTime,
+                TelNo = x.AgentTransferNumber,
+                UserName = x.UserName,
+            })
+            .OrderByDescending(x => x.CreatedTime)
+            .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
+
+        return new PagedDto<BiSeatSwitchDto>(total, _mapper.Map<IReadOnlyList<BiSeatSwitchDto>>(items));
+
+    }
 }

+ 9 - 2
src/Hotline.Api/Controllers/IPPbxController.cs

@@ -289,6 +289,10 @@ namespace Hotline.Api.Controllers
 
             //获取用户
             var work = await _userCacheManager.GetWorkByTelNoLast(model.TelNo);
+            if (!string.IsNullOrEmpty(model.AgentTransferNumber))
+            {
+                work = await _userCacheManager.GetWorkByTelNoLast(model.AgentTransferNumber);
+            }
             if (work != null)
             {
                 model.UserId = work.UserId;
@@ -307,8 +311,11 @@ namespace Hotline.Api.Controllers
                 }
                 var trCallDto = _mapper.Map<TrCallDto>(model);
                 publishCallRecordDto.TrCallRecordDto = trCallDto;
-                //推省上
-                await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineCallBye, publishCallRecordDto);
+                if (string.IsNullOrEmpty(model.AgentTransferNumber))
+                {
+                    //推省上
+                    await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineCallBye, publishCallRecordDto);
+                }
             }
 
             return OpenResponse.Ok("success");

+ 1 - 16
src/Hotline.Application/Mappers/CallMapperConfigs.cs

@@ -19,31 +19,16 @@ namespace Hotline.Application.Mappers
                 .Map(d => d.RecordingFileName, x => x.recording_file_name)
                 .Map(d => d.CallDirection, x => x.call_direction == "in" ? ECallDirection.In : ECallDirection.Out)
                 .Map(d => d.EndBy, x => x.hangup_side == "caller" ? EEndBy.From : (x.hangup_side == "callee" ? EEndBy.To : EEndBy.None))
+                .Map(d => d.AgentTransferNumber, x => x.agent_transfer_number)
                 .Map(d => d.CallAccept, x => x.call_accept)
                 .Map(d => d.CPN, x => x.caller_id_number)
                 .Map(d => d.CPNName, x => x.caller_id_name)
                 .Map(d=>d.CDPN,x=>x.destination_number)
                 .Map(d => d.RecordingFileUrl, x => x.recording_file_url)
-                //.Map(d => d.CreatedTime, x => x.created_time)
-                //.Map(d=> d.AnsweredTime,x=>x.answered_time)
-                //.IgnoreIf((s, d) => s.answered_time == null, d => d.AnsweredTime)
-                //.Map(d => d.OverTime, x => x.over_time)
                 .Map(d => d.Gateway, x => x.gateway)
                 .Map(d => d.OtherStr, x => x.other_str)
                 .Map(d => d.OtherAccept, x => x.other_accept)
                 .Map(d => d.Status, x => x.status)
-                //.Map(d=>d.BeginIvrTime,x=>x.beginIvrTime)
-                //.Map(d=>d.EndIvrTime,x=>x.endIvrTime)
-                //.Map(d=>d.BeginQueueTime,x=>x.beginQueueTime)
-                //.Map(d=>d.EndQueueTime,x=>x.endQueueTime)
-                //.Map(d=>d.BeginRingTime,x=>x.beginRingTime)
-                //.Map(d=>d.EndRingTimg,x=>x.endRingTime)
-                //.IgnoreIf((s, d) => s.beginIvrTime == null, d => d.BeginIvrTime)
-                //.IgnoreIf((s, d) => s.endIvrTime == null, d => d.EndIvrTime)
-                //.IgnoreIf((s, d) => s.beginQueueTime == null, d => d.BeginQueueTime)
-                //.IgnoreIf((s, d) => s.endQueueTime == null, d => d.EndQueueTime)
-                //.IgnoreIf((s, d) => s.beginRingTime == null, d => d.BeginRingTime)
-                //.IgnoreIf((s, d) => s.endRingTime == null, d => d.EndRingTimg)
                 .Map(d => d.OlaQueue, x => x.ola_queue)
                 .Map(d => d.BatchAccept, x => x.batch_accept)
                 .Map(d => d.IvrDtmf, x => x.ivr_dtmf)

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

@@ -112,4 +112,29 @@ public class BiSeatRestDto
     public int RestCount { get; set; }
 
     public double RestDuration { get; set; }
+}
+
+
+public class BiSeatSwitchDto
+{
+    public string? UserId { get; set; }
+
+    public string? UserName { get; set; }
+
+    public string? CPN { get; set; }
+
+    /// <summary>
+    /// 外线号码
+    /// </summary>
+    public string? CDPN { get; set; }
+
+    /// <summary>
+    /// 分机号
+    /// </summary>
+    public string? TelNo { get; set; }
+
+    /// <summary>
+    /// 转接外线时间
+    /// </summary>
+    public DateTime CreatedTime { get; set; }
 }

+ 5 - 0
src/Hotline.Share/Dtos/TrCallCenter/TrTelDao.cs

@@ -215,6 +215,11 @@ namespace Hotline.Share.Dtos.TrCallCenter
         /// </summary>
         public string hangup_side { get; set; }
 
+        /// <summary>
+        /// 转接分机号
+        /// </summary>
+        public string? agent_transfer_number { get; set; }
+
         /// <summary>
         /// 坐席侧通话流水,无坐席参与则为手机侧通话流水
         /// </summary>

+ 8 - 0
src/Hotline.Share/Requests/PagedKeywordRequest.cs

@@ -42,4 +42,12 @@ public record QuerySeatRestRequest:ReportPagedRequest
 
 	public string? StaffNo { get; set; }
 
+}
+
+public record QuerySeatSwitchRequest:ReportPagedRequest
+{
+	public string? UserName { get; set; }
+
+	public string? CDPN { get; set; }
+
 }

+ 6 - 0
src/Hotline/CallCenter/Calls/TrCallRecord.cs

@@ -23,6 +23,12 @@ namespace Hotline.CallCenter.Calls
         /// 挂断方
         /// </summary>
         public EEndBy? EndBy { get; set; }
+
+        /// <summary>
+        /// 转接分机号
+        /// </summary>
+        public string? AgentTransferNumber { get; set; }
+
         /// <summary>
         /// 坐席侧通话流水,无坐席参与则为手机侧通话流水
         /// </summary>