|
@@ -24,6 +24,14 @@ using SqlSugar;
|
|
|
using Hotline.Push.Notifies;
|
|
|
using Hotline.Share.Enums.Push;
|
|
|
using MediatR;
|
|
|
+using Hotline.Authentications;
|
|
|
+using Hotline.ContingencyManagement.Notifies;
|
|
|
+using Hotline.EventBus;
|
|
|
+using Hotline.Share.Enums.FlowEngine;
|
|
|
+using Mapster;
|
|
|
+using Microsoft.AspNetCore.Builder.Extensions;
|
|
|
+using Hotline.Configurations;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
|
|
|
namespace Hotline.Orders;
|
|
|
|
|
@@ -38,16 +46,19 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
private readonly ITypedCache<CacheOrderNO> _cacheOrderNo;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly ICapPublisher _capPublisher;
|
|
|
+ private readonly IRepository<OrderVisitDetail> _orderVisitDetailRepository;
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly ILogger<OrderDomainService> _logger;
|
|
|
private readonly IFileRepository _fileRepository;
|
|
|
private readonly IRepository<Scheduling> _schedulingRepository;
|
|
|
+ private readonly Publisher _publisher;
|
|
|
+ private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
|
|
|
private readonly IRepository<User> _userRepository;
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
private readonly IWorkflowDomainService _workflowDomainService;
|
|
|
private readonly IRepository<Hotspot> _hotspotRepository;
|
|
|
private readonly IMediator _mediator;
|
|
|
-
|
|
|
+ private readonly IRepository<WorkflowStep> _workflowStepRepository;
|
|
|
|
|
|
public OrderDomainService(
|
|
|
IOrderRepository orderRepository,
|
|
@@ -68,7 +79,10 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
IRepository<Scheduling> schedulingRepository,
|
|
|
IWorkflowDomainService workflowDomainService,
|
|
|
IRepository<Hotspot> hotspotRepository,
|
|
|
- IMediator mediator)
|
|
|
+ IMediator mediator,
|
|
|
+ Publisher publisher,
|
|
|
+ IRepository<OrderVisitDetail> orderVisitDetailRepository,
|
|
|
+ IRepository<WorkflowStep> workflowStepRepository)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
|
_orderRedoRepository = orderRedoRepository;
|
|
@@ -88,6 +102,153 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
_workflowDomainService = workflowDomainService;
|
|
|
_hotspotRepository = hotspotRepository;
|
|
|
_mediator = mediator;
|
|
|
+ _publisher = publisher;
|
|
|
+ _orderVisitDetailRepository = orderVisitDetailRepository;
|
|
|
+ _workflowStepRepository = workflowStepRepository;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task OrderPublishAsync(Order order, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ OrderPublish orderPublish = new()
|
|
|
+ {
|
|
|
+ OrderId = order.Id,
|
|
|
+ No = order.No,
|
|
|
+ PublishState = false, //当前写死为false
|
|
|
+ ArrangeTitle = order.Title,
|
|
|
+ ArrangeContent = order.Content,
|
|
|
+ ArrangeOpinion = order.FileOpinion,
|
|
|
+ ProPublishState = false,
|
|
|
+ FeedBackPhone = order.Contact,
|
|
|
+ CreatorName = _sessionContext.UserName
|
|
|
+ };
|
|
|
+ await _orderPublishRepository.AddAsync(orderPublish, cancellationToken);
|
|
|
+ order.Publish(orderPublish.PublishState);
|
|
|
+ await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
+ //推省上
|
|
|
+ var publishPublishOrder = orderPublish.Adapt<PublishPublishOrderDto>();
|
|
|
+ publishPublishOrder.Order = order.Adapt<OrderDto>();
|
|
|
+ //查询实际办理附件
|
|
|
+ if (!string.IsNullOrEmpty(order.ActualHandleStepId))
|
|
|
+ {
|
|
|
+ var actualHandleStep = await _workflowStepRepository.GetAsync(order.ActualHandleStepId, cancellationToken);
|
|
|
+ publishPublishOrder.FileJsons = actualHandleStep?.FileJson;
|
|
|
+ }
|
|
|
+
|
|
|
+ await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderPublishOrder, publishPublishOrder, cancellationToken: cancellationToken);
|
|
|
+
|
|
|
+ //推应急管理局
|
|
|
+ //是否开启
|
|
|
+ var isOpenContingencyManagement =
|
|
|
+ _systemSettingCacheManager.GetSetting(SettingConstants.IsOpenContingencyManagement)?.SettingValue[0];
|
|
|
+ if (isOpenContingencyManagement == "true")
|
|
|
+ await _publisher.PublishAsync(new ContingencyManagementNotify(order, order.Title, order.Content, order.ActualOpinion),
|
|
|
+ PublishStrategy.ParallelWhenAll, cancellationToken);
|
|
|
+
|
|
|
+ var orderVisit = new OrderVisit
|
|
|
+ {
|
|
|
+ No = order.No,
|
|
|
+ OrderId = order.Id,
|
|
|
+ VisitState = EVisitState.WaitForVisit,
|
|
|
+ PublishTime = DateTime.Now,
|
|
|
+ IsCanHandle = true,
|
|
|
+ EmployeeId = _sessionContext.RequiredUserId
|
|
|
+ };
|
|
|
+ if (!order.IsProvince)
|
|
|
+ {
|
|
|
+ orderVisit.EmployeeId = _sessionContext.RequiredUserId;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_appOptions.Value.IsZiGong)
|
|
|
+ {
|
|
|
+ orderVisit.EmployeeId = string.Empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (order is { ProcessType: EProcessType.Zhiban, CounterSignType: null } && !order.IsProvince)
|
|
|
+ {
|
|
|
+ orderVisit.VisitState = EVisitState.Visited;
|
|
|
+ orderVisit.VisitTime = DateTime.Now;
|
|
|
+ orderVisit.VisitType = EVisitType.OtherVisit;
|
|
|
+ orderVisit.NowEvaluate = new Kv() { Key = "4", Value = "满意" };
|
|
|
+ if (_appOptions.Value.IsZiGong)
|
|
|
+ {
|
|
|
+ // 根据禅道 自贡需求 Id_361, 第一条, 3小条需求;
|
|
|
+ // 直办件归档后自动回访量需统计在“胡玲”的默认回访量中;
|
|
|
+ orderVisit.EmployeeId = _systemSettingCacheManager.DefaultVisitEmployeeId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (order.CounterSignType != ECounterSignType.Center)
|
|
|
+ {
|
|
|
+ orderVisit.IsCanAiVisit = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ string visitId = await _orderVisitRepository.AddAsync(orderVisit);
|
|
|
+
|
|
|
+ //新增回访信息
|
|
|
+ var visitedDetail = new List<OrderVisitDetail>();
|
|
|
+
|
|
|
+ var seatDetail = new OrderVisitDetail();
|
|
|
+ seatDetail.VisitId = visitId;
|
|
|
+ seatDetail.VisitTarget = EVisitTarget.Seat;
|
|
|
+
|
|
|
+
|
|
|
+ var orgDetail = new OrderVisitDetail();
|
|
|
+ orgDetail.VisitId = visitId;
|
|
|
+ orgDetail.VisitOrgCode = order.ActualHandleOrgCode;
|
|
|
+ orgDetail.VisitOrgName = order.ActualHandleOrgName;
|
|
|
+ orgDetail.VisitTarget = EVisitTarget.Org;
|
|
|
+ if (order is { ProcessType: EProcessType.Zhiban, CounterSignType: null, IsProvince: false })
|
|
|
+ {
|
|
|
+ var satisfy = new Kv() { Key = "4", Value = "满意" };
|
|
|
+ orgDetail.OrgProcessingResults = satisfy;
|
|
|
+ //orgDetail.OrgHandledAttitude = satisfy;
|
|
|
+ }
|
|
|
+
|
|
|
+ visitedDetail.Add(orgDetail);
|
|
|
+
|
|
|
+ if (order is { ProcessType: EProcessType.Zhiban, CounterSignType: null })
|
|
|
+ {
|
|
|
+ seatDetail.VoiceEvaluate = EVoiceEvaluate.Satisfied;
|
|
|
+ seatDetail.SeatEvaluate = ESeatEvaluate.Satisfied;
|
|
|
+ order.Visited("4", "满意");
|
|
|
+ order.Status = EOrderStatus.Visited;
|
|
|
+ await _orderRepository.UpdateAsync(order, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ visitedDetail.Add(seatDetail);
|
|
|
+ await _orderVisitDetailRepository.AddRangeAsync(visitedDetail, cancellationToken);
|
|
|
+
|
|
|
+ if (order.IsProvince == false && orderVisit.VisitState == EVisitState.Visited)
|
|
|
+ {
|
|
|
+ //推省上
|
|
|
+ await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderVisited,
|
|
|
+ new PublishVisitDto()
|
|
|
+ {
|
|
|
+ Order = order.Adapt<OrderDto>(),
|
|
|
+ No = orderVisit.No,
|
|
|
+ VisitType = orderVisit.VisitType,
|
|
|
+ VisitName = orderVisit.CreatorName,
|
|
|
+ VisitTime = orderVisit.VisitTime,
|
|
|
+ VisitRemark = orderVisit.NowEvaluate?.Value,
|
|
|
+ AreaCode = order.AreaCode!,
|
|
|
+ SubjectResultSatifyCode = orderVisit.NowEvaluate?.Key,
|
|
|
+ FirstSatisfactionCode = orderVisit.NowEvaluate?.Key,
|
|
|
+ ClientGuid = ""
|
|
|
+ }, cancellationToken: cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ //推门户
|
|
|
+ await _capPublisher.PublishAsync(Hotline.Share.Mq.EventNames.HotlineOrderVisitedWeb, new PublishVisitAllDto()
|
|
|
+ {
|
|
|
+ Id = orderVisit.Id,
|
|
|
+ Order = order.Adapt<OrderDto>(),
|
|
|
+ OrderVisitDetails = orderVisit.OrderVisitDetails.Adapt<List<VisitDetailDto>>(),
|
|
|
+ VisitName = _sessionContext.UserName,
|
|
|
+ VisitTime = orderVisit.VisitTime,
|
|
|
+ VisitType = orderVisit.VisitType,
|
|
|
+ VisitState = orderVisit.VisitState,
|
|
|
+ PublishTime = orderVisit.PublishTime,
|
|
|
+ }, cancellationToken: cancellationToken);
|
|
|
}
|
|
|
|
|
|
public async Task<Order> GetOrderAsync(string? orderId, bool withHotspot = false, bool withAcceptor = false,
|
|
@@ -328,6 +489,7 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
#region 工单校验- 交通类工单
|
|
|
|
|
|
/// <summary>
|