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:
2026-08-28 11:37:36 +08:00
parent b74799a39d
commit 9b095c7439
34 changed files with 859 additions and 921 deletions
+1 -23
View File
@@ -10,14 +10,11 @@ import pandas as pd
from app.algorithms.burst_location import run_burst_location
from app.infra.db.timescaledb.internal_queries import InternalQueries
from app.services.scheme_management import (
query_burst_location_scheme_detail,
query_burst_location_schemes,
get_analysis_run,
scheme_name_exists,
store_scheme_info,
)
from app.services.tjnetwork import dump_inp, 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
SeriesInput = pd.Series | dict[str, Any] | list[dict[str, Any]]
FLOW_SCADA_TYPES = {"pipe_flow", "flow", "demand"}
@@ -367,22 +364,6 @@ def run_burst_location_by_network(
return payload
def list_burst_location_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_location_schemes(
name=network, network=network, query_date=parsed_date
)
def get_burst_location_scheme_detail(network: str, scheme_name: str) -> dict[str, Any]:
result = query_burst_location_scheme_detail(network, scheme_name)
if not result:
raise ValueError(f"未找到爆管定位方案: {scheme_name}")
return result
def _store_burst_scheme(
*,
network: str,
@@ -393,9 +374,6 @@ def _store_burst_scheme(
min_dpressure: float,
basic_pressure: float,
) -> None:
if scheme_name_exists(network, scheme_name):
raise ValueError(f"方案名称已存在: {scheme_name}")
now_iso = utc_now().isoformat()
scheme_detail = {
"network": network,