| | |
| | | } |
| | | |
| | | public int[][] getData() { |
| | | return getData(NavigationMapType.NONE.id, null, null);//默认读取无过滤的全部地图数据 |
| | | } |
| | | |
| | | public int[][] getData(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | String mapFilename = "map_" + lev + ".json"; |
| | | |
| | | String fileName = this.getClass().getClassLoader().getResource(mapFilename).getPath();//获取文件路径 |
| | | File file = new File(fileName); |
| | | StringBuffer stringBuffer = new StringBuffer(); |
| | | if (file.isFile() && file.exists()) { |
| | | InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "GBK"); |
| | | BufferedReader br = new BufferedReader(isr); |
| | | String lineTxt = null; |
| | | while ((lineTxt = br.readLine()) != null) { |
| | | stringBuffer.append(lineTxt); |
| | | } |
| | | br.close(); |
| | | |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class); |
| | | List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | int[][] map = new int[lists.size()][]; |
| | | int j = 0; |
| | | for (List<MapNode> list : lists) { |
| | | int[] tmp = new int[list.size()]; |
| | | int i = 0; |
| | | for (MapNode mapNode : list) { |
| | | //将数据添加进二维数组 |
| | | tmp[i++] = mapNode.getValue(); |
| | | } |
| | | //数据添加进一维数组 |
| | | map[j++] = tmp; |
| | | } |
| | | |
| | | return map; |
| | | } else { |
| | | System.out.println("文件不存在!"); |
| | | } |
| | | } catch (IOException ioException) { |
| | | ioException.printStackTrace(); |
| | | } |
| | | return null; |
| | | return getDataFromRedis(NavigationMapType.NONE.id, null, null);//默认读取无过滤的全部地图数据 |
| | | } |
| | | |
| | | /** |
| | |
| | | lists.add(list); |
| | | } |
| | | |
| | | //过滤数据 |
| | | //获取当前楼层库位数据 |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLev, lev) |
| | | .orderByAsc(Loc::getRow, Loc::getBay)); |
| | | for (Loc loc : locs) { |
| | | Integer row = loc.getRow(); |
| | | Integer bay = loc.getBay(); |
| | | //获取严格模式参数 |
| | | boolean mapStrict = true;//默认严格模式 |
| | | Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, "shuttleMapStrict")); |
| | | if (dict != null) { |
| | | mapStrict = Boolean.parseBoolean(dict.getValue()); |
| | | } |
| | | |
| | | boolean whiteFlag = false;//默认不存在白名单 |
| | | if (whitePoints != null) { |
| | | for (int[] whitePoint : whitePoints) { |
| | | if (whitePoint[0] == row && whitePoint[1] == bay) { |
| | | //存在白名单 |
| | | whiteFlag = true; |
| | | break; |
| | | if (mapStrict) {//严格模式下,载入库位状态 |
| | | //过滤数据 |
| | | //获取当前楼层库位数据 |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLev, lev) |
| | | .orderByAsc(Loc::getRow, Loc::getBay)); |
| | | for (Loc loc : locs) { |
| | | Integer row = loc.getRow(); |
| | | Integer bay = loc.getBay(); |
| | | |
| | | boolean whiteFlag = false;//默认不存在白名单 |
| | | if (whitePoints != null) { |
| | | for (int[] whitePoint : whitePoints) { |
| | | if (whitePoint[0] == row && whitePoint[1] == bay) { |
| | | //存在白名单 |
| | | whiteFlag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (whiteFlag) { |
| | | continue;//存在白名单,不执行下列过滤方案 |
| | | } |
| | | |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.NONE.id) { |
| | | //不过滤任何数据 |
| | | } else if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | //读取对应库位数据,将DFX库位状态的节点置为-1(障碍物) |
| | | if (loc.getLocSts$().equals("F") |
| | | || loc.getLocSts$().equals("D") |
| | | || loc.getLocSts$().equals("X") |
| | | ) { |
| | | mapNode.setValue(-1);//禁用节点 |
| | | if (whiteFlag) { |
| | | continue;//存在白名单,不执行下列过滤方案 |
| | | } |
| | | } else if (mapType == NavigationMapType.NORMAL.id) { |
| | | //过滤库位状态X |
| | | if (loc.getLocSts$().equals("X")) { |
| | | mapNode.setValue(-1);//禁用节点 |
| | | } |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | |
| | | List<MapNode> list = lists.get(row); |
| | | MapNode mapNode = list.get(bay); |
| | | |
| | | if (mapType == NavigationMapType.NONE.id) { |
| | | //不过滤任何数据 |
| | | } else if (mapType == NavigationMapType.DFX.id) { |
| | | //车辆有货 |
| | | //读取对应库位数据,将DFX库位状态的节点置为-1(障碍物) |
| | | if (loc.getLocSts$().equals("F") |
| | | || loc.getLocSts$().equals("D") |
| | | || loc.getLocSts$().equals("X") |
| | | ) { |
| | | mapNode.setValue(-1);//禁用节点 |
| | | } |
| | | } else if (mapType == NavigationMapType.NORMAL.id) { |
| | | //过滤库位状态X |
| | | if (loc.getLocSts$().equals("X")) { |
| | | mapNode.setValue(-1);//禁用节点 |
| | | } |
| | | } |
| | | |
| | | //更新list |
| | | list.set(bay, mapNode); |
| | | lists.set(row, list); |
| | | } |
| | | } |
| | | |
| | | //加载车辆坐标到地图中 |