|
@@ -43,6 +43,7 @@ using Hotline.Repository.SqlSugar.CallCenter;
|
|
|
using SqlSugar;
|
|
|
using Hotline.Tools;
|
|
|
using Hotline.Api.Filter;
|
|
|
+using XF.Domain.Cache;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
|
{
|
|
@@ -69,7 +70,7 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IRepository<QualityTemplate> _qualityTemplate;
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
private readonly IRepository<TelActionRecord> _telActionRecordRepository;
|
|
|
-
|
|
|
+ private readonly ITypedCache<Work> _cacheWork;
|
|
|
private readonly ISystemMobilAreaApplication _systemMobilAreaApplication;
|
|
|
private readonly IRepository<Work> _workRepository;
|
|
|
private readonly Publisher _publisher;
|
|
@@ -85,7 +86,7 @@ namespace Hotline.Api.Controllers
|
|
|
ITelApplication telApplication, IRepository<Quality.Quality> qualiteyRepository,
|
|
|
IAiQualityService aiQualityService, IRepository<QualityTemplate> qualityTemplate,
|
|
|
ISystemSettingCacheManager systemSettingCacheManager, IRepository<TelActionRecord> telActionRecordRepository,
|
|
|
- ISystemMobilAreaApplication systemMobilAreaApplication, IRepository<Work> workRepository, Publisher publisher, ITrCallRecordRepository callRecordRepository)
|
|
|
+ ISystemMobilAreaApplication systemMobilAreaApplication, IRepository<Work> workRepository, Publisher publisher, ITrCallRecordRepository callRecordRepository, ITypedCache<Work> cacheWork)
|
|
|
{
|
|
|
_trClient = trClient;
|
|
|
_mapper = mapper;
|
|
@@ -112,6 +113,7 @@ namespace Hotline.Api.Controllers
|
|
|
_workRepository = workRepository;
|
|
|
_publisher = publisher;
|
|
|
_callRecordRepository = callRecordRepository;
|
|
|
+ _cacheWork = cacheWork;
|
|
|
}
|
|
|
|
|
|
#region 添添呼
|
|
@@ -885,6 +887,56 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region 话机状态
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 重置话机状态
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("tels-status-refreshservice")]
|
|
|
+ [AllowAnonymous]
|
|
|
+ public async Task TelsStatusRefreshService()
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var list = await _workRepository.Queryable().Where(x => 1 == 1 && !x.EndTime.HasValue).ToListAsync();
|
|
|
+ var tellist = await _trClient.QueryTelStateAsync(new Tr.Sdk.Tels.QueryTelStateRequest { },HttpContext.RequestAborted);
|
|
|
+ foreach (var item in list)
|
|
|
+ {
|
|
|
+ var telmodel = tellist.AgentList.First(x => x.TelNo == item.TelNo);
|
|
|
+ if (telmodel != null)
|
|
|
+ {
|
|
|
+ if (telmodel.State == "logout")
|
|
|
+ {
|
|
|
+ var telRest = await _telRestRepository.GetAsync(x => x.TelNo == item.TelNo && !x.EndTime.HasValue, HttpContext.RequestAborted);
|
|
|
+ if (telRest is not null)
|
|
|
+ {
|
|
|
+ telRest.EndRest();
|
|
|
+ await _telRestRepository.UpdateAsync(telRest, HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+
|
|
|
+ item.OffDuty();
|
|
|
+ await _workRepository.UpdateAsync(item, HttpContext.RequestAborted);
|
|
|
+ _cacheWork.Remove(item.GetKey(KeyMode.UserId));
|
|
|
+ _cacheWork.Remove(item.GetKey(KeyMode.TelNo));
|
|
|
+ var listx = await _telActionRecordRepository.Queryable().Where(x => x.TelNo == item.TelNo && !x.EndTime.HasValue).ToListAsync();
|
|
|
+ foreach (var itemx in listx)
|
|
|
+ {
|
|
|
+ itemx.EndAction();
|
|
|
+ await _telActionRecordRepository.UpdateAsync(itemx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|