Dun.Jason 1 сар өмнө
parent
commit
80ee017d88

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

@@ -229,7 +229,7 @@ namespace Hotline.Api.Controllers
             if (dto.OperateModel == 3)
             {
                 //准备数据
-                var reportDto = GetEarlyReport(dto.EarlyWarningPushDetails,earlySettingPush);               
+                var reportDto = await GetEarlyReport(dto.EarlyWarningPushDetails,earlySettingPush);               
                
                 var html = _earlyReportProvder.PushReport(reportDto);
 

+ 6 - 1
src/Hotline.Api/Controllers/OrderController.cs

@@ -4396,9 +4396,14 @@ public class OrderController : BaseController
         //内容分词
         await _orderApplication.OrderParticiple(dto.Content, order.Id, order.No, order.Title, order.CreationTime, HttpContext.RequestAborted);
         //敏感分词
-        await _orderApplication.OrderSensitiveParticiple(dto.Content, order.Id, HttpContext.RequestAborted);
+        var intersect = await _orderApplication.OrderSensitiveParticiple(dto.Content, order.Id, HttpContext.RequestAborted);
         //知识库引用
         await _orderApplication.AddKnowledgeQuote(order.Id, order.Title, order.No, order.KnowledgeQuote, HttpContext.RequestAborted);
+        if (false)
+        {
+            //坐席预警
+            await _orderApplication.SeatEarly(order.Id, intersect, dto.SeatEarlyWarningLevelValue, dto.SeatEarlyWarningLevelName, dto.SeatEarlyWarningTypeValue, dto.SeatEarlyWarningTypeName, HttpContext.RequestAborted);
+        }
         ////sms
         //try
         //{

+ 12 - 1
src/Hotline.Application/OrderApp/IOrderApplication.cs

@@ -54,7 +54,7 @@ namespace Hotline.Application.OrderApp
 
         //Task<PagedDto<WorkflowOrderDto>> GetAboutToExpireNodeAsync(AboutToExpireListDto dto, CancellationToken cancellationToken);
         Task OrderParticiple(string inputStr, string orderId, string no, string title, DateTime time, CancellationToken cancellationToken);
-        Task OrderSensitiveParticiple(string inputStr, string orderId, CancellationToken cancellationToken);
+        Task<List<string>?> OrderSensitiveParticiple(string inputStr, string orderId, CancellationToken cancellationToken);
 
         /// <summary>
         /// 接收外部平台工单
@@ -403,6 +403,17 @@ namespace Hotline.Application.OrderApp
         /// <returns></returns>
         Task AddKnowledgeQuote(string orderId, string title, string no, List<Kv> knowledgeQuote, CancellationToken cancellationToken);
 
+        /// <summary>
+        /// 坐席预警
+        /// </summary>
+        /// <param name="orderId"></param>
+        /// <param name="seatEarlyWarningLevelValue"></param>
+        /// <param name="seatEarlyWarningLevelName"></param>
+        /// <param name="seatEarlyWarningTypeValue"></param>
+        /// <param name="seatEarlyWarningTypeName"></param>
+        /// <returns></returns>
+        Task SeatEarly(string orderId,List<string> intersect, string seatEarlyWarningLevelValue, string seatEarlyWarningLevelName, string seatEarlyWarningTypeValue, string seatEarlyWarningTypeName,CancellationToken cancellationToken);
+
         /// <summary>
         /// 知识库引用
         /// </summary>

+ 44 - 3
src/Hotline.Application/OrderApp/OrderApplication.cs

@@ -8,6 +8,7 @@ using Hotline.Article;
 using Hotline.Authentications;
 using Hotline.Caching.Interfaces;
 using Hotline.Configurations;
+using Hotline.Early;
 using Hotline.File;
 using Hotline.FlowEngine.Definitions;
 using Hotline.FlowEngine.Notifications;
@@ -111,6 +112,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
     private readonly ICircularRecordDomainService _circularRecordDomainService;
     private readonly ISessionContextManager _sessionContextManager;
     private readonly IOrderVisitApplication _orderVisitApplication;
+    private readonly IRepository<OrderEarlyWarning> _orderEarlyWarningRepository;
 
     public OrderApplication(
         IOrderDomainService orderDomainService,
@@ -162,8 +164,8 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         ISessionContextCreator sessionContextCreator,
         ISessionContextManager sessionContextManager,
         IOrderVisitApplication orderVisitApplication,
-        IRepository<Role> roleRepository
-        )
+        IRepository<Role> roleRepository,
+        IRepository<OrderEarlyWarning> orderEarlyWarningRepository)
     {
         _orderDomainService = orderDomainService;
         _workflowDomainService = workflowDomainService;
@@ -214,6 +216,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         _sessionContextManager = sessionContextManager;
         _orderVisitApplication = orderVisitApplication;
         _roleRepository = roleRepository;
+        _orderEarlyWarningRepository = orderEarlyWarningRepository;
     }
 
     /// <summary>
@@ -691,7 +694,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         //}
     }
 
-    public async Task OrderSensitiveParticiple(string inputStr, string orderId, CancellationToken cancellationToken)
+    public async Task<List<string>?> OrderSensitiveParticiple(string inputStr, string orderId, CancellationToken cancellationToken)
     {
         var words = await _orderWrodRepository.Queryable().Where(x => x.IsEnable == 1 && x.Classify.Contains("敏感标签")).Select(x => x.Tag)
             .ToListAsync(cancellationToken);
@@ -702,7 +705,9 @@ public class OrderApplication : IOrderApplication, IScopeDependency
             var intersect = words.Intersect(res).ToList();
             await _orderRepository.Updateable().SetColumns(o => new Order() { Sensitive = intersect }).Where(o => o.Id == orderId)
                 .ExecuteCommandAsync(cancellationToken);
+            return intersect;
         }
