Przeglądaj źródła

Merge branch 'master' of http://110.188.24.182:10023/Fengwo/hotline

xf 1 rok temu
rodzic
commit
d594956150
39 zmienionych plików z 917 dodań i 240 usunięć
  1. 1 1
      src/Hotline.Api/Controllers/KnowledgeApplyController.cs
  2. 43 8
      src/Hotline.Api/Controllers/OrderController.cs
  3. 51 0
      src/Hotline.Api/Controllers/PushMessageController.cs
  4. 2 2
      src/Hotline.Api/Controllers/ReportController.cs
  5. 105 0
      src/Hotline.Api/Controllers/TemplateDomainController.cs
  6. 2 2
      src/Hotline.Api/Controllers/TestController.cs
  7. 82 82
      src/Hotline.Api/Controllers/TestSdkController.cs
  8. 4 3
      src/Hotline.Api/StartupExtensions.cs
  9. 9 6
      src/Hotline.Api/config/appsettings.Development.json
  10. 17 0
      src/Hotline.Application.Contracts/Validators/Push/TemplateDtoValidator.cs
  11. 18 0
      src/Hotline.Application.Contracts/Validators/Push/UpdateTemplateDtoValidator.cs
  12. 11 11
      src/Hotline.Application/Handlers/CallCenter/BaseHandler.cs
  13. 1 1
      src/Hotline.Application/Handlers/CallCenter/CallState/DtmfNotificationHandler.cs
  14. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnOuterToMenuNotificationHandler.cs
  15. 1 1
      src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnVisitorToMenuNotificationHandler.cs
  16. 4 4
      src/Hotline.Application/Handlers/CallCenter/FlowControl/IncomingNotificationHandler.cs
  17. 4 4
      src/Hotline.Application/Handlers/CallCenter/FlowControl/InviteNotificationHandler.cs
  18. 7 0
      src/Hotline.Application/Mappers/MapperConfigs.cs
  19. 87 87
      src/Hotline.NewRock/DeviceManager.cs
  20. 5 5
      src/Hotline.NewRock/Handlers/DeviceEventHandler.cs
  21. 16 0
      src/Hotline.Repository.SqlSugar/Push/MessageRepository.cs
  22. 15 0
      src/Hotline.Repository.SqlSugar/Push/MessageTemplateRepository.cs
  23. 9 0
      src/Hotline.Share/Dtos/Order/OrderDto.cs
  24. 63 1
      src/Hotline.Share/Dtos/Order/QueryOrderDto.cs
  25. 67 0
      src/Hotline.Share/Dtos/Push/MessageDataDto.cs
  26. 15 0
      src/Hotline.Share/Dtos/Push/MessagePagedDto.cs
  27. 37 0
      src/Hotline.Share/Dtos/Push/TemplateDataDto.cs
  28. 47 0
      src/Hotline.Share/Dtos/Push/TemplateDto.cs
  29. 11 0
      src/Hotline.Share/Dtos/Push/TemplatePagedDto.cs
  30. 19 1
      src/Hotline.Share/Enums/Push/EPushStatus.cs
  31. 7 0
      src/Hotline/CallCenter/Devices/DeviceConfigs.cs
  32. 1 1
      src/Hotline/CallCenter/IDeviceEventHandler.cs
  33. 0 2
      src/Hotline/Orders/Order.cs
  34. 8 0
      src/Hotline/Push/IMessageRepository.cs
  35. 8 0
      src/Hotline/Push/IMessageTemplateRepository.cs
  36. 2 8
      src/Hotline/Push/IPushDomainService.cs
  37. 47 6
      src/Hotline/Push/Message.cs
  38. 35 0
      src/Hotline/Push/MessageTemplate.cs
  39. 55 3
      src/Hotline/Push/PushDomainService.cs

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

@@ -79,7 +79,7 @@ namespace Hotline.Api.Controllers
         [HttpPut("update")]
         public async Task UpdateApply([FromBody] UpdateKnowledgeApplyDto dto)
         {
-            var ka = _mapper.Map<KnowledgeApply>(dto); 
+            var ka = _mapper.Map<KnowledgeApply>(dto);
             ka.Status = EKnowledgeApplyStatus.Handling;
             await _knowledgeApplyRepository.UpdateAsync(ka, HttpContext.RequestAborted);
         }

+ 43 - 8
src/Hotline.Api/Controllers/OrderController.cs

@@ -17,6 +17,8 @@ using MapsterMapper;
 using MediatR;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore.Migrations.Operations;
+using MongoDB.Driver.Linq;
 using System.Runtime.CompilerServices;
 using XF.Domain.Authentications;
 using XF.Domain.Exceptions;
@@ -68,6 +70,46 @@ public class OrderController : BaseController
         _mediator = mediator;
     }
 
+    /// <summary>
+    /// 查询(工单发布)
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpGet("publish-order-list")]
+    public async Task<PagedDto<PublishDto>> PublishOrderList([FromQuery] QueryOrderPublishDto dto)
+    {
+        var (total,items) = await _orderRepository.Queryable()
+            .Includes(d => d.OrderPublished)
+            .Includes(d=>d.Employee)
+            .WhereIF(!string.IsNullOrEmpty(dto.OrderTitle), d => d.Title.Contains(dto.OrderTitle!))
+            .WhereIF(dto.PubState == EPubState.Pub, d=> d.Progress == EProgress.Published || d.Progress== EProgress.Visited)
+            .WhereIF(dto.PubState == EPubState.NoPub, d=> d.Progress == EProgress.Managing)
+            .WhereIF(!string.IsNullOrEmpty(dto.PubMan), d => d.Employee.Name.Contains(dto.PubMan!) || d.Employee.StaffNo.Contains(dto.PubMan!))
+            .WhereIF(dto.PubRange!= null,d=>d.OrderPublished.PublishState == dto.PubRange)
+            .WhereIF(dto.AcceptTypes.Any(),d=>dto.AcceptTypes.Contains(d.AcceptType))
+            .WhereIF(dto.HotspotIds.Any(),d=> dto.HotspotIds.Contains(d.HotspotId))
+            .WhereIF(dto.CreationTimeStart.HasValue, d => d.CreationTime >= dto.CreationTimeStart)
+            .WhereIF(dto.CreationTimeEnd.HasValue, d => d.CreationTime <= dto.CreationTimeEnd)
+            .WhereIF(dto.FiledTimeStart.HasValue,d=>d.OrderPublished.CreationTime>= dto.CreationTimeStart)
+            .WhereIF(dto.FiledTimeEnd.HasValue,d=> d.OrderPublished.CreationTime <= dto.CreationTimeEnd)
+            .OrderByDescending(d => d.CreationTime)
+            .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
+
+        return new PagedDto<PublishDto>(total,_mapper.Map<IReadOnlyList<PublishDto>>(items));
+    }
+
+    ///// <summary>
+    ///// 发布工单
+    ///// </summary>
+    ///// <returns></returns>
+    //[HttpPost("publish-order")]
+    //public async Task PublishOrder([FromBody]PublishOrderDto dto)
+    //{
+    //    OrderPublished orderPublished = new OrderPublished();
+    //    orderPublished.PublishState = dto.PublishState;
+    //    orderPublished.ArrangeContent = dto.ArrangeContent;
+    //}
+
     /// <summary>
     /// 工单列表
     /// </summary>
@@ -311,13 +353,6 @@ public class OrderController : BaseController
 
 
 
-
-    //public async Task<PagedDto<PublishDto>> CanPublishOrder([FromQuery] QueryOrderPublishDto dto)
-    //{
-
-
-    //    return null;
-    //}
-
+   
 
 }

+ 51 - 0
src/Hotline.Api/Controllers/PushMessageController.cs

