|
|
@@ -17,7 +17,6 @@ namespace Admin.NET.Plugin.AiDOP.Service.S8;
|
|
|
public class S8WatchSchedulerService : ITransient
|
|
|
{
|
|
|
private readonly SqlSugarRepository<AdoS8WatchRule> _ruleRep;
|
|
|
- private readonly SqlSugarRepository<AdoS8AlertRule> _alertRuleRep;
|
|
|
private readonly SqlSugarRepository<AdoS8Exception> _exceptionRep;
|
|
|
private readonly SqlSugarRepository<AdoS8ExceptionType> _exceptionTypeRep;
|
|
|
private readonly S8NotificationService _notificationService;
|
|
|
@@ -58,7 +57,6 @@ public class S8WatchSchedulerService : ITransient
|
|
|
|
|
|
public S8WatchSchedulerService(
|
|
|
SqlSugarRepository<AdoS8WatchRule> ruleRep,
|
|
|
- SqlSugarRepository<AdoS8AlertRule> alertRuleRep,
|
|
|
SqlSugarRepository<AdoS8Exception> exceptionRep,
|
|
|
SqlSugarRepository<AdoS8ExceptionType> exceptionTypeRep,
|
|
|
S8NotificationService notificationService,
|
|
|
@@ -75,7 +73,6 @@ public class S8WatchSchedulerService : ITransient
|
|
|
SqlSugarRepository<AdoS8RuleDetectionState> detectionStateRep)
|
|
|
{
|
|
|
_ruleRep = ruleRep;
|
|
|
- _alertRuleRep = alertRuleRep;
|
|
|
_exceptionRep = exceptionRep;
|
|
|
_exceptionTypeRep = exceptionTypeRep;
|
|
|
_notificationService = notificationService;
|
|
|
@@ -185,10 +182,6 @@ public class S8WatchSchedulerService : ITransient
|
|
|
.ToListAsync();
|
|
|
if (rules.Count == 0) return aggregate;
|
|
|
|
|
|
- var alertRules = (await _alertRuleRep.AsQueryable()
|
|
|
- .Where(x => x.TenantId == tenantId && x.FactoryId == factoryId)
|
|
|
- .ToListAsync()).AsReadOnly();
|
|
|
-
|
|
|
foreach (var rule in rules.OrderBy(x => x.Id))
|
|
|
{
|
|
|
// S8-RUN-ONCE-LEASE-AWARENESS-1:debug run-once 不持 lease,但若该 rule 已被 Scheduler Job
|
|
|
@@ -211,7 +204,7 @@ public class S8WatchSchedulerService : ITransient
|
|
|
S8RuleRunResult completion;
|
|
|
try
|
|
|
{
|
|
|
- var ruleResults = await ProcessSingleRuleAsync(tenantId, factoryId, rule, ruleType, evaluator, alertRules, runId);
|
|
|
+ var ruleResults = await ProcessSingleRuleAsync(tenantId, factoryId, rule, ruleType, evaluator, runId);
|
|
|
aggregate.AddRange(ruleResults);
|
|
|
completion = new S8RuleRunResult
|
|
|
{
|
|
|
@@ -889,11 +882,7 @@ public class S8WatchSchedulerService : ITransient
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- var alertRules = (await _alertRuleRep.AsQueryable()
|
|
|
- .Where(x => x.TenantId == tenantId && x.FactoryId == factoryId)
|
|
|
- .ToListAsync()).AsReadOnly();
|
|
|
-
|
|
|
- var results = await ProcessSingleRuleAsync(tenantId, factoryId, rule, ruleType, evaluator, alertRules, lease.RunId);
|
|
|
+ var results = await ProcessSingleRuleAsync(tenantId, factoryId, rule, ruleType, evaluator, lease.RunId);
|
|
|
var stats = new S8RuleRunStats
|
|
|
{
|
|
|
Hits = results.Count,
|
|
|
@@ -921,13 +910,13 @@ public class S8WatchSchedulerService : ITransient
|
|
|
/// </summary>
|
|
|
private async Task<List<S8WatchCreationResult>> ProcessSingleRuleAsync(
|
|
|
long tenantId, long factoryId, AdoS8WatchRule rule, string ruleType,
|
|
|
- IS8RuleEvaluator evaluator, IReadOnlyList<AdoS8AlertRule> alertRules, string runId)
|
|
|
+ IS8RuleEvaluator evaluator, string runId)
|
|
|
{
|
|
|
var results = new List<S8WatchCreationResult>();
|
|
|
List<S8RuleHit> hits;
|
|
|
try
|
|
|
{
|
|
|
- hits = await evaluator.EvaluateAsync(tenantId, factoryId, rule, alertRules);
|
|
|
+ hits = await evaluator.EvaluateAsync(tenantId, factoryId, rule);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -1431,7 +1420,6 @@ public sealed class S8WatchHitResult
|
|
|
{
|
|
|
public long SourceRuleId { get; set; }
|
|
|
public string SourceRuleCode { get; set; } = string.Empty;
|
|
|
- public long AlertRuleId { get; set; }
|
|
|
public long DataSourceId { get; set; }
|
|
|
public string RelatedObjectCode { get; set; } = string.Empty;
|
|
|
public decimal CurrentValue { get; set; }
|