| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasMap; |
| | |
| | | |
| | | public List<List<NavigateNode>> getStationMap(int lev) { |
| | | BasMapService basMapService = SpringUtils.getBean(BasMapService.class); |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev)); |
| | | BasMap basMap = basMapService.getOne(new QueryWrapper<BasMap>().eq("lev", lev)); |
| | | if (basMap == null) { |
| | | throw new CoolException("地图不存在"); |
| | | } |
| | |
| | | JSONObject map = row.get(j); |
| | | NavigateNode navigateNode = new NavigateNode(i, j); |
| | | |
| | | String mergeType = map.getString("mergeType"); |
| | | String nodeType = map.getString("type"); |
| | | String nodeValue = map.getString("value"); |
| | | if(nodeType == null) { |
| | | navigateNode.setValue(MapNodeType.DISABLE.id); |
| | | }else if(nodeType.equals("devp") || nodeType.equals("merge")){ |
| | | }else if(nodeType.equals("devp") || (nodeType.equals("merge") && mergeType.equals("devp"))) { |
| | | navigateNode.setValue(MapNodeType.NORMAL_PATH.id); |
| | | |
| | | JSONObject valueObj = JSON.parseObject(map.getString("value")); |
| | |
| | | |
| | | public List<List<NavigateNode>> getRgvTrackMap(int lev) { |
| | | BasMapService basMapService = SpringUtils.getBean(BasMapService.class); |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", lev)); |
| | | BasMap basMap = basMapService.getOne(new QueryWrapper<BasMap>().eq("lev", lev)); |
| | | if (basMap == null) { |
| | | throw new CoolException("地图不存在"); |
| | | } |
| | |
| | | |
| | | for(String direction : directionList) { |
| | | if(direction.equals("top")) { |
| | | NavigateNode node = getValidNavigateNode(map, x - 1, y); |
| | | NavigateNode node = getValidNavigateNode(map, current_node, x - 1, y, direction); |
| | | if(node != null) { |
| | | neighbour_node.add(node); |
| | | } |
| | | }else if(direction.equals("bottom")) { |
| | | NavigateNode node = getValidNavigateNode(map, x + 1, y); |
| | | NavigateNode node = getValidNavigateNode(map, current_node, x + 1, y, direction); |
| | | if(node != null) { |
| | | neighbour_node.add(node); |
| | | } |
| | | }else if(direction.equals("left")) { |
| | | NavigateNode node = getValidNavigateNode(map, x, y - 1); |
| | | NavigateNode node = getValidNavigateNode(map, current_node, x, y - 1, direction); |
| | | if(node != null) { |
| | | neighbour_node.add(node); |
| | | } |
| | | }else if(direction.equals("right")) { |
| | | NavigateNode node = getValidNavigateNode(map, x, y + 1); |
| | | NavigateNode node = getValidNavigateNode(map, current_node, x, y + 1, direction); |
| | | if(node != null) { |
| | | neighbour_node.add(node); |
| | | } |
| | |
| | | } |
| | | |
| | | return neighbour_node; |
| | | } |
| | | |
| | | /** |
| | | * 邻接点校验:可达 + 方向一致(当前节点与下一节点对本次行走方向一致) |
| | | */ |
| | | public NavigateNode getValidNavigateNode(List<List<NavigateNode>> map, NavigateNode currentNode, int x, int y, String moveDirection) { |
| | | NavigateNode node = getValidNavigateNode(map, x, y); |
| | | if (node == null) { |
| | | return null; |
| | | } |
| | | |
| | | if (!isDirectionConsistent(currentNode, node, moveDirection)) { |
| | | return null; |
| | | } |
| | | |
| | | return node; |
| | | } |
| | | |
| | | public NavigateNode getValidNavigateNode(List<List<NavigateNode>> map, int x, int y) { |
| | |
| | | return node; |
| | | } |
| | | |
| | | private boolean isDirectionConsistent(NavigateNode currentNode, NavigateNode nextNode, String moveDirection) { |
| | | if (currentNode == null || nextNode == null) { |
| | | return false; |
| | | } |
| | | |
| | | if (moveDirection == null) { |
| | | return false; |
| | | } |
| | | |
| | | List<String> currentDirectionList = currentNode.getDirectionList(); |
| | | List<String> nextDirectionList = nextNode.getDirectionList(); |
| | | if (currentDirectionList == null || nextDirectionList == null) { |
| | | return false; |
| | | } |
| | | |
| | | // 当前节点允许向 moveDirection 出发,且下一节点在该方向上保持一致,才允许通行 |
| | | return currentDirectionList.contains(moveDirection) && nextDirectionList.contains(moveDirection); |
| | | } |
| | | |
| | | public NavigateNode findStationNavigateNode(List<List<NavigateNode>> map, int stationId) { |
| | | for(int x = 0; x < map.size(); x++) { |
| | | for(int y = 0; y < map.get(0).size(); y++) { |