版本260406

This commit is contained in:
2026-04-06 22:04:05 +08:00
parent 7dc5e73af7
commit 0b150470be
216 changed files with 98993 additions and 33 deletions

View File

@@ -0,0 +1,38 @@
using OrpaonVision.Core.Results;
using OrpaonVision.SiteApp.Runtime.Contracts;
using OrpaonVision.SiteApp.Runtime.Options;
namespace OrpaonVision.SiteApp.Runtime.Services
{
/// <summary>
/// 规则引擎简化实现MVP 阶段)。
/// </summary>
public sealed class SimpleRuleEngineService : IRuleEngineService
{
private readonly RuntimeOptions _options;
/// <summary>
/// 构造函数。
/// </summary>
public SimpleRuleEngineService(RuntimeOptions options)
{
_options = options;
}
/// <inheritdoc />
public Result<RuntimeDecisionDto> 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<RuntimeDecisionDto>.Success(decision, message: "规则判定完成。");
}
}
}