admin 2 年 前
コミット
9cfd510b00

+ 14 - 1
src/CallCenter.Application/Handlers/FlowControl/AnswerViisitorToExtNotificationHandler.cs

@@ -4,6 +4,8 @@ using CallCenter.Notifications;
 using CallCenter.Realtimes;
 using CallCenter.Share.Enums;
 using MediatR;
+using Microsoft.Extensions.Logging;
+using System.Text.Json;
 
 namespace CallCenter.Application.Handlers
 {
@@ -13,14 +15,18 @@ namespace CallCenter.Application.Handlers
         private readonly ICallDetailRepository _callDetailRepository;
         private readonly IUserCacheManager _userCacheManager;
         private readonly IRealtimeService _realtimeService;
+        private readonly ICallCacheManager _callCacheManager;
+        private readonly ILogger<AnsweredVisitorToExtNotificationHandler> _logger;
 
 
-        public AnswerViisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService)
+        public AnswerViisitorToExtNotificationHandler(ICallRepository callRepository, ICallDetailRepository callDetailRepository,IUserCacheManager userCacheManager, IRealtimeService realtimeService, ICallCacheManager callCacheManager,ILogger<AnsweredVisitorToExtNotificationHandler> logger)
         {
             _callRepository = callRepository;
             _callDetailRepository = callDetailRepository;
             _realtimeService = realtimeService;
             _userCacheManager = userCacheManager;
+            _callCacheManager = callCacheManager;
+            _logger = logger;
         }
 
         public async Task Handle(AnswerViisitorToExtNotification notification, CancellationToken cancellationToken)
@@ -45,6 +51,13 @@ namespace CallCenter.Application.Handlers
                 };
                 await _callDetailRepository.AddAsync(detail, cancellationToken);
 
+
+                //处理排队缓存数据 TODO
+                _callCacheManager.RemoveCallCache(model.Id);
+                _logger.LogInformation(JsonSerializer.Serialize(_callCacheManager.GetCallQueueList()));
+                await _realtimeService.CallQueueAsync(_callCacheManager.GetCallQueueList(), cancellationToken);
+
+
                 //调用业务通知 通知前端
                 var workModel = _userCacheManager.GetWorkByTel(notification.TelNo);
                 if (workModel != null)