Files
Tunnel/README.md
2025-12-12 10:57:31 +08:00

153 lines
2.7 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.
# 工程围岩数据信息处理系统
基于 FastAPI + MySQL + SQLAlchemy 的工程围岩数据管理系统。
## 环境要求
- Python 3.12+
- MySQL 8.0+
## 安装
```bash
# 创建虚拟环境
python -m venv .venv
# 激活虚拟环境
# Windows
.venv\Scripts\activate
# Linux/Mac
source .venv/bin/activate
# 安装依赖
pip install -r requirements.txt
```
## 配置
编辑 `.env` 文件:
```env
APP_HOST=0.0.0.0
APP_PORT=8000
APP_DEBUG=true
# Railway数据库账号表
RAILWAY_DB_HOST=localhost
RAILWAY_DB_PORT=3306
RAILWAY_DB_USER=root
RAILWAY_DB_PASSWORD=your_password
RAILWAY_DB_NAME=railway
# Tunnel数据库业务数据
TUNNEL_DB_HOST=localhost
TUNNEL_DB_PORT=3306
TUNNEL_DB_USER=root
TUNNEL_DB_PASSWORD=your_password
TUNNEL_DB_NAME=Tunnel
```
## 运行
```bash
# 开发模式
python main.py
# 生产模式Docker
docker compose up -d
```
## API 接口
所有接口均为 POST 类型,访问 `/docs` 查看完整文档。
### 工区数据
```bash
# 批量导入
POST /api/work_area/import
{
"account_id": 1,
"data": [
{"department_id": "D001", "parent_id": null, "type": "标段", "name": "一标段"}
]
}
# 查询
POST /api/work_area/query
{"account_id": 1, "type": "标段", "page": 1, "page_size": 20}
```
### 断面数据
```bash
# 批量导入
POST /api/section_data/import
{
"account_id": 1,
"data": [
{"section_id": "S001", "department_id": "D001", "mileage": "DK100+500", "rock_mass_classification": "III"}
]
}
# 查询
POST /api/section_data/query
{"account_id": 1, "department_id": "D001", "page": 1, "page_size": 20}
```
### 观测点数据
```bash
# 批量导入
POST /api/checkpoint/import
{
"account_id": 1,
"data": [
{"point_id": "P001", "section_id": "S001", "name": "拱顶沉降"}
]
}
# 按department查询含断面里程和围岩级别
POST /api/checkpoint/query_by_department
{"account_id": 1, "department_id": "D001", "page": 1, "page_size": 20}
```
### 量测数据
```bash
# 批量导入
POST /api/measurement_data/import
{
"account_id": 1,
"data": [
{"point_id": "P001", "monitoring_time": "2024-01-01T10:00:00", "cumulative_deformation": "5.2"}
]
}
# 按department查询含断面里程、围岩级别、观测点名称
POST /api/measurement_data/query_by_department
{"account_id": 1, "department_id": "D001", "page": 1, "page_size": 20}
```
## 数据库分表
业务数据按 `account_id` 分表存储:
- `work_area_{account_id}`
- `section_data_{account_id}`
- `checkpoint_{account_id}`
- `measurement_data_{account_id}`
## 日志
日志文件位于 `logs/` 目录:
- `access.log` - 接口访问日志
- `app.log` - 业务日志
- `database.log` - 数据库日志
## 部署
```bash
chmod +x deploy.sh
./deploy.sh
```