zjs hai 2 semanas
pai
achega
792e724df0

+ 1 - 1
src/main/java/com/cn/esermis/EsermisApplication.java

@@ -25,7 +25,7 @@ public class EsermisApplication  implements CommandLineRunner {
25 25
         /**
26 26
          * 使用异步注解方式启动netty服务端服务
27 27
          */
28
-        new BootNettyServer().bind(8088);
28
+        new BootNettyServer().bind(19900);
29 29
     }
30 30
 
31 31
 }

+ 6 - 0
src/main/java/com/cn/esermis/constant/Constant.java

@@ -1,5 +1,9 @@
1 1
 package com.cn.esermis.constant;
2 2
 
3
+import java.util.ArrayList;
4
+import java.util.Arrays;
5
+import java.util.List;
6
+
3 7
 public class Constant {
4 8
 
5 9
         public static final  String ST_AIR = "31"; //大气环境污染源
@@ -13,4 +17,6 @@ public class Constant {
13 17
         public static final  String CN = "CN"; //大气环境污染源
14 18
         public static final  String SERVER = "server"; //大气环境污染源
15 19
 
20
+        public static final List<String> COMMAND = new ArrayList<>(Arrays.asList(HOUR, MINUTE, REAL)); // 解析数据编码
21
+
16 22
 }

+ 1 - 1
src/main/java/com/cn/esermis/dpld/business/MonitorBusiness.java

@@ -397,7 +397,7 @@ public class MonitorBusiness {
397 397
         if (o != null){
398 398
             PreMarking preMarking = JSON.parseObject(o.toString(), PreMarking.class);
399 399
             Date date = formatter.parse(time);
400
-            if (preMarking.getStartTime().getTime() >= date.getTime()){
400
+            if (preMarking.getStartTime().getTime() <= date.getTime()){
401 401
                 return preMarking.getWorkingCondition();
402 402
             }
403 403
         }

+ 20 - 7
src/main/java/com/cn/esermis/utils/HJ212MsgUtils.java

@@ -1,6 +1,7 @@
1 1
 package com.cn.esermis.utils;
2 2
 
3 3
 import com.alibaba.fastjson2.JSONObject;
4
+import com.cn.esermis.constant.Constant;
4 5
 import lombok.extern.slf4j.Slf4j;
5 6
 
6 7
 import java.util.LinkedList;
@@ -66,7 +67,9 @@ public class HJ212MsgUtils {
66 67
                     .replace(",", "\",\"").replace(";", "\",\"");
67 68
             data.put("SIZE", headStr.substring(0, 4));
68 69
             data.putAll(JSONObject.parseObject("{\"" + headStr.substring(4) + "\"}"));
69
-
70
+            if (!Constant.COMMAND.contains(data.getString("CN"))){
71
+                return data;
72
+            }
70 73
             // 清洗数据体基本数据
71 74
             String[] monitors = subMsg[1].split(";");
72 75
             List<JSONObject> cp = new LinkedList<>();
@@ -100,13 +103,23 @@ public class HJ212MsgUtils {
100 103
      * 解析污染源数据,获取污染源编号
101 104
      */
102 105
     private static String[] getPollutionSource(String data) {
103
-        String key = data.substring(0, data.indexOf("-"));
104
-        data = data.replaceAll(key + "-", "");
106
+        if (data.contains("-")){
107
+            String key = data.substring(0, data.indexOf("-"));
108
+            data = data.replaceAll(key + "-", "");
109
+
110
+            String[] result = new String[2];
111
+            result[0] = key;
112
+            result[1] = data;
113
+            return result;
114
+        }else {
115
+            if (data.contains(":")){
116
+                String[] split = data.split(":");
117
+                return split;
118
+            }
119
+
120
+            return new String[]{data};
121
+        }
105 122
 
106
-        String[] result = new String[2];
107
-        result[0] = key;
108
-        result[1] = data;
109
-        return result;
110 123
     }
111 124
 
112 125