feat(regulatory): 增加整改复核闭环
This commit is contained in:
@@ -46,12 +46,19 @@ def build_markdown_report(batch: RegulatoryReviewBatch) -> str:
|
||||
"# NMPA 注册资料法规核查报告",
|
||||
"",
|
||||
f"批次号:{batch.batch_no}",
|
||||
"",
|
||||
"## 风险汇总",
|
||||
"",
|
||||
"| 风险等级 | 数量 |",
|
||||
"| --- | --- |",
|
||||
]
|
||||
regenerated_from = (batch.condition_json or {}).get("regenerated_from")
|
||||
if regenerated_from:
|
||||
lines.extend(
|
||||
[
|
||||
"",
|
||||
"## 复核来源",
|
||||
"",
|
||||
f"- 来源法规核查批次:{regenerated_from.get('batch_no')}",
|
||||
f"- 来源文件汇总批次:{regenerated_from.get('file_summary_batch_no')}",
|
||||
]
|
||||
)
|
||||
lines.extend(["", "## 风险汇总", "", "| 风险等级 | 数量 |", "| --- | --- |"])
|
||||
summary = batch.risk_summary or {}
|
||||
for severity, label in SEVERITY_LABELS.items():
|
||||
lines.append(f"| {label} | {summary.get(severity, 0)} |")
|
||||
@@ -60,6 +67,14 @@ def build_markdown_report(batch: RegulatoryReviewBatch) -> str:
|
||||
lines.append(
|
||||
f"| {SEVERITY_LABELS.get(issue.severity, issue.severity)} | {issue.title} | {issue.status} | {issue.suggestion or '-'} |"
|
||||
)
|
||||
review_records = _review_records(batch)
|
||||
if review_records:
|
||||
lines.extend(["", "## 复核记录", "", "| 补充批次 | 问题数 | 通过数 | 未通过数 |", "| --- | --- | --- | --- |"])
|
||||
for record in review_records:
|
||||
items = record.get("items", [])
|
||||
passed = sum(1 for item in items if item.get("status") == RegulatoryIssue.Status.REVIEW_PASSED)
|
||||
failed = sum(1 for item in items if item.get("status") == RegulatoryIssue.Status.REVIEW_FAILED)
|
||||
lines.append(f"| {record.get('file_summary_batch_no')} | {len(items)} | {passed} | {failed} |")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
@@ -67,6 +82,7 @@ def build_result_payload(batch: RegulatoryReviewBatch) -> dict[str, object]:
|
||||
return {
|
||||
"batch_no": batch.batch_no,
|
||||
"source_summary_batch": batch.source_summary_batch.batch_no,
|
||||
"regenerated_from": (batch.condition_json or {}).get("regenerated_from"),
|
||||
"risk_summary": batch.risk_summary,
|
||||
"issues": [
|
||||
{
|
||||
@@ -82,6 +98,7 @@ def build_result_payload(batch: RegulatoryReviewBatch) -> dict[str, object]:
|
||||
}
|
||||
for issue in batch.issues.order_by("id")
|
||||
],
|
||||
"review_records": _review_records(batch),
|
||||
}
|
||||
|
||||
|
||||
@@ -165,3 +182,13 @@ def _create_excel_export(batch: RegulatoryReviewBatch, path: Path) -> ExportedSu
|
||||
file_name=path.name,
|
||||
storage_path=str(path),
|
||||
)
|
||||
|
||||
|
||||
def _review_records(batch: RegulatoryReviewBatch) -> list[dict[str, object]]:
|
||||
records = []
|
||||
for artifact in batch.artifacts.filter(metadata__artifact="review_record").order_by("created_at", "id"):
|
||||
try:
|
||||
records.append(json.loads(Path(artifact.storage_path).read_text(encoding="utf-8")))
|
||||
except (OSError, json.JSONDecodeError):
|
||||
continue
|
||||
return records
|
||||
|
||||
Reference in New Issue
Block a user