Files
Orbitin/README.md

145 lines
3.4 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.

# OrbitIn - 码头作业日志管理系统
从 Confluence API 获取交接班日志,提取作业数据并生成统计报表。
## 功能特性
- 📥 从 Confluence 获取交接班日志 HTML
- 📄 提取保留布局的文本内容
- 🗄️ SQLite3 数据库存储
- 📊 生成日报和月度统计
- 📈 支持未统计数据手动录入
## 项目结构
```
OrbitIn/
├── main.py # CLI 入口
├── README.md # 项目说明
├── AGENTS.md # AI助手开发文档
├── layout_output.txt # 缓存的布局文本
├── debug/ # 调试输出目录
│ └── layout_output_*.txt # 带时间戳的调试文件
├── data/ # 数据目录
│ └── daily_logs.db # SQLite3 数据库
└── src/ # 代码模块
├── __init__.py
├── confluence.py # Confluence API 客户端
├── extractor.py # HTML 文本提取器
├── parser.py # 日志解析器
├── database.py # 数据库操作
└── report.py # 报表生成器
```
## 快速开始
### 安装依赖
```bash
pip install requests beautifulsoup4 python-dotenv
```
### 配置 Confluence
`.env` 文件中配置:
```bash
# .env
CONFLUENCE_BASE_URL=https://your-confluence.atlassian.net/rest/api
CONFLUENCE_TOKEN=your-api-token
CONFLUENCE_CONTENT_ID=155764524
```
参考 `.env.example` 文件创建 `.env` 文件。
### 使用方法
```bash
# 默认获取HTML、提取、解析并保存到数据库
python3 main.py
# 仅获取HTML并提取文本保存到debug目录
python3 main.py fetch
# 获取并保存带时间戳的debug文件
python3 main.py fetch-debug
# 生成日报(指定日期)
python3 main.py report 2025-12-28
# 生成今日日报
python3 main.py report-today
# 解析测试使用已有的layout_output.txt
python3 main.py parse-test
# 添加未统计数据
python3 main.py --unaccounted 118 --month 2025-12
# 显示帮助
python3 main.py --help
```
## 数据格式
### 日报表 (daily_handover_logs)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | INTEGER | 主键 |
| date | TEXT | 日期 YYYY-MM-DD |
| shift | TEXT | 班次 (白班/夜班) |
| ship_name | TEXT | 船名 |
| teu | INTEGER | 作业量 TEU |
| efficiency | REAL | 效率 |
| vehicles | INTEGER | 上场车辆数 |
| created_at | TEXT | 创建时间 |
### 未统计表 (monthly_unaccounted)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | INTEGER | 主键 |
| year_month | TEXT | 年月 YYYY-MM |
| teu | INTEGER | 未统计的 TEU |
| note | TEXT | 备注 |
| created_at | TEXT | 创建时间 |
## 文本格式约定
- 列表前缀:`•` 用于 `ul`,数字+点用于 `ol`
- 粗体使用 `**text**`,斜体使用 `*text*`
- 水平线使用 `─` (U+2500) 字符
- 链接渲染为 `text (url)`
## 示例输出
```
日期12/28
船名246#学友洋山
作业量246TEU
当日实际作业量246TEU
当月计划作业量8400TEU (用天数*300TEU)
当月未统计数据118TEU
当月实际作业量12750TEU
当月完成比例151.79%
12/29 白班人员:
12/29 夜班人员:
24小时值班手机13107662315
```
## 技术栈
- Python 3.7+
- SQLite3
- Requests (HTTP 客户端)
- HTMLParser (标准库)
## License
MIT