From 30b7bd603e2735acc341b614f5df287ab1d64ac3 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 13 Apr 2023 14:34:59 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=B3=B5=E7=AB=99=E3=80=81=E5=85=89=E4=BC=8F?= =?UTF-8?q?=E5=8F=91=E7=94=B5=E9=87=8F=E3=80=81=E7=94=A8=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alert/constants/AbnormalAlarmConstant.java | 7 +- .../hzims/operational/alert/vo/SoeParamVo.java | 29 + .../hzims/operational/alert/vo/SoeReustVo.java | 31 + .../operational/fill/entity/GenerateEntity.java | 2 +- .../hzims/operational/fill/entity/UseEntity.java | 2 +- .../hnac/hzims/operational/fill/vo/QueryVo.java | 8 + .../operational/main/vo/GenerationPowerVo.java | 4 + .../operational/main/vo/PhotovoltaicDeviceVo.java | 50 +- .../operational/main/vo/PhotovoltaicTargetVo.java | 1 + .../operational/station/StationConstants.java | 2 + .../alert/controller/AbnormalAlarmController.java | 16 +- .../alert/service/HistoryAbnormalAlarmService.java | 4 + .../impl/HistoryAbnormalAlarmServiceImpl.java | 62 +- .../operational/fill/mapper/GenerateMapper.java | 4 + .../operational/fill/mapper/GenerateMapper.xml | 8 + .../operational/fill/service/GenerateService.java | 6 + .../operational/fill/service/PowerService.java | 8 + .../hzims/operational/fill/service/UseService.java | 12 + .../fill/service/impl/GenerateServiceImpl.java | 40 ++ .../fill/service/impl/PowerServiceImpl.java | 59 ++ .../fill/service/impl/UseServiceImpl.java | 84 ++- .../main/controller/HydropowerController.java | 1 - .../main/controller/WebHomeController.java | 4 +- .../main/scheduled/ScheduledCreateTask.java | 14 +- .../main/service/HydropowerService.java | 22 + .../operational/main/service/IWaterService.java | 2 +- .../operational/main/service/IWebHomeService.java | 23 - .../main/service/impl/HomePageServiceImpl.java | 90 ++- .../main/service/impl/HydropowerServiceImpl.java | 743 ++++++++++++++++++++ .../main/service/impl/PhotovoltaicServiceImpl.java | 60 +- .../main/service/impl/WaterServiceImpl.java | 282 ++++---- .../main/service/impl/WebHomeServiceImpl.java | 744 --------------------- .../service/IOperMaintenanceTaskService.java | 8 +- .../station/service/impl/ImsDeptServiceImpl.java | 2 +- 34 files changed, 1452 insertions(+), 982 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeParamVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeReustVo.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java delete mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWebHomeService.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java delete mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java index 6835eba..1bdcfb6 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/constants/AbnormalAlarmConstant.java @@ -13,8 +13,13 @@ public interface AbnormalAlarmConstant { /**通讯恢复*/ String ABNORMAL_STATUS = "1"; - String TYPE_NAMES[] = {"默认", "系统", "告警", "故障", "用户操作", "遥测越限", "遥信变位", "注册信息", "信息提示", "设备巡检", "遥控操作", "遥测越限恢复","未定义","通讯中断","数据异常"}; + String[] TYPE_NAMES = {"默认", "系统", "告警", "故障", "用户操作", "遥测越限", "遥信变位", "注册信息", "信息提示", "设备巡检", "遥控操作", "遥测越限恢复","未定义","通讯中断","数据异常"}; /**处理、延后、误报*/ List HANDLE_WAY = Arrays.asList(1L,2L,3L,4L); + + /** + * 2-告警,3-故障,5-遥测越限,13-通讯异常,14-数据异常 + */ + List SOE_TYPE_LIST = Arrays.asList(2,3,5,13,14); } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeParamVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeParamVo.java new file mode 100644 index 0000000..2f9d104 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeParamVo.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.operational.alert.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + * @date 2023/03/23 13:34:37 + * @version 4.0.0 + */ +@Data +public class SoeParamVo { + + @ApiModelProperty(value = "站点编码") + private String code; + + @ApiModelProperty(value = "查询开始时间:yyyy-MM-dd HH:mm:ss") + private String date; + + @ApiModelProperty(value = "2-告警,3-故障,5-遥测越限,13-通讯异常,14-数据异常") + private Integer type; + + @ApiModelProperty(value = "当前页码") + private Integer current; + + + @ApiModelProperty(value = "每页条目") + private Integer size; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeReustVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeReustVo.java new file mode 100644 index 0000000..379542d --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/alert/vo/SoeReustVo.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.operational.alert.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + * @date 2023/03/23 13:34:37 + * @version 4.0.0 + */ +@Data +public class SoeReustVo { + + @ApiModelProperty(value = "最新的时间") + private String date; + + @ApiModelProperty(value = "告警数据") + private List soeList; + + @ApiModelProperty(value = "数量统计") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Integer count; + + @ApiModelProperty(value = "总条数") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long total; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/GenerateEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/GenerateEntity.java index 52c1bea..9e3c7f0 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/GenerateEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/GenerateEntity.java @@ -26,7 +26,7 @@ public class GenerateEntity extends TenantEntity implements Serializable { private String dataOrigin; @ApiModelProperty("发电量") - private BigDecimal generate; + private Double generate; @ApiModelProperty("填报月份") private String fillDate; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/UseEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/UseEntity.java index 6ae9334..f097c8d 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/UseEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/entity/UseEntity.java @@ -26,7 +26,7 @@ public class UseEntity extends TenantEntity implements Serializable { private String dataOrigin; @ApiModelProperty("发电量") - private BigDecimal use; + private Double employ; @ApiModelProperty("填报月份") private String fillDate; 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 42cde47..01c68fc 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 @@ -5,6 +5,11 @@ import lombok.Data; import java.util.Date; +/** + * @author ysj + * @date 2023/04/10 11:16:07 + * @version 4.0.0 + */ @Data public class QueryVo{ @@ -19,4 +24,7 @@ public class QueryVo{ @ApiModelProperty("设备编号") private String deviceCode; + + @ApiModelProperty("站点接入类型") + private String dataOrigin; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java index b744dba..854a5d5 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/GenerationPowerVo.java @@ -1,5 +1,7 @@ package com.hnac.hzims.operational.main.vo; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -12,8 +14,10 @@ public class GenerationPowerVo { private String date; @ApiModelProperty(value = "发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) private Float generate; @ApiModelProperty(value = "功率·") + @JsonSerialize(nullsUsing = NullSerializer.class) private Float load; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java index b81247b..68bf536 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicDeviceVo.java @@ -198,101 +198,103 @@ public class PhotovoltaicDeviceVo { private Double dc_voltage_twelve; - @ApiModelProperty(value = "直流电流1") + @ApiModelProperty(value = "串流电流1") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_one; - @ApiModelProperty(value = "直流电流2") + @ApiModelProperty(value = "串流电流2") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_two; - @ApiModelProperty(value = "直流电流3") + @ApiModelProperty(value = "串流电流3") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_three; - @ApiModelProperty(value = "直流电流4") + @ApiModelProperty(value = "串流电流4") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_four; - @ApiModelProperty(value = "直流电流5") + @ApiModelProperty(value = "串流电流5") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_five; - @ApiModelProperty(value = "直流电流6") + @ApiModelProperty(value = "串流电流6") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_six; - @ApiModelProperty(value = "直流电流7") + @ApiModelProperty(value = "串流电流7") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_seven; - @ApiModelProperty(value = "直流电流8") + @ApiModelProperty(value = "串流电流8") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_eight; - @ApiModelProperty(value = "直流电流9") + @ApiModelProperty(value = "串流电流9") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_nine; - @ApiModelProperty(value = "直流电流10") + @ApiModelProperty(value = "串流电流10") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_ten; - @ApiModelProperty(value = "直流电流11") + @ApiModelProperty(value = "串流电流11") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_eleven; - @ApiModelProperty(value = "直流电流12") + @ApiModelProperty(value = "串流电流12") @JsonSerialize(nullsUsing = NullSerializer.class) private Double series_twelve; - @ApiModelProperty(value = "直流电压1") + + + @ApiModelProperty(value = "串流电压1") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_one; - @ApiModelProperty(value = "直流电压2") + @ApiModelProperty(value = "串流电压2") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_two; - @ApiModelProperty(value = "直流电压3") + @ApiModelProperty(value = "串流电压3") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_three; - @ApiModelProperty(value = "直流电压4") + @ApiModelProperty(value = "串流电压4") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_four; - @ApiModelProperty(value = "直流电压5") + @ApiModelProperty(value = "串流电压5") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_five; - @ApiModelProperty(value = "直流电压6") + @ApiModelProperty(value = "串流电压6") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_six; - @ApiModelProperty(value = "直流电压7") + @ApiModelProperty(value = "串流电压7") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_seven; - @ApiModelProperty(value = "直流电压8") + @ApiModelProperty(value = "串流电压8") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_eight; - @ApiModelProperty(value = "直流电压9") + @ApiModelProperty(value = "串流电压9") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_nine; - @ApiModelProperty(value = "直流电压10") + @ApiModelProperty(value = "串流电压10") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_ten; - @ApiModelProperty(value = "直流电压11") + @ApiModelProperty(value = "串流电压11") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_eleven; - @ApiModelProperty(value = "直流电压12") + @ApiModelProperty(value = "串流电压12") @JsonSerialize(nullsUsing = NullSerializer.class) private Double se_voltage_twelve; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicTargetVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicTargetVo.java index 3562934..557b706 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicTargetVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/PhotovoltaicTargetVo.java @@ -25,6 +25,7 @@ public class PhotovoltaicTargetVo { private String deviceName; @ApiModelProperty(value = "当日运行时长") + @JsonSerialize(nullsUsing = NullSerializer.class) private Double runHours; @ApiModelProperty(value = "年发电量: kWh") diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java index 8f9da7f..48ad9d1 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/StationConstants.java @@ -20,6 +20,8 @@ public interface StationConstants { //自动添加或修改机构数据 String TASK_VALUE_IMS_DEPT_CREATE = "imsDeptCreate"; + String DATA_ORIGIN_FILL = "1"; + enum DeptCategoryEnum { STATION(4,"站点") ; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java index 5af23db..e5c525b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/controller/AbnormalAlarmController.java @@ -7,6 +7,8 @@ import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService; import com.hnac.hzims.operational.alert.vo.AlarmParamVo; import com.hnac.hzims.operational.alert.vo.AlarmReustVo; +import com.hnac.hzims.operational.alert.vo.SoeParamVo; +import com.hnac.hzims.operational.alert.vo.SoeReustVo; import com.hnac.hzims.operational.config.vo.*; import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo; import io.swagger.annotations.Api; @@ -112,7 +114,7 @@ public class AbnormalAlarmController extends BladeController { * */ @ApiLog - @ApiOperation(value = "智能优化接口") + @ApiOperation(value = "原始告警接口") @ApiOperationSupport(order = 7) @RequestMapping(value = "/alarms", method = {RequestMethod.GET, RequestMethod.POST}) public R alarms(AlarmParamVo param){ @@ -120,6 +122,18 @@ public class AbnormalAlarmController extends BladeController { } /** + * + */ + @ApiLog + @ApiOperation(value = "等级告警接口") + @ApiOperationSupport(order = 7) + @RequestMapping(value = "/terrace_alarms", method = {RequestMethod.GET, RequestMethod.POST}) + public R terrace_alarms(SoeParamVo param){ + return R.data(service.terrace_alarms(param)); + } + + + /** * 智能告警数量: 时间范围当天 */ @ApiLog 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 ac56340..94ec897 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 @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.vo.AlarmParamVo; import com.hnac.hzims.operational.alert.vo.AlarmReustVo; +import com.hnac.hzims.operational.alert.vo.SoeParamVo; +import com.hnac.hzims.operational.alert.vo.SoeReustVo; import com.hnac.hzims.operational.config.vo.*; import com.hnac.hzims.operational.station.vo.HistoryAbnormalAlarmVo; import org.springblade.core.mp.base.BaseService; @@ -33,4 +35,6 @@ public interface HistoryAbnormalAlarmService extends BaseService alarmData(AlarmDataPageVo page,Query query); List queryStationName(); + + SoeReustVo terrace_alarms(SoeParamVo param); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java index 3c615b6..8d1cb2a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java @@ -4,17 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.fasterxml.jackson.core.type.TypeReference; import com.hnac.hzims.operational.alert.constants.AbnormalAlarmConstant; import com.hnac.hzims.operational.alert.entity.AlarmHandleEntity; import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity; import com.hnac.hzims.operational.alert.mapper.HistoryAbnormalAlarmMapper; import com.hnac.hzims.operational.alert.service.AlarmHandleService; import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService; -import com.hnac.hzims.operational.alert.vo.AlarmDataVo; -import com.hnac.hzims.operational.alert.vo.AlarmParamVo; -import com.hnac.hzims.operational.alert.vo.AlarmReustVo; -import com.hnac.hzims.operational.config.vo.*; +import com.hnac.hzims.operational.alert.vo.*; +import com.hnac.hzims.operational.config.vo.AlarmDataPageVo; +import com.hnac.hzims.operational.config.vo.AlarmVo; +import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; @@ -24,7 +23,9 @@ import com.hnac.hzinfo.datasearch.soe.domian.SoeData; import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; -import com.hnac.hzinfo.sdk.core.utils.JsonUtil; +import com.hnac.hzinfo.sdk.v5.soe.SoeClient; +import com.hnac.hzinfo.sdk.v5.soe.dto.SoeDTO; +import com.hnac.hzinfo.sdk.v5.soe.vo.SoeVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.logstash.logback.encoder.org.apache.commons.lang3.ObjectUtils; @@ -60,6 +61,9 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl wrapper = Wrappers.lambdaQuery(); + if(StringUtils.isNotEmpty(param.getCode())){ + wrapper.eq(StationEntity::getCode,param.getCode()); + } + List stations = stationService.list(wrapper); + if(CollectionUtil.isEmpty(stations)){ + return new SoeReustVo(); + } + // 参数设置 + SoeDTO soe_params = new SoeDTO(); + //soe_params.setProjectId(); + String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"; + String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME) + " 00:00:00"; + soe_params.setBeginTime(DateUtil.parse(start,DateUtil.PATTERN_DATETIME)); + soe_params.setEndTime(DateUtil.parse(end,DateUtil.PATTERN_DATETIME)); + soe_params.setNeedPage(true); + soe_params.setPage(param.getCurrent()); + soe_params.setPageSize(param.getSize()); + if(ObjectUtil.isEmpty(param.getType())){ + soe_params.setTypes(AbnormalAlarmConstant.SOE_TYPE_LIST); + }else{ + soe_params.setTypes(Collections.singletonList(param.getType())); + } + // 查询等级告警数据 + Result> soes = soeClient.pageQuery(soe_params); + if(!soes.isSuccess() || ObjectUtil.isEmpty(soes.getData())){ + return new SoeReustVo(); + } + List handles = this.getAlarmHandleIds(); + + + return null; + } + + + /** * 获取处理数据ID集合 * @return */ @@ -372,7 +419,7 @@ public class HistoryAbnormalAlarmServiceImpl extends BaseServiceImpl { + List records(@Param("date") String date,@Param("station") String station); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/GenerateMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/GenerateMapper.xml index d937e42..67d0642 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/GenerateMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/mapper/GenerateMapper.xml @@ -1,4 +1,12 @@ + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java index 0bd1f45..8e7bcfe 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java @@ -6,10 +6,13 @@ import com.hnac.hzims.operational.fill.entity.RainfallEntity; import com.hnac.hzims.operational.fill.vo.GenerateVo; import com.hnac.hzims.operational.fill.vo.QueryVo; import com.hnac.hzims.operational.fill.vo.RainfallVo; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import java.util.List; + /** * @author ysj * @date 2023/04/10 11:16:07 @@ -22,4 +25,7 @@ public interface GenerateService extends BaseService { // 新增/修改发电量填报数据 boolean saveUpdate(GenerateEntity entity); + + // 获取站点填报发电量 + List generateThreeYear(String start, String end, String station); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/PowerService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/PowerService.java index b1aea53..6ff6d55 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/PowerService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/PowerService.java @@ -3,10 +3,14 @@ package com.hnac.hzims.operational.fill.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.fill.entity.PowerEntity; import com.hnac.hzims.operational.fill.vo.PowerVo; +import com.hnac.hzims.operational.main.vo.GenerationPowerVo; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import java.util.List; + /** * 其他填报接口 */ @@ -17,4 +21,8 @@ public interface PowerService extends BaseService { R upd(PowerEntity entity); R> pageCondition(PowerVo vo, Query query); + + Double generate(String date,Long station); + + List generateThreeYear(String start,String end,Long station); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/UseService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/UseService.java index e25c60e..e80d319 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/UseService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/UseService.java @@ -4,10 +4,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.fill.entity.UseEntity; import com.hnac.hzims.operational.fill.vo.QueryVo; import com.hnac.hzims.operational.fill.vo.UseVo; +import com.hnac.hzims.operational.main.vo.UsrPowerVo; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import java.util.List; +import java.util.Map; + /** * @author ysj * @date 2023/04/10 11:16:07 @@ -20,4 +24,12 @@ public interface UseService extends BaseService { // 新增/修改用电量填报数据 boolean saveUpdate(UseEntity entity); + + // 查询填报用电量 + Float use(String date,String station); + + // 查询30天填报用电量 + List use30Day(String day, String station); + + Map generateThreeYear(String start, String end, String station); } 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 1d1e2ae..6ff4613 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 @@ -3,12 +3,14 @@ package com.hnac.hzims.operational.fill.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.operational.fill.entity.GenerateEntity; import com.hnac.hzims.operational.fill.mapper.GenerateMapper; import com.hnac.hzims.operational.fill.service.GenerateService; import com.hnac.hzims.operational.fill.vo.GenerateVo; import com.hnac.hzims.operational.fill.vo.QueryVo; import com.hnac.hzims.operational.fill.wrapper.GenerateWrapper; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -16,11 +18,15 @@ import org.springblade.core.mp.base.BaseServiceImpl; 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.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * @author ysj @@ -50,6 +56,9 @@ public class GenerateServiceImpl extends BaseServiceImpl generateThreeYear(String start, String end, String station) { + List records = this.list(Wrappers.lambdaQuery() + .eq(GenerateEntity::getStationCode,station) + .between(GenerateEntity::getFillDate,start,end) + ); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + // 返回结果 + return records.stream().peek( + record-> record.setFillDate(DateUtil.format(DateUtil.parse(record.getFillDate(),"yyyy-MM"),"yyyy-MM") + "-01") + ).collect(Collectors.toMap(GenerateEntity::getFillDate,GenerateEntity::getGenerate,Double::sum)). + entrySet().stream().map(entry->{ + PowerMonthVo mon = new PowerMonthVo(); + mon.setStrMonth(entry.getKey()); + if(Math.abs(entry.getValue()) <= 0){ + mon.setPower(0f); + }else{ + mon.setPower(Float.parseFloat(entry.getValue().toString())); + } + return mon; + }).collect(Collectors.toList()); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/PowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/PowerServiceImpl.java index 091e690..eb6a697 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/PowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/PowerServiceImpl.java @@ -1,12 +1,16 @@ package com.hnac.hzims.operational.fill.service.impl; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.operational.fill.entity.PowerEntity; import com.hnac.hzims.operational.fill.mapper.PowerMapper; import com.hnac.hzims.operational.fill.service.PowerService; import com.hnac.hzims.operational.fill.vo.PowerVo; import com.hnac.hzims.operational.fill.wrapper.PowerWrapper; +import com.hnac.hzims.operational.main.vo.GenerationPowerVo; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; @@ -14,12 +18,16 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; @Slf4j @@ -97,4 +105,55 @@ public class PowerServiceImpl extends BaseServiceImpl return R.data(pages.setRecords(list)); } + /** + * 根据时间、机构查询发电量 + * @param date 时间: 年 - yyyy/月 yyyy-mm/日 yyyy-mm-dd + * @param station 所属机构 + * @return + */ + @Override + public Double generate(String date, Long station) { + List powers = this.list(Wrappers.lambdaQuery() + .likeRight(PowerEntity::getMon,date) + .eq(PowerEntity::getCreateDept,station) + // 类型: 光伏 + .eq(PowerEntity::getType,1) + ); + if(CollectionUtil.isEmpty(powers)){ + return 0.0; + } + return powers.stream().mapToDouble(PowerEntity::getPowerMon).sum(); + } + + /** + * + * @param start 开始时间 : yyyy-mm + * @param end 结束时间 : yyyy-mm + * @param station 所属机构 + * @return + */ + @Override + public List generateThreeYear(String start, String end, Long station) { + List fills = this.list(Wrappers.lambdaQuery() + .between(PowerEntity::getMon,start,end) + .eq(PowerEntity::getCreateDept,station) + // 类型: 光伏 + .eq(PowerEntity::getType,1) + ); + if(CollectionUtil.isEmpty(fills)){ + return new ArrayList<>(); + + } + return fills.stream().map(fill->{ + PowerMonthVo mon = new PowerMonthVo(); + mon.setStrMonth(DateUtil.format(DateUtil.parse(fill.getMon(),"yyyy-MM"),DateUtil.PATTERN_DATE)); + if(Math.abs(fill.getPowerMon()) <= 0){ + mon.setPower(0f); + }else{ + mon.setPower(Float.parseFloat(fill.getPowerMon().toString())); + } + return mon; + }).collect(Collectors.toList()); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java index 5093822..4488e91 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/UseServiceImpl.java @@ -3,12 +3,17 @@ package com.hnac.hzims.operational.fill.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.operational.fill.entity.GenerateEntity; +import com.hnac.hzims.operational.fill.entity.PowerEntity; import com.hnac.hzims.operational.fill.entity.UseEntity; import com.hnac.hzims.operational.fill.mapper.UseMapper; import com.hnac.hzims.operational.fill.service.UseService; import com.hnac.hzims.operational.fill.vo.QueryVo; import com.hnac.hzims.operational.fill.vo.UseVo; import com.hnac.hzims.operational.fill.wrapper.UseWrapper; +import com.hnac.hzims.operational.main.vo.PowerMonthVo; +import com.hnac.hzims.operational.main.vo.UsrPowerVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; @@ -16,11 +21,14 @@ import org.springblade.core.mp.base.BaseServiceImpl; 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.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * @author ysj @@ -50,6 +58,9 @@ public class UseServiceImpl extends BaseServiceImpl implem if(!ObjectUtil.isEmpty(filter.getEndTime())){ le("FILL_DATE",filter.getEndTime()); } + if(!ObjectUtil.isEmpty(filter.getDataOrigin())){ + eq("DATA_ORIGIN",filter.getDataOrigin()); + } orderByDesc("create_time"); }}; IPage pages = super.page(Condition.getPage(query), queryWrapper); @@ -78,4 +89,75 @@ public class UseServiceImpl extends BaseServiceImpl implem return this.updateById(entity); } + /** + * 根据时间、机构查询用电量 + * @param date 时间: 年 - yyyy/月 yyyy-mm/日 yyyy-mm-dd + * @param station 所属机构 + * @return + */ + @Override + public Float use(String date, String station) { + List powers = this.list(Wrappers.lambdaQuery() + .likeRight(UseEntity::getFillDate,date) + .eq(UseEntity::getStationCode,station) + ); + if(CollectionUtil.isEmpty(powers)){ + return 0f; + } + return (float) powers.stream().mapToDouble(UseEntity::getEmploy).sum(); + } + + /** + * 查询30天填报用电量 + * @param day : 结束日期 yyyy-MM-dd + * @param station 站点编码 + * @return + */ + @Override + public List use30Day(String day, String station) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse(day,DateUtil.PATTERN_DATE)); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + calendar.add(Calendar.DAY_OF_MONTH,-29); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + List records = this.list(Wrappers.lambdaQuery() + .between(UseEntity::getFillDate,start,end) + .eq(UseEntity::getStationCode,station) + ); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + return records.stream().map(record->{ + UsrPowerVo use = new UsrPowerVo(); + use.setDate(record.getFillDate()); + if(Math.abs(record.getEmploy()) <= 0){ + use.setUsrPower(0f); + }else{ + use.setUsrPower(Float.parseFloat(record.getEmploy().toString())); + } + return use; + }).collect(Collectors.toList()); + } + + /** + * 查询近3年的填报用电量 + * @param start + * @param end + * @param station + * @return + */ + @Override + public Map generateThreeYear(String start, String end, String station) { + List records = this.list(Wrappers.lambdaQuery() + .between(UseEntity::getFillDate,start,end) + .eq(UseEntity::getStationCode,station) + ); + if(CollectionUtil.isEmpty(records)){ + return new HashMap<>(); + + } + return records.stream().peek(record-> record.setFillDate(DateUtil.format(DateUtil.parse(record.getFillDate(),"yyyy-MM"),"yyyy-MM") + "-01")). + collect(Collectors.toMap(UseEntity::getFillDate, value->Float.parseFloat(value.getEmploy().toString()),Float::sum)); + } + } 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 d542570..666b45c 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 @@ -88,7 +88,6 @@ public class HydropowerController extends BladeController { - @ApiLog @ApiOperation("计划发电趋势") @GetMapping("/planGenerationTrend") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WebHomeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WebHomeController.java index db9ee80..c7a5096 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WebHomeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WebHomeController.java @@ -1,7 +1,7 @@ package com.hnac.hzims.operational.main.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.operational.main.service.IWebHomeService; +import com.hnac.hzims.operational.main.service.HydropowerService; import com.hnac.hzims.operational.main.vo.HydropowerStationVo; import com.hnac.hzims.operational.main.vo.HydropowerUnitVo; import io.swagger.annotations.Api; @@ -23,7 +23,7 @@ import java.util.List; @AllArgsConstructor public class WebHomeController extends BladeController { - private final IWebHomeService service; + private final HydropowerService service; @ApiLog @ApiOperation("水电站站点统计") @GetMapping("/webStation") 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 b681a2f..08e591d 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 @@ -13,7 +13,6 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.Arrays; @@ -44,7 +43,7 @@ public class ScheduledCreateTask { @Autowired private IAreaMonthReportService reportService; @Autowired - private IWebHomeService webHomeService; + private HydropowerService hydropowerService; @Autowired private PhotovoltaicService photovoltaicService; @Autowired @@ -169,10 +168,9 @@ public class ScheduledCreateTask { * 获取站点近3年发电量数据 * @return ReturnT */ - //@XxlJob(ELECTRICITY_GENERATION_RECENT_YEAR) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT powerGenerationRecentYear() throws Exception { - String param = ""; + @XxlJob(ELECTRICITY_GENERATION_RECENT_YEAR) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT powerGenerationRecentYear(String param) throws Exception { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -274,7 +272,7 @@ public class ScheduledCreateTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - webHomeService.loadHydropowerReal(param); + hydropowerService.loadHydropowerReal(param); return new ReturnT<>("SUCCESS"); } @@ -288,7 +286,7 @@ public class ScheduledCreateTask { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } - webHomeService.loadHydropowerTarget(param); + hydropowerService.loadHydropowerTarget(param); return new ReturnT<>("SUCCESS"); } 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 new file mode 100644 index 0000000..b7a0576 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.operational.main.service; + +import com.hnac.hzims.operational.main.vo.HydropowerStationVo; +import com.hnac.hzims.operational.main.vo.HydropowerUnitVo; + +import java.util.List; + +/** + * WEB水电站首页接口 + */ +public interface HydropowerService { + + void loadHydropowerReal(String param); + + void loadHydropowerTarget(String param); + + HydropowerStationVo webStation(Long deptId); + + List hydropowerDevice(Long deptId); + + List webStationList(Long deptId); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWaterService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWaterService.java index 6de994a..c0ff232 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWaterService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWaterService.java @@ -27,7 +27,7 @@ public interface IWaterService { List waterYearRain(Long deptId); - Dept getTitleDetp(List authList, Long deptId); + Dept getTitleDetp(Long deptId); WaterStationVo waterStationPage(Long deptId); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWebHomeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWebHomeService.java deleted file mode 100644 index c09cf15..0000000 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWebHomeService.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.hnac.hzims.operational.main.service; - -import com.hnac.hzims.operational.main.vo.HydropowerStationVo; -import com.hnac.hzims.operational.main.vo.HydropowerUnitVo; -import com.hnac.hzims.operational.main.vo.WaterStationVo; - -import java.util.List; - -/** - * WEB水电站首页接口 - */ -public interface IWebHomeService { - - void loadHydropowerReal(String param); - - void loadHydropowerTarget(String param); - - HydropowerStationVo webStation(Long deptId); - - List hydropowerDevice(Long deptId); - - List webStationList(Long deptId); -} 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 a2b0b17..7d82b1b 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 @@ -65,22 +65,40 @@ import java.util.stream.Collectors; @Slf4j public class HomePageServiceImpl implements IHomePageService { - private final IAnalyseDataService analyseDataService; - private final IPlanGenertionClient planGenertionClient; - private final IMainSystemMonitoringService maintenanceTaskService; - private final IMainTaskStatisticService mainTaskStatisticService; private final IStationService stationService; + private final PowerService powerService; + private final OverService overService; - private final OverDetailsService overDetailsService; + private final SolveService solveService; + private final OtherService otherService; + + private final OverDetailsService overDetailsService; + + private final IAnalyseDataService analyseDataService; + + private final PowerService photovoltaicService; + + private final GenerateService hydropowerService; + + private final IMainSystemMonitoringService maintenanceTaskService; + + private final IMainTaskStatisticService mainTaskStatisticService; + private final ISysClient sysClient; + private final ISoeClient soeClient; + + private final IPlanGenertionClient planGenertionClient; + private final ITicketInfoAllClient ticketInfoAllClient; - private final RedisTemplate redisTemplate; + private final IAnalyseInstanceClient analyseInstanceClient; + private final RedisTemplate redisTemplate; + private final static String KEY_INDICATORS_INFO = "hzims:operation:key:indicators:info"; private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; @@ -154,6 +172,8 @@ public class HomePageServiceImpl implements IHomePageService { // 充电桩 case 7: break; + default: + break; } }); redisTemplate.opsForValue().set(KEY_INDICATORS_INFO, keyIndicatorsVo); @@ -237,10 +257,7 @@ public class HomePageServiceImpl implements IHomePageService { stationList.forEach(station -> { // 站点设备集合 List stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(stationDevices)){ - return; - } - Map generateMap = this.getGenerateYear(stationDevices,start,end); + Map generateMap = this.getGenerateYear(station,stationDevices,start,end); if(MapUtils.isEmpty(generateMap)){ return; } @@ -256,26 +273,47 @@ public class HomePageServiceImpl implements IHomePageService { * @param end * @return */ - private Map getGenerateYear(List devices, String start, String end) { + private Map getGenerateYear(StationEntity station,List devices, String start, String end) { List datas = new ArrayList<>(); - 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.valueOf(Optional.ofNullable(record.getVal()).orElse("0")) * device.getRideCount()); - return generate; - }).collect(Collectors.toList())); - }); + // 设备采集发电量 + 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.groupingBy(PowerMonthVo::getStrMonth, Collectors.collectingAndThen( - Collectors.mapping(PowerMonthVo::getPower, Collectors.reducing(Float::sum)),Optional::get))); + return datas.stream().collect(Collectors.toMap(PowerMonthVo::getStrMonth, PowerMonthVo::getPower, Float::sum)); + } + + /** + * 补充填报数据 + * @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 hydropowerService.generateThreeYear(start,end,station.getCode()); } /** 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 new file mode 100644 index 0000000..8393825 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -0,0 +1,743 @@ +package com.hnac.hzims.operational.main.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.hnac.hzims.EquipmentConstants; +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.main.service.*; +import com.hnac.hzims.operational.main.vo.*; +import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationAttributeService; +import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.soe.ISoeClient; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import lombok.RequiredArgsConstructor; +import org.apache.commons.collections4.MapUtils; +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.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +/** + * APP首页实现类 + */ +@Service +@RequiredArgsConstructor +public class HydropowerServiceImpl implements HydropowerService { + + private final IAnalyseDataService analyseDataService; + + private final IHomePageService homePageService; + + private final IMainSystemMonitoringService maintenanceTaskService; + + private final IStationService stationService; + + private final IStationAttributeService attributeService; + + private final IWaterService waterService; + + private final IPlanGenertionClient planGenertionClient; + + private final ISoeClient soeClient; + + private final IWeatherService weatherService; + + private final RedisTemplate redisTemplate; + + @Value("${hzims.operation.realIdKey}") + public String real_id_key; + + private final static String recent_year_power_data = "hzims:operation:key:power:data"; + 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 loadwater_level_key = "hzims:operation:loadwater:level:key"; + + + /** + * 加载水电站机组实时数据 + * @param param + */ + @Override + public void loadHydropowerReal(String param) { + // 有效设备 + List valid = this.getValidDeviceList(); + if(CollectionUtil.isEmpty(valid)){ + return; + } + // 实时数据 + Map map = this.getRealMap(); + // 单位 + Map unitMap = this.attributeService.getPointUnit(); + List list = new ArrayList<>(); + valid.forEach(device->{ + HydropowerUnitRealVo realVo = new HydropowerUnitRealVo(); + realVo.setDeptId(device.getCreateDept()); + realVo.setDeviceCode(device.getEmCode()); + realVo.setDeptName(device.getName()); + realVo.setDeviceName(device.getName()); + // 开关机状态 + String state = this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY); + realVo.setState(state); + // 有功功率 + String activePower = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER); + realVo.setActivePower(activePower); + // 无功功率 + String reactivePower = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_REACTIVE_POWER); + realVo.setReactivePower(reactivePower); + // 功率因数 + String powerFactor = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_POWERFACTOR); + realVo.setPowerFactor(powerFactor); + // 机组频率 + String frequency = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_FREQUENCY); + realVo.setFrequency(frequency); + // 导叶开度 + String guideOpen = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_GUIDEOPEN); + realVo.setGuideOpen(guideOpen); + // 定子电压 + String statorVoltage = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_VOLTAGE); + realVo.setStatorVoltage(statorVoltage); + // 定子电流 + String statorCurrent = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_CURRENT); + realVo.setStatorCurrent(statorCurrent); + // 单位设置 + this.setttingUnit(device,unitMap,realVo); + list.add(realVo); + }); + redisTemplate.opsForValue().set(load_hydropower_unit_real_key,list); + } + + /** + * 获取实时数据 + * @return + */ + private Map getRealMap() { + String json = (String) redisTemplate.opsForValue().get(real_id_key); + if(StringUtil.isBlank(json)){ + return null; + } + return JSONObject.parseObject(json, new TypeReference>() {}); + } + + /** + * 加载水电站机组指标数据 + * @param param + */ + @Override + public void loadHydropowerTarget(String param) { + // 有效设备 + List valid = this.getValidDeviceList(); + if(CollectionUtil.isEmpty(valid)){ + return; + } + List list = new ArrayList<>(); + valid.forEach(device->{ + HydropowerUnitTargetVo targetVo = new HydropowerUnitTargetVo(); + targetVo.setDeptId(device.getCreateDept()); + targetVo.setDeviceCode(device.getEmCode()); + targetVo.setDeviceName(device.getName()); + targetVo.setDeptName(device.getName()); + // 当年发电量 + float powerYear = this.getGenerationPower(device,0); + targetVo.setPowerYear(powerYear); + // 当月发电量 + float powerMon = this.getGenerationPower(device,1); + targetVo.setPowerMon(powerMon); + // 当日发电量 + float powerDay = this.getGenerationPower(device,2); + // 当天有功功率 + List activePowerVoList = waterService.getActivePowerVoList(device); + targetVo.setActivePowerVoList(activePowerVoList); + // 30天发电量 + List generationPowerVoList = this.getGenerationPowerList(device); + targetVo.setGenerationPowerVoList(generationPowerVoList); + targetVo.setPowerDay(powerDay); + list.add(targetVo); + }); + redisTemplate.opsForValue().set(load_hydropower_unit_target_key,list); + } + + /** + * 获取有效设备 + * @return + */ + private List getValidDeviceList() { + // 水利站点(All) + List stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), null); + if(CollectionUtil.isEmpty(stationList)){ + return null; + } + // 获取所有设备 + List deviceList = maintenanceTaskService.getEmInfoList(); + if(CollectionUtil.isEmpty(deviceList)){ + return null; + } + // 有效泵租设备 + List deptIdList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(deptIdList)){ + return null; + } + return deviceList.stream().filter(o->deptIdList.contains(o.getCreateDept())).collect(Collectors.toList()); + } + + + /** + * 获取监测点实时数据 + * @param em + * @param targets + * @return + */ + private String getSignageValue(EminfoAndEmParamVo em,Map map, String targets) { + if(ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)){ + return "0"; + } + Map point = em.getPoint(); + if(MapUtils.isEmpty(point)){ + return "0"; + } + String realId = point.get(targets); + if(StringUtil.isBlank(realId)){ + return "0"; + } + String value = map.get(realId); + if(StringUtil.isBlank(value)){ + return "0"; + } + // 获取value + return value; + } + + /** + * 单位设置 + * @param device + * @param unitMap + * @param realVo + */ + private void setttingUnit(EminfoAndEmParamVo device, Map unitMap, HydropowerUnitRealVo realVo) { + if(MapUtils.isEmpty(unitMap)){ + return; + } + // 有功功率单位 + String power = unitMap.get(device.getId()+HomePageConstant.CONCAT_P); + if(StringUtil.isNotBlank(power)){ + realVo.setPowerUnit(power); + } else { + realVo.setPowerUnit("kW"); + } + // 无功功率 + String reactivePowerUnit = unitMap.get(device.getId()+HomePageConstant.CONCAT_Q); + if(StringUtil.isNotBlank(reactivePowerUnit)){ + realVo.setReactivePowerUnit(reactivePowerUnit); + } else { + realVo.setReactivePowerUnit("kVa r"); + } + // 定子电压单位 + String voltage = unitMap.get(device.getId()+HomePageConstant.CONCAT_UAB); + if(StringUtil.isNotBlank(voltage)){ + realVo.setVoltageUnit(voltage); + } else { + realVo.setVoltageUnit("V"); + } + // 定子电流单位 + String current = unitMap.get(device.getId()+HomePageConstant.CONCAT_IA); + if(StringUtil.isNotBlank(current)){ + realVo.setCurrentUnit(current); + } else { + realVo.setCurrentUnit("A"); + } + } + + /** + * 获取年、月、日发电量 + * @param device + * @param scope + * @return + */ + private float getGenerationPower(EminfoAndEmParamVo device,int scope) { + String start,end; + int accessRules; + Calendar calendar = Calendar.getInstance(); + switch (scope){ + // 年 + case 0: + end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + calendar.setTime(new Date()); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; + accessRules = EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(); + break; + // 月 + case 1: + start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; + end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); + accessRules = EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(); + break; + // 日 + case 2: + String time = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + start = time + " 00:00:00"; + end = time + " 23:59:59"; + accessRules = EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(); + break; + default: + throw new IllegalStateException("Unexpected value: " + scope); + } + return analyseDataService.periodTargetFloat(start,end,accessRules,5,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + } + + /** + * 近30天发电量 + * @param device + * @return + */ + private List getGenerationPowerList(EminfoAndEmParamVo device) { + String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); + 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); + if(CollectionUtil.isEmpty(records)){ + return new ArrayList<>(); + } + return records.stream().map(record -> { + GenerationPowerVo generate = new GenerationPowerVo(); + Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); + generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); + return generate; + }).collect(Collectors.toList()); + } + + /** + * 水电站-站点信息 + * @param deptId + * @return + */ + @Override + public HydropowerStationVo webStation(Long deptId) { + if(ObjectUtil.isEmpty(deptId)){ + return null; + } + // 站点 + StationEntity station = stationService.getStationByCodeOrRefDept(null,deptId); + if(ObjectUtil.isEmpty(station)){ + return null; + } + List list = this.getHydropowerStationList(Collections.singletonList(station)); + if(CollectionUtil.isEmpty(list)){ + return null; + } + return list.get(0); + } + + /** + * 获取首页站点信息 + * @param list + * @return + */ + private List getHydropowerStationList(List list) { + if(CollectionUtil.isEmpty(list)){ + return null; + } + // 实时监测点数据 + List realList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + // 获取站点机组指标数据 + List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + // 所有设备 + List deviceList = maintenanceTaskService.getEmInfoList(); + // 实时天气 + Map weather = this.getWeather(list.stream().map(StationEntity::getCode).collect(Collectors.toList())); + // 七天天气 + Map weekWeather = this.getWeekWeather(list.stream().map(StationEntity::getCode).collect(Collectors.toList())); + List result = new ArrayList<>(); + list.forEach(station ->{ + HydropowerStationVo response = new HydropowerStationVo(); + response.setDeptId(station.getRefDept()); + response.setDeptName(station.getName()); + response.setStationCode(station.getCode()); + // 站点状态 + List soeDataList = soeClient.getByLastLimitTime(null, station.getCode(), 1).getData(); + if (CollectionUtil.isNotEmpty(soeDataList)) { + response.setStationStatus(false); + } else { + response.setStationStatus(true); + } + // 站点实时天气 + String temp = this.getTemp(weather,station.getCode()); + response.setTemp(temp); + // 站点七天天气 + List dailys = this.getDailyList(weekWeather,station.getCode()); + response.setWeather(dailys); + // 限制水位 + response.setLimitWaterLevel(station.getLimitWaterLevel()); + // 运行天数 + int runDay = this.getRunDay(station); + response.setRunDay(runDay); + // 装机容量 + double installedCapacity = this.getInstalledCapacity(deviceList,station.getRefDept()); + response.setInstalledCapacity(installedCapacity); + // 总有功功率(总发电负荷) + double powerSum = this.getPowerSum(realList,station.getRefDept()); + response.setPowerSum(powerSum); + // 总有功单位 + String unit = this.getPowerUnit(realList,station.getRefDept()); + response.setPowerUnit(unit); + // 月计划发电量 + float planPowerMon = this.getPlanPowerrMon(station.getCode()); + response.setPlanPowerMon(planPowerMon); + // 年计划发电量 + float planPowerYear = this.getPlanPowerYear(station.getCode()); + response.setPlanPowerYear(planPowerYear); + // 月发电量、年发电量、年发电完成率 + this.handleStationInfo(station.getRefDept(),response); + // 水位、水位曲线 + this.handleWaterLeve(station.getCode(),response); + // 年发电量完成百分比 + List powerYearList = this.handlePowerFinish(station); + response.setPowerYearMap(powerYearList); + // 设备信息 + List devices = this.getDevices(station,realList,targetList); + response.setDeviceList(devices); + result.add(response); + }); + return result; + } + + /** + * 获取站点设备信息 + * @param station + * @return + */ + private List getDevices(StationEntity station,List realList,List targetList) { + if(CollectionUtil.isEmpty(realList) || CollectionUtil.isEmpty(targetList)){ + return null; + } + // 有效站点机组数据 + List validRealList = realList.stream().filter(o-> null != station.getRefDept() && station.getRefDept().equals(o.getDeptId())).collect(Collectors.toList()); + // 有效站点机组指标数据 + List validTargetList = targetList.stream().filter(o-> null != station.getRefDept() && station.getRefDept().equals(o.getDeptId())).collect(Collectors.toList()); + List list = new ArrayList<>(); + for(HydropowerUnitRealVo real : validRealList){ + HydropowerUnitVo hydropowerUnitVo = new HydropowerUnitVo(); + // 设备编号 + hydropowerUnitVo.setDeivceCode(real.getDeviceCode()); + hydropowerUnitVo.setDeivceName(real.getDeviceName()); + // 实时数据 + hydropowerUnitVo.setHydropowerPumpRealVo(real); + // 指标数据 + if(CollectionUtil.isNotEmpty(validTargetList)){ + List target = targetList.stream().filter(o->real.getDeviceCode().equals(o.getDeviceCode())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(target)){ + hydropowerUnitVo.setHydropowerPumpTargetVo(target.get(0)); + } + } + list.add(hydropowerUnitVo); + } + return list.stream().sorted(Comparator.comparing(HydropowerUnitVo::getDeivceCode)).collect(Collectors.toList()); + } + + /** + * 获取实时温度 + * @param weather + * @param code + * @return + */ + private String getTemp(Map weather, String code) { + if(MapUtils.isEmpty(weather)){ + return "21"; + } + HeWeatherWeatherNowResponse now = weather.get(code); + if(ObjectUtil.isEmpty(now) || ObjectUtil.isEmpty(now.getNow())){ + return "21"; + } + return now.getNow().getTemp(); + } + + /** + * 获取七天天气 + * @param weekWeather + * @param code + * @return + */ + private List getDailyList(Map weekWeather, String code) { + if(MapUtils.isEmpty(weekWeather)){ + return null; + } + HeWeatherWeatherDailyResponse week = weekWeather.get(code); + if(ObjectUtil.isEmpty(week)){ + return null; + } + return week.getDaily(); + } + + /** + * 获取站点实时天气 + * @param codes + */ + private Map getWeather(List codes) { + if(CollectionUtil.isEmpty(codes)){ + return null; + } + // 实时天气 + return this.weatherService.getNowWeather(codes); + } + + /** + * 获取七天天气 + * @param codes + */ + private Map getWeekWeather(List codes) { + if(CollectionUtil.isEmpty(codes)){ + return null; + } + // 实时天气 + return this.weatherService.getWeekWeather(codes); + } + + /** + * 获取设备装机容量 + * @param list + * @param refDept + * @return + */ + private double getInstalledCapacity(List list, Long refDept) { + if(CollectionUtil.isEmpty(list) || ObjectUtil.isEmpty(refDept)){ + return 0.0; + } + return list.stream().filter(o -> refDept.equals(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); + } + + /** + * 获取站点运行天数 + * @param station + * @return + */ + private int getRunDay(StationEntity station) { + if (ObjectUtil.isEmpty(station.getCommissionTime())) { + return 0; + } + // 计算投运时间与当前时间相隔天数 + Duration dur = Duration.between(station.getCommissionTime(), LocalDateTime.now()); + return (int) dur.toDays(); + } + + /** + * 获取总发电负荷 + * @param deptId + * @return + */ + private Double getPowerSum(List realList,Long deptId) { + if(ObjectUtil.isEmpty(deptId)){ + return 0.0; + } + // 获取站点机组实时数据 + if(CollectionUtil.isEmpty(realList)){ + return 0.0; + } + return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(o->Double.parseDouble(o.getActivePower())).sum(); + } + + /** + * 获取总发电负荷单位 + * @param realList + * @param deptId + * @return + */ + private String getPowerUnit(List realList, Long deptId) { + if(ObjectUtil.isEmpty(deptId)){ + return "kW"; + } + // 获取站点机组实时数据 + if(CollectionUtil.isEmpty(realList)){ + return "kW"; + } + List unit = realList.stream().filter(o->deptId.equals(o.getDeptId()) && StringUtil.isNotBlank(o.getPowerUnit())).map(HydropowerUnitRealVo::getPowerUnit).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(unit)){ + return "kW"; + } + return unit.get(0); + } + + /** + * 获取月计划发电量 + * @param code + * @return + */ + private float getPlanPowerrMon(String code) { + R R = planGenertionClient.planGenerationMonthCount(code, DateUtil.format(new Date(), "yyyy-MM")); + if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ + return 0f; + } + return R.getData(); + } + + /** + * 获取年计划发电量 + * @param code + * @return + */ + private float getPlanPowerYear(String code) { + R R = planGenertionClient.planGenerationYearCount(code); + if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ + return 0f; + } + // 查询年计划发电量 + return R.getData(); + } + + /** + * 站点信息处理 + * @param deptId + * @param response + */ + private void handleStationInfo(Long deptId, HydropowerStationVo response) { + response.setPowerMon(0f); + response.setPowerYear(0f); + response.setPowerRateYear(0.0); + List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + if(CollectionUtil.isEmpty(targetList)){ + return; + } + // 月发电量 + float powerMont = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum(); + response.setPowerMon(powerMont); + // 年发电量 + float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); + response.setPowerYear(powerYear); + // 年发电完成率 + float planPowerYear = response.getPlanPowerYear(); + if(Math.abs(planPowerYear) <= 0){ + response.setPowerRateYear(0.0); + } else { + double powerRateYear = BigDecimal.valueOf(powerYear / planPowerYear * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + response.setPowerRateYear(powerRateYear); + } + } + + /** + * 站点水位数据处理 + * @param code + * @param response + */ + private void handleWaterLeve(String code, HydropowerStationVo response) { + response.setFrontWaterLevel(0.0); + List levelList = (List) redisTemplate.opsForValue().get(loadwater_level_key); + if(CollectionUtil.isEmpty(levelList)){ + return; + } + List validList = levelList.stream().filter(o-> code.equals(o.getStationCode())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(validList)){ + return; + } + WaterLevelVo level = validList.get(0); + // 前池水位、当日水位曲线 + response.setFrontWaterLevel(level.getFrontWaterLevel()); + response.setFrontCurveMap(level.getFrontCurveMap()); + } + + /** + * 年发电量完成百分比 + * @param station + */ + private List handlePowerFinish(StationEntity station) { + String code = station.getCode(); + if(StringUtil.isBlank(code)){ + 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 monList = homePageService.getMonthList(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)); + vo.setStrMonth(o); + vo.setYear(localDate.getYear()); + vo.setMonth(localDate.getMonthValue()); + // 实际发电量 + if(CollectionUtil.isEmpty(powerMap)){ + vo.setPower(0f); + }else{ + Map map = powerMap.get(station.getId()); + if(MapUtils.isEmpty(map)){ + vo.setPower(0f); + }else{ + vo.setPower(map.get(o)); + } + } + // 计划发电量 + if(CollectionUtil.isEmpty(planPowerList)){ + 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()); + } + } + return vo; + }).collect(Collectors.toList()); + } + + /** + * 水电站-机组列表 + * @param deptId + * @return + */ + @Override + public List hydropowerDevice(Long deptId) { + if(ObjectUtil.isEmpty(deptId)){ + return null; + } + // 查询站点 + StationEntity station = stationService.getStationByCodeOrRefDept(null,deptId); + if(ObjectUtil.isEmpty(station)){ + return null; + } + // 实时监测点数据 + List realList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); + // 获取站点机组指标数据 + List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); + return this.getDevices(station,realList,targetList); + } + + /** + * 水电站站点列表 + * @param deptId + * @return + */ + @Override + public List webStationList(Long deptId) { + List list = stationService.getStationType(null,Collections.singletonList(HomePageConstant.HYDROPOWER),null); + if(CollectionUtil.isEmpty(list)){ + return null; + } + return this.getHydropowerStationList(list); + } +} 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 1f30818..dcead7c 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 @@ -7,6 +7,7 @@ import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; +import com.hnac.hzims.operational.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.*; @@ -68,10 +69,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { private final IAnalyseDataService analyseDataService; - private final IHistoryDataSearchClient historySearchClient; - private final IMainTaskStatisticService taskService; + private final PowerService generateService; + + private final IHistoryDataSearchClient historySearchClient; + private final ISysClient sysClient; private final ITicketInfoClient ticketInfoClient; @@ -243,6 +246,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { return; } List list = new ArrayList<>(); + // 接入站点设备统计 devices.forEach(device -> { PhotovoltaicTargetVo target = new PhotovoltaicTargetVo(); target.setDeptId(device.getCreateDept()); @@ -273,9 +277,18 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { target.setGenerationPowerVoList(this.getGenerateByMon(device)); list.add(target); }); + // 补充站点填报发电量 + List stations = stationService.list(Wrappers.lambdaQuery() + .eq(StationEntity::getType, HomePageConstant.PHOTOVOLTAIC) + .eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE) + ); + if(CollectionUtil.isNotEmpty(stations)){ + list.addAll(this.generateFill(stations)); + } redisTemplate.opsForValue().set(load_photovoltaic_target_key, list); } + /** * 当天有功功率 * @@ -325,6 +338,45 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { }).sorted(Comparator.comparing(GenerationPowerVo::getDate)).collect(Collectors.toList()); } + /** + * 获取光伏站点填报数据 + * @param stations + * @return + */ + private List generateFill(List stations) { + Calendar calendar = Calendar.getInstance(); + //String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + String mon = DateUtil.format(calendar.getTime(),"yyyy-MM"); + String year = String.valueOf(calendar.get(Calendar.YEAR)); + //calendar.add(Calendar.DAY_OF_MONTH,-1); + //String yesterday = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + return stations.stream().map(station ->{ + PhotovoltaicTargetVo target = new PhotovoltaicTargetVo(); + target.setDeptId(station.getRefDept()); + target.setDeptName(station.getName()); + // 当日运行时长 + target.setRunHours(0.0); + // 日发电量 + target.setGenerationDay(0.0); + // 昨日发电量 + target.setGenerationYesterday(0.0); + // 收益 + target.setIncome(0.0); + // 日发电量 + // 月发电量 + target.setGenerationMon(generateService.generate(mon,station.getRefDept())); + // 节约标准煤 + target.setTec(target.getGenerationMon() * 0.0001229); + // 二氧化碳减排 + target.setCo2(target.getGenerationMon() * 0.000997); + // 减少森林砍伐 + target.setDeforest(target.getGenerationMon() * 0.000553); + // 年发电量 + target.setGenerationYear(generateService.generate(year,station.getRefDept())); + // 30天发电量 + return target; + }).collect(Collectors.toList()); + } /** * 根据事件查询数据值 @@ -1462,7 +1514,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { } // 功率 photovoltaic.setActivePowerVoList( - devices.stream().map(PhotovoltaicDeviceVo::getActivePowerVoList).flatMap(Collection::stream).collect(Collectors.groupingBy(PhotovoltaicPowerVo::getHour)).entrySet().stream().map(entry -> { + devices.stream().map(PhotovoltaicDeviceVo::getActivePowerVoList).filter(ObjectUtil::isNotEmpty).flatMap(Collection::stream).collect(Collectors.groupingBy(PhotovoltaicPowerVo::getHour)).entrySet().stream().map(entry -> { PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); load.setHour(entry.getKey()); load.setActivePower(String.valueOf(entry.getValue().stream().mapToDouble(o -> Double.parseDouble(o.getActivePower())).sum())); @@ -1471,7 +1523,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { ); // 发电量 photovoltaic.setGenerationPowerVoList( - devices.stream().map(PhotovoltaicDeviceVo::getGenerationPowerVoList).flatMap(Collection::stream).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { + devices.stream().map(PhotovoltaicDeviceVo::getGenerationPowerVoList).filter(ObjectUtil::isNotEmpty).flatMap(Collection::stream).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { GenerationPowerVo generate = new GenerationPowerVo(); generate.setDate(entry.getKey()); generate.setGenerate((float) entry.getValue().stream().mapToDouble(o -> Double.valueOf(o.getGenerate())).sum()); 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 878208d..a27d3fa 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 @@ -3,15 +3,18 @@ package com.hnac.hzims.operational.main.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.hzimsweather.response.weather.Daily; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse; import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; +import com.hnac.hzims.operational.fill.service.UseService; +import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.*; import com.hnac.hzims.operational.main.vo.*; -import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.station.StationConstants; import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IHzimsAnalyzeModelStationService; @@ -44,8 +47,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; @@ -60,26 +61,28 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class WaterServiceImpl implements IWaterService { - private final IAnalyseDataService analyseDataService; + private final UseService useService; private final IHomePageService homePageService; private final IStationService stationService; + private final IWeatherService weatherService; + + private final IAnalyseDataService analyseDataService; + private final ISideHustleService sideHustleService; private final IMainSystemMonitoringService maintenanceTaskService; private final IHzimsAnalyzeModelStationService modelStationService; - private final IAnalyseDataSearchClient analyseDataSearchClient; + private final ISysClient sysClient; - private final IWeatherService weatherService; + private final IAnalyseDataSearchClient analyseDataSearchClient; private final IHistoryDataSearchClient historyDataSearchClient; - private final ISysClient sysClient; - private final RedisTemplate redisTemplate; @Value("${hzims.operation.realIdKey}") @@ -91,13 +94,6 @@ public class WaterServiceImpl implements IWaterService { private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; - // 日期格式化yyyy-mm-dd - private final SimpleDateFormat df = new SimpleDateFormat(DateUtil.PATTERN_DATE); - // 日期格式化yyyy-mm-dd - private final SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATETIME); - // 时间格式化yyyy-MM-dd HH:mm:ss" - private final DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); - /** * 水利-泵组实时加载 * @param param @@ -149,43 +145,50 @@ public class WaterServiceImpl implements IWaterService { @Override public void loadWaterPumpTarget(String param) { List valid = this.getValidDeviceList(); - if(CollectionUtil.isEmpty(valid)){ - return; - } List list = new ArrayList<>(); - valid.forEach(device->{ - WaterPumpTargetVo waterPumpTargetVo = new WaterPumpTargetVo(); - waterPumpTargetVo.setDeptId(device.getCreateDept()); - waterPumpTargetVo.setDeviceCode(device.getEmCode()); - waterPumpTargetVo.setDeptName(device.getName()); - // 当年用电量 - float usrPowerYear = this.getUsrPowerYear(device); - waterPumpTargetVo.setUsrPowerYear(usrPowerYear); - // 当月用电量 - float usrPowerMon = this.getUsrPowerMon(device); - waterPumpTargetVo.setUsrPowerMon(usrPowerMon); - // 当日用电量 - float usrPowerDay = this.getUsrPowerDay(device); - waterPumpTargetVo.setUsrPowerDay(usrPowerDay); - // 月运行次数、时长 - WaterRunVo runMon = this.getRunData(device,1); - waterPumpTargetVo.setRunCountMon(runMon.getCount()); - waterPumpTargetVo.setRunDurationMon(runMon.getHour()); - // 年运行次数、时长 - WaterRunVo runYear = this.getRunData(device,0); - waterPumpTargetVo.setRunCountYear(runYear.getCount()); - waterPumpTargetVo.setRunDurationYear(runYear.getHour()); - // 当日机组有功功率 - List activePowerVoList = this.getActivePowerVoList(device); - waterPumpTargetVo.setActivePowerVoList(activePowerVoList); - // 近30天用电量 - List usrPowerVoList = this.getUsrPowerVoList(device); - waterPumpTargetVo.setUsrPowerVoList(usrPowerVoList); - // 近3年用电量 - Map usrYearMap = this.getUsrYearMap(device); - waterPumpTargetVo.setUsrYearMap(usrYearMap); - list.add(waterPumpTargetVo); - }); + if(CollectionUtil.isNotEmpty(valid)){ + valid.forEach(device->{ + WaterPumpTargetVo waterPumpTargetVo = new WaterPumpTargetVo(); + waterPumpTargetVo.setDeptId(device.getCreateDept()); + waterPumpTargetVo.setDeviceCode(device.getEmCode()); + waterPumpTargetVo.setDeptName(device.getName()); + // 当年用电量 + float usrPowerYear = this.getUsrPowerYear(device); + waterPumpTargetVo.setUsrPowerYear(usrPowerYear); + // 当月用电量 + float usrPowerMon = this.getUsrPowerMon(device); + waterPumpTargetVo.setUsrPowerMon(usrPowerMon); + // 当日用电量 + float usrPowerDay = this.getUsrPowerDay(device); + waterPumpTargetVo.setUsrPowerDay(usrPowerDay); + // 月运行次数、时长 + WaterRunVo runMon = this.getRunData(device,1); + waterPumpTargetVo.setRunCountMon(runMon.getCount()); + waterPumpTargetVo.setRunDurationMon(runMon.getHour()); + // 年运行次数、时长 + WaterRunVo runYear = this.getRunData(device,0); + waterPumpTargetVo.setRunCountYear(runYear.getCount()); + waterPumpTargetVo.setRunDurationYear(runYear.getHour()); + // 当日机组有功功率 + List activePowerVoList = this.getActivePowerVoList(device); + waterPumpTargetVo.setActivePowerVoList(activePowerVoList); + // 近30天用电量 + List usrPowerVoList = this.getUsrPowerVoList(device); + waterPumpTargetVo.setUsrPowerVoList(usrPowerVoList); + // 近3年用电量 + Map usrYearMap = this.getUsrYearMap(device); + waterPumpTargetVo.setUsrYearMap(usrYearMap); + list.add(waterPumpTargetVo); + }); + } + // 补充站点填报发电量 + List stations = stationService.list(Wrappers.lambdaQuery() + .in(StationEntity::getType, HomePageConstant.waterList) + .eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE) + ); + if(CollectionUtil.isNotEmpty(stations)){ + list.addAll(this.useFill(stations)); + } redisTemplate.opsForValue().set(loadwaterpump_target_key,list); } @@ -279,12 +282,8 @@ public class WaterServiceImpl implements IWaterService { if(StringUtil.isBlank(time)){ return 0.0; } - try{ - Date date = sdf.parse(time); - if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ - return 0.0; - } - }catch (ParseException e){ + Date date = DateUtil.parse(time,DateUtil.DATETIME_FORMAT); + if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ return 0.0; } return Double.parseDouble(R.getData().get(0).getValue()); @@ -297,7 +296,7 @@ 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"), dtf); + 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<>(); @@ -573,11 +572,11 @@ public class WaterServiceImpl implements IWaterService { */ private float getUsrPowerYear(EminfoAndEmParamVo device) { Calendar calendar = Calendar.getInstance(); - String end = sdf.format(calendar.getTime()); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); calendar.setTime(new Date()); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); - String start = df.format(calendar.getTime()); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); // 当年用电量 return analyseDataService.periodTargetFloat(start,end,6,5,device.getEmCode(),device.getRideCount(),HomePageConstant.ELECTRICITY_CONSUMPTION); } @@ -801,36 +800,82 @@ public class WaterServiceImpl implements IWaterService { /** + * 获取填报用电量 + * @param stations + * @return + */ + private List useFill(List stations) { + Calendar calendar = Calendar.getInstance(); + String day = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + String mon = DateUtil.format(calendar.getTime(),"yyyy-MM"); + String year = String.valueOf(calendar.get(Calendar.YEAR)); + //calendar.add(Calendar.DAY_OF_MONTH,-1); + //String yesterday = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + return stations.stream().map(station ->{ + WaterPumpTargetVo target = new WaterPumpTargetVo(); + target.setDeptId(station.getRefDept()); + target.setDeptName(station.getName()); + // 月运行次数、时长 + target.setRunCountMon(0); + target.setRunDurationMon(0.0); + // 年运行次数、时长 + target.setRunCountYear(0); + target.setRunDurationYear(0.0); + // 当年用电量 + target.setUsrPowerYear(useService.use(year,station.getCode())); + // 当月用电量 + target.setUsrPowerMon(useService.use(mon,station.getCode())); + // 当日用电量 + target.setUsrPowerDay(useService.use(day,station.getCode())); + if(StationConstants.DATA_ORIGIN_FILL.equals(station.getDataOrigin())){ + // 30天用电量 + target.setUsrPowerVoList(useService.use30Day(day,station.getCode())); + } + // 近3年用电量 + target.setUsrYearMap(this.useThreeYear(station.getCode())); + return target; + }).collect(Collectors.toList()); + } + + /** + * 填报近3年发电量 + * @param station + * @return + */ + private Map useThreeYear(String station) { + // 开始时间 + 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(),"yyyy-MM"); + // 结束日期 + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + return useService.generateThreeYear(start,end,station); + } + + /** * 水利首页-指标数据 * @param deptId * @return */ @Override public WaterConservancyVo waterConservancy(Long deptId) { - //根据用户权限获取机构 - R> R = sysClient.getDeptByCurrentUser(); - if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { - return null; - } - // 获取水利站点 - List stationList = stationService.getStationList(R.getData(),deptId,HomePageConstant.waterList,HomePageConstant.HYDROPOWER_SERVETYPE); - if(CollectionUtil.isEmpty(stationList)){ - return null; - } - // 站点归属机构集合 - List deptList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(deptList)){ - return null; + // 查询水利站点 + List stations = stationService.getHomeStationList(deptId, HomePageConstant.waterList, HomePageConstant.HYDROPOWER_SERVETYPE); + if (CollectionUtil.isEmpty(stations)) { + return new WaterConservancyVo(); } WaterConservancyVo response = new WaterConservancyVo(); // 查询指标标题机构 - Dept title = this.getTitleDetp(R.getData(),deptId); + Dept title = this.getTitleDetp(deptId); if(ObjectUtil.isNotEmpty(title)){ response.setDepartId(title.getId()); response.setDepartName(title.getDeptName()); } - response.setWaterStationCount((int) stationList.stream().filter(o->HomePageConstant.PUMPING.equals(o.getType())).count()); - response.setSluiceGateCount((int) stationList.stream().filter(o->HomePageConstant.GATE.equals(o.getType())).count()); + response.setWaterStationCount((int) stations.stream().filter(o->HomePageConstant.PUMPING.equals(o.getType())).count()); + response.setSluiceGateCount((int) stations.stream().filter(o->HomePageConstant.GATE.equals(o.getType())).count()); response.setWaterInstall(0.0); response.setWaterPower(0.0); response.setKWhYear(0f); @@ -838,39 +883,35 @@ public class WaterServiceImpl implements IWaterService { response.setKWhDay(0f); // 获取设备实时数据 List list = (List) redisTemplate.opsForValue().get(loadwaterpump_real_key); - if(CollectionUtil.isEmpty(list)){ - return response; - } - // 获取站点机构有效设备 - List valid = list.stream().filter(o->deptList.contains(o.getDeptId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(valid)){ - return response; + if(CollectionUtil.isNotEmpty(list)){ + // 获取站点机构有效设备 + List valid = list.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(valid)){ + // 装机容量 + double waterInstall = valid.stream().mapToDouble(WaterPumpRealVo::getInstalledCapacity).sum(); + response.setWaterInstall(waterInstall); + // 有功功率 + double waterPower = valid.stream().mapToDouble(WaterPumpRealVo::getActivePower).sum(); + response.setWaterPower(waterPower); + } } - // 装机容量 - double waterInstall = valid.stream().mapToDouble(WaterPumpRealVo::getInstalledCapacity).sum(); - response.setWaterInstall(waterInstall); - // 有功功率 - double waterPower = valid.stream().mapToDouble(WaterPumpRealVo::getActivePower).sum(); - response.setWaterPower(waterPower); // 获取设备指标数据 List targetList = (List) redisTemplate.opsForValue().get(loadwaterpump_target_key); - if(CollectionUtil.isEmpty(targetList)){ - return response; - } - // 获取站点机构有效设备 - List validTarget = targetList.stream().filter(o->deptList.contains(o.getDeptId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(valid)){ - return response; + if(CollectionUtil.isNotEmpty(targetList)){ + // 获取站点机构有效设备 + List validTarget = targetList.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); + if(CollectionUtil.isNotEmpty(validTarget)){ + // 年用电量 + double kwhYear = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerYear).sum(); + response.setKWhYear((float) kwhYear); + // 月用电量 + double kwhMon = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerMon).sum(); + response.setKWhMon((float) kwhMon); + // 日用电量 + double kwhDay = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum(); + response.setKWhDay((float) kwhDay); + } } - // 年用电量 - double kwhYear = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerYear).sum(); - response.setKWhYear((float) kwhYear); - // 月用电量 - double kwhMon = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerMon).sum(); - response.setKWhMon((float) kwhMon); - // 日用电量 - double kwhDay = validTarget.stream().mapToDouble(WaterPumpTargetVo::getUsrPowerDay).sum(); - response.setKWhDay((float) kwhDay); return response; } @@ -1154,16 +1195,17 @@ public class WaterServiceImpl implements IWaterService { * @return */ @Override - public Dept getTitleDetp(List authList, Long deptId) { + public Dept getTitleDetp(Long deptId) { + R> depts = sysClient.getDeptByCurrentUser(); if(null == deptId){ // 最小类型机构 - Dept dept = authList.stream().min(Comparator.comparing(Dept::getDeptCategory)).orElse(null); + Dept dept = depts.getData().stream().min(Comparator.comparing(Dept::getDeptCategory)).orElse(null); if(ObjectUtil.isEmpty(dept)){ return null; } return dept; } - List list = authList.stream().filter(o->deptId.equals(o.getId())).collect(Collectors.toList()); + List list = depts.getData().stream().filter(o->deptId.equals(o.getId())).collect(Collectors.toList()); if(CollectionUtil.isEmpty(list)){ return null; } @@ -1496,26 +1538,6 @@ public class WaterServiceImpl implements IWaterService { } /** - * 获取近30天集合 - * @return - */ - private List getRecent30Day() { - List list = new ArrayList<>(); - // 开始日期 - Calendar calendar = Calendar.getInstance(); - calendar.setTime(new Date()); - list.add(df.format(calendar.getTime())); - // 获取日期之间的月 - int i = 0; - while (i < 30) { - calendar.add(Calendar.DATE, - 1); - list.add(df.format(calendar.getTime())); - i++; - } - return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); - } - - /** * 闸门列表 * @param deptId * @return @@ -1536,7 +1558,7 @@ public class WaterServiceImpl implements IWaterService { if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { return null; } - Dept title = this.getTitleDetp(R.getData(),deptId); + Dept title = this.getTitleDetp(deptId); if(ObjectUtil.isEmpty(title)){ return null; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java deleted file mode 100644 index ef89f5a..0000000 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java +++ /dev/null @@ -1,744 +0,0 @@ -package com.hnac.hzims.operational.main.service.impl; - -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.TypeReference; -import com.hnac.hzims.EquipmentConstants; -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.main.service.*; -import com.hnac.hzims.operational.main.vo.*; -import com.hnac.hzims.operational.main.constant.HomePageConstant; -import com.hnac.hzims.operational.station.entity.StationEntity; -import com.hnac.hzims.operational.station.service.IStationAttributeService; -import com.hnac.hzims.operational.station.service.IStationService; -import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; -import com.hnac.hzinfo.datasearch.soe.ISoeClient; -import com.hnac.hzinfo.datasearch.soe.domian.SoeData; -import lombok.RequiredArgsConstructor; -import org.apache.commons.collections4.MapUtils; -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.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Collectors; - -/** - * APP首页实现类 - */ -@Service -@RequiredArgsConstructor -public class WebHomeServiceImpl implements IWebHomeService { - - private final IAnalyseDataService analyseDataService; - - private final IHomePageService homePageService; - - private final IMainSystemMonitoringService maintenanceTaskService; - - private final IStationService stationService; - - private final IStationAttributeService attributeService; - - private final IWaterService waterService; - - private final IPlanGenertionClient planGenertionClient; - - private final ISoeClient soeClient; - - private final IWeatherService weatherService; - - private final RedisTemplate redisTemplate; - - @Value("${hzims.operation.realIdKey}") - public String real_id_key; - - private final static String recent_year_power_data = "hzims:operation:key:power:data"; - 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 loadwater_level_key = "hzims:operation:loadwater:level:key"; - - - /** - * 加载水电站机组实时数据 - * @param param - */ - @Override - public void loadHydropowerReal(String param) { - // 有效设备 - List valid = this.getValidDeviceList(); - if(CollectionUtil.isEmpty(valid)){ - return; - } - // 实时数据 - Map map = this.getRealMap(); - // 单位 - Map unitMap = this.attributeService.getPointUnit(); - List list = new ArrayList<>(); - valid.forEach(device->{ - HydropowerUnitRealVo realVo = new HydropowerUnitRealVo(); - realVo.setDeptId(device.getCreateDept()); - realVo.setDeviceCode(device.getEmCode()); - realVo.setDeptName(device.getName()); - realVo.setDeviceName(device.getName()); - // 开关机状态 - String state = this.getSignageValue(device,map,HomePageConstant.JOINT_RELAY); - realVo.setState(state); - // 有功功率 - String activePower = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_ACTIVE_POWER); - realVo.setActivePower(activePower); - // 无功功率 - String reactivePower = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_REACTIVE_POWER); - realVo.setReactivePower(reactivePower); - // 功率因数 - String powerFactor = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_POWERFACTOR); - realVo.setPowerFactor(powerFactor); - // 机组频率 - String frequency = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_FREQUENCY); - realVo.setFrequency(frequency); - // 导叶开度 - String guideOpen = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_GUIDEOPEN); - realVo.setGuideOpen(guideOpen); - // 定子电压 - String statorVoltage = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_VOLTAGE); - realVo.setStatorVoltage(statorVoltage); - // 定子电流 - String statorCurrent = this.getSignageValue(device,map,HomePageConstant.HYDROPOWER_CURRENT); - realVo.setStatorCurrent(statorCurrent); - // 单位设置 - this.setttingUnit(device,unitMap,realVo); - list.add(realVo); - }); - redisTemplate.opsForValue().set(load_hydropower_unit_real_key,list); - } - - /** - * 获取实时数据 - * @return - */ - private Map getRealMap() { - String json = (String) redisTemplate.opsForValue().get(real_id_key); - if(StringUtil.isBlank(json)){ - return null; - } - return JSONObject.parseObject(json, new TypeReference>() {}); - } - - /** - * 加载水电站机组指标数据 - * @param param - */ - @Override - public void loadHydropowerTarget(String param) { - // 有效设备 - List valid = this.getValidDeviceList(); - if(CollectionUtil.isEmpty(valid)){ - return; - } - List list = new ArrayList<>(); - valid.forEach(device->{ - HydropowerUnitTargetVo targetVo = new HydropowerUnitTargetVo(); - targetVo.setDeptId(device.getCreateDept()); - targetVo.setDeviceCode(device.getEmCode()); - targetVo.setDeviceName(device.getName()); - targetVo.setDeptName(device.getName()); - // 当年发电量 - float powerYear = this.getGenerationPower(device,0); - targetVo.setPowerYear(powerYear); - // 当月发电量 - float powerMon = this.getGenerationPower(device,1); - targetVo.setPowerMon(powerMon); - // 当日发电量 - float powerDay = this.getGenerationPower(device,2); - // 当天有功功率 - List activePowerVoList = waterService.getActivePowerVoList(device); - targetVo.setActivePowerVoList(activePowerVoList); - // 30天发电量 - List generationPowerVoList = this.getGenerationPowerList(device); - targetVo.setGenerationPowerVoList(generationPowerVoList); - targetVo.setPowerDay(powerDay); - list.add(targetVo); - }); - redisTemplate.opsForValue().set(load_hydropower_unit_target_key,list); - } - - /** - * 获取有效设备 - * @return - */ - private List getValidDeviceList() { - // 水利站点(All) - List stationList = stationService.getStationType(HomePageConstant.HYDROPOWER_SERVETYPE, Collections.singletonList(HomePageConstant.HYDROPOWER), null); - if(CollectionUtil.isEmpty(stationList)){ - return null; - } - // 获取所有设备 - List deviceList = maintenanceTaskService.getEmInfoList(); - if(CollectionUtil.isEmpty(deviceList)){ - return null; - } - // 有效泵租设备 - List deptIdList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(deptIdList)){ - return null; - } - return deviceList.stream().filter(o->deptIdList.contains(o.getCreateDept())).collect(Collectors.toList()); - } - - - /** - * 获取监测点实时数据 - * @param em - * @param targets - * @return - */ - private String getSignageValue(EminfoAndEmParamVo em,Map map, String targets) { - if(ObjectUtil.isEmpty(em) || MapUtils.isEmpty(map)){ - return "0"; - } - Map point = em.getPoint(); - if(MapUtils.isEmpty(point)){ - return "0"; - } - String realId = point.get(targets); - if(StringUtil.isBlank(realId)){ - return "0"; - } - String value = map.get(realId); - if(StringUtil.isBlank(value)){ - return "0"; - } - // 获取value - return value; - } - - /** - * 单位设置 - * @param device - * @param unitMap - * @param realVo - */ - private void setttingUnit(EminfoAndEmParamVo device, Map unitMap, HydropowerUnitRealVo realVo) { - if(MapUtils.isEmpty(unitMap)){ - return; - } - // 有功功率单位 - String power = unitMap.get(device.getId()+HomePageConstant.CONCAT_P); - if(StringUtil.isNotBlank(power)){ - realVo.setPowerUnit(power); - } else { - realVo.setPowerUnit("kW"); - } - // 无功功率 - String reactivePowerUnit = unitMap.get(device.getId()+HomePageConstant.CONCAT_Q); - if(StringUtil.isNotBlank(reactivePowerUnit)){ - realVo.setReactivePowerUnit(reactivePowerUnit); - } else { - realVo.setReactivePowerUnit("kVa r"); - } - // 定子电压单位 - String voltage = unitMap.get(device.getId()+HomePageConstant.CONCAT_UAB); - if(StringUtil.isNotBlank(voltage)){ - realVo.setVoltageUnit(voltage); - } else { - realVo.setVoltageUnit("V"); - } - // 定子电流单位 - String current = unitMap.get(device.getId()+HomePageConstant.CONCAT_IA); - if(StringUtil.isNotBlank(current)){ - realVo.setCurrentUnit(current); - } else { - realVo.setCurrentUnit("A"); - } - } - - /** - * 获取年、月、日发电量 - * @param device - * @param scope - * @return - */ - private float getGenerationPower(EminfoAndEmParamVo device,int scope) { - String start,end; - int accessRules; - Calendar calendar = Calendar.getInstance(); - switch (scope){ - // 年 - case 0: - end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); - calendar.setTime(new Date()); - calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); - calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); - start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; - accessRules = EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(); - break; - // 月 - case 1: - start = DateUtil.format(new Date(), "yyyy-MM") + "-01 00:00:00"; - end = DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME); - accessRules = EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(); - break; - // 日 - case 2: - String time = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); - start = time + " 00:00:00"; - end = time + " 23:59:59"; - accessRules = EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(); - break; - default: - throw new IllegalStateException("Unexpected value: " + scope); - } - return analyseDataService.periodTargetFloat(start,end,accessRules,5,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); - } - - /** - * 近30天发电量 - * @param device - * @return - */ - private List getGenerationPowerList(EminfoAndEmParamVo device) { - String start = DateUtil.format(new Date(),DateUtil.PATTERN_DATE); - 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); - if(CollectionUtil.isEmpty(records)){ - return new ArrayList<>(); - } - return records.stream().map(record -> { - GenerationPowerVo generate = new GenerationPowerVo(); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); - generate.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); - generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); - return generate; - }).collect(Collectors.toList()); - } - - /** - * 水电站-站点信息 - * @param deptId - * @return - */ - @Override - public HydropowerStationVo webStation(Long deptId) { - if(ObjectUtil.isEmpty(deptId)){ - return null; - } - // 站点 - StationEntity station = stationService.getStationByCodeOrRefDept(null,deptId); - if(ObjectUtil.isEmpty(station)){ - return null; - } - List list = this.getHydropowerStationList(Collections.singletonList(station)); - if(CollectionUtil.isEmpty(list)){ - return null; - } - return list.get(0); - } - - /** - * 获取首页站点信息 - * @param list - * @return - */ - private List getHydropowerStationList(List list) { - if(CollectionUtil.isEmpty(list)){ - return null; - } - // 实时监测点数据 - List realList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); - // 获取站点机组指标数据 - List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); - // 所有设备 - List deviceList = maintenanceTaskService.getEmInfoList(); - // 实时天气 - Map weather = this.getWeather(list.stream().map(StationEntity::getCode).collect(Collectors.toList())); - // 七天天气 - Map weekWeather = this.getWeekWeather(list.stream().map(StationEntity::getCode).collect(Collectors.toList())); - List result = new ArrayList<>(); - list.forEach(station ->{ - HydropowerStationVo response = new HydropowerStationVo(); - response.setDeptId(station.getRefDept()); - response.setDeptName(station.getName()); - response.setStationCode(station.getCode()); - // 站点状态 - List soeDataList = soeClient.getByLastLimitTime(null, station.getCode(), 1).getData(); - if (CollectionUtil.isNotEmpty(soeDataList)) { - response.setStationStatus(false); - } else { - response.setStationStatus(true); - } - // 站点实时天气 - String temp = this.getTemp(weather,station.getCode()); - response.setTemp(temp); - // 站点七天天气 - List dailys = this.getDailyList(weekWeather,station.getCode()); - response.setWeather(dailys); - // 限制水位 - response.setLimitWaterLevel(station.getLimitWaterLevel()); - // 运行天数 - int runDay = this.getRunDay(station); - response.setRunDay(runDay); - // 装机容量 - double installedCapacity = this.getInstalledCapacity(deviceList,station.getRefDept()); - response.setInstalledCapacity(installedCapacity); - // 总有功功率(总发电负荷) - double powerSum = this.getPowerSum(realList,station.getRefDept()); - response.setPowerSum(powerSum); - // 总有功单位 - String unit = this.getPowerUnit(realList,station.getRefDept()); - response.setPowerUnit(unit); - // 月计划发电量 - float planPowerMon = this.getPlanPowerrMon(station.getCode()); - response.setPlanPowerMon(planPowerMon); - // 年计划发电量 - float planPowerYear = this.getPlanPowerYear(station.getCode()); - response.setPlanPowerYear(planPowerYear); - // 月发电量、年发电量、年发电完成率 - this.handleStationInfo(station.getRefDept(),response); - // 水位、水位曲线 - this.handleWaterLeve(station.getCode(),response); - // 年发电量完成百分比 - List powerYearList = this.handlePowerFinish(station); - response.setPowerYearMap(powerYearList); - // 设备信息 - List devices = this.getDevices(station,realList,targetList); - response.setDeviceList(devices); - result.add(response); - }); - return result; - } - - /** - * 获取站点设备信息 - * @param station - * @return - */ - private List getDevices(StationEntity station,List realList,List targetList) { - if(CollectionUtil.isEmpty(realList) || CollectionUtil.isEmpty(targetList)){ - return null; - } - // 有效站点机组数据 - List validRealList = realList.stream().filter(o-> null != station.getRefDept() && station.getRefDept().equals(o.getDeptId())).collect(Collectors.toList()); - // 有效站点机组指标数据 - List validTargetList = targetList.stream().filter(o-> null != station.getRefDept() && station.getRefDept().equals(o.getDeptId())).collect(Collectors.toList()); - List list = new ArrayList<>(); - for(HydropowerUnitRealVo real : validRealList){ - HydropowerUnitVo hydropowerUnitVo = new HydropowerUnitVo(); - // 设备编号 - hydropowerUnitVo.setDeivceCode(real.getDeviceCode()); - hydropowerUnitVo.setDeivceName(real.getDeviceName()); - // 实时数据 - hydropowerUnitVo.setHydropowerPumpRealVo(real); - // 指标数据 - if(CollectionUtil.isNotEmpty(validTargetList)){ - List target = targetList.stream().filter(o->real.getDeviceCode().equals(o.getDeviceCode())).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(target)){ - hydropowerUnitVo.setHydropowerPumpTargetVo(target.get(0)); - } - } - list.add(hydropowerUnitVo); - } - return list.stream().sorted(Comparator.comparing(HydropowerUnitVo::getDeivceCode)).collect(Collectors.toList()); - } - - /** - * 获取实时温度 - * @param weather - * @param code - * @return - */ - private String getTemp(Map weather, String code) { - if(MapUtils.isEmpty(weather)){ - return "21"; - } - HeWeatherWeatherNowResponse now = weather.get(code); - if(ObjectUtil.isEmpty(now) || ObjectUtil.isEmpty(now.getNow())){ - return "21"; - } - return now.getNow().getTemp(); - } - - /** - * 获取七天天气 - * @param weekWeather - * @param code - * @return - */ - private List getDailyList(Map weekWeather, String code) { - if(MapUtils.isEmpty(weekWeather)){ - return null; - } - HeWeatherWeatherDailyResponse week = weekWeather.get(code); - if(ObjectUtil.isEmpty(week)){ - return null; - } - return week.getDaily(); - } - - /** - * 获取站点实时天气 - * @param codes - */ - private Map getWeather(List codes) { - if(CollectionUtil.isEmpty(codes)){ - return null; - } - // 实时天气 - return this.weatherService.getNowWeather(codes); - } - - /** - * 获取七天天气 - * @param codes - */ - private Map getWeekWeather(List codes) { - if(CollectionUtil.isEmpty(codes)){ - return null; - } - // 实时天气 - return this.weatherService.getWeekWeather(codes); - } - - /** - * 获取设备装机容量 - * @param list - * @param refDept - * @return - */ - private double getInstalledCapacity(List list, Long refDept) { - if(CollectionUtil.isEmpty(list) || ObjectUtil.isEmpty(refDept)){ - return 0.0; - } - return list.stream().filter(o -> refDept.equals(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum(); - } - - /** - * 获取站点运行天数 - * @param station - * @return - */ - private int getRunDay(StationEntity station) { - if (ObjectUtil.isEmpty(station.getCommissionTime())) { - return 0; - } - // 计算投运时间与当前时间相隔天数 - Duration dur = Duration.between(station.getCommissionTime(), LocalDateTime.now()); - return (int) dur.toDays(); - } - - /** - * 获取总发电负荷 - * @param deptId - * @return - */ - private Double getPowerSum(List realList,Long deptId) { - if(ObjectUtil.isEmpty(deptId)){ - return 0.0; - } - // 获取站点机组实时数据 - if(CollectionUtil.isEmpty(realList)){ - return 0.0; - } - return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(o->Double.parseDouble(o.getActivePower())).sum(); - } - - /** - * 获取总发电负荷单位 - * @param realList - * @param deptId - * @return - */ - private String getPowerUnit(List realList, Long deptId) { - if(ObjectUtil.isEmpty(deptId)){ - return "kW"; - } - // 获取站点机组实时数据 - if(CollectionUtil.isEmpty(realList)){ - return "kW"; - } - List unit = realList.stream().filter(o->deptId.equals(o.getDeptId()) && StringUtil.isNotBlank(o.getPowerUnit())).map(HydropowerUnitRealVo::getPowerUnit).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(unit)){ - return "kW"; - } - return unit.get(0); - } - - /** - * 获取月计划发电量 - * @param code - * @return - */ - private float getPlanPowerrMon(String code) { - R R = planGenertionClient.planGenerationMonthCount(code, DateUtil.format(new Date(), "yyyy-MM")); - if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ - return 0f; - } - return R.getData(); - } - - /** - * 获取年计划发电量 - * @param code - * @return - */ - private float getPlanPowerYear(String code) { - R R = planGenertionClient.planGenerationYearCount(code); - if(!R.isSuccess() || ObjectUtil.isEmpty(R.getData())){ - return 0f; - } - // 查询年计划发电量 - return R.getData(); - } - - /** - * 站点信息处理 - * @param deptId - * @param response - */ - private void handleStationInfo(Long deptId, HydropowerStationVo response) { - response.setPowerMon(0f); - response.setPowerYear(0f); - response.setPowerRateYear(0.0); - List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); - if(CollectionUtil.isEmpty(targetList)){ - return; - } - // 月发电量 - float powerMont = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum(); - response.setPowerMon(powerMont); - // 年发电量 - float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); - response.setPowerYear(powerYear); - // 年发电完成率 - float planPowerYear = response.getPlanPowerYear(); - if(Math.abs(planPowerYear) <= 0){ - response.setPowerRateYear(0.0); - } else { - double powerRateYear = BigDecimal.valueOf(powerYear / planPowerYear * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); - response.setPowerRateYear(powerRateYear); - } - } - - /** - * 站点水位数据处理 - * @param code - * @param response - */ - private void handleWaterLeve(String code, HydropowerStationVo response) { - response.setFrontWaterLevel(0.0); - List levelList = (List) redisTemplate.opsForValue().get(loadwater_level_key); - if(CollectionUtil.isEmpty(levelList)){ - return; - } - List validList = levelList.stream().filter(o-> code.equals(o.getStationCode())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(validList)){ - return; - } - WaterLevelVo level = validList.get(0); - // 前池水位、当日水位曲线 - response.setFrontWaterLevel(level.getFrontWaterLevel()); - response.setFrontCurveMap(level.getFrontCurveMap()); - } - - /** - * 年发电量完成百分比 - * @param station - */ - private List handlePowerFinish(StationEntity station) { - String code = station.getCode(); - if(StringUtil.isBlank(code)){ - 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 monList = homePageService.getMonthList(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)); - vo.setStrMonth(o); - vo.setYear(localDate.getYear()); - vo.setMonth(localDate.getMonthValue()); - // 实际发电量 - if(CollectionUtil.isEmpty(powerMap)){ - vo.setPower(0f); - }else{ - Map map = powerMap.get(station.getId()); - if(MapUtils.isEmpty(map)){ - vo.setPower(0f); - }else{ - vo.setPower(map.get(o)); - } - } - // 计划发电量 - if(CollectionUtil.isEmpty(planPowerList)){ - 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()); - } - } - return vo; - }).collect(Collectors.toList()); - } - - /** - * 水电站-机组列表 - * @param deptId - * @return - */ - @Override - public List hydropowerDevice(Long deptId) { - if(ObjectUtil.isEmpty(deptId)){ - return null; - } - // 查询站点 - StationEntity station = stationService.getStationByCodeOrRefDept(null,deptId); - if(ObjectUtil.isEmpty(station)){ - return null; - } - // 实时监测点数据 - List realList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); - // 获取站点机组指标数据 - List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); - return this.getDevices(station,realList,targetList); - } - - /** - * 水电站站点列表 - * @param deptId - * @return - */ - @Override - public List webStationList(Long deptId) { - List list = stationService.getStationType(null,Collections.singletonList(HomePageConstant.HYDROPOWER),null); - if(CollectionUtil.isEmpty(list)){ - return null; - } - return this.getHydropowerStationList(list); - } -} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java index 3a23096..45098e1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java @@ -3,16 +3,13 @@ package com.hnac.hzims.operational.maintenance.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; -import com.hnac.hzims.operational.maintenance.vo.RegularWorkVO; -import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; -import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; +import com.hnac.hzims.operational.maintenance.vo.RegularWorkVO; +import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; import com.hnac.hzims.vo.SafeCheckStatisticVO; -import com.hnac.hzinfo.inspect.areamonthly.vo.TaskListQuery; -import com.hnac.hzinfo.inspect.areamonthly.vo.TaskVo; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -20,7 +17,6 @@ import org.springblade.flow.core.vo.ComleteTask; import org.springframework.web.bind.annotation.RequestParam; import java.time.LocalDate; -import java.time.LocalDateTime; import java.util.List; import java.util.Map; 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 1978644..12fcb92 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 @@ -319,7 +319,7 @@ public class ImsDeptServiceImpl extends ServiceImpl