# SmartWaterGroupDashboard **Repository Path**: muzileo/SmartWaterGroupDashboard ## Basic Information - **Project Name**: SmartWaterGroupDashboard - **Description**: XXX铁路局智慧水务系统 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-14 - **Last Updated**: 2026-05-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Smart Water Service A minimal FastAPI-based smart water utility backend for meter registration, reading reporting, consumption calculation, and tiered billing. ## Setup ```bash python -m venv .venv . .venv/Scripts/activate pip install -r requirements.txt uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 ``` On Windows PowerShell, activate with: ```powershell . .\.venv\Scripts\Activate.ps1 ``` ## API Overview - `POST /meters/` register a meter - `GET /meters/` list meters - `POST /meters/{meter_id}/readings` report a reading `{reading_time, value_m3}` - `GET /meters/{meter_id}/readings?start&end` list readings in a period - `GET /meters/{meter_id}/consumption?start&end` compute consumed volume - `GET /meters/{meter_id}/billing?start&end` compute charges with active tariff tiers - `POST /tariffs/` create a tariff tier - `GET /tariffs/?active=true` list tiers (filtered) - `PATCH /tariffs/{id}` update tier - `DELETE /tariffs/{id}` delete tier Date-times use ISO 8601, e.g. `2024-01-01T00:00:00`. ## Example 1) Create tiers: ```bash curl -X POST http://localhost:8000/tariffs/ -H "Content-Type: application/json" -d '{ "start_inclusive_m3": 0, "end_exclusive_m3": 10, "price_per_m3": 2.0, "order_index": 1 }' curl -X POST http://localhost:8000/tariffs/ -H "Content-Type: application/json" -d '{ "start_inclusive_m3": 10, "end_exclusive_m3": 30, "price_per_m3": 3.0, "order_index": 2 }' ``` 2) Create meter and readings: ```bash curl -X POST http://localhost:8000/meters/ -H "Content-Type: application/json" -d '{"name":"A1","location":"Block-1"}' curl -X POST http://localhost:8000/meters/1/readings -H "Content-Type: application/json" -d '{ "reading_time": "2024-01-01T00:00:00", "value_m3": 100 }' curl -X POST http://localhost:8000/meters/1/readings -H "Content-Type: application/json" -d '{ "reading_time": "2024-01-31T23:59:59", "value_m3": 120 }' ``` 3) Get consumption and billing: ```bash curl "http://localhost:8000/meters/1/consumption?start=2024-01-01T00:00:00&end=2024-01-31T23:59:59" curl "http://localhost:8000/meters/1/billing?start=2024-01-01T00:00:00&end=2024-01-31T23:59:59" ```