feat(application-form-fill): 展示自动填表工作流卡片

This commit is contained in:
2026-06-07 18:43:39 +08:00
parent 9be10ef990
commit 4ac9c04dbf
7 changed files with 335 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ from .services import (
send_message,
stream_message,
)
from .models import Conversation, FileAttachment, FileSummaryBatch, RegulatoryReviewBatch, WorkflowNodeRun
from .models import ApplicationFormFillBatch, Conversation, FileAttachment, FileSummaryBatch, RegulatoryReviewBatch, WorkflowNodeRun
from .regulatory_review.services.info_extract import ensure_regulatory_condition_candidates
@@ -155,6 +155,25 @@ def build_workflow_cards(conversation: Conversation) -> list[dict[str, object]]:
),
}
)
form_fill_batches = ApplicationFormFillBatch.objects.filter(conversation=conversation, is_deleted=False)
for batch in form_fill_batches:
cards.append(
{
"id": batch.pk,
"workflow_type": "application_form_fill",
"batch_no": batch.batch_no,
"status": batch.status,
"error_message": batch.error_message,
"risk_label": _format_form_fill_label(batch),
"created_at": batch.created_at,
"nodes": list(
WorkflowNodeRun.objects.filter(
workflow_type="application_form_fill",
workflow_batch_id=batch.pk,
).order_by("id")
),
}
)
return sorted(cards, key=lambda item: item["created_at"], reverse=True)[:5]
@@ -187,3 +206,14 @@ def _format_risk_label(risk_summary: dict) -> str:
if count:
parts.append(f"{label} {count}")
return " · ".join(parts)
def _format_form_fill_label(batch: ApplicationFormFillBatch) -> str:
parts = []
if batch.selected_templates:
parts.append("模板 " + "".join(batch.selected_templates))
if batch.conflict_summary:
parts.append(f"冲突字段 {len(batch.conflict_summary)}")
if batch.risk_notes:
parts.append(f"提示 {len(batch.risk_notes)}")
return " · ".join(parts)