From 24393cdbdcc3f3e921050e733bd6a27208d4ea55 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 09 五月 2023 12:48:54 +0800
Subject: [PATCH] console.html fixed
---
src/main/java/com/zy/common/utils/NavigateMapData.java | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/NavigateMapData.java b/src/main/java/com/zy/common/utils/NavigateMapData.java
index 7ffae0e..38e2a3f 100644
--- a/src/main/java/com/zy/common/utils/NavigateMapData.java
+++ b/src/main/java/com/zy/common/utils/NavigateMapData.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.zy.core.enums.ShuttleTaskModeType;
import java.io.*;
import java.util.ArrayList;
@@ -12,15 +13,17 @@
public class NavigateMapData {
public int[][] getData() {
- return getData("in");
+ return getData(ShuttleTaskModeType.PAK_IN.id);
}
- public int[][] getData(String mapType) {
+ public int[][] getData(Integer mapType) {
try {
String mapFilename = "";
- if (mapType.equals("in")) {
+ if (mapType == ShuttleTaskModeType.PAK_IN.id) {
+ //鍏ュ簱鍦板浘
mapFilename = "mapIn.json";
}else {
+ //鍑哄簱鍦板浘
mapFilename = "mapOut.json";
}
@@ -63,4 +66,53 @@
return null;
}
+ //鑾峰彇JSON鏍煎紡鏁版嵁
+ public ArrayList<ArrayList<JSONObject>> getJsonData(Integer mapType) {
+ try {
+ String mapFilename = "";
+ if (mapType == ShuttleTaskModeType.PAK_IN.id) {
+ //鍏ュ簱鍦板浘
+ mapFilename = "mapIn.json";
+ }else {
+ //鍑哄簱鍦板浘
+ mapFilename = "mapOut.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();
+
+ //杩斿洖鐨勭粨鏋滈泦
+ ArrayList<ArrayList<JSONObject>> returnLists = new ArrayList<>();
+
+ //瑙f瀽json鍦板浘鏁版嵁
+ ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class);
+ for (Object obj : arrayList) {
+ ArrayList list = JSON.parseObject(obj.toString(), ArrayList.class);
+ ArrayList<JSONObject> maps = new ArrayList<>();
+ for (Object o : list) {
+ JSONObject jsonObject = JSON.parseObject(o.toString());
+ maps.add(jsonObject);
+ }
+ returnLists.add(maps);
+ }
+
+ return returnLists;
+ } else {
+ System.out.println("鏂囦欢涓嶅瓨鍦�!");
+ }
+ } catch (IOException ioException) {
+ ioException.printStackTrace();
+ }
+ return null;
+ }
+
}
--
Gitblit v1.9.1