feat(javaTest): expose full-map route evidence

This commit is contained in:
zgw
2026-08-05 16:55:15 +08:00
parent ff8aabdf6a
commit 9946881e3a
3 changed files with 42 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package com.ft546.wcs.shadow.history.visualizer;
import com.ft546.wcs.demo.model.Site;
import com.ft546.wcs.demo.model.VehicleSnapshot;
import com.ft546.wcs.demo.traffic.GridMap;
import com.ft546.wcs.shadow.history.HistoricalQueueDataset;
import com.ft546.wcs.shadow.history.HistoricalQueueRecord;
import com.ft546.wcs.shadow.history.simulation.HistoricalDispatchSimulationResult;
@@ -41,6 +42,8 @@ public final class SimulationVisualizationMapper {
DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss");
private final HistoricalQueueDataset dataset;
private final RouteTopologyEvidenceMapper routeTopology =
new RouteTopologyEvidenceMapper();
public SimulationVisualizationMapper(HistoricalQueueDataset dataset) {
if (dataset == null) throw new IllegalArgumentException("dataset is required");
@@ -71,6 +74,8 @@ public final class SimulationVisualizationMapper {
}
payload.put("floors", new ArrayList<Integer>(floors));
payload.put("sites", sites);
// 页面底图必须使用当前 Java 地图的真实邻接边,不能在浏览器中按坐标猜路。
payload.put("edges", routeTopology.fullMapEdges(input.getGridMap()));
List<VehicleSnapshot> orderedVehicles =
new ArrayList<VehicleSnapshot>(input.getInitialVehicles());
@@ -96,7 +101,7 @@ public final class SimulationVisualizationMapper {
List<Map<String, Object>> tasks = new ArrayList<Map<String, Object>>();
for (SimulationTaskResult task : orderedTasks) {
tasks.add(task(task, definitions.get(task.getSimulationTaskId()),
result.getAcceleration()));
result.getAcceleration(), input.getGridMap()));
}
List<Map<String, Object>> events = new ArrayList<Map<String, Object>>();
for (SimulationTickEvent event : result.getEvents()) events.add(event(event));
@@ -145,7 +150,8 @@ public final class SimulationVisualizationMapper {
private Map<String, Object> task(SimulationTaskResult task,
HistoricalSimulationTask definition,
int acceleration) {
int acceleration,
GridMap gridMap) {
HistoricalQueueRecord record = task.getRecord();
List<String> historicalPath = historicalPath(record.getPathInfo());
Long historicalDuration = historicalDuration(task);
@@ -170,6 +176,9 @@ public final class SimulationVisualizationMapper {
value.put("simulatedVehicleId", task.getSimulatedVehicleId());
value.put("historicalPath", historicalPath);
value.put("plannedPath", task.getPlannedPath());
// 边差证据解释新旧路线在哪里重合或分叉,但不参与调度中心的规划结果。
value.put("pathComparison", routeTopology.compare(
gridMap, historicalPath, task.getPlannedPath()));
value.put("assignedVehicles", task.getAssignedVehicles());
value.put("status", task.getStatus().name());
value.put("reason", task.getReason());