cjl
2023-07-26 0ce061d9ed37a6c25fff70e4734fa8cc8747237c
screen-job/src/main/java/com/moral/api/service/impl/ForecastServiceImpl.java
@@ -57,7 +57,7 @@
    private CityAqiService cityAqiService;
    @Autowired
    private ForecastService forecastService;
    private ForecastMapper forecastMapper;
    private static final Map<String, Integer> weatherScore = new HashMap<>();
@@ -129,12 +129,11 @@
        //获取前后一小时map
        Map<Date, List<Integer>> hours = DateUtils.getBeforeAndAfterHourDate(nextDay);
        Forecast forecast = new Forecast();
        List<Forecast> forecastList = new ArrayList<>();
        Map<String, Object> forecastMap = new HashMap<>();
        for (Object obj : cityCodes) {
            Integer cityCode = Integer.parseInt(obj.toString());
            forecast.setCityCode(cityCode);
            //预测
            List<CityWeatherForecast> cityWeatherForecasts = cityForecast.get(cityCode);
@@ -170,6 +169,8 @@
            }
            for (CityWeatherForecast cityWeatherForecast : cityWeatherForecasts) {
                Forecast forecast = new Forecast();
                forecast.setCityCode(cityCode);
                Date time = cityWeatherForecast.getTime();
                Map<String, Object> value = JSONObject.parseObject(cityWeatherForecast.getValue(), Map.class);
                String weather = value.get("text").toString();
@@ -205,11 +206,11 @@
                if (!Double.isNaN(o3Forecast)) {
                    forecastMap.put("O3", AmendUtils.sciCal(o3Forecast, 0));
                    forecast.setValue(JSONObject.toJSONString(forecastMap));
                    forecastService.save(forecast);
                    forecastList.add(forecast);
                }
            }
        }
        forecastMapper.insertForecast(forecastList);
    }
    private Double calculateAvg(List<Map<String, Object>> list, String param) {