|
|
|
@ -1,12 +1,14 @@
|
|
|
|
|
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.conditions.query.QueryWrapper; |
|
|
|
|
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.operational.fill.entity.*; |
|
|
|
|
import com.hnac.hzims.operational.fill.service.*; |
|
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
@ -55,6 +57,8 @@ import java.util.stream.Collectors;
|
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
public class HomeServiceImpl implements HomeService { |
|
|
|
|
|
|
|
|
|
private final WindService windService; |
|
|
|
|
|
|
|
|
|
private final OverService overService; |
|
|
|
|
|
|
|
|
|
private final OtherService otherService; |
|
|
|
@ -82,6 +86,8 @@ public class HomeServiceImpl implements HomeService {
|
|
|
|
|
@Value("${hzims.operation.homePage.charge.url}") |
|
|
|
|
public String charge_url; |
|
|
|
|
|
|
|
|
|
public final static String device_cache_final = "hzims:equipment:emInfo:deviceCode.emInfoList"; |
|
|
|
|
|
|
|
|
|
private final static String load_home_target_key = "load:operation:home:target:key"; |
|
|
|
|
private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; |
|
|
|
|
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; |
|
|
|
@ -234,27 +240,32 @@ public class HomeServiceImpl implements HomeService {
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
return target; |
|
|
|
|
} |
|
|
|
|
QueryWrapper<PowerEntity> queryWrapper = new QueryWrapper<PowerEntity>() {{ |
|
|
|
|
in("create_dept", stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); |
|
|
|
|
eq("type", HomePageConstant.WIND_POWER_TYPE); |
|
|
|
|
likeRight("mon", DateUtil.format(new Date(),"yyyy")); |
|
|
|
|
}}; |
|
|
|
|
List<PowerEntity> list = powerService.list(queryWrapper); |
|
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
|
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery() |
|
|
|
|
.in(WindEntity::getStationCode, stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) |
|
|
|
|
.likeRight(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy"))); |
|
|
|
|
if(CollectionUtil.isEmpty(winds)){ |
|
|
|
|
return target; |
|
|
|
|
} |
|
|
|
|
double plan = list.stream().mapToDouble(PowerEntity::getPlannedPowerMon).sum(); |
|
|
|
|
double pass = list.stream().mapToDouble(power -> Double.parseDouble(power.getDoubleQualifyRate())).sum(); |
|
|
|
|
double plan = winds.stream().mapToDouble(WindEntity::getPlan).sum(); |
|
|
|
|
double power = winds.stream().mapToDouble(WindEntity::getPower).sum(); |
|
|
|
|
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {}); |
|
|
|
|
// 装机容量
|
|
|
|
|
target.setTaget_one(list.get(0).getInstalledCapacity()); |
|
|
|
|
target.setTaget_one(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum()); |
|
|
|
|
// 发电量
|
|
|
|
|
target.setTaget_two(list.stream().mapToDouble(PowerEntity::getPowerMon).sum()); |
|
|
|
|
target.setTaget_two(power); |
|
|
|
|
if(Math.abs(plan) > 0){ |
|
|
|
|
// 发电完成率
|
|
|
|
|
target.setTaget_three(BigDecimal.valueOf(target.getTaget_two() / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
target.setTaget_three(BigDecimal.valueOf(power / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
} |
|
|
|
|
// 双票合格率
|
|
|
|
|
target.setTaget_four(BigDecimal.valueOf(pass / list.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
LocalDate firstDay = LocalDate.now().withDayOfYear(1); |
|
|
|
|
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); |
|
|
|
|
R<List<Dept>> result = sysClient.getDeptList(); |
|
|
|
|
List<Long> areas = result.getData().stream().filter(dept -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(dept.getId())).map(Dept::getParentId).collect(Collectors.toList()); |
|
|
|
|
DoublePassRateVO pass = ticketClient.getDoublePassRate(areas, firstDateTime, LocalDateTime.now()); |
|
|
|
|
if (ObjectUtil.isNotEmpty(pass)) { |
|
|
|
|
target.setTaget_four(Double.valueOf(pass.getDoublePassRate())); |
|
|
|
|
} |
|
|
|
|
return target; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|