|  |  | 
 |  |  | import com.core.common.SpringUtils; | 
 |  |  | import com.core.exception.CoolException; | 
 |  |  | import com.zy.common.model.NavigateNode; | 
 |  |  | import com.zy.common.model.enums.NavigationMapType; | 
 |  |  | import com.zy.core.enums.MapNodeType; | 
 |  |  | import com.zy.core.model.PythonResult; | 
 |  |  | import com.zy.system.entity.Config; | 
 |  |  | 
 |  |  |  | 
 |  |  |     int[][] map = {{}}; | 
 |  |  |  | 
 |  |  |     public NavigateSolution(Integer mapType, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { | 
 |  |  |     public NavigateSolution(List<NavigationMapType> mapTypes, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { | 
 |  |  |         //载入地图指定层高地图 | 
 |  |  |         NavigateMapData mapData = SpringUtils.getBean(NavigateMapData.class); | 
 |  |  |         int[][] data = mapData.getDataFromRedis(lev, mapType, whitePoints, shuttlePoints); | 
 |  |  |         int[][] data = mapData.getDataFromRedis(lev, mapTypes, whitePoints, shuttlePoints); | 
 |  |  |         if (data == null) { | 
 |  |  |             throw new CoolException("地图未载入!"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public NavigateNode astarSearchJava(NavigateNode start, NavigateNode end) { | 
 |  |  |         //默认地图母轨方向x | 
 |  |  |         String mapDirection = "x"; | 
 |  |  |         ConfigService configService = SpringUtils.getBean(ConfigService.class); | 
 |  |  |         if (configService != null) { | 
 |  |  |             Config config = configService.selectOne(new EntityWrapper<Config>() | 
 |  |  |                     .eq("code", "direction_map") | 
 |  |  |                     .eq("status", 1)); | 
 |  |  |             if (config != null) { | 
 |  |  |                 mapDirection = config.getValue(); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //把第一个开始的结点加入到Open表中 | 
 |  |  |         this.Open.add(start); | 
 |  |  |         //主循环 | 
 |  |  | 
 |  |  |             //将这个结点加入到Close表中 | 
 |  |  |             Close.add(current_node); | 
 |  |  |             //对当前结点进行扩展,得到一个四周结点的数组 | 
 |  |  |             ArrayList<NavigateNode> neighbour_node = extend_current_node(current_node); | 
 |  |  |             ArrayList<NavigateNode> neighbour_node = extend_current_node(current_node, mapDirection); | 
 |  |  |             //对这个结点遍历,看是否有目标结点出现 | 
 |  |  |             for (NavigateNode node : neighbour_node) { | 
 |  |  |                 // G + H + E (对启发函数增加去拐点方案calcNodeExtraCost) | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public ArrayList<NavigateNode> extend_current_node(NavigateNode current_node) { | 
 |  |  |         //默认地图母轨方向x | 
 |  |  |         String mapDirection = "x"; | 
 |  |  |         ConfigService configService = SpringUtils.getBean(ConfigService.class); | 
 |  |  |         if (configService != null) { | 
 |  |  |             Config config = configService.selectOne(new EntityWrapper<Config>() | 
 |  |  |                     .eq("code", "direction_map") | 
 |  |  |                     .eq("status", 1)); | 
 |  |  |             if (config != null) { | 
 |  |  |                 mapDirection = config.getValue(); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     public ArrayList<NavigateNode> extend_current_node(NavigateNode current_node, String mapDirection) { | 
 |  |  |         //获取当前结点的x, y | 
 |  |  |         int x = current_node.getX(); | 
 |  |  |         int y = current_node.getY(); | 
 |  |  | 
 |  |  |         if (mapDirection.equals("x")) {//母轨x方向 | 
 |  |  |             if (map[x][y] == MapNodeType.MAIN_PATH.id) { | 
 |  |  |                 //母轨才能进行上下移动 | 
 |  |  |                 if (is_valid(x + 1, y)) | 
 |  |  |                 { | 
 |  |  |                 if (is_valid(x + 1, y)) { | 
 |  |  |                     NavigateNode node = new NavigateNode(x + 1, y); | 
 |  |  |                     node.setNodeValue(map[x + 1][y]); | 
 |  |  |                     neighbour_node.add(node); | 
 |  |  |                 } | 
 |  |  |                 if (is_valid(x - 1, y)) | 
 |  |  |                 { | 
 |  |  |                 if (is_valid(x - 1, y)) { | 
 |  |  |                     NavigateNode node = new NavigateNode(x - 1, y); | 
 |  |  |                     node.setNodeValue(map[x - 1][y]); | 
 |  |  |                     neighbour_node.add(node); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (map[x][y] == MapNodeType.NORMAL_PATH.id || map[x][y] == MapNodeType.MAIN_PATH.id || map[x][y] == MapNodeType.CONVEYOR_CAR_GO.id || map[x][y] == MapNodeType.CHARGE.id || map[x][y] == MapNodeType.LIFT.id) { | 
 |  |  |             if (map[x][y] == MapNodeType.NORMAL_PATH.id || map[x][y] == MapNodeType.MAIN_PATH.id || map[x][y] == MapNodeType.CONVEYOR_CAR_GO.id || map[x][y] == MapNodeType.CONVEYOR.id || map[x][y] == MapNodeType.CHARGE.id || map[x][y] == MapNodeType.LIFT.id) { | 
 |  |  |                 //子轨和母轨、小车可走输送线、充电桩、提升机才能进行左右移动 | 
 |  |  |                 if (is_valid(x, y + 1)) | 
 |  |  |                 { | 
 |  |  |                 if (is_valid(x, y + 1)) { | 
 |  |  |                     NavigateNode node = new NavigateNode(x, y + 1); | 
 |  |  |                     node.setNodeValue(map[x][y + 1]); | 
 |  |  |                     neighbour_node.add(node); | 
 |  |  |                 } | 
 |  |  |                 if (is_valid(x, y - 1)) | 
 |  |  |                 { | 
 |  |  |                 if (is_valid(x, y - 1)) { | 
 |  |  |                     NavigateNode node = new NavigateNode(x, y - 1); | 
 |  |  |                     node.setNodeValue(map[x][y - 1]); | 
 |  |  |                     neighbour_node.add(node); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         }else if (mapDirection.equals("y")) {//母轨y方向 | 
 |  |  |         } else if (mapDirection.equals("y")) {//母轨y方向 | 
 |  |  |             if (map[x][y] == MapNodeType.MAIN_PATH.id) { | 
 |  |  |                 //母轨才能进行左右移动 | 
 |  |  |                 if (is_valid(x, y + 1)) | 
 |  |  |                 { | 
 |  |  |                 if (is_valid(x, y + 1)) { | 
 |  |  |                     NavigateNode node = new NavigateNode(x, y + 1); | 
 |  |  |                     node.setNodeValue(map[x][y + 1]); | 
 |  |  |                     neighbour_node.add(node); | 
 |  |  |                 } | 
 |  |  |                 if (is_valid(x, y - 1)) | 
 |  |  |                 { | 
 |  |  |                 if (is_valid(x, y - 1)) { | 
 |  |  |                     NavigateNode node = new NavigateNode(x, y - 1); | 
 |  |  |                     node.setNodeValue(map[x][y - 1]); | 
 |  |  |                     neighbour_node.add(node); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (map[x][y] == MapNodeType.NORMAL_PATH.id || map[x][y] == MapNodeType.MAIN_PATH.id || map[x][y] == MapNodeType.CONVEYOR_CAR_GO.id || map[x][y] == MapNodeType.CHARGE.id || map[x][y] == MapNodeType.LIFT.id) { | 
 |  |  |             if (map[x][y] == MapNodeType.NORMAL_PATH.id || map[x][y] == MapNodeType.MAIN_PATH.id || map[x][y] == MapNodeType.CONVEYOR_CAR_GO.id || map[x][y] == MapNodeType.CONVEYOR.id || map[x][y] == MapNodeType.CHARGE.id || map[x][y] == MapNodeType.LIFT.id) { | 
 |  |  |                 //子轨和母轨、小车可走输送线、充电桩、提升机才能进行上下移动 | 
 |  |  |                 if (is_valid(x + 1, y)) | 
 |  |  |                 { | 
 |  |  |                 if (is_valid(x + 1, y)) { | 
 |  |  |                     NavigateNode node = new NavigateNode(x + 1, y); | 
 |  |  |                     node.setNodeValue(map[x + 1][y]); | 
 |  |  |                     neighbour_node.add(node); | 
 |  |  |                 } | 
 |  |  |                 if (is_valid(x - 1, y)) | 
 |  |  |                 { | 
 |  |  |                 if (is_valid(x - 1, y)) { | 
 |  |  |                     NavigateNode node = new NavigateNode(x - 1, y); | 
 |  |  |                     node.setNodeValue(map[x - 1][y]); | 
 |  |  |                     neighbour_node.add(node); |