| | |
| | | import com.zy.acs.manager.common.utils.MapDataUtils; |
| | | import com.zy.acs.manager.core.constant.MapDataConstant; |
| | | import com.zy.acs.manager.core.service.astart.*; |
| | | import com.zy.acs.manager.core.service.astart.domain.AStarNavigateNode; |
| | | import com.zy.acs.manager.core.service.astart.domain.DynamicNode; |
| | | import com.zy.acs.manager.core.service.floyd.FloydNavigateService; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | |
| | | int[] startMapIdx = mapDataDispatcher.getCodeMatrixIdx(null, startCode.getData()); |
| | | int[] endMapIdx = mapDataDispatcher.getCodeMatrixIdx(null, endCode.getData()); |
| | | |
| | | NavigateNode startNode = new NavigateNode(startMapIdx[0], startMapIdx[1], startCode.getData()); |
| | | NavigateNode endNode = new NavigateNode(endMapIdx[0], endMapIdx[1], endCode.getData()); |
| | | AStarNavigateNode startNode = new AStarNavigateNode(startMapIdx[0], startMapIdx[1], startCode.getData()); |
| | | AStarNavigateNode endNode = new AStarNavigateNode(endMapIdx[0], endMapIdx[1], endCode.getData()); |
| | | |
| | | long startTime = System.currentTimeMillis(); |
| | | NavigateNode finishNode = aStarNavigateService.execute(agvNo, startNode, endNode, lock, blackList, segment); |
| | | // System.out.println("AStart spend time: " + (System.currentTimeMillis() - startTime)); |
| | | |
| | | // long startTime = System.currentTimeMillis(); |
| | | AStarNavigateNode finishNode = aStarNavigateService.execute(agvNo, startNode, endNode, lock, blackList, segment); |
| | | // System.out.println("A Star Spend time :" + (System.currentTimeMillis() - startTime)); |
| | | if (null == finishNode) { |
| | | log.warn("{} 号AGV检索[{}] ===>> [{}]路径失败......", agvNo, startCode.getData(), endCode.getData()); |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | ArrayList<NavigateNode> navigateNodes = new ArrayList<>(); |
| | | ArrayList<AStarNavigateNode> navigateNodes = new ArrayList<>(); |
| | | |
| | | // 渲染 |
| | | NavigateNode parentNode = null; // 当前循环上一节点,用于拐点计算 |
| | | while (finishNode != null) { |
| | | navigateNodes.add(finishNode); |
| | | |
| | | parentNode = finishNode; |
| | | finishNode = finishNode.getParent(); |
| | | } |
| | | |
| | | Collections.reverse(navigateNodes); |
| | | |
| | | // for (NavigateNode navigateNode : navigateNodes) { |
| | | // navigateNode.setParent(null); |
| | | // } |
| | | |
| | | List<String> navigatePath = navigateNodes.stream().map(NavigateNode::getCodeData).collect(Collectors.toList()); |
| | | List<String> navigatePath = navigateNodes.stream().map(AStarNavigateNode::getCodeData).collect(Collectors.toList()); |
| | | |
| | | // max count of steps |
| | | if (navigatePath.size() > MapDataConstant.MAX_STEPS_SINGLE) { |
| | |
| | | |
| | | |
| | | Integer serial = dynamicNode.getSerial(); |
| | | long time = dynamicNode.getTime(); |
| | | |
| | | List<String> resetCodeList = new ArrayList<>(); |
| | | |
| | | for (int i = 0; i < dynamicMatrix.length; i++) { |
| | | for (int j = 0; j < dynamicMatrix[i].length; j++) { |
| | | |
| | | if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } |
| | | // if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } |
| | | |
| | | DynamicNode node = dynamicMatrix[i][j]; |
| | | if (node.getVehicle().equals(agvNo)) { |
| | | if (node.getSerial() < serial || node.getTime() != time) { |
| | | if (node.getSerial() < serial) { |
| | | resetCodeList.add(codeMatrix[i][j]); |
| | | } |
| | | } |