fix(investigation): allow autonomous model baseline recovery
This commit is contained in:
+24
-11
@@ -79,20 +79,20 @@ async def authorize_query(
|
||||
"get_element_properties", "list_elements", "query_nearby_elements", "get_network_options",
|
||||
"get_node_connections", "get_element_gis_properties", "query_network_extent",
|
||||
"list_regions", "get_region", "get_region_nodes",
|
||||
"analyze_valve_isolation", "generate_node_coverage", "run_burst_simulation", "run_contaminant_simulation", "analyze_flushing",
|
||||
"analyze_valve_isolation", "generate_node_coverage", *SCENARIO_TOOLS,
|
||||
"calculate_demand_allocation", "optimize_sensor_placement",
|
||||
"query_model_baseline_series", "get_model_baseline_at_time", "query_model_baseline_field",
|
||||
"get_calculation_job", "get_calculation_result", "list_calculation_jobs"}
|
||||
if tool.name not in allowed:
|
||||
asset_query = tool.semantics == "asset" and not tool.mutating and not tool.computation
|
||||
if tool.name not in allowed and not asset_query:
|
||||
raise HTTPException(403, "回放调查仅开放冻结 SCADA、资产、拓扑分析及指定模型情景;时序观测请使用 query_scada_readings")
|
||||
if tool.name == "run_burst_simulation":
|
||||
if not args.include_impact_coverage:
|
||||
raise HTTPException(422, "回放爆管情景必须启用影响覆盖,按当前模型估计并保存同刻在线基线")
|
||||
check_replay_window(replay_context, args.start_time, args.start_time)
|
||||
if tool.name == "run_contaminant_simulation":
|
||||
if not args.include_impact_coverage:
|
||||
raise HTTPException(422, "回放污染情景必须启用影响覆盖,按当前模型估计传播范围")
|
||||
check_replay_window(replay_context, args.start_time, args.start_time)
|
||||
if tool.name == "analyze_flushing":
|
||||
if tool.name in SCENARIO_TOOLS:
|
||||
check_replay_window(replay_context, args.start_time, args.start_time)
|
||||
if tool.semantics == "model_baseline":
|
||||
if tool.name == "query_model_baseline_series":
|
||||
check_replay_window(replay_context, args.start, args.end)
|
||||
else:
|
||||
check_replay_window(replay_context, args.time, args.time)
|
||||
if tool.name == "query_scada_readings":
|
||||
check_replay_window(replay_context, args.start, args.end)
|
||||
if tool.name == "run_contaminant_source_trace":
|
||||
@@ -213,6 +213,17 @@ async def execute_query(
|
||||
args.device_ids, args.start, args.end, args.limit + 1, args.offset)
|
||||
data, page, truncated = page_result(rows, args)
|
||||
origin = "synthetic"
|
||||
elif name in {"run_simulation", "analyze_valve_closure", "analyze_pressure_regulation"} and replay_context:
|
||||
from app.mcp.analysis_service import calculate_replay_hydraulic_scenario
|
||||
|
||||
await conn.commit()
|
||||
async with scope.simulation_routing():
|
||||
result = await calculate_replay_hydraulic_scenario(
|
||||
name, args, network=scope.project.project_code, username=scope.user.username,
|
||||
)
|
||||
data = {"parameters": args.model_dump(mode="json", exclude={"context_handle"}), "result": result}
|
||||
origin = "synthetic"
|
||||
gaps = ["回放水力计算使用当前模型,不读取实时SCADA,不代表冻结观测或历史模型重建。在线模拟更新模型基线,关阀及调压仅评估隔离情景;未来模拟样本仅为预测。"]
|
||||
elif name == "run_burst_simulation" and replay_context:
|
||||
from app.mcp.analysis_service import calculate_replay_burst_simulation
|
||||
|
||||
@@ -632,6 +643,8 @@ async def execute_query(
|
||||
truncated = snapshot.truncated
|
||||
else:
|
||||
raise ValueError("query handler is not registered")
|
||||
if replay_context and tool.semantics == "model_baseline":
|
||||
gaps.append("在线模型参考按本次查询时可用数据读取,非冻结SCADA观测;历史报告复用已保存证据。")
|
||||
window = (
|
||||
{"start": args.start, "end": args.end}
|
||||
if hasattr(args, "start") and args.start is not None
|
||||
|
||||
Reference in New Issue
Block a user