|
@@ -29,6 +29,11 @@ using Microsoft.AspNetCore.Http;
|
|
|
using Hotline.Share.Dtos.FlowEngine;
|
|
|
using Hotline.FlowEngine.Workflows;
|
|
|
using Hotline.Share.Enums.FlowEngine;
|
|
|
+using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Mq;
|
|
|
+using Hotline.Snapshot.Notifications;
|
|
|
+using Hotline.EventBus;
|
|
|
+using Hotline.Quality.Notifications;
|
|
|
|
|
|
namespace Hotline.Application.Snapshot;
|
|
|
|
|
@@ -48,8 +53,8 @@ public abstract class SnapshotApplicationBase
|
|
|
private readonly IThirdIdentiyService _thirdLoginService;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly IRepository<RedPackRecord> _redPackRecordRepository;
|
|
|
- private readonly IRepository<OrderSnapshot> _orderSnapshotRepository;
|
|
|
- private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
+ private readonly IOrderSnapshotRepository _orderSnapshotRepository;
|
|
|
+ private readonly ISystemSettingCacheManager _sysSetting;
|
|
|
private readonly ISystemAreaDomainService _systemAreaDomainService;
|
|
|
private readonly IRepository<SystemArea> _systemAreaRepository;
|
|
|
private readonly IFileRepository _fileRepository;
|
|
@@ -59,8 +64,13 @@ public abstract class SnapshotApplicationBase
|
|
|
private readonly IPractitionerRepository _practitionerRepository;
|
|
|
private readonly IVolunteerRepository _volunteerRepository;
|
|
|
private readonly IVolunteerReportRepository _volunteerReportRepository;
|
|
|
+ private readonly ISystemLogRepository _systemLog;
|
|
|
+ private readonly IGuiderSystemService _guiderSystemService;
|
|
|
+ private readonly ICapPublisher _capPublisher;
|
|
|
+ private readonly Publisher _publisher;
|
|
|
+ private readonly IGuiderInfoRepository _guiderInfoRepository;
|
|
|
|
|
|
- public SnapshotApplicationBase(IThirdIdentiyService thirdLoginService, IRepository<Industry> industryRepository, ISnapshotBulletinRepository bulletinRepository, ISessionContext sessionContext, IRepository<RedPackRecord> redPackRecordRepository, IRepository<Order> orderRepository, IThirdAccountRepository thirdAccountRepository, IRepository<OrderSnapshot> orderSnapshotRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemAreaDomainService systemAreaDomainService, IFileRepository fileRepository, ISystemDicDataCacheManager systemDicDataCacheManager, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, IRepository<WorkflowTrace> workflowTraceRepository, IPractitionerRepository practitionerRepository, IRepository<SystemArea> systemAreaRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository)
|
|
|
+ public SnapshotApplicationBase(IThirdIdentiyService thirdLoginService, IRepository<Industry> industryRepository, ISnapshotBulletinRepository bulletinRepository, ISessionContext sessionContext, IRepository<RedPackRecord> redPackRecordRepository, IRepository<Order> orderRepository, IThirdAccountRepository thirdAccountRepository, IOrderSnapshotRepository orderSnapshotRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemAreaDomainService systemAreaDomainService, IFileRepository fileRepository, ISystemDicDataCacheManager systemDicDataCacheManager, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, IRepository<WorkflowTrace> workflowTraceRepository, IPractitionerRepository practitionerRepository, IRepository<SystemArea> systemAreaRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository, ISystemLogRepository systemLog, IGuiderSystemService guiderSystemService, ICapPublisher capPublisher, Publisher publisher, IGuiderInfoRepository guiderInfoRepository)
|
|
|
{
|
|
|
_thirdLoginService = thirdLoginService;
|
|
|
_industryRepository = industryRepository;
|
|
@@ -70,7 +80,7 @@ public abstract class SnapshotApplicationBase
|
|
|
_orderRepository = orderRepository;
|
|
|
_thirdAccountRepository = thirdAccountRepository;
|
|
|
_orderSnapshotRepository = orderSnapshotRepository;
|
|
|
- _systemSettingCacheManager = systemSettingCacheManager;
|
|
|
+ _sysSetting = systemSettingCacheManager;
|
|
|
_systemAreaDomainService = systemAreaDomainService;
|
|
|
_fileRepository = fileRepository;
|
|
|
_systemDicDataCacheManager = systemDicDataCacheManager;
|
|
@@ -80,6 +90,11 @@ public abstract class SnapshotApplicationBase
|
|
|
_systemAreaRepository = systemAreaRepository;
|
|
|
_volunteerRepository = volunteerRepository;
|
|
|
_volunteerReportRepository = volunteerReportRepository;
|
|
|
+ _systemLog = systemLog;
|
|
|
+ _guiderSystemService = guiderSystemService;
|
|
|
+ _capPublisher = capPublisher;
|
|
|
+ _publisher = publisher;
|
|
|
+ _guiderInfoRepository = guiderInfoRepository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -88,8 +103,8 @@ public abstract class SnapshotApplicationBase
|
|
|
/// <returns></returns>
|
|
|
public async Task<HomePageOutDto> GetHomePageAsync()
|
|
|
{
|
|
|
- var fileServiceUrl = _systemSettingCacheManager.FileServerUrl;
|
|
|
- var fileDownloadApi = fileServiceUrl + _systemSettingCacheManager.FileDownloadApi;
|
|
|
+ var fileServiceUrl = _sysSetting.FileServerUrl;
|
|
|
+ var fileDownloadApi = fileServiceUrl + _sysSetting.FileDownloadApi;
|
|
|
var items = await _industryRepository.Queryable()
|
|
|
.Where(m => m.IsEnable)
|
|
|
.OrderBy(m => m.DisplayOrder)
|
|
@@ -108,7 +123,7 @@ public abstract class SnapshotApplicationBase
|
|
|
|
|
|
return new HomePageOutDto
|
|
|
{
|
|
|
- Banners = _systemSettingCacheManager.AppBanner.Split('|').Select(m => fileDownloadApi + m).ToList(),
|
|
|
+ Banners = _sysSetting.AppBanner.Split('|').Select(m => fileDownloadApi + m).ToList(),
|
|
|
Industrys = items
|
|
|
};
|
|
|
}
|
|
@@ -117,7 +132,7 @@ public abstract class SnapshotApplicationBase
|
|
|
/// 获取小程序首页弹窗
|
|
|
/// </summary>
|
|
|
public async Task<BulletinOutDto> GetBulletionPopupAsync(CancellationToken requestAborted)
|
|
|
- {
|
|
|
+ {
|
|
|
var item = await _bulletinRepository.Queryable()
|
|
|
.Where(m => m.BulletinState == EBulletinState.ReviewPass)
|
|
|
.Where(m => m.BulletinTime >= DateTime.Now && m.IsPopup == true)
|
|
@@ -133,8 +148,8 @@ public abstract class SnapshotApplicationBase
|
|
|
/// <returns></returns>
|
|
|
public async Task<IList<IndustryOutDto>> GetIndustresAsync()
|
|
|
{
|
|
|
- var fileServiceUrl = _systemSettingCacheManager.FileServerUrl;
|
|
|
- var fileDownloadApi = fileServiceUrl + _systemSettingCacheManager.FileDownloadApi;
|
|
|
+ var fileServiceUrl = _sysSetting.FileServerUrl;
|
|
|
+ var fileDownloadApi = fileServiceUrl + _sysSetting.FileDownloadApi;
|
|
|
var items = await _industryRepository.Queryable()
|
|
|
.Where(m => m.IsEnable)
|
|
|
.OrderBy(m => m.DisplayOrder)
|
|
@@ -150,8 +165,8 @@ public abstract class SnapshotApplicationBase
|
|
|
/// <returns></returns>
|
|
|
public async Task<IndustryBaseOutDto> GetIndustryBaseAsync(string id, CancellationToken requestAborted)
|
|
|
{
|
|
|
- var fileServiceUrl = _systemSettingCacheManager.FileServerUrl;
|
|
|
- var fileDownloadApi = fileServiceUrl + _systemSettingCacheManager.FileDownloadApi;
|
|
|
+ var fileServiceUrl = _sysSetting.FileServerUrl;
|
|
|
+ var fileDownloadApi = fileServiceUrl + _sysSetting.FileDownloadApi;
|
|
|
var indurstry = await _industryRepository.GetAsync(id, requestAborted)
|
|
|
?? throw UserFriendlyException.SameMessage("行业不存在:" + id);
|
|
|
|
|
@@ -226,7 +241,7 @@ public abstract class SnapshotApplicationBase
|
|
|
throw UserFriendlyException.SameMessage("工单不存在");
|
|
|
|
|
|
var outDto = publish.Adapt<OrderPublishDetailOutDto>();
|
|
|
- var fileServiceUrl = _systemSettingCacheManager.FileServerUrl;
|
|
|
+ var fileServiceUrl = _sysSetting.FileServerUrl;
|
|
|
if (outDto.FileJson != null)
|
|
|
{
|
|
|
foreach (var item in outDto.FileJson)
|
|
@@ -332,7 +347,7 @@ public abstract class SnapshotApplicationBase
|
|
|
throw UserFriendlyException.SameMessage("工单不存在");
|
|
|
|
|
|
var outDto = order.Adapt<OrderPublishDetailOutDto>();
|
|
|
- var fileServiceUrl = _systemSettingCacheManager.FileServerUrl;
|
|
|
+ var fileServiceUrl = _sysSetting.FileServerUrl;
|
|
|
if (outDto.FileJson != null)
|
|
|
{
|
|
|
foreach (var item in outDto.FileJson)
|
|
@@ -487,6 +502,119 @@ public abstract class SnapshotApplicationBase
|
|
|
await _thirdAccountRepository.UpdateAsync(third);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 推送工单到网格员系统
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="orderId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task PostOrderGuiderSystemAsync(string orderId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ string LogName = "推送网格员系统";
|
|
|
+ var order = await _orderRepository.GetAsync(orderId, cancellationToken);
|
|
|
+ var orderSnapshot = await _orderSnapshotRepository.GetAsync(orderId, cancellationToken);
|
|
|
+ if (order is null || orderSnapshot is null)
|
|
|
+ {
|
|
|
+ var msg = order is null ? "order" : "orderSnapshot";
|
|
|
+ _systemLog.Add(LogName, $"OrderId: {orderId}", $"根据Id查询{msg}为null");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ orderSnapshot.DeadLine = DateTime.Now.AddHours(_sysSetting.OvertimeBack);
|
|
|
+ var keySecret = _sysSetting.TianQueAppKeySecret.Split('|');
|
|
|
+
|
|
|
+ var token = new ThirdTokenDto
|
|
|
+ {
|
|
|
+ AppId = keySecret[0],
|
|
|
+ Secret = keySecret[1]
|
|
|
+ };
|
|
|
+ if (order.FileJson.NotNullOrEmpty())
|
|
|
+ {
|
|
|
+ var url = _sysSetting.FileServerUrl;
|
|
|
+ order.FileJson.ForEach(m => { m.Path = url + m.Path; });
|
|
|
+ }
|
|
|
+ var result = await _guiderSystemService.PostOrder(order, orderSnapshot, token);
|
|
|
+ orderSnapshot.GuiderAccLog = result.Result.ToJson();
|
|
|
+ if (result.Code != 0)
|
|
|
+ {
|
|
|
+ _systemLog.Add(LogName, $"OrderNo: {order.No}", $"推送失败: {result.ToJson()}");
|
|
|
+ orderSnapshot.GuiderAccLog = result.ToJson();
|
|
|
+ }
|
|
|
+ orderSnapshot.NetworkENumber = result.Result.GuiderSystemId;
|
|
|
+ await _orderSnapshotRepository.UpdateAsync(orderSnapshot, cancellationToken);
|
|
|
+ _systemLog.Add(LogName, $"OrderNo: {order.No}", status: 1);
|
|
|
+ if (result.Code == 0)
|
|
|
+ {
|
|
|
+ await _capPublisher.PublishAsync(EventNames.GuiderSystemReplyDelay, new PostGuiderSystemDelayed(order.Id));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 延迟检查网格员是否回复工单
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="orderId"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task GuiderSystemReplyDelayAsync(string orderId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var orderSnapshot = await _orderSnapshotRepository.GetAsync(orderId)
|
|
|
+ ?? throw new UserFriendlyException($"orderId:{orderId} order_snapshot 不存在该数据");
|
|
|
+ if (orderSnapshot.IsDeal != null && orderSnapshot.IsDeal == true)
|
|
|
+ return;
|
|
|
+ // 网格员未回复, 推送事件
|
|
|
+ await _publisher.PublishAsync(new GuiderSystemTimeOutBackNotification(orderId), cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 网格员系统回复
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task SaveGuiderSystemReplyAsync(GuiderSystemInDto dto, CancellationToken token)
|
|
|
+ {
|
|
|
+ var orderSnapshot = await _orderSnapshotRepository.GetByGuiderSystemIdAsync(dto.AppealNumber)
|
|
|
+ ?? throw UserFriendlyException.SameMessage("工单不存在");
|
|
|
+ dto.Adapt(orderSnapshot);
|
|
|
+ await _orderSnapshotRepository.UpdateAsync(orderSnapshot);
|
|
|
+ // 网格员办结
|
|
|
+ if (orderSnapshot.ReplyResultType == EGuiderSystemReplyType.Field)
|
|
|
+ {
|
|
|
+ await _publisher.PublishAsync(new GuiderSystemFieldNotification(orderSnapshot.Id), token);
|
|
|
+ }
|
|
|
+ // 网格员超时未回复退回
|
|
|
+ if (orderSnapshot.ReplyResultType == EGuiderSystemReplyType.Returned)
|
|
|
+ {
|
|
|
+ await _publisher.PublishAsync(new GuiderSystemTimeOutBackNotification(orderSnapshot.Id), token);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 根据网格员系统回复的内容同步网格员信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="orderId"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task SyncGuiderInfoAsync(string orderId, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var guiderInfo = await _orderSnapshotRepository.Queryable()
|
|
|
+ .Where(m => m.Id == orderId)
|
|
|
+ .Select(m => new { m.MemberName, m.MemberMobile })
|
|
|
+ .FirstAsync(cancellationToken);
|
|
|
+ var guider = await _guiderInfoRepository.GetByPhoneNumberAsync(guiderInfo.MemberMobile);
|
|
|
+ if (guider != null) return;
|
|
|
+
|
|
|
+ var entity = new GuiderInfo
|
|
|
+ {
|
|
|
+ Name = guiderInfo.MemberName,
|
|
|
+ PhoneNumber = guiderInfo.MemberMobile
|
|
|
+ };
|
|
|
+ entity.Id = await _guiderInfoRepository.AddAsync(entity, cancellationToken);
|
|
|
+ var third = await _thirdAccountRepository.GetByPhoneNumberAsync(guiderInfo.MemberMobile);
|
|
|
+
|
|
|
+ if (third == null) return;
|
|
|
+ third.UserId = entity.Id;
|
|
|
+ third.CitizenType = EReadPackUserType.Guider;
|
|
|
+ await _thirdAccountRepository.UpdateAsync(third, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
#region 从业人员
|
|
|
|
|
|
/// <summary>
|
|
@@ -552,7 +680,7 @@ public abstract class SnapshotApplicationBase
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
/// <returns></returns>
|
|
|
public async Task<PractitionerDetailOutDto> GetPractitionerDetailAsync(string id, CancellationToken cancellationToken)
|
|
|
- {
|
|
|
+ {
|
|
|
var item = await _practitionerRepository.GetAsync(id, cancellationToken)
|
|
|
?? throw UserFriendlyException.SameMessage("从业人员不存在");
|
|
|
return item.Adapt<PractitionerDetailOutDto>();
|
|
@@ -584,8 +712,10 @@ public abstract class SnapshotApplicationBase
|
|
|
entity.VolunteerPhone = volunteer.PhoneNumber;
|
|
|
|
|
|
entity.Id = await _volunteerReportRepository.AddAsync(entity, requestAborted);
|
|
|
- await _fileRepository.AddFileAsync(dto.Files, entity.Id , requestAborted);
|
|
|
+ await _fileRepository.AddFileAsync(dto.Files, entity.Id, requestAborted);
|
|
|
return entity.Adapt<AddVolunteerReportOutDto>();
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+
|
|
|
}
|