Browse Source

#演示大屏降雨修改

zhongwei
yang_shj 9 months ago
parent
commit
b788368e36
  1. 27
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java

27
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<WeatherRainVo> 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<AnalyseDataTaosVO> waters = this.water(startTime,endTime,stationCode,3);
// TODO 查询降雨数据
// 查询降雨数据
R<List<Map<String, Object>>> rains = rainfallClient.getDurationRainFall(stationCode,rainStart,rainEnd);
// 近30天水位、降雨量
List<String> 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());
}

Loading…
Cancel
Save