diff --git a/YLErpDAL/Modules/RiskEngine/Compile/RuleCompileResult.cs b/YLErpDAL/Modules/RiskEngine/Compile/RuleCompileResult.cs
deleted file mode 100644
index 65a88901..00000000
--- a/YLErpDAL/Modules/RiskEngine/Compile/RuleCompileResult.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-
-namespace YLErp.Modules.RiskEngine
-{
- ///
- /// 规则编译结果。
- /// 用于承载公式校验、Roslyn 编译结果和错误信息。
- ///
- public class RuleCompileResult
- {
- ///
- /// 是否编译成功。
- ///
- public bool Success { get; set; }
-
- ///
- /// 编译失败时的错误信息。
- ///
- public string ErrorMessage { get; set; }
-
- ///
- /// 编译成功后的可执行委托。
- ///
- public Func CompiledScript { get; set; }
-
- ///
- /// 创建成功结果。
- ///
- public static RuleCompileResult Ok(Func compiledScript)
- {
- return new RuleCompileResult
- {
- Success = true,
- CompiledScript = compiledScript
- };
- }
-
- ///
- /// 创建失败结果。
- ///
- public static RuleCompileResult Fail(string errorMessage)
- {
- return new RuleCompileResult
- {
- Success = false,
- ErrorMessage = errorMessage
- };
- }
- }
-}
\ No newline at end of file
diff --git a/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiledCache.cs b/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiledCache.cs
deleted file mode 100644
index 61fcd263..00000000
--- a/YLErpDAL/Modules/RiskEngine/Compile/RuleCompiledCache.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-
-namespace YLErp.Modules.RiskEngine
-{
- ///
- /// 规则编译结果的进程内缓存。
- /// 当前第一版按规则 Id 缓存 Roslyn 编译后的可执行委托。
- ///
- public static class RuleCompiledCache
- {
- ///
- /// 规则编译结果的进程内缓存。ConcurrentDictionary为线程安全的字典,用于缓存编译后的规则委托,性能略低。
- ///
- private static readonly ConcurrentDictionary> Cache
- = new ConcurrentDictionary>(StringComparer.OrdinalIgnoreCase);
-
- ///
- /// 写入或更新规则编译结果。
- ///
- public static void Set(string ruleCode, Func compiledScript)
- {
- if (string.IsNullOrWhiteSpace(ruleCode) || compiledScript == null)
- {
- return;
- }
-
- Cache[ruleCode] = compiledScript;
- }
-
- ///
- /// 尝试获取规则编译结果。
- ///
- public static bool TryGet(string ruleCode, out Func compiledScript)
- {
- compiledScript = null;
-
- if (string.IsNullOrWhiteSpace(ruleCode))
- {
- return false;
- }
-
- return Cache.TryGetValue(ruleCode, out compiledScript);
- }
-
- ///
- /// 删除指定规则的编译结果。
- ///
- public static void Remove(string ruleCode)
- {
- if (string.IsNullOrWhiteSpace(ruleCode))
- {
- return;
- }
-
- Cache.TryRemove(ruleCode, out _);
- }
-
- ///
- /// 清空全部规则编译结果。
- ///
- public static void Clear()
- {
- Cache.Clear();
- }
- }
-}
\ No newline at end of file
diff --git a/YLErpDAL/Modules/RiskEngine/RiskRuleApplication.cs b/YLErpDAL/Modules/RiskEngine/RiskRuleApplication.cs
deleted file mode 100644
index 7b741252..00000000
--- a/YLErpDAL/Modules/RiskEngine/RiskRuleApplication.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-using System;
-using YLErp.DBModels;
-
-namespace YLErp.Modules.RiskEngine
-{
- ///
- /// 风控规则应用配置。
- ///
- /// 设计原因:
- /// 依据设计文档,风控规则需要区分“规则定义”和“规则应用”两个层面。
- /// RiskRule 负责定义“规则是什么”,例如规则名称、规则编码、公式表达式、描述、版本等;
- /// RiskRuleApplication 负责定义“规则在什么场景下如何执行”,例如启用状态、校验策略、触发时点、适用范围。
- ///
- /// 拆分后的好处是:
- /// 1. 同一条规则可以被多个应用配置复用,避免重复维护相同的公式定义。
- /// 2. 不同业务场景可以对同一条规则配置不同的执行策略,例如在簿记确认时禁止,在平仓审核时提示。
- /// 3. 调整触发时点、适用范围、控制策略时,不需要修改规则本身,降低配置耦合。
- /// 4. 后续如果要做规则管理页面、规则启停、按场景灰度投放,也更容易扩展。
- ///
- /// 当前文件先定义第一版最小模型,用于支撑基础流程跑通和示例数据加载。
- ///
- public class RiskRuleApplication
- {
- ///
- /// 应用配置主键ID。
- /// 用于唯一标识一条规则应用记录。
- ///
- public int Id { get; set; }
-
- ///
- /// 关联的规则ID列表。
- /// 通过该字段与 RiskRule.Id 关联,多个规则ID使用逗号分隔。
- ///
-
- public string RuleIds { get; set; }
-
- ///
- /// 应用状态。
- /// 约定:
- /// 1 = Active(已生效)
- /// 2 = Disabled(已停用)
- /// 3 = Deleted(已删除)
- /// 在实际执行时,通常只加载 Active 状态的应用配置。
- ///
- public RiskRuleStatus Status { get; set; }
-
- ///
- /// 校验策略。
- /// 约定:
- /// 1 = 禁止
- /// 2 = 审批
- /// 3 = 提示
- /// 当规则命中时,由该字段决定最终处理方式。
- ///
- public RiskControlStrategy ControlStrategy { get; set; }
-
- ///
- /// 触发时点。
- /// 多个时点使用逗号分隔,例如:
- /// BOOK_CONFIRM,CLOSE_REVIEW
- /// 表示该应用配置会在这些业务时点参与风控判断。
- ///
- public string TriggerPoints { get; set; }
-
- ///
- /// 是否全局适用。
- /// true 表示对所有交易都适用,此时通常忽略其他 Scope 字段;
- /// false 表示只在指定范围内适用,需要结合下方各 Scope 字段进行过滤。
- ///
- public bool ScopeIsGlobal { get; set; }
-
- ///
- /// 适用的资产簿记账户范围。
- /// 第一版使用逗号分隔的字符串保存,例如:
- /// 123,456,789
- /// 后续执行时可按约定解析为账户ID集合。
- ///
- public string ScopeAssetBookIds { get; set; }
-
- ///
- /// 适用的客户范围。
- /// 第一版使用逗号分隔的字符串保存客户ID,例如:
- /// 10001,10002
- /// 用于在执行前筛选该规则是否适用于当前客户。
- ///
- public string ScopeClientIds { get; set; }
-
- ///
- /// 适用的标的类型范围。
- /// 例如:
- /// 股票,ETF,债券
- /// 用于控制规则仅对特定标的类型生效。
- ///
- public string ScopeUnderlyingTypes { get; set; }
-
- ///
- /// 适用的交易类型范围。
- /// 例如:
- /// 簿记交易,平仓交易
- /// 用于控制规则仅在指定交易类型下生效。
- ///
- public string ScopeTradeTypes { get; set; }
-
- public int Version { get; set; }
-
- ///
- /// 创建人ID。
- /// 记录是谁创建了这条应用配置。
- ///
- public int OptId { get; set; }
-
- ///
- /// 创建人名称。
- /// 便于界面展示和审计追踪。
- ///
- public string OptName { get; set; }
-
- ///
- /// 创建时间。
- /// 记录应用配置的创建时刻。
- ///
- public DateTime OptDate { get; set; }
-
- ///
- /// 最后更新人ID。
- /// 记录最近一次修改该应用配置的操作人。
- ///
- public int UpdateOptId { get; set; }
-
- ///
- /// 最后更新人名称。
- /// 便于界面展示和审计追踪。
- ///
- public string UpdateOptName { get; set; }
-
- ///
- /// 最后更新时间。
- /// 记录最近一次修改该应用配置的时间。
- ///
- public DateTime UpdateDate { get; set; }
- }
-}
diff --git a/YLErpWeb/App/HostedTaskService.cs b/YLErpWeb/App/HostedTaskService.cs
index 28660c10..75bf1339 100644
--- a/YLErpWeb/App/HostedTaskService.cs
+++ b/YLErpWeb/App/HostedTaskService.cs
@@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Hosting.Server.Features;
using YLErp.DBModels.Consts;
using YLErp.Modules.AppModule;
using YLErp.Modules.EodModule.SettlementModule;
-using YLErp.Modules.RiskEngine;
using YLErp.Modules.RiskModule;
using YLErp.Modules.SuperviseReportModule.SAC.Service;
using YLErp.Modules.TradeRiskCalcModule;
@@ -125,18 +124,6 @@ namespace YLErp.Web.App
PS.SetConfig(ConsAppConfig.YLErpWebUrlConfig, address);
}
- // 预热风控引擎:加载规则与应用到内存,并预编译所有规则
- Task.Run(() =>
- {
- try
- {
- RiskEngineService.GetInstance().Preload();
- }
- catch (Exception ex)
- {
- LogFactory.GetLogger("HostedTaskService").Error("[风控引擎] 启动预热失败", ex);
- }
- });
});
return Task.CompletedTask;
@@ -157,4 +144,4 @@ namespace YLErp.Web.App
return Task.CompletedTask;
}
}
-}
\ No newline at end of file
+}