|
@@ -21,6 +21,7 @@ using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Users;
|
|
|
using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.Extensions.Logging;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Cache;
|
|
|
using XF.Domain.Exceptions;
|
|
@@ -28,7 +29,7 @@ using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Application.CallCenter
|
|
|
{
|
|
|
- public class XingTangCallApplication : DefaultCallApplication, ICallApplication
|
|
|
+ public class XingTangCallApplication : ICallApplication
|
|
|
{
|
|
|
private readonly IRepository<Tel> _telRepository;
|
|
|
private readonly IRepository<TelGroup> _telGroupRepository;
|
|
@@ -36,10 +37,12 @@ namespace Hotline.Application.CallCenter
|
|
|
private readonly ITelRestRepository _telRestRepository;
|
|
|
private readonly IRepository<CallNative> _callNativeRepository;
|
|
|
private readonly IRepository<TelOperation> _teloperationRepository;
|
|
|
+ private readonly IRepository<CallidRelation> _callidRelationRepository;
|
|
|
private readonly ITypedCache<Work> _cacheWork;
|
|
|
private readonly IUserCacheManager _userCacheManager;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
private readonly IMapper _mapper;
|
|
|
+ private readonly ILogger<XingTangCallApplication> _logger;
|
|
|
|
|
|
public XingTangCallApplication(
|
|
|
IRepository<Tel> telRepository,
|
|
@@ -48,10 +51,12 @@ namespace Hotline.Application.CallCenter
|
|
|
ITelRestRepository telRestRepository,
|
|
|
IRepository<CallNative> callNativeRepository,
|
|
|
IRepository<TelOperation> teloperationRepository,
|
|
|
+ IRepository<CallidRelation> callidRelationRepository,
|
|
|
ITypedCache<Work> cacheWork,
|
|
|
IUserCacheManager userCacheManager,
|
|
|
ISessionContext sessionContext,
|
|
|
- IMapper mapper)
|
|
|
+ IMapper mapper,
|
|
|
+ ILogger<XingTangCallApplication> logger)
|
|
|
{
|
|
|
_telRepository = telRepository;
|
|
|
_telGroupRepository = telGroupRepository;
|
|
@@ -59,10 +64,12 @@ namespace Hotline.Application.CallCenter
|
|
|
_telRestRepository = telRestRepository;
|
|
|
_callNativeRepository = callNativeRepository;
|
|
|
_teloperationRepository = teloperationRepository;
|
|
|
+ _callidRelationRepository = callidRelationRepository;
|
|
|
_cacheWork = cacheWork;
|
|
|
_userCacheManager = userCacheManager;
|
|
|
_sessionContext = sessionContext;
|
|
|
_mapper = mapper;
|
|
|
+ _logger = logger;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -230,6 +237,31 @@ namespace Hotline.Application.CallCenter
|
|
|
.WhereIF(dto.OperateState != null, d => d.OperateState == dto.OperateState)
|
|
|
.ToFixedListAsync(dto, cancellationToken);
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 依据通话记录编号获取映射后的callId
|
|
|
+ /// </summary>
|
|
|
+ public async Task<string> GetOrSetCallIdAsync(string callNo, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ var callOrder = await _callidRelationRepository.GetAsync(callNo, cancellationToken);
|
|
|
+ if (callOrder == null)
|
|
|
+ {
|
|
|
+ callOrder = new CallidRelation
|
|
|
+ {
|
|
|
+ Id = callNo,
|
|
|
+ CallId = Ulid.NewUlid().ToString(),
|
|
|
+ };
|
|
|
+ try
|
|
|
+ {
|
|
|
+ await _callidRelationRepository.AddAsync(callOrder, cancellationToken);
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ _logger.LogError($"写入callidRelation失败:{e.Message}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return callOrder.CallId;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|