|
@@ -70,61 +70,15 @@ public class AccuracyPassRateServiceImpl extends ServiceImpl<AccuracyPassRateMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Double> findByMonthBetweenAndForecastTypeAndStationCode(Long startTime, Long endTime, ForecastTypeEnum forecastType, DataSourcesEnum dataSources,String stationCode) {
|
|
|
-
|
|
|
- QueryWrapper<AccuracyPassRate> wrapper = new QueryWrapper<>();
|
|
|
- if (stationCode != null && !stationCode.equals("")) {
|
|
|
- wrapper.eq("station_code", stationCode);
|
|
|
- }
|
|
|
- if (startTime != null && endTime != null) {
|
|
|
- wrapper.between("time", new Date(StartAndEndMonthUtil.getBeginAndEndMonth(startTime,1)), new Date(StartAndEndMonthUtil.getBeginAndEndMonth(endTime,2)));
|
|
|
- }
|
|
|
- if (forecastType != null && !forecastType.equals("")) {
|
|
|
- wrapper.eq("forecast_type", forecastType);
|
|
|
- }
|
|
|
- if (dataSources != null && !dataSources.equals("")) {
|
|
|
- wrapper.eq("data_sources", dataSources);
|
|
|
- }
|
|
|
- List<AccuracyPassRate> accuracyPassRateList = baseMapper.selectList(wrapper);
|
|
|
-
|
|
|
- Map<String, Double> sortMap = new TreeMap<>();
|
|
|
- if (null != accuracyPassRateList && accuracyPassRateList.size() > 0) {
|
|
|
- accuracyPassRateList = accuracyPassRateList.stream().filter(f -> !"无可用数据计算".equals(f.getAccuracy()) && !"无计算公式".equals(f.getAccuracy())).collect(Collectors.toList());
|
|
|
-
|
|
|
- Function<String, Double> stringToDouble = s -> {
|
|
|
- String numberStr = s.replace("%", "");
|
|
|
- return Double.parseDouble(numberStr);
|
|
|
- };
|
|
|
- Map<String, Double> averageByCategory = accuracyPassRateList.stream()
|
|
|
- .filter(apr -> apr.getForecastModel()!=null)
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- AccuracyPassRate::getForecastModel,
|
|
|
- Collectors.averagingDouble(apr -> stringToDouble.apply(apr.getAccuracy()))
|
|
|
- ));
|
|
|
- Map<String, Double> updatedAverageByCategory = averageByCategory.entrySet().stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- entry->dictDataService.selectDictLabel("forecast_model",entry.getKey())==null?entry.getKey():dictDataService.selectDictLabel("forecast_model",entry.getKey()),
|
|
|
- entry->entry.getValue()
|
|
|
- ));
|
|
|
- sortMap = new TreeMap<>(new Comparator<String>() {
|
|
|
- @Override
|
|
|
- public int compare(String o1, String o2) {
|
|
|
- return updatedAverageByCategory.get(o2).compareTo(updatedAverageByCategory.get(o1));
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- sortMap.putAll(updatedAverageByCategory);
|
|
|
-
|
|
|
- }
|
|
|
- return sortMap;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public List<Map<String,String>> finfBySingleMonthBetweenAndForecastTypeAndStationCode(Long startTime, Long endTime, ForecastTypeEnum forecastType, DataSourcesEnum dataSources, String stationCode,String stationName,String uploadDataSources) {
|
|
|
- List<Map<String,String>> list = new ArrayList<>();
|
|
|
List<long[]> longs = StartAndEndMonthUtil.singleMonth(startTime, endTime);
|
|
|
Collections.reverse(longs);
|
|
|
+ List<Map<String, String>> singleMonthList = getSingleMonthList(longs, startTime, endTime, forecastType, dataSources, stationCode, stationName, uploadDataSources);
|
|
|
+ return singleMonthList;
|
|
|
+ }
|
|
|
|
|
|
+ public List<Map<String,String>> getSingleMonthList(List<long[]> longs,Long startTime, Long endTime,ForecastTypeEnum forecastType, DataSourcesEnum dataSources,String stationCode,String stationName,String uploadDataSources){
|
|
|
+ List<Map<String,String>> list = new ArrayList<>();
|
|
|
for (long[] aLong : longs) {
|
|
|
QueryWrapper<AccuracyPassRate> wrapper = new QueryWrapper<>();
|
|
|
QueryWrapper<AccuracyPassRate> wrapper2 = new QueryWrapper<>();
|
|
@@ -192,4 +146,76 @@ public class AccuracyPassRateServiceImpl extends ServiceImpl<AccuracyPassRateMap
|
|
|
}
|
|
|
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<long[]> longs = StartAndEndMonthUtil.singleMonth(startTime, endTime);
|
|
|
+ List<long[]> longsSix = new ArrayList<>();
|
|
|
+ if (longs.size()>=6){
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
+ longsSix.add(longs.get(i));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ longsSix = longs;
|
|
|
+ }
|
|
|
+ List<Map<String, String>> singleMonthList = getSingleMonthList(longsSix, startTime, endTime, forecastType, dataSources, stationCode, stationName, uploadDataSources);
|
|
|
+
|
|
|
+ Map<String, Map<String, Double>> 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 用于生成 ECharts 数据
|
|
|
+ Set<String> allMonths = new TreeSet<>();
|
|
|
+ List<String> preModels = new ArrayList<>(groupedData.keySet());
|
|
|
+ Collections.sort(preModels);
|
|
|
+
|
|
|
+ // 收集所有出现过的月份
|
|
|
+ for (Map<String, Double> 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<>();
|
|
|
+
|
|
|
+ // 为每个 month 构建对应的 shortAccuracy 数据
|
|
|
+ for (String month : months) {
|
|
|
+ List<Double> monthData = new ArrayList<>();
|
|
|
+ for (String preModel : preModels) {
|
|
|
+ monthData.add(groupedData.get(preModel).getOrDefault(month, 0.0));
|
|
|
+ }
|
|
|
+ seriesData.add(monthData);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> result = new TreeMap<>();
|
|
|
+
|
|
|
+
|
|
|
+ for (Map<String, String> entry : singleMonthList) {
|
|
|
+ String month = entry.get("month");
|
|
|
+ String uploadShortAccuracy = entry.get("uploadShortAccuracy");
|
|
|
+ result.put(month, uploadShortAccuracy);
|
|
|
+ }
|
|
|
+ List<String> uploadShortAccuracyList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map.Entry<String, String> entry : result.entrySet()) {
|
|
|
+ uploadShortAccuracyList.add(entry.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,List<Object>> endMap = new HashMap<>();
|
|
|
+
|
|
|
+ endMap.put("uploadShortAccuracyList", Collections.singletonList(uploadShortAccuracyList));
|
|
|
+ endMap.put("xAxis", Collections.singletonList(xAxis));
|
|
|
+ endMap.put("seriesData", Collections.singletonList(seriesData));
|
|
|
+ endMap.put("monthData", Collections.singletonList(months));
|
|
|
+ return endMap;
|
|
|
+ }
|
|
|
}
|