天气同步问题bug处理

This commit is contained in:
2025-11-20 17:19:14 +08:00
parent 855967d083
commit b8a3f9e0f9
2 changed files with 10 additions and 18 deletions

View File

@ -79,7 +79,7 @@ inverter:
largeScreen: largeScreen:
#收益系数 #收益系数
income: 0.6 income: 0.6
weatherCode: 510105 weatherCode: 510117
#线上环境redis密码 #线上环境redis密码
openRedis: openRedis:

View File

@ -203,7 +203,7 @@ public class WeatherController {
//每天的站级天气信息 //每天的站级天气信息
@PostMapping("jobStationWeathers") @PostMapping("jobStationWeathers")
@TokenIgnore @TokenIgnore
public DataResult jobStationWeathers() { public DataResult jobStationWeathers() throws InterruptedException {
log.info("jobStationWeathers ,start"); log.info("jobStationWeathers ,start");
//先查所有电站 //先查所有电站
DataResult<List<Station>> listDataResult = businessFeignClient.selectAllStation(); DataResult<List<Station>> listDataResult = businessFeignClient.selectAllStation();
@ -213,23 +213,9 @@ public class WeatherController {
} }
List<Station> stations = listDataResult.getData(); List<Station> stations = listDataResult.getData();
if (!stations.isEmpty()) { if (!stations.isEmpty()) {
//得到不重复的电站
// List<Station> stationList = weatherStationService.dealStation(stations);
//生成按省市为key的缓存
long updateTime = System.currentTimeMillis(); long updateTime = System.currentTimeMillis();
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
for (Station station : stations) { 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(); String adCode = station.getAdCode();
if (null == adCode) { if (null == adCode) {
MyAddress address = AddressUntils.getAddress(String.valueOf(station.getLatitude()),String.valueOf(station.getLongitude())); MyAddress address = AddressUntils.getAddress(String.valueOf(station.getLatitude()),String.valueOf(station.getLongitude()));
@ -241,9 +227,15 @@ public class WeatherController {
continue; continue;
} }
String key = RedisKeyConstant.WEATHER_PROVINCE_CITY + adCode; String key = RedisKeyConstant.WEATHER_PROVINCE_CITY + adCode;
Thread.sleep(200);
WeatherRespVo weatherRespVo = WeatherUntils.getWeatherRespVo(station.getAdCode()); WeatherRespVo weatherRespVo = WeatherUntils.getWeatherRespVo(station.getAdCode());
weatherRespVo.setUpdateTime(updateTime); if(weatherRespVo!=null){
redisService.set(key, weatherRespVo); 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); map.put(adCode, adCode);
} }
} }