Kaynağa Gözat

首页准确率展示

xusl 5 ay önce
ebeveyn
işleme
9191663312

+ 211 - 176
cpp-admin/src/main/java/com/cpp/web/controller/largeScreen/LargeScreenController.java

@@ -71,7 +71,7 @@ public class LargeScreenController {
     AccuracyPassRateService accuracyPassRateService;
 
     @GetMapping("/getBizData")
-    public R getBizData(String forecastDay,String forecastType) {
+    public R getBizData(String forecastDay, String forecastType, String accuracyType) {
         // 获取所有场站
         List<ElectricField> electricFieldList = electricFieldService.list();
         // 首页左上角场站数据统计
@@ -84,29 +84,28 @@ public class LargeScreenController {
         int wsSumCount = 0;
         int fzdSumCount = 0;
 
-        for (ElectricField electricField:electricFieldList){
+        for (ElectricField electricField : electricFieldList) {
             PowerStationStatusData powerStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), PowerStationStatusData.class);
-            if (ElectricFieldTypeEnum.E1.name().equals(electricField.getElectricFieldTypeEnum())){
+            if (ElectricFieldTypeEnum.E1.name().equals(electricField.getElectricFieldTypeEnum())) {
                 // 获取气象站辐照度
                 WeatherStationStatusData weatherStationStatusData = LatestDataUtil.getData(electricField.getStationCode(), WeatherStationStatusData.class);
-                if (weatherStationStatusData!=null){
+                if (weatherStationStatusData != null) {
                     fzdSum = fzdSum.add(weatherStationStatusData.getGlobalR());
                     fzdSumCount++;
                 }
                 // 累计开机容量
-                if (powerStationStatusData!=null){
+                if (powerStationStatusData != null) {
                     gfOpenCapacitySum = gfOpenCapacitySum.add(powerStationStatusData.getOpenCapacity());
                 }
-            }
-            else{
+            } else {
                 // 获取测风塔风速
                 WindTowerStatusData windTowerStatusData = LatestDataUtil.getData(electricField.getStationCode(), WindTowerStatusData.class);
-                if (windTowerStatusData!=null){
+                if (windTowerStatusData != null) {
                     wsSum = wsSum.add(windTowerStatusData.getWsHubHeight());
                     wsSumCount++;
                 }
                 // 累计开机容量
-                if (powerStationStatusData!=null){
+                if (powerStationStatusData != null) {
                     fdOpenCapacitySum = fdOpenCapacitySum.add(powerStationStatusData.getOpenCapacity());
                 }
             }
@@ -115,36 +114,33 @@ public class LargeScreenController {
         ElectricFieldDataTotalDto electricFieldDataTotalDto = new ElectricFieldDataTotalDto();
         electricFieldDataTotalDto.setGfOpenCapcitySum(gfOpenCapacitySum);
         BigDecimal fzdAvg = BigDecimal.ZERO;
-        if (fzdSum.compareTo(BigDecimal.ZERO)==1){
-            fzdAvg = fzdSum.divide(new BigDecimal(fzdSumCount),2, BigDecimal.ROUND_HALF_UP);
+        if (fzdSum.compareTo(BigDecimal.ZERO) == 1) {
+            fzdAvg = fzdSum.divide(new BigDecimal(fzdSumCount), 2, BigDecimal.ROUND_HALF_UP);
         }
         electricFieldDataTotalDto.setFzdAvg(fzdAvg);
         electricFieldDataTotalDto.setFdOpenCapcitySum(fdOpenCapacitySum);
         BigDecimal wsAvg = BigDecimal.ZERO;
-        if (wsSum.compareTo(BigDecimal.ZERO)==1){
-            wsAvg = wsSum.divide(new BigDecimal(wsSumCount),2, BigDecimal.ROUND_HALF_UP);
+        if (wsSum.compareTo(BigDecimal.ZERO) == 1) {
+            wsAvg = wsSum.divide(new BigDecimal(wsSumCount), 2, BigDecimal.ROUND_HALF_UP);
         }
         electricFieldDataTotalDto.setWsAvg(wsAvg);
         Map bizDataMap = new HashMap();
-        bizDataMap.put("electricFieldDataTotalDto",electricFieldDataTotalDto);
+        bizDataMap.put("electricFieldDataTotalDto", electricFieldDataTotalDto);
         // 计算生成数据
         ProductionDataTotalDto productionDataTotalDto = calGenerating();
-        bizDataMap.put("productionDataTotalDto",productionDataTotalDto);
+        bizDataMap.put("productionDataTotalDto", productionDataTotalDto);
         // 获取预测发电量
         Map forecastGeneratingMap = calForecastGenerating();
-        bizDataMap.put("forecastGeneratingMap",forecastGeneratingMap);
-
+        bizDataMap.put("forecastGeneratingMap", forecastGeneratingMap);
         // 获取首页中心侧nwp气象
-        Map<String,List> forecastNwpMap = centerForecastNwpAvgTotal();
-        bizDataMap.put("forecastNwpMap",forecastNwpMap);
-
-
-
+        Map<String, List> forecastNwpMap = centerForecastNwpAvgTotal();
+        bizDataMap.put("forecastNwpMap", forecastNwpMap);
         //////////////// 获取首页预测对比数据 ///////////////
-        Map<String,List> curveMap = getForecastContrast(forecastDay,forecastType);
-        bizDataMap.put("curveMap",curveMap);
-
-
+        Map<String, List> curveMap = getForecastContrast(forecastDay, forecastType);
+        bizDataMap.put("curveMap", curveMap);
+        /////////////// 获取首页准确率排名 ///////////////
+        Map<String, List<AccuracyRankingDto>> accuracyRankingMap = accuracyRanking();
+        bizDataMap.put("accuracyRankingMap", accuracyRankingMap);
 
 
         return R.ok(bizDataMap);
@@ -152,9 +148,10 @@ public class LargeScreenController {
 
     /**
      * 统计首页生成数据
+     *
      * @return
      */
-    private ProductionDataTotalDto calGenerating(){
+    private ProductionDataTotalDto calGenerating() {
         // 当日零点
         Date dayStartTime = new Date(DateTimeUtil.getMillisecondsSubDay());
         // 获取当前时刻5分钟
@@ -171,13 +168,13 @@ public class LargeScreenController {
         BigDecimal realGeneratingSum = BigDecimal.ZERO;
         for (PowerStationStatusData powerStationStatusData : powerStationStatusDataList) {
             // 统计实际功率总和
-            if (powerStationStatusData.getRealValue()!=null){
+            if (powerStationStatusData.getRealValue() != null) {
                 realPowerSum = realPowerSum.add(powerStationStatusData.getRealValue());
                 // 发电量(万kWh) = 实际 * 0.08 * 0.1
                 realGeneratingSum = realGeneratingSum.add(powerStationStatusData.getRealValue().multiply(new BigDecimal("0.08")).multiply(new BigDecimal("0.1")).setScale(2, RoundingMode.HALF_UP));
             }
             // 统计理论功率总和
-            if (powerStationStatusData.getTheoryValue()!=null){
+            if (powerStationStatusData.getTheoryValue() != null) {
                 theoryPowerSum = theoryPowerSum.add(powerStationStatusData.getTheoryValue());
             }
         }
@@ -198,20 +195,19 @@ public class LargeScreenController {
             generationWrapper.eq("gen_date", formatter.format(yesterdayDate.getTime()));
             generationWrapper.eq("prediction_data_source", "云端下发");
             dayPowerGenerationList = dayPowerGenerationService.list(generationWrapper);
-            if (!dayPowerGenerationList.isEmpty()){
+            if (!dayPowerGenerationList.isEmpty()) {
                 // 查出数据,并且有今日的预测数据,就退出当前循环。
                 dayPowerGenerationList = dayPowerGenerationList.stream().filter(f -> f.getTime().equals(formatter.format(new Date()))).collect(Collectors.toList());
-                if (dayPowerGenerationList.size()>0){
+                if (dayPowerGenerationList.size() > 0) {
                     break;
                 }
-            }
-            else{
+            } else {
                 // 否则,日期往前推一天,再查
             }
         }
         // 累加中心侧预测发电量
         BigDecimal forecastGeneratingSum = BigDecimal.ZERO;
-        for (DayPowerGeneration dayPowerGeneration:dayPowerGenerationList){
+        for (DayPowerGeneration dayPowerGeneration : dayPowerGenerationList) {
             forecastGeneratingSum = forecastGeneratingSum.add(dayPowerGeneration.getForecastPowerGeneration());
         }
 
@@ -225,9 +221,10 @@ public class LargeScreenController {
 
     /**
      * 统计首页未来10天预测总发电量
+     *
      * @return
      */
-    private Map calForecastGenerating(){
+    private Map calForecastGenerating() {
         // 获取未来10天的中心侧模型预测发电量
         int counts = -3;
         // 定义日期格式
@@ -242,72 +239,70 @@ public class LargeScreenController {
             generationWrapper.eq("gen_date", formatter.format(currentDate.getTime()));
             generationWrapper.eq("prediction_data_source", "云端下发");
             dayPowerGenerationList = dayPowerGenerationService.list(generationWrapper);
-            if (!dayPowerGenerationList.isEmpty()){
+            if (!dayPowerGenerationList.isEmpty()) {
                 // 查出数据就退出当前循环
                 break;
-            }
-            else{
+            } else {
                 // 否则,日期往前推一天,再查
             }
         }
         // 按场时间分组
-        Map<String, List<DayPowerGeneration>> shortTermDataGroup = dayPowerGenerationList.stream().collect(Collectors.groupingBy(s->s.getTime()));
-        Map<String,List> forecastGeneratingMap = new HashMap<>();
+        Map<String, List<DayPowerGeneration>> shortTermDataGroup = dayPowerGenerationList.stream().collect(Collectors.groupingBy(s -> s.getTime()));
+        Map<String, List> forecastGeneratingMap = new HashMap<>();
         // 图表x轴时间数据
         List<String> xDataList = new ArrayList<>();
         // 图表y轴发电量数据
         List<BigDecimal> pDataList = new ArrayList<>();
 
         // 统计每天里所有电站发电量总和
-        if (shortTermDataGroup!=null){
+        if (shortTermDataGroup != null) {
             // 第二天
             Calendar nextDate = Calendar.getInstance();
             nextDate.add(Calendar.DAY_OF_MONTH, 1);
             Calendar end10Date = Calendar.getInstance();
             end10Date.add(Calendar.DAY_OF_MONTH, 10);
             for (; nextDate.before(end10Date); nextDate.add(Calendar.DATE, 1)) {
-                String dateFormat = DateUtil.format(nextDate.getTime(),"yyyy-MM-dd");
+                String dateFormat = DateUtil.format(nextDate.getTime(), "yyyy-MM-dd");
                 xDataList.add(dateFormat.substring(5));
-                if (shortTermDataGroup.get(dateFormat)!=null){
+                if (shortTermDataGroup.get(dateFormat) != null) {
                     List<DayPowerGeneration> dayPowerGenerations = shortTermDataGroup.get(dateFormat);
                     BigDecimal sum = BigDecimal.ZERO;
-                    for (DayPowerGeneration dayPowerGeneration:dayPowerGenerations){
+                    for (DayPowerGeneration dayPowerGeneration : dayPowerGenerations) {
                         sum = sum.add(dayPowerGeneration.getForecastPowerGeneration());
                     }
                     pDataList.add(sum);
-                }
-                else{
+                } else {
                     pDataList.add(BigDecimal.ZERO);
                 }
 
             }
-            forecastGeneratingMap.put("xData",xDataList);
-            forecastGeneratingMap.put("pData",pDataList);
+            forecastGeneratingMap.put("xData", xDataList);
+            forecastGeneratingMap.put("pData", pDataList);
         }
         return forecastGeneratingMap;
     }
 
     /**
      * 首页中心预测nwp气象站数据总体平均值
+     *
      * @return
      */
-    private Map<String,List> centerForecastNwpAvgTotal(){
+    private Map<String, List> centerForecastNwpAvgTotal() {
         // 根据类型获取所有场站
-        Map<String,List> stationMap = new HashMap();
+        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")){
+        for (ElectricField electricField : list) {
+            if (electricField.getElectricFieldTypeEnum().equals("E1")) {
                 gfStationCodeList.add(electricField.getStationCode());
-            }
-            else{
+            } else {
                 windStationCodeList.add(electricField.getStationCode());
             }
         }
-        stationMap.put("gf",gfStationCodeList);
-        stationMap.put("wind",windStationCodeList);
-        Map<String,List> forecastWeatherAvgDataMap = new HashMap<>();
+        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()) {
@@ -315,29 +310,28 @@ public class LargeScreenController {
             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")){
+            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));
+                nwpWshubheightMap = nwpWshubheightList.stream().collect(Collectors.toMap(SysDictData::getDictLabel, SysDictData::getDictValue));
             }
-            if (!stationCodeList.isEmpty()){
+            if (!stationCodeList.isEmpty()) {
                 int counts = 10;
-                for (int i=1; i<=counts; i++) {
+                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.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()));
+                    if (!nwpCloudList.isEmpty()) {
+                        nwpCloudMap = nwpCloudList.stream().collect(Collectors.groupingBy(n -> n.getTime().getTime(), Collectors.toList()));
                         // 查出数据,并且有今日的预测数据,就退出当前循环。
                         break;
-                    }
-                    else{
+                    } else {
                         // 否则,日期往前推一天,再查
                     }
                 }
@@ -346,24 +340,23 @@ public class LargeScreenController {
             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.setTime(DateUtil.format(new Date(tempTime), "HH:mm"));
+                if ("wind".equals(entry.getKey())) {
                     totalForecastNwpDto.setName("平均轮毂风速");
-                }
-                else{
+                } else {
                     totalForecastNwpDto.setName("平均总辐射");
                 }
 
-                if (nwpCloudMap.get(tempTime)!=null){
+                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){
+                    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 field = ReflectUtil.getField(NwpCloud.class, "ws" + nwpWshubheightMap.get(nwpCloud.getStationCode()));
                                 // 设置为可访问,私有字段也可以访问
                                 field.setAccessible(true);
                                 try {
@@ -374,26 +367,25 @@ public class LargeScreenController {
                                     e.printStackTrace();
                                 }
                             }
-                        }
-                        else{
+                        } else {
                             sum = sum.add(nwpCloud.getSwr());
                         }
                     }
                     totalForecastNwpDto.setValue(sum);
-                }
-                else{
+                } else {
                     // 时间点位为空
                     totalForecastNwpDto.setValue(BigDecimal.ZERO);
                 }
                 forecastNwpDtoList.add(totalForecastNwpDto);
             }
-            forecastWeatherAvgDataMap.put(entry.getKey(),forecastNwpDtoList);
+            forecastWeatherAvgDataMap.put(entry.getKey(), forecastNwpDtoList);
         }
         return forecastWeatherAvgDataMap;
     }
 
     /**
      * 预测气象放大窗口获取每个站的数据
+     *
      * @param weatherType
      * @return
      */
@@ -402,7 +394,7 @@ public class LargeScreenController {
     public R forecastNwpFull(String weatherType) {
         Map<String, String> nwpWshubheightMap = new HashMap<>();
         QueryWrapper wrapper = new QueryWrapper<>();
-        if ("wind".equals(weatherType)){
+        if ("wind".equals(weatherType)) {
             // 过滤出风场站
             wrapper.eq("electric_field_type_enum", "E2");
 
@@ -410,56 +402,54 @@ public class LargeScreenController {
             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{
+            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){
+        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()){
+        Map<String, List<NwpCloud>> nwpCloudMap = new HashMap<>();
+        if (!stationCodeList.isEmpty()) {
             int counts = 10;
-            for (int i=1; i<=counts; i++) {
+            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.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()));
+                if (!nwpCloudList.isEmpty()) {
+                    nwpCloudMap = nwpCloudList.stream().collect(Collectors.groupingBy(n -> n.getStationCode(), Collectors.toList()));
                     // 查出数据,并且有今日的预测数据,就退出当前循环。
                     break;
-                }
-                else{
+                } else {
                     // 否则,日期往前推一天,再查
                 }
             }
         }
-        Map<String,List<BigDecimal>> forecastWeatherDataMap = new HashMap<>();
+        Map<String, List<BigDecimal>> forecastWeatherDataMap = new HashMap<>();
         Long momentTime = 15 * 60 * 1000L;
-        for (ElectricField electricField:list){
+        for (ElectricField electricField : list) {
             List<BigDecimal> nwpList = new ArrayList<>();
             // 获取场站nwp
-            if (nwpCloudMap.get(electricField.getStationCode())!=null){
+            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));
+                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){
+                    if (tempMap.get(tempTime) != null) {
                         NwpCloud nwpCloud = tempMap.get(tempTime);
-                        if ("wind".equals(weatherType)){
-                            if (nwpWshubheightMap.get(nwpCloud.getStationCode())!=null){
+                        if ("wind".equals(weatherType)) {
+                            if (nwpWshubheightMap.get(nwpCloud.getStationCode()) != null) {
                                 // 场站配置了轮毂高度,根据轮毂高度反射获取字段值
-                                Field field = ReflectUtil.getField(NwpCloud.class, "ws"+nwpWshubheightMap.get(nwpCloud.getStationCode()));
+                                Field field = ReflectUtil.getField(NwpCloud.class, "ws" + nwpWshubheightMap.get(nwpCloud.getStationCode()));
                                 // 设置为可访问,私有字段也可以访问
                                 field.setAccessible(true);
                                 try {
@@ -470,66 +460,64 @@ public class LargeScreenController {
                                     e.printStackTrace();
                                 }
                             }
-                        }
-                        else{
+                        } else {
                             value = nwpCloud.getSwr();
                         }
                     }
                     nwpList.add(value);
                 }
-            }
-            else{
+            } else {
                 for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
                     nwpList.add(BigDecimal.ZERO);
                 }
             }
-            forecastWeatherDataMap.put(electricField.getName(),nwpList);
+            forecastWeatherDataMap.put(electricField.getName(), nwpList);
         }
         return R.ok(forecastWeatherDataMap);
     }
 
     /**
      * 首页功率曲线对比
+     *
      * @param forecastDay
      * @param forecastType
      * @return
      */
     @GetMapping("/forecastContrast")
-    public R forecastContrast(String forecastDay,String forecastType) {
-        Map<String,List> map = getForecastContrast(forecastDay,forecastType);
+    public R forecastContrast(String forecastDay, String forecastType) {
+        Map<String, List> map = getForecastContrast(forecastDay, forecastType);
         return R.ok(map);
     }
 
     /**
      * 获取预测对比数据公共方法
+     *
      * @param forecastDay
      * @param forecastType
      */
-    private Map<String,List> getForecastContrast(String forecastDay,String forecastType){
+    private Map<String, List> getForecastContrast(String forecastDay, String forecastType) {
         Date dayStartTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
         Date dayEndTime = null;
-        if ("day".equals(forecastDay)){
+        if ("day".equals(forecastDay)) {
             // 当日
             dayEndTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
-        }
-        else{
+        } else {
             // 包含当天的才是10天
             dayEndTime = DateUtil.offsetDay(new Date(), 9);
         }
 
         QueryWrapper wrapper = new QueryWrapper<>();
-        if ("wind".equals(forecastType)){
+        if ("wind".equals(forecastType)) {
             // 过滤出风场站
             wrapper.eq("electric_field_type_enum", "E2");
-        }
-        else{
+        } else {
             // 过滤出光场站
             wrapper.eq("electric_field_type_enum", "E1");
         }
         List<ElectricField> list = electricFieldService.list(wrapper);
         // 遍历获取场站nwp数据
         List<String> stationCodeList = new ArrayList<>();
-        for (ElectricField electricField:list){
+        for (ElectricField electricField : list) {
             stationCodeList.add(electricField.getStationCode());
         }
 
@@ -541,14 +529,14 @@ public class LargeScreenController {
         List<Object> dqList = new ArrayList<>();
         List<Object> timeList = new ArrayList<>();
 
-        if (!stationCodeList.isEmpty()){
+        if (!stationCodeList.isEmpty()) {
             // 查询实际功率、可用、理论
             QueryWrapper<PowerStationStatusData> realQueryWrapper = new QueryWrapper<>();
-            realQueryWrapper.between("time",dayStartTime,dayEndTime);
+            realQueryWrapper.between("time", dayStartTime, dayEndTime);
             realQueryWrapper.in("station_code", stationCodeList);
             List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataService.list(realQueryWrapper);
             // 按场时间分组
-            Map<Long, List<PowerStationStatusData>> powerStationStatusDataGroup = powerStationStatusDataList.stream().collect(Collectors.groupingBy(s->s.getTime().getTime()));
+            Map<Long, List<PowerStationStatusData>> powerStationStatusDataGroup = powerStationStatusDataList.stream().collect(Collectors.groupingBy(s -> s.getTime().getTime()));
             // 获取超短期
             String cdqHowLongAgo = configService.selectConfigByKey("cdqHowLongAgo");
             QueryWrapper cdqysWrapper = new QueryWrapper<>();
@@ -557,7 +545,7 @@ public class LargeScreenController {
             cdqysWrapper.in("station_code", stationCodeList);
             List<ForecastPowerUltraShortTermRegulation> forecastPowerUltraShortTermStationList = forecastPowerUltraShortTermRegulationService.list(cdqysWrapper);
             // 按场时间分组
-            Map<Long, List<ForecastPowerUltraShortTermRegulation>> utraShortTermStationDataGroup = forecastPowerUltraShortTermStationList.stream().collect(Collectors.groupingBy(s->s.getTime().getTime()));
+            Map<Long, List<ForecastPowerUltraShortTermRegulation>> utraShortTermStationDataGroup = forecastPowerUltraShortTermStationList.stream().collect(Collectors.groupingBy(s -> s.getTime().getTime()));
 
             // 获取短期上报
             String dqHowLongAgo = configService.selectConfigByKey("dqHowLongAgo");
@@ -567,25 +555,24 @@ public class LargeScreenController {
             dqsbWrapper.in("station_code", stationCodeList);
             List<ForecastPowerShortTermRegulation> forecastPowerShortTermRegulationList = forecastPowerShortTermRegulationService.list(dqsbWrapper);
             // 按场时间分组
-            Map<Long, List<ForecastPowerShortTermRegulation>> shortTermDataGroup = forecastPowerShortTermRegulationList.stream().collect(Collectors.groupingBy(s->s.getTime().getTime()));
+            Map<Long, List<ForecastPowerShortTermRegulation>> shortTermDataGroup = forecastPowerShortTermRegulationList.stream().collect(Collectors.groupingBy(s -> s.getTime().getTime()));
 
             Long momentTime = 15 * 60 * 1000L;
             for (Long tempTime = dayStartTime.getTime(); tempTime <= dayEndTime.getTime(); tempTime = tempTime + momentTime) {
-                if ("day".equals(forecastDay)){
+                if ("day".equals(forecastDay)) {
                     timeList.add(DateUtil.format(new Date(tempTime), "HH:mm"));
-                }
-                else{
+                } else {
                     timeList.add(DateUtil.format(new Date(tempTime), "yyyy-MM-dd HH:mm"));
                 }
 
                 // 统计实际功率、可用、理论曲线
-                if (powerStationStatusDataGroup.get(tempTime)!=null){
+                if (powerStationStatusDataGroup.get(tempTime) != null) {
                     // 对每个时间点的所有场站数据进行求和
                     List<PowerStationStatusData> everyDataList = powerStationStatusDataGroup.get(tempTime);
                     BigDecimal tempRealSum = BigDecimal.ZERO;
                     BigDecimal tempAbleSum = BigDecimal.ZERO;
                     BigDecimal tempTheorySum = BigDecimal.ZERO;
-                    for (PowerStationStatusData powerStationStatusData:everyDataList){
+                    for (PowerStationStatusData powerStationStatusData : everyDataList) {
                         BigDecimal realValue = powerStationStatusData.getRealValue();
                         tempRealSum = tempRealSum.add(realValue);
                         BigDecimal ableValue = powerStationStatusData.getAbleValue();
@@ -596,99 +583,147 @@ public class LargeScreenController {
                     realList.add(tempRealSum);
                     ableList.add(tempAbleSum);
                     theoryList.add(tempTheorySum);
-                }
-                else{
+                } else {
                     realList.add(null);
                     ableList.add(null);
                     theoryList.add(null);
                 }
                 // 统计超短期曲线
-                if (utraShortTermStationDataGroup.get(tempTime)!=null){
+                if (utraShortTermStationDataGroup.get(tempTime) != null) {
                     // 对每个时间点的所有场站数据进行求和
                     List<ForecastPowerUltraShortTermRegulation> everyDataList = utraShortTermStationDataGroup.get(tempTime);
                     BigDecimal tempCdqSum = BigDecimal.ZERO;
-                    for (ForecastPowerUltraShortTermRegulation forecastPowerUltraShortTermStation:everyDataList){
+                    for (ForecastPowerUltraShortTermRegulation forecastPowerUltraShortTermStation : everyDataList) {
                         BigDecimal cdqValue = forecastPowerUltraShortTermStation.getFpValue();
                         tempCdqSum = tempCdqSum.add(cdqValue);
                     }
                     cdqList.add(tempCdqSum);
-                }
-                else{
+                } else {
                     cdqList.add(null);
                 }
                 // 统计短期上报曲线
-                if (shortTermDataGroup.get(tempTime)!=null){
+                if (shortTermDataGroup.get(tempTime) != null) {
                     // 对每个时间点的所有场站数据进行求和
                     List<ForecastPowerShortTermRegulation> everyDataList = shortTermDataGroup.get(tempTime);
                     BigDecimal tempDqSum = BigDecimal.ZERO;
-                    for (ForecastPowerShortTermRegulation forecastPowerShortTermRegulation:everyDataList){
+                    for (ForecastPowerShortTermRegulation forecastPowerShortTermRegulation : everyDataList) {
                         BigDecimal dqValue = forecastPowerShortTermRegulation.getFpValue();
                         tempDqSum = tempDqSum.add(dqValue);
                     }
                     dqList.add(tempDqSum);
-                }
-                else{
+                } else {
                     dqList.add(null);
                 }
             }
         }
 
         // 定义曲线map
-        Map<String,List> curveMap = new HashMap();
-        curveMap.put("timeList",timeList);
-        curveMap.put("realList",realList);
-        curveMap.put("ableList",ableList);
-        curveMap.put("theoryList",theoryList);
-        curveMap.put("cdqList",cdqList);
-        curveMap.put("dqList",dqList);
+        Map<String, List> curveMap = new HashMap();
+        curveMap.put("timeList", timeList);
+        curveMap.put("realList", realList);
+        curveMap.put("ableList", ableList);
+        curveMap.put("theoryList", theoryList);
+        curveMap.put("cdqList", cdqList);
+        curveMap.put("dqList", dqList);
 
         return curveMap;
     }
 
     /**
      * 首页准确率排名
+     *
      * @return
      */
-    private Map<String,List<AccuracyRankingDto>> accuracyRanking(String accuracyType){
-        Map<String,List<AccuracyRankingDto>> accuracyMap = new HashMap();
-        // 根据类型获取准确率数据
-        Date startTime = DateTimeUtil.getMonthStartTime(System.currentTimeMillis());
-        Date endTime = DateTimeUtil.getMonthLastTime(System.currentTimeMillis());
-        if ("day".equals(accuracyType)){
-            // 当日
-            startTime = DateTimeUtil.getDayStartTime(System.currentTimeMillis());
-            endTime = DateTimeUtil.getDayLastTime(System.currentTimeMillis());
-        }
-
+    private Map<String, List<AccuracyRankingDto>> accuracyRanking() {
+        Map<String, List<AccuracyRankingDto>> accuracyMap = new HashMap();
+        // 昨日时间段
+        Date startTime = DateTimeUtil.getDayStartTime(DateUtil.yesterday().getTime());
+        Date endTime = DateTimeUtil.getDayLastTime(DateUtil.yesterday().getTime());
+        // 上个月时间段
+        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<>();
         accuracyPassRateQueryWrapper.eq("forecast_how_long_ago", dqHowLongAgo);
         accuracyPassRateQueryWrapper.eq("data_sources", DataSourcesEnum.E4.name());
-        accuracyPassRateQueryWrapper.between("time", startTime,endTime);
+        accuracyPassRateQueryWrapper.between("time", startTime, endTime);
         List<AccuracyPassRate> accuracyPassRateList = accuracyPassRateService.list(accuracyPassRateQueryWrapper);
         // 按场站编号分组
         Map<String, List<AccuracyPassRate>> groupByStationCode = accuracyPassRateList.stream().collect(Collectors.groupingBy(AccuracyPassRate::getStationCode));
+        List<AccuracyRankingDto> dayRankingList = new ArrayList();
+        for (ElectricField electricField : list) {
+            AccuracyRankingDto accuracyRankingDto = new AccuracyRankingDto();
+            accuracyRankingDto.setName(electricField.getName());
+            if (groupByStationCode.get(electricField.getStationCode()) != null) {
+                List<AccuracyPassRate> accuracyPassRateList1 = groupByStationCode.get(electricField.getStationCode());
+                if ("无可用数据计算".equals(accuracyPassRateList1.get(0).getAccuracy())) {
+                    accuracyRankingDto.setAccuracy("0%");
+                } else {
+                    accuracyRankingDto.setAccuracy(accuracyPassRateList1.get(0).getAccuracy());
+                }
+            } else {
+                // 昨日没有此场站的准确率
+                accuracyRankingDto.setAccuracy("0%");
+            }
+            dayRankingList.add(accuracyRankingDto);
+        }
+        dayRankingList.sort(Comparator.comparing(AccuracyRankingDto::getAccuracy).reversed().thenComparing(AccuracyRankingDto::getName));
+        // 分配排名,允许并列
+        int currentRank = 1;
+        for (int i = 0; i < dayRankingList.size(); i++) {
+            AccuracyRankingDto dto = dayRankingList.get(i);
+            dto.setSort(currentRank + "");
+            if (i + 1 <= dayRankingList.size() - 1) {
+                AccuracyRankingDto nextDto = dayRankingList.get(i + 1);
+                if (!dto.getAccuracy().equals(nextDto.getAccuracy())) {
+                    currentRank++;
+                }
+            }
+        }
 
-
-
-
-
-
-        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());
+        // 查询上个月的准确率
+        QueryWrapper<AccuracyPassRate> lastMonthQueryWrapper = new QueryWrapper<>();
+        lastMonthQueryWrapper.eq("forecast_how_long_ago", dqHowLongAgo);
+        lastMonthQueryWrapper.eq("data_sources", DataSourcesEnum.E4.name());
+        lastMonthQueryWrapper.between("time", lastMonthStartTime, lastMonthEndTime);
+        List<AccuracyPassRate> lastMonthAccuracyPassRateList = accuracyPassRateService.list(lastMonthQueryWrapper);
+        // 按场站编号分组
+        Map<String, List<AccuracyPassRate>> lastMonthGroupByStationCode = lastMonthAccuracyPassRateList.stream().collect(Collectors.groupingBy(AccuracyPassRate::getStationCode));
+        List<AccuracyRankingDto> lastMonthRankingList = new ArrayList();
+        for (ElectricField electricField : list) {
+            AccuracyRankingDto accuracyRankingDto = new AccuracyRankingDto();
+            accuracyRankingDto.setName(electricField.getName());
+            if (lastMonthGroupByStationCode.get(electricField.getStationCode()) != null) {
+                List<AccuracyPassRate> accuracyPassRateList1 = lastMonthGroupByStationCode.get(electricField.getStationCode());
+                if ("无可用数据计算".equals(accuracyPassRateList1.get(0).getAccuracy())) {
+                    accuracyRankingDto.setAccuracy("0%");
+                } else {
+                    accuracyRankingDto.setAccuracy(accuracyPassRateList1.get(0).getAccuracy());
+                }
+            } else {
+                // 上个月没有此场站的准确率
+                accuracyRankingDto.setAccuracy("0%");
             }
-            else{
-                windStationCodeList.add(electricField.getStationCode());
+            lastMonthRankingList.add(accuracyRankingDto);
+        }
+        lastMonthRankingList.sort(Comparator.comparing(AccuracyRankingDto::getAccuracy).reversed().thenComparing(AccuracyRankingDto::getName));
+        // 分配排名,允许并列
+        int lastMonthCurrentRank = 1;
+        for (int i = 0; i < lastMonthRankingList.size(); i++) {
+            AccuracyRankingDto dto = lastMonthRankingList.get(i);
+            dto.setSort(lastMonthCurrentRank + "");
+            if (i + 1 <= lastMonthRankingList.size() - 1) {
+                AccuracyRankingDto nextDto = lastMonthRankingList.get(i + 1);
+                if (!dto.getAccuracy().equals(nextDto.getAccuracy())) {
+                    lastMonthCurrentRank++;
+                }
             }
         }
-//        stationMap.put("gf",gfStationCodeList);
-//        stationMap.put("wind",windStationCodeList);
-        Map<String,List> forecastWeatherAvgDataMap = new HashMap<>();
+        accuracyMap.put("dayRankingList", dayRankingList);
+        accuracyMap.put("lastMonthRankingList", lastMonthRankingList);
 
-        return null;
+        return accuracyMap;
     }
 }

+ 1 - 1
cpp-admin/src/main/java/com/cpp/web/dto/largeScreen/AccuracyRankingDto.java

@@ -17,5 +17,5 @@ public class AccuracyRankingDto {
     // 排名
     private String sort;
     // 准确率
-    private BigDecimal accuracy;
+    private String accuracy;
 }

+ 3 - 3
cpp-ui/src/views/largeScreen/components/right-top.vue

@@ -81,14 +81,14 @@ export default {
     }
   },
   props: {
-    params: {type: Array}
+    params: {type: Object}
   },
   watch: {
     params: {
       // immediate: true,// 第一次立即监听
       handler(value) {
-        this.dayTableData = value.dayTableData
-        this.monthTableData = value.monthTableData
+        this.dayTableData = value.dayRankingList
+        this.monthTableData = value.lastMonthRankingList
 
         if(sessionStorage.getItem('screen-accuracy-type')){
           if (sessionStorage.getItem('screen-accuracy-type').includes('day')){

+ 7 - 9
cpp-ui/src/views/largeScreen/index.vue

@@ -557,12 +557,12 @@ export default {
     },
     async getBizData() {
       // 气象站预测按钮类型
-      let weatherType
-      if(sessionStorage.getItem('screen-weather-type')){
-        weatherType = sessionStorage.getItem('screen-weather-type')
-      }else{
-        weatherType = 'wind'
-      }
+      // let weatherType
+      // if(sessionStorage.getItem('screen-weather-type')){
+      //   weatherType = sessionStorage.getItem('screen-weather-type')
+      // }else{
+      //   weatherType = 'wind'
+      // }
       let forecastDay
       if(sessionStorage.getItem('screen-forecast-day')){
         forecastDay = sessionStorage.getItem('screen-forecast-day')
@@ -576,11 +576,9 @@ export default {
         forecastType = 'wind'
       }
 
-
       let queryParams = {
         "forecastDay": forecastDay,
         "forecastType": forecastType,
-        "forecastType": forecastType,
       }
 
       await this.$axios({url: '/largeScreenController/getBizData', method: 'get',params: queryParams}).then(response => {
@@ -613,7 +611,7 @@ export default {
           timeList: curveMap.timeList,
         }
         // 准确率排名
-        this.rightTopParams = response.data.accuracyMap
+        this.rightTopParams = response.data.accuracyRankingMap