|
@@ -5,6 +5,7 @@ using Hotline.FlowEngine.WorkflowModules;
|
|
|
using Hotline.FlowEngine.Workflows;
|
|
|
using Hotline.KnowledgeBase;
|
|
|
using Hotline.Orders;
|
|
|
+using Hotline.Push.Notifies;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Settings.TimeLimits;
|
|
|
using Hotline.Share.Dtos.FlowEngine.Workflow;
|
|
@@ -12,13 +13,16 @@ using Hotline.Share.Dtos.Order;
|
|
|
using Hotline.Share.Dtos.Settings;
|
|
|
using Hotline.Share.Enums.FlowEngine;
|
|
|
using Hotline.Share.Enums.Order;
|
|
|
+using Hotline.Share.Enums.Push;
|
|
|
using Hotline.Share.Enums.Quality;
|
|
|
using Hotline.Share.Mq;
|
|
|
+using Hotline.Users;
|
|
|
using MapsterMapper;
|
|
|
using MediatR;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Newtonsoft.Json;
|
|
|
using XF.Domain.Authentications;
|
|
|
+using XF.Domain.Entities;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Application.Handlers.FlowEngine;
|
|
@@ -39,8 +43,10 @@ public class WorkflowNextHandler : INotificationHandler<NextStepNotify>
|
|
|
private readonly IKnowledgeRepository _knowledgeRepository;
|
|
|
private readonly IKnowledgeWorkFlowRepository _knowledgeWorkFlowRepository;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
+ private readonly IRepository<User> _userRepository;
|
|
|
+ private readonly IMediator _mediator;
|
|
|
|
|
|
- public WorkflowNextHandler(
|
|
|
+ public WorkflowNextHandler(
|
|
|
IOrderDomainService orderDomainService,
|
|
|
IKnowledgeDomainService knowledgeDomainService,
|
|
|
IOrderRepository orderRepository,
|
|
@@ -54,7 +60,9 @@ public class WorkflowNextHandler : INotificationHandler<NextStepNotify>
|
|
|
IKnowledgeRepository knowledgeRepository,
|
|
|
IKnowledgeWorkFlowRepository knowledgeWorkFlowRepository,
|
|
|
ISessionContext sessionContext,
|
|
|
- IOrderDelayRepository orderDelayRepository)
|
|
|
+ IOrderDelayRepository orderDelayRepository,
|
|
|
+ IRepository<User> userRepository,
|
|
|
+ IMediator mediator)
|
|
|
{
|
|
|
_orderDomainService = orderDomainService;
|
|
|
_knowledgeDomainService = knowledgeDomainService;
|
|
@@ -70,7 +78,9 @@ public class WorkflowNextHandler : INotificationHandler<NextStepNotify>
|
|
|
_knowledgeRepository = knowledgeRepository;
|
|
|
_knowledgeWorkFlowRepository = knowledgeWorkFlowRepository;
|
|
|
_sessionContext = sessionContext;
|
|
|
- }
|
|
|
+ _userRepository = userRepository;
|
|
|
+ _mediator = mediator;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>Handles a notification</summary>
|
|
|
/// <param name="notification">The notification</param>
|
|
@@ -133,7 +143,63 @@ public class WorkflowNextHandler : INotificationHandler<NextStepNotify>
|
|
|
//}
|
|
|
|
|
|
await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (notification.Dto.IsSms)
|
|
|
+ {
|
|
|
+ switch (notification.FlowAssignInfo.FlowAssignType)
|
|
|
+ {
|
|
|
+ case EFlowAssignType.Org:
|
|
|
+ var orgCodes = notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
|
|
|
+ var orgList = await _userRepository.Queryable().Where(x => orgCodes.Contains(x.OrgId) && x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e")).ToListAsync();
|
|
|
+ foreach (var item in orgList)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(item.PhoneNo))
|
|
|
+ {
|
|
|
+ var messageDto = new Share.Dtos.Push.MessageDto
|
|
|
+ {
|
|
|
+ PushBusiness = EPushBusiness.OrderSupervise,
|
|
|
+ ExternalId = order.Id,
|
|
|
+ OrderId = order.Id,
|
|
|
+ PushPlatform = EPushPlatform.Sms,
|
|
|
+ Remark = order.Title,
|
|
|
+ Name = item.PhoneNo,
|
|
|
+ TemplateCode = "1007",
|
|
|
+ Params = new List<string>() { order.No },
|
|
|
+ TelNumber = item.PhoneNo,
|
|
|
+
|
|
|
+ };
|
|
|
+ await _mediator.Publish(new PushMessageNotify(messageDto), cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case EFlowAssignType.User:
|
|
|
+ var userCodes = notification.FlowAssignInfo.HandlerObjects.Select(x => x.Key);
|
|
|
+ var userList = await _userRepository.Queryable().Where(x => userCodes.Contains(x.Id) && x.Roles.Any(d => d.Id == "08dae71e-0eca-4bc4-89fe-7eaefae8a98e")).ToListAsync();
|
|
|
+ foreach (var item in userList)
|
|
|
+ {
|
|
|
+ var messageDto = new Share.Dtos.Push.MessageDto
|
|
|
+ {
|
|
|
+ PushBusiness = EPushBusiness.OrderSupervise,
|
|
|
+ ExternalId = order.Id,
|
|
|
+ OrderId = order.Id,
|
|
|
+ PushPlatform = EPushPlatform.Sms,
|
|
|
+ Remark = order.Title,
|
|
|
+ Name = item.PhoneNo,
|
|
|
+ TemplateCode = "1007",
|
|
|
+ Params = new List<string>() { order.No },
|
|
|
+ TelNumber = item.PhoneNo,
|
|
|
|
|
|
+ };
|
|
|
+ await _mediator.Publish(new PushMessageNotify(messageDto), cancellationToken);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
var orderDto = _mapper.Map<OrderDto>(order);
|
|
|
await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderFlowHandled, new OrderFlowDto
|
|
|
{
|