|
@@ -1,9 +1,12 @@
|
|
using Hotline.Caching.Interfaces;
|
|
using Hotline.Caching.Interfaces;
|
|
using Hotline.CallCenter.Tels;
|
|
using Hotline.CallCenter.Tels;
|
|
|
|
+using Hotline.Share.Dtos.CallCenter;
|
|
using Hotline.Share.Dtos.TrCallCenter;
|
|
using Hotline.Share.Dtos.TrCallCenter;
|
|
|
|
+using Hotline.Share.Enums.CallCenter;
|
|
using Hotline.Users;
|
|
using Hotline.Users;
|
|
using Tr.Sdk;
|
|
using Tr.Sdk;
|
|
using XF.Domain.Authentications;
|
|
using XF.Domain.Authentications;
|
|
|
|
+using XF.Domain.Cache;
|
|
using XF.Domain.Constants;
|
|
using XF.Domain.Constants;
|
|
using XF.Domain.Dependency;
|
|
using XF.Domain.Dependency;
|
|
using XF.Domain.Exceptions;
|
|
using XF.Domain.Exceptions;
|
|
@@ -19,7 +22,9 @@ namespace Hotline.Application.CallCenter.Calls
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
private readonly ITelRestRepository _telRestRepository;
|
|
private readonly ITelRestRepository _telRestRepository;
|
|
- public TrApplication(ITrClient trClient, ISessionContext sessionContext,IWorkRepository workRepository,ISystemSettingCacheManager systemSettingCacheManager,IUserCacheManager userCacheManager, ITelRestRepository telRestRepository)
|
|
|
|
|
|
+ private readonly ITypedCache<Work> _cacheWork;
|
|
|
|
+
|
|
|
|
+ public TrApplication(ITrClient trClient, ISessionContext sessionContext,IWorkRepository workRepository,ISystemSettingCacheManager systemSettingCacheManager,IUserCacheManager userCacheManager, ITelRestRepository telRestRepository, ITypedCache<Work> cacheWork)
|
|
{
|
|
{
|
|
_trClient = trClient;
|
|
_trClient = trClient;
|
|
_sessionContext = sessionContext;
|
|
_sessionContext = sessionContext;
|
|
@@ -27,6 +32,7 @@ namespace Hotline.Application.CallCenter.Calls
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
_userCacheManager = userCacheManager;
|
|
_userCacheManager = userCacheManager;
|
|
_telRestRepository = telRestRepository;
|
|
_telRestRepository = telRestRepository;
|
|
|
|
+ _cacheWork = cacheWork;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -42,12 +48,7 @@ namespace Hotline.Application.CallCenter.Calls
|
|
if (work is not null)
|
|
if (work is not null)
|
|
{
|
|
{
|
|
|
|
|
|
- if (work.TelNo == telNo)
|
|
|
|
- {
|
|
|
|
- bool isRest = await _telRestRepository.AnyAsync(x => x.TelNo == telNo && x.UserId == userId && !x.EndTime.HasValue);
|
|
|
|
- return new TrOnDutyResponseDto() { TelNo = work.TelNo, TelPwd = work.TelPwd, Description = work.Description, QueueId = work.QueueId,StartTime = work.StartTime, IsRest= isRest };
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ if (work.TelNo != telNo)
|
|
{
|
|
{
|
|
throw UserFriendlyException.SameMessage("当前用户已签入其他分机");
|
|
throw UserFriendlyException.SameMessage("当前用户已签入其他分机");
|
|
}
|
|
}
|
|
@@ -62,7 +63,7 @@ namespace Hotline.Application.CallCenter.Calls
|
|
var telModel = await _trClient.QueryTelsAsync(new Tr.Sdk.Tels.QueryTelRequest() { TelNo = telNo }, cancellationToken);
|
|
var telModel = await _trClient.QueryTelsAsync(new Tr.Sdk.Tels.QueryTelRequest() { TelNo = telNo }, cancellationToken);
|
|
if (telModel !=null && telModel.Count>0)
|
|
if (telModel !=null && telModel.Count>0)
|
|
{
|
|
{
|
|
- work = new Work(_sessionContext.UserId, _sessionContext.UserName, telModel[0].Id, telNo, telModel[0].Password, telModel[0].Description, telModel[0].QueueId,_sessionContext.StaffNo);
|
|
|
|
|
|
+ work = new Work(_sessionContext.UserId, _sessionContext.UserName, telModel[0].Id, telNo, telModel[0].Password, telModel[0].Description, telModel[0].QueueId,_sessionContext.StaffNo, ETelModel.OrdinaryModel);
|
|
await _workRepository.AddAsync(work, cancellationToken);
|
|
await _workRepository.AddAsync(work, cancellationToken);
|
|
bool IsTelNeedVerify = bool.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.IsTelNeedVerify).SettingValue[0]);
|
|
bool IsTelNeedVerify = bool.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.IsTelNeedVerify).SettingValue[0]);
|
|
if (IsTelNeedVerify)
|
|
if (IsTelNeedVerify)
|
|
@@ -76,5 +77,72 @@ namespace Hotline.Application.CallCenter.Calls
|
|
}
|
|
}
|
|
throw UserFriendlyException.SameMessage("签入异常,未查询到对应分机信息");
|
|
throw UserFriendlyException.SameMessage("签入异常,未查询到对应分机信息");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 查询当前用户的分机状态
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="userId"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public async Task<TrOnDutyResponseDto> TelState(string userId)
|
|
|
|
+ {
|
|
|
|
+ var work = _userCacheManager.GetWorkByUserNoExp(userId);
|
|
|
|
+ if (work is not null)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ bool isRest = await _telRestRepository.AnyAsync(x => x.TelNo == work.TelNo && x.UserId == userId && !x.EndTime.HasValue);
|
|
|
|
+ bool IsTelNeedVerify = bool.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.IsTelNeedVerify).SettingValue[0]);
|
|
|
|
+ if (IsTelNeedVerify)
|
|
|
|
+ {
|
|
|
|
+ return new TrOnDutyResponseDto() { TelNo = work.TelNo, TelPwd = "", Description = work.Description, QueueId = work.QueueId, StartTime = work.StartTime, IsRest = isRest, TelModel = work.TelModel };
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return new TrOnDutyResponseDto() { TelNo = work.TelNo, TelPwd = work.TelPwd, Description = work.Description, QueueId = work.QueueId, StartTime = work.StartTime, IsRest = isRest, TelModel = work.TelModel };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 切换状态
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="userId"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public async Task ChangeTelModel(string userId,bool isCallOut)
|
|
|
|
+ {
|
|
|
|
+ var work = _userCacheManager.GetWorkByUserNoExp(userId);
|
|
|
|
+ if (work!=null)
|
|
|
|
+ {
|
|
|
|
+ if (isCallOut)
|
|
|
|
+ {
|
|
|
|
+ //切换外呼模式
|
|
|
|
+ if (work.TelModel== ETelModel.CallOutModel)
|
|
|
|
+ {
|
|
|
|
+ throw UserFriendlyException.SameMessage("已是外呼模式,无需切换");
|
|
|
|
+ }
|
|
|
|
+ work.TelModel = ETelModel.CallOutModel;
|
|
|
|
+ await _workRepository.UpdateAsync(work);
|
|
|
|
+ _cacheWork.Remove(work.GetKey(KeyMode.UserId));
|
|
|
|
+ _cacheWork.Remove(work.GetKey(KeyMode.TelNo));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //切换普通模式
|
|
|
|
+ if (work.TelModel == ETelModel.OrdinaryModel)
|
|
|
|
+ {
|
|
|
|
+ throw UserFriendlyException.SameMessage("已是普通模式,无需切换");
|
|
|
|
+ }
|
|
|
|
+ work.TelModel = ETelModel.OrdinaryModel;
|
|
|
|
+ await _workRepository.UpdateAsync(work);
|
|
|
|
+ }
|
|
|
|
+ _cacheWork.Remove(work.GetKey(KeyMode.UserId));
|
|
|
|
+ _cacheWork.Remove(work.GetKey(KeyMode.TelNo));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ throw UserFriendlyException.SameMessage("当前用户没有签入,不能切换状态");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|