From b788368e36cd2d9b0ee1b11e6250258d33c4f196 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 22 Feb 2024 09:31:38 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=BC=94=E7=A4=BA=E5=A4=A7=E5=B1=8F=E9=99=8D?= =?UTF-8?q?=E9=9B=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/service/impl/HzimsDataServiceImpl.java | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java index dd9ac56..0255687 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java @@ -6,6 +6,7 @@ import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.hzimsweather.feign.IRainfallClient; import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; import com.hnac.hzims.operational.data.service.HzimsDataService; import com.hnac.hzims.operational.data.vo.AreaVo; @@ -78,6 +79,8 @@ public class HzimsDataServiceImpl implements HzimsDataService { private final IEmInfoClient deviceClient; + private final IRainfallClient rainfallClient; + private final IPlanGenertionClient planGenertionClient; private final RedisTemplate redisTemplate; @@ -284,6 +287,7 @@ public class HzimsDataServiceImpl implements HzimsDataService { weatherWater.setDailys(week.getDaily()); } } + // 水位、降雨 weatherWater.setWeatherRains(this.waterRain(stationCode)); redisTemplate.opsForValue().set(conver_weather_key + stationCode,weatherWater); redisTemplate.expire(conver_weather_key + stationCode,30, TimeUnit.MINUTES); @@ -340,14 +344,17 @@ public class HzimsDataServiceImpl implements HzimsDataService { private List waterRain(String stationCode) { Calendar calendar = Calendar.getInstance(); String endTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + String rainEnd = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); calendar.add(Calendar.MINUTE,-calendar.get(Calendar.MINUTE)); calendar.add(Calendar.SECOND,-calendar.get(Calendar.SECOND)); calendar.add(Calendar.DAY_OF_MONTH,-29); String startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + String rainStart = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); // 查询水位数据 List waters = this.water(startTime,endTime,stationCode,3); - // TODO 查询降雨数据 + // 查询降雨数据 + R>> rains = rainfallClient.getDurationRainFall(stationCode,rainStart,rainEnd); // 近30天水位、降雨量 List days = this.get30Day(); return days.stream().map(day->{ @@ -365,8 +372,22 @@ public class HzimsDataServiceImpl implements HzimsDataService { } }).sum()); } - // TODO 降雨量数据 - weatherRain.setRain(0.0); + // 降雨 + if(!rains.isSuccess() || CollectionUtil.isEmpty(rains.getData())){ + weatherRain.setRain(0.0); + }else{ + weatherRain.setRain(rains.getData().stream().mapToDouble(map->{ + if (map.get("fx_date").equals(day)) { + Object object = map.get("precip"); + if(ObjectUtil.isEmpty(object)){ + return 0.0; + }else{ + return Double.parseDouble(object.toString()); + } + } + return 0.0; + }).sum()); + } return weatherRain; }).collect(Collectors.toList()); }