|
|
|
@ -6,15 +6,15 @@ 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.response.weather.HeWeatherWeatherDailyResponse; |
|
|
|
|
import com.hnac.hzims.operational.data.service.HzimsDataService; |
|
|
|
|
import com.hnac.hzims.operational.data.vo.AreaVo; |
|
|
|
|
import com.hnac.hzims.operational.data.vo.ConverElectricityVo; |
|
|
|
|
import com.hnac.hzims.operational.data.vo.LoadWaterLevelVo; |
|
|
|
|
import com.hnac.hzims.operational.data.vo.PowerConvertVo; |
|
|
|
|
import com.hnac.hzims.operational.data.vo.*; |
|
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
|
import com.hnac.hzims.operational.main.service.AreaService; |
|
|
|
|
import com.hnac.hzims.operational.main.service.IAnalyseDataService; |
|
|
|
|
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; |
|
|
|
|
import com.hnac.hzims.operational.main.service.IWeatherService; |
|
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
|
import com.hnac.hzims.operational.station.entity.HzimsAnalyzeModelStationEntity; |
|
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
@ -67,16 +67,18 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
|
|
|
|
|
private final IStationService stationService; |
|
|
|
|
|
|
|
|
|
private final IWeatherService weatherService; |
|
|
|
|
|
|
|
|
|
private final IAnalyseDataService dataService; |
|
|
|
|
|
|
|
|
|
private final IHzimsAnalyzeModelStationService modelStationService; |
|
|
|
|
|
|
|
|
|
private final IMainSystemMonitoringService maintenanceTaskService; |
|
|
|
|
|
|
|
|
|
private final IEmInfoClient deviceClient; |
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
private final IEmInfoClient deviceClient; |
|
|
|
|
|
|
|
|
|
private final IPlanGenertionClient planGenertionClient; |
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
@ -88,6 +90,8 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
|
|
|
|
|
private final static String conver_power_key = "hzims:operation:conver:power:"; |
|
|
|
|
|
|
|
|
|
private final static String conver_weather_key = "hzims:operation:conver:weather:"; |
|
|
|
|
|
|
|
|
|
private final static String recent_year_power_data = "hzims:operation:key:power:data"; |
|
|
|
|
|
|
|
|
|
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; |
|
|
|
@ -235,6 +239,40 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 站点天气、降雨、水位 |
|
|
|
|
* @param stationCode |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public WeatherWaterVo weather(String stationCode) { |
|
|
|
|
WeatherWaterVo redisCache = (WeatherWaterVo) redisTemplate.opsForValue().get(conver_weather_key + stationCode); |
|
|
|
|
if(!ObjectUtil.isEmpty(redisCache)){ |
|
|
|
|
return redisCache; |
|
|
|
|
} |
|
|
|
|
WeatherWaterVo weatherWater = new WeatherWaterVo(); |
|
|
|
|
// 查询站点
|
|
|
|
|
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery(). |
|
|
|
|
eq(StationEntity::getCode,stationCode) |
|
|
|
|
); |
|
|
|
|
if(ObjectUtil.isEmpty(station)){ |
|
|
|
|
return new WeatherWaterVo(); |
|
|
|
|
} |
|
|
|
|
weatherWater.setStationName(station.getName()); |
|
|
|
|
// 七天天气
|
|
|
|
|
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.getWeekWeather(Collections.singletonList(station.getCode())); |
|
|
|
|
if(!MapUtils.isEmpty(weekWeather)){ |
|
|
|
|
HeWeatherWeatherDailyResponse week = weekWeather.get(stationCode); |
|
|
|
|
if(!ObjectUtil.isEmpty(week)){ |
|
|
|
|
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); |
|
|
|
|
return weatherWater; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 站点功率换算电量 |
|
|
|
|
* @param stationCode |
|
|
|
|
* @return |
|
|
|
@ -263,6 +301,58 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
return convert; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取七天天气 |
|
|
|
|
* @param codes |
|
|
|
|
*/ |
|
|
|
|
private Map<String, HeWeatherWeatherDailyResponse> getWeekWeather(List codes) { |
|
|
|
|
if(CollectionUtil.isEmpty(codes)){ |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
// 实时天气
|
|
|
|
|
return this.weatherService.getWeekWeather(codes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 30天水位、降雨量 |
|
|
|
|
* @param stationCode |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<WeatherRainVo> waterRain(String stationCode) { |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
String endTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
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); |
|
|
|
|
// 查询水位数据
|
|
|
|
|
List<AnalyseDataTaosVO> waters = this.water(startTime,endTime,stationCode); |
|
|
|
|
// TODO 查询降雨数据
|
|
|
|
|
// 近30天水位、降雨量
|
|
|
|
|
List<String> days = this.get30Day(); |
|
|
|
|
return days.stream().map(day->{ |
|
|
|
|
WeatherRainVo weatherRain = new WeatherRainVo(); |
|
|
|
|
weatherRain.setTime(day); |
|
|
|
|
// 水位
|
|
|
|
|
if(CollectionUtil.isEmpty(waters)){ |
|
|
|
|
weatherRain.setWater(0.0); |
|
|
|
|
}else{ |
|
|
|
|
weatherRain.setWater(waters.stream().filter(o->o.getTs().contains(day)).mapToDouble(water->{ |
|
|
|
|
if(StringUtil.isEmpty(water.getVal())){ |
|
|
|
|
return 0.0; |
|
|
|
|
}else{ |
|
|
|
|
return Double.parseDouble(water.getVal()); |
|
|
|
|
} |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
// TODO 降雨量数据
|
|
|
|
|
weatherRain.setRain(0.0); |
|
|
|
|
return weatherRain; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询近30天发电量 |
|
|
|
|
* @param deptId |
|
|
|
@ -375,7 +465,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 水位查询
|
|
|
|
|
return dataService.periodTargetData(startTime,endTime,3,2,model.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); |
|
|
|
|
return dataService.periodTargetData(startTime,endTime,3,3,model.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -400,6 +490,28 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取30天 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<String> get30Day() { |
|
|
|
|
List<String> times = new ArrayList<>(); |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
Date end = calendar.getTime(); |
|
|
|
|
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); |
|
|
|
|
Date start = calendar.getTime(); |
|
|
|
|
while (start.compareTo(end) < 0) { |
|
|
|
|
times.add(DateUtil.format(calendar.getTime(),"yyyy-MM-dd")); |
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
} |
|
|
|
|
return times; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取24小时 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|