|
@@ -143,6 +143,7 @@ public class WeatherInfoServiceImpl extends ServiceImpl<WeatherInfoMapper, Weath
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ System.out.println("同步当天天气完成");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -253,6 +254,7 @@ public class WeatherInfoServiceImpl extends ServiceImpl<WeatherInfoMapper, Weath
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ System.out.println("完成");
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -335,21 +337,20 @@ public class WeatherInfoServiceImpl extends ServiceImpl<WeatherInfoMapper, Weath
|
|
Map<String, String> day = weatherMap.get(date.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
|
|
Map<String, String> day = weatherMap.get(date.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
|
|
if (day == null || day.size() == 0){
|
|
if (day == null || day.size() == 0){
|
|
log.info("从整月天气中获取当天失败:" + area.getCity()+"-"+area.getCounty() + ",syncTime:" + date);
|
|
log.info("从整月天气中获取当天失败:" + area.getCity()+"-"+area.getCounty() + ",syncTime:" + date);
|
|
|
|
+ }else {
|
|
|
|
+ //计算平均气温
|
|
|
|
+ BigDecimal aver = (new BigDecimal(day.get("high")).add(new BigDecimal(day.get("low")))).divide(new BigDecimal("2"), 1, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ WeatherInfo newWeather = new WeatherInfo(String.valueOf(area.getId()), day.get("weather"), aver.toString(), day.get("high"), day.get("low"), day.get("windLevel"));
|
|
|
|
+ newWeather.setRecordTime(Date.from(date.atStartOfDay().atZone(zone).toInstant()));
|
|
|
|
+ list.add(newWeather);
|
|
}
|
|
}
|
|
- //计算平均气温
|
|
|
|
- BigDecimal aver = (new BigDecimal(day.get("high")).add(new BigDecimal(day.get("low")))).divide(new BigDecimal("2"), 1, BigDecimal.ROUND_HALF_UP);
|
|
|
|
- WeatherInfo newWeather = new WeatherInfo(String.valueOf(area.getId()), day.get("weather"), aver.toString(), day.get("high"), day.get("low"), day.get("windLevel"));
|
|
|
|
- newWeather.setRecordTime(Date.from(date.atStartOfDay().atZone(zone).toInstant()));
|
|
|
|
- list.add(newWeather);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
//保存进天气表
|
|
//保存进天气表
|
|
this.saveBatch(list);
|
|
this.saveBatch(list);
|
|
}
|
|
}
|
|
-
|
|
|
|
System.out.println("同步天气完成");
|
|
System.out.println("同步天气完成");
|
|
-
|
|
|
|
}
|
|
}
|
|
//测试循环
|
|
//测试循环
|
|
public void test7(){
|
|
public void test7(){
|