Files
ppt/ppt_manager/README.md

116 lines
3.6 KiB
Markdown
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智能管理系统
PPT管理系统实现**静态模板内容**与**动态数据内容**的智能合并。
## ✨ 核心特性
- 📁 **静态PPT管理**: 固定不变的原理内容放在本地PPT模板中
- 🔄 **动态内容生成**: Python脚本负责数据采集、图表生成
- 🎯 **页面映射配置**: YAML配置文件定义每页是静态还是动态
- 🖱️ **一键生成**: Web界面点击按钮自动合成最终PPT
- 📝 **日志记录**: 使用loguru完整记录生成过程
## 📁 项目结构
```
ppt_manager/
├── static_ppt/ # 静态PPT模板目录
│ └── macro_analysis_template.pptx # 23页模板示例
├── config/
│ └── project_config.yaml # 项目配置:页面映射关系
├── scripts/ # 动态内容生成脚本
│ ├── gdp_chart.py # GDP图表生成
│ ├── inflation_chart.py # CPI/PPI图表
│ ├── employment_table.py # 就业数据表
│ ├── trade_chart.py # 进出口图表
│ └── market_analysis.py # 市场分析图表
├── dynamic_content/ # 动态生成的图片存放
├── output/ # 最终生成的PPT输出目录
├── logs/ # 日志目录
├── src/
│ ├── config_loader.py # 配置加载器
│ ├── ppt_core.py # PPT核心操作
│ ├── dynamic_generator.py # 动态内容生成器
│ └── ppt_generator.py # 主合成引擎
├── templates/
│ └── index.html # Web界面
├── app.py # Flask Web应用
├── main.py # 命令行入口
├── create_sample_template.py # 创建示例模板脚本
└── requirements.txt # Python依赖
```
## 🚀 快速开始
### 1. 安装依赖
```bash
cd ppt_manager
pip install -r requirements.txt
```
### 2. 初始化示例静态PPT模板
```bash
python create_sample_template.py
```
### 3. 运行系统
**方式一Web界面推荐**
```bash
python app.py
```
然后在浏览器打开: http://localhost:5000
**方式二:命令行**
```bash
python main.py macro_analysis
```
## ⚙️ 配置说明
在 [config/project_config.yaml](file:///f:/ppt/ppt_manager/config/project_config.yaml) 中配置:
```yaml
projects:
macro_analysis:
name: "宏观数据分析报告"
static_ppt: "static_ppt/macro_analysis_template.pptx"
total_slides: 23
slide_mapping:
1: static # 静态页,来自模板
2: static
3: static
4: dynamic_chart_gdp # 动态页,执行对应脚本
5: dynamic_chart_inflation
...
dynamic_generators:
dynamic_chart_gdp: "scripts/gdp_chart.py" # 脚本对应关系
...
```
## 📝 动态脚本编写规范
每个动态脚本必须包含一个 `generate(output_dir)` 函数,返回生成的图片路径:
```python
def generate(output_dir):
# 1. 采集数据API/爬虫/数据库等)
# 2. 生成图表matplotlib/plotly等
# 3. 返回图片完整路径
return str(image_path)
```
## 🎯 使用场景示例
| 页面 | 类型 | 内容 | 更新频率 |
|------|------|------|----------|
| 1-3页 | static | 封面、目录、分析框架 | 固定不变 |
| 4页 | dynamic | GDP趋势图 | 每月更新 |
| 5页 | dynamic | CPI/PPI通胀图 | 每月更新 |
| 7页 | dynamic | 就业数据表 | 每月更新 |
| 10页 | dynamic | 进出口贸易 | 每月更新 |
| 13页 | dynamic | A股市场分析 | 每周更新 |
| 其他页 | static | 原理、方法论 | 固定不变 |