|
@@ -16,10 +16,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;
|
|
|
|
|
@@ -41,6 +40,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(
|
|
@@ -57,7 +57,8 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
IRepository<OrderPublish> orderPublishRepository,
|
|
|
IRepository<SystemOrganize> systemOrganizeRepository,
|
|
|
IRepository<AiOrderVisitDetail> aiOrderVisitDetailRepository,
|
|
|
- ISessionContext sessionContext
|
|
|
+ ISessionContext sessionContext,
|
|
|
+ ISystemSettingCacheManager systemSettingCacheManager
|
|
|
)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
@@ -74,6 +75,7 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
_systemOrganizeRepository = systemOrganizeRepository;
|
|
|
_aiOrderVisitDetailRepository = aiOrderVisitDetailRepository;
|
|
|
_sessionContext = sessionContext;
|
|
|
+ _systemSettingCacheManager = systemSettingCacheManager;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -345,7 +347,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
|
|
|
{
|
|
@@ -413,7 +415,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
|
|
|
{
|
|
@@ -446,7 +448,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
|
|
|
{
|
|
@@ -492,7 +494,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));
|
|
@@ -584,7 +586,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>
|
|
@@ -720,7 +722,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"))
|
|
@@ -820,7 +822,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"))
|
|
@@ -1166,7 +1168,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,
|
|
@@ -1344,6 +1346,49 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
}).ToListAsync();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 高频来电统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="StartDate"></param>
|
|
|
+ /// <param name="EndDate"></param>
|
|
|
+ /// <param name="PhoneNum"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("high_frequency_call_statistics")]
|
|
|
+ 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)
|
|
|
+ .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;
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 高频事项预警
|
|
|
/// </summary>
|
|
@@ -1418,6 +1463,73 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
.OrderByDescending(d => d.CreationTime)
|
|
|
.ToPagedListAsync(dto, HttpContext.RequestAborted);
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 高频来电统计列表详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("high_frequency_call_statistics_order_list")]
|
|
|
+ public async Task<PagedDto<OrderDto>> HighFrequencyCallStatisticsOrderList([FromQuery] HighFrequencyCallStatisticsRequest dto)
|
|
|
+ {
|
|
|
+ if (!dto.StartDate.HasValue || !dto.EndDate.HasValue)
|
|
|
+ throw UserFriendlyException.SameMessage("请选择时间!");
|
|
|
+ if (string.IsNullOrEmpty(dto.FromPhone))
|
|
|
+ throw UserFriendlyException.SameMessage("号码不能为空!");
|
|
|
+
|
|
|
+ dto.EndDate = dto.EndDate.Value.AddDays(1).AddSeconds(-1);
|
|
|
+ var data = await _trCallRecordRepository.Queryable()
|
|
|
+ .LeftJoin<Order>((p, o) => p.ExternalId == o.Id)
|
|
|
+ .Where((p, o) => p.OverTime >= dto.StartDate && p.OverTime <= dto.EndDate)
|
|
|
+ .Where((p, o) => p.CallOrderType == ECallOrderType.Order)
|
|
|
+ .Where((p, o) => p.ExternalId != null && o.Id != null)
|
|
|
+ .Where((p, o) => p.CPN == dto.FromPhone)
|
|
|
+ .Select((p, o) =>
|
|
|
+ p.ExternalId
|
|
|
+ )
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+
|
|
|
+ var (total, items) = await _orderRepository.Queryable()
|
|
|
+ .Includes(x => x.OrderScreens)
|
|
|
+ .Where(p => data.Contains(p.Id))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.Title.Contains(dto.Keyword!)) //标题
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.ProvinceNo), d => d.ProvinceNo.Contains(dto.ProvinceNo)) //省本地编号
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.No), d => d.No.Contains(dto.No)) //工单编码
|
|
|
+ .WhereIF(dto.AcceptTypes.Any(), d => dto.AcceptTypes.Contains(d.AcceptTypeCode)) //受理类型
|
|
|
+ .WhereIF(dto.Channels.Any(), d => dto.Channels.Contains(d.SourceChannelCode)) //来源渠道
|
|
|
+ .WhereIF(dto.HotspotIds.Any(), d => dto.HotspotIds.Contains(d.HotspotId)) //热点类型
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.TransferPhone), d => d.TransferPhone.Contains(dto.TransferPhone!)) //转接号码
|
|
|
+ .WhereIF(dto.OrgCodes.Any(), d => dto.OrgCodes.Contains(d.ActualHandleOrgCode)) //接办部门
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.NameOrNo), d => d.AcceptorName.Contains(dto.NameOrNo!) || d.AcceptorStaffNo.Contains(dto.NameOrNo!)) //受理人/坐席
|
|
|
+ .WhereIF(dto.CreationTimeStart.HasValue, d => d.CreationTime >= dto.CreationTimeStart) //受理时间开始
|
|
|
+ .WhereIF(dto.CreationTimeEnd.HasValue, d => d.CreationTime <= dto.CreationTimeEnd) //受理时间结束
|
|
|
+ .WhereIF(dto.EmergencyLevels.Any(), d => dto.EmergencyLevels.Contains(d.EmergencyLevel)) //紧急程度
|
|
|
+ // .WhereIF(!string.IsNullOrEmpty(dto.FromPhone), d => d.FromPhone.Contains(dto.FromPhone)) //来电号码
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.PhoneNo), d => d.Contact.Contains(dto.PhoneNo!)) //联系电话
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.PushTypeCode), d => d.PushTypeCode == dto.PushTypeCode) //推送分类
|
|
|
+ .WhereIF(dto.ExpiredTimeStart.HasValue, d => d.ExpiredTime >= dto.ExpiredTimeStart) //超期时间开始
|
|
|
+ .WhereIF(dto.ExpiredTimeEnd.HasValue, d => d.ExpiredTime <= dto.ExpiredTimeEnd) //超期时间结束
|
|
|
+ .WhereIF(dto.Statuses.Any(), d => dto.Statuses.Contains(d.Status)) //工单状态
|
|
|
+ .WhereIF(dto.Statuses.Any(d => d == EOrderStatus.SpecialToUnAccept), d => d.Status <= EOrderStatus.SpecialToUnAccept)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.ActualHandlerName), d => d.ActualHandlerName.Contains(dto.ActualHandlerName)) //接办人
|
|
|
+ .WhereIF(dto.IsScreen == true, d => d.OrderScreens.Any(x => x.Status != EScreenStatus.Refuse)) //有甄别
|
|
|
+ .WhereIF(dto.IsScreen == false, d => !d.OrderScreens.Any(x => x.Status != EScreenStatus.Refuse)) //无甄别
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.CurrentStepCode), d => d.ActualHandleStepCode == dto.CurrentStepCode) //当前办理节点
|
|
|
+ .WhereIF(dto.ActualHandleTimeStart.HasValue, d => d.ActualHandleTime >= dto.ActualHandleTimeStart) //办结时间开始
|
|
|
+ .WhereIF(dto.ActualHandleTimeEnd.HasValue, d => d.ActualHandleTime <= dto.ActualHandleTimeEnd) //办结时间结束
|
|
|
+ .WhereIF(dto.IsOverTime == true, d => (d.ExpiredTime < DateTime.Now && d.Status < EOrderStatus.Filed) || (d.ExpiredTime < d.ActualHandleTime && d.Status >= EOrderStatus.Filed)) //是 超期
|
|
|
+ .WhereIF(dto.IsOverTime == false, d => (d.ExpiredTime > DateTime.Now && d.Status < EOrderStatus.Filed) || (d.ExpiredTime > d.ActualHandleTime && d.Status >= EOrderStatus.Filed)) //否 超期
|
|
|
+ .WhereIF(dto.IdentityType != null, d => d.IdentityType == dto.IdentityType) //来电主体
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.FromName), d => d.FromName.Contains(dto.FromName)) //来电人姓名
|
|
|
+ .WhereIF(dto.AreaCodes.Any(), d => dto.AreaCodes.Contains(d.AreaCode)) //区域
|
|
|
+ .WhereIF(dto.IsProvinceOrder.HasValue && dto.IsProvinceOrder == true, x => x.IsProvince == true)
|
|
|
+ .WhereIF(dto.IsProvinceOrder.HasValue && dto.IsProvinceOrder == false, x => x.IsProvince == false)
|
|
|
+ .OrderByDescending(d => d.CreationTime)
|
|
|
+ .ToPagedListAsync(dto, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ return new PagedDto<OrderDto>(total, _mapper.Map<IReadOnlyList<OrderDto>>(items));
|
|
|
+
|
|
|
+ }
|
|
|
return new PagedDto<OrderDto>(total, _mapper.Map<IReadOnlyList<OrderDto>>(items));
|
|
|
}
|
|
|
}
|