baodan/api/insurance/models/ppt_session.py
wsb1224 c7df34d0cd 07-27 阶段 状态 进度
阶段 1:数据库与工作区	 完成	100%
阶段 2:Celery 后台任务	 完成	100%
阶段 3:前端刷新恢复与多工作区	 完成	100%
阶段 4:任务坞与任务中心	 完成	100%
阶段 5:版本化编辑	 完成	100%
阶段 6:测试与灰度	 未开始	0%
2026-07-28 17:53:14 +08:00

69 lines
4.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""PPT 生成会话模型。"""
from sqlalchemy import Column, String, Text, Integer, TIMESTAMP, func
from insurance.db.compat import db
class PptSession(db.Model):
"""PPT 生成会话表。"""
__tablename__ = "insurance_ppt_sessions"
id = Column(String(36), primary_key=True, comment="UUID")
user_id = Column(String(64), nullable=False, comment="用户 ID")
status = Column(String(20), default="created", nullable=False,
comment="状态: created/parsing/parsed/generating/done/error")
files_json = Column(Text, nullable=True, comment="上传文件列表 JSON")
extractions_json = Column(Text, nullable=True, comment="提取结果 JSON")
parse_progress = Column(Integer, default=0, nullable=False, comment="解析进度 0-100")
parse_message = Column(Text, nullable=True, comment="解析进度说明")
parse_error = Column(Text, nullable=True, comment="解析任务错误")
parse_started_at = Column(TIMESTAMP, nullable=True, comment="解析开始时间")
parse_finished_at = Column(TIMESTAMP, nullable=True, comment="解析完成时间")
chat_history_json = Column(Text, nullable=True, comment="对话历史 JSON")
ppt_path = Column(String(500), nullable=True, comment="生成的 PPT 路径")
markdown_path = Column(String(500), nullable=True, comment="Markdown 路径")
preview_paths_json = Column(Text, nullable=True, comment="预览图路径 JSON")
preview_pdf_path = Column(String(500), nullable=True, comment="预览 PDF 路径")
slide_count = Column(Integer, nullable=True, comment="幻灯片数量")
# 工作区字段migrate_022
title = Column(String(200), default="", comment="用户可识别名称")
workflow_step = Column(String(20), default="upload", comment="当前业务步骤")
draft_options_json = Column(Text, nullable=True, comment="模板、公司、脱敏等草稿设置")
draft_revision = Column(Integer, default=1, comment="当前草稿版本")
generated_revision = Column(Integer, default=0, comment="最新成品版本")
latest_task_id = Column(String(36), nullable=True, comment="最近一次任务 ID")
latest_output_path = Column(String(500), nullable=True, comment="最新成品路径")
archived_at = Column(TIMESTAMP, nullable=True, comment="归档时间")
created_at = Column(TIMESTAMP, server_default=func.now())
updated_at = Column(TIMESTAMP, server_default=func.now(), onupdate=func.now())
def to_dict(self):
import json
return {
"id": self.id,
"user_id": self.user_id,
"status": self.status,
"files": json.loads(self.files_json) if self.files_json else [],
"extractions": json.loads(self.extractions_json) if self.extractions_json else [],
"parse_progress": self.parse_progress or 0,
"parse_message": self.parse_message,
"parse_error": self.parse_error,
"parse_started_at": str(self.parse_started_at) if self.parse_started_at else None,
"parse_finished_at": str(self.parse_finished_at) if self.parse_finished_at else None,
"chat_history": json.loads(self.chat_history_json) if self.chat_history_json else [],
"ppt_path": self.ppt_path,
"markdown_path": self.markdown_path,
"preview_paths": json.loads(self.preview_paths_json) if self.preview_paths_json else [],
"preview_pdf_path": self.preview_pdf_path,
"slide_count": self.slide_count,
"title": self.title or "",
"workflow_step": self.workflow_step or "upload",
"draft_options": json.loads(self.draft_options_json) if self.draft_options_json else None,
"draft_revision": self.draft_revision or 1,
"generated_revision": self.generated_revision or 0,
"latest_task_id": self.latest_task_id,
"latest_output_path": self.latest_output_path,
"archived_at": str(self.archived_at) if self.archived_at else None,
"created_at": str(self.created_at) if self.created_at else None,
"updated_at": str(self.updated_at) if self.updated_at else None,
}