|
@@ -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));
|
|
|
}
|