|
@@ -1,4 +1,5 @@
|
|
|
using DotNetCore.CAP;
|
|
|
+using Hotline.CallCenter.Tels.CallTelDomain;
|
|
|
using ExtendedNumerics.Exceptions;
|
|
|
using Hotline.Ai.Quality;
|
|
|
using Hotline.Application.CallCenter.Calls;
|
|
@@ -27,9 +28,6 @@ using Microsoft.Extensions.Options;
|
|
|
using Newtonsoft.Json;
|
|
|
using System.Threading;
|
|
|
using Hotline.EventBus;
|
|
|
-using Tr.Sdk;
|
|
|
-using Tr.Sdk.Blacklist;
|
|
|
-using Tr.Sdk.Tels;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Exceptions;
|
|
|
using XF.Domain.Filters;
|
|
@@ -44,17 +42,17 @@ using SqlSugar;
|
|
|
using Hotline.Tools;
|
|
|
using Hotline.Api.Filter;
|
|
|
using XF.Domain.Cache;
|
|
|
+using Hotline.Application.CallCenter;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
public class IPPbxController : BaseController
|
|
|
{
|
|
|
- private readonly ITrClient _trClient;
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly IUserDomainService _userDomainService;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly IRepository<TrCallRecord> _trCallRecordRepository;
|
|
|
- private readonly ITrApplication _trApplication;
|
|
|
+ private readonly ICallApplication _callApplication;
|
|
|
private readonly IRepository<TrCallEvaluate> _trCallEvaluate;
|
|
|
private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
|
|
|
private readonly ILogger<IPPbxController> _logger;
|
|
@@ -75,10 +73,12 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IRepository<Work> _workRepository;
|
|
|
private readonly Publisher _publisher;
|
|
|
private readonly ITrCallRecordRepository _callRecordRepository;
|
|
|
+ private readonly IIPPbxApplication _iPPbxApplication;
|
|
|
+ private readonly ICallTelClient _callTelClient;
|
|
|
|
|
|
- public IPPbxController(ITrClient trClient, IMapper mapper, IUserDomainService userDomainService,
|
|
|
+ public IPPbxController(IMapper mapper, IUserDomainService userDomainService,
|
|
|
ISessionContext sessionContext, IRepository<TrCallRecord> trCallRecordRepository,
|
|
|
- ITrApplication trApplication, IRepository<TrCallEvaluate> trCallRecord,
|
|
|
+ ICallApplication callApplication, IRepository<TrCallEvaluate> trCallRecord,
|
|
|
ISystemDicDataCacheManager systemDicDataCacheManager, ILogger<IPPbxController> logger,
|
|
|
IOrderRepository orderRepository, IRepository<OrderVisit> orderVisitRepository,
|
|
|
IUserCacheManager userCacheManager, ICapPublisher capPublisher,
|
|
@@ -86,14 +86,13 @@ 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, ITypedCache<Work> cacheWork)
|
|
|
+ ISystemMobilAreaApplication systemMobilAreaApplication, IRepository<Work> workRepository, Publisher publisher, ITrCallRecordRepository callRecordRepository, ITypedCache<Work> cacheWork, IIPPbxApplication iPPbxApplication, ICallTelClient callTelClient)
|
|
|
{
|
|
|
- _trClient = trClient;
|
|
|
_mapper = mapper;
|
|
|
_userDomainService = userDomainService;
|
|
|
_sessionContext = sessionContext;
|
|
|
_trCallRecordRepository = trCallRecordRepository;
|
|
|
- _trApplication = trApplication;
|
|
|
+ _callApplication = callApplication;
|
|
|
_trCallEvaluate = trCallRecord;
|
|
|
_systemDicDataCacheManager = systemDicDataCacheManager;
|
|
|
_logger = logger;
|
|
@@ -114,6 +113,8 @@ namespace Hotline.Api.Controllers
|
|
|
_publisher = publisher;
|
|
|
_callRecordRepository = callRecordRepository;
|
|
|
_cacheWork = cacheWork;
|
|
|
+ _iPPbxApplication = iPPbxApplication;
|
|
|
+ _callTelClient = callTelClient;
|
|
|
}
|
|
|
|
|
|
#region 添添呼
|
|
@@ -126,7 +127,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpGet("query-tels")]
|
|
|
public async Task<List<TrTelDto>> TrQueryTels()
|
|
|
{
|
|
|
- var tels = await _trClient.QueryTelsAsync(new QueryTelRequest() { }, HttpContext.RequestAborted);
|
|
|
+ var tels = await _callTelClient.QueryTelsAsync(new QueryTelRequest() { }, HttpContext.RequestAborted);
|
|
|
var listenTels = _systemSettingCacheManager.GetSetting(SettingConstants.ListenTels)?.SettingValue;
|
|
|
tels = tels.Where(m => listenTels.Contains(m.TelNo) == false).ToList();
|
|
|
var returnlist = _mapper.Map<List<TrTelDto>>(tels);
|
|
@@ -147,7 +148,7 @@ namespace Hotline.Api.Controllers
|
|
|
[AllowAnonymous]
|
|
|
public async Task<IReadOnlyList<TrTelStateDto>> TrQueryTelState([FromQuery] string? state, bool hasListen)
|
|
|
{
|
|
|
- var tels = await _trClient.QueryTelStateAsync(new QueryTelStateRequest() { State = state }, HttpContext.RequestAborted);
|
|
|
+ var tels = await _callTelClient.QueryTelStateAsync(new QueryTelStateRequest() { State = state }, HttpContext.RequestAborted);
|
|
|
var listenTels = _systemSettingCacheManager.GetSetting(SettingConstants.ListenTels)?.SettingValue;
|
|
|
var workList = await _workRepository.Queryable().Where(d=> 1 == 1 && !d.EndTime.HasValue).ToListAsync();
|
|
|
var query = from tel in tels.AgentList
|
|
@@ -194,7 +195,7 @@ namespace Hotline.Api.Controllers
|
|
|
[AllowAnonymous]
|
|
|
public async Task<TrTelStateDto> TrQueryTelStateByTelNo([FromQuery]string? telno)
|
|
|
{
|
|
|
- var tels = await _trClient.QueryTelStateAsync(new QueryTelStateRequest() { TelNo = telno }, HttpContext.RequestAborted);
|
|
|
+ var tels = await _callTelClient.QueryTelStateAsync(new QueryTelStateRequest() { TelNo = telno }, HttpContext.RequestAborted);
|
|
|
|
|
|
var listenTels = _systemSettingCacheManager.GetSetting(SettingConstants.ListenTels)?.SettingValue;
|
|
|
tels.Agents = tels.Agents?.Where(m => listenTels.Contains(m.TelNo) == false).ToList();
|
|
@@ -249,7 +250,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPost("add-blacklist")]
|
|
|
public async Task AddBlacklist([FromBody] TrAddBlacklistDto dto)
|
|
|
{
|
|
|
- await _trClient.AddBlacklistAsync(new AddBlacklistRequest() { Phone = dto.Phone, SpecialFlag = dto.SpecialFlag }, HttpContext.RequestAborted);
|
|
|
+ await _callTelClient.AddBlacklistAsync(new AddBlacklistRequest() { Phone = dto.Phone, SpecialFlag = dto.SpecialFlag }, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -261,7 +262,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPost("remove-blacklist")]
|
|
|
public async Task DelBlacklist([FromBody] TrDelBlacklistDto dto)
|
|
|
{
|
|
|
- await _trClient.DelBlacklistAsync(new DelBlacklistRequest() { Phone = dto.Phone, SpecialFlag = dto.SpecialFlag }, HttpContext.RequestAborted);
|
|
|
+ await _callTelClient.DelBlacklistAsync(new DelBlacklistRequest() { Phone = dto.Phone, SpecialFlag = dto.SpecialFlag }, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -271,7 +272,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpGet("query-blacklist")]
|
|
|
public async Task<IReadOnlyList<TrQueryBlacklistResponseDto>> QueryBlacklist([FromQuery] TrQueryBlacklistDto dto)
|
|
|
{
|
|
|
- var blacklist = await _trClient.QueryBlacklistAsync(new QueryBlacklistRequest() { Phone = dto.Phone, SpecialFlag = dto.SpecialFlag }, HttpContext.RequestAborted);
|
|
|
+ var blacklist = await _callTelClient.QueryBlacklistAsync(new QueryBlacklistRequest() { Phone = dto.Phone, SpecialFlag = dto.SpecialFlag }, HttpContext.RequestAborted);
|
|
|
return _mapper.Map<IReadOnlyList<TrQueryBlacklistResponseDto>>(blacklist);
|
|
|
}
|
|
|
|
|
@@ -287,8 +288,7 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPost("on-duty")]
|
|
|
public async Task<TrOnDutyResponseDto> OnDuty([FromBody] TrOnDutyDto dto)
|
|
|
{
|
|
|
- //return await _userDomainService.TrOnDutyAsync(_sessionContext.RequiredUserId,dto.TelNo, HttpContext.RequestAborted);
|
|
|
- return await _trApplication.OnSign(_sessionContext.RequiredUserId, dto.TelNo,(ETelModel)dto.TelModelState, HttpContext.RequestAborted);
|
|
|
+ return await _callApplication.SignInAsync(new SignInDto() { TelNo = dto.TelNo, TelModelState = dto.TelModelState}, HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -309,10 +309,9 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpGet("tel-state")]
|
|
|
public async Task<TrOnDutyResponseDto> TelState()
|
|
|
{
|
|
|
- return await _trApplication.TelState(_sessionContext.RequiredUserId,HttpContext.RequestAborted);
|
|
|
+ return await _callApplication.GetTelStateAsync(HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 切换状态
|
|
|
/// </summary>
|
|
@@ -322,11 +321,9 @@ namespace Hotline.Api.Controllers
|
|
|
[HttpPost("change-telmodel")]
|
|
|
public async Task ChangeTelModel([FromBody] ChangeTelModelDto dto)
|
|
|
{
|
|
|
- await _trApplication.ChangeTelModel(_sessionContext.RequiredUserId, dto.isCallOut,HttpContext.RequestAborted);
|
|
|
+ await _callApplication.ChangeTelModel(dto.isCallOut,HttpContext.RequestAborted);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 下班-管理手动操作
|
|
|
/// </summary>
|
|
@@ -900,7 +897,7 @@ namespace Hotline.Api.Controllers
|
|
|
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);
|
|
|
+ var tellist = await _callTelClient.QueryTelStateAsync(new QueryTelStateRequest { },HttpContext.RequestAborted);
|
|
|
foreach (var item in list)
|
|
|
{
|
|
|
var telmodel = tellist.AgentList.First(x => x.TelNo == item.TelNo);
|
|
@@ -908,23 +905,24 @@ namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
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);
|
|
|
- }
|
|
|
+ await _iPPbxApplication.ResetTelStatus(item.Id,null, HttpContext.RequestAborted);
|
|
|
+ //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);
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
}
|