Browse Source

#光伏站点首页

zhongwei
yang_shj 2 years ago
parent
commit
6d51cca7c7
  1. 28
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java
  2. 35
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicRealVo.java
  3. 19
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationVo.java
  4. 40
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicTargetVo.java
  5. 322
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

28
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java

@ -35,10 +35,34 @@ public class PhotovoltaicDeviceVo {
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "环比功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double loadRatio;
@ApiModelProperty(value = "发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate;
@ApiModelProperty(value = "日发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateDay;
@ApiModelProperty(value = "环比功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateDayRatio;
@ApiModelProperty(value = "月发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateMon;
@ApiModelProperty(value = "年发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateYear;
@ApiModelProperty(value = "电压: V")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double voltage;
@ApiModelProperty(value = "电流: A")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double current;
@ -51,6 +75,10 @@ public class PhotovoltaicDeviceVo {
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double tec;
@ApiModelProperty(value = "收益: 元")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double income;
@ApiModelProperty(value = "当日机组有功功率")
private List<PhotovoltaicPowerVo> activePowerVoList;

35
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicRealVo.java

@ -33,23 +33,7 @@ public class PhotovoltaicRealVo {
@ApiModelProperty(value = "总发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generation;
@ApiModelProperty(value = "年发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationYear;
@ApiModelProperty(value = "月发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationMon;
@ApiModelProperty(value = "日发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationDay;
@ApiModelProperty(value = "日发电量环比(相比昨日)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationChain;
private Double generate;
@ApiModelProperty(value = "电压: V")
@JsonSerialize(nullsUsing = NullSerializer.class)
@ -59,23 +43,12 @@ public class PhotovoltaicRealVo {
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double current;
@ApiModelProperty(value = "节约标准煤:1kwh = 0.0001229吨煤")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double tec;
@ApiModelProperty(value = "二氧化碳减排:1kwh = 0.000997吨二氧化碳排放")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double co2;
@ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double deforest;
@ApiModelProperty(value = "功率: kW")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "收益:1kwh = 0.3 ~ 0.425人名币")
@ApiModelProperty(value = "上次功率: kW")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double income;
private Double lastLoad;
}

19
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationVo.java

@ -1,14 +1,17 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
* @author ysj
@ -28,6 +31,14 @@ public class PhotovoltaicStationVo {
@ApiModelProperty(value = "站点编码")
private String stationCode;
@ApiModelProperty(value = "地址")
private String address;
@ApiModelProperty(value = "投运时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime operationTime;
@ApiModelProperty(value = "总装机容量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@ -58,6 +69,12 @@ public class PhotovoltaicStationVo {
@ApiModelProperty(value = "站点实时温度")
private String temp;
@ApiModelProperty(value = "站点收益")
private Double income;
@ApiModelProperty(value = "逆变器数量")
private Integer inverterCount;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;

40
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicTargetVo.java

@ -1,5 +1,7 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -22,14 +24,40 @@ public class PhotovoltaicTargetVo {
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "当年发电量")
private Float powerYear;
@ApiModelProperty(value = "当日运行时长")
private Double runHours;
@ApiModelProperty(value = "当月发电量")
private Float powerMon;
@ApiModelProperty(value = "年发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationYear;
@ApiModelProperty(value = "当日发电量")
private Float powerDay;
@ApiModelProperty(value = "月发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationMon;
@ApiModelProperty(value = "节约标准煤:1kwh = 0.0001229吨煤")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double tec;
@ApiModelProperty(value = "二氧化碳减排:1kwh = 0.000997吨二氧化碳排放")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double co2;
@ApiModelProperty(value = "收益:1kwh = 0.3 ~ 0.425人名币")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double income;
@ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double deforest;
@ApiModelProperty(value = "日发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationDay;
@ApiModelProperty(value = "昨日发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationYesterday;
@ApiModelProperty(value = "当日机组有功功率")
private List<PhotovoltaicPowerVo> activePowerVoList;

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

@ -13,6 +13,11 @@ import com.hnac.hzims.operational.main.service.*;
import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.exception.ServiceException;
@ -57,7 +62,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
private final IWeatherService weatherService;
private final IWaterService waterService;
private final IHistoryDataSearchClient historySearchClient;
private final ISysClient sysClient;
@ -95,28 +100,16 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
real.setState(random.nextInt(2)-1);
// 容量
real.setCapacity(device.getInstalledCapacity());
// 年发电量
real.setGenerationYear(random.nextDouble() * 25000 * 360);
// 月发电量
real.setGenerationMon(random.nextDouble() * 25000 * 30);
// 日发电量
real.setGenerationDay(random.nextDouble() * 25000 * 30);
// 日发电量环比(相比昨日)
real.setGenerationChain(random.nextDouble());
// 发电量
real.setGenerate(random.nextDouble() * 25000 * 300 * 2);
// 电压
real.setVoltage(random.nextDouble() * 300);
// 电流
real.setCurrent(random.nextDouble() * 300);
// 节约标准煤
real.setTec(real.getGenerationMon() * 0.0001229);
// 二氧化碳减排
real.setCo2(real.getGenerationMon() * 0.997);
// 减少森林砍伐
real.setDeforest(real.getGenerationMon() * 0.000553);
// 功率
real.setLoad(random.nextDouble() * 300);
// 收益
real.setIncome(random.nextDouble() * 0.34);
// 上次功率
real.setLastLoad(random.nextDouble() * 300);
list.add(real);
});
redisTemplate.opsForValue().set(load_photovoltaic_real_key,list);
@ -134,29 +127,42 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return;
}
List<PhotovoltaicTargetVo> list = new ArrayList<>();
Random random = new Random();
devices.forEach(device->{
PhotovoltaicTargetVo target = new PhotovoltaicTargetVo();
target.setDeptId(device.getCreateDept());
target.setDeviceCode(device.getEmCode());
target.setDeviceName(device.getName());
target.setDeptName(device.getName());
// 当年发电量
float powerYear = this.getGenerationPower(device,0);
target.setPowerYear(powerYear);
// 当月发电量
float powerMon = this.getGenerationPower(device,1);
target.setPowerMon(powerMon);
// 当日发电量
float powerDay = this.getGenerationPower(device,2);
// 当日运行时长
// target.setRunHours(this.runHours(device.getPoint().get(HomePageConstant.PV_JOINT_RELAY)));
// 当天有功功率
// List<ActivePowerVo> activePowerVoList = waterService.getActivePowerVoList(device);
// FIXME 测试模拟数据
// FIXME 测试数据
// 当天运行时长
target.setRunHours(new Random().nextDouble() * 24);
// 年发电量
target.setGenerationYear(random.nextDouble() * 25000 * 360);
// 月发电量
target.setGenerationMon(random.nextDouble() * 25000 * 30);
// 日发电量
target.setGenerationDay(random.nextDouble() * 25000);
// 收益
target.setIncome(target.getGenerationDay() * 0.34);
// 昨日发电量
target.setGenerationYesterday(random.nextDouble() * 25000);
// 节约标准煤
target.setTec(target.getGenerationMon() * 0.0001229);
// 二氧化碳减排
target.setCo2(target.getGenerationMon() * 0.000997);
// 减少森林砍伐
target.setDeforest(target.getGenerationMon() * 0.000553);
// FIXME 测试模拟数据30天功率
List<PhotovoltaicPowerVo> photovoltaicPowers = this.activePowerVoList(device);
target.setActivePowerVoList(photovoltaicPowers);
// 30天发电量
List<GenerationPowerVo> generationPowerVoList = this.getGenerationPowerList(device);
target.setGenerationPowerVoList(generationPowerVoList);
target.setPowerDay(powerDay);
list.add(target);
});
redisTemplate.opsForValue().set(load_photovoltaic_target_key,list);
@ -176,6 +182,106 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
/**
* 当天运行时长
* @param realId
* @return
*/
private Double runHours(String realId) {
Calendar calendar = Calendar.getInstance();
Date end = 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));
Date start = calendar.getTime();
OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(realId);
originalDataQuery.setBeginTime(start);
originalDataQuery.setEndTime(end);
originalDataQuery.setLimit(100000);
originalDataQuery.setPage(1);
// 查询时间范围开关机监测点历史数据
Result<HzPage<PointData>> R = historySearchClient.getOriginalDataByRealIds(originalDataQuery);
if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){
return 0.0;
}
// 过滤相邻开关机状态相同数据
List<PointData> result = this.filterData(R.getData().getRecords());
if(CollectionUtil.isEmpty(result)){
return 0.0;
}
// 开机运行时长
long time = this.runTime(result,start,end);
return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 过滤相邻开关机状态相同数据
* @param list
* @return
*/
private List<PointData> filterData(List<PointData> list) {
if(CollectionUtil.isEmpty(list)){
return null;
}
List<PointData> result = new ArrayList<>();
// 遍历数据
for(int i = 0; i< list.size() ; i++){
// 第一个数据保存下来
if(i == 0){
result.add(list.get(i));
continue;
}
// 遍历数据状态
String value = list.get(i).getValue();
if(StringUtil.isBlank(value)){
continue;
}
// 上一条数据状态
String up_value = list.get(i-1).getValue();
if(value.equals(up_value)){
continue;
}
result.add(list.get(i));
}
return result;
}
/**
* 获取运行时长
* @param result
* @return
*/
private long runTime(List<PointData> result,Date startDate,Date endDate) {
if(result.size() == 1){
// 一直开机
if(HomePageConstant.OFF.equals(result.get(0).getValue())){
return endDate.getTime() - startDate.getTime();
}
// 一直关机
return 0;
}
long time=0;
// 遍历累计开机时长
for(int i = 0; i< result.size() ; i++){
// 记录为开机状态 就计算到下次关机的时间差
if(HomePageConstant.ON.equals(result.get(i).getValue())){
continue;
}
Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME);
// 遍历至最后一条数据,累计至当前时间
if(i == result.size() - 1){
endTime = endDate;
}
else {
endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME);
}
time += endTime.getTime() - startTime.getTime();
}
return time;
}
/**
* 获取年日发电量
* @param device
* @param scope
@ -373,37 +479,43 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
if(CollectionUtil.isEmpty(stations)){
return new PhotovoltaicKPIsVo();
}
// redis实时数据
List<PhotovoltaicRealVo> photovoltaics = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
if(CollectionUtil.isEmpty(photovoltaics)){
return new PhotovoltaicKPIsVo();
}
// 过滤无效设备实时数据
List<PhotovoltaicRealVo> devices = photovoltaics.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(devices)){
return new PhotovoltaicKPIsVo();
}
PhotovoltaicKPIsVo kpi = new PhotovoltaicKPIsVo();
// 站点数量
kpi.setCount(stations.size());
// 实时数据
List<PhotovoltaicRealVo> deviceReals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
if(CollectionUtil.isNotEmpty(deviceReals)){
List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(reals)){
// 容量
kpi.setInstalledCapacity(devices.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
kpi.setInstalledCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
// 负荷
kpi.setLoad(devices.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
kpi.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
}
}
// 指标数据
List<PhotovoltaicTargetVo> deviceTargets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
if(CollectionUtil.isEmpty(deviceTargets)){
return kpi;
}
List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(targets)){
return kpi;
}
// 年发电量
kpi.setPowerYear(devices.stream().mapToDouble(PhotovoltaicRealVo::getGenerationYear).sum());
kpi.setPowerYear(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum());
// 月发电量
kpi.setPowerMon(devices.stream().mapToDouble(PhotovoltaicRealVo::getGenerationMon).sum());
kpi.setPowerMon(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationMon).sum());
// 日发电量
kpi.setPowerDay(devices.stream().mapToDouble(PhotovoltaicRealVo::getGenerationDay).sum());
kpi.setPowerDay(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum());
// 节约标准煤
kpi.setTec(devices.stream().mapToDouble(PhotovoltaicRealVo::getTec).sum());
kpi.setTec(targets.stream().mapToDouble(PhotovoltaicTargetVo::getTec).sum());
// CO2减排
kpi.setCo2(devices.stream().mapToDouble(PhotovoltaicRealVo::getCo2).sum());
kpi.setCo2(targets.stream().mapToDouble(PhotovoltaicTargetVo::getCo2).sum());
// 减少森林砍伐
kpi.setDeforest(devices.stream().mapToDouble(PhotovoltaicRealVo::getDeforest).sum());
kpi.setDeforest(targets.stream().mapToDouble(PhotovoltaicTargetVo::getDeforest).sum());
// 近3年发电量
kpi.setPowerYearVoList(this.getPowerList(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())));
kpi.setPowerYearVoList(this.getPowerList(stations.stream().map(StationEntity::getId).collect(Collectors.toList())));
return kpi;
}
@ -411,7 +523,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
* 获取近3年发电量
* @return
*/
private List<PowerYearVo> getPowerList(List<String> stations) {
private List<PowerYearVo> getPowerList(List<Long> stations) {
// 站点近年发电数据 key - stationCode value - 月份,发电量
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
if(MapUtils.isEmpty(map)){
@ -579,11 +691,10 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
if(MapUtils.isEmpty(map)){
return new ArrayList<>();
}
// redis实时数据
List<PhotovoltaicRealVo> photovoltaics = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
if(CollectionUtil.isEmpty(photovoltaics)){
return new ArrayList<>();
}
// 实时数据
List<PhotovoltaicRealVo> deviceReals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 指标数据
List<PhotovoltaicTargetVo> deviceTargets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
// 遍历数据
List<SubordinateVo> list = new ArrayList<>();
for (Map.Entry<Dept,List<StationEntity>> entry : map.entrySet()) {
@ -598,16 +709,20 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
StationEntity station = entry.getValue().get(0);
subordinate.setLttd(station.getLttd());
subordinate.setLgtd(station.getLgtd());
// 省市编码
String areaCode = station.getAreaCode();
subordinate.setAreaCode(areaCode);
if(StringUtil.isEmpty(areaCode)){
continue;
}
if(!StringUtil.isEmpty(areaCode)){
String[] arrCode = areaCode.split(",");
R<Region> R = sysClient.getRegion(arrCode[1]);
if (R.isSuccess() && ObjectUtil.isNotEmpty(R.getData())) {
subordinate.setAreaName(R.getData().getName());
}
}
// 站点类型
if(HomePageConstant.STATION.equals(entry.getKey().getDeptCategory())){
subordinate.setType(entry.getValue().get(0).getPhotovoltaicType());
}
// 获取实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode()));
if(MapUtils.isNotEmpty(nowWeather)){
@ -619,14 +734,18 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
subordinate.setTemp(nowWeather.get(station.getCode()).getNow().getTemp());
}
subordinate.setWeather(weekWeather.get(station.getCode()).getDaily());
// 区域/站点 设备集合
List<PhotovoltaicRealVo> devices = photovoltaics.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(devices)){
subordinate.setGeneration(devices.stream().mapToDouble(PhotovoltaicRealVo::getGenerationYear).sum());
// 区域/站点 设备实时数据
List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(reals)){
subordinate.setStationCount(Long.valueOf(entry.getValue().size()));
subordinate.setStationUseCount(devices.stream().filter(device -> HomePageConstant.OFF.equals(device.getState())).map(PhotovoltaicRealVo::getDeptId).distinct().count());
subordinate.setCapacity(devices.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
subordinate.setLoad(devices.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
subordinate.setStationUseCount(reals.stream().filter(device -> HomePageConstant.OFF.equals(device.getState())).map(PhotovoltaicRealVo::getDeptId).distinct().count());
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).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(CollectionUtil.isNotEmpty(targets)){
subordinate.setGeneration(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum());
}
list.add(subordinate);
}
@ -688,18 +807,24 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
photovoltaic.setDeptId(station.getRefDept());
photovoltaic.setDeptName(station.getName());
photovoltaic.setStationCode(station.getCode());
// 站点地址
photovoltaic.setAddress(station.getAddress());
// 站点投运时间
photovoltaic.setOperationTime(station.getCommissionTime());
// 站点实时天气
photovoltaic.setTemp(this.temp(weather,station.getCode()));
// 站点七天天气
photovoltaic.setWeather(this.week(weekWeather,station.getCode()));
// 逆变器数量
photovoltaic.setInverterCount(devices.size());
// 运行天数
photovoltaic.setRunDay(this.run_day(station));
// 实时数据: 装机容量、功率、总发电量、年发电量、月发电、日发电量
this.real_data(photovoltaic,devices,reals);
// 设备实时数据、指标数据: 容量、发电量、实时功率、电流、co2、节约标准煤、30日发电量、当日功率
photovoltaic.setDevices(this.deviceRealTarget(devices,reals,targets));
// 设备排行榜
photovoltaic.setCharts(this.deviceCharts(photovoltaic.getDevices()));
// 站点实时数据: 装机容量、总发电量、功率、收益
this.real_data(photovoltaic);
// 年发电量比较概括
photovoltaic.setGenerateSurvey(this.generateSurvey(station.getId()));
return photovoltaic;
@ -754,33 +879,28 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
}
/**
* 指标数据
* @param devices
* @param reals
* 站点实时数据统计
* @param photovoltaic
*/
private void real_data(PhotovoltaicStationVo photovoltaic, List<EminfoAndEmParamVo> devices, List<PhotovoltaicRealVo> reals) {
private void real_data(PhotovoltaicStationVo photovoltaic) {
// 站点设备检查
if(CollectionUtil.isEmpty(devices)){
return;
}
photovoltaic.setCapacity(devices.stream().mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
if(CollectionUtil.isEmpty(reals)){
}
// 设备指标数据匹配
List<PhotovoltaicRealVo> deviceReals = reals.stream().filter(o-> devices.stream().map(EminfoAndEmParamVo::getCreateDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(deviceReals)){
if(CollectionUtil.isEmpty(photovoltaic.getDevices())){
return;
}
// 日发电量
photovoltaic.setGenerateDay(deviceReals.stream().mapToDouble(PhotovoltaicRealVo::getGenerationDay).sum());
// 月发电量
photovoltaic.setGenerateMon(deviceReals.stream().mapToDouble(PhotovoltaicRealVo::getGenerationMon).sum());
// 年发电量
photovoltaic.setGenerateYear(deviceReals.stream().mapToDouble(PhotovoltaicRealVo::getGenerationYear).sum());
// 容量
photovoltaic.setCapacity(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getCapacity).sum());
// 总发电量
photovoltaic.setGenerate(deviceReals.stream().mapToDouble(PhotovoltaicRealVo::getGeneration).sum());
photovoltaic.setGenerate(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerate).sum());
// 收益
photovoltaic.setIncome(photovoltaic.getGenerate() * 0.34);
// 年发电量
photovoltaic.setGenerateYear(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateYear).sum());
// 月发电量
photovoltaic.setGenerateMon(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateMon).sum());
// 日发电量
photovoltaic.setGenerateDay(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getGenerateDay).sum());
// 功率
photovoltaic.setLoad(deviceReals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
photovoltaic.setLoad(photovoltaic.getDevices().stream().mapToDouble(PhotovoltaicDeviceVo::getLoad).sum());
}
/**
@ -798,25 +918,43 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
PhotovoltaicDeviceVo item = new PhotovoltaicDeviceVo();
item.setDeviceCode(device.getEmCode());
item.setDeviceName(device.getName());
item.setDeptId(item.getDeptId());
item.setDeptId(device.getCreateDept());
// 装机容量
item.setCapacity(device.getInstalledCapacity());
// 实时数据
List<PhotovoltaicRealVo> mateReals = reals.stream().filter(o->o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(mateReals)){
// 发电量、实时功率、电流、co2减排、节约标准煤
item.setGenerate(mateReals.get(0).getGenerationDay());
// 总发电量、实时功率、电压、电流、环比功率
item.setGenerate(mateReals.get(0).getGenerate());
item.setLoad(mateReals.get(0).getLoad());
item.setVoltage(mateReals.get(0).getVoltage());
item.setCurrent(mateReals.get(0).getCurrent());
item.setCo2(mateReals.get(0).getCo2());
item.setTec(mateReals.get(0).getTec());
// 环比功率
if(Math.abs(mateReals.get(0).getLoad()) <= 0 || mateReals.get(0).getLastLoad() <= 0 ){
item.setLoadRatio(0.0);
}else{
item.setLoadRatio(BigDecimal.valueOf((mateReals.get(0).getLoad() - mateReals.get(0).getLastLoad()) / mateReals.get(0).getLastLoad() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
}
// 指标数据
List<PhotovoltaicTargetVo> mateTargets = targets.stream().filter(o->o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(mateReals)){
// 30天发电量、当日功率
if(CollectionUtil.isNotEmpty(mateTargets)){
// 年发电量、月发电量、日发电量、co2减排、节约标准煤、收益、30天发电量、当日功率、环比日发电量
item.setGenerateYear(mateTargets.get(0).getGenerationYear());
item.setGenerateMon(mateTargets.get(0).getGenerationMon());
item.setGenerateDay(mateTargets.get(0).getGenerationDay());
item.setCo2(mateTargets.get(0).getCo2());
item.setTec(mateTargets.get(0).getTec());
item.setIncome(mateTargets.get(0).getIncome());
item.setActivePowerVoList(mateTargets.get(0).getActivePowerVoList());
item.setGenerationPowerVoList(mateTargets.get(0).getGenerationPowerVoList());
// 环比发电量
if(Math.abs(mateTargets.get(0).getGenerationDay()) <= 0 || mateTargets.get(0).getGenerationYesterday() <= 0 ){
item.setGenerateDayRatio(0.0);
}else{
item.setGenerateDayRatio(BigDecimal.valueOf((mateTargets.get(0).getGenerationDay() - mateTargets.get(0).getGenerationYesterday()) / mateTargets.get(0).getGenerationYesterday() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
}
return item;
}).collect(Collectors.toList());

Loading…
Cancel
Save