更新参数名;更新引用类

This commit is contained in:
JIANG
2025-12-18 14:50:29 +08:00
parent 971386ae5a
commit 2b268081b1
3 changed files with 8 additions and 12 deletions

View File

@@ -22,6 +22,7 @@ import uuid
import project_info import project_info
from api.postgresql_info import get_pgconn_string from api.postgresql_info import get_pgconn_string
from timescaledb.internal_queries import InternalQueries as TimescaleInternalQueries from timescaledb.internal_queries import InternalQueries as TimescaleInternalQueries
from timescaledb.internal_queries import InternalStorage as TimescaleInternalStorage
logging.basicConfig( logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
@@ -1229,11 +1230,11 @@ def run_simulation(
# 存储 # 存储
starttime = time.time() starttime = time.time()
if simulation_type.upper() == "REALTIME": if simulation_type.upper() == "REALTIME":
TimescaleInternalQueries.store_realtime_simulation( TimescaleInternalStorage.store_realtime_simulation(
node_result, link_result, modify_pattern_start_time node_result, link_result, modify_pattern_start_time
) )
elif simulation_type.upper() == "EXTENDED": elif simulation_type.upper() == "EXTENDED":
TimescaleInternalQueries.store_scheme_simulation( TimescaleInternalStorage.store_scheme_simulation(
scheme_Type, scheme_Type,
scheme_Name, scheme_Name,
node_result, node_result,

View File

@@ -458,7 +458,7 @@ class CompositeQueries:
@staticmethod @staticmethod
async def predict_pipeline_health( async def predict_pipeline_health(
timescale_conn: AsyncConnection, timescale_conn: AsyncConnection,
db_name: str, network_name: str,
query_time: datetime, query_time: datetime,
) -> List[Dict[str, Any]]: ) -> List[Dict[str, Any]]:
""" """
@@ -500,7 +500,7 @@ class CompositeQueries:
fields = ["id", "diameter", "node1", "node2"] fields = ["id", "diameter", "node1", "node2"]
all_links = InternalQueries.get_links_by_property( all_links = InternalQueries.get_links_by_property(
fields=fields, fields=fields,
db_name=db_name, db_name=network_name,
) )
# 转换为字典以快速查找 # 转换为字典以快速查找

View File

@@ -599,7 +599,7 @@ async def clean_scada_data(
@router.get("/composite/pipeline-health-prediction") @router.get("/composite/pipeline-health-prediction")
async def predict_pipeline_health( async def predict_pipeline_health(
query_time: datetime = Query(..., description="查询时间"), query_time: datetime = Query(..., description="查询时间"),
db_name: str = Query(..., description="管网数据库名称"), network_name: str = Query(..., description="管网数据库名称"),
timescale_conn: AsyncConnection = Depends(get_database_connection), timescale_conn: AsyncConnection = Depends(get_database_connection),
): ):
""" """
@@ -616,14 +616,9 @@ async def predict_pipeline_health(
预测结果列表,每个元素包含 link_id 和对应的生存函数 预测结果列表,每个元素包含 link_id 和对应的生存函数
""" """
try: try:
result = await CompositeQueries.predict_pipeline_health( return await CompositeQueries.predict_pipeline_health(
timescale_conn, db_name, query_time timescale_conn, network_name, query_time
) )
return {
"success": True,
"result": result,
}
except ValueError as e: except ValueError as e:
raise HTTPException(status_code=400, detail=str(e)) raise HTTPException(status_code=400, detail=str(e))
except FileNotFoundError as e: except FileNotFoundError as e: