|
@@ -1,13 +1,13 @@
|
|
|
-using Hotline.Caching.Interfaces;
|
|
|
-using Hotline.Caching.Services;
|
|
|
+using Hotline.Application.StatisticalReport;
|
|
|
+using Hotline.Caching.Interfaces;
|
|
|
using Hotline.CallCenter.Calls;
|
|
|
using Hotline.CallCenter.Tels;
|
|
|
-using Hotline.Orders;
|
|
|
using Hotline.Repository.SqlSugar.Extensions;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Share.Dtos;
|
|
|
using Hotline.Share.Dtos.CallCenter;
|
|
|
using Hotline.Share.Dtos.Order;
|
|
|
+using Hotline.Share.Dtos.TrCallCenter;
|
|
|
using Hotline.Share.Enums.CallCenter;
|
|
|
using Hotline.Share.Enums.User;
|
|
|
using Hotline.Share.Requests;
|
|
@@ -18,7 +18,6 @@ using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using SqlSugar;
|
|
|
using System.Data;
|
|
|
-using XF.Domain.Constants;
|
|
|
using XF.Domain.Exceptions;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
@@ -37,6 +36,7 @@ public class BiCallController : BaseController
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
private readonly IRepository<Work> _workRepository;
|
|
|
private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
|
|
|
+ private readonly ICallReportApplication _callReportApplication;
|
|
|
|
|
|
|
|
|
|
|
@@ -48,7 +48,8 @@ public class BiCallController : BaseController
|
|
|
ITrCallRecordRepository trCallRecordRepositoryEx,
|
|
|
ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
ISystemDicDataCacheManager sysDicDataCacheManager,
|
|
|
- IRepository<Work> workRepository)
|
|
|
+ IRepository<Work> workRepository,
|
|
|
+ ICallReportApplication callReportApplication)
|
|
|
{
|
|
|
_trCallRecordRepository = trCallRecordRepository;
|
|
|
_userRepository = userRepository;
|
|
@@ -58,6 +59,7 @@ public class BiCallController : BaseController
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
_workRepository = workRepository;
|
|
|
_sysDicDataCacheManager = sysDicDataCacheManager;
|
|
|
+ _callReportApplication = callReportApplication;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -161,6 +163,253 @@ public class BiCallController : BaseController
|
|
|
return ExcelStreamResult(stream, "话务统计分析");
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 话务日期明细
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("query_calls_detail")]
|
|
|
+ public async Task<object> QueryCallsDetailAsync([FromQuery] BiQueryCallsDto dto)
|
|
|
+ {
|
|
|
+ if (!dto.StartTime.HasValue || !dto.EndTime.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+ dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ var items = await _callReportApplication.QueryCallsDetailAsync(dto);
|
|
|
+
|
|
|
+ var total = new QueryCallsDetailDto
|
|
|
+ {
|
|
|
+ Date = "合计",
|
|
|
+ Hour = "",
|
|
|
+ InTotal = items.Sum(p => p.InTotal),
|
|
|
+ InConnectionQuantity = items.Sum(p => p.InConnectionQuantity),
|
|
|
+ NotAcceptedHang = items.Sum(p => p.NotAcceptedHang),
|
|
|
+ TotalDurationIncomingCalls = items.Sum(p => p.TotalDurationIncomingCalls),
|
|
|
+ InAvailableAnswer = items.Sum(p => p.InAvailableAnswer),
|
|
|
+ InHangupImmediateWhenAnswered = items.Sum(p => p.InHangupImmediateWhenAnswered),
|
|
|
+ TimeoutConnection = items.Sum(p => p.TimeoutConnection),
|
|
|
+ TimeoutSuspension = items.Sum(p => p.TimeoutSuspension),
|
|
|
+ QueueByeCount = items.Sum(p => p.QueueByeCount),
|
|
|
+ IvrByeCount = items.Sum(p => p.IvrByeCount),
|
|
|
+ OutTotal = items.Sum(p => p.OutTotal),
|
|
|
+ OutConnectionQuantity = items.Sum(p => p.OutConnectionQuantity)
|
|
|
+ };
|
|
|
+
|
|
|
+ return new { List = items, Total = total };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 话务日期明细--导出
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("query_calls_detail_export")]
|
|
|
+ public async Task<FileStreamResult> QueryCallsDetailExportAsync([FromBody] ExportExcelDto<BiQueryCallsDto> dto)
|
|
|
+ {
|
|
|
+ if (!dto.QueryDto.StartTime.HasValue || !dto.QueryDto.EndTime.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+ dto.QueryDto.EndTime = dto.QueryDto.EndTime.Value.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ var items = await _callReportApplication.QueryCallsDetailAsync(dto.QueryDto);
|
|
|
+
|
|
|
+ var total = new QueryCallsDetailDto
|
|
|
+ {
|
|
|
+ Date = "合计",
|
|
|
+ Hour = "",
|
|
|
+ InTotal = items.Sum(p => p.InTotal),
|
|
|
+ InConnectionQuantity = items.Sum(p => p.InConnectionQuantity),
|
|
|
+ NotAcceptedHang = items.Sum(p => p.NotAcceptedHang),
|
|
|
+ TotalDurationIncomingCalls = items.Sum(p => p.TotalDurationIncomingCalls),
|
|
|
+ InAvailableAnswer = items.Sum(p => p.InAvailableAnswer),
|
|
|
+ InHangupImmediateWhenAnswered = items.Sum(p => p.InHangupImmediateWhenAnswered),
|
|
|
+ TimeoutConnection = items.Sum(p => p.TimeoutConnection),
|
|
|
+ TimeoutSuspension = items.Sum(p => p.TimeoutSuspension),
|
|
|
+ QueueByeCount = items.Sum(p => p.QueueByeCount),
|
|
|
+ IvrByeCount = items.Sum(p => p.IvrByeCount),
|
|
|
+ OutTotal = items.Sum(p => p.OutTotal),
|
|
|
+ OutConnectionQuantity = items.Sum(p => p.OutConnectionQuantity)
|
|
|
+ };
|
|
|
+ items.Add(total);
|
|
|
+
|
|
|
+ dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass(dto.ColumnInfos);
|
|
|
+
|
|
|
+ var dtos = items
|
|
|
+ .Select(stu => _mapper.Map(stu, typeof(QueryCallsDetailDto), dynamicClass))
|
|
|
+ .Cast<object>()
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ var stream = ExcelHelper.CreateStream(dtos);
|
|
|
+
|
|
|
+ return ExcelStreamResult(stream, "话务日期明细数据");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 话务日期明细--呼入明细
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("query_incall_calls_list")]
|
|
|
+ public async Task<PagedDto<TrCallDto>> GetInCallCallListAsync([FromQuery] BiQueryCallsDto dto)
|
|
|
+ {
|
|
|
+ if (!dto.StartTime.HasValue || !dto.EndTime.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+ dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ var (total, items) = await _callReportApplication.QueryCallsDetailInTotalAsync(dto)
|
|
|
+ .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ return new PagedDto<TrCallDto>(total, _mapper.Map<IReadOnlyList<TrCallDto>>(items));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 话务日期明细----导出
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("query_incall_calls_list_export")]
|
|
|
+ public async Task<FileStreamResult> GetInCallCallListExportAsync([FromBody] ExportExcelDto<BiQueryCallsDto> dto)
|
|
|
+ {
|
|
|
+ if (!dto.QueryDto.StartTime.HasValue || !dto.QueryDto.EndTime.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+ dto.QueryDto.EndTime = dto.QueryDto.EndTime.Value.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ var query = _callReportApplication.QueryCallsDetailInTotalAsync(dto.QueryDto);
|
|
|
+ List<TrCallRecord> data;
|
|
|
+ if (dto.IsExportAll)
|
|
|
+ {
|
|
|
+ data = await query.ToListAsync(HttpContext.RequestAborted);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var (_, items) = await query.ToPagedListAsync(dto.QueryDto, HttpContext.RequestAborted);
|
|
|
+ data = items;
|
|
|
+ }
|
|
|
+
|
|
|
+ var dataDtos = _mapper.Map<ICollection<TrCallDto>>(data);
|
|
|
+
|
|
|
+ dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass(dto.ColumnInfos);
|
|
|
+
|
|
|
+ var dtos = dataDtos
|
|
|
+ .Select(stu => _mapper.Map(stu, typeof(TrCallDto), dynamicClass))
|
|
|
+ .Cast<object>()
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ var stream = ExcelHelper.CreateStream(dtos);
|
|
|
+
|
|
|
+ string name = dto.QueryDto.TypeCode == "2" ? "话务日期-接通明细数据" : "话务日期-总量明细数据";
|
|
|
+
|
|
|
+ return ExcelStreamResult(stream, name);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 话务日期明细--时间段
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("query_calls_hour_detail_list")]
|
|
|
+ public async Task<object> QueryCallsHourDetailListAsync([FromQuery] BiQueryCallsDto dto)
|
|
|
+ {
|
|
|
+ if (!dto.StartTime.HasValue || !dto.EndTime.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+ dto.EndTime = dto.EndTime.Value.AddDays(1).AddSeconds(-1);
|
|
|
+ //超时接通量
|
|
|
+ int CallInOverConnRingTime = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.CallInOverConnRingTime)?.SettingValue[0]);
|
|
|
+ //坐席超时挂断时间
|
|
|
+ int SeatChaoTime = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.SeatChaoTime)?.SettingValue[0]);
|
|
|
+
|
|
|
+ //未接秒挂时间
|
|
|
+ int noConnectByeTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.NoConnectByeTimes)?.SettingValue[0]);
|
|
|
+ //呼入有效时间
|
|
|
+ int effectiveTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.EffectiveTimes)?.SettingValue[0]);
|
|
|
+ //接通秒挂时间
|
|
|
+ int connectByeTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.ConnectByeTimes)?.SettingValue[0]);
|
|
|
+
|
|
|
+ var items = await _trCallRecordRepositoryEx.QueryCallsHourDetail(dto.StartTime.Value, dto.EndTime.Value, noConnectByeTimes, effectiveTimes
|
|
|
+ , connectByeTimes, CallInOverConnRingTime, SeatChaoTime, dto.Keyword);
|
|
|
+
|
|
|
+ var total = new QueryCallsDetailDto
|
|
|
+ {
|
|
|
+ Date = "",
|
|
|
+ Hour = "合计",
|
|
|
+ InTotal = items.Sum(p => p.InTotal),
|
|
|
+ InConnectionQuantity = items.Sum(p => p.InConnectionQuantity),
|
|
|
+ NotAcceptedHang = items.Sum(p => p.NotAcceptedHang),
|
|
|
+ TotalDurationIncomingCalls = items.Sum(p => p.TotalDurationIncomingCalls),
|
|
|
+ InAvailableAnswer = items.Sum(p => p.InAvailableAnswer),
|
|
|
+ InHangupImmediateWhenAnswered = items.Sum(p => p.InHangupImmediateWhenAnswered),
|
|
|
+ TimeoutConnection = items.Sum(p => p.TimeoutConnection),
|
|
|
+ TimeoutSuspension = items.Sum(p => p.TimeoutSuspension),
|
|
|
+ QueueByeCount = items.Sum(p => p.QueueByeCount),
|
|
|
+ IvrByeCount = items.Sum(p => p.IvrByeCount),
|
|
|
+ OutTotal = items.Sum(p => p.OutTotal),
|
|
|
+ OutConnectionQuantity = items.Sum(p => p.OutConnectionQuantity)
|
|
|
+ };
|
|
|
+
|
|
|
+ return new { List = items, Total = total };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 话务日期明细--时间段--导出
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("query_calls_hour_detail_list_export")]
|
|
|
+ public async Task<FileStreamResult> QueryCallsHourDetailListExportAsync([FromBody] ExportExcelDto<BiQueryCallsDto> dto)
|
|
|
+ {
|
|
|
+ if (!dto.QueryDto.StartTime.HasValue || !dto.QueryDto.EndTime.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+ dto.QueryDto.EndTime = dto.QueryDto.EndTime.Value.AddDays(1).AddSeconds(-1);
|
|
|
+ //超时接通量
|
|
|
+ int CallInOverConnRingTime = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.CallInOverConnRingTime)?.SettingValue[0]);
|
|
|
+ //坐席超时挂断时间
|
|
|
+ int SeatChaoTime = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.SeatChaoTime)?.SettingValue[0]);
|
|
|
+
|
|
|
+ //未接秒挂时间
|
|
|
+ int noConnectByeTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.NoConnectByeTimes)?.SettingValue[0]);
|
|
|
+ //呼入有效时间
|
|
|
+ int effectiveTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.EffectiveTimes)?.SettingValue[0]);
|
|
|
+ //接通秒挂时间
|
|
|
+ int connectByeTimes = int.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.ConnectByeTimes)?.SettingValue[0]);
|
|
|
+
|
|
|
+ var items = await _trCallRecordRepositoryEx.QueryCallsHourDetail(dto.QueryDto.StartTime.Value, dto.QueryDto.EndTime.Value, noConnectByeTimes, effectiveTimes
|
|
|
+ , connectByeTimes, CallInOverConnRingTime, SeatChaoTime, dto.QueryDto.Keyword);
|
|
|
+
|
|
|
+ var total = new QueryCallsDetailDto
|
|
|
+ {
|
|
|
+ Date = "",
|
|
|
+ Hour = "合计",
|
|
|
+ InTotal = items.Sum(p => p.InTotal),
|
|
|
+ InConnectionQuantity = items.Sum(p => p.InConnectionQuantity),
|
|
|
+ NotAcceptedHang = items.Sum(p => p.NotAcceptedHang),
|
|
|
+ TotalDurationIncomingCalls = items.Sum(p => p.TotalDurationIncomingCalls),
|
|
|
+ InAvailableAnswer = items.Sum(p => p.InAvailableAnswer),
|
|
|
+ InHangupImmediateWhenAnswered = items.Sum(p => p.InHangupImmediateWhenAnswered),
|
|
|
+ TimeoutConnection = items.Sum(p => p.TimeoutConnection),
|
|
|
+ TimeoutSuspension = items.Sum(p => p.TimeoutSuspension),
|
|
|
+ QueueByeCount = items.Sum(p => p.QueueByeCount),
|
|
|
+ IvrByeCount = items.Sum(p => p.IvrByeCount),
|
|
|
+ OutTotal = items.Sum(p => p.OutTotal),
|
|
|
+ OutConnectionQuantity = items.Sum(p => p.OutConnectionQuantity)
|
|
|
+ };
|
|
|
+
|
|
|
+ items.Add(total);
|
|
|
+
|
|
|
+ dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass(dto.ColumnInfos);
|
|
|
+
|
|
|
+ var dtos = items
|
|
|
+ .Select(stu => _mapper.Map(stu, typeof(QueryCallsDetailDto), dynamicClass))
|
|
|
+ .Cast<object>()
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ var stream = ExcelHelper.CreateStream(dtos);
|
|
|
+
|
|
|
+ return ExcelStreamResult(stream, "话务日期明细-时间段");
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 坐席话务统计分析
|