| | |
| | | QueryWrapper<CityConfigWeather> wrapper = new QueryWrapper<>(); |
| | | wrapper.select("city_code", "location_id").eq("is_delete", Constants.NOT_DELETE); |
| | | List<CityConfigWeather> list = cityConfigWeatherService.list(wrapper); |
| | | CityWeather cityWeather = new CityWeather(); |
| | | for (CityConfigWeather cityConfigWeather : list) { |
| | | Integer cityCode = cityConfigWeather.getCityCode(); |
| | | Integer locationId = cityConfigWeather.getLocationId(); |
| | | Map<String, Object> data = restTemplate.getForObject("https://api.qweather.com/v7/weather/now?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, locationId); |
| | | Map<String, Object> now = (Map<String, Object>) data.get("now"); |
| | | CityWeather cityWeather = new CityWeather(); |
| | | cityWeather.setCityCode(cityCode); |
| | | //风速km/h->m/s |
| | | double windSpeed = Double.parseDouble(now.get("windSpeed").toString()); |