From 2f86825edef657dd7d6c11b6ef2ed67555ef324b Mon Sep 17 00:00:00 2001 From: yang_shj Date: Fri, 24 Mar 2023 15:04:23 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=85=89=E4=BC=8F=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/main/constant/MainConstants.java | 6 + .../hzims/operational/main/vo/GenerationVo.java | 22 +++ .../operational/main/vo/PhotovoltaicKPIsVo.java | 14 ++ .../operational/main/vo/PhotovoltaicRealVo.java | 63 ++++++++ .../hzims/operational/main/vo/SubordinateVo.java | 63 ++++++++ .../main/controller/PhotovoltaicController.java | 15 ++ .../main/scheduled/ScheduledCreateTask.java | 30 ++++ .../main/service/PhotovoltaicService.java | 15 ++ .../main/service/impl/PhotovoltaicServiceImpl.java | 163 ++++++++++++++++++++- 9 files changed, 389 insertions(+), 2 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicRealVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/SubordinateVo.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java index 83eda1e..e6033b2 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java +++ b/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 LOAD_PHOTOVOLTAIC_TARGET = "loadPhotovoltaicTarget"; + + // 光伏站-机组指标数据 + String LOAD_PHOTOVOLTAIC_REAL = "loadPhotovoltaicReal"; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationVo.java new file mode 100644 index 0000000..cb1f13f --- /dev/null +++ b/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; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicKPIsVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicKPIsVo.java index 128489f..9d35c87 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicKPIsVo.java +++ b/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 lombok.Data; +import java.util.List; + /** * @author ysj * @date 2023/03/23 16:54:36 @@ -26,9 +28,21 @@ public class PhotovoltaicKPIsVo { @ApiModelProperty(value = "年发电量:单位-kWh") 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") private Double powerMon; @ApiModelProperty(value = "日发电量:单位-kWh") private Double powerDay; + + @ApiModelProperty(value = "近年发电量集合") + private List powerYearVoList; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicRealVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicRealVo.java new file mode 100644 index 0000000..eaec0cf --- /dev/null +++ b/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; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/SubordinateVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/SubordinateVo.java new file mode 100644 index 0000000..a09ac26 --- /dev/null +++ b/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 weather; + + @ApiModelProperty(value = "排序") + private Integer sort; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java index 0b6cb91..45b6948 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/PhotovoltaicController.java +++ b/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)); } + @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)); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java index 33a2184..4a19c4d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/scheduled/ScheduledCreateTask.java @@ -44,6 +44,8 @@ public class ScheduledCreateTask { @Autowired private IWebHomeService webHomeService; @Autowired + private PhotovoltaicService photovoltaicService; + @Autowired BladeLogger logger; private final static Integer SERVE_TYPE = 2; @@ -286,4 +288,32 @@ public class ScheduledCreateTask { webHomeService.loadHydropowerTarget(param); return new ReturnT<>("SUCCESS"); } + + /** + * 光伏站-逆变器指标加载 + * @return ReturnT + */ + @XxlJob(LOAD_PHOTOVOLTAIC_TARGET) + //@Scheduled(cron = "0/10 * * * * ? ") + public ReturnT 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 + */ + @XxlJob(LOAD_PHOTOVOLTAIC_REAL) + //@Scheduled(cron = "0/10 * * * * ? ") + public ReturnT loadPhotovoltaicReal(String param) throws Exception { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + photovoltaicService.loadPhotovoltaicReal(param); + return new ReturnT<>("SUCCESS"); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java index 197c359..b0ca8a3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/PhotovoltaicService.java +++ b/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; +import com.hnac.hzims.operational.main.vo.GenerationVo; import com.hnac.hzims.operational.main.vo.PhotovoltaicKPIsVo; +import com.hnac.hzims.operational.main.vo.SubordinateVo; + +import java.util.List; /** * @author ysj @@ -9,7 +13,18 @@ import com.hnac.hzims.operational.main.vo.PhotovoltaicKPIsVo; */ public interface PhotovoltaicService { + // 光伏站指标数据加载 + void loadPhotovoltaicTarget(String param); + + // 光伏站实时数据加载 + void loadPhotovoltaicReal(String param); // 集团/区域关键指标 PhotovoltaicKPIsVo KPIs(Long deptId); + + // 集团/区域发电量 + List generation(Long deptId,Long type); + + // 集团/区域下属数据占比 + List subordinate(Long deptId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java index 63bb0bd..e37b492 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java +++ b/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; +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.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 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 java.util.*; +import java.util.stream.Collectors; + /** * @author ysj @@ -15,6 +34,108 @@ import org.springframework.stereotype.Service; @RequiredArgsConstructor 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 devices = this.getPhotovoltaicDevice(); + if(CollectionUtil.isEmpty(devices)){ + return; + } + // 取redis实时数据 + Map map = this.getRealData(); + List 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 getRealData() { + String json = (String) redisTemplate.opsForValue().get(real_id_key); + if(StringUtil.isBlank(json)){ + return null; + } + return JSONObject.parseObject(json, new TypeReference>() {}); + } + + /** + * 获取光伏设备 + * @return + */ + private List getPhotovoltaicDevice() { + // 光伏站点 + List stations = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC),null); + if(CollectionUtil.isEmpty(stations)){ + return null; + } + // 设备 + List 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 @@ -22,9 +143,47 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { */ @Override public PhotovoltaicKPIsVo KPIs(Long deptId) { + // 查询光伏站点 + List stations = stationService.getHomeStationList(deptId,Collections.singletonList(HomePageConstant.PHOTOVOLTAIC),HomePageConstant.HYDROPOWER_SERVETYPE); + if(CollectionUtil.isEmpty(stations)){ + return null; + } + // redis实时数据 + List photovoltaics = (List) redisTemplate.opsForValue().get(load_photovoltaic_real_key); + if(CollectionUtil.isEmpty(photovoltaics)){ + return new PhotovoltaicKPIsVo(); + } + // 过滤无效设备实时数据 + List 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()); + // 容量 + kpi.setInstalledCapacity(devices.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); + return kpi; + } + /** + * 集团/区域发电量 + * @param deptId + * @param type + * @return + */ + @Override + public List generation(Long deptId, Long type) { + return null; + } - return kpi; + /** + * 集团/区域下属数据占比 + * @param deptId + * @return + */ + @Override + public List subordinate(Long deptId) { + return null; } }