feat(regulatory): 增加法规规则版本检查
This commit is contained in:
27
review_agent/management/commands/regulatory_rules_check.py
Normal file
27
review_agent/management/commands/regulatory_rules_check.py
Normal 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 与数据库记录不一致,请人工确认后更新规则版本记录。")
|
||||
)
|
||||
Reference in New Issue
Block a user