|
|
|
@ -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<StationEntity> stations = stationService.list(new LambdaQueryWrapper<StationEntity>() {{ |
|
|
|
|
eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
|
eq(StationEntity::getType,HomePageConstant.WIND_POWER); |
|
|
|
|
}}); |
|
|
|
|
if(CollectionUtil.isNotEmpty(stations)){ |
|
|
|
|
return new WindScoreVo(); |
|
|
|
|
} |
|
|
|
|
// 查询站点年填报数据
|
|
|
|
|
List<WindEntity> years = windService.list(new LambdaQueryWrapper<WindEntity>() {{ |
|
|
|
|
like(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
}}); |
|
|
|
|
// 查询站点月填报数据
|
|
|
|
|
List<WindEntity> mons = windService.list(new LambdaQueryWrapper<WindEntity>() {{ |
|
|
|
|
like(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy-MM")); |
|
|
|
|
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
}}); |
|
|
|
|
// 查询站点日填报数据
|
|
|
|
|
List<WindEntity> days = windService.list(new LambdaQueryWrapper<WindEntity>() {{ |
|
|
|
|
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<WindEntity> 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<WindEntity> 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<WindEntity> days, WindScoreVo score) { |
|
|
|
|
// 日发电量
|
|
|
|
|
score.setGenerateDay(days.stream().mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
} |
|
|
|
|
} |