Procházet zdrojové kódy

模型准确率调整及预测发电量折线图改为柱状图

fanxiaoyu před 5 měsíci
rodič
revize
9684ce1c20

+ 33 - 13
cpp-admin/src/main/java/com/cpp/web/service/accuracy/impl/AccuracyPassRateServiceImpl.java

@@ -2,6 +2,8 @@ package com.cpp.web.service.accuracy.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.cpp.common.core.domain.entity.SysDictData;
+import com.cpp.common.utils.DictUtils;
 import com.cpp.system.service.ISysDictDataService;
 import com.cpp.web.domain.accuracy.AccuracyPassRate;
 import com.cpp.web.domain.enums.DataSourcesEnum;
@@ -159,23 +161,36 @@ public class AccuracyPassRateServiceImpl extends ServiceImpl<AccuracyPassRateMap
             });
             sortMap.putAll(averageByCategory);
 
-            for (Map.Entry<String, Double> entry : sortMap.entrySet()) {
+            List<String> modelList =  DictUtils.getDictCache("forecast_model").stream().map(SysDictData::getDictValue).collect(Collectors.toList());
+
+            for (String s : modelList) {
                 Map<String,String> map = new HashMap<>();
                 map.put("station",stationName);
                 map.put("month",new SimpleDateFormat("yyyy-MM").format(new Date(aLong[0])));
-                map.put("preModels",dictDataService.selectDictLabel("forecast_model",entry.getKey())==null?entry.getKey():dictDataService.selectDictLabel("forecast_model",entry.getKey()));
-                map.put("shortAccuracy",BigDecimal.valueOf(entry.getValue()).setScale(2, RoundingMode.HALF_UP).toString());
+                map.put("preModels",dictDataService.selectDictLabel("forecast_model",s));
+                map.put("shortAccuracy",sortMap.get(s) == null? "" : BigDecimal.valueOf(sortMap.get(s)).setScale(2, RoundingMode.HALF_UP).toString());
                 map.put("uploadShortAccuracy",collect.toString());
                 map.put("accuracyRanking",String.valueOf(++count));
                 list.add(map);
             }
+//            for (Map.Entry<String, Double> entry : sortMap.entrySet()) {
+//
+//                map.put("station",stationName);
+//                map.put("month",new SimpleDateFormat("yyyy-MM").format(new Date(aLong[0])));
+//                map.put("preModels",dictDataService.selectDictLabel("forecast_model",entry.getKey())==null?entry.getKey():dictDataService.selectDictLabel("forecast_model",entry.getKey()));
+//                map.put("shortAccuracy",BigDecimal.valueOf(entry.getValue()).setScale(2, RoundingMode.HALF_UP).toString());
+//                map.put("uploadShortAccuracy",collect.toString());
+//                map.put("accuracyRanking",String.valueOf(++count));
+//                list.add(map);
+//            }
 
         }
         return list;
     }
     @Override
     public Map<String,List<Object>> echarts(Long startTime, Long endTime, ForecastTypeEnum forecastType, DataSourcesEnum dataSources, String stationCode,String stationName,String uploadDataSources){
-        List<Map<String, String>> list = finfBySingleMonthBetweenAndForecastTypeAndStationCode(startTime, endTime, forecastType, dataSources, stationCode, stationName, uploadDataSources);
+        // 注释掉无用代码
+//        List<Map<String, String>> list = finfBySingleMonthBetweenAndForecastTypeAndStationCode(startTime, endTime, forecastType, dataSources, stationCode, stationName, uploadDataSources);
         List<long[]> longs = StartAndEndMonthUtil.singleMonth(startTime, endTime);
         List<long[]> longsSix = new ArrayList<>();
         if (longs.size()>=6){
@@ -187,16 +202,21 @@ public class AccuracyPassRateServiceImpl extends ServiceImpl<AccuracyPassRateMap
         }
         List<Map<String, String>> singleMonthList = getSingleMonthList(longsSix, startTime, endTime, forecastType, dataSources, stationCode, stationName, uploadDataSources);
 
-        Map<String, Map<String, Double>> groupedData = new HashMap<>();
+        Map<String, Map<String, Object>> groupedData = new HashMap<>();
         // 根据 preModels 和 month 分组
         for (Map<String, String> data : singleMonthList) {
             String preModels = data.get("preModels");
             String month = data.get("month");
-            double shortAccuracy = Double.parseDouble(data.get("shortAccuracy"));
-
-            groupedData
-                    .computeIfAbsent(preModels, k -> new HashMap<>())
-                    .put(month, shortAccuracy);
+            if (data.get("shortAccuracy") != ""){
+                double shortAccuracy = Double.parseDouble(data.get("shortAccuracy"));
+                groupedData
+                        .computeIfAbsent(preModels, k -> new HashMap<>())
+                        .put(month, shortAccuracy);
+            }else {
+                groupedData
+                        .computeIfAbsent(preModels, k -> new HashMap<>())
+                        .put(month, "");
+            }
         }
 
         // 用于生成 ECharts 数据
@@ -205,18 +225,18 @@ public class AccuracyPassRateServiceImpl extends ServiceImpl<AccuracyPassRateMap
         Collections.sort(preModels);
 
         // 收集所有出现过的月份
-        for (Map<String, Double> monthData : groupedData.values()) {
+        for (Map<String, Object> monthData : groupedData.values()) {
             allMonths.addAll(monthData.keySet());
         }
         List<String> months = new ArrayList<>(allMonths);
 
         // 构建 ECharts xAxis 数据
         List<String> xAxis = preModels;  // xAxis 就是模型名称列表
-        List<List<Double>> seriesData = new ArrayList<>();
+        List<List<Object>> seriesData = new ArrayList<>();
 
         // 为每个 month 构建对应的 shortAccuracy 数据
         for (String month : months) {
-            List<Double> monthData = new ArrayList<>();
+            List<Object> monthData = new ArrayList<>();
             for (String preModel : preModels) {
                 monthData.add(groupedData.get(preModel).getOrDefault(month, 0.0));
             }

+ 1 - 2
cpp-ui/src/views/regulation/modelAccuracyStatistics/index.vue

@@ -285,8 +285,7 @@ export default {
       })
     },
     initChart(xAxis,series) {
-      var chartDom = document.getElementById('masChart');
-      this.chart = echarts.init(chartDom);
+      this.chart = echarts.init(document.getElementById('masChart'), "dark", {renderer: 'svg'})
       this.chart.setOption({
         title: {
           top: 20,

+ 11 - 11
cpp-ui/src/views/statistics/predictedPowerGeneration/index.vue

@@ -181,12 +181,12 @@ export default {
         },
         xAxis: {
           type: 'category',
-          boundaryGap: false,
+          // boundaryGap: false,
           data: times,
-          axisLabel: {
-            formatter: '{value}',
-            hideOverlap: true
-          },
+          // axisLabel: {
+          //   formatter: '{value}',
+          //   hideOverlap: true
+          // },
 
         },
         yAxis: [{
@@ -207,7 +207,7 @@ export default {
         series: [
           {
             name: '站端上传',
-            type: 'line',
+            type: 'bar',
             data: zd,
             lineStyle: {
               normal: {
@@ -216,15 +216,15 @@ export default {
             },
             itemStyle: {
               normal: {
-                color: '#c9daf8',
-                borderColor: 'rgba(50,194,219,0.2)',
+                color: '#ff8200',
+                // borderColor: 'rgba(50,194,219,0.2)',
                 borderWidth: 12
               }
             }
           },
           {
             name: '中心预测',
-            type: 'line',
+            type: 'bar',
             data: yd,
             lineStyle: {
               normal: {
@@ -234,8 +234,8 @@ export default {
             itemStyle: {
               normal: {
 
-                color: '#aef899',
-                borderColor: 'rgba(87,219,50,0.2)',
+                color: '#EE82EE',
+                // borderColor: 'rgba(87,219,50,0.2)',
                 borderWidth: 12
               }
             }