| | |
| | | import com.zy.common.model.MapNode; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.model.enums.NavigationMapType; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.ShuttleTaskModeType; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.*; |
| | |
| | | public int[][] getData(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | String mapFilename = "map_" + lev + ".json"; |
| | | ClassPathResource classPathResource = new ClassPathResource(mapFilename); |
| | | InputStream inputStream = classPathResource.getInputStream(); |
| | | byte[] buffer = new byte[inputStream.available()]; |
| | | inputStream.read(buffer); |
| | | File file = File.createTempFile("prefix","suffix"); |
| | | try (OutputStream outStream = new FileOutputStream(file)) { |
| | | outStream.write(buffer); |
| | | } |
| | | |
| | | 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"); |
| | |
| | | */ |
| | | public int[][] getDataFromRedis(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | Object o = redisUtil.get("realtimeBasMap_" + lev); |
| | | Object o = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (o == null) { |
| | | return null; |
| | | } |
| | |
| | | public List<List<MapNode>> getJsonData(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | String mapFilename = "map_" + lev + ".json"; |
| | | ClassPathResource classPathResource = new ClassPathResource(mapFilename); |
| | | InputStream inputStream = classPathResource.getInputStream(); |
| | | byte[] buffer = new byte[inputStream.available()]; |
| | | inputStream.read(buffer); |
| | | File file = File.createTempFile("prefix","suffix"); |
| | | try (OutputStream outStream = new FileOutputStream(file)) { |
| | | outStream.write(buffer); |
| | | } |
| | | |
| | | 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"); |
| | |
| | | public List<List<MapNode>> getJsonData(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | String mapFilename = "map_" + lev + ".json"; |
| | | ClassPathResource classPathResource = new ClassPathResource(mapFilename); |
| | | InputStream inputStream = classPathResource.getInputStream(); |
| | | byte[] buffer = new byte[inputStream.available()]; |
| | | inputStream.read(buffer); |
| | | File file = File.createTempFile("prefix","suffix"); |
| | | try (OutputStream outStream = new FileOutputStream(file)) { |
| | | outStream.write(buffer); |
| | | } |
| | | |
| | | 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"); |
| | |
| | | } |
| | | |
| | | //加载白名单节点 |
| | | List<List<MapNode>> realMap = getJsonData(lev, -1, null, null);//获取完整地图 |
| | | for (int[] points : whitePoints) { |
| | | //获取原始节点数据 |
| | | int x = points[0]; |
| | | int y = points[1]; |
| | | List<MapNode> rows = realMap.get(x); |
| | | MapNode col = rows.get(y); |
| | | if (whitePoints != null) { |
| | | List<List<MapNode>> realMap = getJsonData(lev, -1, null, null);//获取完整地图 |
| | | for (int[] points : whitePoints) { |
| | | //获取原始节点数据 |
| | | int x = points[0]; |
| | | int y = points[1]; |
| | | List<MapNode> rows = realMap.get(x); |
| | | MapNode col = rows.get(y); |
| | | |
| | | List<MapNode> list = lists.get(x); |
| | | MapNode mapNode = list.get(y); |
| | | mapNode.setValue(col.getValue());//恢复原始节点 |
| | | List<MapNode> list = lists.get(x); |
| | | MapNode mapNode = list.get(y); |
| | | mapNode.setValue(col.getValue());//恢复原始节点 |
| | | |
| | | //更新list |
| | | list.set(y, mapNode); |
| | | lists.set(x, list); |
| | | //更新list |
| | | list.set(y, mapNode); |
| | | lists.set(x, list); |
| | | } |
| | | } |
| | | |
| | | |
| | | return lists; |
| | | } |