Commit Graph

31 Commits

Author SHA1 Message Date
573210f9c3 修复海报生成过程的BUG 2026-07-30 10:30:33 +08:00
65d17179b3 优化海报程程页面PPT 2026-07-30 09:15:07 +08:00
29657d31e4 所有阶段 3-5 的任务全部完成。最终盘点:
全部改动文件总览
后端(8 个文件)
文件	操作
api/insurance/models/ppt_session.py	修改 — 新增 5 个字段
api/insurance/db/migrate_025.py	新建 — 数据库迁移
api/insurance/ppt/renderer.py	修改 — 新增 parse_slides(),deck 返回
api/insurance/ppt/quality_checker.py	新建 — 质量检查
api/insurance/ppt/routes.py	修改 — 新增 5 个接口
api/insurance/generation/celery_tasks.py	修改 — 集成预览+质检+版本化,新增 regenerate 任务
api/insurance/generation/task_service.py	修改 — 注册 regenerate 任务
前端(8 个文件)
文件	操作
frontend/src/utils/ppt-api.ts	修改 — 新增类型和 API 方法
frontend/src/pages/components/ppt/PptSlideCanvas.vue	新建 — Canvas 渲染器
frontend/src/pages/components/ppt/PptResult.vue	重写 — 三栏工作台 + 版本历史
frontend/src/pages/components/ppt/PptUpload.vue	重写 — 双栏 Hero 布局
frontend/src/pages/components/ppt/PptParsing.vue	重写 — 五阶段进度
frontend/src/pages/components/ppt/PptDataReview.vue	修改 — 主题色更新
frontend/src/pages/PptPage.vue	修改 — 步骤描述 + 主题色
frontend/src/pages/PptHistoryPage.vue	重写 — 卡片式布局
新增后端接口
方法	路径	功能
GET	/ppt/preview/:id	获取幻灯片 JSON + 质量报告 + 版本历史
PUT	/ppt/preview/:id/slide/:index	更新编辑内容 + 显隐
PUT	/ppt/preview/:id/quality-confirm	人工质量确认
POST	/ppt/preview/:id/regenerate	基于编辑生成新版本
2026-07-29 22:14:02 +08:00
25c6f2a3b7 阶段 3 剩余:编辑与版本化
功能	文件	说明
幻灯片显隐	routes.py, PptResult.vue, ppt-api.ts	每页可点击隐藏/恢复,隐藏页在缩略图中半透明显示,页码标注隐藏数量
DeckContract 快照	renderer.py, celery_tasks.py, ppt_session.py	生成时保存完整 deck JSON 到文件系统,供版本化回溯
版本化生成	celery_tasks.py, task_service.py, routes.py	POST /preview/:id/regenerate → 递增版本号 → 用 deck 重新渲染 → 追加到版本历史,不覆盖旧版
版本历史 UI	PptResult.vue	右栏显示版本列表(版本号/页数/时间),当前版本高亮标记
数据库迁移	migrate_025.py	新增 deck_contract_path、versions_json 字段
阶段 4:UI 重构
功能	文件	说明
保险绿主题	PptPage.vue, PptGenerate.vue, PptResult.vue, PptSlideCanvas.vue	主色从 #2563eb 蓝改为 #3B7A57 保险绿,背景暖灰 #f0f7f3
生成决策展示	PptGenerate.vue	新增"系统决策"区域,展示检测场景、选用模板、计划书数量、险种类型、保司
骨架屏加载	PptResult.vue	preview_status=none/generating 时显示骨架屏 + 加载动画,不再显示静态 fallback
新增后端接口(本轮)
方法	路径	功能
POST	/ppt/preview/:id/regenerate	基于编辑内容生成新版本
PUT	/ppt/preview/:id/slide/:index	增加 hidden 字段支持
新增 Celery 任务
任务名	说明
insurance.regenerate_ppt	读取 DeckContract → 应用编辑 → 重新渲染 → 保存新版本
2026-07-29 21:41:28 +08:00
f23b08eec6 07-29 PPT生成优化第一阶段完成:
已完成约 40%(阶段 1 + 阶段 2 + 阶段 3 基础编辑),覆盖了计划书中最核心的 P0 需求:

 真实预览(Canvas 方案替代了 LibreOffice 方案)
 质量检查(6 自动 + 4 人工)
 三栏结果工作台
 基础文字编辑
