Browse Source

#光伏首页

zhongwei
yang_shj 2 years ago
parent
commit
2f86825ede
  1. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java
  2. 22
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java
  3. 14
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicKPIsVo.java
  4. 63
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicRealVo.java
  5. 63
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/SubordinateVo.java
  6. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java
  7. 30
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java
  8. 15
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java
  9. 163
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java

@ -70,4 +70,10 @@ public interface MainConstants {
// 通讯中断数据处理 // 通讯中断数据处理
String ALARM_DATA_HANDLE = "alarmDataHandle"; String ALARM_DATA_HANDLE = "alarmDataHandle";
// 光伏站-机组指标数据
String LOAD_PHOTOVOLTAIC_TARGET = "loadPhotovoltaicTarget";
// 光伏站-机组指标数据
String LOAD_PHOTOVOLTAIC_REAL = "loadPhotovoltaicReal";
} }

22
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java

@ -0,0 +1,22 @@
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/24 09:58:57
* @version 4.0.0
*/
@Data
@ApiModel(value = "发电量数据")
public class GenerationVo {
@ApiModelProperty(value = "周期")
private String period;
@ApiModelProperty(value = "月发电量")
private Float power;
}

14
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicKPIsVo.java

@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author ysj * @author ysj
* @date 2023/03/23 16:54:36 * @date 2023/03/23 16:54:36
@ -26,9 +28,21 @@ public class PhotovoltaicKPIsVo {
@ApiModelProperty(value = "年发电量:单位-kWh") @ApiModelProperty(value = "年发电量:单位-kWh")
private Double powerYear; private Double powerYear;
@ApiModelProperty(value = "二氧化碳减排:1kwh = 0.997kg二氧化碳排放")
private Double co2;
@ApiModelProperty(value = "节约标准煤:1kwh = 0.0001229吨煤")
private Double tec;
@ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553")
private Double deforest;
@ApiModelProperty(value = "月发电量:单位-kWh") @ApiModelProperty(value = "月发电量:单位-kWh")
private Double powerMon; private Double powerMon;
@ApiModelProperty(value = "日发电量:单位-kWh") @ApiModelProperty(value = "日发电量:单位-kWh")
private Double powerDay; private Double powerDay;
@ApiModelProperty(value = "近年发电量集合")
private List<PowerYearVo> powerYearVoList;
} }

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

@ -0,0 +1,63 @@
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/24 10:55:02
* @version 4.0.0
*/
@Data
@ApiModel(value = "光伏实时数据")
public class PhotovoltaicRealVo {
@ApiModelProperty(value = "机构Id")
private Long deptId;
@ApiModelProperty(value = "设备Code")
private String deviceCode;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "状态: 0-运行")
private Integer state;
@ApiModelProperty(value = "容量: kW")
private Double capacity;
@ApiModelProperty(value = "年发电量: kWh")
private Double generationYear;
@ApiModelProperty(value = "月发电量: kWh")
private Double generationMon;
@ApiModelProperty(value = "日发电量: kWh")
private Double generationDay;
@ApiModelProperty(value = "日发电量环比(相比昨日)")
private Double generationChain;
@ApiModelProperty(value = "电压: V")
private Double voltage;
@ApiModelProperty(value = "电流: A")
private Double current;
@ApiModelProperty(value = "节约标准煤:1kwh = 0.0001229吨煤")
private Double tec;
@ApiModelProperty(value = "二氧化碳减排:1kwh = 0.997kg二氧化碳排放")
private Double co2;
@ApiModelProperty(value = "减少森林砍伐:1kwh = 0.000553")
private Double deforest;
@ApiModelProperty(value = "功率: kW")
private Double power;
@ApiModelProperty(value = "收益:1kwh = 0.3 ~ 0.425人名币")
private Double income;
}

63
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/SubordinateVo.java

