refactor(db)!: clean up business SQL access
- make realtime replacement and analysis result writes transactional\n- consolidate SCADA repositories and remove process-global project state\n- validate SCADA batches and use indexed GIS-backed business queries\n\nBREAKING CHANGE: remove the public analysis result writer and the pipeline-health network_name query parameter.
This commit is contained in:
@@ -11,13 +11,10 @@ import pandas as pd
|
||||
from app.algorithms.burst_detection.burst_detector import BurstDetector
|
||||
from app.infra.db.timescaledb.internal_queries import InternalQueries
|
||||
from app.services.scheme_management import (
|
||||
query_burst_detection_scheme_detail,
|
||||
query_burst_detection_schemes,
|
||||
scheme_name_exists,
|
||||
store_scheme_info,
|
||||
)
|
||||
from app.services.tjnetwork import get_all_scada_info
|
||||
from app.services.time_api import extract_date, parse_utc_time, utc_now
|
||||
from app.services.time_api import parse_utc_time, utc_now
|
||||
|
||||
|
||||
TARGET_DAY_COUNT = 15
|
||||
@@ -365,25 +362,6 @@ def _build_observed_pressure_from_simulation(
|
||||
return observation_df
|
||||
|
||||
|
||||
def list_burst_detection_schemes(
|
||||
network: str,
|
||||
query_date: datetime | str | None = None,
|
||||
) -> list[dict[str, Any]]:
|
||||
parsed_date = extract_date(query_date, field_name="query_date") if query_date is not None else None
|
||||
return query_burst_detection_schemes(
|
||||
name=network,
|
||||
network=network,
|
||||
query_date=parsed_date,
|
||||
)
|
||||
|
||||
|
||||
def get_burst_detection_scheme_detail(network: str, scheme_name: str) -> dict[str, Any]:
|
||||
result = query_burst_detection_scheme_detail(network, scheme_name)
|
||||
if not result:
|
||||
raise ValueError(f"未找到爆管侦测方案: {scheme_name}")
|
||||
return result
|
||||
|
||||
|
||||
def _store_burst_detection_scheme(
|
||||
*,
|
||||
network: str,
|
||||
@@ -394,9 +372,6 @@ def _store_burst_detection_scheme(
|
||||
points_per_day: int,
|
||||
iforest_params: dict[str, Any],
|
||||
) -> None:
|
||||
if scheme_name_exists(network, scheme_name):
|
||||
raise ValueError(f"方案名称已存在: {scheme_name}")
|
||||
|
||||
now_iso = utc_now().isoformat()
|
||||
scheme_detail = {
|
||||
"network": network,
|
||||
|
||||
Reference in New Issue
Block a user