@@ -0,0 +1,51 @@
+using Hotline.Push;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Push;
+using MapsterMapper;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Hotline.Api.Controllers
+{
+    public class PushMessageController : BaseController
+    {
+        private readonly IMessageRepository _messageRepository;
+        private readonly IMapper _mapper;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="messageRepository"></param>
+        /// <param name="mapper"></param>
+        public PushMessageController(IMessageRepository messageRepository, IMapper mapper)
+        {
+            _messageRepository = messageRepository;
+            _mapper = mapper;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="pagedDto"></param>
+        /// <returns></returns>
+        [HttpGet("getlist")]
+        public async Task<PagedDto<MessageDataDto>> AllMessage([FromQuery] MessagePagedDto pagedDto)
+        {
+            var (total, items) = await _messageRepository
+                    .Queryable()
+                    .Includes(it => it.User)
+                    .Includes(it => it.SystemOrganize)
+                    .Includes(it => it.Order)
+                    .WhereIF(pagedDto.PushBusiness.HasValue, d => d.PushBusiness == pagedDto.PushBusiness)
+                    .WhereIF(pagedDto.Status.HasValue, d => d.Status == pagedDto.Status)
+                    .WhereIF(!string.IsNullOrEmpty(pagedDto.Keyword), d => d.Name.Contains(pagedDto.Keyword!) || d.Content.Contains(pagedDto.Keyword!) || d.TelNumber.Contains(pagedDto.Keyword!) || d.User.Name.Contains(pagedDto.Keyword!) || d.SystemOrganize.OrgName.Contains(pagedDto.Keyword!))
+                    .WhereIF(pagedDto.StartTime.HasValue, d => d.SendTime >= pagedDto.StartTime)
+                    .WhereIF(pagedDto.EndTime.HasValue, d => d.SendTime <= pagedDto.EndTime)
+                    .OrderByDescending(it => it.CreationTime)
+                    .ToPagedListAsync(pagedDto.PageIndex, pagedDto.PageSize, HttpContext.RequestAborted);
+
+            return new PagedDto<MessageDataDto>(total, _mapper.Map<IReadOnlyList<MessageDataDto>>(items));
+
+        }
+    }
+}

+ 2 - 2
src/Hotline.Api/Controllers/ReportController.cs

@@ -10,10 +10,10 @@ namespace Hotline.Api.Controllers;
 [Route("api/report")]
 public class ReportController : ControllerBase
 {
-    private readonly IOptionsSnapshot<DeviceConfigs> _options;
+    private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
     private readonly IDeviceEventHandler _deviceEventHandler;
 
-    public ReportController(IOptionsSnapshot<DeviceConfigs> options, IDeviceEventHandler deviceEventHandler)
+    public ReportController(IOptionsSnapshot<CallCenterConfiguration> options, IDeviceEventHandler deviceEventHandler)
     {
         _options = options;
         _deviceEventHandler = deviceEventHandler;

+ 105 - 0
src/Hotline.Api/Controllers/TemplateDomainController.cs

@@ -0,0 +1,105 @@
+using Hotline.Push;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Push;
+using MapsterMapper;
+using Microsoft.AspNetCore.Mvc;
+using XF.Domain.Exceptions;
+
+namespace Hotline.Api.Controllers
+{
+    public class TemplateDomainController : BaseController
+    {
+        private readonly IMessageTemplateRepository _messageTemplateRepository;
+        private readonly IMapper _mapper;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="messageTemplateRepository"></param>
+        /// <param name="mapper"></param>
+        public TemplateDomainController(IMessageTemplateRepository messageTemplateRepository, IMapper mapper)
+        {
+            _messageTemplateRepository = messageTemplateRepository;
+            _mapper = mapper;
+        }
+
+        /// <summary>
+        /// 新增
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPut("add")]
+        public async Task<string> AddTemplate([FromBody] TemplateDto dto)
+        {
+            var template = _mapper.Map<MessageTemplate>(dto);
+
+            var data = await _messageTemplateRepository.GetAsync(p => p.Code == template.Code, HttpContext.RequestAborted);
+            if (data != null)
+                throw UserFriendlyException.SameMessage("存在相同Code!");
+
+            return await _messageTemplateRepository.AddAsync(template, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 修改
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPut("update")]
+        public async Task UpdateTemplate([FromBody] UpdateTemplateDto dto)
+        {
+            var template = _mapper.Map<MessageTemplate>(dto);
+
+            var data = await _messageTemplateRepository.GetAsync(p => p.Code == template.Code && p.Id != template.Id, HttpContext.RequestAborted);
+            if (data != null)
+                throw UserFriendlyException.SameMessage("存在相同Code!");
+
+            await _messageTemplateRepository.UpdateAsync(template, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 删除
+        /// </summary>
+        /// <param name="Id"></param>
+        /// <returns></returns>
+        [HttpDelete("remove")]
+        public async Task RemoveType(string Id)
+        {
+            await _messageTemplateRepository.RemoveAsync(Id, false, HttpContext.RequestAborted);
+        }
+
+        /// <summary>
+        /// 查询详情
+        /// </summary>
+        /// <param name="Id"></param>
+        /// <returns></returns>
+        [HttpGet("info/{Id}")]
+        public async Task<UpdateTemplateDto> Info(string Id)
+        {
+            var template = await _messageTemplateRepository.GetAsync(Id, HttpContext.RequestAborted);
+            if (template is null)
+                throw UserFriendlyException.SameMessage("查询失败!");
+            return _mapper.Map<UpdateTemplateDto>(template);
+        }
+
+        /// <summary>
+        /// 查询列表
+        /// </summary>
+        /// <param name="pagedDto"></param>
+        /// <returns></returns>
+        [HttpGet("getlist")]
+        public async Task<PagedDto<TemplateDataDto>> GetList([FromQuery] TemplatePagedDto pagedDto)
+        {
+            var (total, items) = await _messageTemplateRepository
+                    .Queryable()
+                    .WhereIF(!string.IsNullOrEmpty(pagedDto.Keyword), d => d.Code.Contains(pagedDto.Keyword!) || d.Content.Contains(pagedDto.Keyword!))
+                    .WhereIF(pagedDto.PushBusiness.HasValue, d => d.PushBusiness == pagedDto.PushBusiness)
+                    .OrderByDescending(it => it.CreationTime)
+                    .ToPagedListAsync(pagedDto.PageIndex, pagedDto.PageSize, HttpContext.RequestAborted);
+
+            return new PagedDto<TemplateDataDto>(total, _mapper.Map<IReadOnlyList<TemplateDataDto>>(items));
+
+        }
+    }
+}

+ 2 - 2
src/Hotline.Api/Controllers/TestController.cs

@@ -40,7 +40,7 @@ public class TestController : BaseController
 {
     private readonly ILogger<TestController> _logger;
     private readonly IAuthorizeGenerator _authorizeGenerator;
-    private readonly IOptionsSnapshot<DeviceConfigs> _options;
+    private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
     private readonly ISessionContext _sessionContext;
     private readonly IUserRepository _userRepository;
 
@@ -64,7 +64,7 @@ public class TestController : BaseController
         INewRockClient client,
         ILogger<TestController> logger,
         IAuthorizeGenerator authorizeGenerator,
-        IOptionsSnapshot<DeviceConfigs> options,
+        IOptionsSnapshot<CallCenterConfiguration> options,
         ISessionContext sessionContext,
         IUserRepository userRepository,
         //ICacheManager<User> cache

+ 82 - 82
src/Hotline.Api/Controllers/TestSdkController.cs

@@ -24,12 +24,12 @@ namespace Hotline.Api.Controllers
     {
         private readonly INewRockClient _client;
         private readonly ILogger<TestController> _logger;
-        private readonly IOptionsSnapshot<DeviceConfigs> _options;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
 
         public TestSdkController(
             INewRockClient client,
             ILogger<TestController> logger,
-            IOptionsSnapshot<DeviceConfigs> options
+            IOptionsSnapshot<CallCenterConfiguration> options
             )
         {
             _client = client;
@@ -48,8 +48,8 @@ namespace Hotline.Api.Controllers
         {
             var result = await _client.QueryDeviceInfo(
                 new QueryDeviceInfoRequest { Attribute = "Query", DeviceInfo = string.Empty },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<QueryDeviceInfoResponse?>(result));
         }
@@ -64,8 +64,8 @@ namespace Hotline.Api.Controllers
         {
             var result = await _client.QueryExt(
                 new QueryExtRequest() { Attribute = "Query", Ext = new Ext() { Id = extid } },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted
             );
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<QueryExtResponse?>(result));
@@ -83,8 +83,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Query",
                 Group = new QueryExtGroup() { Id = groupid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<QueryExtGroupResponse?>(result));
         }
@@ -101,8 +101,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Query",
                 Menu = new QueryMenuMenu() { Id = menuid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<QueryMenuResponse?>(result));
         }
@@ -121,8 +121,8 @@ namespace Hotline.Api.Controllers
                 Attribute = "Query",
                 Trunk = new QueryTrunkTrunk() { Id = trunkid }
             },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+               _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<QueryTrunkResponse?>(result));
         }
@@ -139,8 +139,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Query",
                 Visitor = new QueryVisitorVisitor() { Id = visitorid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<QueryVisitorResponse?>(result));
         }
@@ -158,8 +158,8 @@ namespace Hotline.Api.Controllers
                 Attribute = "Query",
                 Outer = new QueryOuterOuter() { Id = outerid }
             },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+               _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<QueryOuterResponse?>(result));
         }
@@ -183,8 +183,8 @@ namespace Hotline.Api.Controllers
                 {
                     Id = extid
                 },
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -203,8 +203,8 @@ namespace Hotline.Api.Controllers
                 {
                     Id = visitorId
                 }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -223,8 +223,8 @@ namespace Hotline.Api.Controllers
                 {
                     Id = outerId
                 }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -261,8 +261,8 @@ namespace Hotline.Api.Controllers
                     Api = "7"
                 }
             },
-            _options.Value.ReceiveKey,
-            _options.Value.Expired,
+           _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
             HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<AssginConfigExtResponse?>(result));
         }
@@ -289,8 +289,8 @@ namespace Hotline.Api.Controllers
                         "210"
                     }
                 }
-            }, _options.Value.ReceiveKey,
-            _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
             HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<AssginConfigGroupResponse?>(result));
         }
@@ -313,8 +313,8 @@ namespace Hotline.Api.Controllers
                     Repeat = "3",
                     InfoLength = "5",
                 }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -333,8 +333,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Hold",
                 Ext = new Ext() { Id = extid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             //_logger.LogInformation(result.Manufacturer);
         }
@@ -350,8 +350,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Unhold",
                 Ext = new Ext() { Id = extid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -371,8 +371,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Mute",
                 Ext = new Ext() { Id = extid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -388,8 +388,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Unmute",
                 Ext = new Ext() { Id = extid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -414,8 +414,8 @@ namespace Hotline.Api.Controllers
                         new ExtToExtExt() { Id = fromextid },
                         new ExtToExtExt() { Id = toextid }
                     }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize(result));
         }
@@ -433,8 +433,8 @@ namespace Hotline.Api.Controllers
                 Ext = new ExtToOuterExtRequest() { Id = fromextid },
                 Outer = new ExtToOuterOuterRequest() { To = to }
             },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+               _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -450,8 +450,8 @@ namespace Hotline.Api.Controllers
                 Attribute = "Connect",
                 Visitor = new VisitorToExtVisitor() { Id = visid },
                 Ext = new VisitorToExtExt() { Id = toextid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -471,8 +471,8 @@ namespace Hotline.Api.Controllers
                 Visitor = new VisitorToOuterVisitor() { Id = visid },
                 Outer = new VisitorToOuterOuter() { To = outerphonenum, Display = display },
 
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -490,8 +490,8 @@ namespace Hotline.Api.Controllers
                 Attribute = "Connect",
                 Visitor = new VisitorToMenuVisitor() { Id = visid },
                 Menu = new VisitorToMenuMenu() { Id = menuid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -510,8 +510,8 @@ namespace Hotline.Api.Controllers
                 Outer = new OuterToExtOuter() { Id = outer },
                 Ext = new OuterToExtExt() { Id = extid }
             },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+               _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -529,8 +529,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Connect",
                 Outer = new List<OuterToOuterOuterModel>() { new OuterToOuterOuterModel() { Id = outerid }, new OuterToOuterOuterModel() { To = outerphonenum } },
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -548,8 +548,8 @@ namespace Hotline.Api.Controllers
                 Attribute = "Connect",
                 Outer = new OuterToMenuOuter() { Id = outerid },
                 Menu = new OuterToMenuMenu() { Id = menuid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -567,8 +567,8 @@ namespace Hotline.Api.Controllers
                 Attribute = "Connect",
                 Menu = new MenuToExtMenu() { Id = menuid },
                 Ext = new MenuToExtExt() { Id = extid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -586,8 +586,8 @@ namespace Hotline.Api.Controllers
                 Attribute = "Connect",
                 Menu = new MenuToOuterMenu() { Id = menuid },
                 Outer = new MenuToOuterOuter() { To = outernum }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -609,8 +609,8 @@ namespace Hotline.Api.Controllers
                         new TwoWayOuterOuter(){ To = outerone},
                         new TwoWayOuterOuter(){ To = outertwo}
                     }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -630,8 +630,8 @@ namespace Hotline.Api.Controllers
                 Ext = new VoiceNewsFlashExt() { Id = extid }
             };
 
-            var result = await _client.VoiceNewsFlash(model, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            var result = await _client.VoiceNewsFlash(model, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -651,8 +651,8 @@ namespace Hotline.Api.Controllers
                 Visitor = new VoiceNewsFlashVisitor() { Id = visiitorid }
             };
 
-            var result = await _client.VoiceNewsFlash(model, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            var result = await _client.VoiceNewsFlash(model, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -672,8 +672,8 @@ namespace Hotline.Api.Controllers
                 Outer = new VoiceNewsFlashOuter() { Id = outerid }
             };
 
-            var result = await _client.VoiceNewsFlash(model, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            var result = await _client.VoiceNewsFlash(model, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -695,8 +695,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Conference",
                 Ext = new ConferenceMeetingExt() { Id = extid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -719,8 +719,8 @@ namespace Hotline.Api.Controllers
                 Attribute = "Queue",
                 Visitor = new VisitorToExtQueueVisitor() { Id = visitorid },
                 Ext = new VisitorToExtQueueExt() { Id = extid }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -739,8 +739,8 @@ namespace Hotline.Api.Controllers
                 Visitor = new VisitorToGroupQueueVisitor() { Id = visitorid },
                 Group = new VisitorToGroupQueueGroup() { Id = groupid }
             },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+               _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -762,8 +762,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Query",
                 VoiceFile = ""
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
             _logger.LogInformation(System.Text.Json.JsonSerializer.Serialize<VoiceQueryListResponse?>(result));
         }
@@ -780,8 +780,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Remove",
                 VoiceFile = voiceFile
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 HttpContext.RequestAborted);
         }
 
@@ -802,8 +802,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Monitor",
                 Exts = new List<Ext>() { new Ext() { Id = firstTelNo }, new Ext() { Id = secondTelNo } }
-            }, _options.Value.ReceiveKey,
-             _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
              HttpContext.RequestAborted) ;
         }
 
@@ -822,8 +822,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Talk",
                 Ext = new Ext() { Id=telNo }
-            }, _options.Value.ReceiveKey,
-              _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
               HttpContext.RequestAborted);
         }
 
@@ -842,8 +842,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "Listen",
                 Ext = new Ext() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-             _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
              HttpContext.RequestAborted);
         }
 
@@ -869,8 +869,8 @@ namespace Hotline.Api.Controllers
             {
                 Attribute = "BargeinExt",
                 Exts = new List<Ext>() { new Ext() { Id=firstTelNo },new Ext() { Id=secondTelNo } }
-            },_options.Value.ReceiveKey,
-             _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
              HttpContext.RequestAborted);
         }
 

+ 4 - 3
src/Hotline.Api/StartupExtensions.cs

@@ -33,8 +33,9 @@ internal static class StartupExtensions
         builder.WebHost.UseUrls("http://*:50100");
 #endif
 
-        services.Configure<DeviceConfigs>(d => configuration.GetSection(nameof(DeviceConfigs)).Bind(d));
+        //services.Configure<DeviceConfigs>(d => configuration.GetSection(nameof(DeviceConfigs)).Bind(d));
         services.Configure<IdentityConfiguration>(d => configuration.GetSection(nameof(IdentityConfiguration)).Bind(d));
+        services.Configure<CallCenterConfiguration>(d => configuration.GetSection(nameof(CallCenterConfiguration)).Bind(d));
 
         // Add services to the container.
         services
@@ -81,8 +82,8 @@ internal static class StartupExtensions
         });
 
         //迅时IPPBX
-        var deviceConfigs = configuration.GetSection("DeviceConfigs").Get<DeviceConfigs>();
-        services.AddNewRock(deviceConfigs.Address);
+        var deviceConfigs = configuration.GetSection("CallCenterConfiguration").Get<CallCenterConfiguration>();
+        services.AddNewRock(deviceConfigs.DeviceConfigs.Address);
 
         //sqlsugar
         services.AddSqlSugar(configuration, "Hotline");

+ 9 - 6
src/Hotline.Api/config/appsettings.Development.json

@@ -1,11 +1,14 @@
 {
   "AllowedHosts": "*",
-  "DeviceConfigs": {
-    "Address": "http://192.168.100.100/xml",
-    "Authorize": true,
-    "ReceiveKey": "E1BBD1BB-A269-44",
-    "SendKey": "2A-BA92-160A3B1D",
-    "Expired": 86300 //认证过期时间(秒)
+  "CallCenterConfiguration": {
+    "CallCenterType": "XunShi",
+    "DeviceConfigs": {
+      "Address": "http://192.168.100.100/xml",
+      "Authorize": true,
+      "ReceiveKey": "E1BBD1BB-A269-44",
+      "SendKey": "2A-BA92-160A3B1D",
+      "Expired": 86300 //认证过期时间(秒)
+    }
   },
   "ConnectionStrings": {
     "Hotline": "PORT=5432;DATABASE=hotline;HOST=110.188.24.182;PASSWORD=fengwo11!!;USER ID=dev;",

+ 17 - 0
src/Hotline.Application.Contracts/Validators/Push/TemplateDtoValidator.cs

@@ -0,0 +1,17 @@
+using FluentValidation;
+using Hotline.Share.Dtos.Push;
+
+namespace Hotline.Application.Contracts.Validators.Push
+{
+    public class TemplateDtoValidator : AbstractValidator<TemplateDto>
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        public TemplateDtoValidator()
+        {
+            RuleFor(d => d.Code).NotEmpty();
+            RuleFor(d => d.Content).NotEmpty();
+        }
+    }
+}

+ 18 - 0
src/Hotline.Application.Contracts/Validators/Push/UpdateTemplateDtoValidator.cs

@@ -0,0 +1,18 @@
+using FluentValidation;
+using Hotline.Share.Dtos.Push;
+
+namespace Hotline.Application.Contracts.Validators.Push
+{
+    public class UpdateTemplateDtoValidator : AbstractValidator<UpdateTemplateDto>
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        public UpdateTemplateDtoValidator()
+        {
+            RuleFor(d => d.Id).NotEmpty();
+            RuleFor(d => d.Code).NotEmpty();
+            RuleFor(d => d.Content).NotEmpty();
+        }
+    }
+}

+ 11 - 11
src/Hotline.Application/Handlers/CallCenter/BaseHandler.cs

@@ -15,11 +15,11 @@ namespace Hotline.Application.Handlers.CallCenter
     public class BaseHandler
     {
         private readonly INewRockClient _newRockClient;
-        private readonly IOptionsSnapshot<DeviceConfigs> _options;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
         private readonly ICallRepository _callRepository;
         private readonly ICallCacheManager _callCacheManager;
         private readonly IRealtimeService _realtimeService;
-        public BaseHandler(INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options,ICallRepository callRepository,ICallCacheManager callCacheManager,IRealtimeService realtimeService)
+        public BaseHandler(INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options,ICallRepository callRepository,ICallCacheManager callCacheManager,IRealtimeService realtimeService)
         {
             _newRockClient = newRockClient;
             _options = options;
@@ -47,7 +47,7 @@ namespace Hotline.Application.Handlers.CallCenter
                                     Menu = new OuterToMenuMenu() { Id = tomenuId },
                                     Outer = new OuterToMenuOuter() { Id = model.ConversationId },
                                     //VoiceFile = string.IsNullOrEmpty(ivrAnswer.PreVoice) ? "" : ivrAnswer.PreVoice,
-                                }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                                 break;
                             case ECallType.VisitorCallIn:
                                 await _newRockClient.VisitorToMenu(new VisitorToMenuRequest()
@@ -56,7 +56,7 @@ namespace Hotline.Application.Handlers.CallCenter
                                     Menu = new VisitorToMenuMenu() { Id = tomenuId },
                                     Visitor = new VisitorToMenuVisitor() { Id = model.ConversationId },
                                     //VoiceFile = string.IsNullOrEmpty(ivrAnswer.PreVoice) ? "" : ivrAnswer.PreVoice,
-                                }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                                 break;
                             default:
                                 throw new ArgumentOutOfRangeException();
@@ -80,7 +80,7 @@ namespace Hotline.Application.Handlers.CallCenter
                                     Attribute = "Queue",
                                     Ext = new VisitorToExtQueueExt() { Id = telNo },
                                     Visitor = new VisitorToExtQueueVisitor() { Id = model.ConversationId }
-                                }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                                 break;
                             case ECallType.ExtToOuter:
                                 await _newRockClient.OuterToExt(new OuterToExtRequest()
@@ -88,7 +88,7 @@ namespace Hotline.Application.Handlers.CallCenter
                                     Attribute = "Connect",
                                     Ext = new OuterToExtExt() { Id = telNo },
                                     Outer = new OuterToExtOuter() { Id = model.ConversationId }
-                                }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                                 break;
                             default:
                                 throw new ArgumentOutOfRangeException();
@@ -103,7 +103,7 @@ namespace Hotline.Application.Handlers.CallCenter
                             Attribute = "Queue",
                             Group = new VisitorToGroupQueueGroup() { Id = groupId },
                             Visitor = new VisitorToGroupQueueVisitor() { Id = model.ConversationId }
-                        }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                        }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
 
                         //处理队列记录
                         _callCacheManager.AddCallCache(model);
@@ -125,7 +125,7 @@ namespace Hotline.Application.Handlers.CallCenter
                                         //TODO DISPLAY属性待定
                                     }
                                 },
-                                    _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                    _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                                 break;
                             case ECallType.ExtToOuter:
                                 await _newRockClient.OuterToOuter(new OuterToOuterRequest()
@@ -135,7 +135,7 @@ namespace Hotline.Application.Handlers.CallCenter
                                         new(){Id = model.ConversationId},
                                             new(){To = phoneNo},
                                         }
-                                }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                                 break;
                             default:
                                 throw new ArgumentOutOfRangeException();
@@ -150,14 +150,14 @@ namespace Hotline.Application.Handlers.CallCenter
                                 {
                                     Attribute = "Clear",
                                     Visitor = new ClearCallVisitor() { Id = model.ConversationId },
-                                }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                                 break;
                             case ECallType.ExtToOuter:
                                 await _newRockClient.ClearCall(new ClearCallRequest()
                                 {
                                     Attribute = "Clear",
                                     Outer = new ClearCallOuter() { Id = model.ConversationId },
-                                }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                                 break;
                         }
                         break;

+ 1 - 1
src/Hotline.Application/Handlers/CallCenter/CallState/DtmfNotificationHandler.cs

@@ -18,7 +18,7 @@ namespace Hotline.Application.Handlers.CallCenter.CallState
         private readonly ICallDetailRepository _callDetailRepository;
 
 
-        public DtmfNotificationHandler(IIvrDomainService ivrDomainService, ICallDetailRepository callDetailRepository, ICallRepository callRepository, INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService) :base(newRockClient, options,callRepository, callCacheManager,realtimeService)
+        public DtmfNotificationHandler(IIvrDomainService ivrDomainService, ICallDetailRepository callDetailRepository, ICallRepository callRepository, INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService) :base(newRockClient, options,callRepository, callCacheManager,realtimeService)
         {
             _ivrDomainService = ivrDomainService;
             _callDetailRepository = callDetailRepository;

+ 1 - 1
src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnOuterToMenuNotificationHandler.cs

@@ -16,7 +16,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly ICallRepository _callRepository;
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IIvrDomainService _ivrDomainService;
-        public EndOfAnnOuterToMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IIvrDomainService ivrDomainService, INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService) : base(newRockClient, options,callRepository,callCacheManager, realtimeService)
+        public EndOfAnnOuterToMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IIvrDomainService ivrDomainService, INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService) : base(newRockClient, options,callRepository,callCacheManager, realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;

+ 1 - 1
src/Hotline.Application/Handlers/CallCenter/FlowControl/EndOfAnnVisitorToMenuNotificationHandler.cs

@@ -18,7 +18,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IIvrDomainService _ivrDomainService;
 
-        public EndOfAnnVisitorToMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IIvrDomainService ivrDomainService,INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService):base(newRockClient,options,callRepository,callCacheManager, realtimeService)
+        public EndOfAnnVisitorToMenuNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IIvrDomainService ivrDomainService,INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options,ICallCacheManager callCacheManager,IRealtimeService realtimeService):base(newRockClient,options,callRepository,callCacheManager, realtimeService)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;

+ 4 - 4
src/Hotline.Application/Handlers/CallCenter/FlowControl/IncomingNotificationHandler.cs

