From b8a3f9e0f9b4e8e9ed4fdf0e1ae20c18af774eca Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 Nov 2025 17:19:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A9=E6=B0=94=E5=90=8C=E6=AD=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98bug=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/bootstrap.yml | 2 +- .../controller/WeatherController.java | 26 +++++++------------ 2 files changed, 10 insertions(+), 18 deletions(-) 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); } }