| | |
| | | package com.zy.acs.manager.core.service; |
| | | |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.common.utils.Utils; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.constant.MapDataConstant; |
| | | import com.zy.acs.manager.core.domain.Lane; |
| | |
| | | openQueue.add(start); |
| | | existNodes.add(start); |
| | | |
| | | RetreatNavigateNode firstPointOfTurn = null; |
| | | List<String> firstPointWaveScopeOfTurn = new ArrayList<>(); |
| | | RetreatNavigateNode availablePointOfTurn = null; |
| | | List<String> availablePointWaveScopeOfTurn = new ArrayList<>(); |
| | | int actuallyLanesOfTurn = 0; |
| | | |
| | | while (openQueue.size() > 0 && null == finialNode) { |
| | | |
| | |
| | | List<RetreatNavigateNode> enableNodes = new ArrayList<>(); |
| | | |
| | | ArrayList<RetreatNavigateNode> neighborNodes = this.getNeighborNodes(currentNode, existNodes); |
| | | int forks = neighborNodes.size(); |
| | | if (firstPointOfTurn == null && forks >= 2 && !isSame(start, currentNode)) { |
| | | firstPointOfTurn = currentNode; |
| | | firstPointWaveScopeOfTurn = mapService.getWaveScopeByCode(lev, firstPointOfTurn.getCodeData(), avoidDistance) |
| | | .stream().map(NavigateNode::getCodeData).distinct().collect(Collectors.toList()); |
| | | boolean pointOfTurn = false; |
| | | if (neighborNodes.size() >= 2 && !isSame(start, currentNode)) { |
| | | pointOfTurn = true; |
| | | } |
| | | |
| | | label: for (RetreatNavigateNode node : neighborNodes) { |
| | | |
| | | int weight = 0; |
| | | |
| | | // wave |
| | | String waveNode = waveMatrix[node.getX()][node.getY()]; |
| | | assert !waveNode.equals(WaveNodeType.DISABLE.val); |
| | | if (!waveNode.equals(WaveNodeType.ENABLE.val)) { |
| | | List<String> waveNodeList = MapDataUtils.parseWaveNode(waveNode); |
| | | List<String> otherWaveList = MapDataUtils.hasOtherWave(waveNodeList, agvNo); |
| | | for (String otherWave : otherWaveList) { |
| | | if (!Cools.isEmpty(blackList) && blackList.contains(otherWave)) { |
| | | continue; |
| | | } |
| | | if (1 < mapDataDispatcher.queryCodeListFromDynamicNode(lev, otherWave).size()) { |
| | | continue label; |
| | | } else { |
| | | weight += WEIGHT_CALC_COEFFICIENT; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 计算是否为可用转弯点 |
| | | if (pointOfTurn) { |
| | | for (RetreatNavigateNode node : neighborNodes) { |
| | | // lane |
| | | Lane lane = laneService.search(node.getCodeData()); |
| | | if (null != lane) { |
| | |
| | | } |
| | | } |
| | | |
| | | // have cross turn road |
| | | if (null != firstPointOfTurn) { |
| | | if (!firstPointWaveScopeOfTurn.contains(node.getCodeData())) { |
| | | actuallyLanesOfTurn ++; |
| | | } |
| | | |
| | | if (actuallyLanesOfTurn >= 2) { |
| | | availablePointOfTurn = currentNode; |
| | | availablePointWaveScopeOfTurn = mapService.getWaveScopeByCode(lev, availablePointOfTurn.getCodeData(), avoidDistance) |
| | | .stream().map(NavigateNode::getCodeData).distinct().collect(Collectors.toList()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | label: for (RetreatNavigateNode node : neighborNodes) { |
| | | int weight = 0; |
| | | |
| | | // wave |
| | | String waveNode = waveMatrix[node.getX()][node.getY()]; |
| | | assert !waveNode.equals(WaveNodeType.DISABLE.val); |
| | | if (!waveNode.equals(WaveNodeType.ENABLE.val)) { |
| | | List<String> waveNodeList = MapDataUtils.parseWaveNode(waveNode); |
| | | List<String> otherWaveList = MapDataUtils.hasOtherWave(waveNodeList, agvNo); |
| | | for (String otherWave : otherWaveList) { |
| | | if (!Cools.isEmpty(blackList) && blackList.contains(otherWave)) { |
| | | continue; |
| | | } |
| | | if (1 < mapDataDispatcher.queryCodeListFromDynamicNode(lev, otherWave).size()) { |
| | | |
| | | if (null != availablePointOfTurn && actuallyLanesOfTurn > 0) { |
| | | actuallyLanesOfTurn --; |
| | | } |
| | | |
| | | continue label; |
| | | } else { |
| | | weight += WEIGHT_CALC_COEFFICIENT; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (null != availablePointOfTurn) { |
| | | if (!availablePointWaveScopeOfTurn.contains(node.getCodeData())) { |
| | | enableNodes.add(node); |
| | | } |
| | | } |
| | |
| | | existNodes.add(node); |
| | | } |
| | | |
| | | |
| | | if (!Cools.isEmpty(enableNodes)) { |
| | | |
| | | if (actuallyLanesOfTurn >= 2) { |
| | | Collections.sort(enableNodes); |
| | | finialNode = enableNodes.stream().findFirst().orElse(null); |
| | | jam.setCycleAvo(1); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | return finialNode; |
| | | } |
| | | |
| | | private int calcNodeWeightVal(List<String> otherWaveList) { |
| | | int weightVal = 0; |
| | | |
| | | if (!Cools.isEmpty(otherWaveList)) { |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | return weightVal; |
| | | } |
| | | |
| | | // 获取四周节点 |