Ver código fonte

回复消息 bug修改

zjs 4 dias atrás
pai
commit
09986395c1

+ 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
     }

+ 19 - 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
@@ -103,7 +102,23 @@ public class HJ212MsgUtils {
103 102
                     cp.add(jsonObject);
104 103
                 }
105 104
             }
106
-            data.put("CP", cp);
105
+            // 处理有相同因子 值不同的数据
106
+            Set<JSONObject> cpNew = new HashSet<>();
107
+            for (JSONObject jsonObject : cp) {
108
+                JSONObject cpd = new JSONObject();
109
+                List<JSONObject> collect = cp.stream().filter(d -> d.getString("factor").equals(jsonObject.getString("factor"))).collect(Collectors.toList());
110
+//                System.out.println(collect);
111
+                for (JSONObject object : collect) {
112
+                    cpd.putAll(object);
113
+                }
114
+                cpNew.add(cpd);
115
+            }
116
+
117
+
118
+
119
+            data.put("CP", cpNew);
120
+
121
+
107 122
             // 保存消息尾数据,主要是CRC校验和包结束符
108 123
             data.put("End", subMsg[2]);
109 124