|
@@ -33,6 +33,7 @@ public class BiCallController : BaseController
|
|
|
private readonly IMapper _mapper;
|
|
|
private readonly ITrCallRecordRepository _trCallRecordRepositoryEx;
|
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
+ private readonly IRepository<Work> _workRepository;
|
|
|
|
|
|
|
|
|
|
|
@@ -42,7 +43,8 @@ public class BiCallController : BaseController
|
|
|
IRepository<TelRest> telRestRepository,
|
|
|
IMapper mapper,
|
|
|
ITrCallRecordRepository trCallRecordRepositoryEx,
|
|
|
- ISystemSettingCacheManager systemSettingCacheManager)
|
|
|
+ ISystemSettingCacheManager systemSettingCacheManager,
|
|
|
+ IRepository<Work> workRepository)
|
|
|
{
|
|
|
_trCallRecordRepository = trCallRecordRepository;
|
|
|
_userRepository = userRepository;
|
|
@@ -50,6 +52,7 @@ public class BiCallController : BaseController
|
|
|
_mapper = mapper;
|
|
|
_trCallRecordRepositoryEx = trCallRecordRepositoryEx;
|
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
+ _workRepository = workRepository;
|
|
|
}
|
|
|
|
|
|
[HttpGet("calls")]
|
|
@@ -124,8 +127,8 @@ public class BiCallController : BaseController
|
|
|
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]);
|
|
|
-
|
|
|
- return await _userRepository.Queryable()
|
|
|
+
|
|
|
+ var list = await _userRepository.Queryable()
|
|
|
.LeftJoin<TrCallRecord>((u, c) => u.Id == c.UserId)
|
|
|
.Where(u => !u.IsDeleted && u.UserType == EUserType.Seat)
|
|
|
.WhereIF(dto.StartTime.HasValue, (u, c) => c.CreatedTime >= dto.StartTime.Value)
|
|
@@ -147,27 +150,19 @@ public class BiCallController : BaseController
|
|
|
InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(SqlFunc.IIF(c.CallDirection == ECallDirection.In && c.AnsweredTime != null && c.Duration < connectByeTimes, 1, 0)),
|
|
|
})
|
|
|
.MergeTable()
|
|
|
- .LeftJoin<Work>((it, o) => it.UserId == o.UserId && o.CreationTime>= dto.StartTime && o.CreationTime<= dto.EndTime)
|
|
|
- .LeftJoin<TelRest>((it,o,c)=> it.UserId == c.UserId && c.CreationTime>= dto.StartTime && c.CreationTime<=dto.EndTime)
|
|
|
- .GroupBy((it, o,c) => new { it.UserId,it.Name })
|
|
|
- .Select((it, o,c) => new BiSeatCallsDto
|
|
|
- {
|
|
|
- Name = it.Name,
|
|
|
- UserId = it.UserId,
|
|
|
- InTotal = SqlFunc.AggregateSum(it.InTotal),
|
|
|
- OutTotal = SqlFunc.AggregateSum(it.OutTotal),
|
|
|
- InAnswered = SqlFunc.AggregateSum(it.InAnswered),
|
|
|
- OutAnswered = SqlFunc.AggregateSum(it.OutAnswered),
|
|
|
- InHangupImmediate = SqlFunc.AggregateSum(it.InHangupImmediate),
|
|
|
- InHanguped = SqlFunc.AggregateSum(it.InHanguped),
|
|
|
- InDurationAvg = SqlFunc.AggregateSum(it.InDurationAvg),
|
|
|
- OutDurationAvg = SqlFunc.AggregateSum(it.OutDurationAvg),
|
|
|
- InAvailableAnswer = SqlFunc.AggregateSum(it.InAvailableAnswer),
|
|
|
- InHangupImmediateWhenAnswered = SqlFunc.AggregateSum(it.InHangupImmediateWhenAnswered),
|
|
|
- LoginDuration = SqlFunc.AggregateSum(SqlFunc.IIF(o.WorkingDuration!=null, o.WorkingDuration.Value,0)),
|
|
|
- RestDuration = SqlFunc.AggregateSum(SqlFunc.IIF(c.RestDuration!=0,c.RestDuration,0)),
|
|
|
- })
|
|
|
.ToListAsync(HttpContext.RequestAborted);
|
|
|
+
|
|
|
+
|
|
|
+ list.ForEach(d=>
|
|
|
+ {
|
|
|
+ d.LoginDuration = _workRepository.Queryable().Where(q => q.UserId == d.UserId && q.CreationTime >= dto.StartTime && q.CreationTime <= dto.EndTime).Sum(q => q.WorkingDuration);
|
|
|
+ d.LoginDuration = Math.Round(d.LoginDuration.Value,2);
|
|
|
+ d.RestDuration = _telRestRepository.Queryable().Where(q => q.UserId == d.UserId && q.CreationTime >= dto.StartTime && q.CreationTime <= dto.EndTime).Sum(q => q.RestDuration);
|
|
|
+ d.RestDuration = Math.Round(d.RestDuration, 2);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|