|
@@ -23,6 +23,7 @@ using Hotline.Tools;
|
|
using MapsterMapper;
|
|
using MapsterMapper;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using MiniExcelLibs;
|
|
using MiniExcelLibs;
|
|
|
|
+using NPOI.OpenXmlFormats.Vml;
|
|
using SqlSugar;
|
|
using SqlSugar;
|
|
using System.Data;
|
|
using System.Data;
|
|
using XF.Domain.Authentications;
|
|
using XF.Domain.Authentications;
|
|
@@ -2989,103 +2990,52 @@ namespace Hotline.Api.Controllers.Bi
|
|
public async Task<object> HotspotAndAreaStatistics([FromQuery] HotspotAndAreaStatisticsReq dto)
|
|
public async Task<object> HotspotAndAreaStatistics([FromQuery] HotspotAndAreaStatisticsReq dto)
|
|
{
|
|
{
|
|
dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
- var areaList = await _systemAreaRepository.Queryable().Where(x => SqlFunc.Length(x.Id) == 6 && x.Id!= "510000").OrderBy(x=>x.Id).ToListAsync();
|
|
|
|
- List<dynamic> returnList = new List<dynamic>();
|
|
|
|
- foreach (var item in areaList)
|
|
|
|
- {
|
|
|
|
- List<dynamic> list = new List<dynamic>();
|
|
|
|
-
|
|
|
|
- switch (dto.HotspotLevel)
|
|
|
|
|
|
+ var areaList = _systemAreaRepository.Queryable().Where(x => SqlFunc.Length(x.Id) == 6 && x.Id!= "510000").OrderBy(x=>x.Id).MergeTable();
|
|
|
|
+ var endIndex = (2 * dto.HotspotLevel).ToString();
|
|
|
|
+ var orderList = _orderRepository.Queryable()
|
|
|
|
+ .LeftJoin(areaList, (it, o) => it.AreaCode.Substring(0, 6) == o.Id)
|
|
|
|
+ .Where((it, o) => it.CreationTime >= dto.StartTime && it.CreationTime < dto.EndTime)
|
|
|
|
+ .Select((it, o) => new
|
|
{
|
|
{
|
|
- case 1:
|
|
|
|
- list = await _orderRepository.Queryable()
|
|
|
|
- .LeftJoin<Hotspot>((it, o) => it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")) == o.Id)
|
|
|
|
- .Where((it, o) => it.CreationTime >= dto.StartTime && it.CreationTime < dto.EndTime && it.AreaCode.StartsWith(item.Id) && SqlFunc.Length(it.HotspotId)>=2)
|
|
|
|
- .GroupBy((it, o) => new
|
|
|
|
- {
|
|
|
|
- HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")),
|
|
|
|
- o.HotSpotFullName,
|
|
|
|
- o.OrderBy
|
|
|
|
- })
|
|
|
|
- .OrderBy((it,o)=> new {
|
|
|
|
- o.OrderBy
|
|
|
|
- } )
|
|
|
|
- .Select((it, o) => new
|
|
|
|
- {
|
|
|
|
- HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")),
|
|
|
|
- Key = item.Id,
|
|
|
|
- HotSpotNameOne = o.HotSpotFullName,
|
|
|
|
- Count = SqlFunc.AggregateCount(o.HotSpotFullName)
|
|
|
|
- }).ToPivotListAsync(x => x.Key, x => new { x.HotspotId, x.HotSpotNameOne }, x => x.Sum(x => x.Count));
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- list = await _orderRepository.Queryable()
|
|
|
|
- .LeftJoin<Hotspot>((it, o) => it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("4")) == o.Id)
|
|
|
|
- .Where((it, o) => it.CreationTime >= dto.StartTime && it.CreationTime < dto.EndTime && it.AreaCode.StartsWith(item.Id) && SqlFunc.Length(it.HotspotId) >= 4)
|
|
|
|
- .GroupBy((it, o) => new
|
|
|
|
- {
|
|
|
|
- HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("4")),
|
|
|
|
- o.HotSpotFullName,
|
|
|
|
- o.OrderBy
|
|
|
|
- })
|
|
|
|
- .OrderBy((it, o) => new {
|
|
|
|
- o.OrderBy
|
|
|
|
- })
|
|
|
|
- .Select((it, o) => new
|
|
|
|
- {
|
|
|
|
- HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("4")),
|
|
|
|
- Key = item.Id,
|
|
|
|
- HotSpotName = o.HotSpotFullName,
|
|
|
|
- Count = SqlFunc.AggregateCount(o.HotSpotFullName)
|
|
|
|
- }).ToPivotListAsync(x => x.Key, x => new { x.HotspotId, x.HotSpotName }, x => x.Sum(x => x.Count));
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- list = await _orderRepository.Queryable()
|
|
|
|
- .LeftJoin<Hotspot>((it, o) => it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
|
|
|
|
- .Where((it, o) => it.CreationTime >= dto.StartTime && it.CreationTime < dto.EndTime && it.AreaCode.StartsWith(item.Id) && SqlFunc.Length(it.HotspotId) >= 6)
|
|
|
|
- .GroupBy((it, o) => new
|
|
|
|
- {
|
|
|
|
- HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
|
- o.HotSpotFullName,
|
|
|
|
- o.OrderBy
|
|
|
|
- })
|
|
|
|
- .OrderBy((it, o) => new {
|
|
|
|
- o.OrderBy
|
|
|
|
- })
|
|
|
|
- .Select((it, o) => new
|
|
|
|
- {
|
|
|
|
- HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
|
- Key = item.Id,
|
|
|
|
- HotSpotName = o.HotSpotFullName,
|
|
|
|
- Count = SqlFunc.AggregateCount(o.HotSpotFullName)
|
|
|
|
- }).ToPivotListAsync(x => x.Key, x => new { x.HotspotId, x.HotSpotName }, x => x.Sum(x => x.Count));
|
|
|
|
- break;
|
|
|
|
- case 4:
|
|
|
|
- list = await _orderRepository.Queryable()
|
|
|
|
- .LeftJoin<Hotspot>((it, o) => it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("8")) == o.Id && SqlFunc.Length(it.HotspotId) >= 8)
|
|
|
|
- .Where((it, o) => it.CreationTime >= dto.StartTime && it.CreationTime < dto.EndTime && it.AreaCode.StartsWith(item.Id))
|
|
|
|
- .GroupBy((it, o) => new
|
|
|
|
- {
|
|
|
|
- HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("8")),
|
|
|
|
- o.HotSpotFullName,
|
|
|
|
- o.OrderBy
|
|
|
|
- })
|
|
|
|
- .OrderBy((it, o) => new {
|
|
|
|
- o.OrderBy
|
|
|
|
- })
|
|
|
|
- .Select((it, o) => new
|
|
|
|
- {
|
|
|
|
- HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("8")),
|
|
|
|
- Key = item.Id,
|
|
|
|
- HotSpotName = o.HotSpotFullName,
|
|
|
|
- Count = SqlFunc.AggregateCount(o.HotSpotFullName)
|
|
|
|
- }).ToPivotListAsync(x => x.Key, x => new { x.HotspotId, x.HotSpotName }, x => x.Sum(x => x.Count));
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- returnList.AddRange(list);
|
|
|
|
- }
|
|
|
|
|
|
+ AreaCode = o.Id,
|
|
|
|
+ AreaName = o.AreaName,
|
|
|
|
+ HotspotId = it.HotspotId.Substring(0, int.Parse(endIndex))
|
|
|
|
+ }).MergeTable();
|
|
|
|
+
|
|
|
|
+ var returnList = _hotspotRepository.Queryable()
|
|
|
|
+ .LeftJoin(orderList, (it, o) => it.Id == o.HotspotId)
|
|
|
|
+ .GroupBy((it, o) => o.HotspotId);
|
|
|
|
+ //.Select((it,o)=>)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //List<dynamic> returnList = new List<dynamic>();
|
|
|
|
+ //var endIndex = (2 * dto.HotspotLevel).ToString();
|
|
|
|
+ //foreach (var item in areaList)
|
|
|
|
+ //{
|
|
|
|
+ // List<dynamic> list = new List<dynamic>();
|
|
|
|
+ // list = await _orderRepository.Queryable()
|
|
|
|
+ // .LeftJoin<Hotspot>((it, o) => it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(endIndex)) == o.Id)
|
|
|
|
+ // .Where((it, o) => it.CreationTime >= dto.StartTime && it.CreationTime < dto.EndTime && it.AreaCode.StartsWith(item.Id) && SqlFunc.Length(it.HotspotId) >= int.Parse(endIndex))
|
|
|
|
+ // .GroupBy((it, o) => new
|
|
|
|
+ // {
|
|
|
|
+ // HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(endIndex)),
|
|
|
|
+ // o.HotSpotFullName,
|
|
|
|
+ // o.OrderBy
|
|
|
|
+ // })
|
|
|
|
+ // .OrderBy((it, o) => new {
|
|
|
|
+ // o.OrderBy
|
|
|
|
+ // })
|
|
|
|
+ // .Select((it, o) => new
|
|
|
|
+ // {
|
|
|
|
+ // HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(endIndex)),
|
|
|
|
+ // Key = item.Id,
|
|
|
|
+ // HotSpotNameOne = o.HotSpotFullName,
|
|
|
|
+ // Count = SqlFunc.AggregateCount(o.HotSpotFullName)
|
|
|
|
+ // }).ToPivotListAsync(x => x.Key, x => new { x.HotspotId, x.HotSpotNameOne }, x => x.Sum(x => x.Count));
|
|
|
|
+ // returnList.AddRange(list);
|
|
|
|
+ //}
|
|
|
|
|
|
return new { AreaList = areaList, Data = returnList };
|
|
return new { AreaList = areaList, Data = returnList };
|
|
}
|
|
}
|