GuiderSystemTimeoutHandler.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Hotline.Caching.Interfaces;
  2. using Hotline.Settings;
  3. using Hotline.Share.Tools;
  4. using Hotline.Snapshot.Notifications;
  5. using MediatR;
  6. namespace Hotline.Application.OrderApp.Handlers.SnapshotHandler
  7. {
  8. /// <summary>
  9. /// 需求:坐席派给网格员的安全隐患工单若未推送成功超过4小时或者网格员超过4小时没回复,则自动流转到标注节点待标注列表
  10. /// </summary>
  11. public class GuiderSystemTimeoutHandler : INotificationHandler<GuiderSystemTimeOutBackNotification>
  12. {
  13. private readonly ISystemSettingCacheManager _systemSettingCacheManager;
  14. private readonly IOrderApplication _orderApplication;
  15. private readonly ISystemLogRepository _systemLogRepository;
  16. public GuiderSystemTimeoutHandler(
  17. ISystemSettingCacheManager systemSettingCacheManager,
  18. IOrderApplication orderApplication
  19. ,
  20. ISystemLogRepository systemLogRepository)
  21. {
  22. _systemSettingCacheManager = systemSettingCacheManager;
  23. _orderApplication = orderApplication;
  24. _systemLogRepository = systemLogRepository;
  25. }
  26. /// <summary>Handles a notification</summary>
  27. /// <param name="notification">The notification</param>
  28. /// <param name="cancellationToken">Cancellation token</param>
  29. public async Task Handle(GuiderSystemTimeOutBackNotification notification, CancellationToken cancellationToken)
  30. {
  31. try
  32. {
  33. if (_systemSettingCacheManager.Snapshot)
  34. {
  35. await _orderApplication.HandleFromWanggeyuanToMaskAsync(notification.OrderId, "超时4小时12345自动退回。", cancellationToken);
  36. }
  37. }
  38. catch (Exception e)
  39. {
  40. _systemLogRepository.Add("网格员超时未回复", notification.OrderId, "方法异常", status: 0, executeResult: e.ToJson());
  41. throw;
  42. }
  43. _systemLogRepository.Add("网格员超时未回复", notification.OrderId, "收到事件", "", 1);
  44. }
  45. }
  46. }