|
@@ -6,6 +6,7 @@ using Hotline.Share.Dtos.CallCenter;
|
|
|
using Hotline.Share.Dtos.TrCallCenter;
|
|
|
using Hotline.Share.Enums.CallCenter;
|
|
|
using SqlSugar;
|
|
|
+using XF.Domain.Authentications;
|
|
|
using XF.Domain.Dependency;
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
|
@@ -13,8 +14,15 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
{
|
|
|
public class TrCallRecordRepository : BaseRepository<TrCallRecord>, ITrCallRecordRepository, IScopeDependency
|
|
|
{
|
|
|
- public TrCallRecordRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
|
|
|
+ private readonly ISessionContext _sessionContext;
|
|
|
+
|
|
|
+ public TrCallRecordRepository(
|
|
|
+ ISugarUnitOfWork<HotlineDbContext> uow,
|
|
|
+ IDataPermissionFilterBuilder dataPermissionFilterBuilder,
|
|
|
+ IServiceProvider serviceProvider,
|
|
|
+ ISessionContext sessionContext) : base(uow, dataPermissionFilterBuilder, serviceProvider)
|
|
|
{
|
|
|
+ _sessionContext = sessionContext;
|
|
|
}
|
|
|
|
|
|
public async Task<List<BiCallDto>> GetQueryCalls(DateTime beginDate, DateTime endDate, string? Line)
|
|
@@ -83,7 +91,7 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
|
|
|
var list = Db.Queryable<TrCallRecord>()
|
|
|
.Where(p => p.CreatedTime >= beginDate && p.CreatedTime <= endDate)
|
|
|
- // .Where(p => p.Gateway != "82826886" && SqlFunc.Length(p.Gateway) != 4)
|
|
|
+ // .Where(p => p.Gateway != "82826886" && SqlFunc.Length(p.Gateway) != 4)
|
|
|
.WhereIF(!string.IsNullOrEmpty(Line), p => p.Gateway == Line)
|
|
|
.GroupBy(p => p.CreatedTime.Hour)
|
|
|
.Select(p => new
|
|
@@ -178,13 +186,13 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 通话时段统计明细
|
|
|
- /// </summary>
|
|
|
- /// <returns></returns>
|
|
|
- public async Task<TotalData<BiSeatSwitchDto>> GetCallList(QueryCallListDto dto, int noConnectByeTimes, int effectiveTimes, int connectByeTimes)
|
|
|
- {
|
|
|
- TimeSpan endHourTo = DateTime.Now.TimeOfDay;
|
|
|
+ /// <summary>
|
|
|
+ /// 通话时段统计明细
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<TotalData<BiSeatSwitchDto>> GetCallList(QueryCallListDto dto, int noConnectByeTimes, int effectiveTimes, int connectByeTimes)
|
|
|
+ {
|
|
|
+ TimeSpan endHourTo = DateTime.Now.TimeOfDay;
|
|
|
if (dto.StartHourTo.HasValue)
|
|
|
{
|
|
|
endHourTo = dto.StartHourTo.Value.Add(new TimeSpan(1, 0, 0));
|
|
@@ -213,16 +221,16 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
CDPN = x.CDPN,
|
|
|
CreatedTime = x.CreatedTime
|
|
|
})
|
|
|
- .OrderByIF(dto is { SortRule: 0, SortField: "createdTime" }, x => x.CreatedTime, OrderByType.Asc)
|
|
|
- .OrderByIF(dto is { SortRule: 1, SortField: "createdTime" }, x => x.CreatedTime, OrderByType.Desc)
|
|
|
- .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
+ .OrderByIF(dto is { SortRule: 0, SortField: "createdTime" }, x => x.CreatedTime, OrderByType.Asc)
|
|
|
+ .OrderByIF(dto is { SortRule: 1, SortField: "createdTime" }, x => x.CreatedTime, OrderByType.Desc)
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
return new TotalData<BiSeatSwitchDto>(res, total.Value);
|
|
|
}
|
|
|
|
|
|
public async Task<List<CallHotLineDto>> GetCallHotLineList(DateTime beginDate, DateTime endDate, string lineNum, int noConnectByeTimes, int effectiveTimes, int connectByeTimes, int ringTims)
|
|
|
{
|
|
|
var list = await Db.Queryable<TrCallRecord>()
|
|
|
- .Where(x => x.CreatedTime >= beginDate && x.CreatedTime <= endDate && SqlFunc.Length(x.Gateway)>4)
|
|
|
+ .Where(x => x.CreatedTime >= beginDate && x.CreatedTime <= endDate && SqlFunc.Length(x.Gateway) > 4)
|
|
|
.WhereIF(!string.IsNullOrEmpty(lineNum), x => x.Gateway == lineNum)
|
|
|
.GroupBy(x => x.Gateway)
|
|
|
.Select(x => new CallHotLineDto()
|
|
@@ -243,55 +251,45 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
|
|
|
public ISugarQueryable<TrCallRecord> GetCallList(GetCallListDto dto)
|
|
|
{
|
|
|
- return Db.Queryable<TrCallRecord>()
|
|
|
- .Includes(x => x.Order)
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.CPN), x => x.CPN.Contains(dto.CPN))
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.CDPN), x => x.CDPN.Contains(dto.CDPN))
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.TelNo), x => x.TelNo.Contains(dto.TelNo))
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
|
|
|
- .WhereIF(dto.CallDirection != null, x => x.CallDirection == dto.CallDirection)
|
|
|
- .WhereIF(dto.OnState != null, x => x.OnState == dto.OnState)
|
|
|
- .WhereIF(dto.EndBy != null, x => x.EndBy == dto.EndBy)
|
|
|
-
|
|
|
- .WhereIF(dto.BeginIvrTimeStart.HasValue, x => x.BeginIvrTime >= dto.BeginIvrTimeStart)
|
|
|
- .WhereIF(dto.BeginIvrTimeEnd.HasValue, x => x.BeginIvrTime <= dto.BeginIvrTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(dto.EndIvrTimeStart.HasValue, x => x.EndIvrTime >= dto.EndIvrTimeStart)
|
|
|
- .WhereIF(dto.EndIvrTimeEnd.HasValue, x => x.EndIvrTime <= dto.EndIvrTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(dto.BeginQueueTimeStart.HasValue, x => x.BeginQueueTime >= dto.BeginQueueTimeEnd)
|
|
|
- .WhereIF(dto.BeginQueueTimeEnd.HasValue, x => x.BeginQueueTime <= dto.BeginQueueTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(dto.EndQueueTimeStart.HasValue, x => x.EndQueueTime >= dto.EndQueueTimeStart)
|
|
|
- .WhereIF(dto.EndQueueTimeEnd.HasValue, x => x.EndQueueTime <= dto.EndQueueTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(dto.AnsweredTimeStart.HasValue, x => x.AnsweredTime >= dto.AnsweredTimeStart)
|
|
|
- .WhereIF(dto.AnsweredTimeEnd.HasValue, x => x.AnsweredTime <= dto.AnsweredTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(dto.OverTimeStart.HasValue, x => x.OverTime >= dto.OverTimeStart)
|
|
|
- .WhereIF(dto.OverTimeEnd.HasValue, x => x.OverTime <= dto.OverTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(dto.BeginRingTimeStart.HasValue, x => x.BeginRingTime >= dto.BeginRingTimeStart)
|
|
|
- .WhereIF(dto.BeginRingTimeEnd.HasValue, x => x.BeginRingTime <= dto.BeginRingTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(dto.EndRingTimeStart.HasValue, x => x.EndRingTimg >= dto.EndRingTimeStart)
|
|
|
- .WhereIF(dto.EndRingTimeEnd.HasValue, x => x.EndRingTimg <= dto.EndRingTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(dto.CallTimeStart.HasValue, x => x.CreatedTime >= dto.CallTimeStart)
|
|
|
- .WhereIF(dto.CallTimeEnd.HasValue, x => x.CreatedTime <= dto.CallTimeEnd)
|
|
|
-
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.OrderNo), x => x.Order.No.Contains(dto.OrderNo))
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.Title), x => x.Order.Title.Contains(dto.Title))
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.Gateway), x => x.Gateway.Contains(dto.Gateway))
|
|
|
- .WhereIF(dto.IsSensitiveWord.HasValue && dto.IsSensitiveWord == true, d => d.Sensitive != null && SqlFunc.JsonArrayLength(d.Sensitive) > 0)
|
|
|
- .WhereIF(!string.IsNullOrEmpty(dto.SensitiveWord), d => SqlFunc.JsonArrayAny(d.Sensitive, dto.SensitiveWord))
|
|
|
- .WhereIF(dto.IsAiAnswered == true, x => string.IsNullOrEmpty(x.UserId) == true && x.BeginIvrTime.HasValue && x.EndIvrTime.HasValue)
|
|
|
-
|
|
|
- .WhereIF(dto.PhoneTypes != null, x => x.PhoneTypes == dto.PhoneTypes)
|
|
|
- .OrderByDescending(x => x.CreatedTime);
|
|
|
+ return Db.Queryable<TrCallRecord>()
|
|
|
+ .Includes(x => x.Order)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.CPN), x => x.CPN.Contains(dto.CPN))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.CDPN), x => x.CDPN.Contains(dto.CDPN))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.TelNo), x => x.TelNo.Contains(dto.TelNo))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UserName), x => x.UserName.Contains(dto.UserName))
|
|
|
+ .WhereIF(dto.CallDirection != null, x => x.CallDirection == dto.CallDirection)
|
|
|
+ .WhereIF(dto.OnState != null, x => x.OnState == dto.OnState)
|
|
|
+ .WhereIF(dto.EndBy != null, x => x.EndBy == dto.EndBy)
|
|
|
+ .WhereIF(dto.BeginIvrTimeStart.HasValue, x => x.BeginIvrTime >= dto.BeginIvrTimeStart)
|
|
|
+ .WhereIF(dto.BeginIvrTimeEnd.HasValue, x => x.BeginIvrTime <= dto.BeginIvrTimeEnd)
|
|
|
+ .WhereIF(dto.EndIvrTimeStart.HasValue, x => x.EndIvrTime >= dto.EndIvrTimeStart)
|
|
|
+ .WhereIF(dto.EndIvrTimeEnd.HasValue, x => x.EndIvrTime <= dto.EndIvrTimeEnd)
|
|
|
+ .WhereIF(dto.BeginQueueTimeStart.HasValue, x => x.BeginQueueTime >= dto.BeginQueueTimeEnd)
|
|
|
+ .WhereIF(dto.BeginQueueTimeEnd.HasValue, x => x.BeginQueueTime <= dto.BeginQueueTimeEnd)
|
|
|
+ .WhereIF(dto.EndQueueTimeStart.HasValue, x => x.EndQueueTime >= dto.EndQueueTimeStart)
|
|
|
+ .WhereIF(dto.EndQueueTimeEnd.HasValue, x => x.EndQueueTime <= dto.EndQueueTimeEnd)
|
|
|
+ .WhereIF(dto.AnsweredTimeStart.HasValue, x => x.AnsweredTime >= dto.AnsweredTimeStart)
|
|
|
+ .WhereIF(dto.AnsweredTimeEnd.HasValue, x => x.AnsweredTime <= dto.AnsweredTimeEnd)
|
|
|
+ .WhereIF(dto.OverTimeStart.HasValue, x => x.OverTime >= dto.OverTimeStart)
|
|
|
+ .WhereIF(dto.OverTimeEnd.HasValue, x => x.OverTime <= dto.OverTimeEnd)
|
|
|
+ .WhereIF(dto.BeginRingTimeStart.HasValue, x => x.BeginRingTime >= dto.BeginRingTimeStart)
|
|
|
+ .WhereIF(dto.BeginRingTimeEnd.HasValue, x => x.BeginRingTime <= dto.BeginRingTimeEnd)
|
|
|
+ .WhereIF(dto.EndRingTimeStart.HasValue, x => x.EndRingTimg >= dto.EndRingTimeStart)
|
|
|
+ .WhereIF(dto.EndRingTimeEnd.HasValue, x => x.EndRingTimg <= dto.EndRingTimeEnd)
|
|
|
+ .WhereIF(dto.CallTimeStart.HasValue, x => x.CreatedTime >= dto.CallTimeStart)
|
|
|
+ .WhereIF(dto.CallTimeEnd.HasValue, x => x.CreatedTime <= dto.CallTimeEnd)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.OrderNo), x => x.Order.No.Contains(dto.OrderNo))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Title), x => x.Order.Title.Contains(dto.Title))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Gateway), x => x.Gateway.Contains(dto.Gateway))
|
|
|
+ .WhereIF(dto.IsSensitiveWord.HasValue && dto.IsSensitiveWord == true, d => d.Sensitive != null && SqlFunc.JsonArrayLength(d.Sensitive) > 0)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.SensitiveWord), d => SqlFunc.JsonArrayAny(d.Sensitive, dto.SensitiveWord))
|
|
|
+ .WhereIF(dto.IsAiAnswered == true, x => string.IsNullOrEmpty(x.UserId) == true && x.BeginIvrTime.HasValue && x.EndIvrTime.HasValue)
|
|
|
+ .WhereIF(dto.PhoneTypes != null, x => x.PhoneTypes == dto.PhoneTypes)
|
|
|
+ .WhereIF(dto.QuerySelf.HasValue && dto.QuerySelf == true, x => x.UserId == _sessionContext.UserId)
|
|
|
+ .OrderByDescending(x => x.CreatedTime);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
public async Task<List<QueryCallDateStatisticsDetailResp>> QueryCallDateStatisticsDetail(DateTime startTime, DateTime endTime)
|
|
|
{
|
|
|
var query = Db.Queryable<TrCallRecord>()
|
|
@@ -315,7 +313,7 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
IvrRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.BeginIvrTime.HasValue && !x.BeginQueueTime.HasValue && !x.BeginRingTime.HasValue && x.OnState == EOnState.NoOn, 1, 0)), //IVR挂断
|
|
|
})
|
|
|
.OrderBy(x => x.Date);
|
|
|
- return await query.ToListAsync();
|
|
|
+ return await query.ToListAsync();
|
|
|
}
|
|
|
|
|
|
public async Task<List<QueryPersonCallDateStatisticsDetailResp>> QueryPersonCallDateStatisticsDetail(DateTime startTime, DateTime endTime)
|
|
@@ -330,13 +328,13 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
PersonCallInPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.OnState == EOnState.On, 1, 0)),
|
|
|
//PersonRingOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.OnState == EOnState.NoOn, 1, 0)),//个人服务挂断
|
|
|
PersonQueueOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.QueueTims > 0 && x.RingTimes == 0 && x.OnState == EOnState.NoOn, 1, 0)),//个人服务队列挂断
|
|
|
- PersonWaitOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length -1,1) =="1" && x.RingTimes>0 && x.OnState == EOnState.NoOn,1,0)) //个人服务等待挂断
|
|
|
+ PersonWaitOffCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.IvrDtmf.Substring(x.IvrDtmf.Length - 1, 1) == "1" && x.RingTimes > 0 && x.OnState == EOnState.NoOn, 1, 0)) //个人服务等待挂断
|
|
|
})
|
|
|
.OrderBy(x => x.Date);
|
|
|
return await query.ToListAsync();
|
|
|
}
|
|
|
|
|
|
- public async Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail(DateTime startTime,DateTime endTime)
|
|
|
+ public async Task<List<QueryEnterpriseCallDateStatisticsDetailResp>> QueryEnterpriseCallDateStatisticsDetail(DateTime startTime, DateTime endTime)
|
|
|
{
|
|
|
var query = Db.Queryable<TrCallRecord>()
|
|
|
.Where(x => x.CreatedTime >= startTime && x.CreatedTime <= endTime && SqlFunc.Length(x.Gateway) > 4 && x.CallDirection == ECallDirection.In)
|
|
@@ -354,28 +352,28 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
return await query.ToListAsync();
|
|
|
}
|
|
|
|
|
|
- public async Task<List<QueryCallOutDateStatisticsDetailResp>> QueryCallOutDateStatisticsDetail(DateTime startTime,DateTime endTime,List<string> enterpriseTels)
|
|
|
+ public async Task<List<QueryCallOutDateStatisticsDetailResp>> QueryCallOutDateStatisticsDetail(DateTime startTime, DateTime endTime, List<string> enterpriseTels)
|
|
|
{
|
|
|
var callTable = Db.Queryable<TrCallRecord>()
|
|
|
- .Where(x => x.CreatedTime >= startTime && x.CreatedTime <= endTime && SqlFunc.Length(x.Gateway) > 4 && x.CallDirection == ECallDirection.Out && SqlFunc.Length(x.TelNo)==4)
|
|
|
+ .Where(x => x.CreatedTime >= startTime && x.CreatedTime <= endTime && SqlFunc.Length(x.Gateway) > 4 && x.CallDirection == ECallDirection.Out && SqlFunc.Length(x.TelNo) == 4)
|
|
|
.GroupBy(x => x.CreatedTime.ToString("yyyy-MM-dd"))
|
|
|
.Select(x => new QueryCallOutDateStatisticsDetailResp()
|
|
|
{
|
|
|
Date = x.CreatedTime.ToString("yyyy-MM-dd"),
|
|
|
- PersonCallOutCount = SqlFunc.AggregateSum(SqlFunc.IIF(1 == 1 && !enterpriseTels.Contains(x.TelNo),1,0)),
|
|
|
- EnterpriseCallOutCount = SqlFunc.AggregateSum(SqlFunc.IIF(1== 1 && enterpriseTels.Contains(x.TelNo),1,0)),
|
|
|
+ PersonCallOutCount = SqlFunc.AggregateSum(SqlFunc.IIF(1 == 1 && !enterpriseTels.Contains(x.TelNo), 1, 0)),
|
|
|
+ EnterpriseCallOutCount = SqlFunc.AggregateSum(SqlFunc.IIF(1 == 1 && enterpriseTels.Contains(x.TelNo), 1, 0)),
|
|
|
PersonCallOutPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(!enterpriseTels.Contains(x.TelNo) && x.OnState == EOnState.On, 1, 0)),
|
|
|
EnterpriseCallOutPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(enterpriseTels.Contains(x.TelNo) && x.OnState == EOnState.On, 1, 0)),
|
|
|
}).MergeTable();
|
|
|
|
|
|
- var aiVisitCallTable = Db.Queryable<AiOrderVisitDetail>()
|
|
|
+ var aiVisitCallTable = Db.Queryable<AiOrderVisitDetail>()
|
|
|
.Where(x => x.CallTime >= startTime && x.CallTime <= endTime)
|
|
|
.GroupBy(x => x.CallTime.Value.ToString("yyyy-MM-dd"))
|
|
|
.Select(x => new QueryCallOutDateStatisticsDetailResp()
|
|
|
{
|
|
|
Date = x.CallTime.Value.ToString("yyyy-MM-dd"),
|
|
|
AiVisitCallOutCount = SqlFunc.AggregateCount(x.Id),
|
|
|
- AiVisitCallOutPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.AiIsContact!=null || x.AiVolved!=null || x.AiOrgProcessingResults != null ,1,0))
|
|
|
+ AiVisitCallOutPutthroughCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.AiIsContact != null || x.AiVolved != null || x.AiOrgProcessingResults != null, 1, 0))
|
|
|
}).MergeTable();
|
|
|
|
|
|
var list = await callTable.LeftJoin(aiVisitCallTable, (a, b) => a.Date == b.Date)
|
|
@@ -386,11 +384,11 @@ namespace Hotline.Repository.SqlSugar.CallCenter
|
|
|
EnterpriseCallOutCount = a.EnterpriseCallOutCount,
|
|
|
AiVisitCallOutCount = b.AiVisitCallOutCount,
|
|
|
AiCallOutCount = 0,
|
|
|
- PersonCallOutPutthroughCount= a.PersonCallOutPutthroughCount,
|
|
|
+ PersonCallOutPutthroughCount = a.PersonCallOutPutthroughCount,
|
|
|
EnterpriseCallOutPutthroughCount = a.EnterpriseCallOutPutthroughCount,
|
|
|
AiVisitCallOutPutthroughCount = b.AiVisitCallOutPutthroughCount,
|
|
|
AiCallOutPutthroughCount = 0,
|
|
|
- }).OrderBy(a=>a.Date).ToListAsync();
|
|
|
+ }).OrderBy(a => a.Date).ToListAsync();
|
|
|
return list;
|
|
|
}
|
|
|
|