@@ -26,7 +26,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly ISystemSettingCacheManager _systemSettingCacheManager;
         private readonly IIvrCacheManager _ivrCacheManager;
         private readonly INewRockClient _newRockClient;
-        private readonly IOptionsSnapshot<DeviceConfigs> _options;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
         private readonly ITypedCache<List<TrunkIvrManager>> _worktimeCache;
         private readonly ILogger<IncomingNotificationHandler> _logger;
         private readonly ITrunkIvrManagerRepository _trunkIvrManagerRepository;
@@ -39,7 +39,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
             ISystemSettingCacheManager systemSettingCacheManager,
             IIvrCacheManager ivrCacheManager,
             INewRockClient newRockClient,
-            IOptionsSnapshot<DeviceConfigs> options,
+            IOptionsSnapshot<CallCenterConfiguration> options,
             ITypedCache<List<TrunkIvrManager>> worktimeCache,
             ILogger<IncomingNotificationHandler> logger,
             ITrunkIvrManagerRepository trunkIvrManagerRepository,
@@ -105,7 +105,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                                     Menu = new VisitorToMenuMenu() { Id = ivr.No },
                                     Visitor = new VisitorToMenuVisitor() { Id = notification.Visitor.Id }
                                 },
-                                _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                                _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
 
                             //写入进入IVR流程
                             model.InIvrTime = DateTime.Now;
@@ -131,7 +131,7 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                                 Visitor = new VisitorToGroupQueueVisitor() { Id = notification.Visitor.Id },
                                 Group = new VisitorToGroupQueueGroup() { Id = correct.ReturnValue }
                             },
-                            _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                            _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
                             model.InQueueTime = DateTime.Now;
                             await _callRepository.UpdateAsync(model, cancellationToken);
                             //处理队列记录

+ 4 - 4
src/Hotline.Application/Handlers/CallCenter/FlowControl/InviteNotificationHandler.cs

@@ -21,9 +21,9 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
         private readonly IUserCacheManager _userCacheManager;
         private readonly IBlacklistDomainService _blacklistDomainService;
         private readonly INewRockClient _newRockClient;
-        private readonly IOptionsSnapshot<DeviceConfigs> _options;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
         private readonly IOptionsSnapshot<WorkTimeSettings> _workTimeOptions;
-        public InviteNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IUserCacheManager userCacheManager, IBlacklistDomainService blacklistDomainService, INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options, IOptionsSnapshot<WorkTimeSettings> workTimeOptions)
+        public InviteNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository, IUserCacheManager userCacheManager, IBlacklistDomainService blacklistDomainService, INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options, IOptionsSnapshot<WorkTimeSettings> workTimeOptions)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
@@ -89,14 +89,14 @@ namespace Hotline.Application.Handlers.CallCenter.FlowControl
                     {
                         Id = notification.Visitor.Id
                     }
-                }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
             }
             else
             {
                 await _newRockClient.AcceptVisitor(
                     new AcceptVisitorRequest()
                     { Attribute = "Accept", Visitor = new AcceptVisitorModel() { Id = notification.Visitor.Id } },
-                    _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                    _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
             }
         }
     }

+ 7 - 0
src/Hotline.Application/Mappers/MapperConfigs.cs

@@ -9,6 +9,7 @@ using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Dtos.FlowEngine;
 using Hotline.Share.Dtos.Knowledge;
 using Hotline.Share.Dtos.Order;
+using Hotline.Share.Dtos.Push;
 using Hotline.Share.Dtos.Roles;
 using Hotline.Share.Dtos.Users;
 using Hotline.Users;
@@ -181,6 +182,12 @@ namespace Hotline.Application.Mappers
                 .Map(d => d.OrderReport.Id, x => x.Id);
 
             #endregion
+
+            config.ForType<Hotline.Push.Message, MessageDataDto>()
+               .Map(d => d.SendUser, x => x.User.Name)
+               .Map(d => d.SendOrganize, x => x.SystemOrganize.OrgName)
+               .Map(d => d.OrderId, x => x.Order.Id)
+               .Map(d => d.OrderNo, x => x.Order.No);
         }
     }
 }

+ 87 - 87
src/Hotline.NewRock/DeviceManager.cs

