Browse Source

#代码修改

zhongwei
yang_shj 2 years ago
parent
commit
3c042a8711
  1. 7
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java
  2. 155
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

7
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicPowerVo.java

@ -5,12 +5,17 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
/**
* @author ysj
* @version 4.0.0
* @date 2023/03/23 16:51:43
*/
@Data @Data
@ApiModel(value = "当日机组有功功率") @ApiModel(value = "当日机组有功功率")
public class PhotovoltaicPowerVo { public class PhotovoltaicPowerVo {
@ApiModelProperty(value = "小时") @ApiModelProperty(value = "小时")
private Integer hour; private String hour;
@ApiModelProperty(value = "有功功率") @ApiModelProperty(value = "有功功率")
private String activePower; private String activePower;

155
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

@ -3,7 +3,6 @@ package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
@ -22,7 +21,6 @@ import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import net.sf.jsqlparser.expression.StringValue;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -66,8 +64,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
private final ISideHustleService sideHustleService; private final ISideHustleService sideHustleService;
private final IHomePageService homePageService;
private final IWeatherService weatherService; private final IWeatherService weatherService;
private final IAnalyseDataService analyseDataService; private final IAnalyseDataService analyseDataService;
@ -296,7 +292,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return records.stream().map(record -> { return records.stream().map(record -> {
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); PhotovoltaicPowerVo load = new PhotovoltaicPowerVo();
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s");
load.setHour(time.getHours()); load.setHour(DateUtil.format(time,"yyyy-mm-dd HH"));
load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0"));
return load; return load;
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList()); }).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());
@ -340,8 +336,8 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
*/ */
private float sumValueByTime(String deviceCode, int rideCount, String type) { private float sumValueByTime(String deviceCode, int rideCount, String type) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
String start = null, end = null; String start, end;
Integer cycleType = 3; int cycleType = 3;
switch (type) { switch (type) {
//年 //年
case "0": case "0":
@ -376,6 +372,8 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME);
end = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; end = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00";
break; break;
default:
throw new ServiceException("无效查询类型!");
} }
return analyseDataService.periodTargetFloat(start, end, 5, cycleType, deviceCode, rideCount, HomePageConstant.PV_GENERATION_CAPACITY); return analyseDataService.periodTargetFloat(start, end, 5, cycleType, deviceCode, rideCount, HomePageConstant.PV_GENERATION_CAPACITY);
} }
@ -571,17 +569,16 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
*/ */
private List<String> getRecentWeek() { private List<String> getRecentWeek() {
// 日期格式化yyyy-mm-dd // 日期格式化yyyy-mm-dd
SimpleDateFormat df = new SimpleDateFormat(DateUtil.PATTERN_DATE);
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
// 开始日期 // 开始日期
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date()); calendar.setTime(new Date());
calendar.add(Calendar.DATE, +1); calendar.add(Calendar.DATE, +1);
list.add(df.format(calendar.getTime())); list.add(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE));
// 获取日期之间的月 // 获取日期之间的月
int i = 0; int i = 0;
while (i <= 7) { while (i <= 7) {
list.add(df.format(calendar.getTime())); list.add(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE));
calendar.add(Calendar.DATE, -1); calendar.add(Calendar.DATE, -1);
i++; i++;
} }
@ -693,14 +690,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
// 根据月份分组 // 根据月份分组
List<PowerMonthVo> powerMonthVos = new ArrayList<>(); List<PowerMonthVo> powerMonthVos = new ArrayList<>();
filter.forEach(item -> { filter.forEach(item -> item.forEach((key, value) -> {
item.forEach((key, value) -> { PowerMonthVo powerMonthVo = new PowerMonthVo();
PowerMonthVo powerMonthVo = new PowerMonthVo(); powerMonthVo.setStrMonth(key);
powerMonthVo.setStrMonth(key); powerMonthVo.setPower(value);
powerMonthVo.setPower(value); powerMonthVos.add(powerMonthVo);
powerMonthVos.add(powerMonthVo); }));
});
});
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth));
// 总和所有相同月份的发电量 // 总和所有相同月份的发电量
List<PowerMonthVo> powerMonthVoList = months.entrySet().stream().map(entry -> { List<PowerMonthVo> powerMonthVoList = months.entrySet().stream().map(entry -> {
@ -765,7 +760,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// redis实时数据 // redis实时数据
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if (CollectionUtil.isEmpty(photovoltaics)) { if (CollectionUtil.isEmpty(photovoltaics)) {
return new ArrayList(); return new ArrayList<>();
} }
// 过滤有效光伏设备 // 过滤有效光伏设备
List<PhotovoltaicTargetVo> filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); List<PhotovoltaicTargetVo> filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList());
@ -820,14 +815,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
// 根据月份分组 // 根据月份分组
List<PowerMonthVo> powerMonthVos = new ArrayList<>(); List<PowerMonthVo> powerMonthVos = new ArrayList<>();
filter.forEach(item -> { filter.forEach(item -> item.forEach((key, value) -> {
item.forEach((key, value) -> { PowerMonthVo powerMonthVo = new PowerMonthVo();
PowerMonthVo powerMonthVo = new PowerMonthVo(); powerMonthVo.setStrMonth(key);
powerMonthVo.setStrMonth(key); powerMonthVo.setPower(value);
powerMonthVo.setPower(value); powerMonthVos.add(powerMonthVo);
powerMonthVos.add(powerMonthVo); }));
});
});
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth));
// 总和所有相同月份的发电量 // 总和所有相同月份的发电量
String year = String.valueOf(LocalDate.now().getYear()); String year = String.valueOf(LocalDate.now().getYear());
@ -893,16 +886,16 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
subordinate.setWeather(weekWeather.get(station.getCode()).getDaily()); subordinate.setWeather(weekWeather.get(station.getCode()).getDaily());
// 区域/站点 设备实时数据 // 区域/站点 设备实时数据
List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList()); if (deviceReals != null) {
if (CollectionUtil.isNotEmpty(reals)) { List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList());
subordinate.setStationCount(Long.valueOf(entry.getValue().size())); subordinate.setStationCount((long) entry.getValue().size());
subordinate.setStationUseCount(reals.stream().filter(device -> HomePageConstant.OFF.equals(device.getState())).map(PhotovoltaicRealVo::getDeptId).distinct().count()); subordinate.setStationUseCount(reals.stream().filter(device -> device.getState() == 1).map(PhotovoltaicRealVo::getDeptId).distinct().count());
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
} }
// 区域/站点 设备指标数据 // 区域/站点 设备指标数据
List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList()); if (deviceTargets != null) {
if (CollectionUtil.isNotEmpty(targets)) { List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList());
subordinate.setGeneration(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum()); subordinate.setGeneration(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum());
} }
list.add(subordinate); list.add(subordinate);
@ -915,7 +908,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
Double sumLoad = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getCapacity).sum(); Double sumLoad = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getCapacity).sum();
Double sumStationCount = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getStationCount).sum(); Double sumStationCount = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getStationCount).sum();
// 计算 :集团发电占比 电站利用率 容量利用率 // 计算 :集团发电占比 电站利用率 容量利用率
return list.stream().map(subordinate -> { return list.stream().peek(subordinate -> {
if (Math.abs(sumGeneration) <= 0) { if (Math.abs(sumGeneration) <= 0) {
subordinate.setGenerationRate(0.0); subordinate.setGenerationRate(0.0);
} else { } else {
@ -931,7 +924,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} else { } else {
subordinate.setStationUse(BigDecimal.valueOf(subordinate.getStationUseCount() / sumStationCount * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); subordinate.setStationUse(BigDecimal.valueOf(subordinate.getStationUseCount() / sumStationCount * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
} }
return subordinate;
}).sorted(Comparator.comparing(PhotovoltaicSubordinateVo::getCapacity)).collect(Collectors.toList()); }).sorted(Comparator.comparing(PhotovoltaicSubordinateVo::getCapacity)).collect(Collectors.toList());
} }
@ -1024,7 +1016,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
subordinate.setNow(nowWeather.get(station.getCode()).getNow()); subordinate.setNow(nowWeather.get(station.getCode()).getNow());
} }
// 容量、实时功率、今日发电量 // 容量、实时功率、今日发电量
this.subordinateTargetData(subordinate, entry.getValue().stream().collect(Collectors.toList()), deviceReals, deviceTargets); this.subordinateTargetData(subordinate, new ArrayList<>(entry.getValue()), deviceReals, deviceTargets);
// 当月任务执行情况 // 当月任务执行情况
this.subordinateTaskMon(subordinate, Collections.singletonList(entry.getKey().getId())); this.subordinateTaskMon(subordinate, Collections.singletonList(entry.getKey().getId()));
subordinates.add(subordinate); subordinates.add(subordinate);
@ -1171,9 +1163,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
List<PhotovoltaicRealVo> mateReals = reals.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList()); List<PhotovoltaicRealVo> mateReals = reals.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList());
List<PhotovoltaicTargetVo> mateTargets = targets.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList()); List<PhotovoltaicTargetVo> mateTargets = targets.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(mateReals) && CollectionUtil.isEmpty(mateTargets)) {
return;
}
// 实时数据 : 实时功率、总发电量 // 实时数据 : 实时功率、总发电量
if (CollectionUtil.isNotEmpty(mateReals)) { if (CollectionUtil.isNotEmpty(mateReals)) {
// 设备状态统计 // 设备状态统计
@ -1240,48 +1229,38 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
* @return * @return
*/ */
private List<PhotovoltaicLoadGenerateVo> periodLoadDay(List<Long> stations) { private List<PhotovoltaicLoadGenerateVo> periodLoadDay(List<Long> stations) {
// FIXME 测试数据 // redis实时数据
List<String> hours = getDayHours(); List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
Random random = new Random(); if(CollectionUtil.isEmpty(photovoltaics)){
return hours.stream().map(hour -> { return new ArrayList<>();
}
// 过滤有效光伏设备
List<PhotovoltaicTargetVo> devices = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATE);
// 开始日期
Calendar calendar = Calendar.getInstance();
String end = sdf.format(calendar.getTime());
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String start = sdf.format(calendar.getTime());
List<AnalyseDataTaosVO> list = new ArrayList<>();
for(PhotovoltaicTargetVo device : devices){
list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PV_LOAD));
}
if(CollectionUtil.isEmpty(list)){
return new ArrayList<>();
}
return list.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)).entrySet().stream().map(entry ->{
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo();
target.setPeriod(hour); LocalDateTime time = LocalDateTime.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME));
target.setValue((float) (random.nextDouble() * 500)); target.setPeriod(String.valueOf(time.getHour()));
target.setValue((float) entry.getValue().stream().mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum());
return target; return target;
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); }).collect(Collectors.toList());
/*// redis实时数据
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if(CollectionUtil.isEmpty(photovoltaics)){
return new ArrayList();
}
// 过滤有效光伏设备
List<PhotovoltaicTargetVo> devices = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATE);
// 开始日期
Calendar calendar = Calendar.getInstance();
String start = sdf.format(calendar.getTime());
calendar.add(Calendar.HOUR_OF_DAY, -calendar.get(Calendar.HOUR_OF_DAY));
calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE));
calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND));
String end = sdf.format(calendar.getTime());
List<AnalyseDataTaosVO> list = new ArrayList<>();
for(PhotovoltaicTargetVo device : devices){
list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PHOTOVOLTAIC_LOAD));
};
if(CollectionUtil.isEmpty(list)){
return new ArrayList<>();
}
return list.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)).entrySet().stream().map(entry ->{
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo();
LocalDateTime time = LocalDateTime.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME));
target.setPeriod(String.valueOf(time.getHour()));
target.setValue((float) entry.getValue().stream().mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum());
return target;
}).collect(Collectors.toList());*/
} }
/** /**
@ -1295,7 +1274,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
// redis实时数据 // redis实时数据
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if (CollectionUtil.isEmpty(photovoltaics)) { if (CollectionUtil.isEmpty(photovoltaics)) {
return new ArrayList(); return new ArrayList<>();
} }
// 过滤有效光伏设备 // 过滤有效光伏设备
List<PhotovoltaicTargetVo> filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); List<PhotovoltaicTargetVo> filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList());
@ -1359,14 +1338,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
} }
// 根据月份分组 // 根据月份分组
List<PowerMonthVo> powerMonthVos = new ArrayList<>(); List<PowerMonthVo> powerMonthVos = new ArrayList<>();
filter.forEach(item -> { filter.forEach(item -> item.forEach((key, value) -> {
item.forEach((key, value) -> { PowerMonthVo powerMonthVo = new PowerMonthVo();
PowerMonthVo powerMonthVo = new PowerMonthVo(); powerMonthVo.setStrMonth(key);
powerMonthVo.setStrMonth(key); powerMonthVo.setPower(value);
powerMonthVo.setPower(value); powerMonthVos.add(powerMonthVo);
powerMonthVos.add(powerMonthVo); }));
});
});
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth));
// 总和所有相同月份的发电量 // 总和所有相同月份的发电量
String year = String.valueOf(LocalDate.now().getYear()); String year = String.valueOf(LocalDate.now().getYear());
@ -1488,7 +1465,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
devices.stream().map(PhotovoltaicDeviceVo::getActivePowerVoList).flatMap(Collection::stream).collect(Collectors.groupingBy(PhotovoltaicPowerVo::getHour)).entrySet().stream().map(entry -> { devices.stream().map(PhotovoltaicDeviceVo::getActivePowerVoList).flatMap(Collection::stream).collect(Collectors.groupingBy(PhotovoltaicPowerVo::getHour)).entrySet().stream().map(entry -> {
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); PhotovoltaicPowerVo load = new PhotovoltaicPowerVo();
load.setHour(entry.getKey()); load.setHour(entry.getKey());
load.setActivePower(String.valueOf(entry.getValue().stream().mapToDouble(o -> Double.valueOf(o.getActivePower())).sum())); load.setActivePower(String.valueOf(entry.getValue().stream().mapToDouble(o -> Double.parseDouble(o.getActivePower())).sum()));
return load; return load;
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList()) }).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList())
); );

Loading…
Cancel
Save