From ecfa391eea9fd35013d797b4d7b08dc0bec24a22 Mon Sep 17 00:00:00 2001 From: que01 Date: Thu, 3 Sep 2026 12:07:50 +0800 Subject: [PATCH] feat(workbench): summarize junction facilities and diagnostics --- workbench/client/src/App.tsx | 25 +++++++++++++++++++ .../client/src/junction/JunctionWorkspace.tsx | 21 ++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/workbench/client/src/App.tsx b/workbench/client/src/App.tsx index 62f8dcf..d7242a1 100644 --- a/workbench/client/src/App.tsx +++ b/workbench/client/src/App.tsx @@ -207,6 +207,29 @@ function App() { nodeIds.has(String(handle.anchor.nodeId)), ); }, [editMode, junctionDescriptor, manifest]); + const junctionFacilitySummary = useMemo(() => { + if (!junctionDescriptor || !state) return { crosswalks: 0, stopLines: 0, signals: 0 }; + const nodeIds = new Set(junctionDescriptor.nodeIds.map(String)); + const crossingIds = new Set( + (state.layers.crosswalks?.features ?? []) + .filter((feature) => nodeIds.has(String(feature.properties?.crossing_node_id))) + .map((feature) => String(feature.properties?.crossing_node_id)), + ); + const stopLines = (state.layers.vehicleStopLines?.features ?? []).filter((feature) => + nodeIds.has(String(feature.properties?.crossing_node_id)), + ).length; + const signals = state.trafficSignals.assemblies.features.filter((feature) => + nodeIds.has(String(feature.properties?.node_id)), + ).length; + return { crosswalks: crossingIds.size, stopLines, signals }; + }, [junctionDescriptor, state]); + const junctionDiagnostics = useMemo(() => { + if (!junctionDescriptor || !state) return []; + const ids = new Set(junctionDescriptor.diagnosticIds); + return state.compiled.diagnostics.filter( + (item) => ids.has(item.id) || item.subjectId === junctionDescriptor.ref.id, + ); + }, [junctionDescriptor, state]); // A greyed handle without a reason reads as a bug rather than an ownership // boundary, so the first blocked handle explains itself in the header. const blockedHandle = editHandles.find((handle) => !handle.editable); @@ -999,6 +1022,8 @@ function App() { setJunctionSession((current) => (current ? applyJunctionDraft(current) : current))} onDiscard={() => setJunctionSession((current) => (current ? cancelJunctionSession(current) : current))} diff --git a/workbench/client/src/junction/JunctionWorkspace.tsx b/workbench/client/src/junction/JunctionWorkspace.tsx index 8699f23..aaa51cb 100644 --- a/workbench/client/src/junction/JunctionWorkspace.tsx +++ b/workbench/client/src/junction/JunctionWorkspace.tsx @@ -8,6 +8,8 @@ import type { EditHandle } from '../edit/types'; interface Props { descriptor: JunctionDescriptor; session: JunctionSession; + diagnostics?: Array<{ id: string; message: string; rule: string; severity?: string }>; + facilitySummary?: { crosswalks: number; stopLines: number; signals: number }; onClose: () => void; onApply: () => void; onDiscard: () => void; @@ -26,6 +28,8 @@ export function JunctionWorkspace({ onApply, onDiscard, onSave, + diagnostics = [], + facilitySummary = { crosswalks: 0, stopLines: 0, signals: 0 }, handles = [], onDraft, onSettle, @@ -59,6 +63,23 @@ export function JunctionWorkspace({ {session.dirty ? '(有未应用草稿)' : ''} +
+

设施与验证

+

+ 斑马线 {facilitySummary.crosswalks} · 停止线 {facilitySummary.stopLines} · 信号灯 {facilitySummary.signals} +

+ {diagnostics.length ? ( +
    + {diagnostics.map((item) => ( +
  • + {item.severity === 'error' ? '阻塞' : '提示'} {item.message} +
  • + ))} +
+ ) : ( +

当前路口没有诊断问题。

+ )} +
{editable ? ( <>