From 64b5e5e5675b34886bc70e48cfb4827c3f1032e7 Mon Sep 17 00:00:00 2001 From: wenfei Date: Fri, 13 Jun 2025 19:38:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=99=A8=E5=91=A8=E6=9C=9F?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E7=94=B1=E6=AF=8F30=E5=88=86?= =?UTF-8?q?=E9=92=9F=E8=B0=83=E4=B8=80=E6=AC=A1=E6=94=B9=E6=88=90=E6=AF=8F?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E8=B0=83=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 20240922/weather/pom.xml | 16 ++++++++++++++-- .../rehome/weather/service/ScheduledService.java | 4 ++-- .../weather/service/impl/StormServiceImpl.java | 4 ---- .../weather/service/impl/WeatherServiceImpl.java | 4 ++-- .../weather/src/main/resources/application.yml | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/20240922/weather/pom.xml b/20240922/weather/pom.xml index 3b7c3c4..20065c6 100644 --- a/20240922/weather/pom.xml +++ b/20240922/weather/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.4.5 + 2.5.3 com.rehome @@ -109,7 +109,19 @@ 11.2.0.jre8 - + + + + repository + http://47.242.184.139:8081/repository/maven-public/ + + true + + + true + + + diff --git a/20240922/weather/src/main/java/com/rehome/weather/service/ScheduledService.java b/20240922/weather/src/main/java/com/rehome/weather/service/ScheduledService.java index 43bed60..c63f873 100644 --- a/20240922/weather/src/main/java/com/rehome/weather/service/ScheduledService.java +++ b/20240922/weather/src/main/java/com/rehome/weather/service/ScheduledService.java @@ -36,9 +36,9 @@ public class ScheduledService { * @description: 定时任务,每30分钟执行一次,从聚合数据平台查询天气数据并入库 * @Param: null */ - //@Scheduled(cron = "0 0 */1 * * *")//每个小时执行一次 + @Scheduled(cron = "0 0 */1 * * *")//每个小时执行一次 //@Scheduled(cron = "0/10 * * * * *")//每10秒执行一次 - @Scheduled(cron = "0 */30 * * * *") //每30分钟执行一次 + //@Scheduled(cron = "0 */30 * * * *") //每30分钟执行一次 public void scheduled(){ log.info("scheduled"); log.info("=====>>>>>使用cron:"+String.valueOf(System.currentTimeMillis())); diff --git a/20240922/weather/src/main/java/com/rehome/weather/service/impl/StormServiceImpl.java b/20240922/weather/src/main/java/com/rehome/weather/service/impl/StormServiceImpl.java index 2217838..0b26998 100644 --- a/20240922/weather/src/main/java/com/rehome/weather/service/impl/StormServiceImpl.java +++ b/20240922/weather/src/main/java/com/rehome/weather/service/impl/StormServiceImpl.java @@ -74,7 +74,6 @@ public class StormServiceImpl implements StormService { * Created DateTime 2021-05-08 17:29 */ @Override - @CacheEvict(cacheNames = "com.rehome.weather.service.impl.StormServiceImpl",allEntries = true) public Map getStormListByScheduled(String year) { String url=stormListUrl+"?key="+heFengStormKey+"&basin=NP&year="+year; @@ -207,7 +206,6 @@ public class StormServiceImpl implements StormService { * Created DateTime 2021-05-10 14:18 */ @Override - @Cacheable(cacheNames="com.rehome.weather.service.impl.StormServiceImpl",key="#year+'-getLocalStormList'") public Map getLocalStormList(String year) { Map map = new HashMap(); Optional> storm=stormDataRepository.findByYear(year); @@ -227,7 +225,6 @@ public class StormServiceImpl implements StormService { * Created DateTime 2021-05-10 14:17 */ @Override - @Cacheable(cacheNames="com.rehome.weather.service.impl.StormServiceImpl",key="#stormid+'-getLocalStormForecastByStormId'") public String getLocalStormForecastByStormId(String stormid) { Optional stormForecast = stormForecastRepository.findByIdOne(stormid); if(stormForecast.isPresent()){ @@ -246,7 +243,6 @@ public class StormServiceImpl implements StormService { * Created DateTime 2021-05-10 14:18 */ @Override - @Cacheable(cacheNames="com.rehome.weather.service.impl.StormServiceImpl",key="#stormid+'-getLocalStormTrackByStormId'") public String getLocalStormTrackByStormId(String stormid) { Optional stormTrack = stormTrackJpaRepository.findByIdOne(stormid); if (stormTrack.isPresent()){ diff --git a/20240922/weather/src/main/java/com/rehome/weather/service/impl/WeatherServiceImpl.java b/20240922/weather/src/main/java/com/rehome/weather/service/impl/WeatherServiceImpl.java index 2487d3c..a150af6 100644 --- a/20240922/weather/src/main/java/com/rehome/weather/service/impl/WeatherServiceImpl.java +++ b/20240922/weather/src/main/java/com/rehome/weather/service/impl/WeatherServiceImpl.java @@ -129,7 +129,6 @@ public class WeatherServiceImpl implements WeatherService { * @Param: cityInput 要查询天气的城市 */ @Override - @CacheEvict(cacheNames="com.rehome.weather.service.impl.WeatherServiceImpl",key="#cityInput+'-getLocalWeatherByCity'") public Map getJuheWeatherByScheduled(String cityInput) { String url=weatherQueryUrl+"?key="+weatherKey+"&city="+city; String weatherJson = WeatherUtil.analysisUrl(url); @@ -175,6 +174,8 @@ public class WeatherServiceImpl implements WeatherService { weatherFutureRepository.save(weatherFuture); }else{ weatherFuture.setUpdatetime(new Date()); + weatherFuture.setCreatetime(weatherFutureDB.get().getCreatetime()); + weatherFuture.setId(weatherFutureDB.get().getId()); weatherFutureRepository.save(weatherFuture); } } @@ -195,7 +196,6 @@ public class WeatherServiceImpl implements WeatherService { * @Param: city 要查询天气的城市 */ @Override - @Cacheable(cacheNames="com.rehome.weather.service.impl.WeatherServiceImpl",key="#city+'-getLocalWeatherByCity'") public Map getLocalWeatherByCity(String cityParam) { Map map = new HashMap(); if(city.equals(cityParam)){ diff --git a/20240922/weather/src/main/resources/application.yml b/20240922/weather/src/main/resources/application.yml index 8f6d260..7e84fa3 100644 --- a/20240922/weather/src/main/resources/application.yml +++ b/20240922/weather/src/main/resources/application.yml @@ -25,9 +25,9 @@ spring: # 文件写入磁盘的阈值 file-size-threshold: 2KB # 最大文件大小 - max-file-size: 200MB + max-file-size: 20MB # 最大请求大小 - max-request-size: 215MB + max-request-size: 20MB rehome: resourcesPath: /Users/wenfeihuang/storage # 外部资源文件存储路径 格式:/Users/edao/storage weather: