diff --git a/simulation.py b/simulation.py index 71389fd..783a0c3 100644 --- a/simulation.py +++ b/simulation.py @@ -22,6 +22,7 @@ import uuid import project_info from api.postgresql_info import get_pgconn_string from timescaledb.internal_queries import InternalQueries as TimescaleInternalQueries +from timescaledb.internal_queries import InternalStorage as TimescaleInternalStorage logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" @@ -1229,11 +1230,11 @@ def run_simulation( # 存储 starttime = time.time() if simulation_type.upper() == "REALTIME": - TimescaleInternalQueries.store_realtime_simulation( + TimescaleInternalStorage.store_realtime_simulation( node_result, link_result, modify_pattern_start_time ) elif simulation_type.upper() == "EXTENDED": - TimescaleInternalQueries.store_scheme_simulation( + TimescaleInternalStorage.store_scheme_simulation( scheme_Type, scheme_Name, node_result, diff --git a/timescaledb/composite_queries.py b/timescaledb/composite_queries.py index 42fe46d..a102f48 100644 --- a/timescaledb/composite_queries.py +++ b/timescaledb/composite_queries.py @@ -458,7 +458,7 @@ class CompositeQueries: @staticmethod async def predict_pipeline_health( timescale_conn: AsyncConnection, - db_name: str, + network_name: str, query_time: datetime, ) -> List[Dict[str, Any]]: """ @@ -500,7 +500,7 @@ class CompositeQueries: fields = ["id", "diameter", "node1", "node2"] all_links = InternalQueries.get_links_by_property( fields=fields, - db_name=db_name, + db_name=network_name, ) # 转换为字典以快速查找 diff --git a/timescaledb/router.py b/timescaledb/router.py index 4d4ea19..436c696 100644 --- a/timescaledb/router.py +++ b/timescaledb/router.py @@ -599,7 +599,7 @@ async def clean_scada_data( @router.get("/composite/pipeline-health-prediction") async def predict_pipeline_health( query_time: datetime = Query(..., description="查询时间"), - db_name: str = Query(..., description="管网数据库名称"), + network_name: str = Query(..., description="管网数据库名称"), timescale_conn: AsyncConnection = Depends(get_database_connection), ): """ @@ -616,14 +616,9 @@ async def predict_pipeline_health( 预测结果列表,每个元素包含 link_id 和对应的生存函数 """ try: - result = await CompositeQueries.predict_pipeline_health( - timescale_conn, db_name, query_time + return await CompositeQueries.predict_pipeline_health( + timescale_conn, network_name, query_time ) - - return { - "success": True, - "result": result, - } except ValueError as e: raise HTTPException(status_code=400, detail=str(e)) except FileNotFoundError as e: