TANG JIANG 1 年之前
父節點
當前提交
87f9ecfb85

+ 31 - 13
src/Hotline.Api/Controllers/IPPbxController.cs

@@ -53,7 +53,7 @@ namespace Hotline.Api.Controllers
         private readonly IRepository<QualityTemplate> _qualityTemplate;
 
 
-		public IPPbxController(ITrClient trClient, IMapper mapper, IUserDomainService userDomainService,
+        public IPPbxController(ITrClient trClient, IMapper mapper, IUserDomainService userDomainService,
             ISessionContext sessionContext, IRepository<TrCallRecord> trCallRecordRepository,
             ITrApplication trApplication, IRepository<TrCallEvaluate> trCallRecord,
             ISystemDicDataCacheManager systemDicDataCacheManager, ILogger<IPPbxController> logger,
@@ -81,8 +81,8 @@ namespace Hotline.Api.Controllers
             _telApplication = telApplication;
             _qualiteyRepository = qualiteyRepository;
             _aiQualityService = aiQualityService;
-            _qualityTemplate = qualityTemplate; 
-		}
+            _qualityTemplate = qualityTemplate;
+        }
 
         #region 添添呼
 
@@ -310,16 +310,16 @@ namespace Hotline.Api.Controllers
                 model.ExternalId = order.Id;
                 // 写入智能质检
                 var teAny = await _qualityTemplate.Queryable()
