From e4271d60003223566b67d141e4d330b8bb4d7162 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 21 三月 2026 21:04:08 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java | 334 +++++++++++++++++++++++++++++++++++++++++
src/main/java/com/zy/core/trace/StationTaskTraceRegistry.java | 95 +++++++++++
src/main/java/com/zy/asrs/domain/vo/StationTaskTraceVo.java | 8 +
src/main/webapp/views/watch/stationTrace.html | 19 ++
src/main/java/com/zy/common/utils/NavigateUtils.java | 13 +
5 files changed, 463 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/zy/asrs/domain/vo/StationTaskTraceVo.java b/src/main/java/com/zy/asrs/domain/vo/StationTaskTraceVo.java
index 945c8e4..1ded766 100644
--- a/src/main/java/com/zy/asrs/domain/vo/StationTaskTraceVo.java
+++ b/src/main/java/com/zy/asrs/domain/vo/StationTaskTraceVo.java
@@ -39,6 +39,14 @@
private Integer totalSegmentCount;
+ private Boolean loopAlertActive;
+
+ private String loopAlertType;
+
+ private String loopAlertText;
+
+ private Integer loopAlertCount;
+
private Long updatedAt;
private List<StationTaskTraceEventVo> events;
diff --git a/src/main/java/com/zy/common/utils/NavigateUtils.java b/src/main/java/com/zy/common/utils/NavigateUtils.java
index 6219dbc..eed3ee1 100644
--- a/src/main/java/com/zy/common/utils/NavigateUtils.java
+++ b/src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -102,6 +102,19 @@
return normalizeCandidatePaths(orderedPathList);
}
+ public synchronized Map<Integer, Set<Integer>> loadUndirectedStationGraphSnapshot() {
+ Map<Integer, Set<Integer>> graph = loadUndirectedStationGraph();
+ Map<Integer, Set<Integer>> snapshot = new HashMap<>();
+ for (Map.Entry<Integer, Set<Integer>> entry : graph.entrySet()) {
+ Integer stationId = entry.getKey();
+ if (stationId == null) {
+ continue;
+ }
+ snapshot.put(stationId, new LinkedHashSet<>(entry.getValue() == null ? Collections.emptySet() : entry.getValue()));
+ }
+ return snapshot;
+ }
+
private synchronized List<NavigateNode> calcByStationId(Integer startStationId,
Integer endStationId,
Integer currentTaskNo,
diff --git a/src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java b/src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java
index f35e6b1..212a2ec 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java
@@ -32,14 +32,17 @@
import com.zy.core.network.ZyStationConnectDriver;
import com.zy.core.network.entity.ZyStationStatusEntity;
import com.zy.core.thread.impl.v5.StationV5SegmentExecutor;
+import com.zy.core.trace.StationTaskTraceRegistry;
import com.zy.core.utils.DeviceLogRedisKeyBuilder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.ArrayDeque;
import java.util.Collections;
import java.util.Date;
+import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -56,7 +59,8 @@
private static final int RUN_BLOCK_REROUTE_STATE_EXPIRE_SECONDS = 60 * 60 * 24;
private static final int SHORT_PATH_REPEAT_AVOID_THRESHOLD = 2;
- private static final int SMALL_LOOP_REPEAT_AVOID_THRESHOLD = 2;
+ private static final int LOOP_REPEAT_TRIGGER_COUNT = 2;
+ private static final int LOCAL_LOOP_NEIGHBOR_HOP = 3;
private List<StationProtocol> statusList = new ArrayList<>();
private DeviceConfig deviceConfig;
@@ -262,6 +266,12 @@
RunBlockRerouteState rerouteState = loadRunBlockRerouteState(taskNo, stationId);
TaskLoopRerouteState taskLoopRerouteState = loadTaskLoopRerouteState(taskNo);
LoopIdentity currentLoopIdentity = resolveStationLoopIdentity(stationId);
+ log.info("杈撻�佺嚎鍫靛閲嶈鍒掔幆绾胯瘑鍒紝taskNo={}, stationId={}, scopeType={}, localStationCount={}, sourceLoopStationCount={}",
+ taskNo,
+ stationId,
+ currentLoopIdentity.getScopeType(),
+ currentLoopIdentity.getLocalStationCount(),
+ currentLoopIdentity.getSourceLoopStationCount());
rerouteState.setTaskNo(taskNo);
rerouteState.setBlockStationId(stationId);
rerouteState.setLastTargetStationId(targetStationId);
@@ -306,6 +316,8 @@
if (rerouteCommand != null) {
saveRunBlockRerouteState(rerouteState);
touchTaskLoopRerouteState(taskLoopRerouteState, currentLoopIdentity);
+ syncTaskTraceLoopAlert(taskNo, stationId, currentLoopIdentity,
+ resolveCurrentLoopIssuedCount(taskLoopRerouteState, currentLoopIdentity));
saveTaskLoopRerouteState(taskLoopRerouteState);
log.info("杈撻�佺嚎鍫靛閲嶈鍒掗�変腑鍊欓�夎矾绾匡紝taskNo={}, planCount={}, stationId={}, targetStationId={}, route={}",
taskNo, rerouteState.getPlanCount(), stationId, targetStationId, JSON.toJSONString(rerouteCommand.getNavigatePath()));
@@ -455,7 +467,7 @@
}
Set<String> issuedRouteSignatureSet = rerouteState.getIssuedRouteSignatureSet();
- int currentLoopIssuedCount = resolveCurrentLoopIssuedCount(taskLoopRerouteState, currentLoopIdentity);
+ int currentLoopIssuedCount = resolveExpectedLoopIssuedCount(taskLoopRerouteState, currentLoopIdentity);
List<RerouteCandidateCommand> candidateCommandList = new ArrayList<>();
for (List<NavigateNode> candidatePath : candidatePathList) {
StationCommand rerouteCommand = buildMoveCommand(taskNo, stationId, targetStationId, palletSize, candidatePath);
@@ -539,7 +551,7 @@
}
if (!Cools.isEmpty(candidateCommand.getLoopFingerprint())
&& candidateCommand.getLoopIssuedCount() != null
- && candidateCommand.getLoopIssuedCount() >= SMALL_LOOP_REPEAT_AVOID_THRESHOLD) {
+ && isLoopRepeatTriggered(candidateCommand.getLoopIssuedCount())) {
currentLoopOverused = true;
}
}
@@ -686,6 +698,64 @@
return taskLoopRerouteState.getLoopIssueCountMap().getOrDefault(currentLoopIdentity.getLoopFingerprint(), 0);
}
+ private int resolveExpectedLoopIssuedCount(TaskLoopRerouteState taskLoopRerouteState,
+ LoopIdentity currentLoopIdentity) {
+ if (currentLoopIdentity == null || Cools.isEmpty(currentLoopIdentity.getLoopFingerprint())) {
+ return 0;
+ }
+ return resolveCurrentLoopIssuedCount(taskLoopRerouteState, currentLoopIdentity) + 1;
+ }
+
+ private boolean isLoopRepeatTriggered(Integer loopIssuedCount) {
+ return loopIssuedCount != null && loopIssuedCount >= LOOP_REPEAT_TRIGGER_COUNT;
+ }
+
+ private void syncTaskTraceLoopAlert(Integer taskNo,
+ Integer blockedStationId,
+ LoopIdentity currentLoopIdentity,
+ int loopIssuedCount) {
+ StationTaskTraceRegistry traceRegistry;
+ try {
+ traceRegistry = SpringUtils.getBean(StationTaskTraceRegistry.class);
+ } catch (Exception ignore) {
+ return;
+ }
+ if (traceRegistry == null || taskNo == null || taskNo <= 0) {
+ return;
+ }
+
+ boolean active = currentLoopIdentity != null
+ && !Cools.isEmpty(currentLoopIdentity.getLoopFingerprint())
+ && isLoopRepeatTriggered(loopIssuedCount);
+ Map<String, Object> details = new HashMap<>();
+ details.put("blockedStationId", blockedStationId);
+ details.put("loopScopeType", currentLoopIdentity == null ? "" : currentLoopIdentity.getScopeType());
+ details.put("loopStationCount", currentLoopIdentity == null ? 0 : currentLoopIdentity.getLocalStationCount());
+ details.put("sourceLoopStationCount", currentLoopIdentity == null ? 0 : currentLoopIdentity.getSourceLoopStationCount());
+ details.put("loopRepeatCount", loopIssuedCount);
+ String loopAlertType = resolveLoopAlertType(currentLoopIdentity);
+ String loopAlertText = buildLoopAlertText(loopAlertType, currentLoopIdentity, loopIssuedCount);
+ traceRegistry.updateLoopHint(taskNo, active, loopAlertType, loopAlertText, loopIssuedCount, details);
+ }
+
+ private String resolveLoopAlertType(LoopIdentity currentLoopIdentity) {
+ if (currentLoopIdentity == null || Cools.isEmpty(currentLoopIdentity.getLoopFingerprint())) {
+ return "";
+ }
+ return "wholeLoop".equals(currentLoopIdentity.getScopeType()) ? "LARGE_LOOP" : "SMALL_LOOP";
+ }
+
+ private String buildLoopAlertText(String loopAlertType,
+ LoopIdentity currentLoopIdentity,
+ int loopIssuedCount) {
+ if (Cools.isEmpty(loopAlertType) || currentLoopIdentity == null || !isLoopRepeatTriggered(loopIssuedCount)) {
+ return "";
+ }
+ String typeLabel = "LARGE_LOOP".equals(loopAlertType) ? "澶х幆绾�" : "灏忕幆绾�";
+ return typeLabel + "缁曞湀棰勮锛岀疮璁¢噸瑙勫垝" + loopIssuedCount + "娆★紝褰撳墠璇嗗埆鑼冨洿"
+ + currentLoopIdentity.getLocalStationCount() + "绔�";
+ }
+
private int countCurrentLoopStationHit(List<Integer> path, Set<Integer> currentLoopStationIdSet) {
if (path == null || path.isEmpty() || currentLoopStationIdSet == null || currentLoopStationIdSet.isEmpty()) {
return 0;
@@ -738,11 +808,247 @@
if (loopStationIdList.isEmpty() || !loopStationIdList.contains(stationId)) {
continue;
}
- return new LoopIdentity(buildLoopFingerprint(loopStationIdList), new HashSet<>(loopStationIdList));
+ Set<Integer> loopStationIdSet = new HashSet<>(loopStationIdList);
+ Map<Integer, Set<Integer>> stationGraph = loadUndirectedStationGraph();
+ List<Integer> localCycleStationIdList = resolveLocalCycleStationIdList(stationId, loopStationIdSet, stationGraph);
+ if (localCycleStationIdList.size() >= 3) {
+ return buildLoopIdentity(localCycleStationIdList, loopStationIdList.size(), "localCycle");
+ }
+
+ List<Integer> localNeighborhoodStationIdList = resolveLocalNeighborhoodStationIdList(stationId, loopStationIdSet, stationGraph);
+ if (localNeighborhoodStationIdList.size() >= 3 && localNeighborhoodStationIdList.size() < loopStationIdList.size()) {
+ return buildLoopIdentity(localNeighborhoodStationIdList, loopStationIdList.size(), "localNeighborhood");
+ }
+ return buildLoopIdentity(loopStationIdList, loopStationIdList.size(), "wholeLoop");
}
} catch (Exception ignore) {
}
return LoopIdentity.empty();
+ }
+
+ private LoopIdentity buildLoopIdentity(List<Integer> stationIdList,
+ int sourceLoopStationCount,
+ String scopeType) {
+ List<Integer> normalizedStationIdList = normalizeLoopStationIdList(stationIdList);
+ if (normalizedStationIdList.isEmpty()) {
+ return LoopIdentity.empty();
+ }
+ return new LoopIdentity(
+ buildLoopFingerprint(normalizedStationIdList),
+ new HashSet<>(normalizedStationIdList),
+ sourceLoopStationCount,
+ normalizedStationIdList.size(),
+ scopeType
+ );
+ }
+
+ private List<Integer> resolveLocalCycleStationIdList(Integer stationId,
+ Set<Integer> loopStationIdSet,
+ Map<Integer, Set<Integer>> stationGraph) {
+ if (stationId == null
+ || stationId <= 0
+ || loopStationIdSet == null
+ || loopStationIdSet.isEmpty()
+ || stationGraph == null
+ || stationGraph.isEmpty()) {
+ return new ArrayList<>();
+ }
+ Set<Integer> localNeighborhoodStationIdSet = collectLoopNeighborhoodStationIdSet(
+ stationId,
+ loopStationIdSet,
+ stationGraph,
+ LOCAL_LOOP_NEIGHBOR_HOP
+ );
+ if (localNeighborhoodStationIdSet.size() < 3) {
+ return new ArrayList<>();
+ }
+
+ Set<Integer> directNeighborStationIdSet = filterLoopNeighborStationIdSet(
+ stationGraph.getOrDefault(stationId, Collections.emptySet()),
+ localNeighborhoodStationIdSet,
+ stationId
+ );
+ if (directNeighborStationIdSet.size() < 2) {
+ return new ArrayList<>();
+ }
+
+ List<Integer> bestCycleStationIdList = new ArrayList<>();
+ List<Integer> neighborStationIdList = new ArrayList<>(directNeighborStationIdSet);
+ for (int i = 0; i < neighborStationIdList.size(); i++) {
+ Integer leftNeighborStationId = neighborStationIdList.get(i);
+ if (leftNeighborStationId == null) {
+ continue;
+ }
+ for (int j = i + 1; j < neighborStationIdList.size(); j++) {
+ Integer rightNeighborStationId = neighborStationIdList.get(j);
+ if (rightNeighborStationId == null) {
+ continue;
+ }
+ List<Integer> pathBetweenNeighbors = findShortestScopePath(
+ leftNeighborStationId,
+ rightNeighborStationId,
+ stationId,
+ localNeighborhoodStationIdSet,
+ stationGraph
+ );
+ if (pathBetweenNeighbors.isEmpty()) {
+ continue;
+ }
+ List<Integer> cycleStationIdList = new ArrayList<>();
+ cycleStationIdList.add(stationId);
+ cycleStationIdList.addAll(pathBetweenNeighbors);
+ cycleStationIdList = normalizeLoopStationIdList(cycleStationIdList);
+ if (cycleStationIdList.size() < 3) {
+ continue;
+ }
+ if (bestCycleStationIdList.isEmpty() || cycleStationIdList.size() < bestCycleStationIdList.size()) {
+ bestCycleStationIdList = cycleStationIdList;
+ }
+ }
+ }
+ return bestCycleStationIdList;
+ }
+
+ private List<Integer> resolveLocalNeighborhoodStationIdList(Integer stationId,
+ Set<Integer> loopStationIdSet,
+ Map<Integer, Set<Integer>> stationGraph) {
+ return normalizeLoopStationIdList(new ArrayList<>(collectLoopNeighborhoodStationIdSet(
+ stationId,
+ loopStationIdSet,
+ stationGraph,
+ LOCAL_LOOP_NEIGHBOR_HOP
+ )));
+ }
+
+ private Set<Integer> collectLoopNeighborhoodStationIdSet(Integer stationId,
+ Set<Integer> loopStationIdSet,
+ Map<Integer, Set<Integer>> stationGraph,
+ int maxHop) {
+ Set<Integer> neighborhoodStationIdSet = new LinkedHashSet<>();
+ if (stationId == null
+ || stationId <= 0
+ || loopStationIdSet == null
+ || loopStationIdSet.isEmpty()
+ || !loopStationIdSet.contains(stationId)
+ || stationGraph == null
+ || stationGraph.isEmpty()
+ || maxHop < 0) {
+ return neighborhoodStationIdSet;
+ }
+
+ Deque<StationHopNode> queue = new ArrayDeque<>();
+ queue.offer(new StationHopNode(stationId, 0));
+ neighborhoodStationIdSet.add(stationId);
+ while (!queue.isEmpty()) {
+ StationHopNode current = queue.poll();
+ if (current == null || current.getHop() >= maxHop) {
+ continue;
+ }
+ Set<Integer> neighborStationIdSet = filterLoopNeighborStationIdSet(
+ stationGraph.getOrDefault(current.getStationId(), Collections.emptySet()),
+ loopStationIdSet,
+ null
+ );
+ for (Integer neighborStationId : neighborStationIdSet) {
+ if (neighborStationId == null || !neighborhoodStationIdSet.add(neighborStationId)) {
+ continue;
+ }
+ queue.offer(new StationHopNode(neighborStationId, current.getHop() + 1));
+ }
+ }
+ return neighborhoodStationIdSet;
+ }
+
+ private Set<Integer> filterLoopNeighborStationIdSet(Set<Integer> candidateNeighborStationIdSet,
+ Set<Integer> allowedStationIdSet,
+ Integer excludedStationId) {
+ Set<Integer> result = new LinkedHashSet<>();
+ if (candidateNeighborStationIdSet == null || candidateNeighborStationIdSet.isEmpty()
+ || allowedStationIdSet == null || allowedStationIdSet.isEmpty()) {
+ return result;
+ }
+ for (Integer stationId : candidateNeighborStationIdSet) {
+ if (stationId == null
+ || !allowedStationIdSet.contains(stationId)
+ || (excludedStationId != null && excludedStationId.equals(stationId))) {
+ continue;
+ }
+ result.add(stationId);
+ }
+ return result;
+ }
+
+ private List<Integer> findShortestScopePath(Integer startStationId,
+ Integer endStationId,
+ Integer excludedStationId,
+ Set<Integer> allowedStationIdSet,
+ Map<Integer, Set<Integer>> stationGraph) {
+ if (startStationId == null
+ || endStationId == null
+ || Objects.equals(startStationId, excludedStationId)
+ || Objects.equals(endStationId, excludedStationId)
+ || allowedStationIdSet == null
+ || !allowedStationIdSet.contains(startStationId)
+ || !allowedStationIdSet.contains(endStationId)
+ || stationGraph == null
+ || stationGraph.isEmpty()) {
+ return new ArrayList<>();
+ }
+
+ Deque<Integer> queue = new ArrayDeque<>();
+ Map<Integer, Integer> parentMap = new HashMap<>();
+ Set<Integer> visitedStationIdSet = new HashSet<>();
+ queue.offer(startStationId);
+ visitedStationIdSet.add(startStationId);
+ while (!queue.isEmpty()) {
+ Integer currentStationId = queue.poll();
+ if (currentStationId == null) {
+ continue;
+ }
+ if (Objects.equals(currentStationId, endStationId)) {
+ break;
+ }
+ Set<Integer> neighborStationIdSet = filterLoopNeighborStationIdSet(
+ stationGraph.getOrDefault(currentStationId, Collections.emptySet()),
+ allowedStationIdSet,
+ excludedStationId
+ );
+ for (Integer neighborStationId : neighborStationIdSet) {
+ if (neighborStationId == null || !visitedStationIdSet.add(neighborStationId)) {
+ continue;
+ }
+ parentMap.put(neighborStationId, currentStationId);
+ queue.offer(neighborStationId);
+ }
+ }
+ if (!visitedStationIdSet.contains(endStationId)) {
+ return new ArrayList<>();
+ }
+
+ List<Integer> pathStationIdList = new ArrayList<>();
+ Integer cursorStationId = endStationId;
+ while (cursorStationId != null) {
+ pathStationIdList.add(cursorStationId);
+ if (Objects.equals(cursorStationId, startStationId)) {
+ break;
+ }
+ cursorStationId = parentMap.get(cursorStationId);
+ }
+ if (pathStationIdList.isEmpty()
+ || !Objects.equals(pathStationIdList.get(pathStationIdList.size() - 1), startStationId)) {
+ return new ArrayList<>();
+ }
+ Collections.reverse(pathStationIdList);
+ return pathStationIdList;
+ }
+
+ private Map<Integer, Set<Integer>> loadUndirectedStationGraph() {
+ NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
+ if (navigateUtils == null) {
+ return new HashMap<>();
+ }
+ Map<Integer, Set<Integer>> stationGraph = navigateUtils.loadUndirectedStationGraphSnapshot();
+ return stationGraph == null ? new HashMap<>() : stationGraph;
}
private List<Integer> normalizeLoopStationIdList(List<Integer> stationIdList) {
@@ -877,14 +1183,30 @@
private static class LoopIdentity {
private String loopFingerprint;
private Set<Integer> stationIdSet = new HashSet<>();
+ private int sourceLoopStationCount;
+ private int localStationCount;
+ private String scopeType;
- private LoopIdentity(String loopFingerprint, Set<Integer> stationIdSet) {
+ private LoopIdentity(String loopFingerprint,
+ Set<Integer> stationIdSet,
+ int sourceLoopStationCount,
+ int localStationCount,
+ String scopeType) {
this.loopFingerprint = loopFingerprint;
this.stationIdSet = stationIdSet == null ? new HashSet<>() : stationIdSet;
+ this.sourceLoopStationCount = sourceLoopStationCount;
+ this.localStationCount = localStationCount;
+ this.scopeType = scopeType == null ? "" : scopeType;
}
private static LoopIdentity empty() {
- return new LoopIdentity("", new HashSet<>());
+ return new LoopIdentity("", new HashSet<>(), 0, 0, "none");
}
}
+
+ @Data
+ private static class StationHopNode {
+ private final Integer stationId;
+ private final int hop;
+ }
}
diff --git a/src/main/java/com/zy/core/trace/StationTaskTraceRegistry.java b/src/main/java/com/zy/core/trace/StationTaskTraceRegistry.java
index 5c8b962..d76b8f3 100644
--- a/src/main/java/com/zy/core/trace/StationTaskTraceRegistry.java
+++ b/src/main/java/com/zy/core/trace/StationTaskTraceRegistry.java
@@ -152,6 +152,21 @@
persistState(state);
}
+ public void updateLoopHint(Integer taskNo,
+ Boolean loopAlertActive,
+ String loopAlertType,
+ String loopAlertText,
+ Integer loopAlertCount,
+ Map<String, Object> details) {
+ ensureCacheLoaded();
+ TraceTaskState state = taskStateMap.get(taskNo);
+ if (state == null) {
+ return;
+ }
+ state.updateLoopHint(loopAlertActive, loopAlertType, loopAlertText, loopAlertCount, details);
+ persistState(state);
+ }
+
public List<StationTaskTraceVo> listLatestTraces() {
ensureCacheLoaded();
cleanupExpired();
@@ -435,6 +450,10 @@
private List<StationTaskTraceSegmentVo> segmentList = new ArrayList<>();
private Integer issuedSegmentCount;
private Integer totalSegmentCount;
+ private Boolean loopAlertActive;
+ private String loopAlertType;
+ private String loopAlertText;
+ private Integer loopAlertCount;
private Long updatedAt;
private Long terminalExpireAt;
private List<StationTaskTraceEventVo> events = new ArrayList<>();
@@ -462,6 +481,10 @@
private List<StationTaskTraceSegmentVo> segmentList = new ArrayList<>();
private Integer issuedSegmentCount = 0;
private Integer totalSegmentCount = 0;
+ private Boolean loopAlertActive = Boolean.FALSE;
+ private String loopAlertType;
+ private String loopAlertText;
+ private Integer loopAlertCount;
private final List<StationTaskTraceEventVo> events = new ArrayList<>();
private Long updatedAt = System.currentTimeMillis();
private Long terminalExpireAt;
@@ -477,6 +500,7 @@
List<Integer> localPathStationIds,
List<StationTaskTraceSegmentVo> localSegmentList) {
TraceRegistration registration = new TraceRegistration();
+ boolean firstPlan = this.traceVersion == null || this.traceVersion <= 0;
boolean rerouted = !isTerminalStatus(this.status) && this.traceVersion != null && this.traceVersion > 0;
int nextTraceVersion = rerouted ? this.traceVersion + 1 : 1;
int pathOffset = rerouted ? this.passedStationIds.size() : 0;
@@ -498,6 +522,9 @@
this.latestIssuedSegmentPath = new ArrayList<>();
this.status = rerouted ? STATUS_REROUTED : STATUS_WAITING;
this.terminalExpireAt = null;
+ if (firstPlan) {
+ clearLoopHintState();
+ }
rebuildProgress(planCurrentStationId);
this.updatedAt = System.currentTimeMillis();
@@ -507,6 +534,7 @@
details.put("segmentCount", this.totalSegmentCount);
details.put("pathOffset", pathOffset);
details.put("currentStationId", this.currentStationId);
+ appendLoopHintDetails(details);
appendEvent(rerouted ? "REROUTED" : "PLAN_READY",
rerouted ? "杈撻�佷换鍔¤矾寰勫凡閲嶇畻骞剁画鎺ヨ建杩�" : "杈撻�佷换鍔″垎娈佃鍒掑凡寤虹珛",
details);
@@ -605,6 +633,44 @@
appendEvent(eventType, message, nextDetails);
}
+ private synchronized void updateLoopHint(Boolean loopAlertActive,
+ String loopAlertType,
+ String loopAlertText,
+ Integer loopAlertCount,
+ Map<String, Object> details) {
+ boolean active = Boolean.TRUE.equals(loopAlertActive)
+ && loopAlertCount != null
+ && loopAlertCount > 1
+ && loopAlertText != null
+ && !loopAlertText.trim().isEmpty();
+ String nextType = active ? loopAlertType : null;
+ String nextText = active ? loopAlertText.trim() : null;
+ Integer nextCount = active ? loopAlertCount : null;
+ boolean changed = !Objects.equals(this.loopAlertActive, active)
+ || !Objects.equals(this.loopAlertType, nextType)
+ || !Objects.equals(this.loopAlertText, nextText)
+ || !Objects.equals(this.loopAlertCount, nextCount);
+ if (!changed) {
+ return;
+ }
+
+ this.loopAlertActive = active;
+ this.loopAlertType = nextType;
+ this.loopAlertText = nextText;
+ this.loopAlertCount = nextCount;
+ this.updatedAt = System.currentTimeMillis();
+ if (!active) {
+ return;
+ }
+
+ Map<String, Object> nextDetails = copyDetails(details);
+ nextDetails.put("loopAlertActive", Boolean.TRUE);
+ nextDetails.put("loopAlertType", this.loopAlertType);
+ nextDetails.put("loopAlertText", this.loopAlertText);
+ nextDetails.put("loopAlertCount", this.loopAlertCount);
+ appendEvent("LOOP_REPEAT_ALERT", this.loopAlertText, nextDetails);
+ }
+
private void clearPathState() {
this.fullPathStationIds = new ArrayList<>();
this.issuedStationIds = new ArrayList<>();
@@ -647,6 +713,10 @@
vo.setSegmentList(copySegmentListWithIssued(segmentList, issuedSegmentCount));
vo.setIssuedSegmentCount(issuedSegmentCount);
vo.setTotalSegmentCount(totalSegmentCount);
+ vo.setLoopAlertActive(loopAlertActive);
+ vo.setLoopAlertType(loopAlertType);
+ vo.setLoopAlertText(loopAlertText);
+ vo.setLoopAlertCount(loopAlertCount);
vo.setUpdatedAt(updatedAt);
vo.setEvents(copyEventList(events));
return vo;
@@ -670,6 +740,10 @@
snapshot.setSegmentList(copySegmentList(segmentList));
snapshot.setIssuedSegmentCount(issuedSegmentCount);
snapshot.setTotalSegmentCount(totalSegmentCount);
+ snapshot.setLoopAlertActive(loopAlertActive);
+ snapshot.setLoopAlertType(loopAlertType);
+ snapshot.setLoopAlertText(loopAlertText);
+ snapshot.setLoopAlertCount(loopAlertCount);
snapshot.setUpdatedAt(updatedAt);
snapshot.setTerminalExpireAt(terminalExpireAt);
snapshot.setEvents(copyEventList(events));
@@ -693,6 +767,10 @@
state.segmentList = copySegmentList(snapshot.getSegmentList());
state.issuedSegmentCount = snapshot.getIssuedSegmentCount() == null ? 0 : snapshot.getIssuedSegmentCount();
state.totalSegmentCount = snapshot.getTotalSegmentCount() == null ? state.segmentList.size() : snapshot.getTotalSegmentCount();
+ state.loopAlertActive = Boolean.TRUE.equals(snapshot.getLoopAlertActive());
+ state.loopAlertType = snapshot.getLoopAlertType();
+ state.loopAlertText = snapshot.getLoopAlertText();
+ state.loopAlertCount = snapshot.getLoopAlertCount();
state.updatedAt = snapshot.getUpdatedAt() == null ? System.currentTimeMillis() : snapshot.getUpdatedAt();
state.terminalExpireAt = snapshot.getTerminalExpireAt();
state.events.clear();
@@ -743,6 +821,23 @@
this.pendingStationIds = copyIntegerList(fullPath.subList(currentIndex + 1, fullPath.size()));
}
+ private void clearLoopHintState() {
+ this.loopAlertActive = Boolean.FALSE;
+ this.loopAlertType = null;
+ this.loopAlertText = null;
+ this.loopAlertCount = null;
+ }
+
+ private void appendLoopHintDetails(Map<String, Object> details) {
+ if (details == null || !Boolean.TRUE.equals(this.loopAlertActive) || this.loopAlertCount == null || this.loopAlertCount <= 1) {
+ return;
+ }
+ details.put("loopAlertActive", Boolean.TRUE);
+ details.put("loopAlertType", this.loopAlertType);
+ details.put("loopAlertText", this.loopAlertText);
+ details.put("loopAlertCount", this.loopAlertCount);
+ }
+
private boolean acceptTraceVersion(Integer incomingTraceVersion) {
return incomingTraceVersion != null
&& this.traceVersion != null
diff --git a/src/main/webapp/views/watch/stationTrace.html b/src/main/webapp/views/watch/stationTrace.html
index ca08a37..5db8a43 100644
--- a/src/main/webapp/views/watch/stationTrace.html
+++ b/src/main/webapp/views/watch/stationTrace.html
@@ -429,6 +429,9 @@
褰撳墠绔�: {{ orDash(item.currentStationId) }}<br>
鐩爣绔�: {{ orDash(item.finalTargetStationId) }}<br>
鍒嗘: {{ orDash(item.issuedSegmentCount) }} / {{ orDash(item.totalSegmentCount) }}<br>
+ <template v-if="item.loopAlertActive && item.loopAlertText">
+ 鎻愮ず: {{ item.loopAlertText }}<br>
+ </template>
鏇存柊鏃堕棿: {{ formatTime(item.updatedAt) }}
</div>
</button>
@@ -488,6 +491,14 @@
<div class="trace-summary-item">
<div class="trace-summary-label">绾跨▼瀹炵幇</div>
<div class="trace-summary-value">{{ orDash(selectedTrace.threadImpl) }}</div>
+ </div>
+ <div class="trace-summary-item">
+ <div class="trace-summary-label">缁曞湀鎻愮ず</div>
+ <div class="trace-summary-value">{{ selectedTrace.loopAlertActive ? orDash(selectedTrace.loopAlertText) : '--' }}</div>
+ </div>
+ <div class="trace-summary-item">
+ <div class="trace-summary-label">缁曞湀绱</div>
+ <div class="trace-summary-value">{{ selectedTrace.loopAlertActive ? orDash(selectedTrace.loopAlertCount) : '--' }}</div>
</div>
</div>
@@ -858,6 +869,14 @@
pendingStationIds: '寰呰蛋璺緞',
currentStationId: '褰撳墠绔欑偣',
blockedStationId: '鍫靛绔欑偣',
+ loopAlertActive: '缁曞湀棰勮',
+ loopAlertType: '缁曞湀绫诲瀷',
+ loopAlertText: '缁曞湀鎻愮ず',
+ loopAlertCount: '缁曞湀绱',
+ loopRepeatCount: '缁曞湀绱',
+ loopScopeType: '璇嗗埆鑼冨洿',
+ loopStationCount: '褰撳墠鐜寖鍥寸珯鐐规暟',
+ sourceLoopStationCount: '鎵�鍦ㄥぇ鐜珯鐐规暟',
timeoutMs: '瓒呮椂鏃堕棿',
commandStationId: '鍛戒护璧风偣',
commandTargetStationId: '鍛戒护鐩爣',
--
Gitblit v1.9.1