Explorar o código

解决了加载AI点空值问题

songwenbin hai 1 ano
pai
achega
d438850d81

+ 20 - 5
gdnxfgs/src/main/java/com/gyee/edge/gddlly/config/PointService.java

@@ -11,6 +11,7 @@ import java.sql.ResultSet;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ArrayBlockingQueue;
 
 @Slf4j
 @Component
@@ -40,6 +41,8 @@ public class PointService {
         return aiMap;
     }
 
+
+
     private Map<Integer, ArrayList<Point>> loadAiPointMap() {
         Map<Integer, ArrayList<Point>> map = new HashMap<>();
         aiKeyMap = new HashMap<>();
@@ -97,7 +100,7 @@ public class PointService {
         try {
             log.info("加载DI测点......");
             Connection conn = db.getConnection();
-            String sql = "select * from point where pointtype = 'DI' order by publicaddr, pointaddr";
+            String sql = "select * from point where pointtype = 'DI' order by publicaddr, pointaddr asc";
             log.info("执行SQL:" + sql);
             PreparedStatement ps = conn.prepareStatement(sql);
             ResultSet rs = ps.executeQuery();
@@ -137,7 +140,10 @@ public class PointService {
             aiMap = loadAiPointMap();
         }
 
-        return aiMap.get(addr);
+        if (aiMap != null)
+            return aiMap.get(addr);
+
+        return null;
     }
 
     public ArrayList<Point> getDiList(int addr) {
@@ -145,7 +151,10 @@ public class PointService {
             diMap = loadDiPointMap();
         }
 
-        return diMap.get(addr);
+        if (diMap != null)
+            return diMap.get(addr);
+
+        return null;
     }
 
     public ArrayList<String> getAiKeys(int addr) {
@@ -153,7 +162,10 @@ public class PointService {
             loadAiPointMap();
         }
 
-        return aiKeyMap.get(addr);
+        if (aiKeyMap != null)
+            return aiKeyMap.get(addr);
+
+        return null;
     }
 
     public ArrayList<String> getDiKeys(int addr) {
@@ -161,7 +173,10 @@ public class PointService {
             loadDiPointMap();
         }
 
-        return diKeyMap.get(addr);
+        if (diKeyMap != null)
+            return diKeyMap.get(addr);
+
+        return null;
     }
 
 }

+ 7 - 2
gdnxfgs/src/main/java/com/gyee/edge/gddlly/iec104/Iec104Session.java

@@ -104,8 +104,13 @@ public class Iec104Session {
                     short newAddress = request.getTerminalAddress();
                     if (publicAddress != newAddress) {
                         publicAddress = request.getTerminalAddress();
-                        aiList = (ArrayList<Point>)pointService.getAiList().get((int)publicAddress).clone();
-                        diList = (ArrayList<Point>)pointService.getDiList().get((int)publicAddress).clone();
+
+//                        aiList = (ArrayList<Point>)pointService.getAiList().get((int)publicAddress).clone();
+//                        diList = (ArrayList<Point>)pointService.getDiList().get((int)publicAddress).clone();
+
+                        aiList = pointService.getAiList((int)publicAddress);
+                        diList = pointService.getDiList((int)publicAddress);
+
                         aiKeys = pointService.getAiKeys((int)publicAddress);
                         diKeys = pointService.getDiKeys((int)publicAddress);
                     }

+ 1 - 0
gdnxfgs/src/main/java/com/gyee/edge/gddlly/redis/RedisDataService.java

@@ -138,6 +138,7 @@ public class RedisDataService {
                     double value = Double.valueOf(mp.get("value")).doubleValue();
                     if (point.getValue() != value) {
                         point.setConsumed(false);
+                        log.info("*#$ point:" + point.getPoint() + "changed!");
                         point.setValue(value);
                         point.setLastUpdateTime(new Date(time));
                     }

BIN=BIN
gdnxfgs/src/main/resources/gdnxzs.sqlite