Report_Generate_Server/dist/README.md

81 lines
2.5 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.

# 报告生成工具使用文档
## 1. 功能简介
本工具用于根据风机巡检数据自动生成 Word 报告。
支持 **配置文件****命令行参数** 两种输入方式,命令行可覆盖配置文件中的同名字段。
## 2. 准备
1. 获取可执行程序
2. 准备模板目录(默认 `./muban`)与输出目录(默认 `./output`)。
## 3. 配置文件(推荐)
在项目根目录新建 `config.json`(或任意文件名),格式如下:
```json
{
"json1": {
"turbine_id": "183463dbf40d9278549a76b82b175dd9"
},
"json2": {
"shengcheng_dir": "./reports",
"muban_dir": "./templates",
"if_waibu": true,
"if_neibu": true,
"if_fanglei": true,
"userName": "张三",
"baogaoCheck": "已审核",
"key_words": "缺,损,裂",
"data_processor": "李四",
"jiancha_renyuan": "王五",
"check_date": "2024-06-01",
"coverurl": "https://example.com/cover.jpg",
"conclusion": "整体良好,详见报告"
}
}
```
4. 命令行参数
| 参数 | 说明 | 示例 |
|------|------|------|
| `--config` / `-c` | 指定配置文件 | `--config prod.json` |
| `--turbine_id` / `--id` | 风机 ID | `--turbine_id 123456` |
| `--output_dir` / `--out` | 报告输出目录 | `--output_dir ./result` |
| `--template_dir` / `--tpl` | 模板目录 | `--template_dir ./tpl` |
| `--if_waibu` | 是否包含外部作业章节 | `true` / `false` |
| `--if_neibu` | 是否包含内部作业章节 | `true` / `false` |
| `--if_fanglei` | 是否包含防雷作业章节 | `true` / `false` |
| `--userName` | 报告编制人 | `--userName 张三` |
| `--baogaoCheck` | 审核状态 | `--baogaoCheck 已审核` |
| `--key_words` | 关键词(英文逗号分隔) | `--key_words 缺,损,裂` |
| `--data_processor` | 数据处理人 | `--data_processor 李四` |
| `--jiancha_renyuan` | 检查人员 | `--jiancha_renyuan 王五` |
| `--check_date` | 检查日期YYYY-MM-DD | `--check_date 2024-06-01` |
| `--coverurl` | 封面图片 URL | `--coverurl /stastic/path/to/pic` |
| `--conclusion` | 报告总结 | `--conclusion 整体良好` |
5. 使用示例
### 5.1 仅使用配置文件
```bash
python report.py
```
### 5.2 完全命令行
```bash
python report.py \
--turbine_id 123456 \
--output_dir ./my_out \
--if_waibu false \
--userName Alice \
--check_date 2024-06-01 \
--conclusion "检查完毕,无异常"
```
### 5.3 混合方式
```bash
python report.py --config prod.json --userName Bob --if_fanglei false
```