| | |
| | | ks.put("cityCode", 320583); |
| | | ks.put("cityId", 101190404); |
| | | cityList.add(ks); |
| | | int count = 0; |
| | | Map<String, Object> hq = new HashMap<>(); |
| | | hq.put("cityCode", 320505); |
| | | hq.put("cityId", 101190406); |
| | | cityList.add(hq); |
| | | int state = 200; |
| | | for (Map<String, Object> map : cityList) { |
| | | String cityCode = map.get("cityCode").toString(); |
| | | 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) { |
| | | return count; |
| | | if (!dataMap.get("code").equals("200")) { |
| | | return 500; |
| | | } |
| | | String json = JSONObject.toJSONString(dataMap); |
| | | dataMap = (Map<String, Object>) JSONObject.parse(json); |
| | |
| | | parameters.put("end", c.getTime()); |
| | | parameters.put("cityCode", cityCode); |
| | | weatherMapper.deleteByTime(parameters); |
| | | count = count + weatherMapper.insertForecastWeather(resultList); |
| | | weatherMapper.insertForecastWeather(resultList); |
| | | } |
| | | return count; |
| | | return state; |
| | | } |
| | | |
| | | private List<Map<String, Object>> getSample(Map<String, Object> params, List<Integer> years) { |
| | |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | c.setTime(new Date()); |
| | | Date endTime = sdf.parse(sdf.format(c.getTime())); |
| | | c.add(Calendar.MONTH, -2); |
| | | c.add(Calendar.MONTH, -1); |
| | | Date startTime = sdf.parse(sdf.format(c.getTime())); |
| | | int count = 0; |
| | | int state = 200; |
| | | List<Map<String, Object>> cityList = weatherMapper.getCityWeatherConfig(); |
| | | for (Map<String, Object> map : cityList) { |
| | | 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) { |
| | | return count; |
| | | if (!dataMap.get("code").equals("200")) { |
| | | return 500; |
| | | } |
| | | String json = JSONObject.toJSONString(dataMap); |
| | | dataMap = (Map<String, Object>) JSONObject.parse(json); |
| | |
| | | sum2 = sum2 + temp * temp; |
| | | } |
| | | //光照 |
| | | double cloud = Double.valueOf(listMap.get("cloud").toString().replace("\"", "").split("\\.")[0]); |
| | | if (listMap.get("beam") != null) { |
| | | if (listMap.get("beam") != null&&listMap.get("cloud") != null) { |
| | | double cloud = Double.valueOf(listMap.get("cloud").toString().replace("\"", "").split("\\.")[0]); |
| | | double beam = Double.valueOf(listMap.get("beam").toString().replace("\"", "").split("\\.")[0]); |
| | | cloudSum = cloudSum + cloud; |
| | | beamSum = beamSum + beam; |
| | |
| | | parameters.put("end", end); |
| | | parameters.put("cityCode", cityCode); |
| | | weatherMapper.deleteByTime(parameters); |
| | | count = count + weatherMapper.insertForecastWeather(resultList); |
| | | weatherMapper.insertForecastWeather(resultList); |
| | | } |
| | | return count; |
| | | return state; |
| | | } |
| | | |
| | | @Override |
| | |
| | | Date now = sdf1.parse(sdf.format(c.getTime()) + ":00:00"); |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | List<Map<String, Object>> cityList = weatherMapper.getCityWeatherConfig(); |
| | | int count = 0; |
| | | int state = 200; |
| | | for (Map<String, Object> map : cityList) { |
| | | String id = map.get("cityId").toString(); |
| | | Map<String, Object> dataMap = restTemplate.getForObject("https://api.heweather.net/v7/weather/now?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, id); |
| | | if (dataMap == null) { |
| | | return count; |
| | | if (!dataMap.get("code").equals("200")) { |
| | | return 500; |
| | | } |
| | | String json = JSONObject.toJSONString(dataMap); |
| | | dataMap = (Map<String, Object>) JSONObject.parse(json); |
| | |
| | | resultList.add(resultMap); |
| | | } |
| | | weatherMapper.deleteRealWeather(sdf1.format(now)); |
| | | return weatherMapper.insertRealWeather(resultList); |
| | | weatherMapper.insertRealWeather(resultList); |
| | | return state; |
| | | } |
| | | |
| | | private int getWindScale(Double windSpeed) { |