Commit 037212d2 authored by 高建强's avatar 高建强

item:稳压泵启停状态图接口剔除iotCode为空

parent 28465f81
......@@ -220,44 +220,42 @@ public class EmergencyServiceImpl implements IEmergencyService {
List<Integer> yList = new ArrayList<>();
String name = x.get("name").toString();
yMap.put("name", name);
String iotCode = x.get("iotCode").toString();
Object iotCode = x.get("iotCode");
String prefix = null;
String suffix = null;
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
ResponseModel responseModel = null;
try {
responseModel = iotFeign.selectList(appKey, product, token, startTime, endTime, prefix, suffix, fieldKey);
} catch (Exception e) {
e.printStackTrace();
}
if (200 == responseModel.getStatus()) {
String json = JSON.toJSONString(responseModel.getResult());
List<Map<String, String>> dataList = (List<Map<String, String>>) JSONArray.parse(json);
if (!CollectionUtils.isEmpty(dataList)) {
Collections.reverse(dataList);
Map<String, List<Map<String, String>>> dataMap = dataList.stream().collect(Collectors.groupingBy(e -> e.get("time").substring(5, 16).replace("T", " ")));
timeList.forEach(t -> {
List<Map<String, String>> data = dataMap.get(t);
if (!CollectionUtils.isEmpty(data)) {
List<Map<String, String>> yDataList = dataMap.get(t).stream().filter(o -> "true".equals(o.get(fieldKey).toString())).collect(Collectors.toList());
yList.add(CollectionUtils.isEmpty(yDataList) ? 0 : 1);
} else {
if (x.get("iotCode") != null && iotCode.toString().length() > 8) {
prefix = iotCode.toString().substring(0, 8);
suffix = iotCode.toString().substring(8);
ResponseModel responseModel = null;
try {
responseModel = iotFeign.selectList(appKey, product, token, startTime, endTime, prefix, suffix, fieldKey);
} catch (Exception e) {
e.printStackTrace();
}
if (200 == responseModel.getStatus()) {
String json = JSON.toJSONString(responseModel.getResult());
List<Map<String, String>> dataList = (List<Map<String, String>>) JSONArray.parse(json);
if (!CollectionUtils.isEmpty(dataList)) {
Collections.reverse(dataList);
Map<String, List<Map<String, String>>> dataMap = dataList.stream().collect(Collectors.groupingBy(e -> e.get("time").substring(5, 16).replace("T", " ")));
timeList.forEach(t -> {
List<Map<String, String>> data = dataMap.get(t);
if (!CollectionUtils.isEmpty(data)) {
List<Map<String, String>> yDataList = dataMap.get(t).stream().filter(o -> "true".equals(o.get(fieldKey).toString())).collect(Collectors.toList());
yList.add(CollectionUtils.isEmpty(yDataList) ? 0 : 1);
} else {
yList.add(0);
}
});
} else {
timeList.forEach(t -> {
yList.add(0);
}
});
} else {
timeList.forEach(t -> {
yList.add(0);
});
});
}
}
yMap.put("data", yList);
yData.add(yMap);
}
yMap.put("data", yList);
yData.add(yMap);
});
map.put("xData", timeList);
map.put("yData", yData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment