移除实时数据和仿真结果接口,优化代码结构
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from typing import Any
|
||||
import random
|
||||
from fastapi import APIRouter, Query
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi import status
|
||||
@@ -63,24 +62,3 @@ async def fastapi_test_dict(data: Item) -> dict[str, str]:
|
||||
"""
|
||||
item = data.dict()
|
||||
return item
|
||||
|
||||
@router.get("/getrealtimedata/", summary="获取实时数据", description="获取实时监测数据")
|
||||
async def fastapi_get_realtimedata():
|
||||
"""
|
||||
获取实时数据
|
||||
|
||||
返回随机生成的实时监测数据示例
|
||||
"""
|
||||
data = [random.randint(0, 100) for _ in range(100)]
|
||||
return data
|
||||
|
||||
|
||||
@router.get("/getsimulationresult/", summary="获取模拟结果", description="获取仿真计算结果")
|
||||
async def fastapi_get_simulationresult():
|
||||
"""
|
||||
获取仿真结果
|
||||
|
||||
返回随机生成的仿真计算结果示例
|
||||
"""
|
||||
data = [random.randint(0, 100) for _ in range(100)]
|
||||
return data
|
||||
|
||||
@@ -195,26 +195,6 @@ async def dump_output_endpoint(output: str = Query(..., description="模拟输
|
||||
|
||||
|
||||
# Analysis Endpoints
|
||||
@router.get("/burstanalysis/", summary="爆管分析(基础)", description="对管网中的爆管事件进行分析,包括爆管对管网压力和流量的影响。此为基础版本,接收简化的查询参数。")
|
||||
async def burst_analysis_endpoint(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
pipe_id: str = Query(..., description="管段ID"),
|
||||
start_time: str = Query(..., description="分析开始时间(ISO 8601格式)"),
|
||||
end_time: str = Query(..., description="分析结束时间(ISO 8601格式)"),
|
||||
burst_flow: float = Query(..., description="爆管流量大小(L/s)"),
|
||||
):
|
||||
"""
|
||||
爆管分析(基础版本)
|
||||
|
||||
- **network**: 管网名称(或数据库名称)
|
||||
- **pipe_id**: 管段ID
|
||||
- **start_time**: 分析开始时间
|
||||
- **end_time**: 分析结束时间
|
||||
- **burst_flow**: 爆管流量大小
|
||||
"""
|
||||
return burst_analysis(network, pipe_id, start_time, end_time, burst_flow)
|
||||
|
||||
|
||||
@router.get("/burst_analysis/", summary="爆管分析(高级)", description="高级版本的爆管分析,支持在指定时间点修改泵控制模式和阀门开度,以分析这些改变对爆管影响的作用。支持固定泵和变速泵的独立控制。")
|
||||
async def fastapi_burst_analysis(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
@@ -247,24 +227,6 @@ async def fastapi_burst_analysis(
|
||||
return "success"
|
||||
|
||||
|
||||
@router.get("/valvecloseanalysis/", summary="阀门关闭分析(基础)", description="对管网中的阀门关闭事件进行分析,评估关闭阀门对管网的影响。此为基础版本。")
|
||||
async def valve_close_analysis_endpoint(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
valve_id: str = Query(..., description="阀门ID"),
|
||||
start_time: str = Query(..., description="分析开始时间(ISO 8601格式)"),
|
||||
end_time: str = Query(..., description="分析结束时间(ISO 8601格式)"),
|
||||
):
|
||||
"""
|
||||
阀门关闭分析(基础版本)
|
||||
|
||||
- **network**: 管网名称(或数据库名称)
|
||||
- **valve_id**: 阀门ID
|
||||
- **start_time**: 分析开始时间
|
||||
- **end_time**: 分析结束时间
|
||||
"""
|
||||
return valve_close_analysis(network, valve_id, start_time, end_time)
|
||||
|
||||
|
||||
@router.get("/valve_close_analysis/", response_class=PlainTextResponse, summary="阀门关闭分析(高级)", description="高级版本的阀门关闭分析,支持同时关闭多个阀门,并在指定持续时间内进行模拟。返回纯文本格式的分析结果。")
|
||||
async def fastapi_valve_close_analysis(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
@@ -331,26 +293,6 @@ async def valve_isolation_endpoint(
|
||||
return result
|
||||
|
||||
|
||||
@router.get("/flushinganalysis/", summary="冲洗分析(基础)", description="对管网的冲洗操作进行分析,评估冲洗流量和持续时间对管网的影响。此为基础版本。")
|
||||
async def flushing_analysis_endpoint(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
pipe_id: str = Query(..., description="要冲洗的管段ID"),
|
||||
start_time: str = Query(..., description="冲洗开始时间(ISO 8601格式)"),
|
||||
duration: float = Query(..., description="冲洗持续时间(分钟)"),
|
||||
flow: float = Query(..., description="冲洗流量(L/s)"),
|
||||
):
|
||||
"""
|
||||
冲洗分析(基础版本)
|
||||
|
||||
- **network**: 管网名称(或数据库名称)
|
||||
- **pipe_id**: 要冲洗的管段ID
|
||||
- **start_time**: 冲洗开始时间
|
||||
- **duration**: 冲洗持续时间(分钟)
|
||||
- **flow**: 冲洗流量(L/s)
|
||||
"""
|
||||
return flushing_analysis(network, pipe_id, start_time, duration, flow)
|
||||
|
||||
|
||||
@router.get("/flushing_analysis/", response_class=PlainTextResponse, summary="冲洗分析(高级)", description="高级版本的冲洗分析,支持同时开启多个阀门进行冲洗,指定排污节点,并设置固定的冲洗流量。返回纯文本格式的分析结果。")
|
||||
async def fastapi_flushing_analysis(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
@@ -426,23 +368,10 @@ async def fastapi_contaminant_simulation(
|
||||
return result or "success"
|
||||
|
||||
|
||||
@router.get("/ageanalysis/", summary="水龄分析(基础)", description="对管网中的水体停留时间(水龄)进行分析。此为基础版本。")
|
||||
async def age_analysis_endpoint(network: str = Query(..., description="管网名称(或数据库名称)")):
|
||||
"""
|
||||
水龄分析(基础版本)
|
||||
|
||||
- **network**: 管网名称(或数据库名称)
|
||||
|
||||
分析管网中各节点的水体停留时间。
|
||||
"""
|
||||
return age_analysis(network)
|
||||
|
||||
|
||||
@router.get("/age_analysis/", response_class=PlainTextResponse, summary="水龄分析(高级)", description="高级版本的水龄分析,在指定时间点进行分析,支持自定义模拟持续时间。返回纯文本格式的分析结果。")
|
||||
async def fastapi_age_analysis(
|
||||
network: str = Query(..., description="管网名称(或数据库名称)"),
|
||||
start_time: str = Query(..., description="分析开始时间(ISO 8601格式)"),
|
||||
end_time: str = Query(..., description="分析结束时间(ISO 8601格式)"),
|
||||
duration: int = Query(..., description="模拟持续时间(秒)"),
|
||||
) -> str:
|
||||
"""
|
||||
@@ -450,7 +379,6 @@ async def fastapi_age_analysis(
|
||||
|
||||
- **network**: 管网名称(或数据库名称)
|
||||
- **start_time**: 分析开始时间
|
||||
- **end_time**: 分析结束时间(可选)
|
||||
- **duration**: 模拟持续时间(秒)
|
||||
|
||||
分析指定时间段内管网中各节点的水体停留时间。
|
||||
@@ -520,18 +448,6 @@ async def fastapi_pressure_regulation(data: PressureRegulation = Body(..., descr
|
||||
return "success"
|
||||
|
||||
|
||||
@router.get("/projectmanagement/", summary="项目管理(基础)", description="对管网项目进行基础的管理操作。此为基础版本。")
|
||||
async def project_management_endpoint(network: str = Query(..., description="管网名称(或数据库名称)")):
|
||||
"""
|
||||
项目管理(基础版本)
|
||||
|
||||
- **network**: 管网名称(或数据库名称)
|
||||
|
||||
进行基础的项目管理操作。
|
||||
"""
|
||||
return project_management(network)
|
||||
|
||||
|
||||
@router.post("/project_management/", summary="项目管理(高级)", description="高级版本的项目管理,通过JSON请求体提供详细的控制参数,包括泵控制策略、水箱初始水位和区域需水量控制。")
|
||||
async def fastapi_project_management(data: ProjectManagement = Body(..., description="项目管理控制参数")) -> str:
|
||||
"""
|
||||
@@ -633,18 +549,6 @@ async def fastapi_network_project(file: UploadFile = File(..., description="INP
|
||||
return run_inp(temp_file_name)
|
||||
|
||||
|
||||
@router.get("/networkupdate/", summary="管网更新(基础)", description="对指定管网项目进行基础的更新操作。此为基础版本。")
|
||||
async def network_update_endpoint(network: str = Query(..., description="管网名称(或数据库名称)")):
|
||||
"""
|
||||
管网更新(基础版本)
|
||||
|
||||
- **network**: 管网名称(或数据库名称)
|
||||
|
||||
进行管网的基础更新操作。
|
||||
"""
|
||||
return network_update(network)
|
||||
|
||||
|
||||
@router.post("/network_update/", summary="管网更新(高级)", description="通过上传更新文件对管网进行高级的更新操作。系统将处理更新文件并应用到数据库。")
|
||||
async def fastapi_network_update(file: UploadFile = File(..., description="包含管网更新信息的文件")) -> str:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user