Browse Source

Merge branch 'refs/heads/master' into fb

# Conflicts:
#	src/main/java/com/cn/esermis/netty/BootNettyChannelInboundHandlerAdapter.java
#	src/main/resources/application.yml
zjs 3 days ago
parent
commit
220fb52dd4

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

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

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

@@ -345,7 +345,7 @@ public class MonitorBusiness {
345
                 }
345
                 }
346
             }
346
             }
347
         } catch (Exception e) {
347
         } catch (Exception e) {
348
-//            throw new RuntimeException(e);
348
+            throw new RuntimeException(e);
349
 //            log.error("插入数据库异常:"+e);
349
 //            log.error("插入数据库异常:"+e);
350
         }
350
         }
351
     }
351
     }

+ 2 - 3
src/main/java/com/cn/esermis/netty/BootNettyChannelInboundHandlerAdapter.java

@@ -23,7 +23,6 @@ import java.net.InetSocketAddress;
23
 import java.util.Date;
23
 import java.util.Date;
24
 import java.util.HashMap;
24
 import java.util.HashMap;
25
 import java.util.Map;
25
 import java.util.Map;
26
-import java.util.concurrent.TimeUnit;
27
 
26
 
28
 @Log4j2
27
 @Log4j2
29
 @Component
28
 @Component
@@ -96,7 +95,7 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
96
                             String MN = jsonObject.getString("MN");
95
                             String MN = jsonObject.getString("MN");
97
                             String dataTime = jsonObject.getString("DataTime");
96
                             String dataTime = jsonObject.getString("DataTime");
98
                             if (!adapter.redisQueueService.isElementExist(MN +":"+ CN +":"+ dataTime, dataTime)){
97
                             if (!adapter.redisQueueService.isElementExist(MN +":"+ CN +":"+ dataTime, dataTime)){
99
-                                adapter.redisQueueService.addElementWithExpire(MN +":"+ CN +":"+ dataTime, dataTime, 1, TimeUnit.HOURS);
98
+                                adapter.redisQueueService.addElementWithExpire(MN +":"+ CN +":"+ dataTime, dataTime, 2, TimeUnit.HOURS);
100
                                 adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
99
                                 adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
101
                             }
100
                             }
102
                         }
101
                         }
@@ -113,7 +112,7 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
113
                                 String MN = jsonObject.getString("MN");
112
                                 String MN = jsonObject.getString("MN");
114
                                 String dataTime = jsonObject.getString("DataTime");
113
                                 String dataTime = jsonObject.getString("DataTime");
115
                                 if (!adapter.redisQueueService.isElementExist(MN +":"+ CN +":"+ dataTime, dataTime)){
114
                                 if (!adapter.redisQueueService.isElementExist(MN +":"+ CN +":"+ dataTime, dataTime)){
116
-                                    adapter.redisQueueService.addElementWithExpire(MN +":"+ CN +":"+ dataTime, dataTime, 1, TimeUnit.HOURS);
115
+                                    adapter.redisQueueService.addElementWithExpire(MN +":"+ CN +":"+ dataTime, dataTime, 2, TimeUnit.HOURS);
117
                                     adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
116
                                     adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
118
                                 }
117
                                 }
119
                             }
118
                             }

+ 22 - 4
src/main/java/com/cn/esermis/utils/HJ212MsgUtils.java

@@ -5,9 +5,8 @@ import com.cn.esermis.coding.PollutionGas;
5
 import com.cn.esermis.constant.Constant;
5
 import com.cn.esermis.constant.Constant;
6
 import lombok.extern.slf4j.Slf4j;
6
 import lombok.extern.slf4j.Slf4j;
7
 
7
 
8
-import java.util.LinkedList;
9
-import java.util.List;
10
-import java.util.Map;
8
+import java.util.*;
9
+import java.util.stream.Collectors;
11
 
10
 
12
 /**
11
 /**
13
  * @author DaHuaJia
12
  * @author DaHuaJia
@@ -61,6 +60,9 @@ public class HJ212MsgUtils {
61
      * @return json
60
      * @return json
62
      */
61
      */
63
     public static JSONObject dealMsg2(String msg) {
62
     public static JSONObject dealMsg2(String msg) {
63
+        if (msg.contains("CN=2011")){
64
+            return null;
65
+        }
64
         JSONObject data = new JSONObject();
66
         JSONObject data = new JSONObject();
65
         try {
67
         try {
66
             // 拆分消息
68
             // 拆分消息
@@ -103,7 +105,23 @@ public class HJ212MsgUtils {
103
                     cp.add(jsonObject);
105
                     cp.add(jsonObject);
104
                 }
106
                 }
105
             }
107
             }
106
-            data.put("CP", cp);
108
+            // 处理有相同因子 值不同的数据
109
+            Set<JSONObject> cpNew = new HashSet<>();
110
+            for (JSONObject jsonObject : cp) {
111
+                JSONObject cpd = new JSONObject();
112
+                List<JSONObject> collect = cp.stream().filter(d -> d.getString("factor").equals(jsonObject.getString("factor"))).collect(Collectors.toList());
113
+//                System.out.println(collect);
114
+                for (JSONObject object : collect) {
115
+                    cpd.putAll(object);
116
+                }
117
+                cpNew.add(cpd);
118
+            }
119
+
120
+
121
+
122
+            data.put("CP", cpNew);
123
+
124
+
107
             // 保存消息尾数据,主要是CRC校验和包结束符
125
             // 保存消息尾数据,主要是CRC校验和包结束符
108
             data.put("End", subMsg[2]);
126
             data.put("End", subMsg[2]);
109
 
127