+        return null;
     }
 
     /// <summary>
@@ -5156,6 +5161,42 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         }
     }
 
+    /// <summary>
+    /// 坐席预警
+    /// </summary>
+    /// <param name="orderId"></param>
+    /// <param name="seatEarlyWarningLevelValue"></param>
+    /// <param name="seatEarlyWarningLevelName"></param>
+    /// <param name="seatEarlyWarningTypeValue"></param>
+    /// <param name="seatEarlyWarningTypeName"></param>
+    /// <returns></returns>
+    public async Task SeatEarly(string orderId,List<string> intersect, string seatEarlyWarningLevelValue, string seatEarlyWarningLevelName, string seatEarlyWarningTypeValue, string seatEarlyWarningTypeName,CancellationToken cancellationToken)
+    {
+        var model = await _orderEarlyWarningRepository.GetAsync(orderId, cancellationToken);
+        if (model!=null)
+        {
+            model.SeatEarlyWarningLevelValue = seatEarlyWarningLevelValue;
+            model.SeatEarlyWarningLevelName = seatEarlyWarningLevelName;
+            model.SeatEarlyWarningTypeValue = seatEarlyWarningTypeValue;
+            model.SeatEarlyWarningTypeName = seatEarlyWarningTypeName;
+            await _orderEarlyWarningRepository.UpdateAsync(model, cancellationToken);
+        }
+        else
+        {
+            model = new OrderEarlyWarning();
+            model.SeatEarlyWarningLevelValue = seatEarlyWarningLevelValue;
+            model.SeatEarlyWarningLevelName = seatEarlyWarningLevelName;
+            model.SeatEarlyWarningTypeValue = seatEarlyWarningTypeValue;
+            model.SeatEarlyWarningTypeName = seatEarlyWarningTypeName;
+            //预警预选信息
+
+            model.CanChooseEarlyWarning = null;
+
+            await _orderEarlyWarningRepository.AddAsync(model, cancellationToken);
+        }
+        
+    }
+
     /// <summary>
     /// 知识库引用
     /// </summary>

+ 10 - 0
src/Hotline.Share/Dtos/Early/EarlyDto.cs

@@ -173,6 +173,16 @@ namespace Hotline.Share.Dtos.Early
         /// 次数
         /// </summary>
         public int Times { get; set; }
+
+        /// <summary>
+        /// 顺序
+        /// </summary>
+        public int Sort { get; set; }
+
+        /// <summary>
+        /// 下一节点条件
+        /// </summary>
+        public ENextWhere? NextWhere { get; set; }
     }
 
     #endregion

+ 24 - 0
src/Hotline.Share/Dtos/Order/OrderDto.cs

@@ -1502,6 +1502,30 @@ namespace Hotline.Share.Dtos.Order
         /// </summary>
         public List<string>? Tags { get; set; }
 
+        #region 预警信息
+
+        /// <summary>
+        /// 坐席预警级别值
+        /// </summary>
+        public string SeatEarlyWarningLevelValue { get; set; }
+
+        /// <summary>
+        /// 坐席预警级别名称
+        /// </summary>
+        public string SeatEarlyWarningLevelName { get; set; }
+
+        /// <summary>
+        /// 坐席预警类型值
+        /// </summary>
+        public string SeatEarlyWarningTypeValue { get; set; }
+
+        /// <summary>
+        /// 坐席预警类型名称
+        /// </summary>
+        public string SeatEarlyWarningTypeName { get; set; }
+
+        #endregion
+
     }
 
     public record CanLinkCallRecordOrderDto : PagedKeywordRequest

+ 24 - 0
src/Hotline.Share/Enums/Early/ENextWhere.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.Share.Enums.Early
+{
+    public enum ENextWhere
+    {
+        /// <summary>
+        /// 并且
+        /// </summary>
+        [Description("并且")]
+        And = 1,
+
+        /// <summary>
+        /// 或者
+        /// </summary>
+        [Description("或者")]
+        Or = 2,
+    }
+}

+ 12 - 1
src/Hotline/Early/EarlyWarningSetting.cs

@@ -1,4 +1,5 @@
 using Hotline.Share.Enums.Early;
+using SqlSugar;
 using XF.Domain.Repository;
 
 namespace Hotline.Early
@@ -43,7 +44,7 @@ namespace Hotline.Early
         /// <summary>
         /// 预警规则
         /// </summary>
-        
+        [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
         public List<EarlyWarningRule> EarlyWarningRules { get; set; }
 
         /// <summary>
@@ -68,5 +69,15 @@ namespace Hotline.Early
         /// 次数
         /// </summary>
         public int Times { get; set; }
+
+        /// <summary>
+        /// 顺序
+        /// </summary>
+        public int Sort { get; set; }
+
+        /// <summary>
+        /// 下一节点条件
+        /// </summary>
+        public ENextWhere? NextWhere { get; set; }
     }
 }

+ 1 - 0
src/Hotline/Early/OrderEarlyWarning.cs

@@ -55,6 +55,7 @@ namespace Hotline.Early
         /// <summary>
         /// 可选择预警设置
         /// </summary>
+        
         public List<EarlyWarningSetting> CanChooseEarlyWarning { get; set; }
     }
 }