From 46e3c1095472bc990da1736a3bb66727bf1fdfa5 Mon Sep 17 00:00:00 2001 From: PSH Date: Sun, 25 Aug 2024 01:30:16 +0900 Subject: [PATCH] =?UTF-8?q?3=EC=8B=9C=20=EA=B8=B0=EC=A4=80=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9A=94=EC=9D=BC=20=EB=B3=80=EA=B2=BD=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/bus/service/BusStatService.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/com/talkka/server/bus/service/BusStatService.java b/server/src/main/java/com/talkka/server/bus/service/BusStatService.java index 5ed74e92..a61834cf 100644 --- a/server/src/main/java/com/talkka/server/bus/service/BusStatService.java +++ b/server/src/main/java/com/talkka/server/bus/service/BusStatService.java @@ -45,14 +45,12 @@ public List getBusStat(BusStatReqDto busStatReqDto) { public List getBusStatNow(Long routeId, Long stationId) { LocalDateTime now = LocalDateTime.now(); - int startTime = getTime(now.minusMinutes(30)); - int endTime = getTime(now.plusMinutes(30)); return busStatRepository.findByRouteIdAndStationIdAndDayOfWeekBetweenNow( routeId, stationId, - now.getDayOfWeek().getValue(), - startTime, - endTime + getDayOfWeek(now), + getTime(now.minusMinutes(30)), + getTime(now.plusMinutes(30)) ).stream() .map(BusStatRespDto::of) .toList(); @@ -115,7 +113,7 @@ private static BusStatEntity toBusStatEntity(BusLocationEntity before, BusLocati .afterTime(after.getCreatedAt()) .plateNo(after.getPlateNo()) .plateType(after.getPlateType()) - .dayOfWeek(before.getCreatedAt().getDayOfWeek().getValue()) + .dayOfWeek(getDayOfWeek(before.getCreatedAt())) .time(getTime(before.getCreatedAt())) .build(); } @@ -125,6 +123,13 @@ private static int getTime(LocalDateTime localDateTime) { return localDateTime.getHour() * 100 + localDateTime.getMinute(); } + private static int getDayOfWeek(LocalDateTime localDateTime) { + if (localDateTime.getHour() < 3) { + return localDateTime.getDayOfWeek().getValue() - 1; + } + return localDateTime.getDayOfWeek().getValue(); + } + // old logic // @Deprecated // @Transactional