| | |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.MapNode; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.model.enums.NavigationMapType; |
| | | import com.zy.core.enums.ShuttleTaskModeType; |
| | | |
| | | import java.util.*; |
| | |
| | | */ |
| | | public class NavigateUtils { |
| | | |
| | | public static List<NavigateNode> calc(String startPoint, String endPoint, Integer mapType) { |
| | | public static List<NavigateNode> calc(String startPoint, String endPoint, Integer mapType, List<int[]> shuttlePoints) { |
| | | //通过开始编号和结束编号获取对应的xy轴坐标 |
| | | int[] startArr = NavigatePositionConvert.positionToXY(startPoint);//开始节点 |
| | | int[] endArr = NavigatePositionConvert.positionToXY(endPoint);//结束节点 |
| | | |
| | | ArrayList<int[]> whiteList = new ArrayList<>();//设置计算节点的白名单 |
| | | whiteList.add(startArr);//将开始节点设置为白名单,以防被过滤 |
| | | |
| | | //获取当前节点计算的层高,并赋值到每一个节点中 |
| | | int lev = Utils.getLev(startPoint); |
| | |
| | | start.setFather(null); |
| | | |
| | | NavigateNode end = new NavigateNode(endArr[0], endArr[1]); |
| | | NavigateSolution solution = new NavigateSolution(mapType, lev); |
| | | NavigateSolution solution = new NavigateSolution(mapType, lev, whiteList, shuttlePoints); |
| | | //开始节点,不纳入禁用节点内计算 |
| | | |
| | | NavigateNode res_node = solution.astarSearch(start, end); |
| | | if (res_node == null) { |
| | | System.out.println("未找到路径"); |
| | |
| | | //获取从x点到下一点的行走距离 |
| | | public static Integer getXToNextDistance(NavigateNode xNode) { |
| | | NavigateMapData mapData = new NavigateMapData(); |
| | | List<List<MapNode>> lists = mapData.getJsonData(1); |
| | | List<List<MapNode>> lists = mapData.getJsonData(NavigationMapType.NONE.id, null, null); |
| | | if (lists != null) { |
| | | MapNode mapNode = lists.get(xNode.getX()).get(xNode.getY()); |
| | | if (mapNode != null) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据原始节点结果,计算总行走距离 |
| | | */ |
| | | public static Integer getOriginPathAllDistance(List<NavigateNode> path) { |
| | | ArrayList<ArrayList<NavigateNode>> sectionPath = NavigateUtils.getSectionPath(path); |
| | | Integer allDistance = 0; |
| | | for (ArrayList<NavigateNode> navigateNodes : sectionPath) { |
| | | Integer distance = NavigateUtils.getCurrentPathAllDistance(navigateNodes); |
| | | allDistance += distance; |
| | | } |
| | | return allDistance; |
| | | } |
| | | |
| | | /** |
| | | * 获取当前路径总行走距离 |
| | | */ |
| | | public static Integer getCurrentPathAllDistance(List<NavigateNode> path) { |
| | |
| | | return allDistance; |
| | | } |
| | | |
| | | /** |
| | | * 获取中间点到目标点行走距离 |
| | | */ |
| | | public static Integer getMiddleToDistDistance(List<NavigateNode> path) { |
| | | //中间路径 |
| | | NavigateNode middlePath = path.get(path.size() - 2); |
| | | return middlePath.getMoveDistance(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | //计算路径 |
| | | List<NavigateNode> calc = calc("1000901", "1800201", ShuttleTaskModeType.PAK_OUT.id); |
| | | List<NavigateNode> calc = calc("1000901", "1800201", NavigationMapType.NONE.id, null); |
| | | System.out.println(calc); |
| | | System.out.println("------------------------"); |
| | | // List<NavigateNode> calc = calc("0501401", "0201801", "out"); |