feat(regulatory): 新增法规核查模型与工作流通用字段
This commit is contained in:
@@ -4,7 +4,14 @@ from review_agent.models import FileSummaryBatch, WorkflowEvent
|
||||
|
||||
|
||||
def record_event(batch: FileSummaryBatch, event_type: str, payload: dict | None = None) -> WorkflowEvent:
|
||||
return WorkflowEvent.objects.create(batch=batch, event_type=event_type, payload=payload or {})
|
||||
return WorkflowEvent.objects.create(
|
||||
batch=batch,
|
||||
workflow_type="file_summary",
|
||||
workflow_batch_id=batch.pk,
|
||||
conversation=batch.conversation,
|
||||
event_type=event_type,
|
||||
payload=payload or {},
|
||||
)
|
||||
|
||||
|
||||
def serialize_event(event: WorkflowEvent) -> dict[str, object]:
|
||||
|
||||
@@ -54,6 +54,9 @@ def generate_excel_export(batch: FileSummaryBatch) -> ExportedSummaryFile:
|
||||
workbook.save(path)
|
||||
exported = ExportedSummaryFile.objects.create(
|
||||
batch=batch,
|
||||
workflow_type="file_summary",
|
||||
workflow_batch_id=batch.pk,
|
||||
export_category="summary",
|
||||
export_type=ExportedSummaryFile.ExportType.EXCEL,
|
||||
file_name=path.name,
|
||||
storage_path=str(path),
|
||||
|
||||
@@ -65,6 +65,9 @@ def generate_markdown_report(batch: FileSummaryBatch) -> tuple[ExportedSummaryFi
|
||||
path.write_text(content, encoding="utf-8")
|
||||
exported = ExportedSummaryFile.objects.create(
|
||||
batch=batch,
|
||||
workflow_type="file_summary",
|
||||
workflow_batch_id=batch.pk,
|
||||
export_category="summary",
|
||||
export_type=ExportedSummaryFile.ExportType.MARKDOWN,
|
||||
file_name=path.name,
|
||||
storage_path=str(path),
|
||||
|
||||
@@ -283,11 +283,12 @@ def export_download(request, export_id: int):
|
||||
extra={"export_id": exported.pk, "storage_path": exported.storage_path},
|
||||
)
|
||||
return JsonResponse({"error": "文件不存在。"}, status=404)
|
||||
content_type = (
|
||||
"text/markdown; charset=utf-8"
|
||||
if exported.export_type == ExportedSummaryFile.ExportType.MARKDOWN
|
||||
else "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
)
|
||||
content_types = {
|
||||
ExportedSummaryFile.ExportType.MARKDOWN: "text/markdown; charset=utf-8",
|
||||
ExportedSummaryFile.ExportType.EXCEL: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
ExportedSummaryFile.ExportType.JSON: "application/json; charset=utf-8",
|
||||
}
|
||||
content_type = content_types.get(exported.export_type, "application/octet-stream")
|
||||
logger.info(
|
||||
"Export download started",
|
||||
extra={
|
||||
|
||||
@@ -112,7 +112,14 @@ def create_file_summary_batch(
|
||||
attachment.save(update_fields=["upload_status"])
|
||||
|
||||
for code, name, _skill_name in NODE_DEFINITIONS:
|
||||
WorkflowNodeRun.objects.create(batch=batch, node_code=code, node_name=name)
|
||||
WorkflowNodeRun.objects.create(
|
||||
batch=batch,
|
||||
workflow_type="file_summary",
|
||||
workflow_batch_id=batch.pk,
|
||||
node_group="file_summary",
|
||||
node_code=code,
|
||||
node_name=name,
|
||||
)
|
||||
|
||||
record_event(batch, "workflow_created", {"batch_id": batch.pk, "batch_no": batch.batch_no})
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user