diff --git a/business-service/src/main/resources/bootstrap.yml b/business-service/src/main/resources/bootstrap.yml index f89393a..a5f5d89 100644 --- a/business-service/src/main/resources/bootstrap.yml +++ b/business-service/src/main/resources/bootstrap.yml @@ -79,7 +79,7 @@ inverter: largeScreen: #收益系数 income: 0.6 - weatherCode: 510105 + weatherCode: 510117 #线上环境redis密码 openRedis: diff --git a/file-center/src/main/java/com/ho/filecenter/controller/WeatherController.java b/file-center/src/main/java/com/ho/filecenter/controller/WeatherController.java index a9e1707..dd41503 100644 --- a/file-center/src/main/java/com/ho/filecenter/controller/WeatherController.java +++ b/file-center/src/main/java/com/ho/filecenter/controller/WeatherController.java @@ -203,7 +203,7 @@ public class WeatherController { //每天的站级天气信息 @PostMapping("jobStationWeathers") @TokenIgnore - public DataResult jobStationWeathers() { + public DataResult jobStationWeathers() throws InterruptedException { log.info("jobStationWeathers ,start"); //先查所有电站 DataResult> listDataResult = businessFeignClient.selectAllStation(); @@ -213,23 +213,9 @@ public class WeatherController { } List stations = listDataResult.getData(); if (!stations.isEmpty()) { - //得到不重复的电站 -// List stationList = weatherStationService.dealStation(stations); - //生成按省市为key的缓存 long updateTime = System.currentTimeMillis(); Map map = new HashMap<>(); for (Station station : stations) { - //循环调用 -// String pinyin = PinyinUtil.getPinyin(station.getAddress()); -// log.info("pinyin:" + pinyin); -// String longitude = String.valueOf(station.getLongitude()); -// String latitude = String.valueOf(station.getLatitude()); -// WeatherRespVo weather = weatherService.getWeatherFromApi(longitude, latitude); -// weather.setUpdateTime(updateTime); -// weather.setCityzh(station.getName()); -// // -// String key = "weatherProvinceCity:" + pinyin; -// redisService.set(key,weather ); String adCode = station.getAdCode(); if (null == adCode) { MyAddress address = AddressUntils.getAddress(String.valueOf(station.getLatitude()),String.valueOf(station.getLongitude())); @@ -241,9 +227,15 @@ public class WeatherController { continue; } String key = RedisKeyConstant.WEATHER_PROVINCE_CITY + adCode; + Thread.sleep(200); WeatherRespVo weatherRespVo = WeatherUntils.getWeatherRespVo(station.getAdCode()); - weatherRespVo.setUpdateTime(updateTime); - redisService.set(key, weatherRespVo); + if(weatherRespVo!=null){ + weatherRespVo.setUpdateTime(updateTime); + redisService.set(key, weatherRespVo); + log.info("更新天气站点名称:{},weatherRespVo:{}",station.getName(),weatherRespVo); + }else{ + log.info("报错的站id:{},报错的adCode:{}",station.getId(),adCode); + } map.put(adCode, adCode); } }