@ -0,0 +1,63 @@
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;
/**
* @author ysj
* @date 2023/03/24 09:58:57
* @version 4.0.0
*/
@Data
@ApiModel(value = "发电量数据")
public class SubordinateVo {
@ApiModelProperty(value = "机构ID")
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "地市编码")
private String code;
@ApiModelProperty("经度(东经)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lgtd;
@ApiModelProperty("纬度(北纬)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lttd;
@ApiModelProperty(value = "发电占比")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double areaMakeUp;
@ApiModelProperty(value = "发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generation;
@ApiModelProperty(value = "电站利用率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double stationUse;
@ApiModelProperty(value = "容量利用率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double capacityUse;
@ApiModelProperty(value = "站点实时温度")
private String temp;
@ApiModelProperty(value = "七日内天气")
private List<Daily> weather;
@ApiModelProperty(value = "排序")
private Integer sort;
}

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

@ -32,4 +32,19 @@ public class PhotovoltaicController extends BladeController {
return R.data(service.KPIs(deptId)); return R.data(service.KPIs(deptId));
} }
@ApiOperation("集团/区域发电量")
@GetMapping("/generation")
@ApiOperationSupport(order = 1)
public R generation(@ApiParam(value = "集团/区域机构编号") Long deptId,
@ApiParam(value = "查询类型:0-周 1-月 -2年") Long type) {
return R.data(service.generation(deptId,type));
}
@ApiOperation("集团/区域下属数据占比")
@GetMapping("/subordinate")
@ApiOperationSupport(order = 1)
public R subordinate(@ApiParam(value = "集团/区域机构编号") Long deptId) {
return R.data(service.subordinate(deptId));
}
} }

30
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java

@ -44,6 +44,8 @@ public class ScheduledCreateTask {
@Autowired @Autowired
private IWebHomeService webHomeService; private IWebHomeService webHomeService;
@Autowired @Autowired
private PhotovoltaicService photovoltaicService;
@Autowired
BladeLogger logger; BladeLogger logger;
private final static Integer SERVE_TYPE = 2; private final static Integer SERVE_TYPE = 2;
@ -286,4 +288,32 @@ public class ScheduledCreateTask {
webHomeService.loadHydropowerTarget(param); webHomeService.loadHydropowerTarget(param);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
/**
* 光伏站-逆变器指标加载
* @return ReturnT<String>
*/
@XxlJob(LOAD_PHOTOVOLTAIC_TARGET)
//@Scheduled(cron = "0/10 * * * * ? ")
public ReturnT<String> loadPhotovoltaicTarget(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
photovoltaicService.loadPhotovoltaicTarget(param);
return new ReturnT<>("SUCCESS");
}
/**
* 光伏站-逆变器实时加载
* @return ReturnT<String>
*/
@XxlJob(LOAD_PHOTOVOLTAIC_REAL)
//@Scheduled(cron = "0/10 * * * * ? ")
public ReturnT<String> loadPhotovoltaicReal(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
}
photovoltaicService.loadPhotovoltaicReal(param);
return new ReturnT<>("SUCCESS");
}
} }

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

@ -1,6 +1,10 @@
package com.hnac.hzims.operational.main.service; 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.PhotovoltaicKPIsVo;
import com.hnac.hzims.operational.main.vo.SubordinateVo;
import java.util.List;
/** /**
* @author ysj * @author ysj
@ -9,7 +13,18 @@ import com.hnac.hzims.operational.main.vo.PhotovoltaicKPIsVo;
*/ */
public interface PhotovoltaicService { public interface PhotovoltaicService {
// 光伏站指标数据加载
void loadPhotovoltaicTarget(String param);
// 光伏站实时数据加载
void loadPhotovoltaicReal(String param);
// 集团/区域关键指标 // 集团/区域关键指标
PhotovoltaicKPIsVo KPIs(Long deptId); PhotovoltaicKPIsVo KPIs(Long deptId);
// 集团/区域发电量
List<GenerationVo> generation(Long deptId,Long type);
// 集团/区域下属数据占比
List<SubordinateVo> subordinate(Long deptId);
} }

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

