新增爆管位置检测模块及相关API接口
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.auth.keycloak_dependencies import get_current_keycloak_username
|
||||
from app.services.burst_location import run_burst_location_by_network
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
class BurstLocationRequest(BaseModel):
|
||||
network: str
|
||||
pressure_scada_ids: list[str]
|
||||
burst_pressure: dict[str, float] | list[dict[str, Any]]
|
||||
normal_pressure: dict[str, float] | list[dict[str, Any]]
|
||||
burst_leakage: float
|
||||
flow_scada_ids: list[str] | None = None
|
||||
burst_flow: dict[str, float] | list[dict[str, Any]] | None = None
|
||||
normal_flow: dict[str, float] | list[dict[str, Any]] | None = None
|
||||
min_dpressure: float = 2.0
|
||||
basic_pressure: float = 10.0
|
||||
|
||||
|
||||
@router.post("/locate/")
|
||||
async def locate_burst(
|
||||
data: BurstLocationRequest,
|
||||
_username: str = Depends(get_current_keycloak_username),
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
return run_burst_location_by_network(**data.model_dump())
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc))
|
||||
@@ -13,6 +13,7 @@ from app.api.v1.endpoints import (
|
||||
risk,
|
||||
cache,
|
||||
leakage,
|
||||
burst_location,
|
||||
user_management, # 新增:用户管理
|
||||
audit, # 新增:审计日志
|
||||
meta,
|
||||
@@ -85,6 +86,9 @@ api_router.include_router(misc.router, tags=["Misc"])
|
||||
api_router.include_router(risk.router, tags=["Risk"])
|
||||
api_router.include_router(cache.router, tags=["Cache"])
|
||||
api_router.include_router(leakage.router, prefix="/leakage", tags=["Leakage"])
|
||||
api_router.include_router(
|
||||
burst_location.router, prefix="/burst-location", tags=["Burst Location"]
|
||||
)
|
||||
|
||||
# Database Routers
|
||||
api_router.include_router(timescaledb_router, tags=["TimescaleDB"])
|
||||
|
||||
Reference in New Issue
Block a user