Merge branch 'feature/p132_74-risk-engine' of https://gitee.glmszq.com/gsty/onederiv/trs into feature/p132_74-risk-engine
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
-- 仅供参考,正式脚本以 TRS 为准
|
||||
CREATE TABLE `eod_bond_lending_rate` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`RecordCode` varchar(96) NOT NULL COMMENT '业务唯一代码:UnderlyingSecurityId_yyyyMMdd',
|
||||
`ValueDate` date NOT NULL COMMENT '业务日期',
|
||||
`UnderlyingSecurityId` varchar(64) NOT NULL COMMENT '标的债券代码',
|
||||
`UnderlyingSymbol` varchar(255) DEFAULT NULL COMMENT '标的债券名称',
|
||||
`PreCloseRate` decimal(18,8) DEFAULT NULL COMMENT '前收盘费率(%)',
|
||||
`PreWeightedAvgRate` decimal(18,8) DEFAULT NULL COMMENT '前加权平均费率(%)',
|
||||
`OpenRate` decimal(18,8) DEFAULT NULL COMMENT '开盘费率(%)',
|
||||
`LatestRate` decimal(18,8) DEFAULT NULL COMMENT '最新费率(%)',
|
||||
`HighRate` decimal(18,8) DEFAULT NULL COMMENT '最高费率(%)',
|
||||
`LowRate` decimal(18,8) DEFAULT NULL COMMENT '最低费率(%)',
|
||||
`CloseRate` decimal(18,8) DEFAULT NULL COMMENT '收盘费率(%)',
|
||||
`WeightedAvgRate` decimal(18,8) DEFAULT NULL COMMENT '加权平均费率(%)',
|
||||
`TurnoverAmount` decimal(24,4) DEFAULT NULL COMMENT '成交量(元)',
|
||||
`OptId` int NOT NULL DEFAULT 0 COMMENT '操作人ID,行情自动同步固定为0',
|
||||
`OptName` varchar(64) NOT NULL DEFAULT '行情中心' COMMENT '操作人名称',
|
||||
`OptDate` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '操作时间',
|
||||
`DataSource` varchar(32) NOT NULL DEFAULT '系统' COMMENT '数据来源:系统/人工',
|
||||
`SourceTime` varchar(40) DEFAULT NULL COMMENT '源行情时间,优先使用transactTime',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_eod_bond_lending_rate_record_code` (`RecordCode`),
|
||||
KEY `idx_eod_bond_lending_rate_security_date` (`UnderlyingSecurityId`, `ValueDate`),
|
||||
KEY `idx_eod_bond_lending_rate_opt_date` (`OptDate`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='标的债券借贷费率日终行情(Topic 20028)';
|
||||
@@ -19,7 +19,7 @@ namespace YLErp.Modules.RiskEngine
|
||||
|
||||
/// <summary>
|
||||
/// 【核心】条件JSON(结构化模式的条件列表存储),如
|
||||
/// {"conditions":[{"variableId":1,"operator":">","value":100000000}]}
|
||||
/// {"conditions":[{"variableId":1,"operator":"gt","value":100000000}]}
|
||||
/// 由 RuleCompiler 解析并编译为 CompiledScript
|
||||
/// </summary>
|
||||
public string ConditionJson { get; set; }
|
||||
|
||||
@@ -1093,7 +1093,16 @@ namespace YLErp.Modules.RiskEngine
|
||||
|
||||
foreach (var app in affectedApps)
|
||||
{
|
||||
var remainingIds = ParseStoredRuleIds(app.RuleIds).Where(id => id != ruleId).ToList();
|
||||
List<long> remainingIds;
|
||||
try
|
||||
{
|
||||
remainingIds = ParseStoredRuleIds(app.RuleIds).Where(id => id != ruleId).ToList();
|
||||
}
|
||||
catch (ServiceException ex)
|
||||
{
|
||||
_logger.Error($"删除规则时解析应用关联规则 ID 格式异常,跳过应用 {app.id}:{ex.Message}");
|
||||
continue;
|
||||
}
|
||||
app.RuleIds = string.Join(",", remainingIds);
|
||||
app.Version++;
|
||||
app.UpdateOptId = UserId;
|
||||
@@ -1907,8 +1916,10 @@ namespace YLErp.Modules.RiskEngine
|
||||
/// </summary>
|
||||
private List<glms_risk_rule> GetRulesByVariableId(long variableId)
|
||||
{
|
||||
var idText = variableId.ToString();
|
||||
var allRules = DbContext.glms_risk_rule
|
||||
.Where(r => r.Status != RiskRuleStatus.Deleted && r.ConditionJson != null && r.ConditionJson != "")
|
||||
.Where(r => r.ConditionJson.Contains(idText))
|
||||
.ToList();
|
||||
|
||||
return allRules
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace YLErp.Modules.RiskEngine
|
||||
|
||||
var idText = variableId.ToString(CultureInfo.InvariantCulture);
|
||||
return VariableReferenceFields.Any(field =>
|
||||
Regex.IsMatch(conditionJson, $@"""{field}""\s*:\s*{idText}\b", RegexOptions.CultureInvariant));
|
||||
Regex.IsMatch(conditionJson, $@"""{field}""\s*:\s*{idText}(?=[,\s}}\]])", RegexOptions.CultureInvariant));
|
||||
}
|
||||
|
||||
public static string Build(
|
||||
|
||||
Reference in New Issue
Block a user