优先级: P1 预计工时: 1天 创建日期: 2026-08-22
小程序端报告页面已实现「固定模板 + 自由显示」展示模式:
report_blocks 表中预置的 blocks(score/indicator/list/text),由 ReportBlockAssembler 生成目前后台缺少模板配置管理和采集训练能力,导致新报告类型无法灵活配置展示方式。
| 角色 | 故事 | 验收标准 |
|---|---|---|
| 管理员 | 为不同报告类型配置展示模板(固定块顺序+自由显示开关) | 能创建/编辑/启停模板;模板影响小程序报告渲染 |
| 管理员 | 在未知报告聚类中手动标注报告类型,作为采集器训练数据 | 能看到 LLM 解析结果;能选类型;能预览模板渲染效果 |
| 系统 | 新报告类型首次发现时自动建定义(无指纹),积累3份后生成指纹+模板 | 新类型自动创建 report_template 空模板;ready 状态聚类可一键生成 |
report_templateCREATE TABLE IF NOT EXISTS report_template (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL COMMENT '模板名称',
report_type VARCHAR(50) NOT NULL COMMENT '报告类型: gut_flora/dan/physical_exam/tongue',
config JSON NOT NULL COMMENT '模板配置JSON',
is_active TINYINT DEFAULT 1 COMMENT '0=停用 1=启用',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uk_report_type (report_type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='报告展示模板';
{
"fixedBlocks": [
{
"type": "score",
"title": "健康评分",
"items": ["overallScore", "gutHealthScore", "chronicDiseaseScore"],
"order": 1
},
{
"type": "indicator",
"title": "血脂指标",
"indicatorCodes": ["total_cholesterol", "triglyceride", "hdl"],
"groupLabel": "血脂",
"order": 2
}
],
"freeDisplay": {
"enabled": true,
"groupName": "其他指标"
}
}
report_unknown_upload.annotationALTER TABLE report_unknown_upload ADD COLUMN annotation TEXT COMMENT '管理员标注: 手动指定类型+确认提取结果JSON';
| 文件 | 说明 |
|---|---|
entity/ReportTemplate.java |
模板实体 |
mapper/ReportTemplateMapper.java |
MyBatis-Plus Mapper |
service/ReportTemplateService.java |
业务逻辑 |
controller/admin/ReportTemplateController.java |
REST 接口 |
POST /api/admin/report-template/list 分页列表
POST /api/admin/report-template/save 保存(创建或更新)
POST /api/admin/report-template/delete 删除
POST /api/admin/report-template/toggle 启用/停用
POST /api/admin/report-template/get 按reportType获取
POST /api/admin/report-template/indicators 获取可选指标列表(用于编辑器)
ReportBlockAssembler.java — 新增方法:
public List<Map<String, Object>> assembleWithTemplate(String reportType, Object payload) {
// 1. 查询 template config
// 2. 按 fixedBlocks 顺序组装
// 3. 如果 freeDisplay.enabled,追加未配置指标
}
ReportParserAdminController.java — 修改 generateType():
report_template 记录(config 为空)DatabaseInitializer.java — 添加迁移:
schema.sql — 追加 CREATE TABLE + ALTER TABLE report_unknown_upload
| 文件 | 说明 |
|---|---|
src/api/reportTemplate.js |
API 封装 |
src/views/admin/ReportTemplateManage.vue |
模板管理页 |
src/views/admin/ReportCollectorTrainer.vue |
采集训练器页 |
router/index.js{
path: 'report-template',
name: 'ReportTemplateManage',
component: () => import('@/views/admin/ReportTemplateManage.vue'),
meta: { title: '报告模板管理', perm: 'config:report-parser' }
},
{
path: 'report-collector-trainer',
name: 'ReportCollectorTrainer',
component: () => import('@/views/admin/ReportCollectorTrainer.vue'),
meta: { title: '报告采集训练', perm: 'config:report-parser' }
}
Layout.vue(报告解析系统子菜单追加)报告采集训练 ─ el-icon-film perm: config:report-parser
报告模板管理 ─ el-icon-setting perm: config:report-parser
在 docs/superpowers/api/API_REFERENCE.md 的「报告解析系统」章节追加:
| 路径 | 方法 | 说明 |
|---|---|---|
/api/admin/report-template/list |
POST | 模板列表 |
/api/admin/report-template/save |
POST | 保存模板 |
/api/admin/report-template/delete |
POST | 删除模板 |
/api/admin/report-template/toggle |
POST | 启停模板 |
/api/admin/report-template/get |
POST | 按类型获取 |
/api/admin/report-template/indicators |
POST | 获取可选指标 |
mvn clean compile 通过/api/admin/report-template/list 返回空列表