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/IWebHomeService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java similarity index 83% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IWebHomeService.java rename to hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/HydropowerService.java index c09cf15..b7a0576 100644 --- 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/HydropowerService.java @@ -2,14 +2,13 @@ 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 { +public interface HydropowerService { void loadHydropowerReal(String param); 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/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/WebHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java similarity index 99% rename from hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WebHomeServiceImpl.java rename to hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index ef89f5a..8393825 100644 --- 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/HydropowerServiceImpl.java @@ -30,7 +30,6 @@ 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; @@ -43,7 +42,7 @@ import java.util.stream.Collectors; */ @Service @RequiredArgsConstructor -public class WebHomeServiceImpl implements IWebHomeService { +public class HydropowerServiceImpl implements HydropowerService { private final IAnalyseDataService analyseDataService; 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/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