|
@@ -1,12 +1,15 @@
|
|
|
using Hotline.KnowledgeBase;
|
|
|
using Hotline.Orders;
|
|
|
using Hotline.Repository.SqlSugar.Orders;
|
|
|
+using Hotline.Settings;
|
|
|
using Hotline.Settings.Hotspots;
|
|
|
using Hotline.Share.Dtos.Bigscreen;
|
|
|
using Hotline.Share.Enums.KnowledgeBase;
|
|
|
using Hotline.Share.Enums.Order;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.AspNetCore.Mvc.Formatters;
|
|
|
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
|
using SqlSugar;
|
|
|
using XF.Domain.Repository;
|
|
|
|
|
@@ -166,6 +169,7 @@ namespace Hotline.Api.Controllers.Bigscreen
|
|
|
[HttpGet("earlywarning-statistics")]
|
|
|
public async Task<List<EarlyWarningHotsPotsStatisticsDto>> EarlyWarningHotsPotsStatistics(DateTime StartDate, DateTime EndDate,string AreaCode)
|
|
|
{
|
|
|
+ EndDate = EndDate.AddDays(1).AddSeconds(-1);
|
|
|
if (AreaCode.Length==6 && AreaCode.IndexOf("0") == 5)
|
|
|
{
|
|
|
AreaCode = AreaCode.Remove(4);
|
|
@@ -181,5 +185,124 @@ namespace Hotline.Api.Controllers.Bigscreen
|
|
|
}).OrderByDescending(x=>x.SumCount).Take(5).ToListAsync();
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 工单当日统计及环比
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpGet("ordercount-statistics")]
|
|
|
+ public async Task<OrderCountStatisticsDto> OrderCountStatistics()
|
|
|
+ {
|
|
|
+ var today = DateTime.Now;
|
|
|
+ var dto = new OrderCountStatisticsDto();
|
|
|
+ #region 当日工单量
|
|
|
+
|
|
|
+ dto.ToDayCount =await _orderRepository.Queryable(false,false,false).Where(x => x.StartTime.Value.Date == today.Date && x.Status > EOrderStatus.WaitForAccept).CountAsync();
|
|
|
+ var beforToDayCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.Date == today.AddDays(-1).Date && x.Status > EOrderStatus.WaitForAccept).CountAsync();
|
|
|
+
|
|
|
+ if (beforToDayCount == 0)
|
|
|
+ {
|
|
|
+ dto.ToDayQoQ = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dto.ToDayQoQ = Math.Round((dto.ToDayCount - beforToDayCount) / (double)beforToDayCount, 2);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 当月工单量
|
|
|
+
|
|
|
+ dto.ToMonthCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.ToString("yyyy-MM") == today.ToString("yyyy-MM") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
|
|
|
+
|
|
|
+ var beforToMonthCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.ToString("yyyy-MM") == today.AddMonths(-1).ToString("yyyy-MM") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
|
|
|
+
|
|
|
+ if (beforToMonthCount==0)
|
|
|
+ {
|
|
|
+ dto.ToMonthQoQ = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dto.ToMonthQoQ = Math.Round((dto.ToMonthCount - beforToMonthCount) / (double)beforToMonthCount, 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 当年工单量
|
|
|
+
|
|
|
+ dto.ToYearCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.ToString("yyyy") == today.ToString("yyyy") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
|
|
|
+
|
|
|
+ var beforToYearCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.ToString("yyyy") == today.AddYears(-1).ToString("yyyy") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
|
|
|
+
|
|
|
+ if (beforToYearCount==0)
|
|
|
+ {
|
|
|
+ dto.ToYearQoQ = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dto.ToYearQoQ = Math.Round((dto.ToYearCount - beforToYearCount) / (double)beforToYearCount, 2);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 区域受理排行
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpGet("orderarea-accept-statistics")]
|
|
|
+ public async Task<List<OrderAreaAcceptStatisticsDto>> OrderAreaAcceptStatistics(DateTime StartDate,DateTime EndDate)
|
|
|
+ {
|
|
|
+ EndDate = EndDate.AddDays(1).AddSeconds(-1);
|
|
|
+
|
|
|
+ var list = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime>= StartDate && x.StartTime<= EndDate && x.Status > EOrderStatus.WaitForAccept)
|
|
|
+ .LeftJoin<SystemArea>((it,o)=> it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
|
|
|
+ .GroupBy((it,o) => new {
|
|
|
+ AreaCode = it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ o.AreaName,
|
|
|
+ })
|
|
|
+ .Select((it,o) => new OrderAreaAcceptStatisticsDto()
|
|
|
+ {
|
|
|
+ AreaCode = it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ AreaName = o.AreaName,
|
|
|
+ AcceptedCount = SqlFunc.AggregateCount(it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
|
|
|
+ CompletionCount = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status>= EOrderStatus.Filed,1,0))
|
|
|
+ }).ToListAsync();
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 区域明细数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="StartDate"></param>
|
|
|
+ /// <param name="EndDate"></param>
|
|
|
+ /// <param name="AreaCode"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpGet("orderareaaccept-query")]
|
|
|
+ public async Task<OrderAreaAcceptQueryDto> OrderAreaAcceptQuery(DateTime StartDate,DateTime EndDate,string AreaCode)
|
|
|
+ {
|
|
|
+ EndDate = EndDate.AddDays(1).AddSeconds(-1);
|
|
|
+ var dto = new OrderAreaAcceptQueryDto();
|
|
|
+ dto.HandlingCount = await _orderRepository.Queryable(false, false, false).Where(x => x.AreaCode == AreaCode && x.StartTime >= StartDate && x.StartTime <= EndDate && x.Status > EOrderStatus.WaitForAccept && x.Status < EOrderStatus.Filed).CountAsync();
|
|
|
+
|
|
|
+ dto.FiledCount = await _orderRepository.Queryable(false, false, false).Where(x => x.AreaCode == AreaCode && x.StartTime >= StartDate && x.StartTime <= EndDate && x.Status >= EOrderStatus.Filed).CountAsync();
|
|
|
+
|
|
|
+ dto.OverTimeCount = await _orderRepository.Queryable(false, false, false).Where(x => x.AreaCode == AreaCode && x.StartTime >= StartDate && x.StartTime <= EndDate && x.ExpiredStatus == EExpiredStatus.Expired).CountAsync();
|
|
|
+
|
|
|
+ var hotsPot =await _orderRepository.Queryable(false, false, false).Where(x => x.AreaCode == AreaCode && x.StartTime >= StartDate && x.StartTime <= EndDate && x.Status > EOrderStatus.WaitForAccept).GroupBy(x => new { x.HotspotId, x.HotspotName })
|
|
|
+ .Select(x => new
|
|
|
+ {
|
|
|
+ HotsPotName = x.HotspotName,
|
|
|
+ HotCount =SqlFunc.AggregateCount(x.HotspotId)
|
|
|
+ }).OrderByDescending(x=>x.HotCount).FirstAsync();
|
|
|
+
|
|
|
+ dto.HotspotName = hotsPot.HotsPotName;
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|