docs(详细设计): 新增Word回填导出设计

This commit is contained in:
2026-06-03 21:12:04 +08:00
parent 2876a1b028
commit cc200a32c4
9 changed files with 1017 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
# Word回填导出编排Skill 设计
## 1. Skill 定位
`Word回填导出编排Skill` 是第六步工作流的总入口 Skill负责组织模板选择、字段映射加载、回填字段集构建、回填拦截检查、Word 渲染、版式校验和导出记录生成。
英文实现标识建议使用 `WordFillExportOrchestrateSkill`
## 2. 输入
```python
@dataclass
class WordFillExportOrchestrateInput:
batch_id: int
template_id: str
target_output_type: str
selected_field_keys: list[str] = field(default_factory=list)
allow_draft_when_blocked: bool = True
```
## 3. 输出
```python
@dataclass
class WordFillExportOrchestrateOutput:
report_type: str
batch_id: int
export_status: str
output_file: dict | None
filled_fields: list[dict]
blocked_fields: list[dict]
audit_id: int | None = None
```
## 4. 依赖 Skill
1. `模板选择Skill`
2. `模板字段映射加载Skill`
3. `回填字段集构建Skill`
4. `回填拦截检查Skill`
5. `Word模板渲染Skill`
6. `导出版式校验Skill`
7. `导出记录生成Skill`
## 5. 核心方法
### 5.1 `run(input) -> WordFillExportOrchestrateOutput`
主入口方法。
### 5.2 `load_export_context(input) -> WordExportContext`
加载字段池、风险报告和一致性报告。
### 5.3 `resolve_export_mode(blockers) -> str`
确认正式、草稿或拦截模式。
## 6. 技术实现
使用技术:
1. Tool Registry
2. Django ORM
3. Django Storage
4. dataclass/Pydantic
建议注册名:
```python
tool_registry.register(
name="word_fill_export_orchestrate",
handler=WordFillExportOrchestrateSkill().run,
)
```
## 7. 异常处理
1. 模板缺失:任务失败。
2. 字段池缺失:任务失败。
3. 正式导出被拦截:按配置生成草稿或直接返回拦截。
4. 渲染失败:写失败审计。
## 8. 测试要点
1. 能按顺序调用依赖 Skill。
2. 冲突字段导致正式导出拦截。
3. 草稿模式可生成文件。
4. 输出报告稳定。