fix(burst): recognize native pressure units and separate isolation impact
Generic Container CI/CD / test-build-publish (push) Successful in 4m37s
Server CI/CD v2 / build-test-publish-and-deploy (push) Successful in 4m37s

This commit is contained in:
2026-11-14 23:45:25 +08:00
parent b45c5c6f46
commit 11eb09fe8f
12 changed files with 87 additions and 11 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ GRADES = (
def _head_factor(unit: Any) -> float | None:
# Standard water head; unsupported or absent units must not become zero loss.
return {"m": 1.0, "meters": 1.0, "metres": 1.0,
return {"m": 1.0, "mtr": 1.0, "meters": 1.0, "metres": 1.0,
"kpa": 1 / 9.80665, "psi": 6894.757293168 / 9806.65,
"bar": 100000 / 9806.65, "mpa": 1000000 / 9806.65,
"ft": 0.3048}.get(str(unit).strip().lower())
+14
View File
@@ -104,3 +104,17 @@ def resolve_overlay(snapshot: TaskDataSnapshot, mode: str) -> dict:
normalized["properties"]["weight"] = weight
features.append(normalized)
return {"type": "FeatureCollection", "features": features}
def validate_overlay_stage(data: dict, stage: str | None) -> None:
"""An event-impact claim must be supported by the saved scenario geometry."""
if stage != "event_impact":
return
features = data.get("features", [])
require(bool(features) and all(
(feature.get("properties") or {}).get("impact_phase") in {
"after_burst_before_intervention", "after_contamination_before_intervention",
} for feature in features
), "OVERLAY_IMPACT_PHASE_MISMATCH",
"事件影响阶段须引用处置前情景覆盖;关阀及供水失源覆盖请使用 isolation_plan,不能替代不可用的事件降压结果",
status=422)
+2 -1
View File
@@ -75,7 +75,7 @@ from app.domain.schemas.operational_task import (
from app.domain.schemas.operational_data import TaskDataSnapshot, TaskDataSource
from app.services.content_digest import digest
from app.services.investigation_graph import adopt_legacy_investigation_graph, update_investigation_graph
from app.services.operational_presentation import resolve_overlay
from app.services.operational_presentation import resolve_overlay, validate_overlay_stage
from app.services.operational_recovery import accept_completion, track_work_order
from app.services.operational_scada_coverage import require_complete_scada_evidence
from app.services import scada_presentation_coverage
@@ -1124,6 +1124,7 @@ class OperationalTaskService:
)
require(supplied == resolved, "OVERLAY_DATA_MISMATCH",
"Overlay data must match the immutable evidence snapshot", status=422)
validate_overlay_stage(resolved, command.narration.stage if command.narration else None)
payload["data"] = resolved
metadata = {"task_id": str(task_id), "run_id": str(run["run_id"]),
"execution_generation": run["generation"], "command": payload}