|
|
|
@ -5,6 +5,8 @@ import com.alibaba.fastjson.TypeReference;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
|
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; |
|
|
|
|
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; |
|
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.Daily; |
|
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; |
|
|
|
@ -92,6 +94,7 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
|
|
|
|
|
private final ITicketInfoClient ticketInfoClient; |
|
|
|
|
|
|
|
|
|
private final IPlanGenertionClient planClient; |
|
|
|
|
|
|
|
|
|
private final IInspectTaskReportClient inspectTaskReportClient; |
|
|
|
|
|
|
|
|
@ -130,7 +133,8 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
// 年发电量
|
|
|
|
|
score.setGenerateYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
// 年计划发电量
|
|
|
|
|
score.setPlanYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
List<PlanGenerationEntity> yearPlans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
score.setPlanYear(yearPlans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
// 年发电完成率
|
|
|
|
|
if(Math.abs(score.getGenerateYear()) > 0 && Math.abs(score.getPlanYear()) > 0){ |
|
|
|
|
score.setCompleteRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
@ -138,7 +142,7 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
// 月发电量
|
|
|
|
|
score.setGenerateMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
// 月计划发电量
|
|
|
|
|
score.setPlanMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
score.setPlanMon(yearPlans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
// 月发电量完成率
|
|
|
|
|
if(Math.abs(score.getGenerateMon()) > 0 && Math.abs(score.getPlanMon()) > 0){ |
|
|
|
|
score.setCompleteMonRate(BigDecimal.valueOf(score.getGenerateMon() / score.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
@ -191,12 +195,13 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
*/ |
|
|
|
|
private List<PowerMonthVo> currentGenerateCurve(List<WindEntity> winds) { |
|
|
|
|
List<String> mons = this.mons(0,12,false); |
|
|
|
|
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(winds.stream().map(WindEntity::getStationCode).distinct().collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
return mons.stream().map(mon->{ |
|
|
|
|
PowerMonthVo power = new PowerMonthVo(); |
|
|
|
|
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
power.setYear(localDate.getYear()); |
|
|
|
|
power.setStrMonth(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue()); |
|
|
|
|
power.setPlanPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
power.setPlanPower((float) plans.stream().filter(o->o.getDateTime().contains(power.getYear() + "-" + power.getStrMonth())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
power.setPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
return power; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
@ -256,23 +261,33 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
// 集团发电占比
|
|
|
|
|
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(winds.stream().mapToDouble(WindEntity::getPower).sum()) > 0){ |
|
|
|
|
subordinate.setGenerationRate(BigDecimal.valueOf(subordinate.getGeneration() / winds.stream().mapToDouble(WindEntity::getPower).sum() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
}else{ |
|
|
|
|
subordinate.setGenerationRate(0.0); |
|
|
|
|
} |
|
|
|
|
// 计划发电量查询
|
|
|
|
|
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
double plan = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); |
|
|
|
|
// 发电完成率
|
|
|
|
|
double plan = piece.stream().mapToDouble(WindEntity::getPlan).sum(); |
|
|
|
|
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(plan) > 0){ |
|
|
|
|
subordinate.setGenerationComplete(BigDecimal.valueOf(subordinate.getGeneration() / plan * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
}else{ |
|
|
|
|
subordinate.setGenerationComplete(0.0); |
|
|
|
|
} |
|
|
|
|
// 风机利用率 : (总时间 - 故障时间) / 总时间
|
|
|
|
|
double fault = piece.stream().mapToDouble(WindEntity::getFaultHours).sum(); |
|
|
|
|
double use = piece.stream().mapToDouble(WindEntity::getAvailable).sum(); |
|
|
|
|
if(Math.abs(fault) > 0 ){ |
|
|
|
|
subordinate.setFanUse(BigDecimal.valueOf(use / (use + fault) * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
}else{ |
|
|
|
|
subordinate.setFanUse(0.0); |
|
|
|
|
} |
|
|
|
|
// 厂用电率 : (发电量-上网电量+下网电量)/发电量
|
|
|
|
|
double surf = piece.stream().mapToDouble(WindEntity::getSurfPower).sum(); |
|
|
|
|
double below = piece.stream().mapToDouble(WindEntity::getBelowPower).sum(); |
|
|
|
|
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(surf + below) > 0){ |
|
|
|
|
subordinate.setFactoryUse(BigDecimal.valueOf((subordinate.getGeneration() - surf + below) / subordinate.getGeneration() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
}else{ |
|
|
|
|
subordinate.setFactoryUse(0.0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return subordinate; |
|
|
|
@ -311,9 +326,9 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
} |
|
|
|
|
// 装机容量
|
|
|
|
|
kpi.setCapacity(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum()); |
|
|
|
|
|
|
|
|
|
// 计划发电量
|
|
|
|
|
kpi.setPlan(winds.stream().mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
kpi.setPlan(plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
// 实际发电量
|
|
|
|
|
kpi.setGenerate(winds.stream().mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
// 发电量完成率
|
|
|
|
@ -366,12 +381,14 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
in(WindEntity::getStationCode,codes) |
|
|
|
|
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
}}); |
|
|
|
|
// 计划发电量
|
|
|
|
|
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(codes, null,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
return areas.entrySet().stream().map(entry -> { |
|
|
|
|
WindAreaVo area = new WindAreaVo(); |
|
|
|
|
area.setDeptId(entry.getKey().getId()); |
|
|
|
|
area.setDeptName(entry.getKey().getDeptName()); |
|
|
|
|
List<String> stationCodes = entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()); |
|
|
|
|
area.setPlan(winds.stream().filter(o-> stationCodes.contains(o.getStationCode())).mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
area.setPlan(plans.stream().filter(o-> stationCodes.contains(o.getStationId())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
area.setGenerate(winds.stream().filter(o-> stationCodes.contains(o.getStationCode())).mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
if(Math.abs(area.getPlan()) > 0 && Math.abs(area.getGenerate()) > 0){ |
|
|
|
|
area.setGenerateComplete(BigDecimal.valueOf(area.getGenerate() / area.getPlan() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
@ -495,24 +512,27 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
areaDuty.setSpeed(winds.stream().mapToDouble(WindEntity::getSpeed).average().orElse(0.0)); |
|
|
|
|
areaDuty.setSurfPower(winds.stream().mapToDouble(WindEntity::getSurfPower).sum()); |
|
|
|
|
areaDuty.setBelowPower(winds.stream().mapToDouble(WindEntity::getBelowPower).sum()); |
|
|
|
|
areaDuty.setAvailable(winds.stream().mapToDouble(WindEntity::getAvailable).average().orElse(0.0)); |
|
|
|
|
areaDuty.setAvailable(winds.stream().mapToDouble(WindEntity::getAvailable).sum()); |
|
|
|
|
areaDuty.setComprehensivePower(winds.stream().mapToDouble(WindEntity::getComprehensivePower).sum()); |
|
|
|
|
areaDuty.setPeakPower(winds.stream().mapToDouble(WindEntity::getPeakPower).average().orElse(0.0)); |
|
|
|
|
areaDuty.setFaultHours(winds.stream().mapToDouble(WindEntity::getFaultHours).average().orElse(0.0)); |
|
|
|
|
} |
|
|
|
|
// 填报发电量
|
|
|
|
|
List<WindEntity> windMons = windService.list(new LambdaQueryWrapper<WindEntity>() {{ |
|
|
|
|
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) |
|
|
|
|
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy-MM")); |
|
|
|
|
}}); |
|
|
|
|
// 计划发电量
|
|
|
|
|
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy-MM")); |
|
|
|
|
if(CollectionUtil.isNotEmpty(windMons)){ |
|
|
|
|
areaDuty.setGenerateMon(windMons.stream().mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
// 月计划发电量
|
|
|
|
|
areaDuty.setPlanMon(windMons.stream().mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
areaDuty.setPlanMon(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
// 月发电量完成率
|
|
|
|
|
if(Math.abs(areaDuty.getGenerateMon()) > 0 && Math.abs(areaDuty.getPlanMon()) > 0){ |
|
|
|
|
areaDuty.setCompleteMonRate(BigDecimal.valueOf(areaDuty.getGenerateMon() / areaDuty.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
} |
|
|
|
|
areaDuty.setAvailable(windMons.stream().mapToDouble(WindEntity::getAvailable).average().getAsDouble()); |
|
|
|
|
areaDuty.setAvailableMon(windMons.stream().mapToDouble(WindEntity::getAvailable).sum()); |
|
|
|
|
} |
|
|
|
|
List<WindEntity> windYears = windService.list(new LambdaQueryWrapper<WindEntity>() {{ |
|
|
|
|
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) |
|
|
|
@ -521,7 +541,7 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
if(CollectionUtil.isEmpty(windYears)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
areaDuty.setPlan(windYears.stream().mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
areaDuty.setPlan(plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
areaDuty.setGenerate(windYears.stream().mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
// 发电量完成率
|
|
|
|
|
if(Math.abs(areaDuty.getPlan()) > 0 && Math.abs(areaDuty.getGenerate()) > 0){ |
|
|
|
@ -806,13 +826,15 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) |
|
|
|
|
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
}}); |
|
|
|
|
// 计划发电量
|
|
|
|
|
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
// 设备
|
|
|
|
|
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {}); |
|
|
|
|
subordinate.setStations(stations.stream().map(station -> { |
|
|
|
|
WindStationGenerateVo generate = new WindStationGenerateVo(); |
|
|
|
|
generate.setDeptId(station.getRefDept()); |
|
|
|
|
generate.setDeptName(station.getName()); |
|
|
|
|
generate.setPlan(winds.stream().filter(o-> o.getStationCode().equals(station.getCode())).mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
generate.setPlan(plans.stream().filter(o-> o.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
generate.setGenerate(winds.stream().filter(o-> o.getStationCode().equals(station.getCode())).mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
// 发电量完成率
|
|
|
|
|
if(Math.abs(generate.getPlan()) > 0 && Math.abs(generate.getGenerate()) > 0){ |
|
|
|
@ -918,11 +940,13 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
List<WindEntity> all = windService.list(Wrappers.<WindEntity>lambdaQuery() |
|
|
|
|
.eq(WindEntity::getStationCode,station.getCode()) |
|
|
|
|
); |
|
|
|
|
// 计划发电量
|
|
|
|
|
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(Collections.singletonList(station.getCode()), null,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
if(CollectionUtil.isNotEmpty(all)){ |
|
|
|
|
// 年计划发电量
|
|
|
|
|
wind.setPlanYear(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
wind.setPlanYear(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
// 月计划发电量
|
|
|
|
|
wind.setPlanMon(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
wind.setPlanMon(plans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
// 总发电量
|
|
|
|
|
wind.setGeneration(all.stream().mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
// 日上网电量
|
|
|
|
@ -960,12 +984,14 @@ public class WindHomeServiceImpl implements WindHomeService {
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
List<String> monList = this.mons(1,12,false); |
|
|
|
|
// 计划发电量查询
|
|
|
|
|
List<PlanGenerationEntity> plans = planClient.getPlanGenerationByParam(Collections.singletonList(station.getCode()), null,DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
return monList.stream().map(mon->{ |
|
|
|
|
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
WindGenerationVo generation = new WindGenerationVo(); |
|
|
|
|
generation.setYear(localDate.getYear()); |
|
|
|
|
generation.setMon(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue()); |
|
|
|
|
generation.setPlan(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPlan).sum()); |
|
|
|
|
generation.setPlan(plans.stream().filter(o->o.getDateTime().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); |
|
|
|
|
generation.setGeneration(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPower).sum()); |
|
|
|
|
return generation; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|