|
@@ -7,6 +7,7 @@ using Hotline.Share.Enums.CallCenter;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Drawing.Printing;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -36,17 +37,20 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
}
|
|
|
|
|
|
var list = await Db.Reportable(dts).ToQueryable<DateTime>()
|
|
|
- .LeftJoin<TrCallRecord>((it, o) => o.CreatedTime >= it.ColumnName && o.CreatedTime < it.ColumnName.AddHours(1))
|
|
|
- .Where((it,o)=> o.CallDirection == ECallDirection.In)
|
|
|
+ .LeftJoin<TrCallRecord>((it, o) => o.CreatedTime >= it.ColumnName && o.CreatedTime < it.ColumnName.AddHours(1) && o.CallDirection == ECallDirection.In)
|
|
|
+ //.Where((it,o)=> o.CallDirection == ECallDirection.In)
|
|
|
.GroupBy(it => it.ColumnName)
|
|
|
.OrderBy(it => it.ColumnName)
|
|
|
.Select((it, o) => new BiCallDto()
|
|
|
{
|
|
|
Hour = it.ColumnName.Hour, //小时段
|
|
|
Total = SqlFunc.AggregateCount(o.Id),
|
|
|
- Answered = SqlFunc.AggregateSum(SqlFunc.IIF(o.AnsweredTime!=null,1,0)), //应答数
|
|
|
- Hanguped = SqlFunc.AggregateSum(SqlFunc.IIF(o.AnsweredTime==null && o.EndBy!=null && o.EndBy.Value == EEndBy.To,1,0)),//挂断数
|
|
|
- }).ToListAsync();
|
|
|
+ Answered = SqlFunc.AggregateSum(SqlFunc.IIF(o.AnsweredTime != null, 1, 0)), //应答数
|
|
|
+ Hanguped = SqlFunc.AggregateSum(SqlFunc.IIF(o.AnsweredTime == null && o.EndBy != null && o.EndBy.Value == EEndBy.To, 1, 0)),//挂断数
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .OrderBy(x => x.Hour)
|
|
|
+ .ToListAsync();
|
|
|
var returnList = list.GroupBy(x => x.Hour)
|
|
|
.Select(x => new BiCallDto()
|
|
|
{
|
|
@@ -84,8 +88,8 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
}
|
|
|
|
|
|
var list = await Db.Reportable(dts).ToQueryable<DateTime>()
|
|
|
- .LeftJoin<TrCallRecord>((it, o) => o.CreatedTime >= it.ColumnName && o.CreatedTime < it.ColumnName.AddHours(1))
|
|
|
- .Where((it, o) => o.CallDirection == ECallDirection.In)
|
|
|
+ .LeftJoin<TrCallRecord>((it, o) => o.CreatedTime >= it.ColumnName && o.CreatedTime < it.ColumnName.AddHours(1) && o.CallDirection == ECallDirection.In)
|
|
|
+ //.Where((it, o) => o.CallDirection == ECallDirection.In)
|
|
|
.GroupBy((it,o) => it.ColumnName)
|
|
|
.Select((it, o) => new TrCallHourDto()
|
|
|
{
|
|
@@ -97,6 +101,8 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
QueueByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(o.QueueTims > 0 && o.RingTimes == 0, 1, 0)), //队列挂断
|
|
|
IvrByeCount = SqlFunc.AggregateSum(SqlFunc.IIF(o.BeginIvrTime.HasValue && !o.BeginQueueTime.HasValue && !o.BeginRingTime.HasValue && o.OnState == EOnState.NoOn, 1, 0)), //IVR挂断
|
|
|
})
|
|
|
+ .MergeTable()
|
|
|
+ .OrderBy(x=>x.Hour)
|
|
|
.ToListAsync();
|
|
|
|
|
|
var resultList = list.GroupBy(x => x.Hour)
|
|
@@ -113,7 +119,40 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
- public async Task<List<CallHotLineDto>> GetCallHotLineList(DateTime beginDate, DateTime endDate,string lineNum, int noConnectByeTimes, int effectiveTimes, int connectByeTimes,int ringTims)
|
|
|
+ /// <summary>
|
|
|
+ /// 通话时段统计明细
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<object> GetCallList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, string type, string source ,int pageIndex, int pageSize)
|
|
|
+ {
|
|
|
+ endDate = endDate.Value.Date.AddDays(1).AddSeconds(-1);
|
|
|
+ RefAsync<int> total = 0;
|
|
|
+ var res = await Db.Queryable<TrCallRecord>()
|
|
|
+ .Where(x => x.CreatedTime >= beginDate && x.CreatedTime <= endDate)
|
|
|
+ .Where(x => x.CallDirection == ECallDirection.In)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(source), x => x.CDPN == source)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) && ("QueueBye".Equals(type) || "queueByeCount".Equals(type)), x => x.QueueTims > 0 && x.RingTimes == 0)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) &&("IvrBye".Equals(type)|| "ivrByeCount".Equals(type)) , x => x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) && ("Effective".Equals(type) || "effectiveCount".Equals(type)), x => x.Duration >= effectiveTimes)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) && "Invalid".Equals(type) , x => x.Duration < effectiveTimes)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) && "connectByeCount".Equals(type) , x => x.Duration > 0 && x.Duration <= connectByeTimes)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) && "noConnectByeCount".Equals(type), x => x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) && "count".Equals(type), x =>
|
|
|
+ (x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0)
|
|
|
+ ||(x.Duration == 0 && x.RingTimes <= noConnectByeTimes && x.RingTimes > 0)
|
|
|
+ ||(x.Duration >= effectiveTimes)
|
|
|
+ ||(x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn)
|
|
|
+ ||(x.QueueTims > 0 && x.RingTimes == 0))
|
|
|
+ .Select(x=> new {
|
|
|
+ CPN = x.CPN,
|
|
|
+ CDPN= x.CDPN,
|
|
|
+ CreatedTime = x.CreatedTime
|
|
|
+ })
|
|
|
+ .ToPageListAsync(pageIndex, pageSize, total);
|
|
|
+ return new { Data = res , Total = total.Value};
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<List<CallHotLineDto>> GetCallHotLineList(DateTime beginDate, DateTime endDate,string lineNum, int noConnectByeTimes, int effectiveTimes, int connectByeTimes,int ringTims)
|
|
|
{
|
|
|
endDate = endDate.AddDays(1).AddSeconds(-1);
|
|
|
var list =await Db.Queryable<TrCallRecord>()
|