fix: 异常数据兼容处理

haikang
huangfeng 2 weeks ago
parent 3140b55c93
commit 5f23f3f003

@ -24,17 +24,20 @@ public class SanbizhiModel {
Iterator<String> it = map.keySet().iterator(); Iterator<String> it = map.keySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
String key = it.next(); String key = it.next();
Object value = map.get(key);
String name = key.toLowerCase(); String name = key.toLowerCase();
if (value != null) {
if (name.contains("c2h2")) { if (name.contains("c2h2")) {
c2h2 = Float.parseFloat(map.get(key).toString()); c2h2 = Float.parseFloat(value.toString());
} else if (name.contains("c2h4")) { } else if (name.contains("c2h4")) {
c2h4 = Float.parseFloat(map.get(key).toString()); c2h4 = Float.parseFloat(value.toString());
} else if (name.contains("ch4")) { } else if (name.contains("ch4")) {
ch4 = Float.parseFloat(map.get(key).toString()); ch4 = Float.parseFloat(value.toString());
} else if (name.contains("h2")) { } else if (name.contains("h2")) {
h2 = Float.parseFloat(map.get(key).toString()); h2 = Float.parseFloat(value.toString());
} else if (name.contains("c2h6")) { } else if (name.contains("c2h6")) {
c2h6 = Float.parseFloat(map.get(key).toString()); c2h6 = Float.parseFloat(value.toString());
}
} }
} }
if (c2h2 == null || c2h4 == null || ch4 == null || h2 == null || c2h6 == null) { if (c2h2 == null || c2h4 == null || ch4 == null || h2 == null || c2h6 == null) {

@ -215,7 +215,11 @@ public class NSensorServiceImpl implements NSensorService {
if (result.getContent() != null) { if (result.getContent() != null) {
for (Map<String, Object> map : result.getContent()) { for (Map<String, Object> map : result.getContent()) {
SanbizhiModel sanbizhi = new SanbizhiModel(); SanbizhiModel sanbizhi = new SanbizhiModel();
try {
sanbizhi.build(map); sanbizhi.build(map);
} catch (Exception ignore) {
sanbizhi.setStatus("有异常数据");
}
map.put("sanbizhi", sanbizhi); map.put("sanbizhi", sanbizhi);
} }
} }

Loading…
Cancel
Save