Commit f7b694c2 authored by chenzhao's avatar chenzhao

修改代码

parent 89bd0685
...@@ -26,6 +26,7 @@ public class IndicatorsDto { ...@@ -26,6 +26,7 @@ public class IndicatorsDto {
private String valueLabel; private String valueLabel;
private String distinct; private String distinct;
private String time; private String time;
private String timeValue;
private String displayName; private String displayName;
private String pictureName; private String pictureName;
private String title; private String title;
...@@ -42,4 +43,14 @@ public class IndicatorsDto { ...@@ -42,4 +43,14 @@ public class IndicatorsDto {
public void setTime(String time) { public void setTime(String time) {
this.time = time; this.time = time;
} }
public void setTimeValue(String time) {
this.timeValue = time;
}
public String getTimeValue() {
if (null != timeValue) {
return timeValue.substring(0,5);
}
return null;
}
} }
...@@ -1673,10 +1673,12 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1673,10 +1673,12 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
map.put("efficiency", keepTwoDecimalPlaces(e.getValue())); map.put("efficiency", keepTwoDecimalPlaces(e.getValue()));
break; break;
case "日发电量": case "日发电量":
map.put("dayNum", keepTwoDecimalPlaces(e.getValue())); double v = Double.parseDouble(e.getValue()) * CommonConstans.pvGenPoweActor;
map.put("dayNum", keepTwoDecimalPlaces(String.valueOf(v)));
break; break;
case "总发电量": case "总发电量":
map.put("yearNum", keepTwoDecimalPlaces(e.getValue())); double a = Double.parseDouble(e.getValue()) * CommonConstans.pvGenPoweActor;
map.put("yearNum", keepTwoDecimalPlaces(String.valueOf(a)));
break; break;
} }
}); });
...@@ -1696,22 +1698,34 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1696,22 +1698,34 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
String[] equipNumber = equipNum.split("-"); String[] equipNumber = equipNum.split("-");
String sql = "SELECT time ,equipmentIndexName ,value FROM iot_data_" + gatewayId + " WHERE time >'" + time + "' and equipmentSpecificName =~/" + equipNumber[0] + "子阵/ and equipmentSpecificName =~/逆变器" + equipNumber[1] + "/ and equipmentSpecificName =~/" + Integer.parseInt(equipNumber[2]) + "汇流箱/ and equipmentIndexName =~/路电流/"; String sql = "SELECT time ,equipmentIndexName ,value FROM iot_data_" + gatewayId + " WHERE time >'" + time + "' and equipmentSpecificName =~/" + equipNumber[0] + "子阵/ and equipmentSpecificName =~/逆变器" + equipNumber[1] + "/ and equipmentSpecificName =~/" + Integer.parseInt(equipNumber[2]) + "汇流箱/ and equipmentIndexName =~/路电流/";
String timeSql = "SELECT DISTINCT value FROM iot_data_" + gatewayId + " WHERE time >'" + time + "' and equipmentSpecificName =~/" + equipNumber[0] + "子阵/ and equipmentSpecificName =~/逆变器" + equipNumber[1] + "/ and equipmentSpecificName =~/" + Integer.parseInt(equipNumber[2]) + "汇流箱/ and equipmentIndexName =~/路电流/ group by time(2m)"; String timeSql = "SELECT DISTINCT value FROM iot_data_" + gatewayId + " WHERE time >'" + time + "' and equipmentSpecificName =~/" + equipNumber[0] + "子阵/ and equipmentSpecificName =~/逆变器" + equipNumber[1] + "/ and equipmentSpecificName =~/" + Integer.parseInt(equipNumber[2]) + "汇流箱/ and equipmentIndexName =~/路电流/ group by time(2m)";
List<IndicatorsDto> dataList = influxDButils.getListData(sql, IndicatorsDto.class); List<IndicatorsDto> dataList = influxDButils.getListDataAll(sql, IndicatorsDto.class);
List<IndicatorsDto> timeList = influxDButils.getListDataAll(timeSql, IndicatorsDto.class); // List<IndicatorsDto> timeList = influxDButils.getListDataAll(timeSql, IndicatorsDto.class);
Map<String, List<IndicatorsDto>> timeMap = timeList.stream().collect(Collectors.groupingBy(IndicatorsDto::getTime, LinkedHashMap::new, Collectors.toList())); Map<String, Object> resultMap = new HashMap<>();
// Map<String, List<IndicatorsDto>> timeMap = timeList.stream().collect(Collectors.groupingBy(IndicatorsDto::getTime, LinkedHashMap::new, Collectors.toList()));
Map<String, List<IndicatorsDto>> data = dataList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName, LinkedHashMap::new, Collectors.toList())); Map<String, List<IndicatorsDto>> data = dataList.stream().collect(Collectors.groupingBy(IndicatorsDto::getEquipmentIndexName, LinkedHashMap::new, Collectors.toList()));
int num = 0;
List<Map<String, Object>> seriesData = new ArrayList<>(); List<Map<String, Object>> seriesData = new ArrayList<>();
for (String s : data.keySet()) { for (String s : data.keySet()) {
data.get(s).stream().forEach(e->{
e.setTimeValue(e.getTime());
});
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<String> value = data.get(s).stream().map(IndicatorsDto::getValue).collect(Collectors.toList()); List<String> value = data.get(s).stream().map(IndicatorsDto::getValue).collect(Collectors.toList());
map.put("data", value); map.put("data", value);
// map.put("name","pv"+s.substring(4,6));
seriesData.add(map); seriesData.add(map);
if (value.size()>num){
Map<String, List<IndicatorsDto>> timeMap = data.get(s).stream().collect(Collectors.groupingBy(IndicatorsDto::getTimeValue , LinkedHashMap::new, Collectors.toList()));
resultMap.put("axisData", timeMap.keySet());
}
num = value.size()>num ? value.size():num;
} }
Map<String, Object> map = new HashMap<>();
map.put("seriesData", seriesData); resultMap.put("seriesData", seriesData);
map.put("axisData", timeMap.keySet()); return resultMap;
return map;
} }
......
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