|
@@ -63,7 +63,7 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
return returnList;
|
|
|
}
|
|
|
|
|
|
- public async Task<List<TrCallHourDto>?> GetCallHourList(DateTime beginDate,DateTime? endDate,int noConnectByeTimes,int effectiveTimes,int connectByeTimes)
|
|
|
+ public async Task<List<TrCallHourDto>?> GetCallHourList(DateTime beginDate,DateTime? endDate,int noConnectByeTimes,int effectiveTimes,int connectByeTimes, string source)
|
|
|
{
|
|
|
//计算小时差
|
|
|
if (!endDate.HasValue)
|
|
@@ -89,8 +89,9 @@ 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) && o.CallDirection == ECallDirection.In)
|
|
|
- //.Where((it, o) => o.CallDirection == ECallDirection.In)
|
|
|
- .GroupBy((it,o) => it.ColumnName)
|
|
|
+ //.Where((it, o) => o.CallDirection == ECallDirection.In)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(source), (it,o) => o.CDPN == source)
|
|
|
+ .GroupBy((it,o) => it.ColumnName)
|
|
|
.Select((it, o) => new TrCallHourDto()
|
|
|
{
|
|
|
DateTimeTo = it.ColumnName,
|
|
@@ -109,7 +110,9 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
.Select(x=> new TrCallHourDto() {
|
|
|
Hour = x.Key,
|
|
|
HourTo = x.Key.ToString().PadLeft(2, '0') + ":00 - " + (x.Key).ToString().PadLeft(2, '0') + ":59",
|
|
|
- EffectiveCount = x.Sum(d=>d.EffectiveCount),
|
|
|
+ StartHourTo= x.Key.ToString().PadLeft(2, '0') + ":00",
|
|
|
+ EndHourTo = x.Key.ToString().PadLeft(2, '0') + ":59",
|
|
|
+ EffectiveCount = x.Sum(d=>d.EffectiveCount),
|
|
|
ConnectByeCount = x.Sum(d=>d.ConnectByeCount),
|
|
|
NoConnectByeCount = x.Sum(d=>d.NoConnectByeCount),
|
|
|
QueueByeCount = x.Sum(d=>d.QueueByeCount),
|
|
@@ -123,26 +126,32 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
/// 通话时段统计明细
|
|
|
/// </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)
|
|
|
+ public async Task<object> GetCallList(DateTime beginDate, DateTime? endDate, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, string type, string source , TimeSpan? startHourTo, int pageIndex, int pageSize)
|
|
|
{
|
|
|
+ TimeSpan endHourTo = DateTime.Now.TimeOfDay;
|
|
|
+ if (startHourTo.HasValue)
|
|
|
+ {
|
|
|
+ endHourTo = startHourTo.Value.Add(new TimeSpan(1, 0, 0));
|
|
|
+ }
|
|
|
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))
|
|
|
+ .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)//IVR挂断
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) && ("Effective".Equals(type) || "effectiveCount".Equals(type)), x => x.Duration >= effectiveTimes) //有效接通
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(type) && "Invalid".Equals(type) , x => x.Duration > 0 && 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.Duration <= connectByeTimes) //接通秒挂
|
|
|
+ || (x.Duration >= effectiveTimes)//有效接通
|
|
|
+ || (x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn) //IVR挂断
|
|
|
+ || (x.QueueTims > 0 && x.RingTimes == 0))//队列挂断
|
|
|
+ .WhereIF(startHourTo.HasValue, x=>SqlFunc.ToTime(x.CreatedTime.ToString("HH:mm:ss")) >= startHourTo.Value && SqlFunc.ToTime(x.CreatedTime.ToString("HH:mm:ss")) < endHourTo)
|
|
|
.Select(x=> new {
|
|
|
CPN = x.CPN,
|
|
|
CDPN= x.CDPN,
|