From 791cfbf76f55f41114f1911184a34a9586177015 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 8 Jul 2024 10:22:03 +0800 Subject: [PATCH] =?UTF-8?q?#=E7=AB=99=E7=82=B9=E9=A1=B5=E9=9D=A2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/service/impl/HydropowerServiceImpl.java | 52 +++++++--------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index 1d72374..8519dbb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -147,8 +147,7 @@ public class HydropowerServiceImpl implements HydropowerService { response.setDeptName(station.getName()); response.setStationCode(station.getCode()); // 站点状态 - List soeDataList = soeClient.getByLastLimitTime(null, station.getCode(), 1).getData(); - response.setStationStatus(!CollectionUtil.isNotEmpty(soeDataList)); + response.setStationStatus(true); // 站点实时天气 response.setTemp(this.getTemp(weather,station.getCode())); // 站点七天天气 @@ -167,9 +166,7 @@ public class HydropowerServiceImpl implements HydropowerService { response.setPlanPowerMon(this.getPlanPowerrMon(station.getCode())); // 年计划发电量 response.setPlanPowerYear(this.getPlanPowerYear(station.getCode())); - // 年发电量、年发电完成率 - this.handleStationInfo(station.getRefDept(),response); - // 月发电量 + // 年发电量、月发电量 this.stationMonthPower(station.getId(),map,response); // 水位、水位曲线 this.handleWaterLeve(station.getCode(),response); @@ -391,33 +388,6 @@ public class HydropowerServiceImpl implements HydropowerService { return R.getData(); } - /** - * 站点信息处理 - * @param deptId - * @param response - */ - private void handleStationInfo(Long deptId, HydropowerStationVo response) { - response.setPowerYear(0f); - response.setPowerRateYear(0.0); - List targetList = (List) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); - if(CollectionUtil.isEmpty(targetList)){ - return; - } - // 月发电量 - float powerMon = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum(); - response.setPowerYear(powerMon); - // 年发电量 - float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); - response.setPowerYear(powerYear); - // 年发电完成率 - float planPowerYear = response.getPlanPowerYear(); - if(Math.abs(planPowerYear) <= 0){ - response.setPowerRateYear(0.0); - } else { - double powerRateYear = BigDecimal.valueOf(powerYear / planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); - response.setPowerRateYear(powerRateYear); - } - } /** * 月发电量 @@ -430,11 +400,24 @@ public class HydropowerServiceImpl implements HydropowerService { response.setPowerMon(0f); return; } + // 月发电量 String month = DateUtil.format(new Date(),"yyyy-MM") + "-01"; float powerMon = map.get(id).getOrDefault(month, 0f); if(powerMon > 0){ response.setPowerMon(powerMon); } + String year = DateUtil.format(new Date(),"yyyy"); + // 年发电量 + float powerYear = (float) map.get(id).entrySet().stream().filter(o->o.getKey().contains(year)).mapToDouble(Map.Entry::getValue).sum(); + response.setPowerYear(powerYear); + // 年发电完成率 + float planPowerYear = response.getPlanPowerYear(); + if(Math.abs(planPowerYear) <= 0){ + response.setPowerRateYear(0.0); + } else { + double powerRateYear = BigDecimal.valueOf(powerYear / planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); + response.setPowerRateYear(powerRateYear); + } } @@ -559,8 +542,7 @@ public class HydropowerServiceImpl implements HydropowerService { hydropower.setDeptName(station.getName()); hydropower.setStationCode(station.getCode()); // 站点状态 - List soeDataList = soeClient.getByLastLimitTime(null, station.getCode(), 1).getData(); - hydropower.setStationStatus(!CollectionUtil.isNotEmpty(soeDataList)); + hydropower.setStationStatus(true); // 站点实时天气 hydropower.setTemp(this.getTemp(weather,station.getCode())); // 站点七天天气 @@ -580,7 +562,7 @@ public class HydropowerServiceImpl implements HydropowerService { // 年计划发电量 hydropower.setPlanPowerYear(this.getPlanPowerYear(station.getCode())); // 月发电量、年发电量、年发电完成率 - this.handleStationInfo(station.getRefDept(),hydropower); + this.stationMonthPower(station.getId(),map,hydropower); // 水位、水位曲线 this.handleWaterLeve(station.getCode(),hydropower); // 年发电量完成百分比