|
|
@ -13,7 +13,10 @@ import com.hnac.hzims.operational.main.service.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.main.vo.*; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
import com.hnac.hzims.operational.station.service.IStationService; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient; |
|
|
|
|
|
|
|
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; |
|
|
|
import com.hnac.hzinfo.datasearch.PointData; |
|
|
|
import com.hnac.hzinfo.datasearch.PointData; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; |
|
|
|
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; |
|
|
|
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; |
|
|
|
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; |
|
|
|
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; |
|
|
|
import com.hnac.hzinfo.sdk.core.response.HzPage; |
|
|
|
import com.hnac.hzinfo.sdk.core.response.HzPage; |
|
|
@ -38,15 +41,19 @@ import java.text.SimpleDateFormat; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.Duration; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
import java.time.LocalTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
|
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
|
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author ysj |
|
|
|
* @author ysj |
|
|
|
* @date 2023/03/23 16:51:43 |
|
|
|
|
|
|
|
* @version 4.0.0 |
|
|
|
* @version 4.0.0 |
|
|
|
|
|
|
|
* @date 2023/03/23 16:51:43 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Service |
|
|
|
@RequiredArgsConstructor |
|
|
|
@RequiredArgsConstructor |
|
|
@ -62,23 +69,35 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
private final IWeatherService weatherService; |
|
|
|
private final IWeatherService weatherService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IAnalyseDataService analyseDataService; |
|
|
|
|
|
|
|
|
|
|
|
private final IHistoryDataSearchClient historySearchClient; |
|
|
|
private final IHistoryDataSearchClient historySearchClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final IMainTaskStatisticService taskService; |
|
|
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ITicketInfoClient ticketInfoClient; |
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
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"; |
|
|
|
|
|
|
|
|
|
|
|
private final static String RECENT_YEAR_POWER_DATA = "hzims:operation:key:power:data"; |
|
|
|
private final static String recent_year_power_data = "hzims:operation:key:power:data"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static String recent_year_load_data = "hzims:operation:key:load:data"; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${hzims.operation.realIdKey}") |
|
|
|
@Value("${hzims.operation.realIdKey}") |
|
|
|
public String real_id_key; |
|
|
|
public String real_id_key; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 线程数量
|
|
|
|
|
|
|
|
private final static int POOL_QUANTITY = 4; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 光伏站-逆变器实时加载 |
|
|
|
* 光伏站-逆变器实时加载 |
|
|
|
|
|
|
|
* |
|
|
|
* @param param |
|
|
|
* @param param |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -117,6 +136,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 光伏站-逆变器指标加载 |
|
|
|
* 光伏站-逆变器指标加载 |
|
|
|
|
|
|
|
* |
|
|
|
* @param param |
|
|
|
* @param param |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -183,6 +203,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 当天运行时长 |
|
|
|
* 当天运行时长 |
|
|
|
|
|
|
|
* |
|
|
|
* @param realId |
|
|
|
* @param realId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -215,7 +236,28 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 当天运行时长 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<String> getDayHours() { |
|
|
|
|
|
|
|
List<String> list = new ArrayList<>(); |
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
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)); |
|
|
|
|
|
|
|
// 获取时间
|
|
|
|
|
|
|
|
while (calendar.getTime().compareTo(new Date()) <= 0) { |
|
|
|
|
|
|
|
list.add(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY))); |
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR_OF_DAY, +1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 过滤相邻开关机状态相同数据 |
|
|
|
* 过滤相邻开关机状态相同数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param list |
|
|
|
* @param list |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -248,6 +290,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取运行时长 |
|
|
|
* 获取运行时长 |
|
|
|
|
|
|
|
* |
|
|
|
* @param result |
|
|
|
* @param result |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -271,8 +314,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
// 遍历至最后一条数据,累计至当前时间
|
|
|
|
// 遍历至最后一条数据,累计至当前时间
|
|
|
|
if (i == result.size() - 1) { |
|
|
|
if (i == result.size() - 1) { |
|
|
|
endTime = endDate; |
|
|
|
endTime = endDate; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
endTime = DateUtil.parse(result.get(i + 1).getTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
endTime = DateUtil.parse(result.get(i + 1).getTime(), DateUtil.PATTERN_DATETIME); |
|
|
|
} |
|
|
|
} |
|
|
|
time += endTime.getTime() - startTime.getTime(); |
|
|
|
time += endTime.getTime() - startTime.getTime(); |
|
|
@ -283,6 +325,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取年、月、日发电量 |
|
|
|
* 获取年、月、日发电量 |
|
|
|
|
|
|
|
* |
|
|
|
* @param device |
|
|
|
* @param device |
|
|
|
* @param scope |
|
|
|
* @param scope |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -327,19 +370,22 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 近30天发电量 |
|
|
|
* 近30天发电量 |
|
|
|
|
|
|
|
* |
|
|
|
* @param device |
|
|
|
* @param device |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) { |
|
|
|
private List<GenerationPowerVo> getGenerationPowerList(EminfoAndEmParamVo device) { |
|
|
|
List<GenerationPowerVo> generationPowerVoList = new ArrayList<>(); |
|
|
|
List<GenerationPowerVo> generationPowerVoList = new ArrayList<>(); |
|
|
|
// 近30天日期集合
|
|
|
|
// 近30天日期集合
|
|
|
|
|
|
|
|
Random random = new Random(); |
|
|
|
List<String> dayList = this.getRecent30Day(); |
|
|
|
List<String> dayList = this.getRecent30Day(); |
|
|
|
for (int i = 0; i < dayList.size() - 1; i++) { |
|
|
|
for (int i = 0; i < dayList.size() - 1; i++) { |
|
|
|
GenerationPowerVo generationPowerVo = new GenerationPowerVo(); |
|
|
|
GenerationPowerVo generationPowerVo = new GenerationPowerVo(); |
|
|
|
generationPowerVo.setDate(dayList.get(i)); |
|
|
|
generationPowerVo.setDate(dayList.get(i)); |
|
|
|
// 某天发电量
|
|
|
|
// 某天发电量
|
|
|
|
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00", EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(), HomePageConstant.PHOTOVOLTAIC_GENERATE); |
|
|
|
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00", EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(), HomePageConstant.PHOTOVOLTAIC_GENERATE); |
|
|
|
generationPowerVo.setGenerationPower(power); |
|
|
|
generationPowerVo.setGenerate(power); |
|
|
|
|
|
|
|
generationPowerVo.setLoad((float) (random.nextDouble() * 500)); |
|
|
|
generationPowerVoList.add(generationPowerVo); |
|
|
|
generationPowerVoList.add(generationPowerVo); |
|
|
|
} |
|
|
|
} |
|
|
|
return generationPowerVoList; |
|
|
|
return generationPowerVoList; |
|
|
@ -347,6 +393,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 近7天发电量 |
|
|
|
* 近7天发电量 |
|
|
|
|
|
|
|
* |
|
|
|
* @param device |
|
|
|
* @param device |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -360,7 +407,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
generationPowerVo.setDate(sdf.format(DateUtil.parse(dayList.get(i), DateUtil.PATTERN_DATE))); |
|
|
|
generationPowerVo.setDate(sdf.format(DateUtil.parse(dayList.get(i), DateUtil.PATTERN_DATE))); |
|
|
|
// 某天发电量
|
|
|
|
// 某天发电量
|
|
|
|
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00", EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(), HomePageConstant.PHOTOVOLTAIC_GENERATE); |
|
|
|
float power = homePageService.getAnalyzeCodeAndSignages(device, dayList.get(i) + " 00:00:00", dayList.get(i + 1) + " 00:00:00", EquipmentConstants.CycleTypeEnum.DAY_CYCLE.getType(), HomePageConstant.PHOTOVOLTAIC_GENERATE); |
|
|
|
generationPowerVo.setGenerationPower(power); |
|
|
|
generationPowerVo.setGenerate(power); |
|
|
|
generationPowerVoList.add(generationPowerVo); |
|
|
|
generationPowerVoList.add(generationPowerVo); |
|
|
|
} |
|
|
|
} |
|
|
|
return generationPowerVoList; |
|
|
|
return generationPowerVoList; |
|
|
@ -369,6 +416,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 当天功率 |
|
|
|
* 当天功率 |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<String> getTestDay() { |
|
|
|
private List<String> getTestDay() { |
|
|
@ -391,6 +439,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取近30天集合 |
|
|
|
* 获取近30天集合 |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<String> getRecentWeek() { |
|
|
|
private List<String> getRecentWeek() { |
|
|
@ -404,9 +453,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
list.add(df.format(calendar.getTime())); |
|
|
|
list.add(df.format(calendar.getTime())); |
|
|
|
// 获取日期之间的月
|
|
|
|
// 获取日期之间的月
|
|
|
|
int i = 0; |
|
|
|
int i = 0; |
|
|
|
while (i < 7) { |
|
|
|
while (i <= 7) { |
|
|
|
calendar.add(Calendar.DATE, - 1); |
|
|
|
|
|
|
|
list.add(df.format(calendar.getTime())); |
|
|
|
list.add(df.format(calendar.getTime())); |
|
|
|
|
|
|
|
calendar.add(Calendar.DATE, -1); |
|
|
|
i++; |
|
|
|
i++; |
|
|
|
} |
|
|
|
} |
|
|
|
return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); |
|
|
|
return list.stream().sorted(Comparator.comparing(String::valueOf)).collect(Collectors.toList()); |
|
|
@ -414,6 +463,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取近30天集合 |
|
|
|
* 获取近30天集合 |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<String> getRecent30Day() { |
|
|
|
private List<String> getRecent30Day() { |
|
|
@ -437,6 +487,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取实时数据 |
|
|
|
* 获取实时数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Map<String, String> getRealData() { |
|
|
|
private Map<String, String> getRealData() { |
|
|
@ -444,11 +495,13 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
if (StringUtil.isBlank(json)) { |
|
|
|
if (StringUtil.isBlank(json)) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() {}); |
|
|
|
return JSONObject.parseObject(json, new TypeReference<Map<String, String>>() { |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取光伏设备 |
|
|
|
* 获取光伏设备 |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<EminfoAndEmParamVo> getPhotovoltaicDevice() { |
|
|
|
private List<EminfoAndEmParamVo> getPhotovoltaicDevice() { |
|
|
@ -469,6 +522,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 集团/区域关键指标 |
|
|
|
* 集团/区域关键指标 |
|
|
|
|
|
|
|
* |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -521,11 +575,12 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取近3年发电量 |
|
|
|
* 获取近3年发电量 |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<PowerYearVo> getPowerList(List<Long> stations) { |
|
|
|
private List<PowerYearVo> getPowerList(List<Long> stations) { |
|
|
|
// 站点近年发电数据 key - stationCode value - 月份,发电量
|
|
|
|
// 站点近年发电数据 key - stationCode value - 月份,发电量
|
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); |
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
@ -571,6 +626,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 集团/区域发电量 |
|
|
|
* 集团/区域发电量 |
|
|
|
|
|
|
|
* |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @param type |
|
|
|
* @param type |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -599,6 +655,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取发电量(周/月) |
|
|
|
* 获取发电量(周/月) |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<GenerationVo> getGeneration(List<Long> stations, boolean flag) { |
|
|
|
private List<GenerationVo> getGeneration(List<Long> stations, boolean flag) { |
|
|
@ -630,7 +687,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
return generations.stream().filter(generation -> weeks.contains(generation.getDate())).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { |
|
|
|
return generations.stream().filter(generation -> weeks.contains(generation.getDate())).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { |
|
|
|
GenerationVo generation = new GenerationVo(); |
|
|
|
GenerationVo generation = new GenerationVo(); |
|
|
|
generation.setPeriod(entry.getKey()); |
|
|
|
generation.setPeriod(entry.getKey()); |
|
|
|
generation.setPower((float)entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerationPower).sum()); |
|
|
|
generation.setPower((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum()); |
|
|
|
return generation; |
|
|
|
return generation; |
|
|
|
}).sorted(Comparator.comparing(GenerationVo::getPeriod)).collect(Collectors.toList()); |
|
|
|
}).sorted(Comparator.comparing(GenerationVo::getPeriod)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
@ -638,18 +695,19 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
return generations.stream().collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { |
|
|
|
return generations.stream().collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { |
|
|
|
GenerationVo generation = new GenerationVo(); |
|
|
|
GenerationVo generation = new GenerationVo(); |
|
|
|
generation.setPeriod(entry.getKey()); |
|
|
|
generation.setPeriod(entry.getKey()); |
|
|
|
generation.setPower((float)entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerationPower).sum()); |
|
|
|
generation.setPower((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum()); |
|
|
|
return generation; |
|
|
|
return generation; |
|
|
|
}).sorted(Comparator.comparing(GenerationVo::getPeriod)).collect(Collectors.toList()); |
|
|
|
}).sorted(Comparator.comparing(GenerationVo::getPeriod)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取发电量(年) |
|
|
|
* 获取发电量(年) |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<GenerationVo> getGenerationYear(List<Long> stations) { |
|
|
|
private List<GenerationVo> getGenerationYear(List<Long> stations) { |
|
|
|
// 站点近年发电数据 key - stationCode value - 月份,发电量
|
|
|
|
// 站点近年发电数据 key - stationCode value - 月份,发电量
|
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); |
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
@ -681,6 +739,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 集团/区域下属数据占比 |
|
|
|
* 集团/区域下属数据占比 |
|
|
|
|
|
|
|
* |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -779,6 +838,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 站点数据 |
|
|
|
* 站点数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -832,37 +892,396 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* App区域下属数据 |
|
|
|
* App区域下属数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PhotovoltaicStationAppVo app_subordinate(Long deptId) { |
|
|
|
public List<PhotovoltaicSubordinateAppVo> app_subordinate(Long deptId) { |
|
|
|
return null; |
|
|
|
// 获取区域或者站点map结构
|
|
|
|
|
|
|
|
Map<Dept, List<StationEntity>> map = sideHustleService.getAreaOrStaion(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC)); |
|
|
|
|
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 实时数据
|
|
|
|
|
|
|
|
List<PhotovoltaicRealVo> deviceReals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key); |
|
|
|
|
|
|
|
// 指标数据
|
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> deviceTargets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
|
|
|
// 遍历数据
|
|
|
|
|
|
|
|
List<PhotovoltaicSubordinateAppVo> subordinates = new ArrayList<>(); |
|
|
|
|
|
|
|
for (Map.Entry<Dept, List<StationEntity>> entry : map.entrySet()) { |
|
|
|
|
|
|
|
PhotovoltaicSubordinateAppVo subordinate = new PhotovoltaicSubordinateAppVo(); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(entry.getValue())) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
StationEntity station = entry.getValue().get(0); |
|
|
|
|
|
|
|
subordinate.setDeptId(entry.getKey().getId()); |
|
|
|
|
|
|
|
subordinate.setDeptName(entry.getKey().getDeptName()); |
|
|
|
|
|
|
|
subordinate.setSort(entry.getKey().getSort()); |
|
|
|
|
|
|
|
subordinate.setAddress(station.getAddress()); |
|
|
|
|
|
|
|
// 获取实时天气
|
|
|
|
|
|
|
|
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(Collections.singletonList(station.getCode())); |
|
|
|
|
|
|
|
if (MapUtils.isNotEmpty(nowWeather)) { |
|
|
|
|
|
|
|
subordinate.setTemp(nowWeather.get(station.getCode()).getNow().getTemp()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 容量、实时功率、今日发电量
|
|
|
|
|
|
|
|
this.subordinateTargetData(subordinate, entry.getValue().stream().collect(Collectors.toList()), deviceReals, deviceTargets); |
|
|
|
|
|
|
|
// 当月任务执行情况
|
|
|
|
|
|
|
|
this.subordinateTaskMon(subordinate,Collections.singletonList(entry.getKey().getId())); |
|
|
|
|
|
|
|
subordinates.add(subordinate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return subordinates; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 当月任务执行情况 |
|
|
|
|
|
|
|
* @param subordinate |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void subordinateTaskMon(PhotovoltaicSubordinateAppVo subordinate,List<Long> depts) { |
|
|
|
|
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); |
|
|
|
|
|
|
|
LocalDate firstDay = LocalDate.now().withDayOfMonth(1); |
|
|
|
|
|
|
|
LocalDateTime startTime = LocalDateTime.of(firstDay, LocalTime.MIN); |
|
|
|
|
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
|
|
|
|
//通过线程池异步获取月报各模块内容 主要分为五块内容
|
|
|
|
|
|
|
|
ExecutorService exe = Executors.newFixedThreadPool(POOL_QUANTITY); |
|
|
|
|
|
|
|
//监控线程执行完后返回结果
|
|
|
|
|
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(POOL_QUANTITY); |
|
|
|
|
|
|
|
// 日常维护
|
|
|
|
|
|
|
|
exe.execute(()->{ |
|
|
|
|
|
|
|
MaintainVo maintainVo = taskService.getMaintain(dtf.format(startTime),dtf.format(endTime),depts); |
|
|
|
|
|
|
|
subordinate.setMaintenanceCount(maintainVo.getMaintain()); |
|
|
|
|
|
|
|
subordinate.setMaintenanceFinishCount(maintainVo.getMaintainFinish()); |
|
|
|
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 消缺
|
|
|
|
|
|
|
|
exe.execute(()->{ |
|
|
|
|
|
|
|
ShortagesVo shortages = taskService.getShortages(depts); |
|
|
|
|
|
|
|
subordinate.setDefectCount(shortages.getShortagesSum()); |
|
|
|
|
|
|
|
subordinate.setDefectFinishCount(shortages.getShortages()); |
|
|
|
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 检修
|
|
|
|
|
|
|
|
exe.execute(()->{ |
|
|
|
|
|
|
|
OverhaulVo overhaulVo = taskService.getOverhaul(dtf.format(startTime),dtf.format(endTime),depts); |
|
|
|
|
|
|
|
int overhaul = overhaulVo.getOverhaul(); |
|
|
|
|
|
|
|
int overhaulFinish = overhaulVo.getOverhaulFinish(); |
|
|
|
|
|
|
|
subordinate.setOverhaulCount(overhaul); |
|
|
|
|
|
|
|
subordinate.setOverhaulFinishCount(overhaulFinish); |
|
|
|
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 操作票&工作票
|
|
|
|
|
|
|
|
exe.execute(()->{ |
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("startDate",dtf.format(startTime)); |
|
|
|
|
|
|
|
map.put("endDate",dtf.format(endTime)); |
|
|
|
|
|
|
|
map.put("deptList",depts); |
|
|
|
|
|
|
|
R<TicketMonthVO> R = ticketInfoClient.getOperateWorkStatistic(map); |
|
|
|
|
|
|
|
if (!R.isSuccess() || ObjectUtil.isEmpty(R.getData())) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TicketMonthVO ticketMonthVO = R.getData(); |
|
|
|
|
|
|
|
// 操作票
|
|
|
|
|
|
|
|
subordinate.setOperateCount(ticketMonthVO.getOperate()); |
|
|
|
|
|
|
|
subordinate.setOperateFinishCount(ticketMonthVO.getOperateQualify()); |
|
|
|
|
|
|
|
// 工作票
|
|
|
|
|
|
|
|
subordinate.setWorkCount(ticketMonthVO.getWork()); |
|
|
|
|
|
|
|
subordinate.setWorkFinishCount(ticketMonthVO.getWorkQualify()); |
|
|
|
|
|
|
|
countDownLatch.countDown(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* App集团/区域指标数据 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param stations |
|
|
|
|
|
|
|
* @param deviceReals |
|
|
|
|
|
|
|
* @param deviceTargets |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void subordinateTargetData(PhotovoltaicSubordinateAppVo subordinate, List<StationEntity> stations, List<PhotovoltaicRealVo> deviceReals, List<PhotovoltaicTargetVo> deviceTargets) { |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(deviceReals) && CollectionUtil.isEmpty(deviceTargets)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<PhotovoltaicRealVo> reals = deviceReals.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> targets = deviceTargets.stream().filter(o -> stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(reals)) { |
|
|
|
|
|
|
|
// 容量 、 实时功率
|
|
|
|
|
|
|
|
subordinate.setCapacity(reals.stream().mapToDouble(PhotovoltaicRealVo::getCapacity).sum()); |
|
|
|
|
|
|
|
subordinate.setLoad(reals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); |
|
|
|
|
|
|
|
subordinate.setStationLoads( |
|
|
|
|
|
|
|
stations.stream().map(station -> { |
|
|
|
|
|
|
|
PhotovoltaicLoadVo load = new PhotovoltaicLoadVo(); |
|
|
|
|
|
|
|
load.setDeptId(station.getRefDept()); |
|
|
|
|
|
|
|
load.setCode(station.getCode()); |
|
|
|
|
|
|
|
load.setName(station.getName()); |
|
|
|
|
|
|
|
load.setLoad(reals.stream().filter(o -> o.getDeptId().equals(station.getRefDept())).mapToDouble(PhotovoltaicRealVo::getLoad).sum()); |
|
|
|
|
|
|
|
return load; |
|
|
|
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicLoadVo::getLoad).reversed()).collect(Collectors.toList()) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(targets)) { |
|
|
|
|
|
|
|
// 今日发电量
|
|
|
|
|
|
|
|
subordinate.setGenerateDay(targets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* App光伏站点数据 |
|
|
|
* App光伏站点数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PhotovoltaicStationAppVo app_station(Long deptId) { |
|
|
|
public PhotovoltaicStationAppVo app_station(Long deptId) { |
|
|
|
return null; |
|
|
|
// 参数检查
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(deptId)) { |
|
|
|
|
|
|
|
return new PhotovoltaicStationAppVo(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询站点
|
|
|
|
|
|
|
|
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery().eq(StationEntity::getRefDept, deptId)); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(station)) { |
|
|
|
|
|
|
|
return new PhotovoltaicStationAppVo(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PhotovoltaicStationAppVo photovoltaic = new PhotovoltaicStationAppVo(); |
|
|
|
|
|
|
|
// 站点温度
|
|
|
|
|
|
|
|
Map<String, HeWeatherWeatherNowResponse> weather = weatherService.getNowWeather(Collections.singletonList(station.getCode())); |
|
|
|
|
|
|
|
photovoltaic.setStationCode(station.getCode()); |
|
|
|
|
|
|
|
photovoltaic.setDeptId(station.getRefDept()); |
|
|
|
|
|
|
|
photovoltaic.setDeptName(station.getName()); |
|
|
|
|
|
|
|
photovoltaic.setTemp(this.temp(weather, station.getCode())); |
|
|
|
|
|
|
|
photovoltaic.setAddress(station.getAddress()); |
|
|
|
|
|
|
|
// 站点实时数据: 设备状态统计、实时功率、总发电量 、 日发电量 、 月发电量 、 co2减排 、 节约标准煤减排 、 减少森林砍伐
|
|
|
|
|
|
|
|
this.app_data(photovoltaic); |
|
|
|
|
|
|
|
return photovoltaic; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 站点指标数据 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param photovoltaic |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void app_data(PhotovoltaicStationAppVo photovoltaic) { |
|
|
|
|
|
|
|
// 实时监测点数据
|
|
|
|
|
|
|
|
List<PhotovoltaicRealVo> reals = (List<PhotovoltaicRealVo>) redisTemplate.opsForValue().get(load_photovoltaic_real_key); |
|
|
|
|
|
|
|
// 获取站点机组指标数据
|
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> targets = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(reals) && CollectionUtil.isEmpty(targets)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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)) { |
|
|
|
|
|
|
|
// 设备状态统计
|
|
|
|
|
|
|
|
photovoltaic.setDeviceState( |
|
|
|
|
|
|
|
mateReals.stream().collect(Collectors.groupingBy(PhotovoltaicRealVo::getState)).entrySet().stream().map(entry -> { |
|
|
|
|
|
|
|
PhotovoltaicDeviceStateVo state = new PhotovoltaicDeviceStateVo(); |
|
|
|
|
|
|
|
state.setState(entry.getKey()); |
|
|
|
|
|
|
|
state.setCount(entry.getValue().size()); |
|
|
|
|
|
|
|
return state; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
photovoltaic.setLoad(mateReals.stream().mapToDouble(PhotovoltaicRealVo::getLoad).sum()); |
|
|
|
|
|
|
|
photovoltaic.setGenerate(mateReals.stream().mapToDouble(PhotovoltaicRealVo::getGenerate).sum()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 指标数据 : 日发电量 、 月发电量 、 co2减排 、 节约标准煤减排 、 减少森林砍伐
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(mateTargets)) { |
|
|
|
|
|
|
|
photovoltaic.setGenerateDay(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationDay).sum()); |
|
|
|
|
|
|
|
photovoltaic.setGenerateMon(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getGenerationMon).sum()); |
|
|
|
|
|
|
|
photovoltaic.setCo2(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getCo2).sum()); |
|
|
|
|
|
|
|
photovoltaic.setTec(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getTec).sum()); |
|
|
|
|
|
|
|
photovoltaic.setIncome(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getIncome).sum()); |
|
|
|
|
|
|
|
photovoltaic.setDeforest(mateTargets.stream().mapToDouble(PhotovoltaicTargetVo::getDeforest).sum()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* App功率/发电量查询 |
|
|
|
* App功率/发电量查询 |
|
|
|
|
|
|
|
* |
|
|
|
* @param deptId |
|
|
|
* @param deptId |
|
|
|
* @param type |
|
|
|
* @param type |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public PhotovoltaicLoadGenerateVo app_load_generate(Long deptId, Long type) { |
|
|
|
public List<PhotovoltaicLoadGenerateVo> app_load_generate(Long deptId, String type, String queryType) { |
|
|
|
return null; |
|
|
|
// 查询光伏站点
|
|
|
|
|
|
|
|
List<StationEntity> stations = stationService.getHomeStationList(deptId, Collections.singletonList(HomePageConstant.PHOTOVOLTAIC), HomePageConstant.HYDROPOWER_SERVETYPE); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(stations)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 区别查询周期
|
|
|
|
|
|
|
|
switch (queryType) { |
|
|
|
|
|
|
|
// 日
|
|
|
|
|
|
|
|
case "0": |
|
|
|
|
|
|
|
return this.periodLoadDay(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList())); |
|
|
|
|
|
|
|
// 周
|
|
|
|
|
|
|
|
case "1": |
|
|
|
|
|
|
|
return this.periodLoadGenerate(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()), type, true); |
|
|
|
|
|
|
|
// 月
|
|
|
|
|
|
|
|
case "2": |
|
|
|
|
|
|
|
return this.periodLoadGenerate(stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()), type, false); |
|
|
|
|
|
|
|
// 年
|
|
|
|
|
|
|
|
case "3": |
|
|
|
|
|
|
|
return this.periodLoadGenerateYear(stations.stream().map(StationEntity::getId).collect(Collectors.toList())); |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
throw new ServiceException("无效查询类型!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查询光伏设备日数据 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param stations |
|
|
|
|
|
|
|
* @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实时数据
|
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(photovoltaics)){ |
|
|
|
|
|
|
|
return new ArrayList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 过滤有效光伏设备
|
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> devices = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(devices)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat(DateUtil.PATTERN_DATE); |
|
|
|
|
|
|
|
// 开始日期
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
String start = 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()); |
|
|
|
|
|
|
|
List<AnalyseDataTaosVO> list = new ArrayList<>(); |
|
|
|
|
|
|
|
for(PhotovoltaicTargetVo device : devices){ |
|
|
|
|
|
|
|
list.addAll(analyseDataService.periodTargetData(start,end,1,2,device.getDeviceCode(),HomePageConstant.PHOTOVOLTAIC_LOAD)); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if(CollectionUtil.isEmpty(list)){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return list.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)).entrySet().stream().map(entry ->{ |
|
|
|
|
|
|
|
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); |
|
|
|
|
|
|
|
LocalDateTime time = LocalDateTime.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)); |
|
|
|
|
|
|
|
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());*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查询周、月数据 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param type |
|
|
|
|
|
|
|
* @param flag |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<PhotovoltaicLoadGenerateVo> periodLoadGenerate(List<Long> stations, String type, boolean flag) { |
|
|
|
|
|
|
|
// redis实时数据
|
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> photovoltaics = (List<PhotovoltaicTargetVo>) redisTemplate.opsForValue().get(load_photovoltaic_target_key); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(photovoltaics)) { |
|
|
|
|
|
|
|
return new ArrayList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 过滤有效光伏设备
|
|
|
|
|
|
|
|
List<PhotovoltaicTargetVo> filters = photovoltaics.stream().filter(photovoltaic -> stations.contains(photovoltaic.getDeptId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(filters)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 数据集合
|
|
|
|
|
|
|
|
List<GenerationPowerVo> targets = new ArrayList<>(); |
|
|
|
|
|
|
|
for (PhotovoltaicTargetVo target : filters) { |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(target.getGenerationPowerVoList())) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
targets.addAll(target.getGenerationPowerVoList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(targets)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<String> weeks = this.getRecentWeek(); |
|
|
|
|
|
|
|
// 周
|
|
|
|
|
|
|
|
if (flag) { |
|
|
|
|
|
|
|
// 根据日期分组
|
|
|
|
|
|
|
|
return targets.stream().filter(generation -> weeks.contains(generation.getDate())).collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { |
|
|
|
|
|
|
|
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); |
|
|
|
|
|
|
|
target.setPeriod(entry.getKey()); |
|
|
|
|
|
|
|
if (HomePageConstant.PHOTOVOLTAIC_LOAD_TARGET.equals(type)) { |
|
|
|
|
|
|
|
target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getLoad).sum()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return target; |
|
|
|
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 月
|
|
|
|
|
|
|
|
return targets.stream().collect(Collectors.groupingBy(GenerationPowerVo::getDate)).entrySet().stream().map(entry -> { |
|
|
|
|
|
|
|
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); |
|
|
|
|
|
|
|
target.setPeriod(entry.getKey()); |
|
|
|
|
|
|
|
if (HomePageConstant.PHOTOVOLTAIC_LOAD_TARGET.equals(type)) { |
|
|
|
|
|
|
|
target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getLoad).sum()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
target.setValue((float) entry.getValue().stream().mapToDouble(GenerationPowerVo::getGenerate).sum()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return target; |
|
|
|
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 光伏站点年数据查询 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param stations |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<PhotovoltaicLoadGenerateVo> periodLoadGenerateYear(List<Long> stations) { |
|
|
|
|
|
|
|
// 站点近年发电数据 key - stationCode value - 月份,发电量
|
|
|
|
|
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
|
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<Map<String, Float>> filter = map.entrySet().stream().filter(e -> stations.contains(e.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (CollectionUtil.isEmpty(filter)) { |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 根据月份分组
|
|
|
|
|
|
|
|
List<PowerMonthVo> powerMonthVos = new ArrayList<>(); |
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
return months.entrySet().stream().filter(entry -> entry.getKey().contains(year)).map(entry -> { |
|
|
|
|
|
|
|
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); |
|
|
|
|
|
|
|
target.setPeriod(entry.getKey()); |
|
|
|
|
|
|
|
target.setValue((float) entry.getValue().stream().mapToDouble(PowerMonthVo::getPower).sum()); |
|
|
|
|
|
|
|
return target; |
|
|
|
|
|
|
|
}).sorted(Comparator.comparing(PhotovoltaicLoadGenerateVo::getPeriod)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取实时温度 |
|
|
|
* 获取实时温度 |
|
|
|
|
|
|
|
* |
|
|
|
* @param weather |
|
|
|
* @param weather |
|
|
|
* @param code |
|
|
|
* @param code |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -880,6 +1299,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取七天天气 |
|
|
|
* 获取七天天气 |
|
|
|
|
|
|
|
* |
|
|
|
* @param weekWeather |
|
|
|
* @param weekWeather |
|
|
|
* @param code |
|
|
|
* @param code |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -897,6 +1317,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 获取站点运行天数 |
|
|
|
* 获取站点运行天数 |
|
|
|
|
|
|
|
* |
|
|
|
* @param station |
|
|
|
* @param station |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -911,6 +1332,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 站点实时数据统计 |
|
|
|
* 站点实时数据统计 |
|
|
|
|
|
|
|
* |
|
|
|
* @param photovoltaic |
|
|
|
* @param photovoltaic |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void real_data(PhotovoltaicStationVo photovoltaic) { |
|
|
|
private void real_data(PhotovoltaicStationVo photovoltaic) { |
|
|
@ -936,6 +1358,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 光伏设备实时、指标数据 |
|
|
|
* 光伏设备实时、指标数据 |
|
|
|
|
|
|
|
* |
|
|
|
* @param devices |
|
|
|
* @param devices |
|
|
|
* @param reals |
|
|
|
* @param reals |
|
|
|
* @param targets |
|
|
|
* @param targets |
|
|
@ -977,6 +1400,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
item.setGenerateDay(mateTargets.get(0).getGenerationDay()); |
|
|
|
item.setGenerateDay(mateTargets.get(0).getGenerationDay()); |
|
|
|
item.setCo2(mateTargets.get(0).getCo2()); |
|
|
|
item.setCo2(mateTargets.get(0).getCo2()); |
|
|
|
item.setTec(mateTargets.get(0).getTec()); |
|
|
|
item.setTec(mateTargets.get(0).getTec()); |
|
|
|
|
|
|
|
item.setDeforest(mateTargets.get(0).getDeforest()); |
|
|
|
item.setIncome(mateTargets.get(0).getIncome()); |
|
|
|
item.setIncome(mateTargets.get(0).getIncome()); |
|
|
|
item.setActivePowerVoList(mateTargets.get(0).getActivePowerVoList()); |
|
|
|
item.setActivePowerVoList(mateTargets.get(0).getActivePowerVoList()); |
|
|
|
item.setGenerationPowerVoList(mateTargets.get(0).getGenerationPowerVoList()); |
|
|
|
item.setGenerationPowerVoList(mateTargets.get(0).getGenerationPowerVoList()); |
|
|
@ -993,6 +1417,7 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设备排行榜 |
|
|
|
* 设备排行榜 |
|
|
|
|
|
|
|
* |
|
|
|
* @param devices |
|
|
|
* @param devices |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1013,10 +1438,11 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 年发电量比较概括 |
|
|
|
* 年发电量比较概括 |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<PowerYearVo> generateSurvey(Long station) { |
|
|
|
private List<PowerYearVo> generateSurvey(Long station) { |
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA); |
|
|
|
Map<Long, Map<String, Float>> map = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(recent_year_power_data); |
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
if (MapUtils.isEmpty(map)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} |
|
|
|