|
@@ -17,6 +17,8 @@ using Hotline.CallCenter.Tels;
|
|
using Hotline.Share.Dtos;
|
|
using Hotline.Share.Dtos;
|
|
using Hotline.Share.Tools;
|
|
using Hotline.Share.Tools;
|
|
using JiebaNet.Segmenter.Common;
|
|
using JiebaNet.Segmenter.Common;
|
|
|
|
+using XingTang.Sdk;
|
|
|
|
+using Mapster;
|
|
|
|
|
|
namespace Hotline.Application.StatisticalReport.CallReport;
|
|
namespace Hotline.Application.StatisticalReport.CallReport;
|
|
|
|
|
|
@@ -86,25 +88,24 @@ public abstract class CallReportApplicationBase : ICallReportApplication
|
|
int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
|
|
int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
|
|
|
|
|
|
var callData = await _callNativeRepository.Queryable()
|
|
var callData = await _callNativeRepository.Queryable()
|
|
- .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime)
|
|
|
|
- // .Where(p => p.Gateway != "82826886" && SqlFunc.Length(p.Gateway) != 4)
|
|
|
|
|
|
+ .Where(p => p.BeginIvrTime >= dto.StartTime && p.BeginIvrTime <= dto.EndTime && p.CallState != ECallState.Invalid)
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Keyword), p => p.ToNo == dto.Keyword)
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Keyword), p => p.ToNo == dto.Keyword)
|
|
- .GroupBy(p => p.CreationTime.ToString("yyyy-MM-dd"))
|
|
|
|
|
|
+ .GroupBy(p => p.BeginIvrTime.Value.ToString("yyyy-MM-dd"))
|
|
.Select(p => new QueryCallsDetailDto
|
|
.Select(p => new QueryCallsDetailDto
|
|
{
|
|
{
|
|
- Date = p.CreationTime.ToString("yyyy-MM-dd"),
|
|
|
|
|
|
+ Date = p.BeginIvrTime.Value.ToString("yyyy-MM-dd"),
|
|
InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In, 1, 0)),//呼入总量
|
|
InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In, 1, 0)),//呼入总量
|
|
InConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null, 1, 0)),//呼入接通量
|
|
InConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null, 1, 0)),//呼入接通量
|
|
- NotAcceptedHang = SqlFunc.AggregateSum(SqlFunc.IIF(p.Duration == 0 && p.RingDuration <= noConnectByeTimes && p.RingDuration > 0 && p.Direction == ECallDirection.In, 1, 0)), //未接通秒挂
|
|
|
|
|
|
+ NotAcceptedHang = SqlFunc.AggregateSum(SqlFunc.IIF(p.RingDuration <= noConnectByeTimes && p.RingDuration > 0 && p.Direction == ECallDirection.In, 1, 0)), //未接通秒挂
|
|
TotalDurationIncomingCalls = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null, p.Duration, 0)), //呼入总时长
|
|
TotalDurationIncomingCalls = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null, p.Duration, 0)), //呼入总时长
|
|
InAvailableAnswer = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null && p.Duration >= effectiveTimes, 1, 0)),//有效接通量
|
|
InAvailableAnswer = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null && p.Duration >= effectiveTimes, 1, 0)),//有效接通量
|
|
InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.Duration > 0 && p.Duration <= connectByeTimes, 1, 0)), //呼入接通秒挂
|
|
InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.Duration > 0 && p.Duration <= connectByeTimes, 1, 0)), //呼入接通秒挂
|
|
TimeoutConnection = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null && p.RingDuration >= CallInOverConnRingTime, 1, 0)),//超时接通量
|
|
TimeoutConnection = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null && p.RingDuration >= CallInOverConnRingTime, 1, 0)),//超时接通量
|
|
TimeoutSuspension = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null && p.Duration >= SeatChaoTime, 1, 0)),//超时挂断量
|
|
TimeoutSuspension = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null && p.Duration >= SeatChaoTime, 1, 0)),//超时挂断量
|
|
- QueueByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.WaitDuration > 0 && p.RingDuration == 0 && p.AnsweredTime == null, 1, 0)), //队列挂断
|
|
|
|
- IvrByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.BeginIvrTime.HasValue && !p.BeginQueueTime.HasValue && !p.BeginRingTime.HasValue && p.AnsweredTime == null, 1, 0)), //IVR挂断
|
|
|
|
|
|
+ QueueByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.CallState == ECallState.NotAcceptedHang, 1, 0)), //队列挂断
|
|
|
|
+ IvrByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.CallState == ECallState.IVRNoAccept, 1, 0)), //IVR挂断
|
|
OutTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.Out, 1, 0)),//呼出总量
|
|
OutTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.Out, 1, 0)),//呼出总量
|
|
- OutConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.AnsweredTime != null && p.Direction == ECallDirection.Out && p.AnsweredTime != null, 1, 0))
|
|
|
|
|
|
+ OutConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.Out && p.AnsweredTime != null, 1, 0))
|
|
})
|
|
})
|
|
.OrderBy(p => p.Date)
|
|
.OrderBy(p => p.Date)
|
|
.ToListAsync();
|
|
.ToListAsync();
|
|
@@ -120,12 +121,12 @@ public abstract class CallReportApplicationBase : ICallReportApplication
|
|
public virtual async Task<(int, List<CallRecordOutDto>)> QueryCallsDetailInTotalAsync(BiQueryCallsDto dto, bool isAll)
|
|
public virtual async Task<(int, List<CallRecordOutDto>)> QueryCallsDetailInTotalAsync(BiQueryCallsDto dto, bool isAll)
|
|
{
|
|
{
|
|
var recordPrefix = _systemSettingCacheManager.RecordPrefix;
|
|
var recordPrefix = _systemSettingCacheManager.RecordPrefix;
|
|
- var query = _callNativeRepository.Queryable()
|
|
|
|
|
|
+ var query = _callNativeRepository.Queryable(includeDeleted: true)
|
|
.LeftJoin<Order>((p, o) => p.Id == o.CallId)
|
|
.LeftJoin<Order>((p, o) => p.Id == o.CallId)
|
|
- .Where((p, o) => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime && p.Direction == ECallDirection.In)
|
|
|
|
|
|
+ .Where((p, o) => p.BeginIvrTime >= dto.StartTime && p.BeginIvrTime <= dto.EndTime && p.Direction == ECallDirection.In && p.CallState != ECallState.Invalid)
|
|
.WhereIF(dto.TypeCode == "2", (p, o) => p.AnsweredTime != null)
|
|
.WhereIF(dto.TypeCode == "2", (p, o) => p.AnsweredTime != null)
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Keyword), (p, o) => p.TelNo == dto.Keyword)
|
|
.WhereIF(!string.IsNullOrEmpty(dto.Keyword), (p, o) => p.TelNo == dto.Keyword)
|
|
- .OrderByDescending((p, o) => p.CreationTime)
|
|
|
|
|
|
+ .OrderByDescending((p, o) => p.BeginIvrTime)
|
|
.Select((p, o) => new CallRecordOutDto
|
|
.Select((p, o) => new CallRecordOutDto
|
|
{
|
|
{
|
|
OtherAccept = p.Id,
|
|
OtherAccept = p.Id,
|
|
@@ -161,16 +162,16 @@ public abstract class CallReportApplicationBase : ICallReportApplication
|
|
int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
|
|
int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
|
|
|
|
|
|
var callData = await _callNativeRepository.Queryable()
|
|
var callData = await _callNativeRepository.Queryable()
|
|
- .Where(p => p.CreationTime >= dto.StartTime && p.CreationTime <= dto.EndTime && p.GroupId != "0")
|
|
|
|
- .GroupBy(p => p.CreationTime.ToString("yyyy-MM-dd"))
|
|
|
|
|
|
+ .Where(p => p.BeginIvrTime >= dto.StartTime && p.BeginIvrTime <= dto.EndTime && p.CallState != ECallState.Invalid)
|
|
|
|
+ .GroupBy(p => p.BeginIvrTime.Value.ToString("yyyy-MM-dd"))
|
|
.Select(p => new QueryCallsDetailStatistics
|
|
.Select(p => new QueryCallsDetailStatistics
|
|
{
|
|
{
|
|
- Date = p.CreationTime.ToString("yyyy-MM-dd"),
|
|
|
|
|
|
+ Date = p.BeginIvrTime.Value.ToString("yyyy-MM-dd"),
|
|
//InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In, 1, 0)),//呼入总量
|
|
//InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In, 1, 0)),//呼入总量
|
|
InConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null, 1, 0)),//呼入接通量
|
|
InConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.AnsweredTime != null, 1, 0)),//呼入接通量
|
|
- NotAcceptedHang = SqlFunc.AggregateSum(SqlFunc.IIF(p.Duration == 0 && p.RingDuration <= noConnectByeTimes && p.RingDuration > 0 && p.Direction == ECallDirection.In, 1, 0)), //呼入队列挂断
|
|
|
|
|
|
+ NotAcceptedHang = SqlFunc.AggregateSum(SqlFunc.IIF(p.CallState == ECallState.NotAcceptedHang && p.Direction == ECallDirection.In, 1, 0)), //呼入队列挂断
|
|
InNotAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(p.Duration == 0 && p.TelNo != "0" && p.Direction == ECallDirection.In, 1, 0)), // 挂机量
|
|
InNotAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(p.Duration == 0 && p.TelNo != "0" && p.Direction == ECallDirection.In, 1, 0)), // 挂机量
|
|
- IvrByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.BeginIvrTime.HasValue && !p.BeginQueueTime.HasValue && !p.BeginRingTime.HasValue && p.AnsweredTime == null, 1, 0)), //IVR挂断
|
|
|
|
|
|
+ IvrByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Direction == ECallDirection.In && p.CallState == ECallState.IVRNoAccept && p.AnsweredTime == null, 1, 0)), //IVR挂断
|
|
OutConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.AnsweredTime != null && p.Direction == ECallDirection.Out, 1, 0)), // 呼出接通量
|
|
OutConnectionQuantity = SqlFunc.AggregateSum(SqlFunc.IIF(p.AnsweredTime != null && p.Direction == ECallDirection.Out, 1, 0)), // 呼出接通量
|
|
OutNotAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(p.AnsweredTime == null && p.Direction == ECallDirection.Out, 1, 0)), // 呼出未接量
|
|
OutNotAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(p.AnsweredTime == null && p.Direction == ECallDirection.Out, 1, 0)), // 呼出未接量
|
|
})
|
|
})
|
|
@@ -211,12 +212,13 @@ public abstract class CallReportApplicationBase : ICallReportApplication
|
|
int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
|
|
int connectByeTimes = _systemSettingCacheManager.ConnectByeTimes;
|
|
var query = _callNativeRepository.Queryable(includeDeleted: true)
|
|
var query = _callNativeRepository.Queryable(includeDeleted: true)
|
|
.LeftJoin<Order>((c, o) => c.Id == o.CallId)
|
|
.LeftJoin<Order>((c, o) => c.Id == o.CallId)
|
|
|
|
+ .Where(m => m.CallState != ECallState.Invalid)
|
|
.WhereIF(dto.OrderNo.NotNullOrEmpty(), (c, o) => o.No == dto.OrderNo)
|
|
.WhereIF(dto.OrderNo.NotNullOrEmpty(), (c, o) => o.No == dto.OrderNo)
|
|
.WhereIF(dto.FromNo.NotNullOrEmpty(), (c, o) => c.FromNo == dto.FromNo)
|
|
.WhereIF(dto.FromNo.NotNullOrEmpty(), (c, o) => c.FromNo == dto.FromNo)
|
|
.WhereIF(dto.ToNo.NotNullOrEmpty(), (c, o) => c.ToNo == dto.ToNo)
|
|
.WhereIF(dto.ToNo.NotNullOrEmpty(), (c, o) => c.ToNo == dto.ToNo)
|
|
.WhereIF(dto.TelNo.NotNullOrEmpty(), (c, o) => c.TelNo == dto.TelNo)
|
|
.WhereIF(dto.TelNo.NotNullOrEmpty(), (c, o) => c.TelNo == dto.TelNo)
|
|
.WhereIF(dto.EndBy.IsNotNull(), (c, o) => c.EndBy == dto.EndBy)
|
|
.WhereIF(dto.EndBy.IsNotNull(), (c, o) => c.EndBy == dto.EndBy)
|
|
- .Where((c, o) => c.CreationTime >= dto.StartTime && c.CreationTime <= dto.EndTime);
|
|
|
|
|
|
+ .Where((c, o) => c.BeginIvrTime >= dto.StartTime && c.BeginIvrTime <= dto.EndTime);
|
|
|
|
|
|
if (dto.FieldName == "intotal") // 呼入总量
|
|
if (dto.FieldName == "intotal") // 呼入总量
|
|
query = query.Where((c, o) => c.Direction == ECallDirection.In);
|
|
query = query.Where((c, o) => c.Direction == ECallDirection.In);
|
|
@@ -250,9 +252,10 @@ public abstract class CallReportApplicationBase : ICallReportApplication
|
|
|
|
|
|
var list = await _userRepository.Queryable()
|
|
var list = await _userRepository.Queryable()
|
|
.LeftJoin<CallNative>((u, c) => u.Id == c.UserId)
|
|
.LeftJoin<CallNative>((u, c) => u.Id == c.UserId)
|
|
|
|
+ .Where((u, c) => c.CallState != ECallState.Invalid)
|
|
.Where(u => !u.IsDeleted && u.UserType == EUserType.Seat)
|
|
.Where(u => !u.IsDeleted && u.UserType == EUserType.Seat)
|
|
- .Where((u, c) => c.CreationTime >= dto.StartTime)
|
|
|
|
- .Where((u, c) => c.CreationTime <= dto.EndTime)
|
|
|
|
|
|
+ .Where((u, c) => c.BeginIvrTime >= dto.StartTime)
|
|
|
|
+ .Where((u, c) => c.BeginIvrTime <= dto.EndTime)
|
|
.GroupBy((u, c) => new { c.UserName, c.UserId })
|
|
.GroupBy((u, c) => new { c.UserName, c.UserId })
|
|
.Select((u, c) => new BiSeatCallsDto
|
|
.Select((u, c) => new BiSeatCallsDto
|
|
{
|
|
{
|
|
@@ -260,14 +263,14 @@ public abstract class CallReportApplicationBase : ICallReportApplication
|
|
UserId = c.UserId,
|
|
UserId = c.UserId,
|
|
InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In, 1, 0)),
|
|
InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In, 1, 0)),
|
|
OutTotal = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.Out, 1, 0)),
|
|
OutTotal = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.Out, 1, 0)),
|
|
- InAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime != null, 1, 0)),
|
|
|
|
- OutAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.Out && c.AnsweredTime != null, 1, 0)),
|
|
|
|
- InHangupImmediate = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime == null && c.RingDuration < noConnectByeTimes, 1, 0)),
|
|
|
|
- InHanguped = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime == null, 1, 0)),
|
|
|
|
- InDurationAvg = SqlFunc.Ceil(SqlFunc.AggregateAvg(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime != null, c.Duration, 0))),
|
|
|
|
- OutDurationAvg = SqlFunc.Ceil(SqlFunc.AggregateAvg(SqlFunc.IIF(c.Direction == ECallDirection.Out && c.AnsweredTime != null, c.Duration, 0))),
|
|
|
|
- InAvailableAnswer = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime != null && c.Duration >= effectiveTimes, 1, 0)),
|
|
|
|
- InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime != null && c.Duration < connectByeTimes, 1, 0)),
|
|
|
|
|
|
+ InAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime != null, 1, 0)), // 呼入接通量
|
|
|
|
+ OutAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.Out && c.AnsweredTime != null, 1, 0)), // 呼出接通量
|
|
|
|
+ InHangupImmediate = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime == null && c.RingDuration < noConnectByeTimes, 1, 0)), // 呼入秒挂
|
|
|
|
+ InHanguped = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.CallState == ECallState.Missed, 1, 0)), //呼入未接
|
|
|
|
+ InDurationAvg = SqlFunc.Ceil(SqlFunc.AggregateAvg(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime != null, c.Duration, 0))), // 呼入平均时长
|
|
|
|
+ OutDurationAvg = SqlFunc.Ceil(SqlFunc.AggregateAvg(SqlFunc.IIF(c.Direction == ECallDirection.Out && c.AnsweredTime != null, c.Duration, 0))), // 呼出平均时长
|
|
|
|
+ InAvailableAnswer = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime != null && c.Duration >= effectiveTimes, 1, 0)), // 有效接通量
|
|
|
|
+ InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.Direction == ECallDirection.In && c.AnsweredTime != null && c.Duration < connectByeTimes, 1, 0)), // 呼入接通秒挂
|
|
})
|
|
})
|
|
.MergeTable()
|
|
.MergeTable()
|
|
.ToListAsync();
|
|
.ToListAsync();
|
|
@@ -291,11 +294,11 @@ public abstract class CallReportApplicationBase : ICallReportApplication
|
|
public virtual async Task<(int, List<BiSeatSwitchDto>)> QuerySeatSwitchAsync(QuerySeatSwitchRequest dto, CancellationToken cancellationToken)
|
|
public virtual async Task<(int, List<BiSeatSwitchDto>)> QuerySeatSwitchAsync(QuerySeatSwitchRequest dto, CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
return await _callNativeRepository.Queryable()
|
|
return await _callNativeRepository.Queryable()
|
|
- .Where(x => !string.IsNullOrEmpty(x.AgentTransferNumber))
|
|
|
|
|
|
+ .Where(x => !string.IsNullOrEmpty(x.AgentTransferNumber) && x.CallState != ECallState.Invalid)
|
|
.WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
|
|
.WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
|
|
.WhereIF(!string.IsNullOrEmpty(dto.CDPN), x => x.ToNo.Contains(dto.CDPN))
|
|
.WhereIF(!string.IsNullOrEmpty(dto.CDPN), x => x.ToNo.Contains(dto.CDPN))
|
|
- .Where(x => x.CreationTime >= dto.StartTime)
|
|
|
|
- .Where(x => x.CreationTime <= dto.EndTime)
|
|
|
|
|
|
+ .Where(x => x.BeginIvrTime >= dto.StartTime)
|
|
|
|
+ .Where(x => x.BeginIvrTime <= dto.EndTime)
|
|
.Select(x => new BiSeatSwitchDto
|
|
.Select(x => new BiSeatSwitchDto
|
|
{
|
|
{
|
|
UserId = x.UserId,
|
|
UserId = x.UserId,
|