diff --git a/Framework/YLErp.Core/DBModels/Enums/RiskControlStrategy.cs b/Framework/YLErp.Core/DBModels/Enums/RiskControlStrategy.cs
index 1fd37054..c8d8ce8a 100644
--- a/Framework/YLErp.Core/DBModels/Enums/RiskControlStrategy.cs
+++ b/Framework/YLErp.Core/DBModels/Enums/RiskControlStrategy.cs
@@ -4,6 +4,6 @@ namespace YLErp.DBModels
{
Block = 1,
Approval = 2,
- Warning = 3
+ ShowTip = 3
}
}
diff --git a/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiledCache.cs b/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiledCache.cs
index 59fe9099..61fcd263 100644
--- a/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiledCache.cs
+++ b/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiledCache.cs
@@ -5,7 +5,7 @@ namespace YLErp.Modules.RiskEngine
{
///
/// 规则编译结果的进程内缓存。
- /// 当前第一版按 RuleCode 缓存 Roslyn 编译后的可执行委托。
+ /// 当前第一版按规则 Id 缓存 Roslyn 编译后的可执行委托。
///
public static class RuleCompiledCache
{
diff --git a/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiler.cs b/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiler.cs
index 5f003ff1..0d2f778f 100644
--- a/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiler.cs
+++ b/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiler.cs
@@ -32,8 +32,7 @@ namespace YLErp.Modules.RiskEngine
/// - 可调试:生成的脚本代码可直接阅读和理解
///
/// 示例:
- /// ConditionJson: { "conditions": [{"variableId":1,"operator":">","value":100000000}] }
- /// 生成脚本:Convert.ToDecimal(((YLErp.DBModels.trade)DataMap["trade"]).StockEqvNotional) > 100000000m
+ /// RuleExpr: Convert.ToDecimal(((YLErp.DBModels.trade)DataMap["trade"]).StockEqvNotional) > 100000000m
/// 编译结果:Func<RiskContext, bool>(内部通过 Roslyn 编译缓存)
///
public static class RuleCompiler
@@ -71,14 +70,14 @@ namespace YLErp.Modules.RiskEngine
}
///
- /// 校验并编译公式表达式。
- /// 当前 FormulaExp 要求是 Roslyn 可直接执行的 bool 表达式。
+ /// 校验并编译规则表达式。
+ /// 当前 RuleExpr 要求是 Roslyn 可直接执行的 bool 表达式。
///
public static RuleCompileResult ValidateAndCompileFormula(string formulaExp)
{
if (string.IsNullOrWhiteSpace(formulaExp))
{
- return RuleCompileResult.Fail("规则 FormulaExp 不能为空");
+ return RuleCompileResult.Fail("规则 RuleExpr 不能为空");
}
try
@@ -101,100 +100,87 @@ namespace YLErp.Modules.RiskEngine
{
return RuleCompileResult.Fail("规则不能为空");
}
-
- if (string.IsNullOrWhiteSpace(rule.RuleCode))
+
+ if (rule.Id <= 0)
{
- return RuleCompileResult.Fail("规则 Code 不能为空");
+ return RuleCompileResult.Fail("规则 Id 不能为空");
}
var result = ValidateAndCompileFormula(rule.RuleExpr);
if (!result.Success)
{
- return RuleCompileResult.Fail($"规则[{rule.RuleCode}]编译失败:{result.ErrorMessage}");
+ return RuleCompileResult.Fail($"规则[{rule.Id}]编译失败:{result.ErrorMessage}");
}
rule.CompiledScript = result.CompiledScript;
- RuleCompiledCache.Set(rule.RuleCode, result.CompiledScript);
+ RuleCompiledCache.Set(rule.Id.ToString(), result.CompiledScript);
return result;
}
///
- /// 解析 ConditionJson,提取条件列表
+ /// 解析 ConditionJson,提取条件列表。
+ /// 要求 expression 明确描述实际取值路径。
+ /// 当前主执行链不再使用该方法,仅作为早期方案保留。
///
- private static List<(long variableId, string op, object value, string variableType)> ParseConditionJson(string conditionJson)
+ // private static List<(string variableCode, string expression, string op, object value, string variableType)> ParseConditionJson(string conditionJson)
+ // {
+ // var result = new List<(string, string, string, object, string)>();
+ // var jObj = JObject.Parse(formulaJson);
+ // var conditions = jObj["conditions"] as JArray;
+
+ // if (conditions == null || !conditions.Any())
+ // {
+ // throw new ArgumentException("ConditionJson 中缺少 conditions");
+ // }
+
+ // foreach (var cond in conditions)
+ // {
+ // string variableCode = cond["variableCode"]?.Value();
+ // string expression = cond["expression"]?.Value();
+ // string op = cond["operator"]?.Value();
+ // object value = cond["value"]?.Value