|
@@ -1,17 +1,21 @@
|
|
|
using Hotline.Application.Orders;
|
|
|
using Hotline.Caching.Interfaces;
|
|
|
using Hotline.Caching.Services;
|
|
|
+using Hotline.CallCenter.Calls;
|
|
|
using Hotline.FlowEngine.WorkflowModules;
|
|
|
using Hotline.FlowEngine.Workflows;
|
|
|
+using Hotline.Identity.Accounts;
|
|
|
using Hotline.Orders;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Settings.TimeLimits;
|
|
|
using Hotline.Share.Dtos.Bi;
|
|
|
using Hotline.Share.Dtos.CallCenter;
|
|
|
using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Share.Enums.FlowEngine;
|
|
|
using Hotline.Share.Enums.Order;
|
|
|
using Hotline.Share.Requests;
|
|
|
+using Hotline.Users;
|
|
|
using JiebaNet.Segmenter.Common;
|
|
|
using MapsterMapper;
|
|
|
using MediatR;
|
|
@@ -40,6 +44,10 @@ namespace Hotline.Application.StatisticalReport
|
|
|
private readonly IOrderSecondaryHandlingApplication _orderSecondaryHandlingApplication;
|
|
|
private readonly ITimeLimitDomainService _timeLimitDomainService;
|
|
|
private readonly IRepository<SystemDicData> _systemDicDataRepository;
|
|
|
+ private readonly IRepository<TrCallRecord> _trCallRecordRepository;
|
|
|
+ private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
+ private readonly IRepository<User> _userRepository;
|
|
|
+ private readonly IRepository<Account> _accountRepository;
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -65,9 +73,12 @@ namespace Hotline.Application.StatisticalReport
|
|
|
IRepository<OrderScreen> orderScreenRepository,
|
|
|
IOrderSecondaryHandlingApplication orderSecondaryHandlingApplication,
|
|
|
ITimeLimitDomainService timeLimitDomainService,
|
|
|
- IRepository<SystemDicData> systemDicDataRepository
|
|
|
-,
|
|
|
- ISystemDicDataCacheManager sysDicDataCacheManager
|
|
|
+ IRepository<SystemDicData> systemDicDataRepository,
|
|
|
+ ISystemDicDataCacheManager sysDicDataCacheManager,
|
|
|
+ IRepository<TrCallRecord> trCallRecordRepository,
|
|
|
+ ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
+ IRepository<User> userRepository,
|
|
|
+ IRepository<Account> accountRepository
|
|
|
)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
@@ -82,6 +93,10 @@ namespace Hotline.Application.StatisticalReport
|
|
|
_timeLimitDomainService = timeLimitDomainService;
|
|
|
_systemDicDataRepository = systemDicDataRepository;
|
|
|
_sysDicDataCacheManager = sysDicDataCacheManager;
|
|
|
+ _trCallRecordRepository = trCallRecordRepository;
|
|
|
+ _systemSettingCacheManager = systemSettingCacheManager;
|
|
|
+ _userRepository = userRepository;
|
|
|
+ _accountRepository = accountRepository;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 部门办件统计表---新
|
|
@@ -1862,5 +1877,78 @@ namespace Hotline.Application.StatisticalReport
|
|
|
.MergeTable();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 企业专席信件统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<List<EnterpriseSeatsReportDto>> GetEnterpriseSeatsReport(EnterpriseSeatsReportRequestDto dto)
|
|
|
+ {
|
|
|
+ dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ //查询坐席信息
|
|
|
+ var enterpriseSeats = _systemSettingCacheManager.GetSetting(SettingConstants.EnterpriseSeats)?.SettingValue;
|
|
|
+ var userData = await _accountRepository.Queryable()
|
|
|
+ .Where(p => enterpriseSeats.Contains(p.UserName)).Select(p => p.Id).ToListAsync();
|
|
|
+
|
|
|
+ //查询工单
|
|
|
+ var queryOrderData = _orderRepository.Queryable()
|
|
|
+ .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
|
|
|
+ .Where(p => userData.Contains(p.SignerId))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UserName), p => p.SignerName.Contains(dto.UserName))
|
|
|
+ .GroupBy(p => new { p.SignerId })
|
|
|
+ .Select(p => new EnterpriseSeatsReportDto
|
|
|
+ {
|
|
|
+ UserId = p.SignerId,
|
|
|
+ OrderNum = SqlFunc.AggregateSum(SqlFunc.IIF(p.AcceptType != "无效", 1, 0)),
|
|
|
+ })
|
|
|
+ .MergeTable();
|
|
|
+
|
|
|
+ //查询通话
|
|
|
+ var queryCall = _trCallRecordRepository.Queryable()
|
|
|
+ .Where(t => t.CreatedTime >= dto.StartTime && t.CreatedTime <= dto.EndTime)
|
|
|
+ .Where(t => userData.Contains(t.UserId))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UserName), t => t.UserName.Contains(dto.UserName))
|
|
|
+ .GroupBy(t => new { t.UserId })
|
|
|
+ .Select(t => new EnterpriseSeatsReportDto
|
|
|
+ {
|
|
|
+ UserId = t.UserId,
|
|
|
+ TelCallNum = SqlFunc.AggregateSum(SqlFunc.IIF(t.CallDirection == ECallDirection.In || t.CallDirection == ECallDirection.Out, 1, 0)),
|
|
|
+ })
|
|
|
+ .MergeTable();
|
|
|
+
|
|
|
+ return await _userRepository.Queryable()
|
|
|
+ .Where(u => userData.Contains(u.Id))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UserName), u => u.Name.Contains(dto.UserName))
|
|
|
+ .LeftJoin(queryOrderData, (u, qo) => u.Id == qo.UserId)
|
|
|
+ .LeftJoin(queryCall, (u, qo, qc) => u.Id == qc.UserId)
|
|
|
+ .Select((u, qo, qc) => new EnterpriseSeatsReportDto
|
|
|
+ {
|
|
|
+ UserName = u.Name,
|
|
|
+ UserId = u.Id,
|
|
|
+ UserNo = u.StaffNo,
|
|
|
+ TelCallNum = qc.TelCallNum,
|
|
|
+ OrderNum = qo.OrderNum,
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 企业专席信件统计--明细
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public ISugarQueryable<Order> GetEnterpriseSeatsReportDetail(EnterpriseSeatsReportRequestDto dto)
|
|
|
+ {
|
|
|
+ dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ return _orderRepository.Queryable()
|
|
|
+ .Where(o => o.CreationTime >= dto.StartTime && o.CreationTime <= dto.EndTime && o.SignerId == dto.UserId)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UserName), o => o.SignerName.Contains(dto.UserName))
|
|
|
+ .OrderByDescending(o => o.CreationTime);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|