feat: 动态生成资料包异常提示
This commit is contained in:
@@ -247,6 +247,59 @@ def build_batch_rows(batches) -> list[dict]:
|
||||
return rows
|
||||
|
||||
|
||||
def build_exception_items(batches, documents) -> list[dict]:
|
||||
"""
|
||||
聚合资料包页需要关注的异常提示。
|
||||
|
||||
只返回真实存在的异常来源,避免页面继续展示静态 demo 文案:
|
||||
- 批次级待复核
|
||||
- 文档级待人工复核
|
||||
- 文档级处理失败
|
||||
"""
|
||||
items = []
|
||||
|
||||
for document in documents:
|
||||
if document.status == UploadedDocument.STATUS_FAILED:
|
||||
items.append(
|
||||
{
|
||||
"level": "失败",
|
||||
"title": f"文档处理失败:{document.original_name}",
|
||||
"detail": document.error_message or "文档处理异常,请重新上传或稍后重试。",
|
||||
}
|
||||
)
|
||||
continue
|
||||
|
||||
if document.needs_manual_review:
|
||||
review_reasons = []
|
||||
if document.file_type.lower() == "docx" and document.page_count_confidence != "exact":
|
||||
review_reasons.append("页数为估算值,建议人工确认")
|
||||
if not document.chapter_code or document.chapter_match_status != "matched":
|
||||
review_reasons.append("章节点未识别,建议人工确认归类")
|
||||
items.append(
|
||||
{
|
||||
"level": "待确认",
|
||||
"title": f"文档待人工复核:{document.original_name}",
|
||||
"detail": ";".join(review_reasons) or "资料存在待确认项,建议人工复核。",
|
||||
}
|
||||
)
|
||||
|
||||
for batch in batches:
|
||||
if batch.import_status != SubmissionBatch.STATUS_REVIEW_REQUIRED:
|
||||
continue
|
||||
items.append(
|
||||
{
|
||||
"level": "待确认",
|
||||
"title": f"资料包待复核:{batch.batch_id}",
|
||||
"detail": (
|
||||
f"{batch.product_name or '未识别产品名称'} 当前存在 "
|
||||
f"{batch.exception_count} 项异常,请进入关联会话或处理历史继续复核。"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
return items
|
||||
|
||||
|
||||
def extract_text(document: UploadedDocument) -> str:
|
||||
"""
|
||||
根据文档类型选择合适的文本抽取策略。
|
||||
|
||||
Reference in New Issue
Block a user