feat: 对齐导出节点口径与下载信息展示

This commit is contained in:
2026-06-04 02:07:58 +08:00
parent 007bf43e15
commit 0d4e02b9dc
3 changed files with 41 additions and 1 deletions

View File

@@ -161,12 +161,19 @@ def _build_workspace_summary(conversation: Conversation, batch: SubmissionBatch
notify_status = node_status_map.get("飞书通知", "待处理") notify_status = node_status_map.get("飞书通知", "待处理")
export_status = node_status_map.get("Word 回填导出", "待处理") export_status = node_status_map.get("Word 回填导出", "待处理")
highest_risk_level = "" if risk_status in {"已阻断", "待复核"} else "" highest_risk_level = "" if risk_status in {"已阻断", "待复核"} else ""
export_allowed = "" if risk_status in {"已阻断", "待复核"} else "" export_allowed = (
""
if risk_status in {"已阻断", "待复核"} or export_status in {"已阻断", "待复核", "失败"}
else ""
)
latest_summary = conversation.latest_summary or {}
structured_output = latest_summary.get("structured_output") or {}
return { return {
"highest_risk_level": highest_risk_level, "highest_risk_level": highest_risk_level,
"export_allowed": export_allowed, "export_allowed": export_allowed,
"notify_status": notify_status, "notify_status": notify_status,
"export_status": export_status, "export_status": export_status,
"download_url": structured_output.get("download_url", ""),
"file_count": batch.file_count if batch else 0, "file_count": batch.file_count if batch else 0,
"page_count": batch.page_count if batch else 0, "page_count": batch.page_count if batch else 0,
} }
@@ -180,6 +187,7 @@ def _apply_agent_result_to_conversation(conversation: Conversation, result: Agen
"answer": result.answer, "answer": result.answer,
"status": result.status, "status": result.status,
"error": result.error, "error": result.error,
"structured_output": result.structured_output,
"notification_payload": result.notification_payload, "notification_payload": result.notification_payload,
} }
conversation.last_run_at = timezone.now() conversation.last_run_at = timezone.now()

View File

@@ -157,6 +157,10 @@
<strong>导出状态</strong> <strong>导出状态</strong>
<div>{{ workspace_summary.export_status }}</div> <div>{{ workspace_summary.export_status }}</div>
</li> </li>
<li class="detail-item">
<strong>导出下载地址</strong>
<div>{{ workspace_summary.download_url|default:"-" }}</div>
</li>
<li class="detail-item">当前会话围绕 `conversation_id / batch_id / product_name` 串联。</li> <li class="detail-item">当前会话围绕 `conversation_id / batch_id / product_name` 串联。</li>
{% if audit_log %} {% if audit_log %}
<li class="detail-item"><a href="{% url 'audit:detail' audit_log.id %}">查看本次处理历史</a></li> <li class="detail-item"><a href="{% url 'audit:detail' audit_log.id %}">查看本次处理历史</a></li>

View File

@@ -373,6 +373,34 @@ def test_chat_page_shows_upload_entry_and_dynamic_context_cards(client, db):
assert "飞书通知 / 待处理" in content assert "飞书通知 / 待处理" in content
def test_chat_page_blocks_formal_export_when_word_export_node_is_blocked(client, db):
batch, conversation = _create_conversation_with_batch()
conversation.node_results = [
{"label": "资料包导入", "status": "已完成"},
{"label": "目录汇总", "status": "已完成"},
{"label": "法规完整性检查", "status": "已完成"},
{"label": "字段抽取", "status": "已完成"},
{"label": "一致性核查", "status": "已完成"},
{"label": "风险预警", "status": "已完成"},
{"label": "Word 回填导出", "status": "已阻断"},
{"label": "飞书通知", "status": "待处理"},
]
conversation.latest_summary = {
"structured_output": {
"download_url": "/downloads/export.docx",
}
}
conversation.save(update_fields=["node_results", "latest_summary", "updated_at"])
response = client.get(reverse("chat:detail", args=[conversation.conversation_id]))
content = response.content.decode("utf-8")
assert response.status_code == 200
assert "是否允许正式导出" in content
assert ">否<" in content
assert "/downloads/export.docx" in content
def test_chat_upload_keeps_existing_conversation_binding_and_adds_documents(client, db): def test_chat_upload_keeps_existing_conversation_binding_and_adds_documents(client, db):
batch, conversation = _create_conversation_with_batch() batch, conversation = _create_conversation_with_batch()
existing_document = UploadedDocument.objects.create( existing_document = UploadedDocument.objects.create(