@@ -26,14 +26,14 @@ namespace Hotline.NewRock
     {
         private readonly INewRockClient _newRockClient;
         private readonly ICallRepository _callRepository;
-        private readonly IOptionsSnapshot<DeviceConfigs> _options;
+        private readonly IOptionsSnapshot<CallCenterConfiguration> _options;
         private readonly IMapper _mapper;
         private readonly ITelGroupRepository _telGroupRepository;
         private readonly IUserCacheManager _userCacheManager;
         private readonly ITelRestRepository _telRestRepository;
         private readonly ITelCacheManager _telCacheManager;
 
-        public DeviceManager(INewRockClient newRockClient, IOptionsSnapshot<DeviceConfigs> options, IMapper mapper, ICallRepository callRepository, ITelGroupRepository telGroupRepository,IUserCacheManager userCacheManager, ITelRestRepository telRestRepository, ITelCacheManager telCacheManager)
+        public DeviceManager(INewRockClient newRockClient, IOptionsSnapshot<CallCenterConfiguration> options, IMapper mapper, ICallRepository callRepository, ITelGroupRepository telGroupRepository,IUserCacheManager userCacheManager, ITelRestRepository telRestRepository, ITelCacheManager telCacheManager)
         {
             _newRockClient = newRockClient;
             _options = options;
@@ -53,7 +53,7 @@ namespace Hotline.NewRock
             {
                 var result = await _newRockClient.QueryExt(
                 new QueryExtRequest() { Attribute = "Query", Ext = new Ext { Id = TelNo } },
-                _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
 
                 if (result?.Ext.Outer != null)
                 {
@@ -127,7 +127,7 @@ namespace Hotline.NewRock
         {
             var result = await _newRockClient.QueryExt(
                 new QueryExtRequest() { Attribute = "Query", Ext = new Ext { Id = TelNo } },
-                _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+                _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
 
             switch (result.Ext.State)
             {
@@ -156,8 +156,8 @@ namespace Hotline.NewRock
         {
             var result = await _newRockClient.QueryDeviceInfo(
                 new QueryDeviceInfoRequest { Attribute = "Query", DeviceInfo = string.Empty },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
             var exts = result.Devices.Ext;
             return _mapper.Map<List<Tel>>(exts);
@@ -172,8 +172,8 @@ namespace Hotline.NewRock
         {
             var result = await _newRockClient.QueryDeviceInfo(
                 new QueryDeviceInfoRequest { Attribute = "Query", DeviceInfo = string.Empty },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
 
             var groups = result.Devices.Group;
@@ -191,8 +191,8 @@ namespace Hotline.NewRock
                 {
                     Attribute = "Query",
                     VoiceFile = "",
-                }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
             return result?.VoiceFile;
         }
@@ -201,8 +201,8 @@ namespace Hotline.NewRock
         {
             await _newRockClient.QueryExtGroup(new QueryExtGroupRequest()
                 { Attribute = "Query", Group = new QueryExtGroup() { Id = groupId } },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken
             );
         }
@@ -223,8 +223,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Query",
                 Ext = new Ext() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-            _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+            _options.Value.DeviceConfigs.Expired,
             cancellationToken);
 
             if (telModel == null)
@@ -232,8 +232,8 @@ namespace Hotline.NewRock
 
             await _newRockClient.ConfigExt(
                 new AssginConfigExtRequest() { Attribute = "Assign", Ext = new ConfigExt() { Lineid = telModel.Ext.LineId, Groups=Enumerable.Select<QueryExtGroup, string>(telModel.Ext.Group, x=>x.Id).ToList(), No_Disturb = "On" } },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -249,8 +249,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Query",
                 Ext = new Ext() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
 
             if (telModel == null)
@@ -258,8 +258,8 @@ namespace Hotline.NewRock
 
             await _newRockClient.ConfigExt(
                 new AssginConfigExtRequest() { Attribute = "Assign", Ext = new ConfigExt() { Lineid = telModel.Ext.LineId, Groups = Enumerable.Select<QueryExtGroup, string>(telModel.Ext.Group, x => x.Id).ToList(), No_Disturb = "Off" } },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -275,8 +275,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Remove",
                 VoiceFile = voiceName
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -318,8 +318,8 @@ namespace Hotline.NewRock
                     Exit = exit,
                     Repeat = repeat,
                 }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -367,8 +367,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Assign",
                 Group = groupModel
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -391,7 +391,7 @@ namespace Hotline.NewRock
 
             #region 清除分机组设置
 
-            await _newRockClient.ConfigExtGroup(new AssginConfigGroupRequest() { Attribute = "Assign", Group = new Group() { Id = groupId } }, _options.Value.ReceiveKey, _options.Value.Expired, cancellationToken);
+            await _newRockClient.ConfigExtGroup(new AssginConfigGroupRequest() { Attribute = "Assign", Group = new Group() { Id = groupId } }, _options.Value.DeviceConfigs.ReceiveKey, _options.Value.DeviceConfigs.Expired, cancellationToken);
 
             #endregion
 
@@ -445,8 +445,8 @@ namespace Hotline.NewRock
             groupModel.Ext = exts;
             await _newRockClient.ConfigExtGroup(
                 new AssginConfigGroupRequest() { Attribute = "Assign", Group = groupModel, },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken
                 );
         }
@@ -464,8 +464,8 @@ namespace Hotline.NewRock
                 {
                     Attribute = "Query",
                     Ext = new Ext() { Id = telNo }
-                }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
 
             if (telModel == null)
@@ -473,8 +473,8 @@ namespace Hotline.NewRock
 
             await _newRockClient.ConfigExt(
                 new AssginConfigExtRequest() { Attribute = "Assign", Ext = new ConfigExt() { Id = telNo,Lineid = lineId, Staffid = staffNo } },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
         #endregion
@@ -490,8 +490,8 @@ namespace Hotline.NewRock
         public async Task HoldAsync(string telNo, CancellationToken cancellationToken)
         {
             await _newRockClient.HoldOrUnHold(
-                new HoldSetRequest() { Attribute = "Hold", Ext = new Ext() { Id = telNo } }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                new HoldSetRequest() { Attribute = "Hold", Ext = new Ext() { Id = telNo } }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -504,8 +504,8 @@ namespace Hotline.NewRock
         public async Task UnHoldAsync(string telNo, CancellationToken cancellationToken)
         {
             await _newRockClient.HoldOrUnHold(
-                new HoldSetRequest() { Attribute = "Unhold", Ext = new Ext() { Id = telNo } }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                new HoldSetRequest() { Attribute = "Unhold", Ext = new Ext() { Id = telNo } }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -518,8 +518,8 @@ namespace Hotline.NewRock
         public async Task MuteAsync(string telNo, CancellationToken cancellationToken)
         {
             await _newRockClient.MuteOrUnMute(
-                new MuteSetRequest() { Attribute = "Mute", Ext = new Ext() { Id = telNo } }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                new MuteSetRequest() { Attribute = "Mute", Ext = new Ext() { Id = telNo } }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -533,8 +533,8 @@ namespace Hotline.NewRock
         {
             await _newRockClient.MuteOrUnMute(
                 new MuteSetRequest() { Attribute = "Unmute", Ext = new Ext() { Id = telNo } },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -553,8 +553,8 @@ namespace Hotline.NewRock
                 {
                     Id = extId
                 }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -570,8 +570,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Clear",
                 Visitor = new ClearCallVisitor() { Id = visitorId }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -587,8 +587,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Clear",
                 Outer = new ClearCallOuter() { Id = outerId }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -604,8 +604,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Accept",
                 Visitor = new AcceptVisitorModel() { Id = visitorId }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
         #endregion
@@ -626,8 +626,8 @@ namespace Hotline.NewRock
                 {
                     Attribute = "Connect",
                     Exts = new List<ExtToExtExt>() { new ExtToExtExt() { Id = from }, new ExtToExtExt() { Id = to } }
-                }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -649,8 +649,8 @@ namespace Hotline.NewRock
                         Outer = new ExtToOuterOuterRequest() { To = to },
                         Trunk = new ExtToOuterTrunkRequest() { Id = trunkid }
                     },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -669,8 +669,8 @@ namespace Hotline.NewRock
                 Attribute = "Connect",
                 Visitor = new VisitorToExtVisitor() { Id = visitorId },
                 Ext = new VisitorToExtExt() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -691,8 +691,8 @@ namespace Hotline.NewRock
                 Visitor = new VisitorToOuterVisitor() { Id = visitorId },
                 Outer = new VisitorToOuterOuter() { To = outerPhoneNum, Display = display },
 
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -711,8 +711,8 @@ namespace Hotline.NewRock
                 Attribute = "Connect",
                 Visitor = new VisitorToMenuVisitor() { Id = visitorId },
                 Menu = new VisitorToMenuMenu() { Id = menuId }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -730,8 +730,8 @@ namespace Hotline.NewRock
                 Attribute = "Queue",
                 Visitor = new VisitorToGroupQueueVisitor() { Id = visitorId },
                 Group = new VisitorToGroupQueueGroup() { Id = groupId }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -750,8 +750,8 @@ namespace Hotline.NewRock
                 Outer = new OuterToExtOuter() { Id = outerId },
                 Ext = new OuterToExtExt() { Id = telNo }
             },
-                _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -772,8 +772,8 @@ namespace Hotline.NewRock
                         new OuterToOuterOuterModel() { Id = outerId },
                         new OuterToOuterOuterModel() { To = outerPhoneNum }
                     },
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -792,8 +792,8 @@ namespace Hotline.NewRock
                 Attribute = "Connect",
                 Menu = new MenuToExtMenu() { Id = menuId },
                 Ext = new MenuToExtExt() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -812,8 +812,8 @@ namespace Hotline.NewRock
                 Attribute = "Connect",
                 Menu = new MenuToOuterMenu() { Id = menuId },
                 Outer = new MenuToOuterOuter() { To = outerPhoneNum }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -834,8 +834,8 @@ namespace Hotline.NewRock
                         new TwoWayOuterOuter(){ To = outerOne},
                         new TwoWayOuterOuter(){ To = outerTwo}
                     }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -853,8 +853,8 @@ namespace Hotline.NewRock
                 Attribute = "Connect",
                 VoiceFile = voiceFileName,
                 Ext = new VoiceNewsFlashExt() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -874,8 +874,8 @@ namespace Hotline.NewRock
                     Attribute = "Connect",
                     VoiceFile = voiceFileName,
                     Visitor = new VoiceNewsFlashVisitor() { Id = visitorId }
-                }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -894,8 +894,8 @@ namespace Hotline.NewRock
                     Attribute = "Connect",
                     VoiceFile = voiceFileName,
                     Outer = new VoiceNewsFlashOuter() { Id = outerId }
-                }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+                }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -911,8 +911,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Conference",
                 Ext = new ConferenceMeetingExt() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-                _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+                _options.Value.DeviceConfigs.Expired,
                 cancellationToken);
         }
 
@@ -950,8 +950,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Monitor",
                 Exts = new List<Ext>() { new Ext() { Id=firstTelNo },new Ext() { Id=secondTelNo } }
-            }, _options.Value.ReceiveKey,
-             _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+             _options.Value.DeviceConfigs.Expired,
              cancellationToken) ;
         }
 
@@ -970,8 +970,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Talk",
                 Ext = new Ext() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-              _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+              _options.Value.DeviceConfigs.Expired,
               cancellationToken) ;
         }
 
@@ -991,8 +991,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Listen",
                 Ext = new Ext() { Id = telNo }
-            }, _options.Value.ReceiveKey,
-              _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+              _options.Value.DeviceConfigs.Expired,
               cancellationToken);
         }
 
@@ -1017,8 +1017,8 @@ namespace Hotline.NewRock
             {
                 Attribute = "Bargein",
                 Exts = new List<Ext>() { new Ext() { Id = firstTelNo },new Ext() { Id=secondTelNo } }
-            }, _options.Value.ReceiveKey,
-              _options.Value.Expired,
+            }, _options.Value.DeviceConfigs.ReceiveKey,
+              _options.Value.DeviceConfigs.Expired,
               cancellationToken);
         }
 

+ 5 - 5
src/Hotline.NewRock/Handlers/DeviceEventHandler.cs

@@ -29,7 +29,7 @@ namespace Hotline.NewRock.Handlers
             _logger = logger;
         }
 
