|
@@ -2,6 +2,7 @@ package com.cpp.web.controller.largeScreen;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ReflectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.cpp.common.core.cache.LocalCache;
|
|
|
import com.cpp.common.core.domain.R;
|
|
@@ -23,7 +24,6 @@ import com.cpp.web.service.station.*;
|
|
|
import com.cpp.web.utils.DateTimeUtil;
|
|
|
import com.cpp.web.utils.LatestDataUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.apache.commons.lang.time.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -31,6 +31,8 @@ import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -74,6 +76,7 @@ public class LargeScreenController {
|
|
|
public R getBizData(String forecastDay, String forecastType, String accuracyType) {
|
|
|
// 获取所有场站
|
|
|
List<ElectricField> electricFieldList = electricFieldService.list();
|
|
|
+
|
|
|
// 首页左上角场站数据统计
|
|
|
// 统计开机容量累计值
|
|
|
BigDecimal gfOpenCapacitySum = BigDecimal.ZERO;
|
|
@@ -124,6 +127,7 @@ public class LargeScreenController {
|
|
|
wsAvg = wsSum.divide(new BigDecimal(wsSumCount), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
electricFieldDataTotalDto.setWsAvg(wsAvg);
|
|
|
+
|
|
|
Map bizDataMap = new HashMap();
|
|
|
bizDataMap.put("electricFieldDataTotalDto", electricFieldDataTotalDto);
|
|
|
// 计算生成数据
|
|
@@ -133,14 +137,17 @@ public class LargeScreenController {
|
|
|
Map forecastGeneratingMap = calForecastGenerating();
|
|
|
bizDataMap.put("forecastGeneratingMap", forecastGeneratingMap);
|
|
|
// 获取首页中心侧nwp气象
|
|
|
- Map<String, List> forecastNwpMap = centerForecastNwpAvgTotal();
|
|
|
+ Map<String, List> forecastNwpMap = centerForecastNwpAvgTotal(electricFieldList);
|
|
|
bizDataMap.put("forecastNwpMap", forecastNwpMap);
|
|
|
//////////////// 获取首页预测对比数据 ///////////////
|
|
|
Map<String, List> curveMap = getForecastContrast(forecastDay, forecastType);
|
|
|
bizDataMap.put("curveMap", curveMap);
|
|
|
/////////////// 获取首页准确率排名 ///////////////
|
|
|
- Map<String, List<AccuracyRankingDto>> accuracyRankingMap = accuracyRanking();
|
|
|
+ Map<String, List<AccuracyRankingDto>> accuracyRankingMap = accuracyRanking(electricFieldList);
|
|
|
bizDataMap.put("accuracyRankingMap", accuracyRankingMap);
|
|
|
+ ////////////// 获取首页地图数据 //////////////
|
|
|
+ Map mapDataMap = mapData(electricFieldList);
|
|
|
+ bizDataMap.put("mapDataMap", mapDataMap);
|
|
|
|
|
|
|
|
|
return R.ok(bizDataMap);
|
|
@@ -287,10 +294,9 @@ public class LargeScreenController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private Map<String, List> centerForecastNwpAvgTotal() {
|
|
|
+ private Map<String, List> centerForecastNwpAvgTotal(List<ElectricField> list) {
|
|
|
// 根据类型获取所有场站
|
|
|
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) {
|
|
@@ -634,7 +640,7 @@ public class LargeScreenController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private Map<String, List<AccuracyRankingDto>> accuracyRanking() {
|
|
|
+ private Map<String, List<AccuracyRankingDto>> accuracyRanking(List<ElectricField> list) {
|
|
|
Map<String, List<AccuracyRankingDto>> accuracyMap = new HashMap();
|
|
|
// 昨日时间段
|
|
|
Date startTime = DateTimeUtil.getDayStartTime(DateUtil.yesterday().getTime());
|
|
@@ -642,7 +648,7 @@ public class LargeScreenController {
|
|
|
// 上个月时间段
|
|
|
Date lastMonthStartTime = DateTimeUtil.getMonthStartTime(System.currentTimeMillis());
|
|
|
Date lastMonthEndTime = DateTimeUtil.getMonthLastTime(System.currentTimeMillis());
|
|
|
- List<ElectricField> list = electricFieldService.list();
|
|
|
+
|
|
|
// 先查询昨日的准确率
|
|
|
String dqHowLongAgo = configService.selectConfigByKey("dqHowLongAgo");
|
|
|
QueryWrapper<AccuracyPassRate> accuracyPassRateQueryWrapper = new QueryWrapper<>();
|
|
@@ -726,4 +732,163 @@ public class LargeScreenController {
|
|
|
|
|
|
return accuracyMap;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 首页地图数据展示
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map mapData(List<ElectricField> list) {
|
|
|
+ List<String> stationCodeList = list.stream().map(ElectricField::getStationCode).collect(Collectors.toList());
|
|
|
+ // 获取当前时刻所有场站短期数据
|
|
|
+ Date dqMomentDate = DateTimeUtil.getMomentTimeFor15Minute(System.currentTimeMillis());
|
|
|
+ QueryWrapper dqsbWrapper = new QueryWrapper<>();
|
|
|
+ dqsbWrapper.eq("time", dqMomentDate);
|
|
|
+ dqsbWrapper.in("station_code", stationCodeList);
|
|
|
+ List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList = forecastPowerShortTermRegulationService.list(dqsbWrapper);
|
|
|
+ // 按场站分组
|
|
|
+ Map<String, List<ForecastPowerShortTermRegulation>> shortTermDataGroupByStationCode = forecastPowerShortTermRegulationList.stream().collect(Collectors.groupingBy(ForecastPowerShortTermRegulation::getStationCode));
|
|
|
+ // 超短期
|
|
|
+ QueryWrapper cdqsbWrapper = new QueryWrapper<>();
|
|
|
+ cdqsbWrapper.eq("time", dqMomentDate);
|
|
|
+ cdqsbWrapper.in("station_code", stationCodeList);
|
|
|
+ List<ForecastPowerUltraShortTermRegulation> forecastPowerUltraShortTermRegulationList = forecastPowerUltraShortTermRegulationService.list(cdqsbWrapper);
|
|
|
+ // 按场站分组
|
|
|
+ Map<String, List<ForecastPowerUltraShortTermRegulation>> ultraShortTermDataGroupByStationCode = forecastPowerUltraShortTermRegulationList.stream().collect(Collectors.groupingBy(ForecastPowerUltraShortTermRegulation::getStationCode));
|
|
|
+
|
|
|
+ List<MapDtaDto> mapDataDtoList = new ArrayList();
|
|
|
+ // 首页地图限电场站统计
|
|
|
+ int xdcoutns = 0;
|
|
|
+ // 通讯状态个数
|
|
|
+ int txcoutns = 0;
|
|
|
+ // 检修状态个数
|
|
|
+ int jxcoutns = 0;
|
|
|
+ // 运行状态个数
|
|
|
+ int yxcoutns = 0;
|
|
|
+ // 遍历所有场站封装地图展示的数据
|
|
|
+ for (ElectricField electricField : list) {
|
|
|
+ MapDtaDto mapDtaDto = new MapDtaDto();
|
|
|
+ mapDtaDto.setName(electricField.getName());
|
|
|
+ mapDtaDto.setStationCode(electricField.getStationCode());
|
|
|
+ mapDtaDto.setStationType(electricField.getElectricFieldTypeEnum());
|
|
|
+ mapDtaDto.setCapacity(electricField.getCapacity().setScale(2, RoundingMode.HALF_UP).toString());
|
|
|
+ mapDtaDto.setLeft(electricField.getMapLeft());
|
|
|
+ mapDtaDto.setTop(electricField.getMapTop());
|
|
|
+ if (shortTermDataGroupByStationCode.get(electricField.getStationCode())!=null){
|
|
|
+ List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList1 = shortTermDataGroupByStationCode.get(electricField.getStationCode());
|
|
|
+ // 再对场站多条预测记录,按howlongago排序,先获取数值小的。
|
|
|
+ forecastPowerShortTermRegulationList1.sort(Comparator.comparing(ForecastPowerShortTermRegulation::getForecastHowLongAgo));
|
|
|
+ mapDtaDto.setDq(forecastPowerShortTermRegulationList1.get(0).getFpValue().toString());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ mapDtaDto.setDq("0.00");
|
|
|
+ }
|
|
|
+ if (ultraShortTermDataGroupByStationCode.get(electricField.getStationCode())!=null){
|
|
|
+ List<ForecastPowerUltraShortTermRegulation> forecastPowerShortTermRegulationList1 = ultraShortTermDataGroupByStationCode.get(electricField.getStationCode());
|
|
|
+ // 再对场站多条预测记录,按howlongago排序,先获取数值小的。
|
|
|
+ forecastPowerShortTermRegulationList1.sort(Comparator.comparing(ForecastPowerUltraShortTermRegulation::getForecastHowLongAgo));
|
|
|
+ mapDtaDto.setCdq(forecastPowerShortTermRegulationList1.get(0).getFpValue().toString());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ mapDtaDto.setCdq("0.00");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 实际、可用、理论
|
|
|
+ PowerStationStatusData powerStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), PowerStationStatusData.class);
|
|
|
+ if (powerStationStatusData != null) {
|
|
|
+ mapDtaDto.setSjgl(powerStationStatusData.getRealValue().toString());
|
|
|
+ mapDtaDto.setKygl(powerStationStatusData.getAbleValue().toString());
|
|
|
+ mapDtaDto.setLlgl(powerStationStatusData.getTheoryValue().toString());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ mapDtaDto.setSjgl("0.00");
|
|
|
+ mapDtaDto.setKygl("0.00");
|
|
|
+ mapDtaDto.setLlgl("0.00");
|
|
|
+ }
|
|
|
+ if (electricField.getElectricFieldTypeEnum().equals("E2")){
|
|
|
+ // 风
|
|
|
+ WindTowerStatusData windTowerStatusData = LatestDataUtil.getData(electricField.getStationCode(), WindTowerStatusData.class);
|
|
|
+ if (windTowerStatusData != null) {
|
|
|
+ mapDtaDto.setHj(windTowerStatusData.getWsHubHeight().toString());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ mapDtaDto.setHj("0.00");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // 光
|
|
|
+ WeatherStationStatusData weatherStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), WeatherStationStatusData.class);
|
|
|
+ if (weatherStationStatusData != null) {
|
|
|
+ mapDtaDto.setHj(weatherStationStatusData.getGlobalR().toString());
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ mapDtaDto.setHj("0.00");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断场站状态,先获取是否通讯
|
|
|
+ boolean isCommunication = false;
|
|
|
+ if (!isCommunication){
|
|
|
+ // 无通讯
|
|
|
+ mapDtaDto.setStatus("无通讯");
|
|
|
+ txcoutns++;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // 判断是否检修
|
|
|
+ if (powerStationStatusData != null) {
|
|
|
+ // 获取站内受阻容量
|
|
|
+ BigDecimal blockedCapacity = powerStationStatusData.getBlockedCapacity();
|
|
|
+ if (blockedCapacity.compareTo(electricField.getCapacity().multiply(new BigDecimal(0.5)))>0){
|
|
|
+ // 超出装机50%容量,认为检修
|
|
|
+ mapDtaDto.setStatus("检修");
|
|
|
+ jxcoutns++;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // 未超过50%,判断是否限电
|
|
|
+ if (powerStationStatusData.getPowerRationing().intValue()==1){
|
|
|
+ // 限电
|
|
|
+ mapDtaDto.setStatus("限电");
|
|
|
+ xdcoutns++;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ mapDtaDto.setStatus("运行");
|
|
|
+ yxcoutns++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ // 没找到实际功率记录,认为场站正常状态
|
|
|
+ mapDtaDto.setStatus("运行");
|
|
|
+ yxcoutns++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mapDataDtoList.add(mapDtaDto);
|
|
|
+ }
|
|
|
+ Map mapDataMap = new HashMap();
|
|
|
+ mapDataMap.put("mapDataDtoList",mapDataDtoList);
|
|
|
+ mapDataMap.put("xdcoutns",xdcoutns);
|
|
|
+ mapDataMap.put("txcoutns",txcoutns);
|
|
|
+ mapDataMap.put("jxcoutns",jxcoutns);
|
|
|
+ mapDataMap.put("yxcoutns",yxcoutns);
|
|
|
+ // 获取系统运行开始日期(yyyy-MM-dd)
|
|
|
+ int runDays = 66;
|
|
|
+ String systemRunDate = configService.selectConfigByKey("systemRunDate");
|
|
|
+ try{
|
|
|
+ // 计算系统运行天数
|
|
|
+ LocalDate date1 = LocalDate.parse(systemRunDate);
|
|
|
+ LocalDate date2 = LocalDate.parse(DateUtil.today());
|
|
|
+ long days = ChronoUnit.DAYS.between(date1, date2);
|
|
|
+ runDays = (int)(days+1);
|
|
|
+ }
|
|
|
+ catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ mapDataMap.put("runDays",runDays);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return mapDataMap;
|
|
|
+ }
|
|
|
}
|