liubo лет назад: 3
Родитель
Сommit
4db4c2726c

+ 6 - 17
zd-modules/zd-base/src/main/java/com/zd/base/files/ueditor/ConfigManager.java

@@ -2,21 +2,24 @@ package com.zd.base.files.ueditor;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import org.springframework.core.io.ClassPathResource;
 
 import java.io.*;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 public class ConfigManager {
-    private String rootPath;
     private String localPath;
     private JSONObject jsonConfig;
 
     private ConfigManager(String localPath) throws IOException {
-        this.rootPath = this.getClass().getClassLoader().getResource("ueditor").getPath();
+
+        String result = new BufferedReader(new InputStreamReader(new ClassPathResource("ueditor/config.json").getInputStream()))
+                .lines().collect(Collectors.joining(System.lineSeparator()));
+        jsonConfig = JSONObject.parseObject(result);
 
         this.localPath = localPath;
-        this.initEnv();
     }
 
     public static ConfigManager getInstance(String realPath) {
@@ -97,20 +100,6 @@ public class ConfigManager {
         return conf;
     }
 
-    private void initEnv() throws IOException {
-        String configContent = this.readFile(this.getConfigPath());
-        try {
-            JSONObject jsonConfig = JSONObject.parseObject(configContent);
-            this.jsonConfig = jsonConfig;
-        } catch (Exception e) {
-            this.jsonConfig = null;
-        }
-    }
-
-    private String getConfigPath() {
-        return this.rootPath + File.separator + "config.json";
-    }
-
     private String[] getArray(String key) {
         JSONArray jsonArray = this.jsonConfig.getJSONArray(key);
         String[] result = new String[jsonArray.size()];

+ 5 - 4
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/socket/runner/TCPServer.java

@@ -8,16 +8,17 @@ import com.zd.laboratory.socket.constant.SocketTypes;
 import com.zd.laboratory.socket.service.BaseRouter;
 import com.zd.laboratory.socket.service.SocketService;
 import com.zd.laboratory.socket.vo.TransmissionVo;
-import com.zd.laboratory.utils.CRCCHECK;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.net.Socket;
 import java.net.SocketException;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * @author dgs
@@ -113,7 +114,7 @@ public class TCPServer implements Runnable {
         try {
             data = data.replace(" ", "").toUpperCase();
             cacheMap.put(data, socket.getOutputStream());
-            log.warn("化学品智能柜锁连接,采集器编号:" + data);
+            log.info("化学品智能柜锁连接,采集器编号:" + data);
         }catch (Exception e){
             log.error(e.toString());
         }