-        public async Task HandleAsync(Stream eventStream, DeviceConfigs deviceConfigs,
+        public async Task HandleAsync(Stream eventStream, CallCenterConfiguration deviceConfigs,
             CancellationToken cancellationToken)
         {
             var sr = new StreamReader(eventStream);
@@ -42,8 +42,8 @@ namespace Hotline.NewRock.Handlers
                 //通话记录报告
                 var eventBase = content.DeserializeWithAuthorize<NewRockCdrEvent>();
                 if (eventBase.value == null) return;
-                if (deviceConfigs.Authorize && (eventBase.authorize == null ||
-                                                !eventBase.authorize.IsAuthorized(deviceConfigs.SendKey)))
+                if (deviceConfigs.DeviceConfigs.Authorize && (eventBase.authorize == null ||
+                                                !eventBase.authorize.IsAuthorized(deviceConfigs.DeviceConfigs.SendKey)))
                     throw new AuthenticationException("无有效身份认证信息");
 
                 var cdrRcv = content.DeserializeWithAuthorize<CdrEvent>();
@@ -53,8 +53,8 @@ namespace Hotline.NewRock.Handlers
             {
                 var eventBase = content.DeserializeWithAuthorize<NewRockEvent>();
                 if (eventBase.value == null) return;
-                if (deviceConfigs.Authorize && (eventBase.authorize == null ||
-                                                !eventBase.authorize.IsAuthorized(deviceConfigs.SendKey)))
+                if (deviceConfigs.DeviceConfigs.Authorize && (eventBase.authorize == null ||
+                                                !eventBase.authorize.IsAuthorized(deviceConfigs.DeviceConfigs.SendKey)))
                     throw new AuthenticationException("无有效身份认证信息");
 
                 switch (eventBase.value.Attribute)

+ 16 - 0
src/Hotline.Repository.SqlSugar/Push/MessageRepository.cs

@@ -0,0 +1,16 @@
+using Hotline.KnowledgeBase;
+using Hotline.Push;
+using Hotline.Repository.SqlSugar.DataPermissions;
+using SqlSugar;
+using XF.Domain.Dependency;
+
+namespace Hotline.Repository.SqlSugar.Push
+{
+    public class MessageRepository : BaseRepository<Message>, IMessageRepository, IScopeDependency
+    {
+        public MessageRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder) : base(uow, dataPermissionFilterBuilder)
+        {
+
+        }
+    }
+}

+ 15 - 0
src/Hotline.Repository.SqlSugar/Push/MessageTemplateRepository.cs

@@ -0,0 +1,15 @@
+using Hotline.Push;
+using Hotline.Repository.SqlSugar.DataPermissions;
+using SqlSugar;
+using XF.Domain.Dependency;
+
+namespace Hotline.Repository.SqlSugar.Push
+{
+    public class MessageTemplateRepository : BaseRepository<MessageTemplate>, IMessageTemplateRepository, IScopeDependency
+    {
+        public MessageTemplateRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder) : base(uow, dataPermissionFilterBuilder)
+        {
+
+        }
+    }
+}

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

@@ -335,4 +335,13 @@ namespace Hotline.Share.Dtos.Order
         /// </summary>
         public string ArrangeContent { get; set; }
     }
+
+    public class PublishOrderDto
+    {
+        public string Id { get; set; }
+
+        public EPublishState PublishState { get; set; }
+
+        public string ArrangeContent { get; set; }
+    }
 }

+ 63 - 1
src/Hotline.Share/Dtos/Order/QueryOrderDto.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -81,6 +82,67 @@ namespace Hotline.Share.Dtos.Order
 
     public record QueryOrderPublishDto : PagedRequest
     {
-        
+        /// <summary>
+        /// 发布状态
+        /// </summary>
+        public EPubState PubState { get; set; }
+
+        /// <summary>
+        /// 工单标题
+        /// </summary>
+        public string OrderTitle { get; set; }
+
+        /// <summary>
+        /// 发布人
+        /// </summary>
+        public string PubMan { get; set; }
+
+        /// <summary>
+        /// 发布范围
+        /// </summary>
+        public EPublishState? PubRange { get; set; }
+
+        /// <summary>
+        /// 受理类型
+        /// </summary>
+        public List<EAcceptType> AcceptTypes { get; set; } = new();
+
+        /// <summary>
+        /// 热点分类
+        /// </summary>
+        public List<string> HotspotIds { get; set; } = new();
+
+        /// <summary>
+        /// 受理时间(工单创建时间)
+        /// </summary>
+        public DateTime? CreationTimeStart { get; set; }
+        public DateTime? CreationTimeEnd { get; set; }
+
+        /// <summary>
+        /// 归档时间
+        /// </summary>
+        public DateTime? FiledTimeStart { get; set; }
+        public DateTime? FiledTimeEnd { get; set; }
+
     }
+
+    public enum EPubState
+    {
+        /// <summary>
+        /// 全部
+        /// </summary>
+        [Description("全部")]
+        All = 0,
+        /// <summary>
+        /// 已发布
+        /// </summary>
+        [Description("已发布")]
+        Pub = 1,
+        /// <summary>
+        /// 未发布
+        /// </summary>
+        [Description("未发布")]
+        NoPub = 2
+    }
+
 }

+ 67 - 0
src/Hotline.Share/Dtos/Push/MessageDataDto.cs

@@ -0,0 +1,67 @@
+using Hotline.Share.Enums.Push;
+
+namespace Hotline.Share.Dtos.Push
+{
+    public record MessageDataDto
+    {
+        /// <summary>
+        /// 消息推送业务
+        /// </summary>
+        public EPushBusiness PushBusiness { get; set; }
+
+        /// <summary>
+        /// 接收姓名
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 接收手机号码
+        /// </summary>
+        public string TelNumber { get; set; }
+
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public string Content { get; set; }
+
+        /// <summary>
+        /// 创建时间
+        /// </summary>
+        public DateTime CreationTime { get; set; }
+
+        /// <summary>
+        /// 发送时间
+        /// </summary>
+        public DateTime? SendTime { get; set; }
+
+        /// <summary>
+        /// 发送人
+        /// </summary>
+        public string SendUser { get; set; }
+
+        /// <summary>
+        /// 发送部门
+        /// </summary>
+        public string SendOrganize { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string? Remark { get; set; }
+
+        /// <summary>
+        /// 关联工单编号
+        /// </summary>
+        public string? OrderNo { get; set; }
+
+        /// <summary>
+        /// 关联工单ID
+        /// </summary>
+        public string? OrderId { get; set; }
+
+        /// <summary>
+        /// 推送状态
+        /// </summary>
+        public EPushStatus Status { get; set; }
+    }
+}

+ 15 - 0
src/Hotline.Share/Dtos/Push/MessagePagedDto.cs

@@ -0,0 +1,15 @@
+using Hotline.Share.Enums.Push;
+using Hotline.Share.Requests;
+
+namespace Hotline.Share.Dtos.Push
+{
+
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="PushBusiness"></param>
+    /// <param name="Status"></param>
+    /// <param name="StartTime"></param>
+    /// <param name="EndTime"></param>
+    public record MessagePagedDto(EPushBusiness? PushBusiness, EPushStatus? Status, DateTime? StartTime, DateTime? EndTime) : PagedKeywordRequest;
+}

+ 37 - 0
src/Hotline.Share/Dtos/Push/TemplateDataDto.cs

@@ -0,0 +1,37 @@
+using Hotline.Share.Enums.Push;
+
+namespace Hotline.Share.Dtos.Push
+{
+    public record TemplateDataDto
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        public string Id { get; set; }
+
+        /// <summary>
+        /// 短信类型
+        /// </summary>
+        public EPushBusiness PushBusiness { get; set; }
+
+        /// <summary>
+        /// 短信Code
+        /// </summary>
+        public string Code { get; set; }
+
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public string Content { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string? Remark { get; set; }
+
+        /// <summary>
+        /// 模板状态
+        /// </summary>
+        public bool Status { get; set; }
+    }
+}

+ 47 - 0
src/Hotline.Share/Dtos/Push/TemplateDto.cs

@@ -0,0 +1,47 @@
+using Hotline.Share.Enums.Push;
+
+namespace Hotline.Share.Dtos.Push
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public record TemplateDto
+    {
+        /// <summary>
+        /// 短信类型
+        /// </summary>
+        public EPushBusiness PushBusiness { get; set; }
+
+        /// <summary>
+        /// 短信Code
+        /// </summary>
+        public string Code { get; set; }
+
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public string Content { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string? Remark { get; set; }
+
+        /// <summary>
+        /// 模板状态
+        /// </summary>
+        public bool Status { get; set; }
+    }
+
+    /// <summary>
+    /// 编辑
+    /// </summary>
+    public record UpdateTemplateDto : TemplateDto
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
+        public string Id { get; set; }
+    }
+
+}

