diff --git a/src/main/java/com/waither/domain/weather/scheduler/SchedulerConfig.java b/src/main/java/com/waither/domain/weather/scheduler/SchedulerConfig.java deleted file mode 100644 index 0c0ee21..0000000 --- a/src/main/java/com/waither/domain/weather/scheduler/SchedulerConfig.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.waither.domain.weather.scheduler;// package com.waither.weatherservice.scheduler; -// -// import java.net.URISyntaxException; -// import java.time.LocalDateTime; -// import java.util.List; -// -// import org.springframework.boot.context.properties.ConfigurationProperties; -// import org.springframework.scheduling.annotation.Scheduled; -// -// import com.waither.weatherservice.entity.Region; -// import com.waither.weatherservice.exception.WeatherExceptionHandler; -// import com.waither.weatherservice.response.WeatherErrorCode; -// import com.waither.weatherservice.service.WeatherService; -// -// import lombok.RequiredArgsConstructor; -// import lombok.extern.slf4j.Slf4j; -// -// @Slf4j -// @RequiredArgsConstructor -// @ConfigurationProperties -// public class SchedulerConfig { -// -// private final WeatherService weatherService; -// -// @Scheduled(cron = "0 0 2,5,8,11,14,17,20,23 * * *") // 3시간 마다 -// public void createDailyWeather() { -// -// LocalDateTime now = LocalDateTime.now(); -// String[] dateTime = weatherService.convertLocalDateTimeToString(now).split("_"); -// List regionList = weatherService.getRegionList(); -// regionList.stream() -// .forEach(region -> { -// try { -// weatherService.createDailyWeather(region.getStartX(), region.getStartY(), dateTime[0], -// dateTime[1]); -// } catch (URISyntaxException e) { -// throw new WeatherExceptionHandler(WeatherErrorCode.WEATHER_URI_ERROR); -// } -// }); -// } -// -// @Scheduled(cron = "0 0 * * * *") // 1시간 마다 -// public void createExpectedWeather() { -// -// LocalDateTime now = LocalDateTime.now(); -// String[] dateTime = weatherService.convertLocalDateTimeToString(now).split("_"); -// List regionList = weatherService.getRegionList(); -// regionList.stream() -// .forEach(region -> { -// try { -// weatherService.createExpectedWeather(region.getStartX(), region.getStartY(), dateTime[0], -// dateTime[1]); -// } catch (URISyntaxException e) { -// throw new WeatherExceptionHandler(WeatherErrorCode.WEATHER_URI_ERROR); -// } -// }); -// } -// } diff --git a/src/main/java/com/waither/domain/weather/service/WeatherService.java b/src/main/java/com/waither/domain/weather/service/WeatherService.java index 3b38320..3f16d27 100644 --- a/src/main/java/com/waither/domain/weather/service/WeatherService.java +++ b/src/main/java/com/waither/domain/weather/service/WeatherService.java @@ -169,16 +169,18 @@ public MainWeatherResponse getMainWeather(double latitude, double longitude) { String expectedWeatherKey = regionName + "_" + convertLocalDateTimeToString(now); - LocalDateTime dailyWeatherBaseTime = convertLocalDateTimeToDailyWeatherTime(now.minusHours(1)); - String dailyWeatherKey = regionName + "_" + convertLocalDateTimeToString(dailyWeatherBaseTime); + LocalDateTime dailyWeatherBaseTime = convertLocalDateTimeToDailyWeatherTime(now); + String dailyWeatherKey = regionName + "_" + convertLocalDateTimeToString(dailyWeatherBaseTime.plusHours(1)); log.info("[Main - api] dailyWeatherKey : {}", dailyWeatherKey); log.info("[Main - api] expectedWeatherKey : {}", expectedWeatherKey); DailyWeather dailyWeather = dailyWeatherRepository.findById(dailyWeatherKey) .orElseGet(() -> { + log.info("[Main - api] Daily Weather Error"); try { - String[] baseTime = convertLocalDateTimeToString(now.minusHours(2)).split("_"); + LocalDateTime dailyTime = convertLocalDateTimeToDailyWeatherTime(now); + String[] baseTime = convertLocalDateTimeToString(dailyTime).split("_"); createDailyWeather(region.getStartX(), region.getStartY(), baseTime[0], baseTime[1]); } catch (URISyntaxException e) { throw new CustomException(WeatherErrorCode.WEATHER_URI_ERROR); @@ -191,6 +193,7 @@ public MainWeatherResponse getMainWeather(double latitude, double longitude) { ExpectedWeather expectedWeather = expectedWeatherRepository.findById(expectedWeatherKey) .orElseGet(() -> { + log.info("[Main - api] Expected Weather Error"); try { String[] baseTime = convertLocalDateTimeToString(now.minusHours(1)).split("_"); createExpectedWeather(region.getStartX(), region.getStartY(), baseTime[0], baseTime[1]); @@ -232,13 +235,13 @@ public String convertLocalDateTimeToString(LocalDateTime time) { public LocalDateTime convertLocalDateTimeToDailyWeatherTime(LocalDateTime time) { // DailyWeather 정보는 3시간마다 - List scheduledHours = Arrays.asList(0, 3, 6, 9, 12, 15, 18, 21); + List scheduledHours = Arrays.asList(2, 5, 8, 11, 14, 17, 20, 23); int currentHour = time.getHour(); int adjustedHour = scheduledHours.stream() .filter(hour -> hour <= currentHour) .reduce((first, second) -> second) - .orElse(scheduledHours.get(scheduledHours.size() - 1)); // 이전 날의 마지막 스케줄 시간(21시) 반환 + .orElse(scheduledHours.get(scheduledHours.size() - 1)); // 현재 시간이 첫 스케줄 시간(0시)보다 작을 경우, 전날의 마지막 스케줄 시간으로 설정 if (currentHour < scheduledHours.get(0)) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml deleted file mode 100644 index e1558a4..0000000 --- a/src/main/resources/application.yml +++ /dev/null @@ -1,61 +0,0 @@ -spring: - datasource: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://waither.cbykekky6x7m.ap-northeast-2.rds.amazonaws.com:3306/waither - username: admin - password: waither1! - - jpa: - show-sql: true - hibernate: - ddl-auto: update - properties: - hibernate: - dialect: org.hibernate.dialect.MySQL8Dialect - show_sql: true - - data: - redis: - host: localhost - port: 6379 - - batch: - job: - enabled: false - jdbc: - initialize-schema: always - - jwt: - # HS512 알고리즘을 사용할 것이기 때문에 512bit, 즉 64byte 이상의 secret key를 사용 - secret: testSecretKey20240316testSecretKey20240316testSecretKey20240316 - token: - access-expiration-time: 3600000 - refresh-expiration-time: 86400000 - - mail: - host: smtp.gmail.com - port: 587 - username: com.waither - password: blxbcxruddrkhpkn - properties: - mail: - smtp: - auth: true - starttls: - enable: true - required: true - connectiontimeout: 5000 - timeout: 5000 - writetimeout: 5000 - auth-code-expiration-millis: 1800000 # 30 * 60 * 1000 == 30분 - -kakao: - client_id: d123b0e487f515ba55f26453d6537fbc - redirect_uri: https://waither.shop/user/oauth/kakao/callback - -openapi: - forecast: - key: KQHOaZw02PSjk%2FsWvznYk0E1sTqn19fLdSywrASSpgFVYRaM9SqL1fyM8%2B7L6LVzpUPpvAIk5NN9xOaZTeiAlQ%3D%3D - accuweather: - # key: r4lWv3DVT9NAScxKCx7e7ffQEhIOkSVU - key: 7PlDuTHKKxQz4rEBOFqbQPibcRvVu1aa \ No newline at end of file