From 131fd52a71e4801957a80305afb2ea959ecc72fd Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 17 十一月 2023 10:09:52 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/ConsoleController.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java
index 54cbddd..3c08969 100644
--- a/src/main/java/com/zy/asrs/controller/ConsoleController.java
+++ b/src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -27,6 +27,7 @@
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.CrnModeType;
+import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.CrnSlave;
import com.zy.core.model.DevpSlave;
@@ -41,6 +42,10 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
import java.util.*;
/**
@@ -308,7 +313,7 @@
@GetMapping("/map/{lev}/auth")
@ManagerAuth
public R getMapFromRedis(@PathVariable Integer lev) {
- Object data = redisUtil.get("realtimeBasMap_" + lev);
+ Object data = redisUtil.get(RedisKeyType.MAP.key + lev);
if (data == null) {
return R.error();
}
@@ -322,12 +327,56 @@
}
/**
+ * 鑾峰彇PLC2鏁版嵁
+ */
+ @GetMapping("/plc2/auth")
+ @ManagerAuth
+ public R getMapFromPlc2() {
+ try {
+ String mapFilename = "plc2.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();
+ }
+
+ NavigateMapData navigateMapData = new NavigateMapData();
+
+ //瑙f瀽json鍦板浘鏁版嵁
+ ArrayList arrayList = JSON.parseObject(stringBuffer.toString(), ArrayList.class);
+ List<List<MapNode>> lists = new ArrayList<>();
+ //閲嶅缓鏁版嵁鏍煎紡
+ for (int i = 0; i < arrayList.size(); i++) {
+ Object obj = arrayList.get(i);
+ List<MapNode> list = JSON.parseArray(obj.toString(), MapNode.class);
+ for (int j = 0; j < list.size(); j++) {
+ MapNode mapNode = list.get(j);
+ list.set(j, mapNode);
+ }
+ lists.add(list);
+ }
+ return R.ok().add(lists);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return R.error();
+ }
+
+ /**
* 閲嶇疆redis涓殑鍦板浘锛屽皢鍗犵敤鐨勫簱浣嶅叏閮ㄨВ闄�
*/
@GetMapping("/map/resetMap/auth")
@ManagerAuth
public R resetMapToRedis() {
- for (int i = 1; i <= 4; i++) {//鎬诲叡鍥涘眰妤�
+ for (int i = 1; i <= 10; i++) {//鎬诲叡10灞傛ゼ
BasMap basMap = basMapService.selectLatestMap(i);
//杞藉叆鍦板浘
NavigateMapData mapData = new NavigateMapData(i);
@@ -353,7 +402,7 @@
}
//灏嗘暟鎹簱鍦板浘鏁版嵁瀛樺叆redis
- redisUtil.set("realtimeBasMap_" + i, JSON.toJSONString(basMap));
+ redisUtil.set(RedisKeyType.MAP.key + i, JSON.toJSONString(basMap));
}
return R.ok();
}
@@ -388,7 +437,7 @@
}
//灏嗘暟鎹簱鍦板浘鏁版嵁瀛樺叆redis
- redisUtil.set("realtimeBasMap_" + lev, JSON.toJSONString(basMap));
+ redisUtil.set(RedisKeyType.MAP.key + lev, JSON.toJSONString(basMap));
return R.ok();
}
--
Gitblit v1.9.1