@ -1,10 +1,29 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.operational.main.service.IHomePageService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.main.service.ISideHustleService;
import com.hnac.hzims.operational.main.service.PhotovoltaicService; import com.hnac.hzims.operational.main.service.PhotovoltaicService;
import com.hnac.hzims.operational.main.vo.PhotovoltaicKPIsVo; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.maintenance.constants.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import io.swagger.annotations.ApiModelProperty;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* @author ysj * @author ysj
@ -15,6 +34,108 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor @RequiredArgsConstructor
public class PhotovoltaicServiceImpl implements PhotovoltaicService { public class PhotovoltaicServiceImpl implements PhotovoltaicService {
private final IStationService stationService;
private final IMainSystemMonitoringService deviceService;
private final RedisTemplate redisTemplate;
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key";
@Value("${hzims.operation.realIdKey}")
public String real_id_key;
/**
* 光伏站-逆变器指标加载
* @param param
*/
@Override
public void loadPhotovoltaicTarget(String param) {
// 查询设备
List<EminfoAndEmParamVo> devices = this.getPhotovoltaicDevice();
if(CollectionUtil.isEmpty(devices)){
return;
}
// 取redis实时数据
Map<String, String> map = this.getRealData();
List<PhotovoltaicRealVo> list = new ArrayList<>();
Random random = new Random();
devices.forEach(device->{
PhotovoltaicRealVo real = new PhotovoltaicRealVo();
real.setDeptId(device.getCreateDept());
real.setDeviceCode(device.getEmCode());
real.setDeviceName(device.getName());
// 容量
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.setVoltage(random.nextDouble() * 300);
// 电流
real.setCurrent(random.nextDouble() * 300);
// 节约标准煤 tec
real.setTec(real.getGenerationMon() * 0.0001229);
// 二氧化碳减排 co2
real.setCo2(real.getGenerationMon() * 0.997);
// 减少森林砍伐 deforest
real.setDeforest(real.getGenerationMon() * 0.000553);
// 功率 power
real.setPower(random.nextDouble() * 300);
// 收益 income
real.setIncome(random.nextDouble() * 0.34);
list.add(real);
});
redisTemplate.opsForValue().set(load_photovoltaic_real_key,list);
}
/**
* 获取实时数据
* @return
*/
private Map<String, String> getRealData() {
String json = (String) redisTemplate.opsForValue().get(real_id_key);
if(StringUtil.isBlank(json)){
return null;
}
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {});
}
/**
* 获取光伏设备
* @return
*/
private List<EminfoAndEmParamVo> getPhotovoltaicDevice() {
// 光伏站点
List<StationEntity> stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC),null);
if(CollectionUtil.isEmpty(stations)){
return null;
}
// 设备
List<EminfoAndEmParamVo> devices = deviceService.getEmInfoList();
if(CollectionUtil.isEmpty(devices)){
return null;
}
return devices.stream().filter(device ->
stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getCreateDept())
).collect(Collectors.toList());
}
/**
* 光伏站-逆变器实时加载
* @param param
*/
@Override
public void loadPhotovoltaicReal(String param) {
}
/** /**
* 集团/区域关键指标 * 集团/区域关键指标
* @param deptId * @param deptId
@ -22,9 +143,47 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
*/ */
@Override @Override
public PhotovoltaicKPIsVo KPIs(Long deptId) { public PhotovoltaicKPIsVo KPIs(Long deptId) {
// 查询光伏站点
List<StationEntity> stations = stationService.getHomeStationList(deptId,Collections.singletonList(HomePageConstant.PHOTOVOLTAIC),HomePageConstant.HYDROPOWER_SERVETYPE);
if(CollectionUtil.isEmpty(stations)){
return null;
}
// 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(); PhotovoltaicKPIsVo kpi = new PhotovoltaicKPIsVo();
// 站点数量
kpi.setCount(stations.size());
// 容量
kpi.setInstalledCapacity(devices.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum());
return kpi;
}
/**
* 集团/区域发电量
* @param deptId
* @param type
* @return
*/
@Override
public List<GenerationVo> generation(Long deptId, Long type) {
return null;
}
return kpi; /**
* 集团/区域下属数据占比
* @param deptId
* @return
*/
@Override
public List<SubordinateVo> subordinate(Long deptId) {
return null;
} }
} }

Loading…
Cancel
Save