| | |
| | | private ProvinceMapper provinceMapper; |
| | | |
| | | @Override |
| | | public void insertForecastWeather() throws ParseException { |
| | | public int insertForecastWeather() throws ParseException { |
| | | Calendar c = Calendar.getInstance(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | } |
| | | } |
| | | |
| | | int count=0; |
| | | |
| | | for (Map<String, Object> map : hashSet) { |
| | | String id = map.get("cityID").toString(); |
| | | Map<String, Object> dataMap = restTemplate.getForObject("https://api.heweather.net/v7/weather/72h?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, id); |
| | | if (dataMap == null) { |
| | | dataMap = new HashMap<>(); |
| | | return count; |
| | | } |
| | | String json = JSONObject.toJSONString(dataMap); |
| | | dataMap = (Map<String, Object>) JSONObject.parse(json); |
| | |
| | | jsonMap.remove("fxTime"); |
| | | map.put("json", JSONObject.toJSONString(jsonMap)); |
| | | } |
| | | forecastWeatherMapper.insertForecastWeather(arrayList); |
| | | count = count+forecastWeatherMapper.insertForecastWeather(arrayList); |
| | | } |
| | | return count; |
| | | } |
| | | } |