From 6bf30636bd221dc3879c264f2902d03b7be820fa Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 2 Aug 2024 11:27:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?#=E6=B0=B4=E7=94=B5=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/operational/home/wind/RainMon.java | 25 -- .../vo/HydroelectricDeviceGenerateVo.java | 26 ++ .../vo/HydroelectricDevicePowerVo.java | 22 ++ .../Hydroelectric/vo/HydroelectricDeviceVo.java | 72 +++++ .../vo/HydroelectricGenerateMonVo.java | 28 ++ .../Hydroelectric/vo/HydroelectricPowerRainVo.java | 22 ++ .../Hydroelectric/vo/HydroelectricStationVo.java | 68 +++++ .../operational/homePage/wind/vo/RainMon.java | 25 ++ .../operational/main/vo/HydropowerStationVo.java | 4 +- .../hzims/operational/main/vo/pv/PowerRainVo.java | 26 -- .../operation/home/impl/RealTargetServiceImpl.java | 4 +- .../fill/service/impl/StorageServiceImpl.java | 5 +- .../fill/service/impl/UseServiceImpl.java | 6 +- .../controller/HydroelectricController.java | 35 +++ .../homePage/service/HydroelectricService.java | 12 + .../service/impl/HydroelectricServiceImpl.java | 315 +++++++++++++++++++++ .../main/service/impl/HydropowerServiceImpl.java | 7 +- .../main/service/impl/WaterServiceImpl.java | 2 +- 18 files changed, 641 insertions(+), 63 deletions(-) delete mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricPowerRainVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/wind/vo/RainMon.java delete mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/pv/PowerRainVo.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java deleted file mode 100644 index b1ab2c2..0000000 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/home/wind/RainMon.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.hnac.hzims.operational.home.wind; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @author ysj - */ -@Data -@ApiModel(value = "降雨月数据") -public class RainMon { - - @ApiModelProperty(value = "年份") - private Integer year; - - @ApiModelProperty(value = "月份") - private Integer month; - - @ApiModelProperty(value = "字符串格式月份") - private String strMon; - - @ApiModelProperty(value = "降雨量") - private Double rain; -} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java new file mode 100644 index 0000000..8e37237 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceGenerateVo.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.operational.homePage.Hydroelectric.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; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-设备近30天发电量") +public class HydroelectricDeviceGenerateVo { + + @ApiModelProperty(value = "日期") + private String date; + + @ApiModelProperty(value = "发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Float generate; + + @ApiModelProperty(value = "功率") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Float load; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java new file mode 100644 index 0000000..c16ea6c --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDevicePowerVo.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-设备近24小时功率曲线") +public class HydroelectricDevicePowerVo { + + @ApiModelProperty(value = "字符串时间") + private String strHour; + + @ApiModelProperty(value = "小时") + private Integer hour; + + @ApiModelProperty(value = "有功功率") + private String activePower; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceVo.java new file mode 100644 index 0000000..f3ce2b7 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricDeviceVo.java @@ -0,0 +1,72 @@ +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-设备信息") +public class HydroelectricDeviceVo { + + @ApiModelProperty(value = "设备编号") + private String deivceCode; + + @ApiModelProperty(value = "设备名称") + private String deivceName; + + @ApiModelProperty(value = "开关机状态: 0 - 关机 1 - 开机") + private Boolean state; + + @ApiModelProperty(value = "总装机容量") + private Double installedCapacity; + + @ApiModelProperty(value = "有功功率") + private Double activePower; + + @ApiModelProperty(value = "容量利用率") + private Double capacityRate; + + @ApiModelProperty(value = "无功功率") + private Double reactivePower; + + @ApiModelProperty(value = "导叶开度") + private Double guideOpen; + + @ApiModelProperty(value = "今日发电量") + private Float powerDay; + + @ApiModelProperty(value = "昨日发电量") + private Float powerYesterDay; + + @ApiModelProperty(value = "当年发电量") + private Float powerYear; + + @ApiModelProperty(value = "去年发电量") + private Float powerYesterYear; + + @ApiModelProperty(value = "当月发电量") + private Float powerMon; + + @ApiModelProperty(value = "本次开机时间") + private String startDownTime; + + @ApiModelProperty(value = "本次开机时长") + private Double startupDownDuration; + + @ApiModelProperty(value = "年停机时长") + private Double shutDownDurationYear; + + @ApiModelProperty(value = "年开机时长") + private Double startupDurationYear; + + @ApiModelProperty(value = "设备近24小时有功功率") + private List powers; + + @ApiModelProperty(value = "设备近30日发电量") + private List generates; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java new file mode 100644 index 0000000..12266ae --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricGenerateMonVo.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "月发电对象") +public class HydroelectricGenerateMonVo { + + @ApiModelProperty(value = "年份") + private Integer year; + + @ApiModelProperty(value = "月份") + private Integer month; + + @ApiModelProperty(value = "字符串格式月份") + private String strMonth; + + @ApiModelProperty(value = "月发电量") + private Double power; + + @ApiModelProperty(value = "计划发电量") + private Double planPower; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricPowerRainVo.java new file mode 100644 index 0000000..a2aae0e --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricPowerRainVo.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "站点首页-最近30日发电量/降雨量") +public class HydroelectricPowerRainVo { + + @ApiModelProperty(value = "日期") + private String date; + + @ApiModelProperty(value = "发电量") + private Double generate; + + @ApiModelProperty(value = "降雨") + private Double rain; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java new file mode 100644 index 0000000..41bd6ba --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/Hydroelectric/vo/HydroelectricStationVo.java @@ -0,0 +1,68 @@ +package com.hnac.hzims.operational.homePage.Hydroelectric.vo; + +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 + */ +@Data +@ApiModel(value = "水电站首页-站点") +public class HydroelectricStationVo { + + + @ApiModelProperty(value = "站点编号") + private String stationCode; + + @ApiModelProperty(value = "站点名称") + private String stationName; + + @ApiModelProperty(value = "总装机容量") + private Double installedCapacity; + + @ApiModelProperty(value = "总发电负荷") + private Double powerSum; + + @ApiModelProperty(value = "容量利用率") + private Double capacityRate; + + @ApiModelProperty(value = "月计划发电量") + private Double powerMonPlan; + + @ApiModelProperty(value = "月发电量") + private Double powerMon; + + @ApiModelProperty(value = "月发电量完成率") + private Double powerRateMon; + + @ApiModelProperty(value = "年计划发电量") + private Double powerYearPlan; + + @ApiModelProperty(value = "年发电量") + private Double powerYear; + + @ApiModelProperty(value = "年发电完成率") + private Double powerRateYear; + + @ApiModelProperty(value = "今日发电量") + private Double powerDay; + + @ApiModelProperty(value = "昨日发电量") + private Double powerYesterDay; + + @ApiModelProperty(value = "七日内天气") + private List weather; + + @ApiModelProperty(value = "设备集合") + private List devices; + + @ApiModelProperty(value = "降雨/发电量曲线") + private List powerRains; + + @ApiModelProperty(value = "降雨/发电量曲线") + private List generateMons; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/wind/vo/RainMon.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/wind/vo/RainMon.java new file mode 100644 index 0000000..5827eb3 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/wind/vo/RainMon.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.operational.homePage.wind.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "降雨月数据") +public class RainMon { + + @ApiModelProperty(value = "年份") + private Integer year; + + @ApiModelProperty(value = "月份") + private Integer month; + + @ApiModelProperty(value = "字符串格式月份") + private String strMon; + + @ApiModelProperty(value = "降雨量") + private Double rain; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java index a39e0cc..2bc64a1 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerStationVo.java @@ -1,7 +1,7 @@ package com.hnac.hzims.operational.main.vo; import com.hnac.hzims.hzimsweather.response.weather.Daily; -import com.hnac.hzims.operational.main.vo.pv.PowerRainVo; +import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricPowerRainVo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -80,7 +80,7 @@ public class HydropowerStationVo { private List weather; @ApiModelProperty(value = "降雨/发电量曲线") - private List powerRains; + private List powerRains; @ApiModelProperty(value = "前水位曲线数据") private Map frontCurveMap; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/pv/PowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/pv/PowerRainVo.java deleted file mode 100644 index 0020a96..0000000 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/pv/PowerRainVo.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.hnac.hzims.operational.main.vo.pv; - -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; - -/** - * @author ysj - */ -@Data -@ApiModel(value = "当日机组有功功率") -public class PowerRainVo { - - @ApiModelProperty(value = "日期") - private String date; - - @ApiModelProperty(value = "发电量") - @JsonSerialize(nullsUsing = NullSerializer.class) - private Double generate; - - @ApiModelProperty(value = "降雨") - @JsonSerialize(nullsUsing = NullSerializer.class) - private Double rain; -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index 746b25b..b6db260 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -13,7 +13,7 @@ import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient; import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; import com.hnac.hzims.operational.fill.entity.RainfallEntity; -import com.hnac.hzims.operational.home.wind.RainMon; +import com.hnac.hzims.operational.homePage.wind.vo.RainMon; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.station.StationConstants; @@ -1488,7 +1488,7 @@ public class RealTargetServiceImpl implements RealTargetService { String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); calendar.add(Calendar.DAY_OF_MONTH,-1); // 开始日期 - String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + String start = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH") + ":00:00"; List records = dataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); if (CollectionUtil.isEmpty(records)) { return new ArrayList<>(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/StorageServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/StorageServiceImpl.java index f7840c0..8acaa68 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/StorageServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/StorageServiceImpl.java @@ -69,11 +69,12 @@ public class StorageServiceImpl extends ServiceImpl(){{ eq(StorageEntity::getStationCode, entity.getStationCode()); eq(StorageEntity::getFillDate,entity.getFillDate()); + ne(ObjectUtil.isNotEmpty(entity.getId()),StorageEntity::getId,entity.getId()); }}); - if(ObjectUtil.isNotEmpty(history) && (ObjectUtil.isEmpty(entity.getId()) || !entity.getId().equals(history.getId()))){ + if(ObjectUtil.isNotEmpty(history)){ throw new ServiceException("日期已经存在填报数据!"); } - if(ObjectUtil.isEmpty(history)){ + if(ObjectUtil.isEmpty(history) && ObjectUtil.isEmpty(entity.getId())){ return this.save(entity); } return this.updateById(entity); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java index 334136a..227ec46 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.fill.entity.StorageEntity; import com.hnac.hzims.operational.fill.entity.UseEntity; import com.hnac.hzims.operational.fill.mapper.UseMapper; import com.hnac.hzims.operational.fill.service.UseService; @@ -97,11 +98,12 @@ public class UseServiceImpl extends ServiceImpl implements UseEntity history = this.getOne(new LambdaQueryWrapper(){{ eq(UseEntity::getStationCode, entity.getStationCode()); eq(UseEntity::getFillDate,entity.getFillDate()); + ne(ObjectUtil.isNotEmpty(entity.getId()), UseEntity::getId,entity.getId()); }}); - if(ObjectUtil.isNotEmpty(history) && (ObjectUtil.isEmpty(entity.getId()) || !entity.getId().equals(history.getId()))){ + if(ObjectUtil.isNotEmpty(history)){ throw new ServiceException("日期已经存在填报数据!"); } - if(ObjectUtil.isEmpty(history)){ + if(ObjectUtil.isEmpty(history) && ObjectUtil.isEmpty(entity.getId())){ return this.save(entity); } return this.updateById(entity); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java new file mode 100644 index 0000000..6bc6de6 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/controller/HydroelectricController.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.operational.homePage.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStationVo; +import com.hnac.hzims.operational.homePage.service.HydroelectricService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author ysj + */ +@RestController +@RequestMapping("/hydroelectric") +@Api(value = "水电站-首页", tags = "水电站-首页") +@AllArgsConstructor +public class HydroelectricController extends BladeController { + + + private final HydroelectricService hydroelectricService; + + @ApiOperation("水电站站点指标") + @GetMapping("/station") + @ApiOperationSupport(order = 1) + public R station(@RequestParam("deptId") Long deptId) { + return R.data(hydroelectricService.station(deptId)); + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java new file mode 100644 index 0000000..14bef09 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/HydroelectricService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.operational.homePage.service; + +import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricStationVo; + +/** + * 水电站-首页接口 + * @author ysj + */ +public interface HydroelectricService { + + HydroelectricStationVo station(Long deptId); +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java new file mode 100644 index 0000000..01b533d --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java @@ -0,0 +1,315 @@ +package com.hnac.hzims.operational.homePage.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.equipment.feign.IPlanGenertionClient; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.equipment.vo.PlanPowerYearVo; +import com.hnac.hzims.hzimsweather.feign.IRainfallClient; +import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; +import com.hnac.hzims.operational.homePage.Hydroelectric.vo.*; +import com.hnac.hzims.operational.homePage.service.HydroelectricService; +import com.hnac.hzims.operational.main.service.IWeatherService; +import com.hnac.hzims.operational.main.vo.HydropowerUnitRealVo; +import com.hnac.hzims.operational.main.vo.HydropowerUnitTargetVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 水电站-首页接口实现类 + * @author ysj + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class HydroelectricServiceImpl implements HydroelectricService { + + + private final IStationService stationService; + + private final IWeatherService weatherService; + + private final IRainfallClient rainClient; + + private final IPlanGenertionClient planClient; + + private final RedisTemplate redisTemplate; + + private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; + private final static String LOAD_HYDROPOWER_REAL_KEY = "hzims:operation:loadhydropowerunit:real:key"; + private final static String LOAD_HYDROPOWER_TARGET_KEY = "hzims:operation:loadhydropowerunit:target:key"; + private final static String DEVICE_CACHE_COFIG_FINAL = "hzims:equipment:emInfo:deviceCode.emInfoList"; + + /** + * 水电站首页-站点首页 + * @param deptId + * @return + */ + @Override + public HydroelectricStationVo station(Long deptId) { + // 步骤1.查询站点 + StationEntity station = stationService.getOne(Wrappers.lambdaQuery().eq(StationEntity::getRefDept,deptId)); + if(ObjectUtil.isEmpty(station)){ + return new HydroelectricStationVo(); + } + // 步骤2.数据准备 + // 设备 + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(DEVICE_CACHE_COFIG_FINAL).toString(),new TypeReference>() {}); + // 实时数据 + List reals = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_REAL_KEY); + // 指标数据 + List targets = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_TARGET_KEY); + // 降雨数据 + List> rains = this.nearThirtyRains(station.getCode()); + // 七日天气 + Map weathers = this.weekWeather(Collections.singletonList(station.getCode())); + // 近3年发电量 + Map> map = (Map>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); + // 计划发电量 + List plans = planClient.getPlanPowerByYear(station.getCode(), Integer.parseInt(DateUtil.format(new Date(),"yyyy"))); + + // 步骤3.数据处理、赋值 + HydroelectricStationVo result = new HydroelectricStationVo(); + result.setStationCode(station.getCode()); + result.setStationName(station.getName()); + // 天气 + if(MapUtils.isNotEmpty(weathers) && weathers.containsKey(station.getCode())){ + HeWeatherWeatherDailyResponse week = weathers.get(station.getCode()); + if(ObjectUtil.isNotEmpty(week) && CollectionUtil.isNotEmpty(week.getDaily())){ + result.setWeather(week.getDaily()); + } + } + // 设备 + if(CollectionUtil.isNotEmpty(devices)){ + result.setDevices(devices.stream().map(iter->{ + HydroelectricDeviceVo device = new HydroelectricDeviceVo(); + Optional real = reals.stream().filter(o-> iter.getEmCode().equals(o.getDeviceCode())).findFirst(); + // 实时数据 + if(real.isPresent()){ + device.setState(real.get().getState()); + device.setInstalledCapacity(real.get().getInstalledCapacity()); + device.setActivePower(real.get().getActivePower()); + device.setReactivePower(real.get().getReactivePower()); + device.setGuideOpen(real.get().getGuideOpen()); + if(device.getActivePower() > 0 && device.getReactivePower() > 0){ + device.setCapacityRate(BigDecimal.valueOf(device.getActivePower() / device.getInstalledCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + }else{ + device.setCapacityRate(0.0); + } + } + // 指标数据 + Optional target = targets.stream().filter(o-> iter.getEmCode().equals(o.getDeviceCode())).findFirst(); + if(target.isPresent()){ + device.setPowerDay(target.get().getPowerDay()); + device.setPowerYesterDay(target.get().getPowerYesterDay()); + device.setPowerYear(target.get().getPowerYear()); + device.setPowerYesterYear(target.get().getPowerYesterYear()); + device.setPowerMon(target.get().getPowerMon()); + device.setStartDownTime(target.get().getStartDownTime()); + device.setStartupDownDuration(target.get().getStartupDownDuration()); + device.setStartupDurationYear(target.get().getStartupDurationYear()); + device.setShutDownDurationYear(target.get().getShutDownDurationYear()); + if(CollectionUtil.isNotEmpty(target.get().getActivePowerVoList())){ + device.setPowers(target.get().getActivePowerVoList().stream().map(o-> BeanUtil.copy(o, HydroelectricDevicePowerVo.class)).collect(Collectors.toList())); + } + if(CollectionUtil.isNotEmpty(target.get().getActivePowerVoList())){ + device.setGenerates(target.get().getGenerationPowerVoList().stream().map(o-> BeanUtil.copy(o, HydroelectricDeviceGenerateVo.class)).collect(Collectors.toList())); + } + } + return device; + }).collect(Collectors.toList())); + } + // 站点指标数据 + if(CollectionUtil.isNotEmpty(result.getDevices())){ + // 装机容量、发电负荷 + result.setInstalledCapacity(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getInstalledCapacity).sum()); + result.setPowerSum(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getActivePower).sum()); + if(result.getInstalledCapacity() > 0 && result.getPowerSum() > 0 ){ + result.setCapacityRate(BigDecimal.valueOf(result.getPowerSum() / result.getInstalledCapacity() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); + }else{ + result.setCapacityRate(0.0); + } + // 月计划发电量、月已发电量 + if(CollectionUtil.isNotEmpty(plans)){ + result.setPowerMonPlan(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(new Date(),"yyyy-NM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum()); + }else{ + result.setPowerMonPlan(0.0); + } + result.setPowerMon(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerMon).sum()); + + // 年计划发电量、年已发电量 + if(CollectionUtil.isNotEmpty(plans)){ + result.setPowerYearPlan(plans.stream().mapToDouble(PlanPowerYearVo::getPlanPower).sum()); + }else{ + result.setPowerYearPlan(0.0); + } + result.setPowerYear(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYear).sum()); + + // 今日发电量、昨日发电量 + result.setPowerDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerDay).sum()); + result.setPowerYesterDay(result.getDevices().stream().mapToDouble(HydroelectricDeviceVo::getPowerYesterDay).sum()); + + // 近30日降雨量/发电量 + result.setPowerRains(this.stationPowerRains(result.getDevices(),rains)); + // 电站月发电/计划发电 + result.setGenerateMons(this.stationGenerateMons(plans,map.get(station.getCode()))); + } + return result; + } + + /** + * 站点近30天降雨数据 + * @param station + * @return + */ + private List> nearThirtyRains(String station) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH,-1); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + calendar.add(Calendar.DAY_OF_MONTH,-29); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + R>> rains = rainClient.getDurationRainFall(station,start,end); + if(!rains.isSuccess() || CollectionUtil.isEmpty(rains.getData())){ + return new ArrayList<>(); + } + return rains.getData(); + } + + + /** + * 站点七天天气 + * @param stations + */ + private Map weekWeather(List stations) { + if(CollectionUtil.isEmpty(stations)){ + return new HashMap<>(); + } + // 实时天气 + return weatherService.getWeekWeather(stations); + } + + /** + * 站点近30天降雨量/发电量 + * @param devices + * @return + */ + private List stationPowerRains(List devices,List> rains) { + List generates = new ArrayList<>(); + devices.forEach(device->{ + generates.addAll(device.getGenerates()); + }); + 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)); + calendar.add(Calendar.DAY_OF_MONTH,-29); + Date start = calendar.getTime(); + List powerRains = new ArrayList<>(); + while (start.compareTo(end) < 0) { + HydroelectricPowerRainVo powerRain = new HydroelectricPowerRainVo(); + // 日期 + powerRain.setDate(DateUtil.format(calendar.getTime(),"yyyy-MM-dd")); + // 发电量 + powerRain.setGenerate(generates.stream().filter(o-> powerRain.getDate().equals(o.getDate())).mapToDouble(HydroelectricDeviceGenerateVo::getGenerate).sum()); + // 降雨量 + if(CollectionUtil.isNotEmpty(rains)){ + powerRain.setRain(rains.stream().mapToDouble(map->{ + if (map.get("fx_date").equals(powerRain.getDate())) { + Object object = map.get("precip"); + if(ObjectUtil.isEmpty(object)){ + return 0.0; + }else{ + return Double.parseDouble(object.toString()); + } + } + return 0.0; + }).sum()); + }else{ + powerRain.setRain(0.0); + } + powerRains.add(powerRain); + calendar.add(Calendar.DAY_OF_MONTH,1); + start = calendar.getTime(); + } + return powerRains; + } + + /** + * 站点电站月发电/计划发电 + * @param plans + * @param map + * @return + */ + private List stationGenerateMons(List plans, Map map) { + // 获取月份集合 + List mons = this.mons(0,12,false); + return mons.stream().map(mon->{ + Date date = DateUtil.parse(mon,DateUtil.PATTERN_DATE); + HydroelectricGenerateMonVo generateMon = new HydroelectricGenerateMonVo(); + generateMon.setStrMonth(mon); + generateMon.setYear(date.getYear()); + generateMon.setMonth(date.getMonth() + 1); + // 计划发电量 + if(CollectionUtil.isNotEmpty(plans)){ + generateMon.setPlanPower(plans.stream().filter(plan -> plan.getMon().contains(DateUtil.format(date,"yyyy-MM"))).mapToDouble(PlanPowerYearVo::getPlanPower).sum()); + }else{ + generateMon.setPlanPower(0.0); + } + // 实际发电 + if(MapUtils.isNotEmpty(map)){ + generateMon.setPower(map.entrySet().stream().filter(entry->entry.getKey().equals(mon)).mapToDouble(Map.Entry::getValue).sum()); + }else{ + generateMon.setPlanPower(0.0); + } + return generateMon; + }).collect(Collectors.toList()); + } + + /** + * 获取近年月份集合 + * @param year + * @return + */ + public List mons(int year, int endMoth, boolean nextMon) { + List list = new ArrayList<>(); + // 开始日期 + Calendar endCal = Calendar.getInstance(); + endCal.setTime(new Date()); + endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth); + endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1); + + // 结束日期 + Calendar startCal = Calendar.getInstance(); + startCal.setTime(new Date()); + startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year); + startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH)); + startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1); + // 获取日期之间的月份 + while (endCal.after(startCal)) { + list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE)); + startCal.add(Calendar.MONTH, 1); + } + if(nextMon){ + list.add(DateUtil.format(endCal.getTime(),DateUtil.PATTERN_DATE)); + } + return list; + } + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index f40aac0..9a826da 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -18,11 +18,11 @@ import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo; +import com.hnac.hzims.operational.homePage.Hydroelectric.vo.HydroelectricPowerRainVo; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.entity.UserDeptEntity; import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.vo.*; -import com.hnac.hzims.operational.main.vo.pv.PowerRainVo; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.station.entity.StationEntity; @@ -193,7 +193,7 @@ public class HydropowerServiceImpl implements HydropowerService { * @param rains * @return */ - private List getPowerRains(StationEntity station,List devices, List> rains) { + private List getPowerRains(StationEntity station,List devices, List> rains) { List powers = new ArrayList<>(); if(CollectionUtil.isNotEmpty(devices)){ devices.forEach(device->{ @@ -205,7 +205,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 根据日期遍历 List days = this.get30Day(); return days.stream().map(day->{ - PowerRainVo powerRain = new PowerRainVo(); + HydroelectricPowerRainVo powerRain = new HydroelectricPowerRainVo(); powerRain.setDate(day); if(CollectionUtil.isEmpty(powers)){ powerRain.setGenerate(0.0); @@ -383,6 +383,7 @@ public class HydropowerServiceImpl implements HydropowerService { private List get30Day() { List times = new ArrayList<>(); Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH,-1); Date end = calendar.getTime(); calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java index c9671f6..ceee58f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java @@ -4,7 +4,7 @@ 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.home.wind.RainMon; +import com.hnac.hzims.operational.homePage.wind.vo.RainMon; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.AreaService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; From 850fed5d6a05fcb59f42f1f389316b303cea23a9 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 2 Aug 2024 11:49:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?#=E6=B0=B4=E7=94=B5=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hnac/hzims/scheduled/ScheduledApplication.java | 4 ---- .../hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java | 7 +++---- .../hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java | 7 +++---- .../homePage/service/impl/HydroelectricServiceImpl.java | 1 + 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java index c8a2b83..a14fbe8 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java @@ -24,8 +24,4 @@ public class ScheduledApplication { BladeApplication.run("hzims-scheduled", ScheduledApplication.class, args); } -// @Override -// protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { -// return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled", ScheduledApplication.class); -// } } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java index 29b4042..ba4dab2 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java @@ -75,10 +75,9 @@ public class GenerationScheduledTask { * @param param * @return */ - //@XxlJob(LOAD_THREE_YEAR_POWER_GENERATION) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadThreeYearPowerGeneration() { - String param = ""; + @XxlJob(LOAD_THREE_YEAR_POWER_GENERATION) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadThreeYearPowerGeneration(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java index e082119..9591c87 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java @@ -59,10 +59,9 @@ public class RealTargetScheduledTask { /** * 水电站-机组指标加载 */ - //@XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadHydropowerTarget() { - String param = ""; + @XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadHydropowerTarget(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java index 01b533d..ed6e432 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java @@ -215,6 +215,7 @@ public class HydroelectricServiceImpl implements HydroelectricService { generates.addAll(device.getGenerates()); }); Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH,-1); Date end = calendar.getTime(); calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE));