天气同步问题bug处理
This commit is contained in:
@ -79,7 +79,7 @@ inverter:
|
||||
largeScreen:
|
||||
#收益系数
|
||||
income: 0.6
|
||||
weatherCode: 510105
|
||||
weatherCode: 510117
|
||||
|
||||
#线上环境redis密码
|
||||
openRedis:
|
||||
|
||||
@ -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());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user