|
|
|
@ -3,7 +3,6 @@ package com.hnac.hzims.operational.main.service.impl;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.hnac.hzims.EquipmentConstants; |
|
|
|
|
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; |
|
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.Daily; |
|
|
|
|
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse; |
|
|
|
@ -22,7 +21,6 @@ import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
|
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.HzPage; |
|
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import net.sf.jsqlparser.expression.StringValue; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
@ -66,8 +64,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
|
|
|
|
|
private final ISideHustleService sideHustleService; |
|
|
|
|
|
|
|
|
|
private final IHomePageService homePageService; |
|
|
|
|
|
|
|
|
|
private final IWeatherService weatherService; |
|
|
|
|
|
|
|
|
|
private final IAnalyseDataService analyseDataService; |
|
|
|
@ -296,7 +292,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
return records.stream().map(record -> { |
|
|
|
|
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); |
|
|
|
|
Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); |
|
|
|
|
load.setHour(time.getHours()); |
|
|
|
|
load.setHour(DateUtil.format(time,"yyyy-mm-dd HH")); |
|
|
|
|
load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); |
|
|
|
|
return load; |
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList()); |
|
|
|
@ -340,8 +336,8 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
*/ |
|
|
|
|
private float sumValueByTime(String deviceCode, int rideCount, String type) { |
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
String start = null, end = null; |
|
|
|
|
Integer cycleType = 3; |
|
|
|
|
String start, end; |
|
|
|
|
int cycleType = 3; |
|
|
|
|
switch (type) { |
|
|
|
|
//年
|
|
|
|
|
case "0": |
|
|
|
@ -376,6 +372,8 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
|
end = DateUtil.format(new Date(), DateUtil.PATTERN_DATE) + " 00:00:00"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
throw new ServiceException("无效查询类型!"); |
|
|
|
|
} |
|
|
|
|
return analyseDataService.periodTargetFloat(start, end, 5, cycleType, deviceCode, rideCount, HomePageConstant.PV_GENERATION_CAPACITY); |
|
|
|
|
} |
|
|
|
@ -571,17 +569,16 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
*/ |
|
|
|
|
private List<String> getRecentWeek() { |
|
|
|
|
// 日期格式化yyyy-mm-dd
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat(DateUtil.PATTERN_DATE); |
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
|
// 开始日期
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
calendar.setTime(new Date()); |
|
|
|
|
calendar.add(Calendar.DATE, +1); |
|
|
|
|
list.add(df.format(calendar.getTime())); |
|
|
|
|
list.add(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE)); |
|
|
|
|
// 获取日期之间的月
|
|
|
|
|
int i = 0; |
|
|
|
|
while (i <= 7) { |
|
|
|
|
list.add(df.format(calendar.getTime())); |
|
|
|
|
list.add(DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE)); |
|
|
|
|
calendar.add(Calendar.DATE, -1); |
|
|
|
|
i++; |
|
|
|
|
} |
|
|
|
@ -693,14 +690,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
} |
|
|
|
|
// 根据月份分组
|
|
|
|
|
List<PowerMonthVo> powerMonthVos = new ArrayList<>(); |
|
|
|
|
filter.forEach(item -> { |
|
|
|
|
item.forEach((key, value) -> { |
|
|
|
|
filter.forEach(item -> item.forEach((key, value) -> { |
|
|
|
|
PowerMonthVo powerMonthVo = new PowerMonthVo(); |
|
|
|
|
powerMonthVo.setStrMonth(key); |
|
|
|
|
powerMonthVo.setPower(value); |
|
|
|
|
powerMonthVos.add(powerMonthVo); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
})); |
|
|
|
|
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); |
|
|
|
|
// 总和所有相同月份的发电量
|
|
|
|
|
List<PowerMonthVo> powerMonthVoList = months.entrySet().stream().map(entry -> { |
|
|
|
@ -765,7 +760,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
// redis实时数据
|
|
|
|
|
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
if (CollectionUtil.isEmpty(photovoltaics)) { |
|
|
|
|
return new ArrayList(); |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 过滤有效光伏设备
|
|
|
|
|
List<PhotovoltaicTargetVo> filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
@ -820,14 +815,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
} |
|
|
|
|
// 根据月份分组
|
|
|
|
|
List<PowerMonthVo> powerMonthVos = new ArrayList<>(); |
|
|
|
|
filter.forEach(item -> { |
|
|
|
|
item.forEach((key, value) -> { |
|
|
|
|
filter.forEach(item -> item.forEach((key, value) -> { |
|
|
|
|
PowerMonthVo powerMonthVo = new PowerMonthVo(); |
|
|
|
|
powerMonthVo.setStrMonth(key); |
|
|
|
|
powerMonthVo.setPower(value); |
|
|
|
|
powerMonthVos.add(powerMonthVo); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
})); |
|
|
|
|
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); |
|
|
|
|
// 总和所有相同月份的发电量
|
|
|
|
|
String year = String.valueOf(LocalDate.now().getYear()); |
|
|
|
@ -893,16 +886,16 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
} |
|
|
|
|
subordinate.setWeather(weekWeather.get(station.getCode()).getDaily()); |
|
|
|
|
// 区域/站点 设备实时数据
|
|
|
|
|
if (deviceReals != null) { |
|
|
|
|
List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtil.isNotEmpty(reals)) { |
|
|
|
|
subordinate.setStationCount(Long.valueOf(entry.getValue().size())); |
|
|
|
|
subordinate.setStationUseCount(reals.stream().filter(device -> HomePageConstant.OFF.equals(device.getState())).map(PhotovoltaicRealVo::getDeptId).distinct().count()); |
|
|
|
|
subordinate.setStationCount((long) entry.getValue().size()); |
|
|
|
|
subordinate.setStationUseCount(reals.stream().filter(device -> device.getState() == 1).map(PhotovoltaicRealVo::getDeptId).distinct().count()); |
|
|
|
|
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); |
|
|
|
|
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); |
|
|
|
|
} |
|
|
|
|
// 区域/站点 设备指标数据
|
|
|
|
|
if (deviceTargets != null) { |
|
|
|
|
List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(photovoltaic -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtil.isNotEmpty(targets)) { |
|
|
|
|
subordinate.setGeneration(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationYear).sum()); |
|
|
|
|
} |
|
|
|
|
list.add(subordinate); |
|
|
|
@ -915,7 +908,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
Double sumLoad = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getCapacity).sum(); |
|
|
|
|
Double sumStationCount = list.stream().mapToDouble(PhotovoltaicSubordinateVo::getStationCount).sum(); |
|
|
|
|
// 计算 :集团发电占比 电站利用率 容量利用率
|
|
|
|
|
return list.stream().map(subordinate -> { |
|
|
|
|
return list.stream().peek(subordinate -> { |
|
|
|
|
if (Math.abs(sumGeneration) <= 0) { |
|
|
|
|
subordinate.setGenerationRate(0.0); |
|
|
|
|
} else { |
|
|
|
@ -931,7 +924,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
} else { |
|
|
|
|
subordinate.setStationUse(BigDecimal.valueOf(subordinate.getStationUseCount() / sumStationCount * 100L).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); |
|
|
|
|
} |
|
|
|
|
return subordinate; |
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicSubordinateVo::getCapacity)).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1024,7 +1016,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
subordinate.setNow(nowWeather.get(station.getCode()).getNow()); |
|
|
|
|
} |
|
|
|
|
// 容量、实时功率、今日发电量
|
|
|
|
|
this.subordinateTargetData(subordinate, entry.getValue().stream().collect(Collectors.toList()), deviceReals, deviceTargets); |
|
|
|
|
this.subordinateTargetData(subordinate, new ArrayList<>(entry.getValue()), deviceReals, deviceTargets); |
|
|
|
|
// 当月任务执行情况
|
|
|
|
|
this.subordinateTaskMon(subordinate, Collections.singletonList(entry.getKey().getId())); |
|
|
|
|
subordinates.add(subordinate); |
|
|
|
@ -1171,9 +1163,6 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
} |
|
|
|
|
List<PhotovoltaicRealVo> mateReals = reals.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
List<PhotovoltaicTargetVo> mateTargets = targets.stream().filter(o -> o.getDeptId().equals(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
if (CollectionUtil.isEmpty(mateReals) && CollectionUtil.isEmpty(mateTargets)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 实时数据 : 实时功率、总发电量
|
|
|
|
|
if (CollectionUtil.isNotEmpty(mateReals)) { |
|
|
|
|
// 设备状态统计
|
|
|
|
@ -1240,20 +1229,10 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private List<PhotovoltaicLoadGenerateVo> periodLoadDay(List<Long> stations) { |
|
|
|
|
// FIXME 测试数据
|
|
|
|
|
List<String> hours = getDayHours(); |
|
|
|
|
Random random = new Random(); |
|
|
|
|
return hours.stream().map(hour -> { |
|
|
|
|
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); |
|
|
|
|
target.setPeriod(hour); |
|
|
|
|
target.setValue((float) (random.nextDouble() * 500)); |
|
|
|
|
return target; |
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
/*// redis实时数据
|
|
|
|
|
// redis实时数据
|
|
|
|
|
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
if(CollectionUtil.isEmpty(photovoltaics)){ |
|
|
|
|
return new ArrayList(); |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 过滤有效光伏设备
|
|
|
|
|
List<PhotovoltaicTargetVo> devices = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
@ -1263,15 +1242,15 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATE); |
|
|
|
|
// 开始日期
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
String start = sdf.format(calendar.getTime()); |
|
|
|
|
String end = sdf.format(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)); |
|
|
|
|
String end = sdf.format(calendar.getTime()); |
|
|
|
|
String start = sdf.format(calendar.getTime()); |
|
|
|
|
List<AnalyseDataTaosVO> list = new ArrayList<>(); |
|
|
|
|
for(PhotovoltaicTargetVo device : devices){ |
|
|
|
|
list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PHOTOVOLTAIC_LOAD)); |
|
|
|
|
}; |
|
|
|
|
list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PV_LOAD)); |
|
|
|
|
} |
|
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
@ -1281,7 +1260,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
target.setPeriod(String.valueOf(time.getHour())); |
|
|
|
|
target.setValue((float) entry.getValue().stream().mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum()); |
|
|
|
|
return target; |
|
|
|
|
}).collect(Collectors.toList());*/ |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1295,7 +1274,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
// redis实时数据
|
|
|
|
|
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
if (CollectionUtil.isEmpty(photovoltaics)) { |
|
|
|
|
return new ArrayList(); |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
// 过滤有效光伏设备
|
|
|
|
|
List<PhotovoltaicTargetVo> filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
@ -1359,14 +1338,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
} |
|
|
|
|
// 根据月份分组
|
|
|
|
|
List<PowerMonthVo> powerMonthVos = new ArrayList<>(); |
|
|
|
|
filter.forEach(item -> { |
|
|
|
|
item.forEach((key, value) -> { |
|
|
|
|
filter.forEach(item -> item.forEach((key, value) -> { |
|
|
|
|
PowerMonthVo powerMonthVo = new PowerMonthVo(); |
|
|
|
|
powerMonthVo.setStrMonth(key); |
|
|
|
|
powerMonthVo.setPower(value); |
|
|
|
|
powerMonthVos.add(powerMonthVo); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
})); |
|
|
|
|
Map<String, List<PowerMonthVo>> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); |
|
|
|
|
// 总和所有相同月份的发电量
|
|
|
|
|
String year = String.valueOf(LocalDate.now().getYear()); |
|
|
|
@ -1488,7 +1465,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
|
|
devices.stream().map(PhotovoltaicDeviceVo::getActivePowerVoList).flatMap(Collection::stream).collect(Collectors.groupingBy(PhotovoltaicPowerVo::getHour)).entrySet().stream().map(entry -> { |
|
|
|
|
PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); |
|
|
|
|
load.setHour(entry.getKey()); |
|
|
|
|
load.setActivePower(String.valueOf(entry.getValue().stream().mapToDouble(o -> Double.valueOf(o.getActivePower())).sum())); |
|
|
|
|
load.setActivePower(String.valueOf(entry.getValue().stream().mapToDouble(o -> Double.parseDouble(o.getActivePower())).sum())); |
|
|
|
|
return load; |
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicPowerVo::getHour)).collect(Collectors.toList()) |
|
|
|
|
); |
|
|
|
|