-	                .LeftJoin<QualityTemplateDetail>((x, d) => x.Id == d.TemplateId)
-	                .LeftJoin<QualityItem>((x, d, i) => d.ItemId == i.Id)
-	                .Where((x, d, i) => i.IsIntelligent == 1)
+                    .LeftJoin<QualityTemplateDetail>((x, d) => x.Id == d.TemplateId)
+                    .LeftJoin<QualityItem>((x, d, i) => d.ItemId == i.Id)
+                    .Where((x, d, i) => i.IsIntelligent == 1)
                     .Where((x, d, i) => x.Grouping == ETemplateGrouping.Accepted).AnyAsync();
                 if (teAny)
                 {
-	                var quality = await _qualiteyRepository.Queryable().Where(x => x.OrderId == order.Id && x.Source == Share.Enums.Quality.EQualitySource.Accepted).FirstAsync();
-					await _aiQualityService.CreateAiOrderQualityTask(quality, model, order, HttpContext.RequestAborted);
-				}
-			}
+                    var quality = await _qualiteyRepository.Queryable().Where(x => x.OrderId == order.Id && x.Source == Share.Enums.Quality.EQualitySource.Accepted).FirstAsync();
+                    await _aiQualityService.CreateAiOrderQualityTask(quality, model, order, HttpContext.RequestAborted);
+                }
+            }
             else
             {
                 var orderVisit = await _orderVisitRepository.GetAsync(x => x.CallId == model.CallAccept, HttpContext.RequestAborted);
@@ -390,14 +390,25 @@ namespace Hotline.Api.Controllers
         public async Task<PagedDto<TrCallDto>> GetCallList([FromQuery] GetCallListDto dto)
         {
             var (total, items) = await _trCallRecordRepository.Queryable()
-                .Includes(x=>x.Order)
+                .Includes(x => x.Order)
                 .WhereIF(!string.IsNullOrEmpty(dto.CPN), x => x.CPN.Contains(dto.CPN))
                 .WhereIF(!string.IsNullOrEmpty(dto.CDPN), x => x.CDPN.Contains(dto.CDPN))
+                .WhereIF(!string.IsNullOrEmpty(dto.TelNo), x => x.TelNo.Contains(dto.TelNo))
+                .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
                 .WhereIF(dto.CallDirection != null, x => x.CallDirection == dto.CallDirection)
                 .WhereIF(dto.OnState != null, x => x.OnState == dto.OnState)
+                .WhereIF(dto.EndBy != null, x => x.EndBy == dto.EndBy)
+                .WhereIF(dto.BeginIvrTime.HasValue, x => x.BeginIvrTime >= dto.BeginIvrTime)
+                .WhereIF(dto.EndIvrTime.HasValue, x => x.EndIvrTime <= dto.EndIvrTime)
+                .WhereIF(dto.BeginQueueTime.HasValue, x => x.BeginQueueTime >= dto.BeginQueueTime)
+                .WhereIF(dto.EndQueueTime.HasValue, x => x.EndQueueTime <= dto.EndQueueTime)
+                .WhereIF(dto.AnsweredTime.HasValue, x => x.AnsweredTime >= dto.AnsweredTime)
+                .WhereIF(dto.OverTime.HasValue, x => x.OverTime <= dto.OverTime)
+                .WhereIF(!string.IsNullOrEmpty(dto.OrderNo), x => x.Order.No.Contains(dto.UserName))
+                .WhereIF(!string.IsNullOrEmpty(dto.Title), x => x.Order.Title.Contains(dto.UserName))
                 .WhereIF(!string.IsNullOrEmpty(dto.Gateway), x => x.Gateway.Contains(dto.Gateway))
-                .WhereIF(dto.StartTime.HasValue, x => x.CreatedTime >= dto.StartTime)
-                .WhereIF(dto.EndTime.HasValue, x => x.CreatedTime <= dto.EndTime)
+                // .WhereIF(dto.StartTime.HasValue, x => x.CreatedTime >= dto.StartTime)
+                //.WhereIF(dto.EndTime.HasValue, x => x.CreatedTime <= dto.EndTime)
                 .OrderByDescending(x => x.CreatedTime)
                 .ToPagedListAsync(dto.PageIndex, dto.PageSize);
             return new PagedDto<TrCallDto>(total, _mapper.Map<IReadOnlyList<TrCallDto>>(items));
@@ -414,6 +425,7 @@ namespace Hotline.Api.Controllers
             {
                 OnState = EnumExts.GetDescriptions<EOnState>(),
                 CallDirection = EnumExts.GetDescriptions<ECallDirection>(),
+                EndBy = EnumExts.GetDescriptions<EEndBy>(),
             };
         }
 
@@ -467,8 +479,14 @@ namespace Hotline.Api.Controllers
             var trRecord = await _trCallRecordRepository.GetAsync(x => x.CallAccept == dto.CallId, HttpContext.RequestAborted);
             if (dto.IsOrder)
             {
+                if (trRecord.CallOrderType == ECallOrderType.Order && !string.IsNullOrEmpty(trRecord.ExternalId))
+                    throw UserFriendlyException.SameMessage("通话记录已经关联工单");
+
                 //工单
                 var order = await _orderRepository.GetAsync(x => x.Id == dto.Id, HttpContext.RequestAborted);
+                if (!string.IsNullOrEmpty(order.CallId))
+                    throw UserFriendlyException.SameMessage("通话记录已经关联工单");
+
                 order.CallId = dto.CallId;
                 await _orderRepository.UpdateAsync(order, HttpContext.RequestAborted);
                 trRecord.CallOrderType = ECallOrderType.Order;

+ 26 - 17
src/Hotline.Api/Controllers/OrderController.cs

@@ -1,52 +1,52 @@
 using DotNetCore.CAP;
+using Hotline.Api.Filter;
+using Hotline.Application.ExportExcel;
 using Hotline.Application.FlowEngine;
 using Hotline.Application.Orders;
+using Hotline.Application.Quality;
 using Hotline.Caching.Interfaces;
+using Hotline.CallCenter.Calls;
+using Hotline.Enterprise;
 using Hotline.File;
 using Hotline.FlowEngine.Definitions;
+using Hotline.FlowEngine.WorkflowModules;
 using Hotline.FlowEngine.Workflows;
+using Hotline.Import;
 using Hotline.Orders;
 using Hotline.Orders.Notifications;
 using Hotline.Permissions;
+using Hotline.Push.FWMessage;
+using Hotline.Push.Notifies;
 using Hotline.Repository.SqlSugar.Extensions;
 using Hotline.Repository.SqlSugar.Ts;
 using Hotline.Settings;
 using Hotline.Settings.Hotspots;
 using Hotline.Settings.TimeLimits;
 using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Enterprise;
 using Hotline.Share.Dtos.FlowEngine;
 using Hotline.Share.Dtos.Order;
+using Hotline.Share.Dtos.Push;
 using Hotline.Share.Dtos.Settings;
+using Hotline.Share.Enums.FlowEngine;
 using Hotline.Share.Enums.Order;
+using Hotline.Share.Enums.Push;
 using Hotline.Share.Enums.Quality;
 using Hotline.Share.Enums.Settings;
 using Hotline.Share.Requests;
+using Hotline.Users;
 using MapsterMapper;
 using MediatR;
+using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
+using MiniExcelLibs;
 using SqlSugar;
-using Hotline.FlowEngine.WorkflowModules;
-using Hotline.Share.Enums.FlowEngine;
 using XF.Domain.Authentications;
+using XF.Domain.Cache;
 using XF.Domain.Constants;
 using XF.Domain.Exceptions;
 using XF.Domain.Repository;
 using XF.Utility.EnumExtensions;
-using Hotline.CallCenter.Calls;
-using Hotline.Application.Quality;
-using Hotline.Enterprise;
-using Hotline.Share.Dtos.Enterprise;
-using Hotline.Push.FWMessage;
-using Hotline.Share.Dtos.Push;
-using Hotline.Share.Enums.Push;
-using XF.Domain.Cache;
-using Hotline.Api.Filter;
-using Hotline.Push.Notifies;
-using Hotline.Users;
-using Microsoft.AspNetCore.Authorization;
-using Hotline.Import;
-using MiniExcelLibs;
-using Hotline.Application.ExportExcel;
 
 namespace Hotline.Api.Controllers;
 
@@ -2202,6 +2202,15 @@ public class OrderController : BaseController
             await _repeatableEventDetailRepository.AddRangeAsync(repeatables, HttpContext.RequestAborted);
         }
 
+        //工单ID跟通话记录相关联
+        var callRecord = await _trCallRecordRepository.GetAsync(p => p.CallAccept == order.CallId, HttpContext.RequestAborted);
+        if (callRecord != null && string.IsNullOrEmpty(callRecord.ExternalId))
+        {
+            callRecord.ExternalId = order.Id;
+            callRecord.CallOrderType = Share.Enums.CallCenter.ECallOrderType.Order;
+            await _trCallRecordRepository.UpdateAsync(callRecord, HttpContext.RequestAborted);
+        }
+
         //内容分词
         await _orderApplication.OrderParticiple(dto.Content, order.Id, HttpContext.RequestAborted);
 

+ 1 - 5
src/Hotline.Application/Handlers/FlowEngine/WorkflowStartHandler.cs

@@ -4,20 +4,16 @@ using Hotline.CallCenter.Calls;
 using Hotline.CallCenter.Tels;
 using Hotline.FlowEngine.Notifications;
 using Hotline.FlowEngine.WorkflowModules;
-using Hotline.FlowEngine.Workflows;
 using Hotline.KnowledgeBase;
 using Hotline.Orders;
-using Hotline.Repository.SqlSugar.Knowledge;
 using Hotline.Share.Dtos.FlowEngine.Workflow;
 using Hotline.Share.Dtos.Order;
 using Hotline.Share.Dtos.TrCallCenter;
-using Hotline.Share.Enums.KnowledgeBase;
 using Hotline.Share.Enums.Quality;
 using Hotline.Share.Mq;
 using MapsterMapper;
 using MediatR;
 using Microsoft.Extensions.Logging;
-using XF.Domain.Exceptions;
 using XF.Domain.Repository;
 
 namespace Hotline.Application.Handlers.FlowEngine
@@ -87,7 +83,7 @@ namespace Hotline.Application.Handlers.FlowEngine
 
                     var publishCallRecordDto = new PublishCallRecrodDto() { };
                     //查询通话记录
-                    var callRecord = await _trCallRecordRepository.GetAsync(order.CallId, cancellationToken);
+                    var callRecord = await _trCallRecordRepository.GetAsync(p => p.CallAccept == order.CallId, cancellationToken);
                     if (callRecord != null)
                     {
                         publishCallRecordDto.TrCallRecordDto = _mapper.Map<TrCallDto>(callRecord);

+ 69 - 17
src/Hotline.Share/Dtos/TrCallCenter/TrTelDao.cs

@@ -314,12 +314,12 @@ namespace Hotline.Share.Dtos.TrCallCenter
         /// <summary>
         /// 队列ID
         /// </summary>
-        public string? ola_queue { get; set; } 
+        public string? ola_queue { get; set; }
 
         /// <summary>
         /// 批量外呼流水
         /// </summary>
-        public string? batch_accept { get; set; } 
+        public string? batch_accept { get; set; }
 
         /// <summary>
         /// IVR按键信息
@@ -338,7 +338,7 @@ namespace Hotline.Share.Dtos.TrCallCenter
         public string dtmf { get; set; }
 
         public string call_accept { get; set; }
-        public int type { get;set; }
+        public int type { get; set; }
     }
 
     public class PublishCallRecrodDto
@@ -357,31 +357,27 @@ namespace Hotline.Share.Dtos.TrCallCenter
 
     #region 通话记录(对内)
 
-    public record class GetCallListDto: PagedRequest
+    public record class GetCallListDto : PagedRequest
     {
         /// <summary>
-        /// 开始时间
+        /// 主叫
         /// </summary>
-        public DateTime? StartTime { get; set; }
-
+        public string? CPN { get; set; }
         /// <summary>
-        /// 结束时间
+        /// 被叫
         /// </summary>
-        public DateTime? EndTime { get; set; }
+        public string? CDPN { get; set; }
 
         /// <summary>
-        /// 中继
+        /// 分机
         /// </summary>
-        public string? Gateway { get; set; }
+        public string? TelNo { get; set; }
 
         /// <summary>
-        /// 主叫
-        /// </summary>
-        public string CPN { get; set; }
-        /// <summary>
-        /// 被叫
+        /// 用户名
         /// </summary>
-        public string CDPN { get; set; }
+        public string? UserName { get; set; }
+
         /// <summary>
         /// 电话方向
         /// </summary>
@@ -392,6 +388,62 @@ namespace Hotline.Share.Dtos.TrCallCenter
         /// </summary>
         public EOnState? OnState { get; set; }
 
+        /// <summary>
+        /// 挂断方
+        /// </summary>
+        public EEndBy? EndBy { get; set; }
+
+        /// <summary>
+        /// IVR开始时间
+        /// </summary>
+        public DateTime? BeginIvrTime { get; set; }
+        /// <summary>
+        /// IVR结束时间
+        /// </summary>
+        public DateTime? EndIvrTime { get; set; }
+
+        /// <summary>
+        /// 开始等待时间(队列开始时间)
+        /// </summary>
+        public DateTime? BeginQueueTime { get; set; }
+        /// <summary>
+        /// 结束等待时间(队列结束时间)
+        /// </summary>
+        public DateTime? EndQueueTime { get; set; }
+
+        /// <summary>
+        /// 接通开始时间
+        /// </summary>
+        public DateTime? AnsweredTime { get; set; }
+        /// <summary>
+        /// 接通结束时间
+        /// </summary>
+        public DateTime? OverTime { get; set; }
+
+        /// <summary>
+        /// 工单编号
+        /// </summary>
+        public string? OrderNo { get; set; }
+
+        /// <summary>
+        /// 工单标题
+        /// </summary>
+        public string? Title { get; set; }
+
+        /// <summary>
+        /// 中继号
+        /// </summary>
+        public string? Gateway { get; set; }
+        ///// <summary>
+        ///// 开始时间
+        ///// </summary>
+        //public DateTime? StartTime { get; set; }
+
+        ///// <summary>
+        ///// 结束时间
+        ///// </summary>
+        //public DateTime? EndTime { get; set; }
+
     }