Selaa lähdekoodia

Merge branch 'feature/snapshot' into dev

qinchaoyue 2 kuukautta sitten
vanhempi
commit
c4bd1bca39

+ 6 - 3
src/Hotline.Api/Controllers/FilterController/ExportDataController.cs

@@ -1,4 +1,5 @@
-using Hotline.Application.ExportExcel;
+using DocumentFormat.OpenXml.Office2010.Ink;
+using Hotline.Application.ExportExcel;
 using Hotline.Share.Attributes;
 using Hotline.Share.Dtos.Order;
 using Hotline.Share.Tools;
@@ -125,14 +126,16 @@ public class ExportDataController : BaseController
         }
 
         var type = result.GetType();
+        if (!type.IsGenericType || type.GetGenericTypeDefinition() == typeof(List<>))
+        {
+            return (result as IEnumerable<object>).ToList();
+        }
 
         if (!type.IsGenericType || type.GetGenericTypeDefinition() != typeof(PostgreSQLQueryable<>))
         {
             throw UserFriendlyException.SameMessage("被导出方法的返回类型不是 ISugarQueryable");
         }
 
-        var genericArgument = type.GetGenericArguments()[0];
-
         if (isExportAll)
         {
             var toListMethod = type.GetMethods()

+ 2 - 2
src/Hotline.Api/Controllers/Snapshot/BiSnapshotController.cs

@@ -59,8 +59,8 @@ public class BiSnapshotController : BaseController
     /// <param name="dto"></param>
     /// <returns></returns>
     [HttpGet("redpack/audit")]
-    public async Task<IList<RedPackStatisticsOutDto>> GetRedPackAuditStatisticsAsync([FromQuery] RedPackStatisticsInDto dto)
-        => await _biSnapshotApplication.GetRedPackAuditStatisticsAsync(dto, HttpContext.RequestAborted);
+    public IList<RedPackStatisticsOutDto> GetRedPackAuditStatisticsAsync([FromQuery] RedPackStatisticsInDto dto)
+        => _biSnapshotApplication.GetRedPackAuditStatistics(dto);
 
     /// <summary>
     /// 市民红包审核统计详情

+ 9 - 5
src/Hotline.Application/Snapshot/BiSnapshotApplication.cs

@@ -1,6 +1,7 @@
 using FluentValidation.Results;
 using Hotline.FlowEngine.Workflows;
 using Hotline.Orders;
+using Hotline.Share.Attributes;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.FlowEngine;
 using Hotline.Share.Enums.Order;
@@ -45,9 +46,10 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
     /// <param name="requestAborted"></param>
     /// <returns></returns>
     /// <exception cref="NotImplementedException"></exception>
-    public async Task<IList<RedPackStatisticsOutDto>> GetRedPackAuditStatisticsAsync(RedPackStatisticsInDto dto, CancellationToken requestAborted)
+    [ExportExcel("市民红包审核统计")]
+    public IList<RedPackStatisticsOutDto> GetRedPackAuditStatistics(RedPackStatisticsInDto dto)
     {
-        var industries = await _industryRepository.Queryable(includeDeleted: true)
+        var industries = _industryRepository.Queryable(includeDeleted: true)
             .LeftJoin<IndustryCase>((industry, industryCase) => industry.Id == industryCase.IndustryId && industryCase.IsEnable == true)
             .Select((industry, industryCase) => new RedPackStatisticsOutDto
             {
@@ -56,9 +58,9 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
                 CaseId = industryCase.Id,
                 CaseName = industryCase.Name,
                 ShouldAmount = industryCase.CitizenReadPackAmount == null ? industry.CitizenReadPackAmount : industryCase.CitizenReadPackAmount,
-            }).ToListAsync();
+            }).ToList();
 
-        var redPackOutDto = await _redPackAuditRepository.Queryable(includeDeleted: true)
+        var redPackOutDto = _redPackAuditRepository.Queryable(includeDeleted: true)
             .LeftJoin<OrderSnapshot>((audit, snapshot) => audit.OrderId == snapshot.Id)
             .LeftJoin<RedPackRecord>((audit, snapshot, record) => record.RedPackAuditId == audit.Id)
             .LeftJoin<SupplementRecord>((audit, snapshot, record, supplement) => supplement.RedPackAuditId == audit.Id)
@@ -79,7 +81,7 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
                 PendingCount = SqlFunc.AggregateSum(SqlFunc.IIF(record.DistributionState == EReadPackSendStatus.Unsend, 1, 0)), // 待发个数
                 SupplementAmount = SqlFunc.AggregateSum(supplement.ReplenishAmount), // 补充红包金额
                 SupplementCount = SqlFunc.AggregateCount(supplement.Id), // 补充红包数
-            }).ToListAsync();
+            }).ToList();
 
         foreach (var industry in industries)
         {
@@ -98,10 +100,12 @@ public class BiSnapshotApplication : IBiSnapshotApplication, IScopeDependency
             {
                 industry.IndustryName = $"{industry.Name}({industry.ShouldAmount?.ToString("f2")})";
                 industry.IndustryType = 1;
+                industry.IndustryId = industry.Id;
             }
             else
             {
                 industry.IndustryType = 2;
+                industry.IndustryId = industry.CaseId;
                 if (industry.CaseName == industry.Name)
                     industry.IndustryName = $"{industry.Name}({industry.ShouldAmount?.ToString("f2")})";
                 else

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

@@ -11,7 +11,7 @@ using System.Threading.Tasks;
 namespace Hotline.Application.Snapshot;
 public interface IBiSnapshotApplication
 {
-    Task<IList<RedPackStatisticsOutDto>> GetRedPackAuditStatisticsAsync(RedPackStatisticsInDto dto, CancellationToken requestAborted);
+    IList<RedPackStatisticsOutDto> GetRedPackAuditStatistics(RedPackStatisticsInDto dto);
     ISugarQueryable<RedPackStatisticsDetailsOutDto> GetRedPackAuditStatisticsDetails(RedPackStatisticsDetailsInDto dto);
     Task<SnapshotStatisticsOutDto> GetSnapshotStatisticsAsync(SnapshotStatisticsInDto dto, CancellationToken token);
     ISugarQueryable<SnapshotStatisticsDetailOutDto> GetSnapshotStatisticsDetail(SnapshotStatisticsDetailInDto dto);