2026-07-29 21:26:48 +08:00
bf90801f28 07-29 修复一版问题PPT 能够上传了 2026-07-29 17:24:34 +08:00
6dfd652a57 07-29 修复一版问题PPT 能够上传了 2026-07-29 15:47:50 +08:00
74dbb32028 07-29 修复一版问题 2026-07-29 12:19:26 +08:00
c7df34d0cd 07-27 阶段 状态 进度
阶段 1:数据库与工作区	 完成	100%
阶段 2:Celery 后台任务	 完成	100%
阶段 3:前端刷新恢复与多工作区	 完成	100%
阶段 4:任务坞与任务中心	 完成	100%
阶段 5:版本化编辑	 完成	100%
阶段 6:测试与灰度	 未开始	0%
2026-07-28 17:53:14 +08:00
8192f6a783 07-27 PDF提取优化 2026-07-28 16:45:14 +08:00
0ffd9dffdf fix(llm): downgrade misleading 'mock mode' warning to debug level
The warning fired at init time when no env var API keys were set,
but the actual config was loaded from the database on first use.
Changed to debug to avoid confusion in logs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-27 15:52:29 +08:00
0b69978812 回复提交 2026-07-27 15:40:58 +08:00
e3479f0546 上线阻断问题全部修复
#	问题	修复	文件
1	前端构建失败(引号错误)	size="small type=" → size="small" type="	PosterHistoryPage.vue
2	migrate_014 ORM vs 缺失列	全部改为原始 SQL,不再引用 ORM 模型	migrate_014.py
3	cleanup 字段名错误	output_path → ppt_path	cleanup.py
4	文案生成 case 越权	添加 case.user_id != user_id 校验	poster/service.py
5	存储路径未接通持久化卷	全部改用 get_storage_root()(默认 /app/api/storage/insurance)	config.py, ppt/routes.py, poster/service.py, poster/tasks.py
高风险问题修复
#	问题	修复	文件
6	migrate_019 rollback 撤销成功字段	每个 ALTER 后立即 commit,失败只回滚当前语句	migrate_019.py
7	迁移锁 Windows 不兼容 + 句柄未持久化	全局变量保存锁句柄,支持 Windows msvcrt	api/insurance/db/__init__.py
8	PDF 校验异常时放行	异常返回 False(文件损坏)	security.py
9	健康检查始终返回成功	缺少关键资源时返回 503 + missing 列表	poster/routes.py
10	短密钥掩码泄露原值	≤4 字符返回 ****	ppt_admin_service.py
11	设置无键名白名单	添加 _ALLOWED_SETTING_KEYS 白名单	ppt_admin_service.py
12	容器重启任务永久 stuck	添加 recover_stale_tasks() 启动恢复函数	poster/tasks.py, ppt/parse_worker.py
2026-07-27 13:52:09 +08:00
67b2dac23f slidesConfig 结构错误 — migrate_017 输出改为数组格式,migrate_019 修复历史数据
迁移系统加固 — 加 advisory lock 防并发,失败回滚并中止启动(原来是 catch-and-continue)
安全漏洞 — Settings/History API 权限收紧,API key 返回掩码值,海报 case 所有权校验
依赖缺失 — requirements.txt 补齐 python-pptx/openai/Pillow,Dockerfile 改为统一安装
海报鉴权下载 — 前端全部改用 authenticated blob,不再 window.open 无 token URL
LLM 配置分离 — 海报文案读取 poster_llm_*(不再复用 ppt_llm_*),支持 config namespace
图片生成器 — 兼容 b64_json 和 URL 两种响应格式,追踪 generation_mode/provider/model
种子数据 — 新环境自动获得 2 个海报模板 + 2 个文案模板
2026-07-27 13:21:34 +08:00
48f6388554 0727 PPT加海报功能02修复一个版本 2026-07-27 10:37:00 +08:00
961924b299 0727 PPT加海报功能01版本修复-修复一个版本 2026-07-27 10:36:13 +08:00
36f08f93e0 修复一次 2026-07-25 14:13:38 +08:00
dbe2f9202d feat: support direct LLM provider config with model sync
- Fix _call_provider to support custom providers (OpenAI-compatible
  fallback) instead of raising ValueError for unknown providers
- Add POST /admin/ppt/sync-models endpoint that fetches available
  models from the configured provider's API
- Redesign PptSettingsAdmin UI: replace Dify model dropdown with
  per-provider 'sync models' button + searchable model selector
- Remove dead Dify-specific code (fetchDifyModels, applyDifyModel)
- Update deepseek default model from deepseek-chat to deepseek-v4-pro
- API Key field now always shown (not conditional on non-dify)
2026-07-25 13:45:32 +08:00
63c7e87ea7 feat(ppt): add data review step between parsing and generation
Add a mandatory data verification step so users can inspect and edit
LLM-extracted data before generating the PPT.

- New PptDataReview.vue: auto-validation on mount, key metrics cards,
  editable benefit/withdrawal tables, inline error highlighting
- New PUT /session/<id>/extractions API endpoint for saving user edits
- Extend PptPage flow from 4 steps to 5 (upload→parse→review→generate→result)
- Update ppt-api.ts with updateExtractions() method
- Update PptParsing button text to match new flow

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 18:22:14 +08:00
1debd7df39 feat(ppt): upgrade renderer from 5 fixed slides to 10+ configurable pages
Rewrite fast_pptx_renderer.py to read requiredPageTypes from template
config instead of hardcoding 5 slides. Add 10 slide builder functions
(cover, company, narrative, chart, timeline, table, compare, synergy,
conclusion, closing) with python-pptx native charts.

