Bladeren bron

办理短信发送

Dun.Jason 8 maanden geleden
bovenliggende
commit
6c14c42bb8

+ 5 - 2
src/Hotline.Api/Controllers/OrderController.cs

@@ -6,6 +6,7 @@ using Hotline.Application.FlowEngine;
 using Hotline.Application.Orders;
 using Hotline.Application.Quality;
 using Hotline.Caching.Interfaces;
+using Hotline.Caching.Services;
 using Hotline.Configurations;
 using Hotline.ContingencyManagement.Notifies;
 using Hotline.EventBus;
@@ -2197,10 +2198,11 @@ public class OrderController : BaseController
                 //发送短信
                 try
                 {
+                    var acceptSmsRoleIds = _systemSettingCacheManager.GetSetting(SettingConstants.AcceptSmsRoleIds)?.SettingValue;
                     //查询部门所有账号
                     var userlist = await _userRepository.Queryable().Where(x =>
                         x.OrgId == model.OrgId && !string.IsNullOrEmpty(x.PhoneNo) &&
-                        x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e" || d.Id == "08dc48c7-b681-4539-860b-f391cf2aa267" || d.Id == "08dc48c7-bcf7-4c6e-8246-346db53d5bd6" || d.Id == "08dc48c8-42b8-4433-8d0f-5e177052d59d")).ToListAsync();
+                        x.Roles.Any(d => acceptSmsRoleIds.Contains(d.Id))).ToListAsync();
                     //发送短信
                     foreach (var user in userlist)
                     {
@@ -2441,10 +2443,11 @@ public class OrderController : BaseController
             {
                 try
                 {
+                    var acceptSmsRoleIds = _systemSettingCacheManager.GetSetting(SettingConstants.AcceptSmsRoleIds)?.SettingValue;
                     //查询部门所有账号
                     var userlist = await _userRepository.Queryable().Where(x =>
                         x.OrgId == model.OrgId && !string.IsNullOrEmpty(x.PhoneNo) &&
-                        x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e" || d.Id == "08dc48c7-b681-4539-860b-f391cf2aa267" || d.Id == "08dc48c7-bcf7-4c6e-8246-346db53d5bd6" || d.Id == "08dc48c8-42b8-4433-8d0f-5e177052d59d")).ToListAsync();
+                        x.Roles.Any(d => acceptSmsRoleIds.Contains(d.Id))).ToListAsync();
                     foreach (var user in userlist)
                     {
                         //发送短信

+ 5 - 4
src/Hotline.Application/Handlers/FlowEngine/WorkflowNextHandler.cs

@@ -155,9 +155,10 @@ public class WorkflowNextHandler : INotificationHandler<NextStepNotify>
                             switch (notification.FlowAssignInfo.FlowAssignType)
                             {
                                 case EFlowAssignType.Org:
-                                    var orgCodes = notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
+                                    var orgCodes = notification.Trace.NextHandlers.Select(x => x.OrgId); //notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
+                                    var acceptSmsRoleIds = _systemSettingCacheManager.GetSetting(SettingConstants.AcceptSmsRoleIds)?.SettingValue;
                                     var orgList = await _userRepository.Queryable()
-                                        .Where(x => orgCodes.Contains(x.OrgId) && x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e" || d.Id== "08dc48c7-b681-4539-860b-f391cf2aa267" || d.Id== "08dc48c7-bcf7-4c6e-8246-346db53d5bd6" || d.Id == "08dc48c8-42b8-4433-8d0f-5e177052d59d"))
+                                        .Where(x => orgCodes.Contains(x.OrgId) && x.Roles.Any(d => acceptSmsRoleIds.Contains(d.Id)))
                                         .ToListAsync(cancellationToken);
                                     foreach (var item in orgList)
                                     {
@@ -181,9 +182,9 @@ public class WorkflowNextHandler : INotificationHandler<NextStepNotify>
                                     }
                                     break;
                                 case EFlowAssignType.User:
-                                    var userCodes = notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
+                                    var userCodes = notification.Trace.NextHandlers.Select(x=>x.UserId); //notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
                                     var userList = await _userRepository.Queryable()
-                                        .Where(x => userCodes.Contains(x.Id) && x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e" || d.Id == "08dc48c7-b681-4539-860b-f391cf2aa267" || d.Id == "08dc48c7-bcf7-4c6e-8246-346db53d5bd6" || d.Id == "08dc48c8-42b8-4433-8d0f-5e177052d59d"))
+                                        .Where(x => userCodes.Contains(x.Id) && !string.IsNullOrEmpty(x.PhoneNo))
                                         .ToListAsync(cancellationToken);
                                     foreach (var item in userList)
                                     {

+ 12 - 6
src/Hotline.Application/Handlers/FlowEngine/WorkflowStartHandler.cs

@@ -1,6 +1,7 @@
 using DotNetCore.CAP;
 using Hotline.Application.CallCenter;
 using Hotline.Application.Quality;
+using Hotline.Caching.Interfaces;
 using Hotline.CallCenter.Configs;
 using Hotline.Configurations;
 using Hotline.FlowEngine.Notifications;
@@ -8,6 +9,7 @@ using Hotline.FlowEngine.WorkflowModules;
 using Hotline.KnowledgeBase;
 using Hotline.Orders;
 using Hotline.Push.Notifies;
+using Hotline.Settings;
 using Hotline.Share.Dtos.FlowEngine.Workflow;
 using Hotline.Share.Dtos.Order;
 using Hotline.Share.Dtos.TrCallCenter;
@@ -39,6 +41,7 @@ namespace Hotline.Application.Handlers.FlowEngine
         private readonly ICallApplication _callApplication;
         private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
         private readonly IMediator _mediator;
+        private readonly ISystemSettingCacheManager _systemSettingCacheManager;
 
         public WorkflowStartHandler(
             IOrderDomainService orderDomainService,
@@ -52,8 +55,9 @@ namespace Hotline.Application.Handlers.FlowEngine
             IRepository<User> userRepository,
             ICallApplication callApplication,
             IOptionsSnapshot<AppConfiguration> appOptions,
-            IMediator mediator
-		)
+            IMediator mediator,
+            ISystemSettingCacheManager systemSettingCacheManager
+        )
         {
             _orderDomainService = orderDomainService;
             _knowledgeDomainService = knowledgeDomainService;
@@ -68,6 +72,7 @@ namespace Hotline.Application.Handlers.FlowEngine
             _callApplication = callApplication;
             _appOptions = appOptions;
             _mediator = mediator;
+            _systemSettingCacheManager = systemSettingCacheManager;
         }
 
         /// <summary>Handles a notification</summary>
@@ -138,9 +143,10 @@ namespace Hotline.Application.Handlers.FlowEngine
                                 switch (notification.FlowAssignInfo.FlowAssignType)
                                 {
                                     case EFlowAssignType.Org:
-                                        var orgCodes = notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
+                                        var orgCodes = notification.Trace.NextHandlers.Select(x => x.OrgId); //notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
+                                        var acceptSmsRoleIds = _systemSettingCacheManager.GetSetting(SettingConstants.AcceptSmsRoleIds)?.SettingValue;
                                         var orgList = await _userRepository.Queryable().Where(x =>
-                                            orgCodes.Contains(x.OrgId) && x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e" || d.Id == "08dc48c7-b681-4539-860b-f391cf2aa267" || d.Id == "08dc48c7-bcf7-4c6e-8246-346db53d5bd6" || d.Id == "08dc48c8-42b8-4433-8d0f-5e177052d59d")).ToListAsync();
+                                            orgCodes.Contains(x.OrgId) && x.Roles.Any(d => orgCodes.Contains(d.Id))).ToListAsync();
                                         foreach (var item in orgList)
                                         {
                                             if (!string.IsNullOrEmpty(item.PhoneNo))
@@ -163,9 +169,9 @@ namespace Hotline.Application.Handlers.FlowEngine
 
                                         break;
                                     case EFlowAssignType.User:
-                                        var userCodes = notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
+                                        var userCodes = notification.Trace.NextHandlers.Select(x => x.UserId); //notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
                                         var userList = await _userRepository.Queryable().Where(x =>
-                                            userCodes.Contains(x.Id) && x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e" || d.Id == "08dc48c7-b681-4539-860b-f391cf2aa267" || d.Id == "08dc48c7-bcf7-4c6e-8246-346db53d5bd6" || d.Id == "08dc48c8-42b8-4433-8d0f-5e177052d59d")).ToListAsync();
+                                            userCodes.Contains(x.Id) && !string.IsNullOrEmpty(x.PhoneNo)).ToListAsync();
                                         foreach (var item in userList)
                                         {
                                             var messageDto = new Share.Dtos.Push.MessageDto

+ 9 - 4
src/Hotline.Application/Subscribers/InternalCapSubscriber.cs

@@ -1,7 +1,9 @@
 using DotNetCore.CAP;
+using Hotline.Caching.Interfaces;
 using Hotline.Orders;
 using Hotline.Push;
 using Hotline.Push.Notifies;
+using Hotline.Settings;
 using Hotline.Share.Dtos.Order;
 using Hotline.Share.Dtos.Push;
 using Hotline.Share.Enums.Push;
@@ -22,14 +24,15 @@ namespace Hotline.Application.Subscribers
         private readonly IRepository<User> _userRepository;
         private readonly ICapPublisher _capPublisher;
         private readonly IRepository<BatchSmsTask> _batchSmsTaskRepository;
-
-        public InternalCapSubscriber(IOrderRepository orderRepository,IMediator mediator,IRepository<User> userRepository,ICapPublisher capPublisher,IRepository<BatchSmsTask> batchSmsTaskRepository)
+        private readonly ISystemSettingCacheManager _systemSettingCacheManager;
+        public InternalCapSubscriber(IOrderRepository orderRepository,IMediator mediator,IRepository<User> userRepository,ICapPublisher capPublisher,IRepository<BatchSmsTask> batchSmsTaskRepository,ISystemSettingCacheManager systemSettingCacheManager)
         {
             _orderRepository = orderRepository;
             _mediator = mediator;
             _userRepository = userRepository;
             _capPublisher = capPublisher;
             _batchSmsTaskRepository = batchSmsTaskRepository;
+            _systemSettingCacheManager = systemSettingCacheManager;
         }
 
         /// <summary>
@@ -70,10 +73,11 @@ namespace Hotline.Application.Subscribers
                 //当前办理部门不为空,发短信给部门经办人
                 else if(!string.IsNullOrEmpty(order.CurrentHandleOrgId))
                 {
+                    var acceptSmsRoleIds = _systemSettingCacheManager.GetSetting(SettingConstants.AcceptSmsRoleIds)?.SettingValue;
                     //查询部门经办人
                     var userlist = await _userRepository.Queryable().Where(x =>
                         x.OrgId == order.CurrentHandleOrgId && !string.IsNullOrEmpty(x.PhoneNo) &&
-                        x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e" || d.Id == "08dc48c7-b681-4539-860b-f391cf2aa267" || d.Id == "08dc48c7-bcf7-4c6e-8246-346db53d5bd6" || d.Id == "08dc48c8-42b8-4433-8d0f-5e177052d59d")).ToListAsync();
+                        x.Roles.Any(d => acceptSmsRoleIds.Contains(d.Id))).ToListAsync();
                     foreach (var user in userlist)
                     {
                         if (!string.IsNullOrEmpty(user.PhoneNo))
@@ -138,10 +142,11 @@ namespace Hotline.Application.Subscribers
                 //当前办理部门不为空,发短信给部门经办人
                 else if (!string.IsNullOrEmpty(order.CurrentHandleOrgId))
                 {
+                    var acceptSmsRoleIds = _systemSettingCacheManager.GetSetting(SettingConstants.AcceptSmsRoleIds)?.SettingValue;
                     //查询部门经办人
                     var userlist = await _userRepository.Queryable().Where(x =>
                         x.OrgId == order.CurrentHandleOrgId && !string.IsNullOrEmpty(x.PhoneNo) &&
-                        x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e" || d.Id == "08dc48c7-b681-4539-860b-f391cf2aa267" || d.Id == "08dc48c7-bcf7-4c6e-8246-346db53d5bd6" || d.Id == "08dc48c8-42b8-4433-8d0f-5e177052d59d")).ToListAsync();
+                        x.Roles.Any(d => acceptSmsRoleIds.Contains(d.Id))).ToListAsync();
                     foreach (var user in userlist)
                     {
                         if (!string.IsNullOrEmpty(user.PhoneNo))

+ 5 - 0
src/Hotline/Settings/SettingConstants.cs

@@ -459,5 +459,10 @@ namespace Hotline.Settings
         /// 录音地址下载前缀
         /// </summary>
         public const string RecordDownLoadPrefix = "RecordDownLoadPrefix";
+
+        /// <summary>
+        /// 接受短信的角色ID
+        /// </summary>
+        public const string AcceptSmsRoleIds = "AcceptSmsRoleIds";
     }
 }