+ 11 - 0
src/Hotline.Share/Dtos/Push/TemplatePagedDto.cs

@@ -0,0 +1,11 @@
+using Hotline.Share.Enums.Push;
+using Hotline.Share.Requests;
+
+namespace Hotline.Share.Dtos.Push
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="PushBusiness"></param>
+    public record TemplatePagedDto(EPushBusiness? PushBusiness) : PagedKeywordRequest;
+}

+ 19 - 1
src/Hotline.Share/Enums/Push/EPushStatus.cs

@@ -1,9 +1,27 @@
-namespace Hotline.Share.Enums.Push;
+using System.ComponentModel;
+
+namespace Hotline.Share.Enums.Push;
 
 /// <summary>
 /// 推送状态
 /// </summary>
 public enum EPushStatus
 {
+    /// <summary>
+    /// 
+    /// </summary>
+    [Description("推送中")]
+    Pushing =0,
+
+    /// <summary>
+    /// 
+    /// </summary>
+    [Description("推送成功")]
+    Success =1,
 
+    /// <summary>
+    /// 
+    /// </summary>
+    [Description("推送失败")]
+    Failed =2
 }

+ 7 - 0
src/Hotline/CallCenter/Devices/DeviceConfigs.cs

@@ -12,4 +12,11 @@
         /// </summary>
         public int Expired { get; set; }
     }
+
+    public class CallCenterConfiguration
+    {
+        public string CallCenterType { get; set; }
+
+        public DeviceConfigs DeviceConfigs { get; set; }
+    }
 }

+ 1 - 1
src/Hotline/CallCenter/IDeviceEventHandler.cs

@@ -7,6 +7,6 @@ namespace Hotline.CallCenter
     /// </summary>
     public interface IDeviceEventHandler
     {
-        Task HandleAsync(Stream eventStream, DeviceConfigs deviceConfigs, CancellationToken cancellationToken);
+        Task HandleAsync(Stream eventStream, CallCenterConfiguration deviceConfigs, CancellationToken cancellationToken);
     }
 }

+ 0 - 2
src/Hotline/Orders/Order.cs

@@ -258,8 +258,6 @@ namespace Hotline.Orders
         [SugarColumn(DefaultValue = "f")]
         public bool IsPublicity { get; set; }
 
-        //public bool IsPub { get; set; }
-
 
         #endregion
 

+ 8 - 0
src/Hotline/Push/IMessageRepository.cs

@@ -0,0 +1,8 @@
+using XF.Domain.Repository;
+
+namespace Hotline.Push
+{
+    public interface IMessageRepository : IRepository<Message>
+    {
+    }
+}

+ 8 - 0
src/Hotline/Push/IMessageTemplateRepository.cs

@@ -0,0 +1,8 @@
+using XF.Domain.Repository;
+
+namespace Hotline.Push
+{
+    public interface IMessageTemplateRepository : IRepository<MessageTemplate>
+    {
+    }
+}

+ 2 - 8
src/Hotline/Push/IPushDomainService.cs

@@ -1,13 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Hotline.Push
+namespace Hotline.Push
 {
     public interface IPushDomainService
     {
-        Task PushAsync(Message message, CancellationToken cancellation);
+        Task PushAsync(Message message, List<string> Params, CancellationToken cancellation);
     }
 }

+ 47 - 6
src/Hotline/Push/Message.cs

@@ -1,9 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Hotline.Orders;
+using Hotline.Settings;
 using Hotline.Share.Enums.Push;
+using Hotline.Users;
 using SqlSugar;
 using XF.Domain.Repository;
 
@@ -14,6 +12,9 @@ namespace Hotline.Push
     /// </summary>
     public class Message : CreationEntity
     {
+        /// <summary>
+        /// 消息推送业务
+        /// </summary>
         public EPushBusiness PushBusiness { get; set; }
 
         /// <summary>
@@ -45,6 +46,46 @@ namespace Hotline.Push
         /// <summary>
         /// 备注
         /// </summary>
-        public string Remark { get; set; }
+        [SugarColumn(IsNullable = true)]
+        public string? Remark { get; set; }
+
+        /// <summary>
+        /// 接收姓名
+        /// </summary>
+        public string Name { get; set; }
+
+        /// <summary>
+        /// 接收手机号码
+        /// </summary>
+        public string TelNumber { get; set; }
+
+        /// <summary>
+        /// 发送时间
+        /// </summary>
+        public DateTime? SendTime { get; set; }
+
+        /// <summary>
+        /// 关联工单编号
+        /// </summary>
+        [SugarColumn(IsNullable = true)]
+        public string? OrderId { get; set; }
+
+        /// <summary>
+        /// 发送人
+        /// </summary>
+        [Navigate(NavigateType.OneToOne, nameof(CreatorId))]//
+        public User User { get; set; }
+
+        /// <summary>
+        /// 发送部门
+        /// </summary>
+        [Navigate(NavigateType.OneToOne, nameof(CreatorOrgId))]//
+        public SystemOrganize SystemOrganize { get; set; }
+
+        /// <summary>
+        /// 关联工单信息
+        /// </summary>
+        [Navigate(NavigateType.OneToOne, nameof(OrderId))]//
+        public Order Order { get; set; }
     }
 }

+ 35 - 0
src/Hotline/Push/MessageTemplate.cs

@@ -0,0 +1,35 @@
+using Hotline.Share.Enums.Push;
+using SqlSugar;
+using XF.Domain.Repository;
+
+namespace Hotline.Push
+{
+    public class MessageTemplate : CreationModificationEntity
+    {
+        /// <summary>
+        /// 短信类型
+        /// </summary>
+        public EPushBusiness PushBusiness { get; set; }
+
+        /// <summary>
+        /// 短信Code
+        /// </summary>
+        public string Code { get; set; }
+
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public string Content { get; set; }
+
+        /// <summary>
+        /// 备注
+        /// </summary>
+        [SugarColumn(IsNullable = true)]
+        public string? Remark { get; set; }
+
+        /// <summary>
+        /// 模板状态
+        /// </summary>
+        public bool Status { get; set; }
+    }
+}

+ 55 - 3
src/Hotline/Push/PushDomainService.cs

@@ -1,11 +1,63 @@
-using XF.Domain.Dependency;
+using System.Text.RegularExpressions;
+using XF.Domain.Dependency;
+using XF.Domain.Exceptions;
 
 namespace Hotline.Push;
 
 public class PushDomainService : IPushDomainService, IScopeDependency
 {
-    public async Task PushAsync(Message message, CancellationToken cancellation)
+
+    private readonly IMessageRepository _messageRepository;
+
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="messageRepository"></param>
+    public PushDomainService(IMessageRepository messageRepository)
+    {
+        _messageRepository = messageRepository;
+    }
+
+    /// <summary>
+    /// 业务处理
+    /// </summary>
+    /// <param name="message"></param>
+    /// <param name="Params"></param>
+    /// <param name="cancellation"></param>
+    /// <returns></returns>
+    public async Task PushAsync(Message message, List<string> Params, CancellationToken cancellation)
     {
-        throw new NotImplementedException();
+        if (message == null)
+        {
+            throw UserFriendlyException.SameMessage("消息不能为空!");
+        }
+
+        //如果模板为空,参数为空则直接用短信内容
+        if (!string.IsNullOrEmpty(message.Template) && Params.Count > 0)
+        {
+            string Template = message.Template;
+            //正则查询模板中需要替换的内容
+            Regex regex = new(@"\{[a-zA-Z0-9]{1,}\}");
+            var matches = regex.Matches(Template);
+            if (matches != null && matches.Count != Params.Count)
+            {
+                //参数与需要替换的字符数不匹配
+                //throw UserFriendlyException.SameMessage("模板需要参数与实际传递参数个数不匹配!");
+                message.Remark = "模板需要参数与实际传递参数个数不匹配!";
+            }
+
+            //根据正则查询出来的匹配项替换内容
+            for (int i = 0; i < matches.Count; i++)
+            {
+                var strTemp = matches[i].ToString();
+                Template = Template.Replace(strTemp, Params[i]);
+            }
+
+            message.Content = Template;
+        }
+        //写入本地数据库
+        var id = await _messageRepository.AddAsync(message);
+
+        //调用短信发送业务
     }
 }