From 802c12dcbc63ee1662c15723d27c8fc1f4fd36e6 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期六, 21 十二月 2024 08:42:56 +0800 Subject: [PATCH] #拐点算法优化 --- src/main/java/com/zy/common/utils/NavigateMapData.java | 67 +++++++++++++++++++++++++++++---- 1 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/zy/common/utils/NavigateMapData.java b/src/main/java/com/zy/common/utils/NavigateMapData.java index b843053..7b73bf1 100644 --- a/src/main/java/com/zy/common/utils/NavigateMapData.java +++ b/src/main/java/com/zy/common/utils/NavigateMapData.java @@ -5,12 +5,14 @@ import com.core.common.SpringUtils; import com.zy.asrs.entity.BasMap; import com.zy.asrs.entity.LocMast; +import com.zy.asrs.service.BasShuttleService; import com.zy.asrs.service.LocMastService; 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.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Component; @@ -27,11 +29,11 @@ private Integer lev;//鍦板浘妤煎眰 - public NavigateMapData() { - this.lev = 1; + public Integer getLev() { + return lev; } - public NavigateMapData(Integer lev) { + public void setLev(Integer lev) { this.lev = lev; } @@ -41,6 +43,30 @@ public int[][] getData(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { try { +// RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); +// Object object = redisUtil.get(RedisKeyType.BASIC_MAP.key + lev); +// if (object == null) { +// return null; +// } +// +// //瑙f瀽json鍦板浘鏁版嵁 +// ArrayList arrayList = JSON.parseObject(object.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; + String mapFilename = "map_" + lev + ".json"; ClassPathResource classPathResource = new ClassPathResource(mapFilename); InputStream inputStream = classPathResource.getInputStream(); @@ -84,8 +110,8 @@ } else { System.out.println("鏂囦欢涓嶅瓨鍦�!"); } - } catch (IOException ioException) { - ioException.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } return null; } @@ -129,6 +155,18 @@ //鑾峰彇JSON鏍煎紡鏁版嵁 public List<List<MapNode>> getJsonData(Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { try { +// RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); +// Object object = redisUtil.get(RedisKeyType.BASIC_MAP.key + lev); +// if (object == null) { +// return null; +// } +// +// //瑙f瀽json鍦板浘鏁版嵁 +// ArrayList arrayList = JSON.parseObject(object.toString(), ArrayList.class); +// List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//杩囨护鍦板浘鏁版嵁 +// return lists; + + String mapFilename = "map_" + lev + ".json"; ClassPathResource classPathResource = new ClassPathResource(mapFilename); InputStream inputStream = classPathResource.getInputStream(); @@ -161,8 +199,8 @@ } else { System.out.println("鏂囦欢涓嶅瓨鍦�!"); } - } catch (IOException ioException) { - ioException.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } return null; } @@ -170,6 +208,17 @@ //鑾峰彇JSON鏍煎紡鏁版嵁 public List<List<MapNode>> getJsonData(Integer lev, Integer mapType, List<int[]> whitePoints, List<int[]> shuttlePoints) { try { +// RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); +// Object object = redisUtil.get(RedisKeyType.BASIC_MAP.key + lev); +// if (object == null) { +// return null; +// } +// +// //瑙f瀽json鍦板浘鏁版嵁 +// ArrayList arrayList = JSON.parseObject(object.toString(), ArrayList.class); +// List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//杩囨护鍦板浘鏁版嵁 +// return lists; + String mapFilename = "map_" + lev + ".json"; ClassPathResource classPathResource = new ClassPathResource(mapFilename); InputStream inputStream = classPathResource.getInputStream(); @@ -202,8 +251,8 @@ } else { System.out.println("鏂囦欢涓嶅瓨鍦�!"); } - } catch (IOException ioException) { - ioException.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); } return null; } -- Gitblit v1.9.1