|
@@ -12,6 +12,10 @@ using SqlSugar;
|
|
|
using Hotline.Share.Requests;
|
|
|
using Hotline.Users;
|
|
|
using XF.Domain.Repository;
|
|
|
+using Hotline.Caching.Services;
|
|
|
+using Hotline.Share.Dtos.CallCenter;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
+using Hotline.Caching.Interfaces;
|
|
|
|
|
|
namespace Hotline.Api.Controllers.Bi
|
|
|
{
|
|
@@ -19,16 +23,21 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
{
|
|
|
private readonly IOrderRepository _orderRepository;
|
|
|
private readonly IRepository<Hotspot> _hotspotTypeRepository;
|
|
|
+ private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
|
|
|
+ private readonly IRepository<OrderVisitDetail> _orderVisitDetailRepository;
|
|
|
|
|
|
- public BiOrderController(
|
|
|
+ public BiOrderController(
|
|
|
IOrderRepository orderRepository,
|
|
|
- IRepository<Hotspot> hotspotTypeRepository
|
|
|
+ IRepository<Hotspot> hotspotTypeRepository,
|
|
|
+ ISystemDicDataCacheManager sysDicDataCacheManager,
|
|
|
+ IRepository<OrderVisitDetail> orderVisitDetailRepository
|
|
|
)
|
|
|
{
|
|
|
_orderRepository = orderRepository;
|
|
|
_hotspotTypeRepository = hotspotTypeRepository;
|
|
|
-
|
|
|
- }
|
|
|
+ _sysDicDataCacheManager = sysDicDataCacheManager;
|
|
|
+ _orderVisitDetailRepository = orderVisitDetailRepository;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 部门数据统计
|
|
@@ -145,5 +154,42 @@ namespace Hotline.Api.Controllers.Bi
|
|
|
return new PagedDto<HotspotDataLsitVo>(total, items);
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 部门不满意统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("visit-nosatisfied")]
|
|
|
+ [AllowAnonymous]
|
|
|
+ public async Task<object> QueryVisitNoSatisfied([FromQuery] QueryVisitNoSatiisfiedRequest dto)
|
|
|
+ {
|
|
|
+ var dissatisfiedReason = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.DissatisfiedReason);
|
|
|
+
|
|
|
+ List<dynamic>? list = new List<dynamic>();
|
|
|
+ foreach (var item in dissatisfiedReason)
|
|
|
+ {
|
|
|
+ var table = _orderVisitDetailRepository.Queryable()
|
|
|
+ .Includes(x => x.OrderVisit)
|
|
|
+ .Where(x => x.VisitTarget == Share.Enums.Order.EVisitTarget.Org)
|
|
|
+ .Where(x => x.OrgNoSatisfiedReason != null)
|
|
|
+ .Where(x => !string.IsNullOrEmpty(x.VisitOrgName))
|
|
|
+ .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)
|
|
|
+ .GroupBy(x => new { x.VisitOrgName, x.VisitOrgCode })
|
|
|
+ .Select(x => new BiVisitNoSatisfiedDto
|
|
|
+ {
|
|
|
+ Count = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonListObjectAny(x.OrgNoSatisfiedReason, "Key", item.DicDataValue), 1, 0)),
|
|
|
+ Key = item.DicDataValue,
|
|
|
+ OrgName = x.VisitOrgName
|
|
|
+ })
|
|
|
+ .OrderByDescending(x => x.Count)
|
|
|
+ .ToPivotList(x => x.Key, x => x.OrgName, x => x.Sum(x => x.Count));
|
|
|
+ list.AddRange(table);
|
|
|
+ }
|
|
|
+ return new { DicReason = dissatisfiedReason, Data = list };
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|