diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/WindMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/WindMapper.java new file mode 100644 index 0000000..7f49eee --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/WindMapper.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.fill.entity.PowerEntity; +import com.hnac.hzims.operational.fill.entity.WindEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface WindMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/WindService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/WindService.java new file mode 100644 index 0000000..e1215f3 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/WindService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.operation.fill; + +import com.hnac.hzims.operational.fill.entity.WindEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface WindService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/WindServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/WindServiceImpl.java new file mode 100644 index 0000000..f761dff --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/fill/impl/WindServiceImpl.java @@ -0,0 +1,22 @@ +package com.hnac.hzims.scheduled.service.operation.fill.impl; + +import com.hnac.hzims.operational.fill.entity.WindEntity; +import com.hnac.hzims.scheduled.mapper.operation.WindMapper; +import com.hnac.hzims.scheduled.service.operation.fill.WindService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + + +/** + * @author ysj + */ +@Slf4j +@Service +@AllArgsConstructor +public class WindServiceImpl extends BaseServiceImpl implements WindService { + + + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java index 6bbffe2..758a9e3 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ShowServiceImpl.java @@ -31,6 +31,7 @@ import com.hnac.hzims.scheduled.service.operation.plate.DataService; import com.hnac.hzims.scheduled.service.operation.station.StationService; import com.hnac.hzims.scheduled.service.ticket.TicketService; import com.hnac.hzims.scheduled.service.ticket.WorkTicketService; +import com.hnac.hzims.ticket.allTicket.dto.TicketStatisticDTO; import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO; @@ -53,6 +54,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -75,6 +77,7 @@ public class ShowServiceImpl implements ShowService { private final TaskService taskService; private final OverService overService; private final PlanService planService; + private final WindService windService; private final PowerService powerService; private final SolveService solveService; private final OtherService otherService; @@ -318,27 +321,35 @@ public class ShowServiceImpl implements ShowService { if(CollectionUtil.isEmpty(stations)){ return target; } - QueryWrapper queryWrapper = new QueryWrapper() {{ - 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 list = powerService.list(queryWrapper); - if(CollectionUtil.isEmpty(list)){ + // 计划发电量 + List plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()),null, DateUtil.format(new Date(),"yyyy")); + // 填报信息 + List winds = windService.list(Wrappers.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 = plans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + double power = winds.stream().mapToDouble(WindEntity::getPower).sum(); + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() {}); // 装机容量 - target.setTaget_one(list.stream().map(PowerEntity::getInstalledCapacity).collect(Collectors.toSet()).stream().mapToDouble(Double::valueOf).sum()); + 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, RoundingMode.HALF_UP).doubleValue()); } // 双票合格率 - target.setTaget_four(BigDecimal.valueOf(pass / list.size()).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + LocalDate firstDay = LocalDate.now().withDayOfYear(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + R> result = sysClient.getDeptList(); + List 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 = ticketService.doublePassRate(areas, firstDateTime, LocalDateTime.now()); + if (ObjectUtil.isNotEmpty(pass)) { + target.setTaget_four(Double.valueOf(pass.getDoublePassRate())); + } return target; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index 39b5f09..e3c106d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -55,6 +55,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; @@ -75,6 +76,8 @@ public class TargetServiceImpl implements TargetService { private final OverService overService; + private final WindService windService; + private final PowerService powerService; private final SolveService solveService; @@ -232,19 +235,19 @@ public class TargetServiceImpl implements TargetService { }else{ // 查询填报数据 String mon = DateUtil.format(new Date(),"yyyy"); - List powers = powerService.list(Wrappers.lambdaQuery() - .in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) - .ge(PowerEntity::getMon, mon + "-01") + List powers = windService.list(Wrappers.lambdaQuery() + .in(WindEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) + .ge(WindEntity::getFillDate, mon + "-01") ); electrics = stations.stream().map(station -> { ElectricGenerationVo item = new ElectricGenerationVo(); item.setStationName(station.getName()); // 发电量 - List stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + List stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); if(CollectionUtils.isEmpty(stationPowers)){ item.setElectricGeneration(0.0); }else{ - item.setElectricGeneration(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerYear()); + item.setElectricGeneration(stationPowers.stream().sorted(Comparator.comparing(WindEntity::getFillDate).reversed()).collect(Collectors.toList()).get(0).getPower()); } item.setDetail("站点为填报数据,暂无设备装机发电量信息!"); return item; @@ -356,24 +359,32 @@ public class TargetServiceImpl implements TargetService { return item; }).filter(complete->Math.abs(complete.getPlanGeneration()) > 0 || Math.abs(complete.getRealityGeneration()) > 0).collect(Collectors.toList()); }else{ + // 计划发电量 + List plans = planClient.getPlanGenerationByParam(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null, DateUtil.format(new Date(), "yyyy")); String mon = DateUtil.format(new Date(),"yyyy"); - List powers = powerService.list(Wrappers.lambdaQuery() - .in(PowerEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) - .ge(PowerEntity::getMon, mon + "-01") + List powers = windService.list(Wrappers.lambdaQuery() + .in(WindEntity::getCreateDept,stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())) + .ge(WindEntity::getFillDate, mon + "-01") ); generations = stations.stream().map(station -> { CompleteGenerationVo item = new CompleteGenerationVo(); item.setStationName(station.getName()); + if(CollectionUtil.isEmpty(plans)){ + item.setPlanGeneration(0.0); + }else{ + item.setPlanGeneration(plans.stream().filter(plan->plan.getStationId().equals(station.getCode())).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); + } // 发电量 - List stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); + List stationPowers = powers.stream().filter(o->o.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); if(CollectionUtils.isEmpty(stationPowers)){ - item.setPlanGeneration(0.0); item.setRealityGeneration(0.0); - item.setCompleteRate(0.0); }else{ - item.setPlanGeneration(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPlannedPowerYear()); - item.setRealityGeneration(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerYear()); - item.setCompleteRate(Double.valueOf(stationPowers.stream().sorted(Comparator.comparing(PowerEntity::getMon).reversed()).collect(Collectors.toList()).get(0).getPowerRateYear())); + item.setRealityGeneration(stationPowers.stream().mapToDouble(WindEntity::getPower).sum()); + } + if(Math.abs(item.getPlanGeneration()) <= 0 || Math.abs(item.getRealityGeneration()) <= 0){ + item.setCompleteRate(100.0); + }else{ + item.setCompleteRate(BigDecimal.valueOf(item.getRealityGeneration() / item.getPlanGeneration() * 100).setScale(1, RoundingMode.HALF_UP).doubleValue()); } return item; }).collect(Collectors.toList()); @@ -389,13 +400,6 @@ public class TargetServiceImpl implements TargetService { */ @Override public IPage completeTicket(IPage page,String areaName,Integer type) { - // 光伏/风电双票填报数据 - if(HomePageConstant.WIND_POWER.equals(type) || HomePageConstant.PHOTOVOLTAIC.equals(type)){ - List completes = this.getcompleteFillTicket(areaName,type); - page.setTotal(completes.size()); - page.setRecords(completes.stream().skip((page.getCurrent() - 1) * page.getSize()).limit(page.getSize()).collect(Collectors.toList())); - return page; - } // 平台业务数据 List types; if(HomePageConstant.WATER_CONSERVANCY.equals(type)){ @@ -437,6 +441,7 @@ public class TargetServiceImpl implements TargetService { completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); } completes.add(completeTicketVo); + countDownLatch.countDown(); } }else{ for (Dept dept: areas) { @@ -459,9 +464,9 @@ public class TargetServiceImpl implements TargetService { completeTicketVo.setCompleteRate(doublePass.getDoublePassRate()); } completes.add(completeTicketVo); + countDownLatch.countDown(); } } - countDownLatch.countDown(); }); // 等待所有线程执行完成 try { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java index 9f45634..08b06b3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomeServiceImpl.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -276,7 +277,7 @@ public class HomeServiceImpl implements HomeService { target.setTaget_two(power); if(Math.abs(plan) > 0){ // 发电完成率 - target.setTaget_three(BigDecimal.valueOf(power / plan * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + target.setTaget_three(BigDecimal.valueOf(power / plan * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); } // 双票合格率 LocalDate firstDay = LocalDate.now().withDayOfYear(1);