|
@@ -1,6 +1,7 @@
|
|
|
using Hotline.CallCenter.Calls;
|
|
|
using Hotline.Share.Dtos.CallCenter;
|
|
|
using Hotline.Share.Enums.CallCenter;
|
|
|
+using Hotline.Share.Enums.User;
|
|
|
using Hotline.Share.Requests;
|
|
|
using Hotline.Users;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
@@ -63,7 +64,7 @@ public class BiCallController : BaseController
|
|
|
})
|
|
|
.OrderBy(d => d.Hour)
|
|
|
.ToListAsync(HttpContext.RequestAborted);
|
|
|
-
|
|
|
+
|
|
|
if (items.Count < 24)
|
|
|
{
|
|
|
for (var i = 0; i < 24; i++)
|
|
@@ -83,9 +84,31 @@ public class BiCallController : BaseController
|
|
|
[AllowAnonymous]
|
|
|
public async Task<IReadOnlyList<BiSeatCallsDto>> QuerySeatCallsAsync([FromQuery] ReportPagedRequest dto)
|
|
|
{
|
|
|
- //_userRepository.Queryable()
|
|
|
- // .LeftJoin<TrCallRecord>()
|
|
|
+ //from config
|
|
|
+ var hangupSeconds = 5;
|
|
|
|
|
|
- throw new NotImplementedException();
|
|
|
+ return await _userRepository.Queryable()
|
|
|
+ .LeftJoin<TrCallRecord>((u, c) => u.Id == c.UserId)
|
|
|
+ .Where(u => !u.IsDeleted && u.UserType == EUserType.Seat)
|
|
|
+ .WhereIF(dto.StartTime.HasValue, (_, c) => c.CreatedTime >= dto.StartTime.Value)
|
|
|
+ .WhereIF(dto.EndTime.HasValue, (_, c) => c.CreatedTime <= dto.EndTime.Value)
|
|
|
+ .GroupBy((u, c) => new { c.UserName, c.TelNo })
|
|
|
+ .Select((u, c) => new BiSeatCallsDto
|
|
|
+ {
|
|
|
+ Name = c.UserName,
|
|
|
+ TelNo = c.TelNo,
|
|
|
+ InTotal = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In, 1, 0)),
|
|
|
+ OutTotal = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.Out, 1, 0)),
|
|
|
+ InAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null, 1, 0)),
|
|
|
+ OutAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.Out && c.AnsweredTime != null, 1, 0)),
|
|
|
+ InHangupImmediate = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime == null && c.RingTimes < hangupSeconds, 1, 0)),
|
|
|
+ InHanguped = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime == null, 1, 0)),
|
|
|
+ InDurationAvg = SqlFunc.AggregateAvg(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null, c.Duration, 0)),
|
|
|
+ OutDurationAvg = SqlFunc.AggregateAvg(SqlFunc.IIF(c.CallDirection == ECallDirection.Out && c.AnsweredTime != null, c.Duration, 0)),
|
|
|
+ InAvailableAnswer = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null && c.Duration >= hangupSeconds, 1, 0)),
|
|
|
+ InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null && c.Duration < hangupSeconds, 1, 0)),
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .ToListAsync(HttpContext.RequestAborted);
|
|
|
}
|
|
|
}
|