|
@@ -920,6 +920,11 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
.WhereIF(!string.IsNullOrEmpty(dto.LineNum), x => x.OrderVisit.Order.CallRecord.Gateway == dto.LineNum);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 热点区域统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public async Task<(List<SystemArea> area,object items)> HotspotAndAreaStatistics(HotspotAndAreaStatisticsReq dto)
|
|
|
{
|
|
|
dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
@@ -937,71 +942,118 @@ public class OrderApplication : IOrderApplication, IScopeDependency
|
|
|
.Select(x => new
|
|
|
{
|
|
|
HotspotId= x.HotspotId.Substring(0,int.Parse(endIndex)),
|
|
|
- AreaCode = x.AreaCode,
|
|
|
+ AreaCode = x.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
}).MergeTable();
|
|
|
|
|
|
|
|
|
- var hotListAndOrder = hotspotList.LeftJoin(orderList, (it, o) => it.HotspotId == o.HotspotId)
|
|
|
- .GroupBy((it, o) => new
|
|
|
- {
|
|
|
- it.HotspotId,
|
|
|
- it.HotspotName,
|
|
|
- AreaCode = o.AreaCode.Substring(0,6),
|
|
|
- })
|
|
|
- .OrderBy((it, o) => it.HotspotId)
|
|
|
- .Select((it, o) => new
|
|
|
- {
|
|
|
- HotspotId=it.HotspotId,
|
|
|
- HotspotName=it.HotspotName,
|
|
|
- AreaCode=o.AreaCode,
|
|
|
- Count = SqlFunc.AggregateCount(it.HotspotId)
|
|
|
+ var hotListAndOrder = hotspotList.LeftJoin(orderList, (it, o) => it.HotspotId == o.HotspotId)
|
|
|
+ .GroupBy((it, o) => new
|
|
|
+ {
|
|
|
+ it.HotspotId,
|
|
|
+ it.HotspotName,
|
|
|
+ AreaCode = o.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ })
|
|
|
+ .OrderBy((it, o) => it.HotspotId)
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ HotspotId = it.HotspotId,
|
|
|
+ HotspotName = it.HotspotName,
|
|
|
+ AreaCode = o.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ Count = SqlFunc.AggregateCount(it.HotspotId)
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+
|
|
|
+ var returnList = await hotListAndOrder.LeftJoin(areaList, (pp, dd) => pp.AreaCode == dd.Id)
|
|
|
+ .GroupBy((pp, dd) => new
|
|
|
+ {
|
|
|
+ HotspotId = pp.HotspotId,
|
|
|
+ HotspotName = pp.HotspotName,
|
|
|
+ AreaCode = pp.AreaCode,
|
|
|
+ AreaName = dd.AreaName,
|
|
|
+ })
|
|
|
+ .OrderBy((pp, dd) => pp.HotspotId)
|
|
|
+ .Select((pp, dd) => new
|
|
|
+ {
|
|
|
+ HotspotId = pp.HotspotId,
|
|
|
+ HotspotName = pp.HotspotName,
|
|
|
+ AreaCode = pp.AreaCode,
|
|
|
+ AreaName = dd.AreaName,
|
|
|
+ Count = SqlFunc.AggregateSum(pp.Count)
|
|
|
+ }).ToPivotListAsync(q=> q.AreaCode, q=> new { q.HotspotName,q.HotspotId},q=> q.Sum(x=>x.Count));
|
|
|
+ return (await areaList.ToListAsync(), returnList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 热点区域统计--导出
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<DataTable> HotspotAndAreaStatisticsExport(HotspotAndAreaStatisticsReq dto)
|
|
|
+ {
|
|
|
+ dto.EndTime = dto.EndTime.AddDays(1).AddSeconds(-1);
|
|
|
+ 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 hotspotList = _hotspotRepository.Queryable().Where(x => SqlFunc.Length(x.Id) == int.Parse(endIndex))
|
|
|
+ .Select(x => new {
|
|
|
+ HotspotId = x.Id,
|
|
|
+ HotspotName = x.HotSpotFullName,
|
|
|
}).MergeTable();
|
|
|
|
|
|
|
|
|
- hotListAndOrder.LeftJoin(areaList, (it, o) => it.AreaCode == o.Id)
|
|
|
- .GroupBy((it, o) => new
|
|
|
+ var orderList = _orderRepository.Queryable().Where(x => x.CreationTime >= dto.StartTime && x.CreationTime < dto.EndTime)
|
|
|
+ .Select(x => new
|
|
|
{
|
|
|
+ HotspotId = x.HotspotId.Substring(0, int.Parse(endIndex)),
|
|
|
+ AreaCode = x.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ }).MergeTable();
|
|
|
|
|
|
- });
|
|
|
|
|
|
- //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 _hotspotRepository.Queryable()
|
|
|
- // .LeftJoin<Order>((it, o) => it.Id == o.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(endIndex)))
|
|
|
- // .Where((it, o) => o.CreationTime >= dto.StartTime && o.CreationTime < dto.EndTime && o.AreaCode.StartsWith(item.Id) && SqlFunc.Length(it.Id) >= int.Parse(endIndex))
|
|
|
- // .GroupBy((it, o) => new
|
|
|
- // {
|
|
|
- // HotspotId = o.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(endIndex)),
|
|
|
- // it.HotSpotFullName,
|
|
|
- // it.OrderBy
|
|
|
- // })
|
|
|
- // .OrderBy((it, o) => new
|
|
|
- // {
|
|
|
- // it.OrderBy
|
|
|
- // }).Select((it, o) => new
|
|
|
- // {Z
|
|
|
- // HotspotId = o.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>(endIndex)),
|
|
|
- // Key = item.Id,
|
|
|
- // HotSpotNameOne = it.HotSpotFullName,
|
|
|
- // Count = SqlFunc.AggregateCount(it.HotSpotFullName)
|
|
|
- // }).ToPivotListAsync(x => x.Key, x => new { x.HotspotId, x.HotSpotNameOne }, x => x.Sum(x => x.Count));
|
|
|
- // returnList.AddRange(list);
|
|
|
- //}
|
|
|
- //return (areaList, returnList );
|
|
|
- return (null,null);
|
|
|
+ var hotListAndOrder = hotspotList.LeftJoin(orderList, (it, o) => it.HotspotId == o.HotspotId)
|
|
|
+ .GroupBy((it, o) => new
|
|
|
+ {
|
|
|
+ it.HotspotId,
|
|
|
+ it.HotspotName,
|
|
|
+ AreaCode = o.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ })
|
|
|
+ .OrderBy((it, o) => it.HotspotId)
|
|
|
+ .Select((it, o) => new
|
|
|
+ {
|
|
|
+ HotspotId = it.HotspotId,
|
|
|
+ HotspotName = it.HotspotName,
|
|
|
+ AreaCode = o.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
|
|
|
+ Count = SqlFunc.AggregateCount(it.HotspotId)
|
|
|
+ }).MergeTable();
|
|
|
+
|
|
|
+
|
|
|
+ var returnList = await hotListAndOrder.LeftJoin(areaList, (pp, dd) => pp.AreaCode == dd.Id)
|
|
|
+ .GroupBy((pp, dd) => new
|
|
|
+ {
|
|
|
+ HotspotId = pp.HotspotId,
|
|
|
+ HotspotName = pp.HotspotName,
|
|
|
+ AreaCode = pp.AreaCode,
|
|
|
+ AreaName = dd.AreaName,
|
|
|
+ })
|
|
|
+ .OrderBy((pp, dd) => pp.HotspotId)
|
|
|
+ .Select((pp, dd) => new
|
|
|
+ {
|
|
|
+ HotspotId = pp.HotspotId,
|
|
|
+ HotspotName = pp.HotspotName,
|
|
|
+ AreaCode = pp.AreaCode,
|
|
|
+ AreaName = dd.AreaName,
|
|
|
+ Count = SqlFunc.AggregateSum(pp.Count)
|
|
|
+ }).ToPivotTableAsync(q => q.AreaName, q => new { q.HotspotName }, q => q.Sum(x => x.Count));
|
|
|
+ return returnList;
|
|
|
}
|
|
|
- #region private
|
|
|
+ #region private
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 接受外部工单(除省平台)
|
|
|
- /// </summary>
|
|
|
- /// <param name="dto"></param>
|
|
|
- /// <param name="cancellationToken"></param>
|
|
|
- /// <returns></returns>
|
|
|
- private async Task<AddOrderResponse> ReceiveOrderFromOtherPlatformAsync(AddOrderDto dto, List<FileDto> files,
|
|
|
+ /// <summary>
|
|
|
+ /// 接受外部工单(除省平台)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private async Task<AddOrderResponse> ReceiveOrderFromOtherPlatformAsync(AddOrderDto dto, List<FileDto> files,
|
|
|
ISessionContext current, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(dto.ExternalId))
|