diff --git a/project/src/main/java/com/sdm/project/service/impl/LyricInternalServiceImpl.java b/project/src/main/java/com/sdm/project/service/impl/LyricInternalServiceImpl.java index 4bf7f007..943314bd 100644 --- a/project/src/main/java/com/sdm/project/service/impl/LyricInternalServiceImpl.java +++ b/project/src/main/java/com/sdm/project/service/impl/LyricInternalServiceImpl.java @@ -2473,18 +2473,48 @@ public class LyricInternalServiceImpl implements ILyricInternalService { .collect(Collectors.toList()); // 查找当前时间落在【开始时间, 结束时间】内的阶段节点 - SimulationNode currentPhaseNode = sortedPhaseNodeList.stream() + List currentPhaseNodeList = sortedPhaseNodeList.stream() .filter(phaseNode -> isCurrentTimeInRange(phaseNode, currentTime, sdf)) - .findFirst() - .orElse(null); + .toList(); + SpdmNodeVo projectNode = nodeList.stream() + .filter(node -> projectNodeId.equals(node.getUuid())).findFirst().orElse(null); + if (projectNode != null) { + // 找到当前阶段,回写至对应的SpdmNodeVo + if (CollectionUtils.isNotEmpty(currentPhaseNodeList)) { + // 开始时间比当前时间小的里面的最大的一个 + List bigPhaseNodeList = currentPhaseNodeList.stream().filter(phaseNode -> { + try { + return currentTime <= sdf.parse(phaseNode.getBeginTime()).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + }).toList(); + if (CollectionUtils.isEmpty(bigPhaseNodeList)) { + SimulationNode simulationNode = currentPhaseNodeList.stream().max(Comparator.comparingLong(phaseNode -> { + try { + return sdf.parse(phaseNode.getBeginTime()).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + })).get(); + projectNode.setCurrentPhase(simulationNode.getNodeName()); + } else { + SimulationNode simulationNode = phaseNodeList.stream().min(Comparator.comparingLong(phaseNode -> { + try { + return sdf.parse(phaseNode.getBeginTime()).getTime(); + } catch (ParseException e) { + throw new RuntimeException(e); + } + })).get(); + projectNode.setCurrentPhase(simulationNode.getNodeName()); + } - // 找到当前阶段,回写至对应的SpdmNodeVo - if (Objects.nonNull(currentPhaseNode)) { - nodeList.stream() - .filter(node -> projectNodeId.equals(node.getUuid())) - .findFirst() - .ifPresent(node -> node.setCurrentPhase(currentPhaseNode.getNodeName())); + } else { + // 如果没有落在【开始时间, 结束时间】内的阶段节点,就选beginTime最大的阶段作为当前阶段 + projectNode.setCurrentPhase(sortedPhaseNodeList.get(sortedPhaseNodeList.size() - 1).getNodeName()); + } } + }); }