| | |
| | | } |
| | | this.status = terminalStatus; |
| | | this.blockedStationId = blockedStationId; |
| | | if (shouldClearPathOnTerminal(terminalStatus)) { |
| | | clearPathState(); |
| | | } |
| | | this.updatedAt = System.currentTimeMillis(); |
| | | this.terminalExpireAt = this.updatedAt + TERMINAL_KEEP_MS; |
| | | |
| | |
| | | Map<String, Object> details) { |
| | | boolean active = Boolean.TRUE.equals(loopAlertActive) |
| | | && loopAlertCount != null |
| | | && loopAlertCount > 1 |
| | | && loopAlertCount > 2 |
| | | && loopAlertText != null |
| | | && !loopAlertText.trim().isEmpty(); |
| | | String nextType = active ? loopAlertType : null; |
| | |
| | | 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<>(); |
| | | this.passedStationIds = new ArrayList<>(); |
| | | this.pendingStationIds = new ArrayList<>(); |
| | | this.latestIssuedSegmentPath = new ArrayList<>(); |
| | | this.segmentList = new ArrayList<>(); |
| | | this.issuedSegmentCount = 0; |
| | | this.totalSegmentCount = 0; |
| | | } |
| | | |
| | | private boolean shouldClearPathOnTerminal(String terminalStatus) { |
| | | return STATUS_BLOCKED.equals(terminalStatus) |
| | | || STATUS_CANCELLED.equals(terminalStatus); |
| | | } |
| | | |
| | | private synchronized boolean shouldRemove(long now) { |
| | |
| | | } |
| | | |
| | | private void appendLoopHintDetails(Map<String, Object> details) { |
| | | if (details == null || !Boolean.TRUE.equals(this.loopAlertActive) || this.loopAlertCount == null || this.loopAlertCount <= 1) { |
| | | if (details == null || !Boolean.TRUE.equals(this.loopAlertActive) || this.loopAlertCount == null || this.loopAlertCount <= 2) { |
| | | return; |
| | | } |
| | | details.put("loopAlertActive", Boolean.TRUE); |