Ver código fonte

DefaultCallApplication

xfe 9 meses atrás
pai
commit
eecd8d243d

+ 348 - 1
src/Hotline.Application/CallCenter/DefaultCallApplication.cs

@@ -1 +1,348 @@
-pub
+using Hotline.Caching.Interfaces;
+using Hotline.CallCenter.BlackLists;
+using Hotline.CallCenter.Calls;
+using Hotline.CallCenter.Tels;
+using Hotline.Orders;
+using Hotline.Repository.SqlSugar.Extensions;
+using Hotline.Share.Dtos.CallCenter;
+using Hotline.Share.Dtos.TrCallCenter;
+using Hotline.Share.Enums.CallCenter;
+using Hotline.Users;
+using MapsterMapper;
+using Microsoft.Extensions.Logging;
+using XF.Domain.Authentications;
+using XF.Domain.Cache;
+using XF.Domain.Exceptions;
+using XF.Domain.Repository;
+
+namespace Hotline.Application.CallCenter;
+
+public abstract class DefaultCallApplication : ICallApplication
+{
+    private readonly IRepository<Tel> _telRepository;
+    private readonly IRepository<TelGroup> _telGroupRepository;
+    private readonly IWorkRepository _workRepository;
+    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<DefaultCallApplication> _logger;
+
+    public DefaultCallApplication(
+        IRepository<Tel> telRepository,
+        IRepository<TelGroup> telGroupRepository,
+        IWorkRepository workRepository,
+        ITelRestRepository telRestRepository,
+        IRepository<CallNative> callNativeRepository,
+        IRepository<TelOperation> telOperationRepository,
+        IRepository<CallidRelation> callIdRelationRepository,
+        ITypedCache<Work> cacheWork,
+        IUserCacheManager userCacheManager,
+        ISessionContext sessionContext,
+        IMapper mapper,
+        ILogger<DefaultCallApplication> logger)
+    {
+        _telRepository = telRepository;
+        _telGroupRepository = telGroupRepository;
+        _workRepository = workRepository;
+        _telRestRepository = telRestRepository;
+        _callNativeRepository = callNativeRepository;
+        _telOperationRepository = telOperationRepository;
+        _callIdRelationRepository = callIdRelationRepository;
+        _cacheWork = cacheWork;
+        _userCacheManager = userCacheManager;
+        _sessionContext = sessionContext;
+        _mapper = mapper;
+        _logger = logger;
+    }
+
+    public DefaultCallApplication() { }
+
+    /// <summary>
+    /// 查询分机
+    /// </summary>
+    public async Task<IReadOnlyList<TelDto>> QueryTelsAsync(CancellationToken cancellationToken)
+    {
+        return await _telRepository.Queryable()
+            .Select<TelDto>()
+            .ToListAsync(cancellationToken);
+    }
+
+    /// <summary>
+    /// 查询分机组
+    /// </summary>
+    public async Task<IReadOnlyList<TelGroupDto>> QueryTelGroupsAsync(CancellationToken cancellationToken)
+    {
+        return await _telGroupRepository.Queryable()
+            .Select<TelGroupDto>()
+            .ToListAsync(cancellationToken);
+    }
+
+    /// <summary>
+    /// 新增黑名单
+    /// </summary>
+    public abstract Task<string> AddBlackListAsync(AddBlacklistDto dto, CancellationToken cancellationToken);
+
+    /// <summary>
+    /// 删除黑名单
+    /// </summary>
+    public abstract Task RemoveBlackListAsync(string id, CancellationToken cancellationToken);
+
+    /// <summary>
+    /// 查询黑名单
+    /// </summary>
+    public abstract Task<List<Blacklist>> QueryBlackListsAsync(CancellationToken cancellationToken);
+
+    /// <summary>
+    /// 签入
+    /// </summary>
+    public async Task<TrOnDutyResponseDto> SignInAsync(SignInDto dto, CancellationToken cancellationToken)
+    {
+        if (string.IsNullOrEmpty(dto.TelNo))
+            throw UserFriendlyException.SameMessage("无效分机号");
+        var work = _userCacheManager.GetWorkByUserNoExp(_sessionContext.RequiredUserId);
+        if (work is not null)
+        {
+            //if (work.TelNo != dto.TelNo)
+            //{
+            //    throw UserFriendlyException.SameMessage("当前用户已签入其他分机");
+            //}
+            throw UserFriendlyException.SameMessage("当前用户已签入");
+        }
+
+        var telWork = _userCacheManager.GetWorkByTelNoExp(dto.TelNo);
+        if (telWork is not null)
+        {
+            throw UserFriendlyException.SameMessage("当前分机已被占用");
+        }
+
+        work = new Work(_sessionContext.RequiredUserId, _sessionContext.UserName,
+            dto.TelNo, dto.TelNo, null, null,
+            dto.GroupId, _sessionContext.StaffNo, null);
+        await _workRepository.AddAsync(work, cancellationToken);
+
+        return new TrOnDutyResponseDto
+        {
+            TelNo = dto.TelNo,
+            QueueId = dto.GroupId,
+            StartTime = work.StartTime,
+        };
+    }
+
+    /// <summary>
+    /// 签出
+    /// </summary>
+    public async Task SingOutAsync(CancellationToken cancellationToken)
+    {
+        var work = _userCacheManager.GetWorkByUserNoExp(_sessionContext.RequiredUserId);
+        if (work is null) return;
+
+        var telRest =
+            await _telRestRepository.GetAsync(x => x.TelNo == work.TelNo && !x.EndTime.HasValue, cancellationToken);
+        if (telRest is not null)
+        {
+            telRest.EndRest();
+            await _telRestRepository.UpdateAsync(telRest, cancellationToken);
+        }
+
+        work.OffDuty();
+        await _workRepository.UpdateAsync(work, cancellationToken);
+        await _cacheWork.RemoveAsync(work.GetKey(KeyMode.UserId), cancellationToken);
+        await _cacheWork.RemoveAsync(work.GetKey(KeyMode.TelNo), cancellationToken);
+    }
+
+    /// <summary>
+    /// 签出
+    /// </summary>
+    public async Task SingOutAsync(string telNo, CancellationToken cancellationToken)
+    {
+        var work = _userCacheManager.GetWorkByTelNoExp(telNo);
+        if (work is null) return;
+
+        var telRest =
+            await _telRestRepository.GetAsync(x => x.TelNo == work.TelNo && !x.EndTime.HasValue, cancellationToken);
+        if (telRest is not null)
+        {
+            telRest.EndRest();
+            await _telRestRepository.UpdateAsync(telRest, cancellationToken);
+        }
+
+        work.OffDuty();
+        await _workRepository.UpdateAsync(work, cancellationToken);
+        await _cacheWork.RemoveAsync(work.GetKey(KeyMode.UserId), cancellationToken);
+        await _cacheWork.RemoveAsync(work.GetKey(KeyMode.TelNo), cancellationToken);
+    }
+
+    /// <summary>
+    /// 查询当前用户的分机状态
+    /// </summary>
+    /// <param name="cancellationToken"></param>
+    /// <returns></returns>
+    public async Task<TrOnDutyResponseDto> GetTelStateAsync(CancellationToken cancellationToken)
+    {
+        var work = _userCacheManager.GetWorkByUserNoExp(_sessionContext.RequiredUserId);
+        if (work is null) return null;
+        return await Task.FromResult(new TrOnDutyResponseDto
+        {
+            TelNo = work.TelNo,
+            QueueId = work.QueueId,
+            StartTime = work.StartTime,
+        });
+    }
+
+    /// <summary>
+    /// 定量查询通话记录
+    /// </summary>
+    public async Task<IReadOnlyList<CallNativeDto>> QueryCallsFixedAsync(QueryCallsFixedDto dto,
+        CancellationToken cancellationToken)
+    {
+        return await _callNativeRepository.Queryable(includeDeleted: true)
+            .LeftJoin<Order>((d, o) => d.CallNo == o.CallId)
+            .WhereIF(!string.IsNullOrEmpty(dto.OrderNo), (d, o) => o.No == dto.OrderNo)
+            .WhereIF(!string.IsNullOrEmpty(dto.FromNo), d => d.FromNo == dto.FromNo)
+            .WhereIF(!string.IsNullOrEmpty(dto.ToNo), d => d.ToNo == dto.ToNo)
+            .WhereIF(!string.IsNullOrEmpty(dto.UserName), d => d.UserName == dto.UserName)
+            .WhereIF(!string.IsNullOrEmpty(dto.TelNo), d => d.TelNo == dto.TelNo)
+            .WhereIF(dto.EndBy != null, d => d.EndBy == dto.EndBy)
+            .WhereIF(dto.CallStartTimeBT != null, d => d.BeginIvrTime >= dto.CallStartTimeBT)
+            .WhereIF(dto.CallStartTimeLT != null, d => d.BeginIvrTime <= dto.CallStartTimeLT)
+            .WhereIF(dto.IsConnected != null, d => d.AnsweredTime != null)
+            .WhereIF(dto.Direction != null, d => d.Direction == dto.Direction)
+            .Select((d, o) => new CallNativeDto
+            {
+                OrderId = o.Id,
+                OrderNo = o.No,
+                Title = o.Title,
+            }, true)
+            .ToFixedListAsync(dto, cancellationToken);
+    }
+
+    /// <summary>
+    /// 查询分机操作记录(定量)
+    /// </summary>
+    public async Task<IReadOnlyList<TelOperation>> QueryTelOperationsAsync(QueryTelOperationsFixedDto dto,
+        CancellationToken cancellationToken)
+    {
+        return await _telOperationRepository.Queryable()
+            .WhereIF(!string.IsNullOrEmpty(dto.UserName), d => d.UserName == dto.UserName)
+            .WhereIF(!string.IsNullOrEmpty(dto.StaffNo), d => d.StaffNo == dto.StaffNo)
+            .WhereIF(!string.IsNullOrEmpty(dto.GroupId), d => d.GroupId == dto.GroupId)
+            .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;
+    }
+
+    /// <summary>
+    /// 批量获取callId
+    /// </summary>
+    public async Task<List<(string callNo, string callId)>> GetOrSetCallIdRangeAsync(List<string> callNos,
+        CancellationToken cancellationToken)
+    {
+        var relations = await _callIdRelationRepository.Queryable()
+            .Where(d => callNos.Contains(d.Id))
+            .ToListAsync(cancellationToken);
+
+        var rsp = new List<(string callNo, string callId)>();
+        var newRelations = new List<CallidRelation>();
+        foreach (var callNo in callNos)
+        {
+            var relation = relations.FirstOrDefault(d => d.Id == callNo);
+            if (relation is null)
+            {
+                relation = new CallidRelation
+                {
+                    Id = callNo,
+                    CallId = Ulid.NewUlid().ToString(),
+                };
+                newRelations.Add(relation);
+                rsp.Add(new(relation.Id, relation.CallId));
+            }
+            else
+            {
+                rsp.Add(new(relation.Id, relation.CallId));
+            }
+        }
+
+        await _callIdRelationRepository.AddRangeAsync(newRelations, cancellationToken);
+        return rsp;
+    }
+
+    /// <summary>
+    /// 查询通话记录
+    /// </summary>
+    public Task<CallNative?> GetCallAsync(string callId, CancellationToken cancellationToken)
+    {
+        if (string.IsNullOrEmpty(callId)) return null;
+        return _callNativeRepository.GetAsync(callId, cancellationToken);
+    }
+
+    /// <summary>
+    /// 查询通话记录
+    /// </summary>
+    public async Task<List<CallNative>> QueryCallsAsync(string phone, ECallDirection? direction,
+        CancellationToken cancellationToken)
+    {
+        if (string.IsNullOrEmpty(phone))
+            return new List<CallNative>();
+        return await _callNativeRepository.Queryable()
+            .WhereIF(direction.HasValue, d => d.Direction == direction)
+            .Where(d => d.FromNo == phone || d.ToNo == phone)
+            .OrderBy(d => d.CreationTime)
+            .ToListAsync(cancellationToken);
+    }
+
+    #region tianrun 临时方案
+
+    public async Task<TrCallRecord?> GetTianrunCallAsync(string callId, CancellationToken cancellationToken)
+    {
+        throw new NotImplementedException();
+    }
+
+    /// <summary>
+    /// 关联通话记录与order(添润)
+    /// </summary>
+    public async Task RelateTianrunCallWithOrderAsync(string callId, string orderId, CancellationToken cancellationToken)
+    {
+        throw new NotImplementedException();
+    }
+
+    /// <summary>
+    /// 查询通话记录
+    /// </summary>
+    public async Task<List<TrCallRecord>> QueryTianrunCallsAsync(string phone, ECallDirection? direction = null,
+        CancellationToken cancellationToken = default)
+    {
+        throw new NotImplementedException();
+    }
+
+    #endregion
+}

