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

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

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