Key changes:
- Renderer reads templateConfig.requiredPageTypes and slidesConfig
  from DeckContract to determine slide sequence and per-slide metadata
- routes.py loads PptTemplate and PptCompany from DB, normalizes all
  PDF extractions (not just the first), passes full context to renderer
- renderer.py injects templateConfig, company info, and multi-product
  data into DeckContract
- Add slides_config_json column to PptTemplate (migrate_017) for
  per-slide title/narrative/chartType configuration via admin UI
- Admin template editor now supports drag-reorder slides, per-slide
  title/narrative hint, chart/table type selection
- Add requiredPageTypes to savings/ink, savings/minimal, savings/business
  templates (were missing, causing fallback to defaults)
- Fix IUL normalizer: add payYears and totalPremium to policy dict
- Fix CI/IUL normalizer: add totalSurrenderValue alias to benefitRows
  so charts render correctly for all product types
- Port calculation functions from baodanppt: decade_rows, paid_premium,
  simple_return, compound_return, find_payback_year

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 17:49:09 +08:00
a4d458c978 fix: map unsupported themes to renderer-compatible themes
- Map broker/modern/fresh to deepblue
- Map warm to caramel
- Keep chinese as is
- Fix 'invalid choice: broker' error
2026-07-24 16:55:09 +08:00
0c9975ed3a fix: correct parameter name in add_textbox call
- Change font_size to size in customer name textbox
- Fix 'unexpected keyword argument' error in renderer
2026-07-24 16:51:42 +08:00
071f08d84a fix: use current Python interpreter for subprocess
- Prefer sys.executable for subprocess calls
- Add fallback to virtual environment Python
- Fix 'No module named pptx' error in Docker
2026-07-24 16:46:12 +08:00
91579d54a0 fix: pass pdf_path to normalizer for data provenance
- Add pdfPath to extraction results in parse_session
- Pass pdf_path to normalizer functions in generate_ppt
- Fix 'missing PDF hash' validation error
2026-07-24 16:41:45 +08:00
eef8fc0892 fix: support multiple PDF parsers for PPT extraction
- Add compatibility for PyMuPDF versions (fitz and pymupdf imports)
- Add fallback support for PyPDF2, pypdf, and pdfplumber
- Update requirements.txt with PDF parsing dependencies
- Fix 'cannot extract PDF text' error in Docker environment
2026-07-24 16:36:52 +08:00
3a0f4f6830 feat: support Dify-synced models without separate API key
When a model is selected from Dify, set provider='dify' and call
through Dify Chat API (/v1/chat-messages) using the existing
DIFY_CHAT_APP_API_KEY. No separate API key configuration needed.

- Frontend: hide API Key/Base URL fields when provider is 'dify',
  show 'via Dify, no API key needed' tag
- Backend: add _call_dify() to route through Dify Chat API
- Backend: _try_load_db_config supports dify provider without api_key

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 16:18:59 +08:00
c8e0c0bb1e feat: add model configuration for PPT and poster generation
- PptSettingsAdmin.vue: full settings page with provider/model/API key
  config for PPT extraction, poster copy, and poster image generation
- Backend: GET /insurance/admin/ppt/available-models to fetch models
  from Dify API (falls back to builtin list when unavailable)
- LLM client: read model config from SystemSetting DB with 60s cache,
  priority: database > environment variables > defaults
- ppt-admin-api.ts: add getAvailableModels() method

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 13:46:04 +08:00
6c3343a222 fix: accept cached extractions in generate/validate and improve parse error UX
- generate_ppt and validate_extraction now accept status 'cached'
  alongside 'success', matching the frontend's hasSuccess logic
- PptParsing: show extraction error messages in the results table
- PptParsing: show '解析失败' icon when all extractions fail
- PptParsing: only show '下一步' button when at least one extraction succeeded
- routes.py: add error logging with stack trace in parse endpoint

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 13:05:27 +08:00
623815a134 fix: 添加 PyMuPDF 详细错误信息并创建缺失的迁移文件
- extraction.py: 添加更详细的 ImportError 错误信息,显示具体原因
- migrate_016.py: 创建 insurance_ppt_sessions 表(修复 500 错误)

解决 PDF 上传失败问题:
1. PyMuPDF 导入失败时显示具体错误原因
2. 数据库表 insurance_ppt_sessions 不存在导致插入失败

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 11:29:49 +08:00
5d28e4518e 0723 PPT加海报功能初步完成 2026-07-23 15:04:16 +08:00
4a556a1cc7 0723 PPT功能初步融合 2026-07-23 13:10:50 +08:00