From 68b21f2c985b1943b152f0134053497c37a6ef42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E5=B3=B0?= Date: Thu, 6 Aug 2026 13:09:27 +0800 Subject: [PATCH 1/2] feat: ai code review fix --- YLErpDAL/Modules/RiskEngine/RiskRule.cs | 2 +- YLErpDAL/Modules/RiskEngine/RiskRuleService.cs | 13 ++++++++++++- .../RiskEngine/RuleConditionExpressionBuilder.cs | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/YLErpDAL/Modules/RiskEngine/RiskRule.cs b/YLErpDAL/Modules/RiskEngine/RiskRule.cs index c4e298d0..b9089261 100644 --- a/YLErpDAL/Modules/RiskEngine/RiskRule.cs +++ b/YLErpDAL/Modules/RiskEngine/RiskRule.cs @@ -19,7 +19,7 @@ namespace YLErp.Modules.RiskEngine /// /// 【核心】条件JSON(结构化模式的条件列表存储),如 - /// {"conditions":[{"variableId":1,"operator":">","value":100000000}]} + /// {"conditions":[{"variableId":1,"operator":"gt","value":100000000}]} /// 由 RuleCompiler 解析并编译为 CompiledScript /// public string ConditionJson { get; set; } diff --git a/YLErpDAL/Modules/RiskEngine/RiskRuleService.cs b/YLErpDAL/Modules/RiskEngine/RiskRuleService.cs index 00e18987..6cd51d3e 100644 --- a/YLErpDAL/Modules/RiskEngine/RiskRuleService.cs +++ b/YLErpDAL/Modules/RiskEngine/RiskRuleService.cs @@ -1093,7 +1093,16 @@ namespace YLErp.Modules.RiskEngine foreach (var app in affectedApps) { - var remainingIds = ParseStoredRuleIds(app.RuleIds).Where(id => id != ruleId).ToList(); + List 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 /// private List 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 diff --git a/YLErpDAL/Modules/RiskEngine/RuleConditionExpressionBuilder.cs b/YLErpDAL/Modules/RiskEngine/RuleConditionExpressionBuilder.cs index 46945ca0..1c260c3b 100644 --- a/YLErpDAL/Modules/RiskEngine/RuleConditionExpressionBuilder.cs +++ b/YLErpDAL/Modules/RiskEngine/RuleConditionExpressionBuilder.cs @@ -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( From f256a623df6758b9a19fa885c3e089ddf344fa86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E5=B3=B0?= Date: Thu, 6 Aug 2026 13:10:05 +0800 Subject: [PATCH 2/2] feat: create_eod_bond_lending_rate_table.sql --- .../create_eod_bond_lending_rate_table.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Framework/YLErp.Resources/DbUpdate/Ver-5.6.0/create_eod_bond_lending_rate_table.sql diff --git a/Framework/YLErp.Resources/DbUpdate/Ver-5.6.0/create_eod_bond_lending_rate_table.sql b/Framework/YLErp.Resources/DbUpdate/Ver-5.6.0/create_eod_bond_lending_rate_table.sql new file mode 100644 index 00000000..65572e76 --- /dev/null +++ b/Framework/YLErp.Resources/DbUpdate/Ver-5.6.0/create_eod_bond_lending_rate_table.sql @@ -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)'; \ No newline at end of file