|
@@ -1,103 +0,0 @@
|
|
|
-using DotNetCore.CAP;
|
|
|
-using Hotline.Caching.Interfaces;
|
|
|
-using Hotline.Configurations;
|
|
|
-using Hotline.ContingencyManagement.Notifies;
|
|
|
-using Hotline.EventBus;
|
|
|
-using Hotline.FlowEngine.Notifications;
|
|
|
-using Hotline.FlowEngine.WorkflowModules;
|
|
|
-using Hotline.Orders;
|
|
|
-using Hotline.Settings;
|
|
|
-using Hotline.Share.Dtos;
|
|
|
-using Hotline.Share.Dtos.Order;
|
|
|
-using Hotline.Share.Enums.FlowEngine;
|
|
|
-using Hotline.Share.Enums.Order;
|
|
|
-using Hotline.Share.Tools;
|
|
|
-using Mapster;
|
|
|
-using MediatR;
|
|
|
-using Microsoft.AspNetCore.Http;
|
|
|
-using Microsoft.Extensions.Logging;
|
|
|
-using Microsoft.Extensions.Options;
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using XF.Domain.Authentications;
|
|
|
-using XF.Domain.Repository;
|
|
|
-
|
|
|
-namespace Hotline.Application.Orders.OrderPublishHandler;
|
|
|
-
|
|
|
-/// <summary>
|
|
|
-/// 中心直办件归档后默认自动发布
|
|
|
-/// </summary>
|
|
|
-public class OrderPublishEndWorkflowHandler : INotificationHandler<EndWorkflowNotify>
|
|
|
-{
|
|
|
- private readonly IOrderRepository _orderRepository;
|
|
|
- private readonly Publisher _publisher;
|
|
|
- private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
|
|
|
- private readonly IRepository<OrderPublish> _orderPublishRepository;
|
|
|
- private readonly ISessionContextProvider _sessionContextProvider;
|
|
|
- private readonly ICapPublisher _capPublisher;
|
|
|
- private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
- private readonly IOrderDomainService _orderDomainService;
|
|
|
- private readonly IOrderVisitRepository _orderVisitRepository;
|
|
|
- private readonly IRepository<OrderVisitDetail> _orderVisitedDetailRepository;
|
|
|
- private readonly ILogger<OrderPublishEndWorkflowHandler> _logger;
|
|
|
- private readonly ISystemLogRepository _systemLogRepository;
|
|
|
- private const string Name = "中心直办件归档后默认自动发布";
|
|
|
- private string ClassName = nameof(OrderPublishEndWorkflowHandler);
|
|
|
-
|
|
|
- public OrderPublishEndWorkflowHandler(IOrderRepository orderRepository, IRepository<OrderPublish> orderPublishRepository, ISessionContextProvider sessionContextProvider, ICapPublisher capPublisher, ISystemSettingCacheManager systemSettingCacheManager, Publisher publisher, IOptionsSnapshot<AppConfiguration> appOptions, IOrderVisitRepository orderVisitRepository, IRepository<OrderVisitDetail> orderVisitedDetailRepository, ILogger<OrderPublishEndWorkflowHandler> logger, ISystemLogRepository systemLogRepository, IOrderDomainService orderDomainService)
|
|
|
- {
|
|
|
- _orderRepository = orderRepository;
|
|
|
- _orderPublishRepository = orderPublishRepository;
|
|
|
- _sessionContextProvider = sessionContextProvider;
|
|
|
- _capPublisher = capPublisher;
|
|
|
- _systemSettingCacheManager = systemSettingCacheManager;
|
|
|
- _publisher = publisher;
|
|
|
- _appOptions = appOptions;
|
|
|
- _orderVisitRepository = orderVisitRepository;
|
|
|
- _orderVisitedDetailRepository = orderVisitedDetailRepository;
|
|
|
- _logger = logger;
|
|
|
- _systemLogRepository = systemLogRepository;
|
|
|
- _orderDomainService = orderDomainService;
|
|
|
- }
|
|
|
-
|
|
|
- public async Task Handle(EndWorkflowNotify notification, CancellationToken cancellationToken)
|
|
|
- {
|
|
|
- await _systemLogRepository.AddAsync(Name, notification.Workflow.ExternalId, "进入方法", ClassName, status: 1);
|
|
|
- try
|
|
|
- {
|
|
|
- if (_systemSettingCacheManager.AutomaticPublishOrder == false)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (notification.Workflow.ModuleCode != WorkflowModuleConsts.OrderHandle)
|
|
|
- return;
|
|
|
- var order = await _orderRepository.GetAsync(notification.Workflow.ExternalId, cancellationToken);
|
|
|
- if (order == null)
|
|
|
- {
|
|
|
- await _systemLogRepository.AddAsync(Name, notification.Workflow.ExternalId, "根据 workflow.ExternalId 查询 order 为空", ClassName);
|
|
|
- return;
|
|
|
- }
|
|
|
- var checkResult = order.AutoPublishCheck();
|
|
|
- if (checkResult.NotNullOrEmpty())
|
|
|
- {
|
|
|
- await _systemLogRepository.AddAsync(Name, order.Id, checkResult);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (order.ProcessType != EProcessType.Zhiban)
|
|
|
- {
|
|
|
- await _systemLogRepository.AddAsync(Name, order.Id, "非中心直办件", ClassName);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- await _orderDomainService.OrderPublishAsync(order, cancellationToken);
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- await _systemLogRepository.AddAsync(Name, notification.Workflow.ExternalId, $"系统异常: {e.Message}", ClassName);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|