|
@@ -1,10 +1,13 @@
|
|
|
using Hotline.Api.Realtimes;
|
|
|
using Hotline.Application.Jobs;
|
|
|
+using Hotline.Caching.Interfaces;
|
|
|
using Hotline.CallCenter.Calls;
|
|
|
using Hotline.Orders;
|
|
|
using Hotline.Realtimes;
|
|
|
+using Hotline.Settings;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using Tr.Sdk;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
@@ -14,10 +17,16 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IOrderDomainService _orderDomainService;
|
|
|
private readonly IRepository<TrCallRecord> _trcallrecordRepoository;
|
|
|
private readonly IRealtimeService _realtimeService;
|
|
|
+ private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
+ private readonly ITrClient _trClient;
|
|
|
|
|
|
- public CorsJobController(IOrderDomainService orderDomainService)
|
|
|
+ public CorsJobController(IOrderDomainService orderDomainService, IRepository<TrCallRecord> trcallrecordRepoository, IRealtimeService realtimeService, ISystemSettingCacheManager systemSettingCacheManager, ITrClient trClient)
|
|
|
{
|
|
|
_orderDomainService = orderDomainService;
|
|
|
+ _trcallrecordRepoository = trcallrecordRepoository;
|
|
|
+ _realtimeService = realtimeService;
|
|
|
+ _systemSettingCacheManager = systemSettingCacheManager;
|
|
|
+ _trClient = trClient;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -50,5 +59,28 @@ namespace Hotline.Api.Controllers
|
|
|
}
|
|
|
catch { }
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 推送当前排队数(5秒一次)
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("send-currentwaitnum")]
|
|
|
+ [AllowAnonymous]
|
|
|
+ public async Task SendCurrentWaitNum()
|
|
|
+ {
|
|
|
+ var callinQueueIds = _systemSettingCacheManager.GetSetting(SettingConstants.CallInQueueId)?.SettingValue.ToList();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ int count = 0;
|
|
|
+ foreach (var id in callinQueueIds)
|
|
|
+ {
|
|
|
+ var rsp = await _trClient.QueryQueueWaitNumAsync(new Tr.Sdk.Tels.QueryQueueWaitNumRequest() { QueueId = id }, HttpContext.RequestAborted);
|
|
|
+ count += Convert.ToInt32(rsp.Count);
|
|
|
+ }
|
|
|
+
|
|
|
+ await _realtimeService.CurrentWaitNumAsync(count, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ catch { }
|
|
|
+ }
|
|
|
}
|
|
|
}
|