|
@@ -1,16 +1,22 @@
|
|
package com.cpp.web.controller.largeScreen;
|
|
package com.cpp.web.controller.largeScreen;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import cn.hutool.core.util.ReflectUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.cpp.common.core.cache.LocalCache;
|
|
import com.cpp.common.core.cache.LocalCache;
|
|
import com.cpp.common.core.domain.R;
|
|
import com.cpp.common.core.domain.R;
|
|
|
|
+import com.cpp.common.core.domain.entity.SysDictData;
|
|
import com.cpp.system.service.ISysConfigService;
|
|
import com.cpp.system.service.ISysConfigService;
|
|
|
|
+import com.cpp.system.service.ISysDictDataService;
|
|
|
|
+import com.cpp.web.domain.cloud.NwpCloud;
|
|
import com.cpp.web.domain.powerGeneration.DayPowerGeneration;
|
|
import com.cpp.web.domain.powerGeneration.DayPowerGeneration;
|
|
import com.cpp.web.domain.station.*;
|
|
import com.cpp.web.domain.station.*;
|
|
import com.cpp.web.domain.station.enums.ElectricFieldTypeEnum;
|
|
import com.cpp.web.domain.station.enums.ElectricFieldTypeEnum;
|
|
import com.cpp.web.dto.largeScreen.ElectricFieldDataTotalDto;
|
|
import com.cpp.web.dto.largeScreen.ElectricFieldDataTotalDto;
|
|
import com.cpp.web.dto.largeScreen.ForecastGeneratingDataDto;
|
|
import com.cpp.web.dto.largeScreen.ForecastGeneratingDataDto;
|
|
|
|
+import com.cpp.web.dto.largeScreen.ForecastNwpDto;
|
|
import com.cpp.web.dto.largeScreen.ProductionDataTotalDto;
|
|
import com.cpp.web.dto.largeScreen.ProductionDataTotalDto;
|
|
|
|
+import com.cpp.web.service.cloud.NwpCloudService;
|
|
import com.cpp.web.service.powerGeneation.DayPowerGenerationService;
|
|
import com.cpp.web.service.powerGeneation.DayPowerGenerationService;
|
|
import com.cpp.web.service.station.*;
|
|
import com.cpp.web.service.station.*;
|
|
import com.cpp.web.utils.DateTimeUtil;
|
|
import com.cpp.web.utils.DateTimeUtil;
|
|
@@ -20,6 +26,7 @@ import org.apache.commons.lang.time.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import java.lang.reflect.Field;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
@@ -55,9 +62,13 @@ public class LargeScreenController {
|
|
WeatherStationStatusDataService weatherStationStatusDataService;
|
|
WeatherStationStatusDataService weatherStationStatusDataService;
|
|
@Autowired
|
|
@Autowired
|
|
DayPowerGenerationService dayPowerGenerationService;
|
|
DayPowerGenerationService dayPowerGenerationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ISysDictDataService iSysDictDataService;
|
|
|
|
+ @Autowired
|
|
|
|
+ NwpCloudService nwpCloudService;
|
|
|
|
|
|
@GetMapping("/getBizData")
|
|
@GetMapping("/getBizData")
|
|
- public R getBizData() {
|
|
|
|
|
|
+ public R getBizData(String weatherType) {
|
|
// 获取所有场站
|
|
// 获取所有场站
|
|
List<ElectricField> electricFieldList = electricFieldService.list();
|
|
List<ElectricField> electricFieldList = electricFieldService.list();
|
|
// 首页左上角场站数据统计
|
|
// 首页左上角场站数据统计
|
|
@@ -120,6 +131,14 @@ public class LargeScreenController {
|
|
Map forecastGeneratingMap = calForecastGenerating();
|
|
Map forecastGeneratingMap = calForecastGenerating();
|
|
bizDataMap.put("forecastGeneratingMap",forecastGeneratingMap);
|
|
bizDataMap.put("forecastGeneratingMap",forecastGeneratingMap);
|
|
|
|
|
|
|
|
+ // 获取首页中心侧nwp气象
|
|
|
|
+ Map<String,List> forecastNwpMap = centerForecastNwpAvgTotal();
|
|
|
|
+ bizDataMap.put("forecastNwpMap",forecastNwpMap);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
// 定义首页实际功率、可用、理论总和
|
|
// 定义首页实际功率、可用、理论总和
|
|
BigDecimal realSum = BigDecimal.ZERO;
|
|
BigDecimal realSum = BigDecimal.ZERO;
|
|
BigDecimal ableSum = BigDecimal.ZERO;
|
|
BigDecimal ableSum = BigDecimal.ZERO;
|
|
@@ -372,19 +391,6 @@ public class LargeScreenController {
|
|
forecastGeneratingSum = forecastGeneratingSum.add(dayPowerGeneration.getForecastPowerGeneration());
|
|
forecastGeneratingSum = forecastGeneratingSum.add(dayPowerGeneration.getForecastPowerGeneration());
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-// Date dayEndTimeFor15 = DateTimeUtil.getMomentTimeFor15Minute(System.currentTimeMillis());
|
|
|
|
-// QueryWrapper<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationQueryWrapper = new QueryWrapper<>();
|
|
|
|
-// forecastPowerShortTermRegulationQueryWrapper.between("time", dayStartTime, dayEndTimeFor15);
|
|
|
|
-// List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList = forecastPowerShortTermRegulationService.list(forecastPowerShortTermRegulationQueryWrapper);
|
|
|
|
-// // 计算短期预测发电量
|
|
|
|
-// BigDecimal forecastGeneratingSum = BigDecimal.ZERO;
|
|
|
|
-// for (ForecastPowerShortTermRegulation forecastPowerShortTermRegulation : forecastPowerShortTermRegulationList) {
|
|
|
|
-// if (forecastPowerShortTermRegulation.getFpValue()!=null){
|
|
|
|
-// // 发电量(万kWh) = 预测值 * 0.25 * 0.1
|
|
|
|
-// forecastGeneratingSum = forecastGeneratingSum.add(forecastPowerShortTermRegulation.getFpValue().multiply(new BigDecimal("0.25")).multiply(new BigDecimal("0.1")).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
ProductionDataTotalDto productionDataTotalDto = new ProductionDataTotalDto();
|
|
ProductionDataTotalDto productionDataTotalDto = new ProductionDataTotalDto();
|
|
productionDataTotalDto.setRealGeneratingSum(realGeneratingSum);
|
|
productionDataTotalDto.setRealGeneratingSum(realGeneratingSum);
|
|
productionDataTotalDto.setForecastGeneratingSum(forecastGeneratingSum);
|
|
productionDataTotalDto.setForecastGeneratingSum(forecastGeneratingSum);
|
|
@@ -447,4 +453,205 @@ public class LargeScreenController {
|
|
}
|
|
}
|
|
return forecastGeneratingMap;
|
|
return forecastGeneratingMap;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 首页中心预测nwp气象站数据总体平均值
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private Map<String,List> centerForecastNwpAvgTotal(){
|
|
|
|
+ // 根据类型获取所有场站
|
|
|
|
+ Map<String,List> stationMap = new HashMap();
|
|
|
|
+ List<ElectricField> list = electricFieldService.list();
|
|
|
|
+ List<String> windStationCodeList = new ArrayList<>();
|
|
|
|
+ List<String> gfStationCodeList = new ArrayList<>();
|
|
|
|
+ for (ElectricField electricField:list){
|
|
|
|
+ if (electricField.getElectricFieldTypeEnum().equals("E1")){
|
|
|
|
+ gfStationCodeList.add(electricField.getStationCode());
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ windStationCodeList.add(electricField.getStationCode());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ stationMap.put("gf",gfStationCodeList);
|
|
|
|
+ stationMap.put("wind",windStationCodeList);
|
|
|
|
+ Map<String,List> forecastWeatherAvgDataMap = new HashMap<>();
|
|
|
|
+ // 循环光和风
|
|
|
|
+ Iterator<Map.Entry<String, List>> stationIterator = stationMap.entrySet().iterator();
|
|
|
|
+ while (stationIterator.hasNext()) {
|
|
|
|
+ Map.Entry<String, List> entry = stationIterator.next();
|
|
|
|
+ List<String> stationCodeList = entry.getValue();
|
|
|
|
+ Date dayStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
|
|
|
|
+ Date dayEndTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
|
|
|
|
+ Map<Long, List<NwpCloud>> nwpCloudMap = new HashMap<>();
|
|
|
|
+ Map<String,String> nwpWshubheightMap = new HashMap<>();
|
|
|
|
+ if (entry.getKey().equals("wind")){
|
|
|
|
+ // 获取字典中nwp风速轮毂设置
|
|
|
|
+ SysDictData sysDictData = new SysDictData();
|
|
|
|
+ sysDictData.setDictType("nwp_wshubheight");
|
|
|
|
+ List<SysDictData> nwpWshubheightList = iSysDictDataService.selectDictDataList(sysDictData);
|
|
|
|
+ nwpWshubheightMap = nwpWshubheightList.stream().collect(Collectors.toMap(SysDictData::getDictLabel,SysDictData::getDictValue));
|
|
|
|
+ }
|
|
|
|
+ if (!stationCodeList.isEmpty()){
|
|
|
|
+ int counts = 10;
|
|
|
|
+ for (int i=1; i<=counts; i++) {
|
|
|
|
+ QueryWrapper<NwpCloud> nwpCloudQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ nwpCloudQueryWrapper.eq("forecast_how_long_ago",i);
|
|
|
|
+ nwpCloudQueryWrapper.between("time",dayStartTime,dayEndTime);
|
|
|
|
+ nwpCloudQueryWrapper.in("station_code", stationCodeList);
|
|
|
|
+ List<NwpCloud> nwpCloudList = nwpCloudService.list(nwpCloudQueryWrapper);
|
|
|
|
+ if (!nwpCloudList.isEmpty()){
|
|
|
|
+ nwpCloudMap = nwpCloudList.stream().collect(Collectors.groupingBy(n->n.getTime().getTime(), Collectors.toList()));
|
|
|
|
+ // 查出数据,并且有今日的预测数据,就退出当前循环。
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ // 否则,日期往前推一天,再查
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Long momentTime = 15 * 60 * 1000L;
|
|
|
|
+ List<ForecastNwpDto> forecastNwpDtoList = new ArrayList<>();
|
|
|
|
+ for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
|
|
|
|
+ ForecastNwpDto totalForecastNwpDto = new ForecastNwpDto();
|
|
|
|
+ totalForecastNwpDto.setTime(DateUtil.format(new Date(tempTime),"HH:mm"));
|
|
|
|
+ if ("wind".equals(entry.getKey())){
|
|
|
|
+ totalForecastNwpDto.setName("平均轮毂风速");
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ totalForecastNwpDto.setName("平均总辐射");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (nwpCloudMap.get(tempTime)!=null){
|
|
|
|
+ // 当前时间点所有站点数据
|
|
|
|
+ List<NwpCloud> nwpCloudList = nwpCloudMap.get(tempTime);
|
|
|
|
+ BigDecimal sum = BigDecimal.ZERO;
|
|
|
|
+ // 循环每个站封装点位以及统计总和
|
|
|
|
+ for (NwpCloud nwpCloud:nwpCloudList){
|
|
|
|
+ if ("wind".equals(entry.getKey())){
|
|
|
|
+ if (nwpWshubheightMap.get(nwpCloud.getStationCode())!=null){
|
|
|
|
+ // 场站配置了轮毂高度,根据轮毂高度反射获取字段值
|
|
|
|
+ Field field = ReflectUtil.getField(NwpCloud.class, "ws"+nwpWshubheightMap.get(nwpCloud.getStationCode()));
|
|
|
|
+ // 设置为可访问,私有字段也可以访问
|
|
|
|
+ field.setAccessible(true);
|
|
|
|
+ try {
|
|
|
|
+ // 获取字段值
|
|
|
|
+ Object fieldValue = field.get(nwpCloud);
|
|
|
|
+ sum = sum.add(new BigDecimal(fieldValue.toString()));
|
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ sum = sum.add(nwpCloud.getSwr());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ totalForecastNwpDto.setValue(sum);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ // 时间点位为空
|
|
|
|
+ totalForecastNwpDto.setValue(BigDecimal.ZERO);
|
|
|
|
+ }
|
|
|
|
+ forecastNwpDtoList.add(totalForecastNwpDto);
|
|
|
|
+ }
|
|
|
|
+ forecastWeatherAvgDataMap.put(entry.getKey(),forecastNwpDtoList);
|
|
|
|
+ }
|
|
|
|
+ return forecastWeatherAvgDataMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 预测气象放大窗口获取每个站的数据
|
|
|
|
+ * @param weatherType
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ @GetMapping("/forecastNwpFull")
|
|
|
|
+ public R forecastNwpFull(String weatherType) {
|
|
|
|
+ Map<String, String> nwpWshubheightMap = new HashMap<>();
|
|
|
|
+ QueryWrapper wrapper = new QueryWrapper<>();
|
|
|
|
+ if ("wind".equals(weatherType)){
|
|
|
|
+ // 过滤出风场站
|
|
|
|
+ wrapper.eq("electric_field_type_enum", "E2");
|
|
|
|
+
|
|
|
|
+ // 获取字典中nwp风速轮毂设置
|
|
|
|
+ SysDictData sysDictData = new SysDictData();
|
|
|
|
+ sysDictData.setDictType("nwp_wshubheight");
|
|
|
|
+ List<SysDictData> nwpWshubheightList = iSysDictDataService.selectDictDataList(sysDictData);
|
|
|
|
+ nwpWshubheightMap = nwpWshubheightList.stream().collect(Collectors.toMap(SysDictData::getDictLabel,SysDictData::getDictValue));
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ // 过滤出光场站
|
|
|
|
+ wrapper.eq("electric_field_type_enum", "E1");
|
|
|
|
+ }
|
|
|
|
+ List<ElectricField> list = electricFieldService.list(wrapper);
|
|
|
|
+ // 遍历获取场站nwp数据
|
|
|
|
+ List<String> stationCodeList = new ArrayList<>();
|
|
|
|
+ for (ElectricField electricField:list){
|
|
|
|
+ stationCodeList.add(electricField.getStationCode());
|
|
|
|
+ }
|
|
|
|
+ // 查询当日所有站的nwp数据
|
|
|
|
+ Date dayStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
|
|
|
|
+ Date dayEndTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
|
|
|
|
+ Map<String, List<NwpCloud>> nwpCloudMap = new HashMap<>();
|
|
|
|
+ if (!stationCodeList.isEmpty()){
|
|
|
|
+ int counts = 10;
|
|
|
|
+ for (int i=1; i<=counts; i++) {
|
|
|
|
+ QueryWrapper<NwpCloud> nwpCloudQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ nwpCloudQueryWrapper.eq("forecast_how_long_ago",i);
|
|
|
|
+ nwpCloudQueryWrapper.between("time",dayStartTime,dayEndTime);
|
|
|
|
+ nwpCloudQueryWrapper.in("station_code", stationCodeList);
|
|
|
|
+ List<NwpCloud> nwpCloudList = nwpCloudService.list(nwpCloudQueryWrapper);
|
|
|
|
+ if (!nwpCloudList.isEmpty()){
|
|
|
|
+ nwpCloudMap = nwpCloudList.stream().collect(Collectors.groupingBy(n->n.getStationCode(), Collectors.toList()));
|
|
|
|
+ // 查出数据,并且有今日的预测数据,就退出当前循环。
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ // 否则,日期往前推一天,再查
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Map<String,List<BigDecimal>> forecastWeatherDataMap = new HashMap<>();
|
|
|
|
+ Long momentTime = 15 * 60 * 1000L;
|
|
|
|
+ for (ElectricField electricField:list){
|
|
|
|
+ List<BigDecimal> nwpList = new ArrayList<>();
|
|
|
|
+ // 获取场站nwp
|
|
|
|
+ if (nwpCloudMap.get(electricField.getStationCode())!=null){
|
|
|
|
+ List<NwpCloud> nwpCloudList = nwpCloudMap.get(electricField.getStationCode());
|
|
|
|
+ Map<Long, NwpCloud> tempMap = nwpCloudList.stream().collect(Collectors.toMap(s->s.getTime().getTime(),s->s));
|
|
|
|
+ for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
|
|
|
|
+ BigDecimal value = BigDecimal.ZERO;
|
|
|
|
+ if (tempMap.get(tempTime)!=null){
|
|
|
|
+ NwpCloud nwpCloud = tempMap.get(tempTime);
|
|
|
|
+ if ("wind".equals(weatherType)){
|
|
|
|
+ if (nwpWshubheightMap.get(nwpCloud.getStationCode())!=null){
|
|
|
|
+ // 场站配置了轮毂高度,根据轮毂高度反射获取字段值
|
|
|
|
+ Field field = ReflectUtil.getField(NwpCloud.class, "ws"+nwpWshubheightMap.get(nwpCloud.getStationCode()));
|
|
|
|
+ // 设置为可访问,私有字段也可以访问
|
|
|
|
+ field.setAccessible(true);
|
|
|
|
+ try {
|
|
|
|
+ // 获取字段值
|
|
|
|
+ Object fieldValue = field.get(nwpCloud);
|
|
|
|
+ value = new BigDecimal(fieldValue.toString());
|
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ value = nwpCloud.getSwr();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ nwpList.add(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
|
|
|
|
+ nwpList.add(BigDecimal.ZERO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ forecastWeatherDataMap.put(electricField.getName(),nwpList);
|
|
|
|
+ }
|
|
|
|
+ return R.ok(forecastWeatherDataMap);
|
|
|
|
+ }
|
|
}
|
|
}
|