| | |
| | | return result; |
| | | } |
| | | |
| | | public List<StationTaskTraceVo> listPlanningActiveTraceSnapshots() { |
| | | ensureCacheLoaded(); |
| | | cleanupExpired(); |
| | | List<StationTaskTraceVo> result = new ArrayList<>(); |
| | | for (TraceTaskState state : taskStateMap.values()) { |
| | | if (state == null) { |
| | | continue; |
| | | } |
| | | StationTaskTraceVo traceVo = state.toPlanningVo(); |
| | | if (traceVo == null) { |
| | | continue; |
| | | } |
| | | result.add(traceVo); |
| | | } |
| | | result.sort(new Comparator<StationTaskTraceVo>() { |
| | | @Override |
| | | public int compare(StationTaskTraceVo a, StationTaskTraceVo b) { |
| | | long av = a.getUpdatedAt() == null ? 0L : a.getUpdatedAt(); |
| | | long bv = b.getUpdatedAt() == null ? 0L : b.getUpdatedAt(); |
| | | return Long.compare(bv, av); |
| | | } |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | private void cleanupExpired() { |
| | | long now = System.currentTimeMillis(); |
| | | for (Map.Entry<Integer, TraceTaskState> entry : taskStateMap.entrySet()) { |
| | |
| | | } |
| | | |
| | | private boolean isStationTraceActiveWrkStatus(Long wrkSts) { |
| | | return Objects.equals(wrkSts, WrkStsType.INBOUND_DEVICE_RUN.sts) |
| | | return Objects.equals(wrkSts, WrkStsType.INBOUND_STATION_RUN.sts) |
| | | || Objects.equals(wrkSts, WrkStsType.STATION_RUN.sts); |
| | | } |
| | | |
| | |
| | | && !loopAlertText.trim().isEmpty(); |
| | | String nextType = active ? loopAlertType : null; |
| | | String nextText = active ? loopAlertText.trim() : null; |
| | | Integer nextCount = active ? loopAlertCount : null; |
| | | Integer nextCount = loopAlertCount != null && loopAlertCount > 0 ? loopAlertCount : null; |
| | | boolean changed = !Objects.equals(this.loopAlertActive, active) |
| | | || !Objects.equals(this.loopAlertType, nextType) |
| | | || !Objects.equals(this.loopAlertText, nextText) |
| | |
| | | vo.setLoopAlertCount(loopAlertCount); |
| | | vo.setUpdatedAt(updatedAt); |
| | | vo.setEvents(copyEventList(events)); |
| | | return vo; |
| | | } |
| | | |
| | | private synchronized StationTaskTraceVo toPlanningVo() { |
| | | if (isTerminalStatus(this.status)) { |
| | | return null; |
| | | } |
| | | StationTaskTraceVo vo = new StationTaskTraceVo(); |
| | | vo.setTaskNo(taskNo); |
| | | vo.setThreadImpl(threadImpl); |
| | | vo.setStatus(status); |
| | | vo.setTraceVersion(traceVersion); |
| | | vo.setStartStationId(startStationId); |
| | | vo.setCurrentStationId(currentStationId); |
| | | vo.setFinalTargetStationId(finalTargetStationId); |
| | | vo.setPendingStationIds(copyIntegerList(pendingStationIds)); |
| | | vo.setLatestIssuedSegmentPath(copyIntegerList(latestIssuedSegmentPath)); |
| | | vo.setUpdatedAt(updatedAt); |
| | | return vo; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private void appendLoopHintDetails(Map<String, Object> details) { |
| | | if (details == null || !Boolean.TRUE.equals(this.loopAlertActive) || this.loopAlertCount == null || this.loopAlertCount <= 2) { |
| | | if (details == null || this.loopAlertCount == null || this.loopAlertCount <= 0) { |
| | | return; |
| | | } |
| | | details.put("loopAlertActive", Boolean.TRUE); |
| | | details.put("loopAlertType", this.loopAlertType); |
| | | details.put("loopAlertText", this.loopAlertText); |
| | | details.put("loopAlertCount", this.loopAlertCount); |
| | | if (Boolean.TRUE.equals(this.loopAlertActive)) { |
| | | details.put("loopAlertActive", Boolean.TRUE); |
| | | details.put("loopAlertType", this.loopAlertType); |
| | | details.put("loopAlertText", this.loopAlertText); |
| | | } |
| | | } |
| | | |
| | | private boolean acceptTraceVersion(Integer incomingTraceVersion) { |