| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | |
| | | List<NavigateNode> nodes = wrkMast == null |
| | | ? navigateUtils.calcOptimalPathByStationId(sourceStationId, targetStationId, null, null) |
| | | : calcOutboundNavigatePath(wrkMast, sourceStationId, targetStationId, pathLenFactor); |
| | | if (nodes == null || nodes.isEmpty()) { |
| | | return LoopHitResult.noHit(); |
| | | } |
| | | |
| | | for (NavigateNode node : nodes) { |
| | | Integer stationId = getStationIdFromNode(node); |
| | | if (stationId == null) { |
| | | continue; |
| | | } |
| | | Integer loopNo = loadGuardState.getStationLoopNoMap().get(stationId); |
| | | if (loopNo != null) { |
| | | return new LoopHitResult(true, loopNo, stationId); |
| | | } |
| | | } |
| | | return findPathLoopHitByNavigateNodes(nodes, loadGuardState); |
| | | } catch (Exception ignore) { |
| | | return LoopHitResult.noHit(); |
| | | } |
| | | } |
| | | |
| | | public LoopHitResult findPathLoopHitByNavigatePath(List<Integer> navigatePath, |
| | | LoadGuardState loadGuardState) { |
| | | if (navigatePath == null || navigatePath.isEmpty()) { |
| | | return LoopHitResult.noHit(); |
| | | } |
| | | if (loadGuardState == null || loadGuardState.getStationLoopNoMap().isEmpty()) { |
| | | return LoopHitResult.noHit(); |
| | | } |
| | | |
| | | for (Integer stationId : navigatePath) { |
| | | if (stationId == null) { |
| | | continue; |
| | | } |
| | | Integer loopNo = loadGuardState.getStationLoopNoMap().get(stationId); |
| | | if (loopNo != null) { |
| | | return new LoopHitResult(true, loopNo, stationId); |
| | | } |
| | | } |
| | | return LoopHitResult.noHit(); |
| | | } |
| | | |
| | | public LoopHitResult findPathLoopHitByNavigateNodes(List<NavigateNode> nodes, |
| | | LoadGuardState loadGuardState) { |
| | | if (nodes == null || nodes.isEmpty()) { |
| | | return LoopHitResult.noHit(); |
| | | } |
| | | |
| | | List<Integer> navigatePath = new ArrayList<>(); |
| | | for (NavigateNode node : nodes) { |
| | | Integer stationId = getStationIdFromNode(node); |
| | | if (stationId != null) { |
| | | navigatePath.add(stationId); |
| | | } |
| | | } |
| | | return findPathLoopHitByNavigatePath(navigatePath, loadGuardState); |
| | | } |
| | | |
| | | public void saveLoopLoadReserve(Integer wrkNo, LoopHitResult loopHitResult) { |
| | | if (wrkNo == null || wrkNo <= 0 || loopHitResult == null || !loopHitResult.isThroughLoop()) { |
| | | return; |