Просмотр исходного кода

fix(s8): scope active flow stuck scan by tenant and factory

YY968XX 2 месяцев назад
Родитель
Сommit
872b2f7315

+ 3 - 3
server/Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj

@@ -11,9 +11,9 @@
     <GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>
     <Copyright>Admin.NET</Copyright>
     <Description>Admin.NET 通用权限开发平台</Description>
-    <AssemblyVersion>1.0.138</AssemblyVersion>
-    <FileVersion>1.0.138</FileVersion>
-    <Version>1.0.138</Version>
+    <AssemblyVersion>1.0.139</AssemblyVersion>
+    <FileVersion>1.0.139</FileVersion>
+    <Version>1.0.139</Version>
   </PropertyGroup>
 
   <ItemGroup>

+ 6 - 1
server/Plugins/Admin.NET.Plugin.AiDOP/Job/S8ActiveFlowStuckScanJob.cs

@@ -29,6 +29,11 @@ public class S8ActiveFlowStuckScanJob : IJob
     private const string EnvSchedulerEnabled = "AIDOP_SCHEDULER_ENABLED";
     private const string EnvS8SchedulerEnabled = "AIDOP_S8_SCHEDULER_ENABLED";
 
+    // S8-ACTIVE-FLOW-TENANT-FILTER-P2-4:当前部署仅租户 1 / 工厂 1 投产,
+    // stuck 候选与 dedup 查询补 tenant/factory 过滤;orphan 路径保持 global 0/0 不变。
+    private const long DefaultTenantId = 1;
+    private const long DefaultFactoryId = 1;
+
     public S8ActiveFlowStuckScanJob(IServiceScopeFactory scopeFactory, IConfiguration configuration, ILoggerFactory loggerFactory)
     {
         _scopeFactory = scopeFactory;
@@ -81,7 +86,7 @@ public class S8ActiveFlowStuckScanJob : IJob
 
         try
         {
-            var alertCount = await watchService.ScanAsync(stoppingToken);
+            var alertCount = await watchService.ScanAsync(DefaultTenantId, DefaultFactoryId, stoppingToken);
             if (alertCount > 0)
                 _logger.LogInformation("S8ActiveFlowStuckScanJob 本轮新增 {Count} 条卡死告警", alertCount);
         }

+ 4 - 2
server/Plugins/Admin.NET.Plugin.AiDOP/Service/S8/S8ActiveFlowWatchService.cs

@@ -40,7 +40,7 @@ public class S8ActiveFlowWatchService : ITransient
         _logger = logger;
     }
 
-    public async Task<int> ScanAsync(CancellationToken cancellationToken = default)
+    public async Task<int> ScanAsync(long tenantId, long factoryId, CancellationToken cancellationToken = default)
     {
         if (!_options.Enabled)
             return 0;
@@ -54,6 +54,7 @@ public class S8ActiveFlowWatchService : ITransient
 
         var staleExceptions = await _exceptionRep.AsQueryable()
             .Where(x => !x.IsDeleted && x.ActiveFlowInstanceId.HasValue &&
+                        x.TenantId == tenantId && x.FactoryId == factoryId &&
                         SqlFunc.IsNull(x.UpdatedAt, x.CreatedAt) < staleBefore)
             .OrderBy(x => x.UpdatedAt, OrderByType.Asc)
             .OrderBy(x => x.Id, OrderByType.Asc)
@@ -65,7 +66,8 @@ public class S8ActiveFlowWatchService : ITransient
 
         var exceptionIds = staleExceptions.Select(x => x.Id).ToHashSet();
         var recentAlertLogs = await _notificationLogRep.AsQueryable()
-            .Where(x => x.Channel == AlertChannel && x.CreatedAt >= alertedAfter && x.ExceptionId != null)
+            .Where(x => x.TenantId == tenantId && x.FactoryId == factoryId &&
+                        x.Channel == AlertChannel && x.CreatedAt >= alertedAfter && x.ExceptionId != null)
             .ToListAsync();
 
         var alertedIds = recentAlertLogs