|
|
@ -7,6 +7,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hnac.hzims.EquipmentConstants; |
|
|
|
import com.hnac.hzims.EquipmentConstants; |
|
|
|
import com.hnac.hzims.equipment.entity.EmParamEntity; |
|
|
|
import com.hnac.hzims.equipment.entity.EmParamEntity; |
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.hzimsweather.feign.IHeWeatherWeatherClient; |
|
|
|
|
|
|
|
import com.hnac.hzims.hzimsweather.vo.RainFallCountByMonthVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.fill.entity.RainfallEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.home.wind.RainMon; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.constant.HomePageConstant; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.station.StationConstants; |
|
|
|
import com.hnac.hzims.operational.station.StationConstants; |
|
|
@ -46,6 +50,8 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.math.RoundingMode; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
import java.util.stream.Stream; |
|
|
@ -63,12 +69,18 @@ public class RealTargetServiceImpl implements RealTargetService { |
|
|
|
|
|
|
|
|
|
|
|
private final DataService dataService; |
|
|
|
private final DataService dataService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final WindService windService; |
|
|
|
|
|
|
|
|
|
|
|
private final PowerService powerService; |
|
|
|
private final PowerService powerService; |
|
|
|
|
|
|
|
|
|
|
|
private final DeviceService deviceService; |
|
|
|
private final DeviceService deviceService; |
|
|
|
|
|
|
|
|
|
|
|
private final StationService stationService; |
|
|
|
private final StationService stationService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final StorageService storageService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RainFallService rainFallService; |
|
|
|
|
|
|
|
|
|
|
|
private final GenerateService generateService; |
|
|
|
private final GenerateService generateService; |
|
|
|
|
|
|
|
|
|
|
|
private final DeviceParamService deviceParamService; |
|
|
|
private final DeviceParamService deviceParamService; |
|
|
@ -78,8 +90,8 @@ public class RealTargetServiceImpl implements RealTargetService { |
|
|
|
private final ModelStationService modelStationService; |
|
|
|
private final ModelStationService modelStationService; |
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final WindService windService; |
|
|
|
|
|
|
|
private final StorageService storageService; |
|
|
|
private final IHeWeatherWeatherClient heWeatherWeatherClient; |
|
|
|
|
|
|
|
|
|
|
|
private final IHistoryDataSearchClient historyDataSearchClient; |
|
|
|
private final IHistoryDataSearchClient historyDataSearchClient; |
|
|
|
|
|
|
|
|
|
|
@ -96,6 +108,7 @@ public class RealTargetServiceImpl implements RealTargetService { |
|
|
|
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; |
|
|
|
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key"; |
|
|
|
private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; |
|
|
|
private final static String loadwaterpump_target_key = "hzims:operation:loadwaterpump:target:key"; |
|
|
|
private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real:key"; |
|
|
|
private final static String loadwaterpump_real_key = "hzims:operation:loadwaterpump:real:key"; |
|
|
|
|
|
|
|
private final static String loadwaterpump_rain_key = "hzims:operation:loadwaterpump:rain:key"; |
|
|
|
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; |
|
|
|
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key"; |
|
|
|
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; |
|
|
|
private final static String load_photovoltaic_real_key = "hzims:operation:photovoltaic:real:key"; |
|
|
|
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; |
|
|
|
private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; |
|
|
@ -377,6 +390,120 @@ public class RealTargetServiceImpl implements RealTargetService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 降雨量数据加载 |
|
|
|
|
|
|
|
* @param param |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void loadRainfallTarget(String param) { |
|
|
|
|
|
|
|
// 查询带运维泵站/闸门
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery() |
|
|
|
|
|
|
|
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE) |
|
|
|
|
|
|
|
.in(StationEntity::getType,HomePageConstant.waterList) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(stations)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询水利站点天气降雨
|
|
|
|
|
|
|
|
Map<String,List<RainFallCountByMonthVo>> weathers = this.weatherRains(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
|
|
|
// 查询填报降雨量
|
|
|
|
|
|
|
|
Map<String,List<RainfallEntity>> fills = this.rainFills(stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(weathers) && MapUtils.isEmpty(fills)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map<String,List<RainMon>> rainMap = new HashMap<>(); |
|
|
|
|
|
|
|
stations.forEach(item->{ |
|
|
|
|
|
|
|
List<RainMon> rains = new ArrayList<>(); |
|
|
|
|
|
|
|
if(weathers.containsKey(item.getCode())){ |
|
|
|
|
|
|
|
rains.addAll(weathers.get(item.getCode()).stream().map(weather->{ |
|
|
|
|
|
|
|
RainMon rain = new RainMon(); |
|
|
|
|
|
|
|
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), weather.getYearAndMonth() + "-01"), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
rain.setYear(localDate.getYear()); |
|
|
|
|
|
|
|
rain.setStrMon(weather.getYearAndMonth()); |
|
|
|
|
|
|
|
rain.setMonth(localDate.getMonthValue()); |
|
|
|
|
|
|
|
rain.setRain(weather.getRainFallCount()); |
|
|
|
|
|
|
|
return rain; |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(fills.containsKey(item.getCode())){ |
|
|
|
|
|
|
|
rains.addAll(fills.get(item.getCode()).stream().map(fill->{ |
|
|
|
|
|
|
|
RainMon rain = new RainMon(); |
|
|
|
|
|
|
|
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), fill.getFillDate() + "-01"), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); |
|
|
|
|
|
|
|
rain.setYear(localDate.getYear()); |
|
|
|
|
|
|
|
rain.setStrMon(fill.getFillDate()); |
|
|
|
|
|
|
|
rain.setMonth(localDate.getMonthValue()); |
|
|
|
|
|
|
|
rain.setRain(fill.getRain().doubleValue()); |
|
|
|
|
|
|
|
return rain; |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
rainMap.put(item.getCode(),rains); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(rainMap)){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(loadwaterpump_rain_key,rainMap); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查询天气降雨量 |
|
|
|
|
|
|
|
* @param stationCodes |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<String, List<RainFallCountByMonthVo>> weatherRains(List<String> stationCodes) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
// 当年
|
|
|
|
|
|
|
|
String first = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
|
|
|
|
|
R<Map<String, List<RainFallCountByMonthVo>>> firsts = heWeatherWeatherClient.getRainFallMonthCount(first,String.join(",",stationCodes)); |
|
|
|
|
|
|
|
// 上一年
|
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
|
|
|
|
String second = DateUtil.format(calendar.getTime(),"yyyy"); |
|
|
|
|
|
|
|
R<Map<String, List<RainFallCountByMonthVo>>> seconds = heWeatherWeatherClient.getRainFallMonthCount(second,String.join(",",stationCodes)); |
|
|
|
|
|
|
|
if(!firsts.isSuccess() && !seconds.isSuccess()){ |
|
|
|
|
|
|
|
return new HashMap<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(firsts.getData()) && MapUtils.isEmpty(seconds.getData())){ |
|
|
|
|
|
|
|
return new HashMap<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(MapUtils.isEmpty(firsts.getData())){ |
|
|
|
|
|
|
|
return seconds.getData(); |
|
|
|
|
|
|
|
}else if(MapUtils.isEmpty(seconds.getData())){ |
|
|
|
|
|
|
|
return firsts.getData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Stream.of(firsts.getData(), seconds.getData()) |
|
|
|
|
|
|
|
.flatMap(map -> map.entrySet().stream()) |
|
|
|
|
|
|
|
.collect(Collectors.toMap(Map.Entry::getKey,Map.Entry::getValue,(value1, value2) -> { |
|
|
|
|
|
|
|
List<RainFallCountByMonthVo> rains = new ArrayList<>(); |
|
|
|
|
|
|
|
rains.addAll(value1); |
|
|
|
|
|
|
|
rains.addAll(value2); |
|
|
|
|
|
|
|
return rains; |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查询填报降雨量 |
|
|
|
|
|
|
|
* @param stationCodes |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Map<String, List<RainfallEntity>> rainFills(List<String> stationCodes) { |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,1); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH,-(calendar.get(Calendar.MONTH) + 1)); |
|
|
|
|
|
|
|
String end = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
|
|
|
|
calendar.add(Calendar.YEAR,-1); |
|
|
|
|
|
|
|
calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH)); |
|
|
|
|
|
|
|
String start = DateUtil.format(calendar.getTime(),"yyyy-MM"); |
|
|
|
|
|
|
|
List<RainfallEntity> rains = rainFallService.list(Wrappers.<RainfallEntity>lambdaQuery() |
|
|
|
|
|
|
|
.in(RainfallEntity::getStationCode,stationCodes) |
|
|
|
|
|
|
|
.ge(RainfallEntity::getFillDate,start) |
|
|
|
|
|
|
|
.le(RainfallEntity::getFillDate,end) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(rains)){ |
|
|
|
|
|
|
|
return new HashMap<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return rains.stream().collect(Collectors.groupingBy(RainfallEntity::getStationCode)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 水利-站点水位数据 |
|
|
|
* 水利-站点水位数据 |
|
|
|
* @param param |
|
|
|
* @param param |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1217,9 +1344,8 @@ public class RealTargetServiceImpl implements RealTargetService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Map<String, Float> getGenerateYearByWindEnergy(StationEntity station, String start, String end) { |
|
|
|
private Map<String, Float> getGenerateYearByWindEnergy(StationEntity station, String start, String end) { |
|
|
|
List<PowerMonthVo> datas = new ArrayList<>(); |
|
|
|
// 补充填报数据
|
|
|
|
// 补充填报数据
|
|
|
|
List<PowerMonthVo> datas = new ArrayList<>(this.generateFill(station, start, end)); |
|
|
|
datas.addAll(this.generateFill(station,start,end)); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(datas)){ |
|
|
|
if(CollectionUtil.isEmpty(datas)){ |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|