Browse Source

#光伏首页

zhongwei
yang_shj 2 years ago
parent
commit
d72e850ce4
  1. 29
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceChartsVo.java
  2. 59
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java
  3. 21
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicGenerateYearVo.java
  4. 20
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicRealVo.java
  5. 72
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicStationVo.java
  6. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java
  7. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java
  8. 224
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

29
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceChartsVo.java

@ -0,0 +1,29 @@
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;
@Data
@ApiModel(value = "光伏设备排行对象")
public class PhotovoltaicDeviceChartsVo {
@ApiModelProperty(value = "机构Id")
private Long deptId;
@ApiModelProperty(value = "设备Code")
private String deviceCode;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "实时功率: kW")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate;
}

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

@ -0,0 +1,59 @@
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;
import java.util.List;
/**
* @author ysj
* @date 2023/03/29 15:14:34
* @version 4.0.0
*/
@Data
@ApiModel(value = "光伏设备数据对象")
public class PhotovoltaicDeviceVo {
@ApiModelProperty(value = "机构Id")
private Long deptId;
@ApiModelProperty(value = "设备Code")
private String deviceCode;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "容量: kW")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@ApiModelProperty(value = "实时功率: kW")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "发电量: kWh")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate;
@ApiModelProperty(value = "电流: A")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double current;
@ApiModelProperty(value = "co2减排: kg")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double co2;
@ApiModelProperty(value = "节约标准煤减排: kt")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double tec;
@ApiModelProperty(value = "当日机组有功功率")
private List<PhotovoltaicPowerVo> activePowerVoList;
@ApiModelProperty(value = "近30天用电量")
private List<GenerationPowerVo> generationPowerVoList;
}

21
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicGenerateYearVo.java

@ -0,0 +1,21 @@
package com.hnac.hzims.operational.main.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
* @date 2023/03/29 15:26:07
* @version 4.0.0
*/
@Data
@ApiModel(value = "月发电对象")
public class PhotovoltaicGenerateYearVo {
@ApiModelProperty(value = "月份")
private String mon;
@ApiModelProperty(value = "发电量")
private Float generate;
}

20
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicRealVo.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;
@ -26,38 +28,54 @@ public class PhotovoltaicRealVo {
private Integer state;
@ApiModelProperty(value = "容量: kW")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@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;
@ApiModelProperty(value = "电压: V")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double voltage;
@ApiModelProperty(value = "电流: A")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double current;
@ApiModelProperty(value = "节约标准煤:1kwh = 0.0001229吨煤")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double tec;
@ApiModelProperty(value = "二氧化碳减排:1kwh = 0.997kg二氧化碳排放")
@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人名币")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double income;
}

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

