feat(regulatory): 增加法规规则版本检查

This commit is contained in:
2026-06-07 00:26:19 +08:00
parent f52dcc197d
commit 2a4dd6cfab
9 changed files with 264 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
from __future__ import annotations
from django.core.management.base import BaseCommand
from review_agent.regulatory_review.services.rule_loader import check_rule_version
class Command(BaseCommand):
help = "检查 NMPA 法规核查 YAML 规则与数据库版本记录。"
def add_arguments(self, parser):
parser.add_argument(
"--no-create",
action="store_true",
help="缺少数据库记录时只报告 missing不创建记录。",
)
def handle(self, *args, **options):
result = check_rule_version(update_missing=not options["no_create"])
self.stdout.write(
f"{result.code}: {result.status}; yaml_hash={result.current_hash}; "
f"db_hash={result.database_hash or '-'}; path={result.path}"
)
if result.status == "mismatch":
self.stdout.write(
self.style.WARNING("YAML 与数据库记录不一致,请人工确认后更新规则版本记录。")
)