Files
gloria/metabase/AGENTS.md
qichi.liang 00d2218c6d feat: 初始化福州港日报管理系统
- 添加日报生成功能 (report_generator.py)
- 添加 GUI 界面 (daily_report_gui.py)
- 添加班次交接报告功能 (shift_report.py)
- 集成飞书 API 获取排班信息
- 集成 Metabase 查询作业数据
- 生成 AGENTS.md 文档
2026-03-03 02:07:34 +08:00

68 lines
1.6 KiB
Markdown
Raw Permalink 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.
# METABASE 数据查询模块
## 概述
Metabase REST API 客户端,查询船舶作业数据。
## 结构
```
metabase/
├── __init__.py # 统一导出
├── time_operations.py # TimeOperationsClient - 时间范围查询
└── vessel_operations.py # VesselOperationsClient - 船舶查询
```
## 查找指南
| 任务 | 位置 |
|------|------|
| 按时间查作业量 | `time_operations.py:get_operations_by_time()` |
| 按船舶查数据 | `vessel_operations.py:get_vessel_operations()` |
| 添加新Card查询 | 对应文件的 `_CARD_IDS` |
## 使用方式
```python
from metabase import TimeOperationsClient, VesselOperationsClient
# 时间范围查询
time_client = TimeOperationsClient()
data = time_client.get_operations_by_time("2026-03-01", "2026-03-02")
# {'cnt20': 100, 'cnt40': 50, 'teu': 200, ...}
# 船舶查询
vessel_client = VesselOperationsClient()
vessel = vessel_client.get_vessel_operations("260301-船名")
# {'cnt20': 44, 'teu': 88, 'start_time': '...', ...}
```
## Card ID 映射
### time_operations.py
| 名称 | ID | 用途 |
|------|-----|------|
| overview | 50 | 总览-箱量统计 |
| load | 51 | 装船 |
| discharge | 52 | 卸船 |
| yardmove | 53 | 转堆 |
### vessel_operations.py
| 名称 | ID | 用途 |
|------|-----|------|
| overview | 57 | 船舶箱量统计 |
| efficiency_normal | 64 | 无人集卡效率 |
| work_info | 74 | 作业指令时间 |
## 环境变量
```
MATEBASE_USERNAME=xxx
MATEBASE_PASSWORD=xxx
```
## 注意事项
- 无官方 Python SDK使用 REST API
- Session Token 无过期检测,每次请求前检查
- 时间格式: `YYYY-MM-DD HH:MM:SS`