天气同步问题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:
#收益系数
income: 0.6
weatherCode: 510105
weatherCode: 510117
#线上环境redis密码
openRedis:

View File

@ -203,7 +203,7 @@ public class WeatherController {
//每天的站级天气信息
@PostMapping("jobStationWeathers")
@TokenIgnore
public DataResult jobStationWeathers() {
public DataResult jobStationWeathers() throws InterruptedException {
log.info("jobStationWeathers ,start");
//先查所有电站
DataResult<List<Station>> listDataResult = businessFeignClient.selectAllStation();
@ -213,23 +213,9 @@ public class WeatherController {
}
List<Station> stations = listDataResult.getData();
if (!stations.isEmpty()) {
//得到不重复的电站
// List<Station> stationList = weatherStationService.dealStation(stations);
//生成按省市为key的缓存
long updateTime = System.currentTimeMillis();
Map<String, String> 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());
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);
}
}