From 806785f8e541ec18c8670565c708eb24ce5ada4c Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 18 Apr 2023 13:33:59 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=B0=B4=E7=94=B5=E7=AB=99=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equipment/feign/IPlanGenertionClient.java | 2 +- .../equipment/feign/IPlanGenertionClientBack.java | 2 +- .../hzims/operational/alert/vo/AlarmMergeVo.java | 2 +- .../duty/vo/ImsDutyGroupGenerationVo.java | 2 +- .../hnac/hzims/operational/fill/vo/QueryVo.java | 5 +- .../main/constant/HomePageConstant.java | 1 + .../hzims/operational/main/vo/ActivePowerVo.java | 5 +- .../hzims/operational/main/vo/AreaScaleVo.java | 16 +- .../operational/main/vo/HydropowerScoreVo.java | 47 +- .../operational/main/vo/HydropowerStationVo.java | 4 +- .../operational/main/vo/HydropowerUnitRealVo.java | 24 +- .../main/vo/HydropowerUnitTargetVo.java | 5 +- .../operational/main/vo/HydropowerUnitVo.java | 3 + .../hzims/operational/main/vo/OldAreaScaleVo.java | 50 ++ .../operational/main/vo/OldHydropowerScoreVo.java | 57 +++ .../operational/main/vo/OldStationCountVo.java | 18 + .../hzims/operational/main/vo/PowerMonthVo.java | 4 +- .../hzims/operational/main/vo/StationCountVo.java | 10 +- .../hnac/hzims/operational/main/vo/TargetVo.java | 43 ++ .../hzims/equipment/feign/PlanGenertionClient.java | 2 +- .../equipment/mapper/PlanGenerationMapper.java | 2 +- .../equipment/mapper/PlanGenerationMapper.xml | 4 +- .../equipment/service/IPlanGenerationService.java | 2 +- .../service/impl/PlanGenerationServiceImpl.java | 10 +- .../hzims/operational/OperationApplication.java | 9 - .../alert/controller/LevelAlarmController.java | 3 - .../alert/service/HistoryAbnormalAlarmService.java | 1 + .../alert/service/impl/AlertMerageServiceImpl.java | 4 +- .../duty/service/impl/ImsDutyMainServiceImpl.java | 3 +- .../fill/service/impl/GenerateServiceImpl.java | 7 +- .../fill/service/impl/RainFallServiceImpl.java | 7 +- .../fill/service/impl/StorageServiceImpl.java | 7 +- .../fill/service/impl/UseServiceImpl.java | 7 +- .../main/controller/HomeController.java | 47 ++ .../main/controller/HomePageController.java | 8 +- .../main/controller/HydropowerController.java | 28 +- .../main/controller/SideHustleController.java | 2 +- .../main/scheduled/ScheduledCreateTask.java | 31 +- .../operational/main/service/AreaService.java | 3 + .../operational/main/service/HomeService.java | 17 + .../main/service/HydropowerService.java | 10 +- .../operational/main/service/IHomePageService.java | 6 +- .../main/service/ISideHustleService.java | 2 +- .../main/service/impl/AppHomeServiceImpl.java | 26 +- .../service/impl/AreaMonthReportServiceImpl.java | 20 +- .../main/service/impl/AreaServiceImpl.java | 43 ++ .../main/service/impl/HomePageServiceImpl.java | 27 +- .../main/service/impl/HomeServiceImpl.java | 516 +++++++++++++++++++++ .../main/service/impl/HydropowerServiceImpl.java | 475 +++++++++++++++++-- .../main/service/impl/PhotovoltaicServiceImpl.java | 6 +- .../main/service/impl/PlatformServiceImpl.java | 10 +- .../service/impl/RunMonthReportServiceImpl.java | 7 +- .../main/service/impl/SideHustleServiceImpl.java | 10 +- .../main/service/impl/WaterServiceImpl.java | 109 ++--- .../station/controller/ImsDeptController.java | 1 - .../station/service/IImsDeptService.java | 2 +- .../station/service/impl/ImsDeptServiceImpl.java | 33 +- 57 files changed, 1491 insertions(+), 316 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldAreaScaleVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldHydropowerScoreVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldStationCountVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HomeService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IPlanGenertionClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IPlanGenertionClient.java index 609057c..f8e77cc 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IPlanGenertionClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IPlanGenertionClient.java @@ -84,7 +84,7 @@ public interface IPlanGenertionClient { * @return */ @GetMapping(GET_POWER_YEAR) - String getPlanPowerYear(@RequestParam(value = "stationIds", required = false) List stationIds, @RequestParam(value = "date", required = false) String date); + Double getPlanPowerYear(@RequestParam(value = "stationIds", required = false) List stationIds, @RequestParam(value = "date", required = false) String date); /** * 计划发电量查询 diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IPlanGenertionClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IPlanGenertionClientBack.java index b746217..102c36b 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IPlanGenertionClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IPlanGenertionClientBack.java @@ -47,7 +47,7 @@ public class IPlanGenertionClientBack implements IPlanGenertionClient { } @Override - public String getPlanPowerYear(List stationIds, String date) { + public Double getPlanPowerYear(List stationIds, String date) { return null; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java index 6371158..74a49b0 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/AlarmMergeVo.java @@ -26,7 +26,7 @@ public class AlarmMergeVo{ private String realId; @ApiModelProperty("告警编号") - private Long alarmCode; + private String alarmCode; @ApiModelProperty("告警类型") private String type; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyGroupGenerationVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyGroupGenerationVo.java index d72cd43..081d53e 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyGroupGenerationVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyGroupGenerationVo.java @@ -10,7 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.sql.Time; @Data -public class ImsDutyGroupGenerationVo extends ImsDutyMainEntity { +public class ImsDutyGroupGenerationVo extends ImsDutyMainEntity { @ApiModelProperty(value = "班组名称") private String groupName; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/vo/QueryVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/vo/QueryVo.java index 01c68fc..3f7d66b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/vo/QueryVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/vo/QueryVo.java @@ -17,10 +17,7 @@ public class QueryVo{ private String stationCode; @ApiModelProperty("开始时间") - private Date startTime; - - @ApiModelProperty("结束时间") - private Date endTime; + private String date; @ApiModelProperty("设备编号") private String deviceCode; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java index 4d95083..2b4339b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java @@ -85,6 +85,7 @@ public interface HomePageConstant { */ Integer HYDROPOWER_SERVETYPE = 2; + /** * 站点类型 : 云服务 */ diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/ActivePowerVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/ActivePowerVo.java index 9b827ae..9de2b1b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/ActivePowerVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/ActivePowerVo.java @@ -5,8 +5,9 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.List; - +/** + * @author ysj + */ @Data @ApiModel(value = "当日机组有功功率") public class ActivePowerVo { diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AreaScaleVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AreaScaleVo.java index 322b051..415903a 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AreaScaleVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/AreaScaleVo.java @@ -1,6 +1,5 @@ package com.hnac.hzims.operational.main.vo; -import com.hnac.hzims.hzimsweather.entity.DailyHeWeatherEntity; import com.hnac.hzims.hzimsweather.response.weather.Daily; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,6 +8,7 @@ import java.util.List; /** * 集团/区域占比 + * @author ysj */ @Data public class AreaScaleVo { @@ -25,26 +25,20 @@ public class AreaScaleVo { @ApiModelProperty(value = "站点实时温度") private String temp; - @ApiModelProperty(value = "年计划发电量") - private float planPowerYear; - @ApiModelProperty(value = "年发电量") private float powerYear; @ApiModelProperty(value = "发电完成率") - private double generationPercentageComplete; - - @ApiModelProperty(value = "区域/集团发电占比") - private double areaMakeUp; + private double generationRate; @ApiModelProperty(value = "电站利用率") - private double stationUse; + private double deviceUse; @ApiModelProperty(value = "容量利用率") private double capacityUse; - @ApiModelProperty(value = "发电量统计") - private double generationCount; + @ApiModelProperty(value = "区域/集团发电占比") + private double areaMakeUp; @ApiModelProperty(value = "排序") private Integer sort; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerScoreVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerScoreVo.java index 4de3c91..ba197d9 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerScoreVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerScoreVo.java @@ -1,11 +1,16 @@ 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 + */ @Data @ApiModel(value = "水电站分计对象") public class HydropowerScoreVo { @@ -19,39 +24,41 @@ public class HydropowerScoreVo { @ApiModelProperty(value = "站点数量") private Integer stationCount; - @ApiModelProperty(value = "月总装机容量") - private Double installedCapacityMonth; + @ApiModelProperty(value = "总装机容量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double installedCapacity; + + @ApiModelProperty(value = "容量利用率") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double capacityRate; @ApiModelProperty(value = "总有功功率") - private Double activePowerMoth; + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double load; @ApiModelProperty(value = "年总发电量") - private String powerYear; + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateYear; @ApiModelProperty(value = "月总发电量") - private String powerMonth; + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateMon; @ApiModelProperty(value = "日总发电量") - private String powerDay; + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double generateDay; @ApiModelProperty(value = "年计划发电量") - private String planPowerYear; - - @ApiModelProperty(value = "年完成发电量") - private String finishPowerYear; + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double plan; @ApiModelProperty(value = "年计划完成率") - private String planCompletionRateYear; - - @ApiModelProperty(value = "年总装机容量") - private Double installedCapacityYear; - - @ApiModelProperty(value = "年总有功功率") - private Double activePowerYear; - - @ApiModelProperty(value = "容量利用率") - private String rateYear; + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double planRate; @ApiModelProperty(value = "近年发电量集合") private List powerYearVoList; + + @ApiModelProperty(value = "今年计划发电趋势集合") + private List powerMonthVoList; } 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 5eb0764..86cb6ef 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,6 +1,5 @@ package com.hnac.hzims.operational.main.vo; -import com.hnac.hzims.hzimsweather.entity.DailyHeWeatherEntity; import com.hnac.hzims.hzimsweather.response.weather.Daily; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -9,6 +8,9 @@ import lombok.Data; import java.util.List; import java.util.Map; +/** + * @author ysj + */ @Data @ApiModel(value = "水利站点首页对象") public class HydropowerStationVo { diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitRealVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitRealVo.java index f0bd60d..f4cf2f8 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitRealVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitRealVo.java @@ -4,8 +4,11 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +/** + * @author ysj + */ @Data -@ApiModel(value = "泵组实时数据对象") +@ApiModel(value = "水电站实时数据对象") public class HydropowerUnitRealVo { @ApiModelProperty(value = "机构Id") @@ -15,7 +18,7 @@ public class HydropowerUnitRealVo { private String deptName; @ApiModelProperty(value = "开关机状态: 0 - 关机 1 - 开机") - private String state; + private Boolean state; @ApiModelProperty(value = "设备Code") private String deviceCode; @@ -23,26 +26,29 @@ public class HydropowerUnitRealVo { @ApiModelProperty(value = "设备名称") private String deviceName; + @ApiModelProperty(value = "总装机容量") + private Double installedCapacity; + @ApiModelProperty(value = "有功功率") - private String activePower; + private Double activePower; @ApiModelProperty(value = "无功功率") - private String reactivePower; + private Double reactivePower; @ApiModelProperty(value = "功率因数") - private String powerFactor; + private Double powerFactor; @ApiModelProperty(value = "机组频率") - private String frequency; + private Double frequency; @ApiModelProperty(value = "导叶开度") - private String guideOpen; + private Double guideOpen; @ApiModelProperty(value = "定子电压") - private String statorVoltage; + private Double statorVoltage; @ApiModelProperty(value = "定子电流") - private String statorCurrent; + private Double statorCurrent; @ApiModelProperty(value = "有功功率单位") private String powerUnit; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java index 3aa0339..e80e55a 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitTargetVo.java @@ -7,8 +7,11 @@ import lombok.Data; import java.util.List; import java.util.Map; +/** + * @author ysj + */ @Data -@ApiModel(value = "泵组指标数据对象") +@ApiModel(value = "水电站指标数据对象") public class HydropowerUnitTargetVo { @ApiModelProperty(value = "机构Id") diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java index b7a07bd..33539d9 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/HydropowerUnitVo.java @@ -4,6 +4,9 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +/** + * @author ysj + */ @Data @ApiModel(value = "水电站数据对象") public class HydropowerUnitVo { diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldAreaScaleVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldAreaScaleVo.java new file mode 100644 index 0000000..6fb52a8 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldAreaScaleVo.java @@ -0,0 +1,50 @@ +package com.hnac.hzims.operational.main.vo; + +import com.hnac.hzims.hzimsweather.response.weather.Daily; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 集团/区域占比 + */ +@Data +public class OldAreaScaleVo { + + @ApiModelProperty(value = "机构ID") + private Long deptId; + + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ApiModelProperty(value = "七日内天气") + private List weather; + + @ApiModelProperty(value = "站点实时温度") + private String temp; + + @ApiModelProperty(value = "年计划发电量") + private float planPowerYear; + + @ApiModelProperty(value = "年发电量") + private float powerYear; + + @ApiModelProperty(value = "发电完成率") + private double generationPercentageComplete; + + @ApiModelProperty(value = "区域/集团发电占比") + private double areaMakeUp; + + @ApiModelProperty(value = "电站利用率") + private double stationUse; + + @ApiModelProperty(value = "容量利用率") + private double capacityUse; + + @ApiModelProperty(value = "发电量统计") + private double generationCount; + + @ApiModelProperty(value = "排序") + private Integer sort; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldHydropowerScoreVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldHydropowerScoreVo.java new file mode 100644 index 0000000..61bf57e --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldHydropowerScoreVo.java @@ -0,0 +1,57 @@ +package com.hnac.hzims.operational.main.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(value = "水电站分计对象") +public class OldHydropowerScoreVo { + + @ApiModelProperty(value = "机构Id") + private Long departId; + + @ApiModelProperty(value = "机构名称") + private String departName; + + @ApiModelProperty(value = "站点数量") + private Integer stationCount; + + @ApiModelProperty(value = "月总装机容量") + private Double installedCapacityMonth; + + @ApiModelProperty(value = "总有功功率") + private Double activePowerMoth; + + @ApiModelProperty(value = "年总发电量") + private String powerYear; + + @ApiModelProperty(value = "月总发电量") + private String powerMonth; + + @ApiModelProperty(value = "日总发电量") + private String powerDay; + + @ApiModelProperty(value = "年计划发电量") + private String planPowerYear; + + @ApiModelProperty(value = "年完成发电量") + private String finishPowerYear; + + @ApiModelProperty(value = "年计划完成率") + private String planCompletionRateYear; + + @ApiModelProperty(value = "年总装机容量") + private Double installedCapacityYear; + + @ApiModelProperty(value = "年总有功功率") + private Double activePowerYear; + + @ApiModelProperty(value = "容量利用率") + private String rateYear; + + @ApiModelProperty(value = "近年发电量集合") + private List powerYearVoList; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldStationCountVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldStationCountVo.java new file mode 100644 index 0000000..d2336f8 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/OldStationCountVo.java @@ -0,0 +1,18 @@ +package com.hnac.hzims.operational.main.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class OldStationCountVo { + + @ApiModelProperty(value = "站点类型") + private String stationType; + + @ApiModelProperty(value = "站点类型名称") + private String stationTypeName; + + @ApiModelProperty(value = "统计") + private int count; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PowerMonthVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PowerMonthVo.java index f4ae6d8..f4ed16c 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PowerMonthVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PowerMonthVo.java @@ -2,9 +2,11 @@ package com.hnac.hzims.operational.main.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.models.auth.In; import lombok.Data; +/** + * @author ysj + */ @Data @ApiModel(value = "月发电对象") public class PowerMonthVo { diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/StationCountVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/StationCountVo.java index 06060a6..30109f8 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/StationCountVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/StationCountVo.java @@ -3,14 +3,20 @@ package com.hnac.hzims.operational.main.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +/** + * @author ysj + */ @Data public class StationCountVo { @ApiModelProperty(value = "站点类型") - private String stationType; + private String type; + + @ApiModelProperty(value = "服务类型") + private String serveType; @ApiModelProperty(value = "站点类型名称") - private String stationTypeName; + private String typeName; @ApiModelProperty(value = "统计") private int count; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java new file mode 100644 index 0000000..967b694 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/TargetVo.java @@ -0,0 +1,43 @@ +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.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class TargetVo { + + public TargetVo(){ + this.taget_one = 0.0; + this.taget_two = 0.0; + this.taget_three = 0.0; + this.taget_four = 0.0; + } + + @ApiModelProperty(value = "指标类型") + private Integer type; + + @ApiModelProperty(value = "指标名称") + private String typeName; + + @ApiModelProperty(value = "指标1") + private Double taget_one; + + @ApiModelProperty(value = "指标2") + private Double taget_two; + + @ApiModelProperty(value = "指标3") + private Double taget_three; + + @ApiModelProperty(value = "指标4") + private Double taget_four; + + @ApiModelProperty(value = "指标5:充电庄数量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer charge; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/PlanGenertionClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/PlanGenertionClient.java index eac10e2..9d8bfb2 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/PlanGenertionClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/PlanGenertionClient.java @@ -103,7 +103,7 @@ public class PlanGenertionClient implements IPlanGenertionClient{ */ @GetMapping(GET_POWER_YEAR) @Override - public String getPlanPowerYear(List stationIds, String date) { + public Double getPlanPowerYear(List stationIds, String date) { return service.getPlanPowerYear(stationIds,date); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/PlanGenerationMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/PlanGenerationMapper.java index 0b9fdc4..eb7f592 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/PlanGenerationMapper.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/PlanGenerationMapper.java @@ -34,7 +34,7 @@ public interface PlanGenerationMapper extends UserDataScopeBaseMapper stationIdList,@Param("date") String date); + Double getPlanPowerYear(@Param("stationIdList") List stationIdList,@Param("date") String date); /** * 计划发电量查询 diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/PlanGenerationMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/PlanGenerationMapper.xml index 314fb57..15361cb 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/PlanGenerationMapper.xml +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/PlanGenerationMapper.xml @@ -75,8 +75,8 @@ - + select IFNULL(sum(PLAN_GENERATION),0) from hz_ims_plan_generation where IS_DELETED = 0 and STATION_ID in diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IPlanGenerationService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IPlanGenerationService.java index 534b05f..f7e6d65 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IPlanGenerationService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IPlanGenerationService.java @@ -47,7 +47,7 @@ public interface IPlanGenerationService extends BaseService stationIds, String date); + Double getPlanPowerYear(List stationIds, String date); /** * 计划发电量查询 diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/PlanGenerationServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/PlanGenerationServiceImpl.java index 96d194b..00614f5 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/PlanGenerationServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/PlanGenerationServiceImpl.java @@ -311,15 +311,11 @@ public class PlanGenerationServiceImpl extends BaseServiceImpl stationIdList, String date) { + public Double getPlanPowerYear(List stationIdList, String date) { if(CollectionUtil.isEmpty(stationIdList) || StringUtils.isEmpty(date)){ - return "0|0"; + return 0.0; } - String concat = this.baseMapper.getPlanPowerYear(stationIdList,date); - if(StringUtils.isEmpty(concat)){ - return "0|0"; - } - return concat; + return this.baseMapper.getPlanPowerYear(stationIdList,date); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java index cad2e11..561d583 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/OperationApplication.java @@ -22,9 +22,7 @@ import org.springblade.core.launch.BladeApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.cloud.client.SpringCloudApplication; -import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; -import org.springframework.scheduling.annotation.EnableScheduling; import javax.annotation.Resource; @@ -40,13 +38,6 @@ import javax.annotation.Resource; @Resource public class OperationApplication extends SpringBootServletInitializer { - static{ - System.setProperty("spring.cloud.nacos.discovery.server-addr", "http://175.6.40.67:10042"); - System.setProperty("spring.cloud.nacos.config.server-addr", "http://175.6.40.67:10042"); - System.setProperty("spring.cloud.nacos.username", "nacos"); - System.setProperty("spring.cloud.nacos.password", "nacos"); - } - public static void main(String[] args) { BladeApplication.run(OperationalConstants.APP_NAME, OperationApplication.class, args); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/LevelAlarmController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/LevelAlarmController.java index 9947e90..2adf429 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/LevelAlarmController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/LevelAlarmController.java @@ -3,7 +3,6 @@ package com.hnac.hzims.operational.alert.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.entity.HistoryLevelAlarmEntity; import com.hnac.hzims.operational.alert.service.HistoryLevelAlarmService; import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo; @@ -13,13 +12,11 @@ import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.log.annotation.ApiLog; -import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springframework.web.bind.annotation.*; -import javax.validation.Valid; import java.util.List; /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java index f122e23..4f396c1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/HistoryAbnormalAlarmService.java @@ -15,6 +15,7 @@ import java.util.List; /** * 告警处理接口 + * @author ysj */ public interface HistoryAbnormalAlarmService extends BaseService { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java index 6972275..c56b802 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/AlertMerageServiceImpl.java @@ -86,7 +86,7 @@ public class AlertMerageServiceImpl implements AlarmMergeService { List alarms = new ArrayList<>(); if(CollectionUtil.isNotEmpty(faults)){ alarms.addAll(faults.stream().filter(o -> CollectionUtil.isEmpty(handles) - || handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(o.getAlarmId())). + || !handles.stream().map(AlarmHandleEntity::getAlarmId).collect(Collectors.toList()).contains(o.getAlarmId())). map(fault->{ AlarmMergeVo alarm = new AlarmMergeVo(); alarm.setStationCode(fault.getStationId()); @@ -94,7 +94,7 @@ public class AlertMerageServiceImpl implements AlarmMergeService { alarm.setContent(fault.getSoeExplain()); alarm.setDate(fault.getStartTime()); alarm.setRealId(fault.getRealId()); - alarm.setAlarmCode(fault.getAlarmId()); + alarm.setAlarmCode(String.valueOf(fault.getAlarmId())); alarm.setType(AbnormalAlarmConstant.WEBSOCKET_FAULT); return alarm; }).collect(Collectors.toList())); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index 77a676b..c633a72 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -1110,7 +1110,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl personIdlist = new ArrayList<>(Arrays.asList(dutyMainPersonIds)); if (1 == changeDutyMainVo.getType()) { personIdlist.addAll(personId); - } else { personIdlist.removeAll(personId); } String resIds = StringUtils.join(personIdlist, "^"); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 2b1f037..f4c92cf 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -54,11 +54,8 @@ public class GenerateServiceImpl extends BaseServiceImpl implem if(!StringUtil.isEmpty(filter.getStationCode())){ eq("STATION_CODE",filter.getStationCode()); } - if(!ObjectUtil.isEmpty(filter.getStartTime())){ - ge("FILL_DATE",filter.getStartTime()); - } - if(!ObjectUtil.isEmpty(filter.getEndTime())){ - le("FILL_DATE",filter.getEndTime()); + if(!ObjectUtil.isEmpty(filter.getDate())){ + likeRight("FILL_DATE",filter.getDate()); } if(!ObjectUtil.isEmpty(filter.getDataOrigin())){ eq("DATA_ORIGIN",filter.getDataOrigin()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java new file mode 100644 index 0000000..5fd9c13 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomeController.java @@ -0,0 +1,47 @@ +package com.hnac.hzims.operational.main.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.main.service.HomeService; +import com.hnac.hzims.operational.main.vo.StationCountVo; +import com.hnac.hzims.operational.main.vo.TargetVo; +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.log.annotation.ApiLog; +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.RestController; + +import java.util.List; + +/** + * @author ysj + */ +@RestController +@RequestMapping("/home") +@Api(value = "app首页", tags = "app-首页") +@AllArgsConstructor +public class HomeController extends BladeController { + + private final HomeService service; + + @ApiLog + @ApiOperation("首页站点数量") + @GetMapping("/count") + @ApiOperationSupport(order = 1) + public R> count() { + return R.data(service.count()); + } + + @ApiLog + @ApiOperation("首页关键指标") + @GetMapping("/target") + @ApiOperationSupport(order = 2) + + public R target(@ApiParam(value = "指标类型",required = true) Integer type) { + return R.data(service.target(type)); + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomePageController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomePageController.java index bf7a8e8..1f3d183 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomePageController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HomePageController.java @@ -37,8 +37,8 @@ public class HomePageController extends BladeController { @ApiOperation("服务厂站统计") @GetMapping("/stationCensus") @ApiOperationSupport(order = 1) - public R> stationCount(@ApiParam(value = "站点服务类型:1、云服务站点; 2、代运维服务站点", required = true) Integer serveType, Long deptId) { - List stationList = homePageService.getStationCount(deptId,serveType); + public R> stationCount(@ApiParam(value = "站点服务类型:1、云服务站点; 2、代运维服务站点", required = true) Integer serveType, Long deptId) { + List stationList = homePageService.getStationCount(deptId,serveType); return R.data(stationList); } @@ -73,8 +73,8 @@ public class HomePageController extends BladeController { @ApiOperation("水电站数据获取") @GetMapping("/getHydropowerData") @ApiOperationSupport(order = 5) - public R> getHydropowerData(@ApiParam(value = "区域id", required = true) Long deptId) { - List hydropowerScoreVoList = homePageService.getHydropowerData(deptId); + public R> getHydropowerData(@ApiParam(value = "区域id", required = true) Long deptId) { + List hydropowerScoreVoList = homePageService.getHydropowerData(deptId); return R.data(hydropowerScoreVoList); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java index 7b10091..930a7fa 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/HydropowerController.java @@ -2,6 +2,8 @@ package com.hnac.hzims.operational.main.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.main.service.HydropowerService; +import com.hnac.hzims.operational.main.vo.AreaScaleVo; +import com.hnac.hzims.operational.main.vo.HydropowerScoreVo; import com.hnac.hzims.operational.main.vo.HydropowerStationVo; import com.hnac.hzims.operational.main.vo.HydropowerUnitVo; import io.swagger.annotations.Api; @@ -21,7 +23,7 @@ import java.util.List; * @author ysj */ @RestController -@RequestMapping("/webHome") +@RequestMapping("/hydropower") @Api(value = "app首页", tags = "app-首页") @AllArgsConstructor public class HydropowerController extends BladeController { @@ -30,21 +32,28 @@ public class HydropowerController extends BladeController { @ApiLog - @ApiOperation("水电站区域指标") - @GetMapping("/area/target") + @ApiOperation("水电站集团/区域指标") + @GetMapping("/KPIs") @ApiOperationSupport(order = 1) - public R area_target(@ApiParam(value = "站点机构ID") Long deptId) { - HydropowerStationVo response = service.area_target(deptId); - return R.data(response); + public R KPIs(@ApiParam(value = "站点机构ID") Long deptId) { + return R.data(service.KPIs(deptId)); } @ApiLog + @ApiOperation("水电站集团/区域占比") + @GetMapping("/proportion") + @ApiOperationSupport(order = 1) + public R> proportion(@ApiParam(value = "站点机构ID") Long deptId) { + return R.data(service.proportion(deptId)); + } + + + @ApiLog @ApiOperation("水电站站点指标") @GetMapping("/station") @ApiOperationSupport(order = 1) public R hydropowerStation(@ApiParam(value = "站点机构ID") Long deptId) { - HydropowerStationVo response = service.station(deptId); - return R.data(response); + return R.data(service.station(deptId)); } @ApiLog @@ -52,8 +61,7 @@ public class HydropowerController extends BladeController { @GetMapping("/getPumpList") @ApiOperationSupport(order = 2) public R> hydropowerDevice(@ApiParam(value = "站点机构ID") Long deptId) { - List list = service.hydropowerDevice(deptId); - return R.data(list); + return R.data(service.hydropowerDevice(deptId)); } @ApiLog diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/SideHustleController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/SideHustleController.java index b37774a..45bc420 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/SideHustleController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/SideHustleController.java @@ -61,7 +61,7 @@ public class SideHustleController extends BladeController { @OperationAnnotation(moduleName = "演示大屏",title = "演示大屏", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE,action = "区域占比") @ApiOperationSupport(order = 4) - public R> areaScale(@ApiParam(value = "区域机构ID") Long deptId) { + public R> areaScale(@ApiParam(value = "区域机构ID") Long deptId) { return R.data(regionService.areaScale(deptId)); } @ApiLog 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 58654ec..6d51538 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 @@ -36,12 +36,8 @@ public class ScheduledCreateTask { @Autowired private IUnitRunningTimeService unitRunningTimeService; @Autowired - private IHomePageService homePageService; - @Autowired private IWaterService waterService; @Autowired - private ISideHustleService sideHustleService; - @Autowired private IAreaMonthReportService reportService; @Autowired private HydropowerService hydropowerService; @@ -151,19 +147,6 @@ public class ScheduledCreateTask { return new ReturnT<>("SUCCESS"); } - /** - * 首页 - 关键指标数据获取 - * @return ReturnT - */ - @XxlJob(CRUCIAL_TARGET_PRELOADING) - public ReturnT loadHydropower(String param) throws Exception { - if (Func.isBlank(param)) { - param = DateUtil.format(new Date(), "yyyy-MM"); - } - homePageService.loadHydropower(param,SERVE_TYPE); - return new ReturnT<>("SUCCESS"); - } - /** * 获取站点近3年发电量数据 @@ -175,7 +158,7 @@ public class ScheduledCreateTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - homePageService.loadPowerData(param, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),SERVE_TYPE,3); + hydropowerService.loadPowerData(param, Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),SERVE_TYPE,3); return new ReturnT<>("SUCCESS"); } @@ -189,7 +172,7 @@ public class ScheduledCreateTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } - sideHustleService.loadDutyInfo(param); + //sideHustleService.loadDutyInfo(param); return new ReturnT<>("SUCCESS"); } @@ -203,7 +186,7 @@ public class ScheduledCreateTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } - sideHustleService.deviceClassify(param); + //sideHustleService.deviceClassify(param); return new ReturnT<>("SUCCESS"); } @@ -254,7 +237,7 @@ public class ScheduledCreateTask { * @return ReturnT */ @XxlJob(LOAD_WATER_LEVEL) - //@Scheduled(cron = "0/10 * * * * ? ") + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadWaterLevel(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); @@ -268,7 +251,7 @@ public class ScheduledCreateTask { * @return ReturnT */ @XxlJob(LOAD_HYDROPOWER_UNIT_REAL) - //@Scheduled(cron = "0/10 * * * * ? ") + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadHydropowerUnitReal(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); @@ -282,7 +265,7 @@ public class ScheduledCreateTask { * @return ReturnT */ @XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) - //@Scheduled(cron = "0/10 * * * * ? ") + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadHydropowerUnitTarget(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); @@ -296,7 +279,7 @@ public class ScheduledCreateTask { * @return ReturnT */ @XxlJob(LOAD_PHOTOVOLTAIC_REAL) - //@Scheduled(cron = "0/50 * * * * ? ") + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadPhotovoltaicReal(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaService.java index 615d7e3..f199289 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaService.java @@ -13,4 +13,7 @@ public interface AreaService { // 获取权限区域 Map> getAuthArea(List list,Long deptId,List typeList,Integer serveType); + + // 获取用户权限区域 + Map> areaOrStaion(Long deptId, List types); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HomeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HomeService.java new file mode 100644 index 0000000..5d2499d --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HomeService.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.operational.main.service; + +import com.hnac.hzims.operational.main.vo.StationCountVo; +import com.hnac.hzims.operational.main.vo.TargetVo; + +import java.util.List; + +/** + * 首页接口 + * @author ysj + */ +public interface HomeService { + + List count(); + + TargetVo target(Integer type); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java index 62c0dba..c2d86aa 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java @@ -1,5 +1,7 @@ package com.hnac.hzims.operational.main.service; +import com.hnac.hzims.operational.main.vo.AreaScaleVo; +import com.hnac.hzims.operational.main.vo.HydropowerScoreVo; import com.hnac.hzims.operational.main.vo.HydropowerStationVo; import com.hnac.hzims.operational.main.vo.HydropowerUnitVo; @@ -15,11 +17,15 @@ public interface HydropowerService { void loadHydropowerTarget(String param); - HydropowerStationVo station(Long deptId); + void loadPowerData(String param, List types, Integer serveType, int year); + + HydropowerStationVo station(Long deptId); List hydropowerDevice(Long deptId); List webStationList(Long deptId); - HydropowerStationVo area_target(Long deptId); + HydropowerScoreVo KPIs(Long deptId); + + List proportion(Long deptId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IHomePageService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IHomePageService.java index 8a641ed..82d6b10 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IHomePageService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IHomePageService.java @@ -1,8 +1,6 @@ package com.hnac.hzims.operational.main.service; -import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.main.vo.*; -import com.hnac.hzims.operational.station.entity.StationEntity; import org.springblade.core.tool.api.R; import org.springblade.system.entity.Dept; @@ -19,7 +17,7 @@ public interface IHomePageService { List getMonthList(int year, int endMoth,boolean nextMon); - List getStationCount(Long deptId, Integer serveType); + List getStationCount(Long deptId, Integer serveType); List powerTarget(Integer serveType,Long deptId); @@ -32,7 +30,7 @@ public interface IHomePageService { R>> areaGenerationMakeUp(Long deptId,Integer stationType,Integer serveType); - List getHydropowerData(Long deptId); + List getHydropowerData(Long deptId); R>> getCount(Long deptId,Integer stationType,Integer serveType); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java index bb7dc0e..c729404 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/ISideHustleService.java @@ -24,7 +24,7 @@ public interface ISideHustleService { List areaPowerScale(Long deptId); - List areaScale(Long deptId); + List areaScale(Long deptId); List getMapMarker(Long deptId,List types); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java index 1df4106..20590c1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java @@ -17,12 +17,12 @@ 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.main.constant.HomePageConstant; +import com.hnac.hzims.operational.main.service.AreaService; import com.hnac.hzims.operational.main.service.IAppHomeService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; -import com.hnac.hzims.operational.main.service.ISideHustleService; import com.hnac.hzims.operational.main.service.IWeatherService; import com.hnac.hzims.operational.main.vo.*; -import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; @@ -65,20 +65,20 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class AppHomeServiceImpl implements IAppHomeService { - private final IMainSystemMonitoringService mainService; - - private final IImsDutyMainService dutyMainService; - - private final ISideHustleService sideHustleService; + private final AreaService areaService; private final IStationService stationService; - private final IStationAttributeService attributeService; + private final IImsDutyMainService dutyMainService; private final IOperPhenomenonService phenomenonService; private final IOperAccessTaskService accessTaskService; + private final IMainSystemMonitoringService mainService; + + private final IStationAttributeService attributeService; + private final IOperMaintenanceTaskService maintenanceTaskService; private final IInspectTaskReportClient inspectTaskReportClient; @@ -350,12 +350,12 @@ public class AppHomeServiceImpl implements IAppHomeService { @Override public List appStationList(Long deptId) { // 获取区域或者站点map结构 - Map> map = sideHustleService.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); + Map> map = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); if(MapUtils.isEmpty(map)){ return null; } // 获取站点计划发电量集合 - List planPowerList = sideHustleService.getStaionPlanPower(map); + //List planPowerList = sideHustleService.getStaionPlanPower(map); // 获取设备指标数据列表 List targetList = (List) redisTemplate.opsForValue().get(LOAD_HYDROPOWER_UNIT_TARGET_KEY); // 获取设备实时数据 @@ -370,10 +370,10 @@ public class AppHomeServiceImpl implements IAppHomeService { response.setDeptId(item.getRefDept()); response.setDeptName(item.getName()); // 站点年计划发电量 - float planPowerYear = this.getPlanPowerYear(planPowerList,item.getCode()); - response.setPlanPowerYear(planPowerYear); + //float planPowerYear = this.getPlanPowerYear(planPowerList,item.getCode()); + response.setPlanPowerYear(0f); // 站点发电完成率 - double powerRate = this.getPowerRate(targetList,item.getCreateDept(),planPowerYear); + double powerRate = this.getPowerRate(targetList,item.getCreateDept(),0f); response.setPowerRate(powerRate); // 设备总数 int deviceSum = this.getDeviceSum(realList,item.getCreateDept(),false); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index 677a0b2..ba2337f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java @@ -5,12 +5,12 @@ import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.message.dto.MailPushDto; import com.hnac.hzims.message.fegin.IPushMsgClient; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; +import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.IAreaMonthReportService; import com.hnac.hzims.operational.main.service.IMainTaskStatisticService; import com.hnac.hzims.operational.main.vo.AreaMonthReportVo; import com.hnac.hzims.operational.main.vo.MaintainVo; import com.hnac.hzims.operational.main.vo.OverhaulVo; -import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.report.vo.DutyDefectVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; @@ -51,7 +51,8 @@ import java.math.BigDecimal; import java.net.URLEncoder; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.time.*; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.CountDownLatch; @@ -532,7 +533,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { // 操作票、操作票合格率/ 工作票、工作票合格率 this.doubleMonth(area, areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon)); // 日常维护、巡检任务、缺陷数、消缺率、检修任务 - this.taskMonth(areaStationList, areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon)); + this.taskMonth(Collections.singletonList(area.getId()), areaMonthReport, mon + "-01 00:00:00", getStrEndTime(mon)); // 预测 this.getPredictPlanPower(oldActualMap,oldOldActualMap,areaStationList,areaMonthReport); // 安全生产会议次数、月度检查报告、技能培训、安全大检查 @@ -785,18 +786,17 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { /** * 任务月报-日常维护、巡检任务、缺陷数、消缺率、检修任务 * - * @param areaStationList + * @param areas * @param areaMonthReport */ - private void taskMonth(List areaStationList, AreaMonthReportVo areaMonthReport, String startTime, String endTime) { - List list = areaStationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + private void taskMonth(List areas, AreaMonthReportVo areaMonthReport, String startTime, String endTime) { //通过线程池异步获取月报各模块内容 主要分为五块内容 ExecutorService exe = Executors.newFixedThreadPool(POOL_QUANTITY); //监控线程执行完后返回结果 CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); // 日常维护 exe.execute(() -> { - MaintainVo maintainVo = mainTaskStatisticService.getMaintain(startTime, endTime, list); + MaintainVo maintainVo = mainTaskStatisticService.getMaintain(startTime, endTime, areas); int maintainSum = maintainVo.getMaintain(); areaMonthReport.setRoutineMaintenance(maintainSum); countDownLatch.countDown(); @@ -807,7 +807,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { Map map = new HashMap<>(); map.put("startDate", startTime); map.put("endDate", endTime); - map.put("deptList", list); + map.put("deptList", areas); R R = inspectTaskReportClient.getDutyInspectTask(map); if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { areaMonthReport.setInspect(0); @@ -820,7 +820,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { // 消缺 exe.execute(() -> { - DutyDefectVO defectVO = operPhenomenonService.getDutyDefect(startTime, endTime, list); + DutyDefectVO defectVO = operPhenomenonService.getDutyDefect(startTime, endTime, areas); int defectSum = defectVO.getDefectSum(); int defect = defectVO.getDefect(); areaMonthReport.setDefect(defectSum); @@ -835,7 +835,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { // 检修 exe.execute(() -> { - OverhaulVo overhaulVo = mainTaskStatisticService.getOverhaul(startTime, endTime, list); + OverhaulVo overhaulVo = mainTaskStatisticService.getOverhaul(startTime, endTime, areas); int overhaul = overhaulVo.getOverhaul(); areaMonthReport.setMaintenanceTasks(overhaul); countDownLatch.countDown(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java index 5fb80f1..2bdc625 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaServiceImpl.java @@ -7,10 +7,12 @@ import com.hnac.hzims.operational.station.service.IStationService; import lombok.RequiredArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -81,4 +83,45 @@ public class AreaServiceImpl implements AreaService { } return result; } + + + /** + * 获取区域或者站点map结构 + * @param deptId + * @return + */ + @Override + public Map> areaOrStaion(Long deptId,List types) { + //根据用户权限获取机构 + R> R = sysClient.getDeptByCurrentUser(); + if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { + return null; + } + if(ObjectUtil.isNotEmpty(deptId)){ + List list = R.getData().stream().filter(o->deptId.equals(o.getId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(list)){ + return null; + } + Dept dept = list.get(0); + // 机构为站点 key-站点机构 value-站点 + if(HomePageConstant.AREA.equals(dept.getDeptCategory())){ + List stationList = stationService.getStationList(R.getData(),dept.getId(),types,HomePageConstant.HYDROPOWER_SERVETYPE); + if(CollectionUtil.isEmpty(stationList)){ + return null; + } + Map> map = new HashMap<>(); + stationList.forEach(item->{ + List stationDeptList = R.getData().stream().filter(o->o.getId().equals(item.getRefDept())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(stationDeptList)){ + return; + } + // 站点机构 + Dept station = stationDeptList.get(0); + map.put(station, Collections.singletonList(item)); + }); + return map; + } + } + return this.getAuthArea(R.getData(),deptId,types,HomePageConstant.HYDROPOWER_SERVETYPE); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java index 7d82b1b..497ae1b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java @@ -341,7 +341,7 @@ public class HomePageServiceImpl implements IHomePageService { * @return */ @Override - public List getStationCount(Long deptId, Integer serveType) { + public List getStationCount(Long deptId, Integer serveType) { //根据用户权限获取机构 R> R = sysClient.getDeptByCurrentUser(); if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { @@ -352,12 +352,12 @@ public class HomePageServiceImpl implements IHomePageService { HomePageConstant.DISTRIBUTION_NETWORK, HomePageConstant.PHOTOVOLTAIC, HomePageConstant.WATER_AFFAIRS, HomePageConstant.CHARGE); // 查询站点 List stationEntityList = stationService.getStationList(R.getData(),deptId,storage,serveType); - List list = new ArrayList<>(); + List list = new ArrayList<>(); storage.forEach(item->{ if(HomePageConstant.PUMPING.equals(item) || HomePageConstant.GATE.equals(item)){ return; } - StationCountVo stationCountVo = new StationCountVo(); + OldStationCountVo stationCountVo = new OldStationCountVo(); stationCountVo.setStationType(item.toString()); stationCountVo.setStationTypeName(DictCache.getValue("stationType", item)); stationCountVo.setCount(0); @@ -1507,8 +1507,8 @@ public class HomePageServiceImpl implements IHomePageService { * @return */ @Override - public List getHydropowerData(Long deptId) { - List hydropowerScoreVoList = new ArrayList<>(); + public List getHydropowerData(Long deptId) { + List hydropowerScoreVoList = new ArrayList<>(); // 站点数据(水电站、风电站、光伏站) KeyIndicatorsVo keyIndicatorsVo = (KeyIndicatorsVo) redisTemplate.opsForValue().get(KEY_INDICATORS_INFO); // 水电站 @@ -1523,7 +1523,7 @@ public class HomePageServiceImpl implements IHomePageService { return null; } deptMap.forEach((key, value) -> { - HydropowerScoreVo hydropowerScoreVo = new HydropowerScoreVo(); + OldHydropowerScoreVo hydropowerScoreVo = new OldHydropowerScoreVo(); hydropowerScoreVo.setDepartId(key); // 站点查询 List stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), value); @@ -1869,7 +1869,7 @@ public class HomePageServiceImpl implements IHomePageService { * @param powerStationTotalVoList * @return */ - private void stationSumData(List stationIdList, List powerStationTotalVoList, HydropowerScoreVo hydropowerScoreVo) { + private void stationSumData(List stationIdList, List powerStationTotalVoList, OldHydropowerScoreVo hydropowerScoreVo) { if (CollectionUtil.isEmpty(powerStationTotalVoList)) { hydropowerScoreVo.setInstalledCapacityMonth(0.0); return; @@ -1899,7 +1899,7 @@ public class HomePageServiceImpl implements IHomePageService { * @param powerMap * @param hydropowerScoreVo */ - private void recentYearPower(List stationIdList, Map> powerMap, HydropowerScoreVo hydropowerScoreVo) { + private void recentYearPower(List stationIdList, Map> powerMap, OldHydropowerScoreVo hydropowerScoreVo) { List> valueList = powerMap.entrySet().stream().filter(e -> stationIdList.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); if (CollectionUtil.isEmpty(valueList) || MapUtils.isEmpty(powerMap)) { return; @@ -1963,7 +1963,7 @@ public class HomePageServiceImpl implements IHomePageService { * @param * @param hydropowerScoreVo */ - private void planActualPower(List stationCodeList, HydropowerScoreVo hydropowerScoreVo) { + private void planActualPower(List stationCodeList, OldHydropowerScoreVo hydropowerScoreVo) { if (CollectionUtil.isEmpty(stationCodeList)) { hydropowerScoreVo.setPlanPowerYear("0"); hydropowerScoreVo.setFinishPowerYear("0"); @@ -1973,13 +1973,12 @@ public class HomePageServiceImpl implements IHomePageService { calendar.setTime(new Date()); String year = String.valueOf(calendar.get(Calendar.YEAR)); // 查询年计划发电情况 返回格式 : 计划发电量|完成发电量 - String planActualPower = planGenertionClient.getPlanPowerYear(stationCodeList, year); - String[] powerArr = planActualPower.split("\\|"); - hydropowerScoreVo.setPlanPowerYear(powerArr[0]); + Double planActualPower = planGenertionClient.getPlanPowerYear(stationCodeList, year); + hydropowerScoreVo.setPlanPowerYear(String.valueOf(planActualPower)); // 使用实时统计年发电量计算 float finishPowerYear = Float.parseFloat(hydropowerScoreVo.getPowerYear()); hydropowerScoreVo.setFinishPowerYear(String.valueOf(finishPowerYear)); - float planPowerYear = Float.parseFloat(powerArr[0]); + float planPowerYear = Float.parseFloat(String.valueOf(planActualPower)); if (Math.abs(planPowerYear) <= 0) { hydropowerScoreVo.setPlanCompletionRateYear("0.0"); return; @@ -1995,7 +1994,7 @@ public class HomePageServiceImpl implements IHomePageService { * @param activePowerMap * @param hydropowerScoreVo */ - private void activePower(List stationList, Map activePowerMap, HydropowerScoreVo hydropowerScoreVo) { + private void activePower(List stationList, Map activePowerMap, OldHydropowerScoreVo hydropowerScoreVo) { if (MapUtils.isEmpty(activePowerMap)) { hydropowerScoreVo.setActivePowerYear(0.0); hydropowerScoreVo.setActivePowerMoth(0.0); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java new file mode 100644 index 0000000..e6bade3 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java @@ -0,0 +1,516 @@ +package com.hnac.hzims.operational.main.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import com.hnac.hzims.equipment.feign.IPlanGenertionClient; +import com.hnac.hzims.operational.fill.entity.*; +import com.hnac.hzims.operational.fill.service.*; +import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.main.service.HomeService; +import com.hnac.hzims.operational.main.service.IMainTaskStatisticService; +import com.hnac.hzims.operational.main.vo.*; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.ticket.allTicket.fegin.ITicketInfoAllClient; +import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.cache.DictCache; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.math.BigDecimal; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.*; +import java.util.concurrent.*; +import java.util.stream.Collectors; + +/** + * 首页实现类 + * @author ysj + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class HomeServiceImpl implements HomeService { + + private final OverService overService; + + private final OtherService otherService; + + private final PowerService powerService; + + private final SolveService solveService; + + private final IStationService stationService; + + private final IPlanGenertionClient planService; + + private final OverDetailsService overDetailsService; + + private final IMainTaskStatisticService mainTaskStatisticService; + + private final ISysClient sysClient; + + private final ITicketInfoAllClient ticketClient; + + private final RedisTemplate redisTemplate; + + private final static String charge = "hzims:operation:key:charge"; + + @Value("${hzims.operation.homePage.charge.url}") + public String charge_url; + + private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; + private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; + + private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; + + private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; + + private static final int STORAGE_POOL_QUANTITY = 4; + + private static final int NETWORK_POOL_QUANTITY = 3; + + /** + * 首页站点数量 + * @return + */ + @Override + public List count() { + // 查询全部站点 + List stations = stationService.list(); + List counts = new ArrayList<>(); + stations.stream().collect(Collectors.groupingBy(StationEntity::getServeType)) + .forEach((key, value) -> counts.addAll(value.stream().collect(Collectors.groupingBy(StationEntity::getType)).entrySet().stream(). + map(station -> { + StationCountVo count = new StationCountVo(); + count.setServeType(key); + if(HomePageConstant.CHARGE.equals(station.getKey()) && "2".equals(key)){ + TargetVo target = (TargetVo) redisTemplate.opsForValue().get(charge); + if(ObjectUtil.isNotEmpty(target)){ + count.setCount(Optional.ofNullable(target.getCharge()).orElse(0)); + } + }else{ + count.setCount(station.getValue().size()); + } + count.setType(String.valueOf(station.getKey())); + count.setTypeName(DictCache.getValue("stationType", station.getKey())); + return count; + }).collect(Collectors.toList()))); + return counts.stream().sorted(Comparator.comparing(StationCountVo::getServeType)).collect(Collectors.toList()); + } + + /** + * 首页指标 + * @param type + * @return + */ + @Override + public TargetVo target(Integer type) { + switch (type){ + // 水电站 + case 0: + return this.hydropowerTaget(); + // 风电站 + case 1: + return this.windTaget(); + // 水利 + case 2: + return this.waterStorageTaget(false); + // 储能站 + case 3: + return this.waterStorageTaget(true); + // 配网 + case 4: + return this.networkTaget(); + // 光伏站 + case 5: + return this.photovoltaicTaget(); + // 充电桩 + case 7: + return this.chargeTarget(); + // 水务 + case 6: + default: + return new TargetVo(); + } + } + + + /** + * 水电站指标 + * @return + */ + private TargetVo hydropowerTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.HYDROPOWER); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.HYDROPOWER)); + // 实时数据 + List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + // 指标数据 + List targets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + if(CollectionUtil.isNotEmpty(reals)){ + // 装机容量 + target.setTaget_one(reals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); + } + if(CollectionUtil.isNotEmpty(targets)){ + // 发电量 + target.setTaget_two(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); + } + // 计划发电量 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.HYDROPOWER)); + if(CollectionUtil.isNotEmpty(stations)){ + List plans = planService.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy")); + if(CollectionUtil.isNotEmpty(plans)){ + double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + if(Math.abs(plan) > 0){ + target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + } + } + // 双票合格率 + R> result = sysClient.getDeptByCurrentUser(); + if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData()) && CollectionUtil.isNotEmpty(stations)){ + List areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(areas)){ + LocalDateTime firstDateTime = LocalDateTime.of(LocalDate.now().withDayOfYear(1), LocalTime.MIN); + DoublePassRateVO pass = ticketClient.getDoublePassRate(areas, firstDateTime, LocalDateTime.now()); + if(ObjectUtil.isNotEmpty(pass)){ + target.setTaget_four(Double.valueOf(pass.getDoublePassRate())); + } + } + } + return target; + } + + + /** + * 风电指标 + * @return + */ + private TargetVo windTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.WIND_POWER); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.WIND_POWER)); + // 填报发电量 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.WIND_POWER)); + if(CollectionUtil.isEmpty(stations)){ + return target; + } + QueryWrapper queryWrapper = new QueryWrapper() {{ + in("create_dept", stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + eq("type", HomePageConstant.WIND_POWER_TYPE); + likeRight("mon", DateUtil.format(new Date(),"yyyy")); + }}; + List list = powerService.list(queryWrapper); + if(CollectionUtil.isEmpty(list)){ + return target; + } + double plan = list.stream().mapToDouble(PowerEntity::getPlannedPowerMon).sum(); + double pass = list.stream().mapToDouble(power -> Double.parseDouble(power.getDoubleQualifyRate())).sum(); + // 装机容量 + target.setTaget_one(list.get(0).getInstalledCapacity()); + // 发电量 + target.setTaget_two(list.stream().mapToDouble(PowerEntity::getPowerMon).sum()); + if(Math.abs(plan) > 0){ + // 发电完成率 + target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + // 双票合格率 + target.setTaget_four(BigDecimal.valueOf(pass / list.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + return target; + } + + /** + * 光伏指标 + * @return + */ + private TargetVo photovoltaicTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.PHOTOVOLTAIC); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.PHOTOVOLTAIC)); + // 实时数据 + List reals = (List) redisTemplate.opsForValue().get(load_photovoltaic_real_key); + // 指标数据 + List targets = (List) redisTemplate.opsForValue().get(load_photovoltaic_target_key); + if(CollectionUtil.isNotEmpty(reals)){ + // 装机容量 + target.setTaget_one(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); + } + if(CollectionUtil.isNotEmpty(targets)){ + // 发电量 + target.setTaget_two(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum()); + } + // 计划发电量、双票合格率 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) + .eq(StationEntity::getType,HomePageConstant.PHOTOVOLTAIC)); + if(CollectionUtil.isNotEmpty(stations)){ + QueryWrapper queryWrapper = new QueryWrapper() {{ + in("create_dept", stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); + eq("type", HomePageConstant.PHOTOVOLTAIC_TYPE); + likeRight("mon", DateUtil.format(new Date(),"yyyy")); + }}; + List list = powerService.list(queryWrapper); + if(CollectionUtil.isEmpty(list)){ + return target; + } + double plan = list.stream().mapToDouble(PowerEntity::getPlannedPowerMon).sum(); + double pass = list.stream().mapToDouble(power -> Double.parseDouble(power.getDoubleQualifyRate())).sum(); + if(Math.abs(plan) > 0){ + // 发电完成率 + target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + // 双票合格率 + target.setTaget_four(BigDecimal.valueOf(pass / list.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + return target; + } + + + /** + * 储能指标 + * @param flag : false - 水利 true - 储能 + * @return + */ + private TargetVo waterStorageTaget(boolean flag) { + TargetVo target = new TargetVo(); + if(flag){ + target.setType(HomePageConstant.ENERGY_STORAGE); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.ENERGY_STORAGE)); + }else{ + target.setType(HomePageConstant.WATER_CONSERVANCY); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.WATER_CONSERVANCY)); + } + + // 查询储能站点 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE); + if(flag){ + wrapper.eq(StationEntity::getType,HomePageConstant.ENERGY_STORAGE); + }else{ + wrapper.eq(StationEntity::getType,HomePageConstant.WATER_CONSERVANCY); + } + List stations = stationService.list(wrapper); + if(CollectionUtil.isEmpty(stations)){ + return target; + } + // 获取储能区域级别机构 + R> result = sysClient.getDeptByCurrentUser(); + if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData()) && CollectionUtil.isNotEmpty(stations)){ + List areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(areas)){ + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("storage-taget-pool-%d").build(); + ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(4, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + // 监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(STORAGE_POOL_QUANTITY); + // 日常维护 + exe.execute(() -> { + target.setTaget_one(Double.valueOf(mainTaskStatisticService.getRoutineMaintenanceCount(areas))); + countDownLatch.countDown(); + }); + // 检修任务 + exe.execute(() -> { + target.setTaget_two(Double.valueOf(mainTaskStatisticService.getMaintenanceTasksCount(areas))); + countDownLatch.countDown(); + }); + // 消缺率 + exe.execute(() -> { + target.setTaget_three(Double.valueOf(mainTaskStatisticService.getDeletionRate(areas))); + countDownLatch.countDown(); + }); + // 双票合格率 + exe.execute(() -> { + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + DoublePassRateVO pass = ticketClient.getDoublePassRate(areas, firstDateTime, LocalDateTime.now()); + if (ObjectUtil.isNotEmpty(pass)) { + target.setTaget_four(Double.valueOf(pass.getDoublePassRate())); + } + countDownLatch.countDown(); + }); + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + exe.shutdown(); + } + } + return target; + } + + /** + * 配网 + * @return + */ + private TargetVo networkTaget() { + TargetVo target = new TargetVo(); + target.setType(HomePageConstant.DISTRIBUTION_NETWORK); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.DISTRIBUTION_NETWORK)); + // 线程池 + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("network-taget-pool-%d").build(); + ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(3, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + // 监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(NETWORK_POOL_QUANTITY); + // 当月 + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + // 检修卡 + exe.execute(()->{ + List overs = overService.list(new QueryWrapper() {{ + ge("create_time", firstDateTime); + le("create_time", LocalDateTime.now()); + }}); + if(CollectionUtil.isEmpty(overs)){ + countDownLatch.countDown(); + return; + } + List details = overDetailsService.list(new QueryWrapper() {{ + ge("create_time", firstDateTime); + le("create_time", LocalDateTime.now()); + in("over_id",overs.stream().map(OverEntity::getId).collect(Collectors.toList())); + }}); + if(CollectionUtil.isEmpty(details)){ + countDownLatch.countDown(); + return; + } + target.setTaget_one(details.stream().mapToDouble(OverDetailsEntity::getQuantity).sum()); + countDownLatch.countDown(); + }); + // 消缺 + exe.execute(()->{ + List solves = solveService.list(new QueryWrapper() {{ + ge("create_time", firstDateTime); + le("create_time", LocalDateTime.now()); + }}); + if(CollectionUtil.isEmpty(solves)){ + countDownLatch.countDown(); + return; + } + target.setTaget_two(solves.stream().mapToDouble(SolveEntity::getSolveQuantity).sum()); + countDownLatch.countDown(); + }); + // 其他 + exe.execute(()->{ + List others = otherService.list(new QueryWrapper() {{ + ge("create_time", firstDateTime); + le("create_time", LocalDateTime.now()); + }}); + if(CollectionUtil.isEmpty(others)){ + countDownLatch.countDown(); + return; + } + target.setTaget_three(others.stream().mapToDouble(OtherEntity::getFaQuantity).sum()); + double online = others.stream().mapToDouble(o-> Double.parseDouble(o.getOnlineRate())).sum(); + if(Math.abs(online) > 0){ + target.setTaget_three(BigDecimal.valueOf(online / others.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + countDownLatch.countDown(); + }); + // 等待所有线程执行完成 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + return target; + } + + /** + * 充电桩 + * @return + */ + private TargetVo chargeTarget() { + TargetVo target = (TargetVo) redisTemplate.opsForValue().get(charge); + if(ObjectUtil.isNotEmpty(target)){ + return target; + } + target = new TargetVo(); + try { + URL serverUrl = new URL(charge_url); + HttpURLConnection conn = (HttpURLConnection) serverUrl.openConnection(); + conn.setRequestMethod("GET"); + conn.setRequestProperty("Content-type", "application/json"); + //必须设置false,否则会自动redirect到重定向后的地址 + conn.setInstanceFollowRedirects(false); + conn.connect(); + String result = responseFormat(conn); + if (StringUtil.isBlank(result)) { + return new TargetVo(); + } + JSONObject jsonObject = JSONObject.parseObject(result); + JSONObject data = JSONObject.parseObject(jsonObject.get("data").toString()); + target.setType(HomePageConstant.CHARGE); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.CHARGE)); + target.setTaget_one(Double.valueOf(data.get("ordersCount").toString())); + target.setTaget_two(Double.valueOf(data.get("todayDegree").toString())); + target.setTaget_three(Double.valueOf(data.get("income").toString())); + target.setTaget_four(Double.valueOf(data.get("kilowatt").toString())); + target.setCharge(Integer.valueOf(data.get("stationNum").toString())); + redisTemplate.opsForValue().set(charge,target); + redisTemplate.expire(charge,30, TimeUnit.MINUTES); + } catch (Exception e) { + target.setType(HomePageConstant.CHARGE); + target.setTypeName(DictCache.getValue("stationType", HomePageConstant.CHARGE)); + target.setTaget_one(0.0); + target.setTaget_two(0.0); + target.setTaget_three(0.0); + target.setTaget_four(0.0); + target.setCharge(0); + log.error("charge_target_exception: {} ", e.getMessage()); + } + return target; + } + + /*** + * 获取返回的内容 + * @param connection + * @return + */ + private String responseFormat(HttpURLConnection connection) { + StringBuilder stringBuilder = new StringBuilder(); + //将返回的输入流转换成字符串 + try ( + InputStream inputStream = connection.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader) + ) { + String str; + while ((str = bufferedReader.readLine()) != null) { + stringBuilder.append(str); + } + } catch (IOException e) { + return null; + } + return stringBuilder.toString(); + } +} 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 88170de..d7bb3b4 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 @@ -4,13 +4,14 @@ 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.entity.PlanGenerationEntity; 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.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; import com.hnac.hzims.operational.fill.service.GenerateService; +import com.hnac.hzims.operational.fill.service.PowerService; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.vo.*; @@ -27,6 +28,7 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; 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; @@ -41,20 +43,21 @@ import java.util.stream.Collectors; /** * APP首页实现类 + * @author ysj */ @Service @RequiredArgsConstructor public class HydropowerServiceImpl implements HydropowerService { - private final IWaterService waterService; - private final IWeatherService weatherService; private final IStationService stationService; private final GenerateService generateService; - private final IHomePageService homePageService; + private final PowerService photovoltaicService; + + private final AreaService areaService; private final IAnalyseDataService analyseDataService; @@ -107,8 +110,10 @@ public class HydropowerServiceImpl implements HydropowerService { real.setDeviceCode(device.getEmCode()); real.setDeptName(device.getName()); real.setDeviceName(device.getName()); + // 装机容量 + real.setInstalledCapacity(device.getInstalledCapacity()); // 开关机状态 - real.setState(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY)); + real.setState(Math.abs(this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY)) > 0); // 有功功率 real.setActivePower(this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER)); // 无功功率 @@ -165,7 +170,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 当日发电量 target.setPowerDay(this.getGenerationPower(device,2)); // 当天有功功率 - target.setActivePowerVoList(waterService.getActivePowerVoList(device)); + target.setActivePowerVoList(this.getLoadsByDay(device)); // 30天发电量 target.setGenerationPowerVoList(this.getGenerationPowerList(device)); return target; @@ -178,6 +183,112 @@ public class HydropowerServiceImpl implements HydropowerService { redisTemplate.opsForValue().set(load_hydropower_unit_target_key,targets); } + + /** + * 近年发电量数据 + * + * @param param 时间 + * @param serveType 站点类型 + * @param year 近几年 + */ + @Override + public void loadPowerData(String param, List types, Integer serveType, int year) { + // 站点查询 + List stationList = stationService.getStationType(serveType, types, null); + // 设备信息 + List devices = maintenanceTaskService.getEmInfoList(); + // 开始时间 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + // 结束日期 + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + // 存储数据map :<站点id,<月份,发电量>> + Map> powerMap = new HashMap<>(); + stationList.forEach(station -> { + // 站点设备集合 + List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + Map generateMap = this.getGenerateYear(station,stationDevices,start,end); + if(MapUtils.isEmpty(generateMap)){ + return; + } + powerMap.put(station.getId(),generateMap); + }); + redisTemplate.opsForValue().set(recent_year_power_data, powerMap); + } + + + /** + * 当天有功功率 + * @param device + * @return + */ + private List getLoadsByDay(EminfoAndEmParamVo device) { + // FIXME 当天功率测试数据 + Calendar start = Calendar.getInstance(); + start.add(Calendar.HOUR_OF_DAY,-start.get(Calendar.HOUR_OF_DAY)); + List list = new ArrayList<>(); + Random random = new Random(); + while (start.getTime().compareTo(new Date()) <= 0){ + ActivePowerVo load = new ActivePowerVo(); + load.setHour(start.get(Calendar.HOUR_OF_DAY)); + load.setActivePower(String.valueOf(random.nextDouble() * 500)); + list.add(load); + start.add(Calendar.HOUR_OF_DAY,1); + } + return list; + /*String start = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; + String end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + List records = analyseDataService.periodTargetData(start, end, 1, 2, device.getEmCode(), HomePageConstant.PV_LOAD); + if (CollectionUtil.isEmpty(records)) { + return new ArrayList<>(); + } + return records.stream().map(record -> { + PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + load.setHour(DateUtil.format(time,"yyyy-mm-dd HH")); + load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); + return load; + }).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList());*/ + } + + /** + * 获取年发电量 + * @param devices + * @param start + * @param end + * @return + */ + private Map getGenerateYear(StationEntity station,List devices, String start, String end) { + List datas = new ArrayList<>(); + // 设备采集发电量 + if(CollectionUtil.isNotEmpty(devices)){ + devices.forEach(device->{ + List records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + if(CollectionUtil.isEmpty(records)){ + return; + } + datas.addAll(records.stream().map(record -> { + PowerMonthVo generate = new PowerMonthVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); + generate.setPower(Float.parseFloat(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); + return generate; + }).collect(Collectors.toList())); + }); + } + // 补充填报数据 + datas.addAll(this.generateFill(station,start,end)); + if(CollectionUtil.isEmpty(datas)){ + return null; + } + return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum)); + } + + /** * 获取填报用电量 * @param stations @@ -206,6 +317,23 @@ public class HydropowerServiceImpl implements HydropowerService { /** + * 补充填报数据 + * @param station + * @param start + * @param end + */ + private List generateFill(StationEntity station, String start, String end) { + start = DateUtil.format(DateUtil.parse(start,DateUtil.PATTERN_DATETIME),"yyyy-MM"); + end = DateUtil.format(DateUtil.parse(end,DateUtil.PATTERN_DATETIME),"yyyy-MM"); + // 光伏 + if(HomePageConstant.PHOTOVOLTAIC.equals(station.getType())){ + return photovoltaicService.generateThreeYear(start,end,station.getRefDept()); + } + // 水电 + return generateService.generateThreeYear(start,end,station.getCode()); + } + + /** * 泵站设备 * @param stations * @return @@ -236,28 +364,28 @@ public class HydropowerServiceImpl implements HydropowerService { /** * 获取监测点实时数据 - * @param em + * @param device * @param targets * @return */ - private String getSignageValue(EminfoAndEmParamVo em,Map map, String targets) { - if(ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)){ - return "0"; + private double getSignageValue(EminfoAndEmParamVo device,Map map, String targets) { + if(ObjectUtil.isEmpty(device) || MapUtils.isEmpty(map)){ + return 0.0; } - Map point = em.getPoint(); + Map point = device.getPoint(); if(MapUtils.isEmpty(point)){ - return "0"; + return 0.0; } String realId = point.get(targets); if(StringUtil.isBlank(realId)){ - return "0"; + return 0.0; } String value = map.get(realId); if(StringUtil.isBlank(value)){ - return "0"; + return 0.0; } // 获取value - return value; + return Double.parseDouble(value); } /** @@ -345,11 +473,25 @@ public class HydropowerServiceImpl implements HydropowerService { * @return */ private List getGenerationPowerList(EminfoAndEmParamVo device) { - String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); + // FIXME 测试数据 + String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH,-29); - String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); - List records = analyseDataService.periodTargetData(start,end,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + 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)); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + Random random = new Random(); + List generates = new ArrayList<>(); + if(calendar.getTime().compareTo(new Date()) <= 0){ + GenerationPowerVo generate = new GenerationPowerVo(); + generate.setDate(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE)); + generate.setGenerate(random.nextFloat() * 500000f); + generates.add(generate); + } + return generates; + + /*List records = analyseDataService.periodTargetData(start,end,EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(),5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER); if(CollectionUtil.isEmpty(records)){ return new ArrayList<>(); } @@ -359,7 +501,7 @@ public class HydropowerServiceImpl implements HydropowerService { generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); return generate; - }).collect(Collectors.toList()); + }).collect(Collectors.toList());*/ } /** @@ -388,6 +530,8 @@ public class HydropowerServiceImpl implements HydropowerService { // 七天天气 Map weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode())); HydropowerStationVo response = new HydropowerStationVo(); + // 近年发电量数据 + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); response.setDeptId(station.getRefDept()); response.setDeptName(station.getName()); response.setStationCode(station.getCode()); @@ -417,7 +561,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 水位、水位曲线 this.handleWaterLeve(station.getCode(),response); // 年发电量完成百分比 - response.setPowerYearMap(this.handlePowerFinish(station)); + response.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map)); // 设备信息 response.setDeviceList(this.getDevices(station,realList,targetList)); return response; @@ -578,7 +722,7 @@ public class HydropowerServiceImpl implements HydropowerService { if(CollectionUtil.isEmpty(realList)){ return 0.0; } - return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(o->Double.parseDouble(o.getActivePower())).sum(); + return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum(); } /** @@ -681,21 +825,18 @@ public class HydropowerServiceImpl implements HydropowerService { /** * 年发电量完成百分比 - * @param station + * @param stations */ - private List handlePowerFinish(StationEntity station) { - String code = station.getCode(); - if(StringUtil.isBlank(code)){ + private List handlePowerFinish(List stations,Map> map) { + if(CollectionUtil.isEmpty(stations)){ return null; } - // 实际发电量 - Map> powerMap = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); // 查询计划发电量 Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); - List planPowerList = planGenertionClient.getPlanPowerByYear(code,calendar.get(Calendar.YEAR)); + List plans = planGenertionClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,String.valueOf(calendar.get(Calendar.YEAR))); // 获取月份集合 - List monList = homePageService.getMonthList(0,12,false); + List monList = this.mons(0,12,false); return monList.stream().map(o->{ PowerMonthVo vo = new PowerMonthVo(); LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), o), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); @@ -703,32 +844,55 @@ public class HydropowerServiceImpl implements HydropowerService { vo.setYear(localDate.getYear()); vo.setMonth(localDate.getMonthValue()); // 实际发电量 - if(CollectionUtil.isEmpty(powerMap)){ + if(CollectionUtil.isEmpty(map)){ vo.setPower(0f); }else{ - Map map = powerMap.get(station.getId()); - if(MapUtils.isEmpty(map)){ - vo.setPower(0f); - }else{ - vo.setPower(map.get(o)); - } + float generate = (float) map.entrySet().stream(). + filter(entry->stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(entry.getKey())). + mapToDouble(valueMap-> valueMap.getValue().entrySet().stream().filter(entry->entry.getKey().equals(o)) + .mapToDouble(Map.Entry::getValue).sum()).sum(); + vo.setPower(generate); } // 计划发电量 - if(CollectionUtil.isEmpty(planPowerList)){ + if(CollectionUtil.isEmpty(plans)){ vo.setPlanPower(0f); }else{ String mon = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM")); - List list = planPowerList.stream().filter(s->mon.equals(s.getMon())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(list)){ - vo.setPlanPower(0f); - }else{ - vo.setPlanPower(list.get(0).getPlanPower()); - } + vo.setPlanPower((float)plans.stream().filter(plan->mon.equals(plan.getDateTime())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); } return vo; }).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; + } /** * 水电站站点列表 @@ -751,6 +915,8 @@ public class HydropowerServiceImpl implements HydropowerService { Map weather = this.getWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); // 七天天气 Map weekWeather = this.getWeekWeather(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + // 站点近年发电数据 key - id value - 月份,发电量 + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); return stations.stream().map(station->{ HydropowerStationVo hydropower = new HydropowerStationVo(); hydropower.setDeptId(station.getRefDept()); @@ -782,7 +948,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 水位、水位曲线 this.handleWaterLeve(station.getCode(),hydropower); // 年发电量完成百分比 - hydropower.setPowerYearMap(this.handlePowerFinish(station)); + hydropower.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map)); // 设备信息 hydropower.setDeviceList(this.getDevices(station,realList,targetList)); return hydropower; @@ -795,7 +961,224 @@ public class HydropowerServiceImpl implements HydropowerService { * @return */ @Override - public HydropowerStationVo area_target(Long deptId) { - return null; + public HydropowerScoreVo KPIs(Long deptId) { + // 查询水电站站点 + List stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.HYDROPOWER), HomePageConstant.HYDROPOWER_SERVETYPE); + if (CollectionUtil.isEmpty(stations)) { + return new HydropowerScoreVo(); + } + HydropowerScoreVo kpi = new HydropowerScoreVo(); + kpi.setDepartId(deptId); + // 站点数量 + kpi.setStationCount(stations.size()); + // 实时数据 + List deviceReals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + if (CollectionUtil.isNotEmpty(deviceReals)) { + List reals = deviceReals.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(reals)) { + // 容量 + kpi.setInstalledCapacity(reals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum()); + // 负荷 + kpi.setLoad(reals.stream().mapToDouble(HydropowerUnitRealVo::getActivePower).sum()); + // 容量利用率 + if (Math.abs(kpi.getInstalledCapacity()) <= 0) { + kpi.setCapacityRate(0.0); + }else{ + kpi.setCapacityRate(BigDecimal.valueOf(kpi.getLoad() / kpi.getInstalledCapacity() * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + } + } + // 指标数据 + List deviceTargets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + if (CollectionUtil.isNotEmpty(deviceTargets)) { + List targets = deviceTargets.stream().filter(device -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(device.getDeptId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(targets)) { + // 年发电量 + kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); + // 月发电量 + kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); + // 日发电量 + kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); + // 年计划发电量 + Double plan = planGenertionClient.getPlanPowerYear(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), DateUtil.format(new Date(),"yyyy")); + kpi.setPlan(plan); + if(Math.abs(plan) <= 0){ + kpi.setPlanRate(0.0); + }else{ + kpi.setPlanRate(BigDecimal.valueOf(kpi.getGenerateYear() / plan * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + + } + } + // 站点近年发电数据 key - id value - 月份,发电量 + Map> map = (Map>) redisTemplate.opsForValue().get(recent_year_power_data); + if (MapUtils.isEmpty(map)) { + return kpi; + } + // 今年发电趋势 + kpi.setPowerMonthVoList(this.handlePowerFinish(stations,map)); + // 近3年发电量 + kpi.setPowerYearVoList(this.generateThreeYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList()),map)); + return kpi; + } + + /** + * 水电站集团/区域指标占比 + * @param deptId + * @return + */ + @Override + public List proportion(Long deptId) { + // 获取区域或者站点map结构 + Map> areas = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); + if(MapUtils.isEmpty(areas)){ + return null; + } + List codes = new ArrayList<>(); + areas.forEach((key,value)-> codes.addAll(value.stream().map(StationEntity::getCode).collect(Collectors.toList()))); + // 获取站点编码集合 + List stations = areas.values().stream().map(values -> values.get(0).getCode()).collect(Collectors.toList()); + // 获取站点实时天气 + Map nowWeather = this.weatherService.getNowWeather(stations); + // 获取站点7日天气 + Map weekWeather = this.weatherService.getWeekWeather(stations); + // 计划发电量 + List plans = planGenertionClient.getPlanGenerationByParam(codes, null, DateUtil.format(new Date(), "yyyy")); + // 实时监测点数据 + List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + // 获取站点机组指标数据 + List targets = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + // 获取总发电量 + List monList = this.mons(0,12,false); + List scales = areas.entrySet().stream().map(entry->{ + AreaScaleVo scale = new AreaScaleVo(); + scale.setDeptId(entry.getKey().getId()); + scale.setSort(entry.getKey().getSort()); + scale.setDeptName(entry.getKey().getDeptName()); + // 天气 + this.getAreaWearther(scale,nowWeather,weekWeather,entry.getValue().get(0).getCode()); + // 指标数据: 发电量完成率 + if(CollectionUtil.isNotEmpty(targets)){ + // 当年发电量 + double generate = targets.stream().filter(target->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(target.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); + scale.setPowerYear((float) generate); + if(CollectionUtil.isNotEmpty(plans)){ + // 当年计划发电量 + double generatePlan = plans.stream().filter(plan-> entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(plan.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + if(Math.abs(generatePlan) > 0){ + scale.setGenerationRate(BigDecimal.valueOf(generate / generatePlan * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + }else{ + scale.setGenerationRate(0.0); + } + }else{ + scale.setGenerationRate(0.0); + } + + } + // 实时数据: 容量利用率、电站利用率 + if(CollectionUtil.isNotEmpty(reals)){ + // 实时功率 + double use = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum(); + if(CollectionUtil.isNotEmpty(plans)){ + // 装机容量 + double capacity = reals.stream().filter(real-> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum(); + if(Math.abs(capacity) > 0){ + scale.setCapacityUse(BigDecimal.valueOf(use / capacity * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + }else{ + scale.setCapacityUse(0.0); + } + }else{ + scale.setCapacityUse(0.0); + } + // 开机数量 + long on = reals.stream().filter(real -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId()) && real.getState()).count(); + long sum = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).count(); + if(Math.abs(sum) > 0){ + scale.setDeviceUse(BigDecimal.valueOf(on / sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + } + return scale; + }).collect(Collectors.toList()); + double generate_sum = scales.stream().mapToDouble(AreaScaleVo::getPowerYear).sum(); + // 返回结果集 + if(Math.abs(generate_sum) > 0){ + return scales.stream().peek(scale-> scale.setAreaMakeUp(BigDecimal.valueOf(scale.getPowerYear() / generate_sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue())). + /*filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0 + && Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerationRate()) > 0) + .*/sorted(Comparator.comparing(AreaScaleVo::getPowerYear).reversed()).collect(Collectors.toList()); + } + return scales.stream().peek(scale-> scale.setAreaMakeUp(0.0))./*filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0 + && Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerationRate()) > 0) + .*/sorted(Comparator.comparing(AreaScaleVo::getPowerYear).reversed()).collect(Collectors.toList()); + } + + + /** + * 区域天气 + * @param scale + * @param nowWeather + * @param weekWeather + * @param code + */ + private void getAreaWearther(AreaScaleVo scale,Map nowWeather, Map weekWeather, String code) { + // 实时天气 + if(MapUtils.isNotEmpty(nowWeather) && nowWeather.containsKey(code)){ + HeWeatherWeatherNowResponse nowData = nowWeather.get(code); + if(ObjectUtil.isNotEmpty(nowData.getNow())){ + scale.setTemp(nowData.getNow().getTemp()); + } + } + // 站点七日内天气 + if(MapUtils.isNotEmpty(weekWeather) && weekWeather.containsKey(code)){ + HeWeatherWeatherDailyResponse weekData = weekWeather.get(code); + List dailyList = weekData.getDaily(); + if (CollectionUtil.isNotEmpty(dailyList)) { + scale.setWeather(dailyList); + } + } + } + + /** + * 近3年发电量 + * @param stations + * @return + */ + private List generateThreeYear(List stations,Map> map) { + List> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(filter)) { + return new ArrayList<>(); + } + // 根据月份分组 + List powerMonthVos = new ArrayList<>(); + filter.forEach(item -> item.forEach((key, value) -> { + PowerMonthVo powerMonthVo = new PowerMonthVo(); + powerMonthVo.setStrMonth(key); + powerMonthVo.setPower(value); + powerMonthVos.add(powerMonthVo); + })); + Map> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); + // 总和所有相同月份的发电量 + List powerMonthVoList = months.entrySet().stream().map(entry -> { + PowerMonthVo powerMonth = new PowerMonthVo(); + powerMonth.setStrMonth(entry.getKey()); + LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + powerMonth.setYear(localDate.getYear()); + powerMonth.setMonth(localDate.getMonthValue()); + powerMonth.setPower((float) entry.getValue().stream().mapToDouble(PowerMonthVo::getPower).sum()); + return powerMonth; + }).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(powerMonthVoList)) { + return new ArrayList<>(); + } + // 根据年份分组 + Map> year = powerMonthVoList.stream().collect(Collectors.groupingBy(PowerMonthVo::getYear)); + // 返回结果集 + return year.entrySet().stream().map(entry -> { + PowerYearVo powerYearVo = new PowerYearVo(); + powerYearVo.setYear(entry.getKey()); + List sortValue = entry.getValue().stream().sorted(Comparator.comparing(PowerMonthVo::getMonth)).collect(Collectors.toList()); + powerYearVo.setPowerMonthVoList(sortValue); + return powerYearVo; + }).collect(Collectors.toList()); } } 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 3f4290e..d6dffbf 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 @@ -63,7 +63,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { private final IMainSystemMonitoringService deviceService; - private final ISideHustleService sideHustleService; + private final AreaService areaService; private final IWeatherService weatherService; @@ -915,7 +915,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { @Override public List subordinate(Long deptId) { // 获取区域或者站点map结构 - Map> map = sideHustleService.getAreaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); + Map> map = areaService.areaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } @@ -1063,7 +1063,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { @Override public List app_subordinate(Long deptId) { // 获取区域或者站点map结构 - Map> map = sideHustleService.getAreaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); + Map> map = areaService.areaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); if (MapUtils.isEmpty(map)) { return new ArrayList<>(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PlatformServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PlatformServiceImpl.java index b7993af..2b6b1f1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PlatformServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PlatformServiceImpl.java @@ -49,21 +49,17 @@ import com.hnac.hzinfo.sdk.core.response.Result; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; -import org.springblade.core.mp.support.BladePage; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; import org.springblade.system.cache.DictCache; import org.springblade.system.entity.Dict; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; @Service @@ -101,7 +97,7 @@ public class PlatformServiceImpl implements IPlatformService { public List doStationCount(Integer serveType) { List list = stationService.getStationTypeGroupCount(serveType); if (CollectionUtil.isNotEmpty(list)) { - list.stream().forEach(iter -> iter.setStationTypeName(DictCache.getValue("stationType", iter.getStationType()))); + list.stream().forEach(iter -> iter.setTypeName(DictCache.getValue("stationType", iter.getType()))); } return list; } @@ -124,8 +120,8 @@ public class PlatformServiceImpl implements IPlatformService { Map> map = list.stream().filter(o -> null != o.getType()).collect(Collectors.groupingBy(StationEntity::getType)); dictList.forEach(o->{ StationCountVo stationCountVo = new StationCountVo(); - stationCountVo.setStationType(o.getDictKey()); - stationCountVo.setStationTypeName(o.getDictValue()); + stationCountVo.setType(o.getDictKey()); + stationCountVo.setTypeName(o.getDictValue()); stationCountVo.setCount(0); Integer type = Integer.valueOf(o.getDictKey()); List stationEntityList = map.get(type); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/RunMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/RunMonthReportServiceImpl.java index 37a8cd2..63c2194 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/RunMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/RunMonthReportServiceImpl.java @@ -699,7 +699,8 @@ public class RunMonthReportServiceImpl extends ServiceImpl listMax = analyzeDataConditionVOMax.getList(); if (CollectionUtil.isNotEmpty(listAvg) || CollectionUtil.isNotEmpty(listMax)) { RunMonthReportUnitVo runMonthReportDataVo = new RunMonthReportUnitVo(); - String name = signKeyMap.get(analyzeDataConditionVOAvg.getSignage()); + String name = ""; + //signKeyMap.get(analyzeDataConditionVOAvg.getSignage()); runMonthReportDataVo.setName(namePerfix + name); int count = 1; Map monthValue = new LinkedHashMap<>(); @@ -814,8 +815,8 @@ public class RunMonthReportServiceImpl extends ServiceImpl areaScale(Long deptId) { + public List areaScale(Long deptId) { // 获取区域或者站点map结构 Map> map = this.getAreaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER)); if(MapUtils.isEmpty(map)){ @@ -888,9 +888,9 @@ public class SideHustleServiceImpl implements ISideHustleService { // 获取总发电量 List monList = homePageService.getMonthList(0,12,false); float sumPower = this.getSumPower(map.values(),powerMap,monList); - List list = new ArrayList<>(); + List list = new ArrayList<>(); map.forEach((key,value)->{ - AreaScaleVo areaScaleVo = new AreaScaleVo(); + OldAreaScaleVo areaScaleVo = new OldAreaScaleVo(); areaScaleVo.setDeptId(key.getId()); areaScaleVo.setSort(key.getSort()); areaScaleVo.setDeptName(key.getDeptName()); @@ -919,7 +919,7 @@ public class SideHustleServiceImpl implements ISideHustleService { this.getAreaWearther(nowWeather,weekWeather,areaScaleVo,value.get(0).getCode()); list.add(areaScaleVo); }); - return list.stream().sorted(Comparator.comparing(AreaScaleVo::getSort)).collect(Collectors.toList()); + return list.stream().sorted(Comparator.comparing(OldAreaScaleVo::getSort)).collect(Collectors.toList()); } @@ -1132,7 +1132,7 @@ public class SideHustleServiceImpl implements ISideHustleService { * @param areaScaleVo * @param code */ - private void getAreaWearther(Map nowWeather, Map weekWeather, AreaScaleVo areaScaleVo, String code) { + private void getAreaWearther(Map nowWeather, Map weekWeather, OldAreaScaleVo areaScaleVo, String code) { // 实时天气 if(MapUtils.isNotEmpty(nowWeather) && nowWeather.containsKey(code)){ HeWeatherWeatherNowResponse nowData = nowWeather.get(code); 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 76f664a..a8d255e 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 @@ -63,7 +63,7 @@ public class WaterServiceImpl implements IWaterService { private final UseService useService; - private final IHomePageService homePageService; + private final AreaService areaService; private final IStationService stationService; @@ -71,8 +71,6 @@ public class WaterServiceImpl implements IWaterService { private final IAnalyseDataService analyseDataService; - private final ISideHustleService sideHustleService; - private final IMainSystemMonitoringService maintenanceTaskService; private final IHzimsAnalyzeModelStationService modelStationService; @@ -291,7 +289,19 @@ public class WaterServiceImpl implements IWaterService { * @return */ private Map getWaterLevelMap(String instanceCode, String signage) { - LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), DateUtil.DATETIME_FORMATTER); + /** + * FIXME 水位测试数据 + */ + Calendar start = Calendar.getInstance(); + start.add(Calendar.HOUR_OF_DAY,-start.get(Calendar.HOUR_OF_DAY)); + Map map = new HashMap<>(); + Random random = new Random(); + while (start.getTime().compareTo(new Date()) <= 0){ + map.put(start.get(Calendar.HOUR_OF_DAY),String.valueOf(random.nextDouble() * 500)); + start.add(Calendar.HOUR_OF_DAY,1); + } + return map; + /*LocalDateTime beginTime = LocalDateTime.parse(DateUtil.format(new Date(), "yyyy-MM-dd 00:00:00"), DateUtil.DATETIME_FORMATTER); LocalDateTime endTime = LocalDateTime.now(); AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); List signboardConditions = new ArrayList<>(); @@ -324,7 +334,7 @@ public class WaterServiceImpl implements IWaterService { return "0"; } return value.getVal(); - })); + }));*/ } /** @@ -894,7 +904,7 @@ public class WaterServiceImpl implements IWaterService { public List waterDetails(Long deptId) { // 获取区域map : key-区域机构 value-水利站点集合 // 获取区域或者站点map结构 - Map> map = sideHustleService.getAreaOrStaion(deptId,HomePageConstant.waterList); + Map> map = areaService.areaOrStaion(deptId,HomePageConstant.waterList); if(MapUtils.isEmpty(map)){ return null; } @@ -939,7 +949,7 @@ public class WaterServiceImpl implements IWaterService { @Override public List waterUseEleRanking(Long deptId) { // 获取区域map : key-区域机构 value-水利站点集合 - Map> map = this.getAreaMap(deptId); + Map> map = areaService.areaOrStaion(deptId,HomePageConstant.waterList); if(MapUtils.isEmpty(map)){ return null; } @@ -1310,7 +1320,7 @@ public class WaterServiceImpl implements IWaterService { //double yearRunTime = validTaget.stream().max(Comparator.comparing(WaterPumpTargetVo::getRunDurationYear)).get().getRunDurationYear(); response.setRunDurationYear(yearRunTime); // 水位曲线/年用电量 - List monList = homePageService.getMonthList(0,12,false); + List monList = this.mons(0,12,false); List waterLevelPowerYearVoList = new ArrayList<>(); monList.forEach(mon->{ WaterLevelPowerYearVo WPYearVo = new WaterLevelPowerYearVo(); @@ -1326,6 +1336,36 @@ public class WaterServiceImpl implements IWaterService { } /** + * 获取近年月份集合 + * @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; + } + + /** * 区域(泵站利用率、容量利用率) * @param value * @param vo @@ -1517,58 +1557,5 @@ public class WaterServiceImpl implements IWaterService { return null; } - /** - * 获取区域节点 key-区域对象 value-站点集合 - * @param deptId - * @return - */ - private Map> getAreaMap(Long deptId) { - //根据用户权限获取机构 - R> R = sysClient.getDeptByCurrentUser(); - if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { - return null; - } - Dept title = this.getTitleDetp(deptId); - if(ObjectUtil.isEmpty(title)){ - return null; - } - Integer type = title.getDeptCategory(); - if(ObjectUtil.isEmpty(type)){ - return null; - } - Map> map = new HashMap<>(); - switch (type){ - case 1: - case 2: - this.areaMapHandle(R.getData(),title.getId(),map); - break; - case 3: - List stationList = stationService.getStationList(R.getData(),title.getId(),HomePageConstant.waterList,HomePageConstant.HYDROPOWER_SERVETYPE); - if(CollectionUtil.isEmpty(stationList)){ - return null; - } - map.put(title,stationList); - break; - default: - return null; - } - return map; - } - /** - * 区域map处理 - * @param deptList - * @param deptId - * @param map - */ - private void areaMapHandle(List deptList,Long deptId,Map> map) { - List list = homePageService.getChildArea(deptList,deptId,new ArrayList<>()); - list.forEach(dept->{ - List stationList = stationService.getStationList(deptList,dept.getId(),HomePageConstant.waterList,HomePageConstant.HYDROPOWER_SERVETYPE); - if(CollectionUtil.isEmpty(stationList)){ - return; - } - map.put(dept,stationList); - }); - } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/ImsDeptController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/ImsDeptController.java index 66da705..87f3bd1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/ImsDeptController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/ImsDeptController.java @@ -15,7 +15,6 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.system.entity.Dept; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IImsDeptService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IImsDeptService.java index f1f89f6..912d3b4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IImsDeptService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IImsDeptService.java @@ -28,5 +28,5 @@ public interface IImsDeptService extends IService { List getHydropowerTree(Integer stationType,Integer serveType); - List getTypeArea(Integer typeArea,Long deptId); + List getTypeArea(Integer typeArea, Long deptId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/ImsDeptServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/ImsDeptServiceImpl.java index 12fcb92..37581ed 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/ImsDeptServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/ImsDeptServiceImpl.java @@ -1,7 +1,6 @@ package com.hnac.hzims.operational.station.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.operational.main.service.IHomePageService; import com.hnac.hzims.operational.main.service.IWaterService; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.ImsDeptEntity; @@ -36,8 +35,9 @@ import java.util.stream.Collectors; public class ImsDeptServiceImpl extends ServiceImpl implements IImsDeptService { private final ISysClient sysClient; + private final IStationService stationService; - private final IHomePageService homePageService; + private final IWaterService waterService; @@ -359,7 +359,34 @@ public class ImsDeptServiceImpl extends ServiceImpl paramList = homePageService.getChildArea(list,dept.getId(),new ArrayList<>()); + List paramList = this.child(list,dept.getId(),new ArrayList<>()); return paramList.stream().map(Dept::getId).collect(Collectors.toList()); } + + + /** + * 递归取子区域 + * @param departList + * @param deptId + * @param list + * @return + */ + private List child(List departList, Long deptId, List list) { + if (ObjectUtil.isEmpty(deptId) || CollectionUtil.isEmpty(departList)) { + return null; + } + departList.forEach(dept -> { + Integer type = dept.getDeptCategory(); + if(ObjectUtil.isEmpty(type) || type.equals(HomePageConstant.STATION)){ + return; + } + if(dept.getParentId().equals(deptId)){ + if (dept.getDeptCategory().equals(HomePageConstant.AREA)) { + list.add(dept); + } + child(departList, dept.getId(), list); + } + }); + return list; + } }