feat:提交格式化模板

This commit is contained in:
雷雨
2025-12-05 16:34:01 +08:00
parent dcc6db2363
commit eb32528f7e
3 changed files with 38 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
python-docx== 0.8.11
python-docx
fastapi
uvicorn
uvicorn
docxtpl

View File

@@ -0,0 +1,35 @@
from docxtpl import DocxTemplate
from pathlib import Path
context = {
'name': '张三',
'sex': '',
'nation': '汉族',
'brith': '1990-01-01',
'address': '北京市海淀区西二旗',
'education': '本科',
'degree': '学士',
# 籍贯
'origin': '山东',
'politics': '党员',
# 部门
'department': '数信部',
'position': '助理开发工程师',
'phone': '13812345678',
'title': '后端开发工程师',
'start_work_time': '2018-01-01',
# 身份证
'id_number': '500221199001010010101',
# 荣誉,交给大模型
'honor': '一等奖',
# 工作内容
'work_text': '''
2023.12-2024.10:负责《边缘计算+5G自组网的水电物联网系统建设与研究》项目异常检测算法和项目实施利用5G自组网技术、自建边缘计算单元等实际实现在线异常检测、时间序列趋势分析、模型轻量化等功能缓解通信带宽压力在观音岩、彭水、渝能等场站实施应用。完成项目科技成果凝练、项目报奖等工作。本项目工作获得第六届全国设备管理与技术创新成果一等奖、中电联职工创新成果二等奖。
2024.04-2025.至今:广西河池源网荷储一体化项目/大唐西藏玉曲河扎拉电厂可行性研究报告&方案编写、AI支持中心方案策划
'''
}
file_path = Path.cwd().joinpath('template.docx')
template = DocxTemplate(file_path)
template.render(context)
template.save('E://resu//output.docx')

BIN
service/template.docx Normal file

Binary file not shown.