@ -0,0 +1,72 @@
package com.hnac.hzims.operational.main.vo;
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 java.util.List;
import java.util.Map;
/**
* @author ysj
* @date 2023/03/29 15:14:34
* @version 4.0.0
*/
@Data
@ApiModel(value = "水利站点首页对象")
public class PhotovoltaicStationVo {
@ApiModelProperty(value = "机构Id")
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "站点编码")
private String stationCode;
@ApiModelProperty(value = "总装机容量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacity;
@ApiModelProperty(value = "安全运行天数")
private Integer runDay;
@ApiModelProperty(value = "总发电负荷")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double load;
@ApiModelProperty(value = "日发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateDay;
@ApiModelProperty(value = "月发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateMon;
@ApiModelProperty(value = "年发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generateYear;
@ApiModelProperty(value = "总发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generate;
@ApiModelProperty(value = "站点实时温度")
private String temp;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "发电排行")
private List<PhotovoltaicDeviceVo> devices;
@ApiModelProperty(value = "年发电量完成百分比")
private List<PowerYearVo> generateSurvey;
@ApiModelProperty(value = "设备信息")
private List<PhotovoltaicDeviceChartsVo> charts;
}

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java

@ -47,4 +47,10 @@ public class PhotovoltaicController extends BladeController {
return R.data(service.subordinate(deptId));
}
@ApiOperation("光伏站点数据")
@GetMapping("/station")
@ApiOperationSupport(order = 4)
public R station(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.station(deptId));
}
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java

@ -2,6 +2,7 @@ package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.operational.main.vo.GenerationVo;
import com.hnac.hzims.operational.main.vo.PhotovoltaicKPIsVo;
import com.hnac.hzims.operational.main.vo.PhotovoltaicStationVo;
import com.hnac.hzims.operational.main.vo.SubordinateVo;
import java.util.List;
@ -27,4 +28,7 @@ public interface PhotovoltaicService {
// 集团/区域下属数据占比
List<SubordinateVo> subordinate(Long deptId);
// 站点数据
PhotovoltaicStationVo station(Long deptId);
}

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

@ -2,8 +2,10 @@ package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
@ -28,7 +30,9 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@ -653,4 +657,224 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
return subordinate;
}).sorted(Comparator.comparing(SubordinateVo::getCapacity)).collect(Collectors.toList());
}
/**
* 站点数据
* @param deptId
* @return
*/
@Override
public PhotovoltaicStationVo station(Long deptId) {
// 参数检查
if(ObjectUtil.isEmpty(deptId)){
return new PhotovoltaicStationVo();
}
// 查询站点
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getRefDept,deptId));
if(ObjectUtil.isEmpty(station)){
return new PhotovoltaicStationVo();
}
// 实时监测点数据
List<PhotovoltaicRealVo> reals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key);
// 获取站点机组指标数据
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key);
// 站点设备
List<EminfoAndEmParamVo> devices = deviceService.getEmInfoList().stream().filter(o-> o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList());
// 实时天气
Map<String, HeWeatherWeatherNowResponse> weather = weatherService.getNowWeather(Collections.singletonList(station.getCode()));
// 七天天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = weatherService.getWeekWeather(Collections.singletonList(station.getCode()));
PhotovoltaicStationVo photovoltaic = new PhotovoltaicStationVo();
photovoltaic.setDeptId(station.getRefDept());
photovoltaic.setDeptName(station.getName());
photovoltaic.setStationCode(station.getCode());
// 站点实时天气
photovoltaic.setTemp(this.temp(weather,station.getCode()));
// 站点七天天气
photovoltaic.setWeather(this.week(weekWeather,station.getCode()));
// 运行天数
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()));
// 年发电量比较概括
photovoltaic.setGenerateSurvey(this.generateSurvey(station.getId()));
return photovoltaic;
}
/**
* 获取实时温度
* @param weather
* @param code
* @return
*/
private String temp(Map<String, HeWeatherWeatherNowResponse> weather, String code) {
if(MapUtils.isEmpty(weather)){
return "21";
}
HeWeatherWeatherNowResponse now = weather.get(code);
if(ObjectUtil.isEmpty(now) || ObjectUtil.isEmpty(now.getNow())){
return "21";
}
return now.getNow().getTemp();
}
/**
* 获取七天天气
* @param weekWeather
* @param code
* @return
*/
private List<Daily> week(Map<String, HeWeatherWeatherDailyResponse> weekWeather, String code) {
if(MapUtils.isEmpty(weekWeather)){
return null;
}
HeWeatherWeatherDailyResponse week = weekWeather.get(code);
if(ObjectUtil.isEmpty(week)){
return null;
}
return week.getDaily();
}
/**
* 获取站点运行天数
* @param station
* @return
*/
private int run_day(StationEntity station) {
if (ObjectUtil.isEmpty(station.getCommissionTime())) {
return 0;
}
// 计算投运时间与当前时间相隔天数
Duration dur = Duration.between(station.getCommissionTime(), LocalDateTime.now());
return (int) dur.toDays();
}
/**
* 指标数据
* @param devices
* @param reals
*/
private void real_data(PhotovoltaicStationVo photovoltaic, List<EminfoAndEmParamVo> devices, List<PhotovoltaicRealVo> reals) {
// 站点设备检查
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)){
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.setGenerate(deviceReals.stream().mapToDouble(PhotovoltaicRealVo::getGeneration).sum());
// 功率
photovoltaic.setLoad(deviceReals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum());
}
/**
* 光伏设备实时指标数据
* @param devices
* @param reals
* @param targets
* @return
*/
private List<PhotovoltaicDeviceVo> deviceRealTarget(List<EminfoAndEmParamVo> devices, List<PhotovoltaicRealVo> reals, List<PhotovoltaicTargetVo> targets) {
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
return devices.stream().map(device->{
PhotovoltaicDeviceVo item = new PhotovoltaicDeviceVo();
item.setDeviceCode(device.getEmCode());
item.setDeviceName(device.getName());
item.setDeptId(item.getDeptId());
// 装机容量
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.setLoad(mateReals.get(0).getLoad());
item.setCurrent(mateReals.get(0).getCurrent());
item.setCo2(mateReals.get(0).getCo2());
item.setTec(mateReals.get(0).getTec());
}
// 指标数据
List<PhotovoltaicTargetVo> mateTargets = targets.stream().filter(o->o.getDeviceCode().equals(device.getEmCode())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(mateReals)){
// 30天发电量、当日功率
item.setActivePowerVoList(mateTargets.get(0).getActivePowerVoList());
item.setGenerationPowerVoList(mateTargets.get(0).getGenerationPowerVoList());
}
return item;
}).collect(Collectors.toList());
}
/**
* 设备排行榜
* @param devices
* @return
*/
private List<PhotovoltaicDeviceChartsVo> deviceCharts(List<PhotovoltaicDeviceVo> devices) {
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
return devices.stream().map(device->{
PhotovoltaicDeviceChartsVo chart = new PhotovoltaicDeviceChartsVo();
chart.setDeptId(device.getDeptId());
chart.setDeviceCode(device.getDeviceCode());
chart.setDeviceName(device.getDeviceName());
chart.setLoad(device.getLoad());
chart.setGenerate(device.getGenerate());
return chart;
}).sorted(Comparator.comparing(PhotovoltaicDeviceChartsVo::getGenerate)).collect(Collectors.toList());
}
/**
* 年发电量比较概括
* @return
*/
private List<PowerYearVo> generateSurvey(Long station) {
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
if(MapUtils.isEmpty(map)){
return new ArrayList<>();
}
// 站点发电数据
if(!map.containsKey(station)){
return new ArrayList<>();
}
// 转换成集合
List<PowerMonthVo> generates = new ArrayList<>();
map.get(station).forEach((key,value) -> {
PowerMonthVo generate = new PowerMonthVo();
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), key), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
generate.setYear(localDate.getYear());
generate.setMonth(localDate.getMonthValue());
generate.setStrMonth(key);
generate.setPower(value);
generates.add(generate);
});
// 根据年份分组
Map<Integer, List<PowerMonthVo>> year = generates.stream().collect(Collectors.groupingBy(PowerMonthVo::getYear));
// 返回结果集
return year.entrySet().stream().map(entry -> {
PowerYearVo powerYearVo = new PowerYearVo();
powerYearVo.setYear(entry.getKey());
List<PowerMonthVo> sortValue = entry.getValue().stream().sorted(Comparator.comparing(PowerMonthVo::getMonth)).collect(Collectors.toList());
powerYearVo.setPowerMonthVoList(sortValue);
return powerYearVo;
}).collect(Collectors.toList());
}
}

Loading…
Cancel
Save