6 Коміти e9a8fb31d5 ... 220fb52dd4

Автор SHA1 Опис Дата
  zjs 220fb52dd4 Merge branch 'refs/heads/master' into fb 3 днів тому
  zjs 768a833a6f 防止重复数据 入队列 4 днів тому
  zjs 1ef6daa1a9 防止重复数据 入队列 4 днів тому
  zjs c41d60b989 防止重复数据 入队列 4 днів тому
  zjs 562b1bc8a7 回复消息 bug修改 4 днів тому
  zjs 09986395c1 回复消息 bug修改 4 днів тому

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

@@ -26,8 +26,8 @@ public class EsermisApplication  implements CommandLineRunner {
26 26
         /**
27 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 347
         } catch (Exception e) {
348
-//            throw new RuntimeException(e);
348
+            throw new RuntimeException(e);
349 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 23
 import java.util.Date;
24 24
 import java.util.HashMap;
25 25
 import java.util.Map;
26
-import java.util.concurrent.TimeUnit;
27 26
 
28 27
 @Log4j2
29 28
 @Component
@@ -96,7 +95,7 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
96 95
                             String MN = jsonObject.getString("MN");
97 96
                             String dataTime = jsonObject.getString("DataTime");
98 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 99
                                 adapter.redisQueueService.sendMessage(Constant.SERVER, jsonObject);
101 100
                             }
102 101
                         }
@@ -113,7 +112,7 @@ public class BootNettyChannelInboundHandlerAdapter extends ChannelInboundHandler
113 112
                                 String MN = jsonObject.getString("MN");
114 113
                                 String dataTime = jsonObject.getString("DataTime");
115 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 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 5
 import com.cn.esermis.constant.Constant;
6 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 12
  * @author DaHuaJia
@@ -61,6 +60,9 @@ public class HJ212MsgUtils {
61 60
      * @return json
62 61
      */
63 62
     public static JSONObject dealMsg2(String msg) {
63
+        if (msg.contains("CN=2011")){
64
+            return null;
65
+        }
64 66
         JSONObject data = new JSONObject();
65 67
         try {
66 68
             // 拆分消息
@@ -103,7 +105,23 @@ public class HJ212MsgUtils {
103 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 125
             // 保存消息尾数据,主要是CRC校验和包结束符
108 126
             data.put("End", subMsg[2]);
109 127