diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindScoreVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindScoreVo.java index 71a6019..a0a83c2 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindScoreVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindScoreVo.java @@ -36,10 +36,18 @@ public class WindScoreVo { @JsonSerialize(nullsUsing = NullSerializer.class) private Double generateMon; + @ApiModelProperty(value = "年计划发电量") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double planYear; + @ApiModelProperty(value = "年总发电量") @JsonSerialize(nullsUsing = NullSerializer.class) private Double generateYear; + @ApiModelProperty(value = "年发电量完成率") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Double completeRate; + @ApiModelProperty(value = "月平均风速") @JsonSerialize(nullsUsing = NullSerializer.class) private Double speedRate; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index d1544a2..d03e205 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -198,6 +198,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ entity.setTaskName("流程结束"); entity.setNextStepOperator("流程结束,无需人员处理"); entity.setActEndTime(new Date()); + entity.setStatus(4); // 开启检修任务 this.startTaskProcess(entity); return this.planService.updateById(entity); @@ -228,6 +229,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ for(OperAccessContentDTO item : entity.getAccessContents()){ //任务参数 AccessTaskV4DTO task = BeanUtil.copy(item, AccessTaskV4DTO.class); + task.setStatus(1); task.setCreateTime(new Date()); task.setCreateUser(entity.getCreateUser()); task.setProcDefId(entity.getProcDefId()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WindHomeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WindHomeController.java index 329aef3..cdebc22 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WindHomeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WindHomeController.java @@ -27,7 +27,7 @@ public class WindHomeController extends BladeController { private final WindHomeService service; @ApiLog - @ApiOperation("水电站集团/区域指标") + @ApiOperation("风电站集团/区域指标") @GetMapping("/KPIs") @ApiOperationSupport(order = 1) public R KPIs(@ApiParam(value = "站点机构ID") Long deptId) { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java index 920bfe9..7664127 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java @@ -1,11 +1,24 @@ package com.hnac.hzims.operational.main.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.operational.fill.entity.WindEntity; +import com.hnac.hzims.operational.fill.service.WindService; +import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.service.WindHomeService; import com.hnac.hzims.operational.main.vo.WindScoreVo; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + /** * @author ysj */ @@ -14,8 +27,85 @@ import org.springframework.stereotype.Service; @Slf4j public class WindHomeServiceImpl implements WindHomeService { + private final IStationService stationService; + + private final WindService windService; + @Override public WindScoreVo KPIs(Long deptId) { - return null; + // 查询风电站 + List stations = stationService.list(new LambdaQueryWrapper() {{ + eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE); + eq(StationEntity::getType,HomePageConstant.WIND_POWER); + }}); + if(CollectionUtil.isNotEmpty(stations)){ + return new WindScoreVo(); + } + // 查询站点年填报数据 + List years = windService.list(new LambdaQueryWrapper() {{ + like(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy")); + in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + }}); + // 查询站点月填报数据 + List mons = windService.list(new LambdaQueryWrapper() {{ + like(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy-MM")); + in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + }}); + // 查询站点日填报数据 + List days = windService.list(new LambdaQueryWrapper() {{ + like(WindEntity::getFillDate, DateUtil.format(new Date(), DateUtil.format(new Date(),DateUtil.PATTERN_DATE))); + in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + }}); + WindScoreVo score = new WindScoreVo(); + score.setStationCount(stations.size()); + this.year(years,score); + this.mon(mons,score); + this.days(days,score); + return score; + } + + /** + * 风电数据 - 年 + * @param years + * @param score + */ + private void year(List years, WindScoreVo score) { + if(CollectionUtil.isNotEmpty(years)){ + return; + } + // 年发电量 + score.setGenerateYear(years.stream().mapToDouble(WindEntity::getPower).sum()); + // 年计划发电量 + score.setPlanYear(years.stream().mapToDouble(WindEntity::getPlan).sum()); + // 年发电完成率 + if(Math.abs(score.getGenerateYear()) > 0 && Math.abs(score.getPlanYear()) > 0){ + score.setSpeedRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + } + + /** + * 风电数据 - 月 + * @param mons + * @param score + */ + private void mon(List mons, WindScoreVo score) { + // 月发电量 + score.setGenerateMon(mons.stream().mapToDouble(WindEntity::getPower).sum()); + // 月平均风速 + score.setSpeedRate(mons.stream().mapToDouble(WindEntity::getSpeed).average().getAsDouble()); + // 月短期准确率 + score.setAccuracy(mons.stream().mapToDouble(WindEntity::getAccuracy).average().getAsDouble()); + // 月超短期准确率 + score.setUltraShortAccuracyRate(mons.stream().mapToDouble(WindEntity::getUltraShortAccuracy).average().getAsDouble()); + } + + /** + * 风电数据 - 日 + * @param days + * @param score + */ + private void days(List days, WindScoreVo score) { + // 日发电量 + score.setGenerateDay(days.stream().mapToDouble(WindEntity::getPower).sum()); } } \ No newline at end of file