+ 7 - 0
src/Hotline.Application/CallCenter/ICallApplication.cs

@@ -54,6 +54,10 @@ namespace Hotline.Application.CallCenter
         /// 签出
         /// </summary>
         Task SingOutAsync(CancellationToken cancellationToken);
+
+        /// <summary>
+        /// 签出
+        /// </summary>
         Task SingOutAsync(string telNo, CancellationToken cancellationToken);
 
         /// <summary>
@@ -89,6 +93,9 @@ namespace Hotline.Application.CallCenter
         /// </summary>
         Task<CallNative?> GetCallAsync(string callId, CancellationToken cancellationToken);
 
+        /// <summary>
+        /// 查询通话记录
+        /// </summary>
         Task<List<CallNative>> QueryCallsAsync(string phone, ECallDirection? direction = null, CancellationToken cancellationToken = default);
 
         #region tianrun

+ 13 - 89
src/Hotline.Application/CallCenter/TianRunCallApplication.cs

@@ -20,7 +20,7 @@ using XF.Domain.Repository;
 
 namespace Hotline.Application.CallCenter
 {
-    public class TianRunCallApplication : ICallApplication
+    public class TianRunCallApplication : DefaultCallApplication
     {
         private readonly ISessionContext _sessionContext;
         private readonly IRepository<TrCallRecord> _trCallRecordRepository;
@@ -43,26 +43,10 @@ namespace Hotline.Application.CallCenter
             _systemSettingCacheManager = systemSettingCacheManager;
         }
 
-        /// <summary>
-        /// 查询分机
-        /// </summary>
-        public Task<IReadOnlyList<TelDto>> QueryTelsAsync(CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// 查询分机组
-        /// </summary>
-        public Task<IReadOnlyList<TelGroupDto>> QueryTelGroupsAsync(CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
         /// <summary>
         /// 新增黑名单
         /// </summary>
-        public async Task<string> AddBlackListAsync(AddBlacklistDto dto, CancellationToken cancellationToken)
+        public override async Task<string> AddBlackListAsync(AddBlacklistDto dto, CancellationToken cancellationToken)
         {
             throw new NotImplementedException();
         }
@@ -70,7 +54,7 @@ namespace Hotline.Application.CallCenter
         /// <summary>
         /// 删除黑名单
         /// </summary>
-        public async Task RemoveBlackListAsync(string id, CancellationToken cancellationToken)
+        public override async Task RemoveBlackListAsync(string id, CancellationToken cancellationToken)
         {
             throw new NotImplementedException();
         }
@@ -78,7 +62,7 @@ namespace Hotline.Application.CallCenter
         /// <summary>
         /// 查询黑名单
         /// </summary>
-        public async Task<List<Blacklist>> QueryBlackListsAsync(CancellationToken cancellationToken)
+        public override async Task<List<Blacklist>> QueryBlackListsAsync(CancellationToken cancellationToken)
         {
             throw new NotImplementedException();
         }
@@ -86,16 +70,16 @@ namespace Hotline.Application.CallCenter
         /// <summary>
         /// 签入
         /// </summary>
-        public Task<TrOnDutyResponseDto> SignInAsync(SignInDto dto, CancellationToken cancellationToken) =>
-            _trApplication.OnSign(_sessionContext.RequiredUserId, dto.TelNo, (ETelModel)dto.TelModelState, cancellationToken);
+        public new async Task<TrOnDutyResponseDto> SignInAsync(SignInDto dto, CancellationToken cancellationToken) =>
+            await _trApplication.OnSign(_sessionContext.RequiredUserId, dto.TelNo, (ETelModel)dto.TelModelState, cancellationToken);
 
         /// <summary>
         /// 签出
         /// </summary>
-        public Task SingOutAsync(CancellationToken cancellationToken) =>
+        public new Task SingOutAsync(CancellationToken cancellationToken) =>
             _telApplication.SignOutAsync(_sessionContext.RequiredUserId, cancellationToken);
 
-        public Task SingOutAsync(string telNo, CancellationToken cancellationToken) =>
+        public new Task SingOutAsync(string telNo, CancellationToken cancellationToken) =>
             _telApplication.SignOutByTelNoAsync(telNo, cancellationToken);
 
         /// <summary>
@@ -103,63 +87,11 @@ namespace Hotline.Application.CallCenter
         /// </summary>
         /// <param name="cancellationToken"></param>
         /// <returns></returns>
-        public Task<TrOnDutyResponseDto> GetTelStateAsync(CancellationToken cancellationToken) =>
+        public new Task<TrOnDutyResponseDto> GetTelStateAsync(CancellationToken cancellationToken) =>
             _trApplication.TelState(_sessionContext.RequiredUserId, cancellationToken);
+        
 
-        /// <summary>
-        /// 定量查询通话记录
-        /// </summary>
-        Task<IReadOnlyList<CallNativeDto>> ICallApplication.QueryCallsFixedAsync(QueryCallsFixedDto dto, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// 关联通话记录与工单或回访
-        /// </summary>
-        public Task RelateCallToOrderAsync(LinkCallRecordDto dto, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// 查询分机操作记录(定量)
-        /// </summary>
-        public async Task<IReadOnlyList<TelOperation>> QueryTelOperationsAsync(QueryTelOperationsFixedDto dto, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// 依据通话记录编号获取映射后的callId
-        /// </summary>
-        public async Task<string> GetOrSetCallIdAsync(string callNo, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// 批量获取callId
-        /// </summary>
-        public async Task<List<(string callNo, string callId)>> GetOrSetCallIdRangeAsync(List<string> callNos, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// 查询通话记录
-        /// </summary>
-        public async Task<CallNative?> GetCallAsync(string callId, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        public async Task<List<CallNative>> QueryCallsAsync(string phone, ECallDirection? direction, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        public async Task<TrCallRecord?> GetTianrunCallAsync(string callId, CancellationToken cancellationToken)
+        public new async Task<TrCallRecord?> GetTianrunCallAsync(string callId, CancellationToken cancellationToken)
         {
             if (string.IsNullOrEmpty(callId)) return null;
             var callRecord = await _trCallRecordRepository.GetAsync(
@@ -170,7 +102,7 @@ namespace Hotline.Application.CallCenter
         /// <summary>
         /// 关联通话记录与order(添润)
         /// </summary>
-        public async Task RelateTianrunCallWithOrderAsync(string callId, string orderId, CancellationToken cancellationToken)
+        public new async Task RelateTianrunCallWithOrderAsync(string callId, string orderId, CancellationToken cancellationToken)
         {
             var callRecord = await _trCallRecordRepository.GetAsync(
                 p => p.OtherAccept == callId && string.IsNullOrEmpty(p.OtherAccept) == false, cancellationToken);
@@ -185,19 +117,11 @@ namespace Hotline.Application.CallCenter
         /// <summary>
         /// 查询通话记录
         /// </summary>
-        public async Task<List<TrCallRecord>> QueryTianrunCallsAsync(string phone, ECallDirection? direction, CancellationToken cancellationToken)
+        public new async Task<List<TrCallRecord>> QueryTianrunCallsAsync(string phone, ECallDirection? direction, CancellationToken cancellationToken)
         {
             return await _trCallRecordRepository.Queryable()
                 .Where(x => x.CallDirection == 0 && x.CPN == phone)
                 .OrderBy(x => x.CreatedTime).ToListAsync(cancellationToken);
         }
-
-        /// <summary>
-        /// 定量查询通话记录
-        /// </summary>
-        public async Task<IReadOnlyList<CallNative>> QueryCallsFixedAsync(QueryCallsFixedDto dto, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
     }
 }

+ 307 - 280
src/Hotline.Application/CallCenter/XingTangCallApplication.cs

@@ -30,20 +30,20 @@ using XF.Domain.Repository;
 
 namespace Hotline.Application.CallCenter
 {
-    public class XingTangCallApplication : ICallApplication
+    public class XingTangCallApplication : DefaultCallApplication
     {
-        private readonly IRepository<Tel> _telRepository;
-        private readonly IRepository<TelGroup> _telGroupRepository;
-        private readonly IWorkRepository _workRepository;
-        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;
+        // private readonly IRepository<Tel> _telRepository;
+        // private readonly IRepository<TelGroup> _telGroupRepository;
+        // private readonly IWorkRepository _workRepository;
+        // 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,
@@ -57,297 +57,324 @@ namespace Hotline.Application.CallCenter
             IUserCacheManager userCacheManager,
             ISessionContext sessionContext,
             IMapper mapper,
-            ILogger<XingTangCallApplication> logger)
+            ILogger<XingTangCallApplication> logger
+        ) : base(telRepository, telGroupRepository, workRepository, telRestRepository, callNativeRepository,
+            teloperationRepository, callidRelationRepository, cacheWork, userCacheManager, sessionContext, mapper,
+            logger)
         {
-            _telRepository = telRepository;
-            _telGroupRepository = telGroupRepository;
-            _workRepository = workRepository;
-            _telRestRepository = telRestRepository;
-            _callNativeRepository = callNativeRepository;
-            _teloperationRepository = teloperationRepository;
-            _callidRelationRepository = callidRelationRepository;
-            _cacheWork = cacheWork;
-            _userCacheManager = userCacheManager;
-            _sessionContext = sessionContext;
-            _mapper = mapper;
-            _logger = logger;
+            // _telRepository = telRepository;
+            // _telGroupRepository = telGroupRepository;
+            // _workRepository = workRepository;
+            // _telRestRepository = telRestRepository;
+            // _callNativeRepository = callNativeRepository;
+            // _teloperationRepository = teloperationRepository;
+            // _callidRelationRepository = callidRelationRepository;
+            // _cacheWork = cacheWork;
+            // _userCacheManager = userCacheManager;
+            // _sessionContext = sessionContext;
+            // _mapper = mapper;
+            // _logger = logger;
         }
 
-        /// <summary>
-        /// 查询分机
-        /// </summary>
-        public async Task<IReadOnlyList<TelDto>> QueryTelsAsync(CancellationToken cancellationToken)
-        {
-            return await _telRepository.Queryable()
-                .Select<TelDto>()
-                .ToListAsync(cancellationToken);
-        }
-
-        /// <summary>
-        /// 查询分机组
-        /// </summary>
-        public async Task<IReadOnlyList<TelGroupDto>> QueryTelGroupsAsync(CancellationToken cancellationToken)
-        {
-            return await _telGroupRepository.Queryable()
-                .Select<TelGroupDto>()
-                .ToListAsync(cancellationToken);
-        }
-
-        /// <summary>
-        /// 新增黑名单
-        /// </summary>
-        public async Task<string> AddBlackListAsync(AddBlacklistDto dto, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// 删除黑名单
-        /// </summary>
-        public async Task RemoveBlackListAsync(string id, CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-        /// <summary>
-        /// 查询黑名单
-        /// </summary>
-        public async Task<List<Blacklist>> QueryBlackListsAsync(CancellationToken cancellationToken)
-        {
-            throw new NotImplementedException();
-        }
-
-
-        /// <summary>
-        /// 签入
-        /// </summary>
-        public async Task<TrOnDutyResponseDto> SignInAsync(SignInDto dto, CancellationToken cancellationToken)
-        {
-            if (string.IsNullOrEmpty(dto.TelNo))
-                throw UserFriendlyException.SameMessage("无效分机号");
-            var work = _userCacheManager.GetWorkByUserNoExp(_sessionContext.RequiredUserId);
-            if (work is not null)
-            {
-                //if (work.TelNo != dto.TelNo)
-                //{
-                //    throw UserFriendlyException.SameMessage("当前用户已签入其他分机");
-                //}
-                throw UserFriendlyException.SameMessage("当前用户已签入");
-            }
-
-            var telWork = _userCacheManager.GetWorkByTelNoExp(dto.TelNo);
-            if (telWork is not null)
-            {
-                throw UserFriendlyException.SameMessage("当前分机已被占用");
-            }
-
-            work = new Work(_sessionContext.RequiredUserId, _sessionContext.UserName,
-                dto.TelNo, dto.TelNo, null, null,
-                dto.GroupId, _sessionContext.StaffNo, null);
-            await _workRepository.AddAsync(work, cancellationToken);
-
-            return new TrOnDutyResponseDto
-            {
-                TelNo = dto.TelNo,
-                QueueId = dto.GroupId,
-                StartTime = work.StartTime,
-            };
-        }
-
-        /// <summary>
-        /// 签出
-        /// </summary>
-        public async Task SingOutAsync(CancellationToken cancellationToken)
-        {
-            var work = _userCacheManager.GetWorkByUser(_sessionContext.RequiredUserId);
-            if (work is null) return;
-
-            var telRest = await _telRestRepository.GetAsync(x => x.TelNo == work.TelNo && !x.EndTime.HasValue, cancellationToken);
-            if (telRest is not null)
-            {
-                telRest.EndRest();
-                await _telRestRepository.UpdateAsync(telRest, cancellationToken);
-            }
-
-            work.OffDuty();
-            await _workRepository.UpdateAsync(work, cancellationToken);
-            await _cacheWork.RemoveAsync(work.GetKey(KeyMode.UserId), cancellationToken);
-            await _cacheWork.RemoveAsync(work.GetKey(KeyMode.TelNo), cancellationToken);
-        }
-
-        public async Task SingOutAsync(string telNo, CancellationToken cancellationToken)
-        {
-            var work = _userCacheManager.GetWorkByTelNoExp(telNo);
-            if (work is null) return;
+        // /// <summary>
+        // /// 查询分机
+        // /// </summary>
+        // public async Task<IReadOnlyList<TelDto>> QueryTelsAsync(CancellationToken cancellationToken)
+        // {
+        //     return await _telRepository.Queryable()
+        //         .Select<TelDto>()
+        //         .ToListAsync(cancellationToken);
+        // }
+        //
+        // /// <summary>
+        // /// 查询分机组
+        // /// </summary>
+        // public async Task<IReadOnlyList<TelGroupDto>> QueryTelGroupsAsync(CancellationToken cancellationToken)
+        // {
+        //     return await _telGroupRepository.Queryable()
+        //         .Select<TelGroupDto>()
+        //         .ToListAsync(cancellationToken);
+        // }
 
-            var telRest = await _telRestRepository.GetAsync(x => x.TelNo == work.TelNo && !x.EndTime.HasValue, cancellationToken);
-            if (telRest is not null)
-            {
-                telRest.EndRest();
-                await _telRestRepository.UpdateAsync(telRest, cancellationToken);
-            }
-
-            work.OffDuty();
-            await _workRepository.UpdateAsync(work, cancellationToken);
-            await _cacheWork.RemoveAsync(work.GetKey(KeyMode.UserId), cancellationToken);
-            await _cacheWork.RemoveAsync(work.GetKey(KeyMode.TelNo), cancellationToken);
-        }
-
-        /// <summary>
-        /// 查询当前用户的分机状态
-        /// </summary>
-        /// <param name="cancellationToken"></param>
-        /// <returns></returns>
-        public async Task<TrOnDutyResponseDto> GetTelStateAsync(CancellationToken cancellationToken)
-        {
-            var work = _userCacheManager.GetWorkByUserNoExp(_sessionContext.RequiredUserId);
-            if (work is null) return null;
-            return await Task.FromResult(new TrOnDutyResponseDto
-            {
-                TelNo = work.TelNo,
-                QueueId = work.QueueId,
-                StartTime = work.StartTime,
-            });
-        }
-
-        /// <summary>
-        /// 定量查询通话记录
-        /// </summary>
-        public async Task<IReadOnlyList<CallNativeDto>> QueryCallsFixedAsync(QueryCallsFixedDto dto, CancellationToken cancellationToken)
-        {
-            return await _callNativeRepository.Queryable(includeDeleted: true)
-                .LeftJoin<Order>((d, o) => d.CallNo == o.CallId)
-                .WhereIF(!string.IsNullOrEmpty(dto.OrderNo), (d, o) => o.No == dto.OrderNo)
-                .WhereIF(!string.IsNullOrEmpty(dto.FromNo), d => d.FromNo == dto.FromNo)
-                .WhereIF(!string.IsNullOrEmpty(dto.ToNo), d => d.ToNo == dto.ToNo)
-                .WhereIF(!string.IsNullOrEmpty(dto.UserName), d => d.UserName == dto.UserName)
-                .WhereIF(!string.IsNullOrEmpty(dto.TelNo), d => d.TelNo == dto.TelNo)
-                .WhereIF(dto.EndBy != null, d => d.EndBy == dto.EndBy)
-                .WhereIF(dto.CallStartTimeBT != null, d => d.BeginIvrTime >= dto.CallStartTimeBT)
-                .WhereIF(dto.CallStartTimeLT != null, d => d.BeginIvrTime <= dto.CallStartTimeLT)
-                .WhereIF(dto.IsConnected != null, d => d.AnsweredTime != null)
-                .WhereIF(dto.Direction != null, d => d.Direction == dto.Direction)
-                .Select((d, o) => new CallNativeDto
-                {
-                    OrderId = o.Id,
-                    OrderNo = o.No,
-                    Title = o.Title,
-                }, true)
-                .ToFixedListAsync(dto, cancellationToken);
-        }
-
-        /// <summary>
-        /// 查询分机操作记录(定量)
-        /// </summary>
-        public async Task<IReadOnlyList<TelOperation>> QueryTelOperationsAsync(QueryTelOperationsFixedDto dto, CancellationToken cancellationToken)
-        {
-            return await _teloperationRepository.Queryable()
-                .WhereIF(!string.IsNullOrEmpty(dto.UserName), d => d.UserName == dto.UserName)
-                .WhereIF(!string.IsNullOrEmpty(dto.StaffNo), d => d.StaffNo == dto.StaffNo)
-                .WhereIF(!string.IsNullOrEmpty(dto.GroupId), d => d.GroupId == dto.GroupId)
-                .WhereIF(dto.OperateState != null, d => d.OperateState == dto.OperateState)
-                .ToFixedListAsync(dto, cancellationToken);
-        }
+        // /// <summary>
+        // /// 新增黑名单
+        // /// </summary>
+        // public async Task<string> AddBlackListAsync(AddBlacklistDto dto, CancellationToken cancellationToken)
+        // {
+        //     throw new NotImplementedException();
+        // }
+        //
+        // /// <summary>
+        // /// 删除黑名单
+        // /// </summary>
+        // public async Task RemoveBlackListAsync(string id, CancellationToken cancellationToken)
+        // {
+        //     throw new NotImplementedException();
+        // }
+        //
+        // /// <summary>
+        // /// 查询黑名单
+        // /// </summary>
+        // public async Task<List<Blacklist>> QueryBlackListsAsync(CancellationToken cancellationToken)
+        // {
+        //     throw new NotImplementedException();
+        // }
 
-        /// <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;
-        }
 
-        /// <summary>
-        /// 批量获取callId
-        /// </summary>
-        public async Task<List<(string callNo, string callId)>> GetOrSetCallIdRangeAsync(List<string> callNos, CancellationToken cancellationToken)
-        {
-            var relations = await _callidRelationRepository.Queryable()
-                .Where(d => callNos.Contains(d.Id))
-                .ToListAsync(cancellationToken);
+        // /// <summary>
+        // /// 签入
+        // /// </summary>
+        // public async Task<TrOnDutyResponseDto> SignInAsync(SignInDto dto, CancellationToken cancellationToken)
+        // {
+        //     if (string.IsNullOrEmpty(dto.TelNo))
+        //         throw UserFriendlyException.SameMessage("无效分机号");
+        //     var work = _userCacheManager.GetWorkByUserNoExp(_sessionContext.RequiredUserId);
+        //     if (work is not null)
+        //     {
+        //         //if (work.TelNo != dto.TelNo)
+        //         //{
+        //         //    throw UserFriendlyException.SameMessage("当前用户已签入其他分机");
+        //         //}
+        //         throw UserFriendlyException.SameMessage("当前用户已签入");
+        //     }
+        //
+        //     var telWork = _userCacheManager.GetWorkByTelNoExp(dto.TelNo);
+        //     if (telWork is not null)
+        //     {
+        //         throw UserFriendlyException.SameMessage("当前分机已被占用");
+        //     }
+        //
+        //     work = new Work(_sessionContext.RequiredUserId, _sessionContext.UserName,
+        //         dto.TelNo, dto.TelNo, null, null,
+        //         dto.GroupId, _sessionContext.StaffNo, null);
+        //     await _workRepository.AddAsync(work, cancellationToken);
+        //
+        //     return new TrOnDutyResponseDto
+        //     {
+        //         TelNo = dto.TelNo,
+        //         QueueId = dto.GroupId,
+        //         StartTime = work.StartTime,
+        //     };
+        // }
+        //
+        // /// <summary>
+        // /// 签出
+        // /// </summary>
+        // public async Task SingOutAsync(CancellationToken cancellationToken)
+        // {
+        //     var work = _userCacheManager.GetWorkByUserNoExp(_sessionContext.RequiredUserId);
+        //     if (work is null) return;
+        //
+        //     var telRest = await _telRestRepository.GetAsync(x => x.TelNo == work.TelNo && !x.EndTime.HasValue, cancellationToken);
+        //     if (telRest is not null)
+        //     {
+        //         telRest.EndRest();
+        //         await _telRestRepository.UpdateAsync(telRest, cancellationToken);
+        //     }
+        //
+        //     work.OffDuty();
+        //     await _workRepository.UpdateAsync(work, cancellationToken);
+        //     await _cacheWork.RemoveAsync(work.GetKey(KeyMode.UserId), cancellationToken);
+        //     await _cacheWork.RemoveAsync(work.GetKey(KeyMode.TelNo), cancellationToken);
+        // }
+        //
+        // public async Task SingOutAsync(string telNo, CancellationToken cancellationToken)
+        // {
+        //     var work = _userCacheManager.GetWorkByTelNoExp(telNo);
+        //     if (work is null) return;
+        //
+        //     var telRest = await _telRestRepository.GetAsync(x => x.TelNo == work.TelNo && !x.EndTime.HasValue, cancellationToken);
+        //     if (telRest is not null)
+        //     {
+        //         telRest.EndRest();
+        //         await _telRestRepository.UpdateAsync(telRest, cancellationToken);
+        //     }
+        //
+        //     work.OffDuty();
+        //     await _workRepository.UpdateAsync(work, cancellationToken);
+        //     await _cacheWork.RemoveAsync(work.GetKey(KeyMode.UserId), cancellationToken);
+        //     await _cacheWork.RemoveAsync(work.GetKey(KeyMode.TelNo), cancellationToken);
+        // }
+        //
+        // /// <summary>
+        // /// 查询当前用户的分机状态
+        // /// </summary>
+        // /// <param name="cancellationToken"></param>
+        // /// <returns></returns>
+        // public async Task<TrOnDutyResponseDto> GetTelStateAsync(CancellationToken cancellationToken)
+        // {
+        //     var work = _userCacheManager.GetWorkByUserNoExp(_sessionContext.RequiredUserId);
+        //     if (work is null) return null;
+        //     return await Task.FromResult(new TrOnDutyResponseDto
+        //     {
+        //         TelNo = work.TelNo,
+        //         QueueId = work.QueueId,
+        //         StartTime = work.StartTime,
+        //     });
+        // }
+        //
+        // /// <summary>
+        // /// 定量查询通话记录
+        // /// </summary>
+        // public async Task<IReadOnlyList<CallNativeDto>> QueryCallsFixedAsync(QueryCallsFixedDto dto, CancellationToken cancellationToken)
+        // {
+        //     return await _callNativeRepository.Queryable(includeDeleted: true)
+        //         .LeftJoin<Order>((d, o) => d.CallNo == o.CallId)
+        //         .WhereIF(!string.IsNullOrEmpty(dto.OrderNo), (d, o) => o.No == dto.OrderNo)
+        //         .WhereIF(!string.IsNullOrEmpty(dto.FromNo), d => d.FromNo == dto.FromNo)
+        //         .WhereIF(!string.IsNullOrEmpty(dto.ToNo), d => d.ToNo == dto.ToNo)
+        //         .WhereIF(!string.IsNullOrEmpty(dto.UserName), d => d.UserName == dto.UserName)
+        //         .WhereIF(!string.IsNullOrEmpty(dto.TelNo), d => d.TelNo == dto.TelNo)
+        //         .WhereIF(dto.EndBy != null, d => d.EndBy == dto.EndBy)
+        //         .WhereIF(dto.CallStartTimeBT != null, d => d.BeginIvrTime >= dto.CallStartTimeBT)
+        //         .WhereIF(dto.CallStartTimeLT != null, d => d.BeginIvrTime <= dto.CallStartTimeLT)
+        //         .WhereIF(dto.IsConnected != null, d => d.AnsweredTime != null)
+        //         .WhereIF(dto.Direction != null, d => d.Direction == dto.Direction)
+        //         .Select((d, o) => new CallNativeDto
+        //         {
+        //             OrderId = o.Id,
+        //             OrderNo = o.No,
+        //             Title = o.Title,
+        //         }, true)
+        //         .ToFixedListAsync(dto, cancellationToken);
+        // }
+        //
+        // /// <summary>
+        // /// 查询分机操作记录(定量)
+        // /// </summary>
+        // public async Task<IReadOnlyList<TelOperation>> QueryTelOperationsAsync(QueryTelOperationsFixedDto dto, CancellationToken cancellationToken)
+        // {
+        //     return await _teloperationRepository.Queryable()
+        //         .WhereIF(!string.IsNullOrEmpty(dto.UserName), d => d.UserName == dto.UserName)
+        //         .WhereIF(!string.IsNullOrEmpty(dto.StaffNo), d => d.StaffNo == dto.StaffNo)
+        //         .WhereIF(!string.IsNullOrEmpty(dto.GroupId), d => d.GroupId == dto.GroupId)
+        //         .WhereIF(dto.OperateState != null, d => d.OperateState == dto.OperateState)
+        //         .ToFixedListAsync(dto, cancellationToken);
+        // }
 
-            var rsp = new List<(string callNo, string callId)>();
-            var newRelations = new List<CallidRelation>();
-            foreach (var callNo in callNos)
-            {
-                var relation = relations.FirstOrDefault(d => d.Id == callNo);
-                if (relation is null)
-                {
-                    relation = new CallidRelation
-                    {
-                        Id = callNo,
-                        CallId = Ulid.NewUlid().ToString(),
-                    };
-                    newRelations.Add(relation);
-                    rsp.Add(new(relation.Id, relation.CallId));
-                }
-                else
-                {
-                    rsp.Add(new(relation.Id, relation.CallId));
-                }
-            }
+        // /// <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;
+        // }
 
-            await _callidRelationRepository.AddRangeAsync(newRelations, cancellationToken);
-            return rsp;
-        }
+        // /// <summary>
+        // /// 批量获取callId
+        // /// </summary>
+        // public async Task<List<(string callNo, string callId)>> GetOrSetCallIdRangeAsync(List<string> callNos, CancellationToken cancellationToken)
+        // {
+        //     var relations = await _callidRelationRepository.Queryable()
+        //         .Where(d => callNos.Contains(d.Id))
+        //         .ToListAsync(cancellationToken);
+        //
+        //     var rsp = new List<(string callNo, string callId)>();
+        //     var newRelations = new List<CallidRelation>();
+        //     foreach (var callNo in callNos)
+        //     {
+        //         var relation = relations.FirstOrDefault(d => d.Id == callNo);
+        //         if (relation is null)
+        //         {
+        //             relation = new CallidRelation
+        //             {
+        //                 Id = callNo,
+        //                 CallId = Ulid.NewUlid().ToString(),
+        //             };
+        //             newRelations.Add(relation);
+        //             rsp.Add(new(relation.Id, relation.CallId));
+        //         }
+        //         else
+        //         {
+        //             rsp.Add(new(relation.Id, relation.CallId));
+        //         }
+        //     }
+        //
+        //     await _callidRelationRepository.AddRangeAsync(newRelations, cancellationToken);
+        //     return rsp;
+        // }
+        //
+        // /// <summary>
+        // /// 查询通话记录
+        // /// </summary>
+        // public Task<CallNative?> GetCallAsync(string callId, CancellationToken cancellationToken)
+        // {
+        //     if (string.IsNullOrEmpty(callId)) return null;
+        //     return _callNativeRepository.GetAsync(callId, cancellationToken);
+        // }
+        //
+        // public async Task<List<CallNative>> QueryCallsAsync(string phone, ECallDirection? direction, CancellationToken cancellationToken)
+        // {
+        //     if (string.IsNullOrEmpty(phone))
+        //         return new List<CallNative>();
+        //     return await _callNativeRepository.Queryable()
+        //         .WhereIF(direction.HasValue, d=>d.Direction == direction)
+        //         .Where(d=>d.FromNo == phone || d.ToNo == phone)
+        //         .OrderBy(d=>d.CreationTime)
+        //         .ToListAsync(cancellationToken);
+        // }
 
+        // public async Task<TrCallRecord?> GetTianrunCallAsync(string callId, CancellationToken cancellationToken)
+        // {
+        //     throw new NotImplementedException();
+        // }
+        //
+        // /// <summary>
+        // /// 关联通话记录与order(添润)
+        // /// </summary>
+        // public async Task RelateTianrunCallWithOrderAsync(string callId, string orderId, CancellationToken cancellationToken)
+        // {
+        //     throw new NotImplementedException();
+        // }
+        //
+        // /// <summary>
+        // /// 查询通话记录
+        // /// </summary>
+        // public async Task<List<TrCallRecord>> QueryTianrunCallsAsync(string phone, ECallDirection? direction, CancellationToken cancellationToken)
+        // {
+        //     throw new NotImplementedException();
+        // }
         /// <summary>
-        /// 查询通话记录
+        /// 新增黑名单
         /// </summary>
-        public Task<CallNative?> GetCallAsync(string callId, CancellationToken cancellationToken)
-        {
-            if (string.IsNullOrEmpty(callId)) return null;
-            return _callNativeRepository.GetAsync(callId, cancellationToken);
-        }
-
-        public async Task<List<CallNative>> QueryCallsAsync(string phone, ECallDirection? direction, CancellationToken cancellationToken)
-        {
-            if (string.IsNullOrEmpty(phone))
-                return new List<CallNative>();
-            return await _callNativeRepository.Queryable()
-                .WhereIF(direction.HasValue, d=>d.Direction == direction)
-                .Where(d=>d.FromNo == phone || d.ToNo == phone)
-                .OrderBy(d=>d.CreationTime)
-                .ToListAsync(cancellationToken);
-        }
-
-        public async Task<TrCallRecord?> GetTianrunCallAsync(string callId, CancellationToken cancellationToken)
+        public override async Task<string> AddBlackListAsync(AddBlacklistDto dto, CancellationToken cancellationToken)
         {
             throw new NotImplementedException();
         }
 
         /// <summary>
-        /// 关联通话记录与order(添润)
+        /// 删除黑名单
         /// </summary>
-        public async Task RelateTianrunCallWithOrderAsync(string callId, string orderId, CancellationToken cancellationToken)
+        public override async Task RemoveBlackListAsync(string id, CancellationToken cancellationToken)
         {
             throw new NotImplementedException();
         }
 
         /// <summary>
-        /// 查询通话记录
+        /// 查询黑名单
         /// </summary>
-        public async Task<List<TrCallRecord>> QueryTianrunCallsAsync(string phone, ECallDirection? direction, CancellationToken cancellationToken)
+        public override async Task<List<Blacklist>> QueryBlackListsAsync(CancellationToken cancellationToken)
         {
             throw new NotImplementedException();
         }
-    }
 
-}
+       
+    }
+}