jinpengyong
2020-08-03 a6f582f020df0c244024f8705fb44bc8621e7bee
src/main/java/com/moral/service/impl/ForecastWeatherServiceImpl.java
@@ -50,7 +50,7 @@
    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");
@@ -123,11 +123,13 @@
            }
        }
        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);
@@ -177,7 +179,8 @@
                jsonMap.remove("fxTime");
                map.put("json", JSONObject.toJSONString(jsonMap));
            }
            forecastWeatherMapper.insertForecastWeather(arrayList);
            count = count+forecastWeatherMapper.insertForecastWeather(arrayList);
        }
        return count;
    }
}