|
|
|
@ -3,17 +3,26 @@ package com.hnac.hzims.operational.data.service.impl;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
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; |
|
|
|
|
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; |
|
|
|
|
import com.hnac.hzims.operational.station.service.IHzimsAnalyzeModelStationService; |
|
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
|
import com.hnac.hzims.operational.station.vo.HzimsStationCountVo; |
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; |
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
@ -40,6 +49,7 @@ import java.time.LocalDate;
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -57,10 +67,20 @@ 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 ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
private final IEmInfoClient deviceClient; |
|
|
|
|
|
|
|
|
|
private final IRainfallClient rainfallClient; |
|
|
|
|
|
|
|
|
|
private final IPlanGenertionClient planGenertionClient; |
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
@ -70,6 +90,13 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
@Value("${hzims.operation.save.station.url}") |
|
|
|
|
public String STATION_URL; |
|
|
|
|
|
|
|
|
|
private final static String charge = "hzims:operation:key:charge"; |
|
|
|
|
|
|
|
|
|
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"; |
|
|
|
@ -114,17 +141,33 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
return this.sendMessage(JSONObject.toJSONBytes(list),AREA_URL); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取站点统计数据 |
|
|
|
|
* 站点数量统计 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public boolean saveStation() { |
|
|
|
|
List<HzimsStationCountVo> list = this.stationService.getStationCount(); |
|
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
|
return false; |
|
|
|
|
public List<StationNumberVo> stationNumber() { |
|
|
|
|
List<StationNumberVo> numbers = new ArrayList<>(); |
|
|
|
|
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery(). |
|
|
|
|
in(StationEntity::getType,Arrays.asList(0,1,5,8)) |
|
|
|
|
); |
|
|
|
|
if(!CollectionUtil.isEmpty(stations)){ |
|
|
|
|
stations.stream().collect(Collectors.groupingBy(StationEntity::getType)).forEach((key, value) -> { |
|
|
|
|
StationNumberVo number = new StationNumberVo(); |
|
|
|
|
number.setType(key); |
|
|
|
|
number.setCount(value.size()); |
|
|
|
|
numbers.add(number); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
TargetVo target = (TargetVo) redisTemplate.opsForValue().get(charge); |
|
|
|
|
if(!ObjectUtil.isEmpty(target)){ |
|
|
|
|
StationNumberVo number = new StationNumberVo(); |
|
|
|
|
number.setType(7); |
|
|
|
|
number.setCount(target.getCharge()); |
|
|
|
|
numbers.add(number); |
|
|
|
|
} |
|
|
|
|
return this.sendMessage(JSONObject.toJSONBytes(list),STATION_URL); |
|
|
|
|
return numbers; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -213,10 +256,341 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
this.handleWaterLeve(station.getCode(),response); |
|
|
|
|
// 年发电量完成百分比
|
|
|
|
|
response.setPowerYearMap(this.handlePowerFinish(Collections.singletonList(station),map)); |
|
|
|
|
// 功率曲线
|
|
|
|
|
response.setActivePowerVoList(this.activePowers(station.getRefDept(),targetList)); |
|
|
|
|
return response; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 24小时功率曲线 |
|
|
|
|
* @param refDept |
|
|
|
|
* @param targetList |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<ActivePowerVo> activePowers(Long refDept, List<HydropowerUnitTargetVo> targetList) { |
|
|
|
|
if(CollectionUtil.isEmpty(targetList)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
List<ActivePowerVo> actives = new ArrayList<>(); |
|
|
|
|
targetList.stream().filter(o-> CollectionUtil.isNotEmpty(o.getActivePowerVoList()) && ObjectUtil.isNotEmpty(o.getDeptId()) && o.getDeptId().equals(refDept)).map(HydropowerUnitTargetVo::getActivePowerVoList).collect(Collectors.toList()).forEach(actives::addAll); |
|
|
|
|
if(CollectionUtil.isEmpty(actives)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
Map<Integer,List<ActivePowerVo>> maps = actives.stream().collect(Collectors.groupingBy(ActivePowerVo::getHour)); |
|
|
|
|
return maps.entrySet().stream().map(entry->{ |
|
|
|
|
ActivePowerVo activePower = new ActivePowerVo(); |
|
|
|
|
activePower.setHour(entry.getKey()); |
|
|
|
|
activePower.setActivePower(String.valueOf(entry.getValue().stream().mapToDouble(o->Double.parseDouble(o.getActivePower())).sum())); |
|
|
|
|
return activePower; |
|
|
|
|
}).sorted(Comparator.comparing(ActivePowerVo::getHour)).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 站点天气、降雨、水位 |
|
|
|
|
* @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.setLimitWater(station.getLimitWaterLevel()); |
|
|
|
|
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 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public PowerConvertVo power(String stationCode) { |
|
|
|
|
PowerConvertVo redisCache = (PowerConvertVo) redisTemplate.opsForValue().get(conver_power_key + stationCode); |
|
|
|
|
if(!ObjectUtil.isEmpty(redisCache)){ |
|
|
|
|
return redisCache; |
|
|
|
|
} |
|
|
|
|
// 查询站点
|
|
|
|
|
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery(). |
|
|
|
|
eq(StationEntity::getCode,stationCode) |
|
|
|
|
); |
|
|
|
|
if(ObjectUtil.isEmpty(station)){ |
|
|
|
|
return new PowerConvertVo(); |
|
|
|
|
} |
|
|
|
|
PowerConvertVo convert = new PowerConvertVo(); |
|
|
|
|
convert.setStationName(station.getName()); |
|
|
|
|
// 查询近30天发电量
|
|
|
|
|
convert.setElectricitys(this.poweyBy30Day(station.getRefDept())); |
|
|
|
|
// 查询24小时水位、功率
|
|
|
|
|
convert.setLoadWaters(this.loadWaterBy24Hour(station.getRefDept(),station.getCode())); |
|
|
|
|
redisTemplate.opsForValue().set(conver_power_key + stationCode,convert); |
|
|
|
|
redisTemplate.expire(conver_power_key + stationCode,30, TimeUnit.MINUTES); |
|
|
|
|
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); |
|
|
|
|
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); |
|
|
|
|
// 查询降雨数据
|
|
|
|
|
R<List<Map<String, Object>>> rains = rainfallClient.getDurationRainFall(stationCode,rainStart,rainEnd); |
|
|
|
|
// 近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()); |
|
|
|
|
} |
|
|
|
|
// 降雨
|
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询近30天发电量 |
|
|
|
|
* @param deptId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<ConverElectricityVo> poweyBy30Day(Long deptId) { |
|
|
|
|
// 查询设备
|
|
|
|
|
R<List<String>> result = deviceClient.getEmCodeByDeptId(deptId); |
|
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
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,-30); |
|
|
|
|
String startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
// 功率查询
|
|
|
|
|
List<AnalyseDataTaosVO> datas = dataService.periodTargetDatas(startTime,endTime,3,2,result.getData(),HomePageConstant.ACTIVE_POWER); |
|
|
|
|
if(CollectionUtil.isEmpty(datas)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
List<ConverElectricityVo> electricitys = new ArrayList<>(); |
|
|
|
|
// 数据累计
|
|
|
|
|
datas.forEach(item->{ |
|
|
|
|
if(CollectionUtil.isEmpty(datas)){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
datas.forEach(data->{ |
|
|
|
|
ConverElectricityVo electricity = new ConverElectricityVo(); |
|
|
|
|
Date date = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
electricity.setTime(DateUtil.format(date,DateUtil.PATTERN_DATE)); |
|
|
|
|
if(StringUtil.isEmpty(data.getVal())){ |
|
|
|
|
electricity.setElectricity(0.0); |
|
|
|
|
}else{ |
|
|
|
|
electricity.setElectricity(Double.parseDouble(data.getVal())); |
|
|
|
|
} |
|
|
|
|
electricitys.add(electricity); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
if(CollectionUtil.isEmpty(electricitys)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 进行time分组
|
|
|
|
|
return electricitys.stream().collect(Collectors.groupingBy(ConverElectricityVo::getTime)).entrySet().stream().map(entry->{ |
|
|
|
|
ConverElectricityVo electricity = new ConverElectricityVo(); |
|
|
|
|
electricity.setTime(entry.getKey()); |
|
|
|
|
electricity.setElectricity(entry.getValue().stream().mapToDouble(ConverElectricityVo::getElectricity).sum()); |
|
|
|
|
return electricity; |
|
|
|
|
}).sorted(Comparator.comparing(ConverElectricityVo::getTime)).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询24小时水位、功率 |
|
|
|
|
* @param stationCode |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<LoadWaterLevelVo> loadWaterBy24Hour(Long deptId,String stationCode) { |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-3); |
|
|
|
|
String endTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-24); |
|
|
|
|
String startTime = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); |
|
|
|
|
List<String> hours = this.get24Hours(); |
|
|
|
|
// 查询功率数据
|
|
|
|
|
List<AnalyseDataTaosVO> loads = this.loads(startTime,endTime,deptId); |
|
|
|
|
// 查询水位数据
|
|
|
|
|
List<AnalyseDataTaosVO> waters = this.water(startTime,endTime,stationCode,2); |
|
|
|
|
return hours.stream().map(hour ->{ |
|
|
|
|
LoadWaterLevelVo loadWater = new LoadWaterLevelVo(); |
|
|
|
|
Date time = DateUtil.parse(hour,"yyyy-MM-dd HH"); |
|
|
|
|
loadWater.setTime(String.valueOf(time.getHours())); |
|
|
|
|
if(CollectionUtil.isEmpty(loads)){ |
|
|
|
|
loadWater.setLoad(0.0); |
|
|
|
|
}else{ |
|
|
|
|
loadWater.setLoad(loads.stream().filter(o->o.getTs().contains(hour)).mapToDouble(load->{ |
|
|
|
|
if(StringUtil.isEmpty(load.getVal())){ |
|
|
|
|
return 0.0; |
|
|
|
|
} |
|
|
|
|
return Double.parseDouble(load.getVal()); |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
if(CollectionUtil.isEmpty(waters)){ |
|
|
|
|
loadWater.setWater(0.0); |
|
|
|
|
}else{ |
|
|
|
|
loadWater.setWater(waters.stream().filter(o->o.getTs().contains(hour)).mapToDouble(load->{ |
|
|
|
|
if(StringUtil.isEmpty(load.getVal())){ |
|
|
|
|
return 0.0; |
|
|
|
|
} |
|
|
|
|
return Double.parseDouble(load.getVal()); |
|
|
|
|
}).sum()); |
|
|
|
|
} |
|
|
|
|
return loadWater; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询水位数据 |
|
|
|
|
* @param startTime |
|
|
|
|
* @param endTime |
|
|
|
|
* @param stationCode |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<AnalyseDataTaosVO> water(String startTime, String endTime, String stationCode,Integer cycleType) { |
|
|
|
|
// 查询模型站点
|
|
|
|
|
HzimsAnalyzeModelStationEntity model = modelStationService.getOne(Wrappers.<HzimsAnalyzeModelStationEntity>lambdaQuery() |
|
|
|
|
.eq(HzimsAnalyzeModelStationEntity::getStationId,stationCode) |
|
|
|
|
); |
|
|
|
|
if(ObjectUtil.isEmpty(model)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 水位查询
|
|
|
|
|
return dataService.periodTargetData(startTime,endTime,3,cycleType,model.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取24小时功率 |
|
|
|
|
* @param refDept |
|
|
|
|
*/ |
|
|
|
|
private List<AnalyseDataTaosVO> loads(String start,String end,Long refDept) { |
|
|
|
|
List<AnalyseDataTaosVO> datas = new ArrayList<>(); |
|
|
|
|
R<List<String>> result = deviceClient.getEmCodeByDeptId(refDept); |
|
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
return datas; |
|
|
|
|
} |
|
|
|
|
return dataService.periodTargetDatas(start,end,3,2,result.getData(),HomePageConstant.ACTIVE_POWER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取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 |
|
|
|
|
*/ |
|
|
|
|
private List<String> get24Hours() { |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-3); |
|
|
|
|
Date end = calendar.getTime(); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,-24); |
|
|
|
|
Date start = calendar.getTime(); |
|
|
|
|
List<String> times = new ArrayList<>(); |
|
|
|
|
while (start.compareTo(end) < 0) { |
|
|
|
|
times.add(DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH")); |
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY,1); |
|
|
|
|
start = calendar.getTime(); |
|
|
|
|
} |
|
|
|
|
return times; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取站点运行天数 |
|
|
|
|
* @param station |
|
|
|
|
* @return |
|
|
|
@ -308,6 +682,14 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
// 月发电量
|
|
|
|
|
float powerMont = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum(); |
|
|
|
|
response.setPowerMon(powerMont); |
|
|
|
|
// 月发电完成率
|
|
|
|
|
float planPowerMon = response.getPlanPowerMon(); |
|
|
|
|
if(Math.abs(planPowerMon) <= 0){ |
|
|
|
|
response.setPowerRateMon(0.0); |
|
|
|
|
} else { |
|
|
|
|
double powerRateYear = BigDecimal.valueOf(powerMont / (double) planPowerMon * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
|
response.setPowerRateMon(powerRateYear); |
|
|
|
|
} |
|
|
|
|
// 年发电量
|
|
|
|
|
float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); |
|
|
|
|
response.setPowerYear(powerYear); |
|
|
|
@ -316,7 +698,7 @@ public class HzimsDataServiceImpl implements HzimsDataService {
|
|
|
|
|
if(Math.abs(planPowerYear) <= 0){ |
|
|
|
|
response.setPowerRateYear(0.0); |
|
|
|
|
} else { |
|
|
|
|
double powerRateYear = BigDecimal.valueOf(powerYear / planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
|
double powerRateYear = BigDecimal.valueOf(powerYear / (double) planPowerYear * 100).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
|
|
|
|
response.setPowerRateYear(powerRateYear); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|