Ver código fonte

Merge branch 'feature/snapshot' into dev

qinchaoyue 2 meses atrás
pai
commit
cc360db007

+ 17 - 1
src/Hotline.Api/Controllers/Snapshot/BiSnapshotController.cs

@@ -76,7 +76,6 @@ public class BiSnapshotController : BaseController
     public async Task<PagedDto<RedPackStatisticsDetailsOutDto>> GetRedPackAuditStatisticsDetailsAsync([FromQuery] RedPackStatisticsDetailsInDto dto)
         => (await _biSnapshotApplication.GetRedPackAuditStatisticsDetails(dto).ToPagedListAsync(dto)).ToPaged();
 
-
     /// <summary>
     /// 热点类型小类统计
     /// </summary>
@@ -95,6 +94,23 @@ public class BiSnapshotController : BaseController
     public async Task<PagedDto<HotspotStatisticsDetailsOutDto>> GetHotspotStatisticsDetailAsync([FromQuery] HotspotStatisticsDetailsInDto dto)
         => (await _biSnapshotApplication.HotspotStatisticsDetail(dto).ToPagedListAsync(dto)).ToPaged();
 
+    /// <summary>
+    /// 热点类型-随手拍
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpGet("hotspot-data-statistics")]
+    public async Task<IList<HotspotDataStatisticsOutDto>> GetHotspotDataStatisticsAsync([FromQuery] HotspotDataStatisticsInDto dto)
+    {
+        var items = await _biSnapshotApplication.GetHotspotDataStatisticsAsync(dto).ToListAsync();
+        items.Add(new HotspotDataStatisticsOutDto
+        {
+            Name = "合计",
+            OrderCount = items.Sum(x => x.OrderCount),
+        });
+        return items;
+    }
+
     /// <summary>
     /// 办件统计-随手拍
     /// </summary>

+ 18 - 0
src/Hotline.Application/Snapshot/BiSnapshotApplication.cs

@@ -6,6 +6,7 @@ using Hotline.Settings;
 using Hotline.Settings.Hotspots;
 using Hotline.Share.Attributes;
 using Hotline.Share.Dtos;
+using Hotline.Share.Dtos.Order;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.FlowEngine;
 using Hotline.Share.Enums.Order;
@@ -16,6 +17,7 @@ using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using Hotline.Tools;
 using Mapster;
+using MediatR;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using NPOI.SS.Formula.Functions;
@@ -464,4 +466,20 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
         { 
         }, true);
     }
+
+    public ISugarQueryable<HotspotDataStatisticsOutDto> GetHotspotDataStatisticsAsync(HotspotDataStatisticsInDto dto)
+    {
+        var isCenter = _sessionContext.OrgIsCenter;
+        var query = _hotspotTypeRepository.Queryable(includeDeleted: true)
+            .LeftJoin<Order>((hotspot, order) => order.HotspotSpliceName != null && (hotspot.HotSpotName == order.HotspotSpliceName || order.HotspotSpliceName.Contains(hotspot.HotSpotName)) && order.IsDeleted == false && order.CreationTime >= dto.StartTime && order.CreationTime <= dto.EndTime)
+            .WhereIF(isCenter == false, (hotspot, order) => order.ActualHandleOrgCode == _sessionContext.RequiredOrgId)
+            .Where(hotspot => hotspot.ParentId == null)
+            .GroupBy((hotspot, order) => new { hotspot.Id, hotspot.HotSpotName })
+            .Select((hotspot, order) => new HotspotDataStatisticsOutDto
+            {
+                Name = hotspot.HotSpotName,
+                OrderCount = SqlFunc.AggregateSum(SqlFunc.IIF(order.Id != null, 1, 0)),
+            });
+        return query;
+    }
 }

+ 1 - 0
src/Hotline.Application/Snapshot/IBiSnapshotApplication.cs

@@ -45,4 +45,5 @@ public interface IBiSnapshotApplication
     ISugarQueryable<GuiderWorkStatisticsOutDto> GetGuiderWorkStatisticsAsync(GuiderWorkStatisticsInDto dto);
 
     ISugarQueryable<GuiderWorkStatisticsDetailsOutDto> GetGuiderWorkStatisticsDetails(GuiderWorkStatisticsDetailsInDto dto);
+    ISugarQueryable<HotspotDataStatisticsOutDto> GetHotspotDataStatisticsAsync(HotspotDataStatisticsInDto dto);
 }

+ 30 - 0
src/Hotline.Share/Dtos/Snapshot/StatisticsDto.cs

@@ -1546,3 +1546,33 @@ public class GuiderWorkStatisticsDetailsOutDto
     /// </summary>
     public string AcceptorName { get; set; }
 }
+
+public class HotspotDataStatisticsOutDto
+{
+    /// <summary>
+    /// 热点名字
+    /// </summary>
+    public string Name { get; set; }
+
+    /// <summary>
+    /// 热点工单数量
+    /// </summary>
+    public int OrderCount { get; set; }
+}
+
+public class HotspotDataStatisticsInDto
+{
+    /// <summary>
+    /// 类型:
+    /// 0: 全部;
+    /// 1: 市民;
+    /// 2: 企业;
+    /// </summary>
+    [Required]
+    public int TypeId { get; set; }
+
+    [Required]
+    public DateTime StartTime { get; set; }
+    [Required]
+    public DateTime EndTime { get; set; }
+}