using OrpaonVision.Core.Results; using OrpaonVision.SiteApp.Runtime.Contracts; using OrpaonVision.SiteApp.Runtime.Options; namespace OrpaonVision.SiteApp.Runtime.Services { /// /// 规则引擎简化实现(MVP 阶段)。 /// public sealed class SimpleRuleEngineService : IRuleEngineService { private readonly RuntimeOptions _options; /// /// 构造函数。 /// public SimpleRuleEngineService(RuntimeOptions options) { _options = options; } /// public Result Evaluate(int currentLayer, InferenceResultDto inference) { var isPass = inference.Label == "OK" || inference.Confidence < _options.NgConfidenceThreshold; var decision = new RuntimeDecisionDto { IsPass = isPass, Code = isPass ? "RULE_PASS" : "RULE_NG", Message = isPass ? $"第 {currentLayer} 层判定通过。" : $"第 {currentLayer} 层判定 NG:{inference.Label}" }; return Result.Success(decision, message: "规则判定完成。"); } } }