From f1623023b61dfe83c2f48836c09709d3dcb6e2b0 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 27 三月 2025 14:27:52 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/utils/NavigateMapData.java | 189 ++++++----------------------------------------
1 files changed, 27 insertions(+), 162 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/NavigateMapData.java b/src/main/java/com/zy/common/utils/NavigateMapData.java
index 2a2351f..d19f34b 100644
--- a/src/main/java/com/zy/common/utils/NavigateMapData.java
+++ b/src/main/java/com/zy/common/utils/NavigateMapData.java
@@ -4,6 +4,7 @@
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasMap;
import com.zy.asrs.entity.LocMast;
+import com.zy.asrs.service.BasMapService;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.MapNode;
@@ -17,7 +18,6 @@
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.ForkLiftThread;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
import java.io.*;
@@ -32,76 +32,31 @@
@Autowired
private SlaveProperties slaveProperties;
+ @Autowired
+ private BasMapService basMapService;
public int[][] getData(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);//杩囨护鍦板浘鏁版嵁
-// 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;
+ BasMap basMap = basMapService.selectLatestMap(lev);
+ String originData = basMap.getOriginData();
- 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);
+ //瑙f瀽json鍦板浘鏁版嵁
+ ArrayList arrayList = JSON.parseObject(originData, 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;
}
- 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();
-
- //瑙f瀽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;
- }
-
- if (!file.delete()) {
- System.out.println("涓存椂鏂囦欢鍒犻櫎澶辫触");
- }
- return map;
- } else {
- System.out.println("鏂囦欢涓嶅瓨鍦�!");
- }
+ return map;
} catch (Exception e) {
e.printStackTrace();
}
@@ -144,106 +99,16 @@
return map;
}
-// //鑾峰彇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();
-// byte[] buffer = new byte[inputStream.available()];
-// inputStream.read(buffer);
-// File file = File.createTempFile("prefix","suffix");
-// try (OutputStream outStream = new FileOutputStream(file)) {
-// outStream.write(buffer);
-// }
-//
-// 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();
-//
-// //瑙f瀽json鍦板浘鏁版嵁
-// ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class);
-// List<List<MapNode>> lists = filterMap(mapType, arrayList, lev, whitePoints, shuttlePoints);//杩囨护鍦板浘鏁版嵁
-//
-// if (!file.delete()) {
-// System.out.println("涓存椂鏂囦欢鍒犻櫎澶辫触");
-// }
-//
-// return lists;
-// } else {
-// System.out.println("鏂囦欢涓嶅瓨鍦�!");
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// return null;
-// }
-
//鑾峰彇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();
- byte[] buffer = new byte[inputStream.available()];
- inputStream.read(buffer);
- File file = File.createTempFile("prefix","suffix");
- try (OutputStream outStream = new FileOutputStream(file)) {
- outStream.write(buffer);
- }
-
- 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();
-
- //瑙f瀽json鍦板浘鏁版嵁
- ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class);
- //閲嶅缓鏁版嵁鏍煎紡
- List<List<MapNode>> lists = rebuildData(arrayList);
-
- if (!file.delete()) {
- System.out.println("涓存椂鏂囦欢鍒犻櫎澶辫触");
- }
-
- return lists;
- } else {
- System.out.println("鏂囦欢涓嶅瓨鍦�!");
- }
+ BasMap basMap = basMapService.selectLatestMap(lev);
+ String originData = basMap.getOriginData();
+ //瑙f瀽json鍦板浘鏁版嵁
+ ArrayList arrayList = JSON.parseObject(originData, ArrayList.class);
+ //閲嶅缓鏁版嵁鏍煎紡
+ List<List<MapNode>> lists = rebuildData(arrayList);
+ return lists;
} catch (Exception e) {
e.printStackTrace();
}
--
Gitblit v1.9.1