|
@@ -15,10 +15,9 @@ using Hotline.Share.Requests;
|
|
|
using MapsterMapper;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
-using SharpCompress.Archives;
|
|
|
using SqlSugar;
|
|
|
-using System.Transactions;
|
|
|
using XF.Domain.Authentications;
|
|
|
+using XF.Domain.Constants;
|
|
|
using XF.Domain.Exceptions;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
@@ -40,6 +39,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
private readonly IRepository<SystemOrganize> _systemOrganizeRepository;
|
|
|
private readonly IRepository<AiOrderVisitDetail> _aiOrderVisitDetailRepository;
|
|
|
private readonly ISessionContext _sessionContext;
|
|
|
+ private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
|
|
|
|
|
|
public BiOrderController(
|
|
@@ -56,7 +56,8 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
IRepository<OrderPublish> orderPublishRepository,
|
|
|
IRepository<SystemOrganize> systemOrganizeRepository,
|
|
|
IRepository<AiOrderVisitDetail> aiOrderVisitDetailRepository,
|
|
|
- ISessionContext sessionContext
|
|
|
+ ISessionContext sessionContext,
|
|
|
+ ISystemSettingCacheManager systemSettingCacheManager
|
|
|
)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
@@ -73,6 +74,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
_systemOrganizeRepository = systemOrganizeRepository;
|
|
|
_aiOrderVisitDetailRepository = aiOrderVisitDetailRepository;
|
|
|
_sessionContext = sessionContext;
|
|
|
+ _systemSettingCacheManager = systemSettingCacheManager;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -344,7 +346,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.OrgName), x => x.VisitOrgName.Contains(dto.OrgName))
|
|
|
.WhereIF(dto.StartTime.HasValue, x => x.OrderVisit.VisitTime >= dto.StartTime.Value)
|
|
|
.WhereIF(dto.EndTime.HasValue, x => x.OrderVisit.VisitTime <= dto.EndTime.Value)
|
|
|
- .WhereIF(IsCenter==false,x=>x.VisitOrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .WhereIF(IsCenter == false, x => x.VisitOrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
.GroupBy(x => new { x.VisitOrgName, x.VisitOrgCode })
|
|
|
.Select(x => new BiVisitNoSatisfiedDto
|
|
|
{
|
|
@@ -412,7 +414,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
.WhereIF(dto.StartTime.HasValue, (x, o) => x.CreationTime >= dto.StartTime)
|
|
|
.WhereIF(dto.EndTime.HasValue, (x, o) => x.CreationTime <= dto.EndTime)
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.OrgName), x => x.ApplyOrgName.Contains(dto.OrgName))
|
|
|
- .WhereIF(IsCenter==false,x=>x.ApplyOrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .WhereIF(IsCenter == false, x => x.ApplyOrgCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
.GroupBy(x => new { x.ApplyOrgCode, x.ApplyOrgName })
|
|
|
.Select(x => new BiOrderDelayDataDto
|
|
|
{
|
|
@@ -445,7 +447,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
var query = _orderSpecialRepository.Queryable()
|
|
|
.WhereIF(dto.StartTime.HasValue, x => x.CreationTime >= dto.StartTime)
|
|
|
.WhereIF(dto.EndTime.HasValue, x => x.CreationTime <= dto.EndTime)
|
|
|
- .WhereIF(IsCenter==false,x=>x.OrgId.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .WhereIF(IsCenter == false, x => x.OrgId.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
.GroupBy(x => new { x.Cause })
|
|
|
.Select(x => new OrderBiSpecialListVo
|
|
|
{
|
|
@@ -491,7 +493,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
.WhereIF(dto.StartTime.HasValue, x => x.CreationTime >= dto.StartTime)
|
|
|
.WhereIF(dto.EndTime.HasValue, x => x.CreationTime <= dto.EndTime)
|
|
|
.WhereIF(dto.State.HasValue, x => x.State == dto.State)
|
|
|
- .WhereIF(IsCenter==false,x=> x.OrgId.StartsWith(_sessionContext.OrgId))
|
|
|
+ .WhereIF(IsCenter == false, x => x.OrgId.StartsWith(_sessionContext.OrgId))
|
|
|
.OrderByDescending(x => x.CreationTime)
|
|
|
.ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
return new PagedDto<OrderSpecialDto>(total, _mapper.Map<IReadOnlyList<OrderSpecialDto>>(items));
|
|
@@ -583,7 +585,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
{
|
|
|
dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
|
var IsCenter = _sessionContext.OrgIsCenter;
|
|
|
- return await _orderRepository.HotPortJoinOrgStatistics(dto.StartTime, dto.EndTime,IsCenter,_sessionContext.OrgId);
|
|
|
+ return await _orderRepository.HotPortJoinOrgStatistics(dto.StartTime, dto.EndTime, IsCenter, _sessionContext.OrgId);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -719,7 +721,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
.Where(x => x.OrderVisit.VisitTime >= StartDate && x.OrderVisit.VisitTime <= EndDate && x.VisitTarget == EVisitTarget.Org && x.OrderVisit.VisitState == EVisitState.Visited && !string.IsNullOrEmpty(x.VisitOrgCode))
|
|
|
.WhereIF(!string.IsNullOrEmpty(OrgName), x => x.VisitOrgName.Contains(OrgName))
|
|
|
.WhereIF(!string.IsNullOrEmpty(LineNum), x => x.OrderVisit.Order.CallRecord.Gateway.Contains(LineNum))
|
|
|
- .WhereIF(IsCenter==false,x=>x.VisitOrgCode.StartsWith(_sessionContext.OrgId))
|
|
|
+ .WhereIF(IsCenter == false, x => x.VisitOrgCode.StartsWith(_sessionContext.OrgId))
|
|
|
.GroupBy(x => new
|
|
|
{
|
|
|
VisitOrgCode = x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))
|
|
@@ -819,7 +821,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
.LeftJoin<OrderVisitDetail>((x, it) => x.Id == it.VisitOrgCode)
|
|
|
.Where((x, it) => it.OrderVisit.VisitTime >= StartDate && it.OrderVisit.VisitTime <= EndDate && it.VisitTarget == EVisitTarget.Org && it.OrderVisit.VisitState == EVisitState.Visited)
|
|
|
.WhereIF(!string.IsNullOrEmpty(LineNum), (x, it) => it.OrderVisit.Order.CallRecord.Gateway.Contains(LineNum))
|
|
|
- .WhereIF(IsCenter == false, (x,it) => it.VisitOrgCode.StartsWith(_sessionContext.OrgId))
|
|
|
+ .WhereIF(IsCenter == false, (x, it) => it.VisitOrgCode.StartsWith(_sessionContext.OrgId))
|
|
|
.GroupBy((x, it) => new
|
|
|
{
|
|
|
VisitOrgCode = it.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("9"))
|
|
@@ -1165,7 +1167,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
.Where((it, o) => it.CreationTime >= StartDate && it.CreationTime <= EndDate && (int)it.Status >= 300)
|
|
|
.WhereIF(TypeCode == 1, (it, o) => it.OrgLevelOneCode == "001")
|
|
|
.WhereIF(TypeCode == 2, (it, o) => it.OrgLevelOneCode != "001")
|
|
|
- .WhereIF(IsCenter==false,(it,o)=> it.OrgLevelOneCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
+ .WhereIF(IsCenter == false, (it, o) => it.OrgLevelOneCode.StartsWith(_sessionContext.RequiredOrgId))
|
|
|
.GroupBy((it, o) => new
|
|
|
{
|
|
|
it.OrgLevelOneCode,
|
|
@@ -1343,7 +1345,89 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
}).ToListAsync();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 高频来电统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="StartDate"></param>
|
|
|
+ /// <param name="EndDate"></param>
|
|
|
+ /// <param name="UserName"></param>
|
|
|
+ /// <param name="PhoneNum"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("high_frequency_call_statistics")]
|
|
|
+ [AllowAnonymous]
|
|
|
+ public async Task<object> HighFrequencyCallStatistics(DateTime? StartDate, DateTime? EndDate, string PhoneNum)
|
|
|
+ {
|
|
|
+ if (!StartDate.HasValue || !EndDate.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+
|
|
|
+
|
|
|
+ int CallCount = 2;
|
|
|
+ var HighFrequencyCallStatistics = _systemSettingCacheManager.GetSetting(SettingConstants.HighFrequencyCallStatistics)?.SettingValue[0];
|
|
|
+ if (HighFrequencyCallStatistics != null)
|
|
|
+ CallCount = int.Parse(HighFrequencyCallStatistics);
|
|
|
+
|
|
|
+ EndDate = EndDate.Value.AddDays(1).AddSeconds(-1);
|
|
|
+ var data = await _trCallRecordRepository.Queryable()
|
|
|
+ .LeftJoin<Order>((p, o) => p.ExternalId == o.Id)
|
|
|
+ .Where((p, o) => p.OverTime >= StartDate && p.OverTime <= EndDate)
|
|
|
+ .Where((p, o) => p.CallOrderType == ECallOrderType.Order)
|
|
|
+ .Where((p, o) => p.ExternalId != null && o.Id != null)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(PhoneNum), (p, o) => p.CPN == PhoneNum)
|
|
|
+ // .Where(p=>p.OnState==EOnState.On)
|
|
|
+ .Select((p, o) => new
|
|
|
+ {
|
|
|
+ p.CPN,
|
|
|
+ p.ExternalId
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .GroupBy(p => p.CPN)
|
|
|
+ .Select(p => new
|
|
|
+ {
|
|
|
+ Callnum = p.CPN,
|
|
|
+ OrderCountNum = SqlFunc.AggregateCount(p.CPN),//总量
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .Where(p => p.OrderCountNum >= CallCount)
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
|
|
|
- //public async Task
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="StartDate"></param>
|
|
|
+ /// <param name="EndDate"></param>
|
|
|
+ /// <param name="PhoneNum"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("high_frequency_call_statistics_order_list")]
|
|
|
+ [AllowAnonymous]
|
|
|
+ public async Task<object> HighFrequencyCallStatisticsOrderList(DateTime? StartDate, DateTime? EndDate, string PhoneNum)
|
|
|
+ {
|
|
|
+ if (!StartDate.HasValue || !EndDate.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+ if (string.IsNullOrEmpty(PhoneNum))
|
|
|
+ throw UserFriendlyException.SameMessage("号码不能为空!");
|
|
|
+
|
|
|
+ EndDate = EndDate.Value.AddDays(1).AddSeconds(-1);
|
|
|
+ var data = _trCallRecordRepository.Queryable()
|
|
|
+ .LeftJoin<Order>((p, o) => p.ExternalId == o.Id)
|
|
|
+ .Where((p, o) => p.OverTime >= StartDate && p.OverTime <= EndDate)
|
|
|
+ .Where((p, o) => p.CallOrderType == ECallOrderType.Order)
|
|
|
+ .Where((p, o) => p.ExternalId != null && o.Id != null)
|
|
|
+ .Where((p, o) => p.CPN == PhoneNum)
|
|
|
+ // .Where(p=>p.OnState==EOnState.On)
|
|
|
+ .Select((p, o) => new
|
|
|
+ {
|
|
|
+ p.CPN,
|
|
|
+ p.ExternalId
|
|
|
+ })
|
|
|
+
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
}
|
|
|
}
|