Skip to content

Commit 317dc35

Browse files
committed
#43 BE : [FEAT] 재실인원 판단 API Service 로직 수정
1 parent e52fbd9 commit 317dc35

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

server/src/main/java/org/cecd/server/service/OccupancyService.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,33 @@ public class OccupancyService {
1919
public OccupancyResponse getOccupancyInfo(String location) {
2020
// 현재 시간 및 요일 가져오기
2121
LocalDateTime now = LocalDateTime.now();
22-
String currentDay = now.getDayOfWeek().toString();
23-
LocalTime currentTime = now.toLocalTime();
22+
String currentDay = now.getDayOfWeek().toString(); // 현재 요일 동적으로 설정
23+
LocalTime currentTime = LocalTime.of(now.getHour(), now.getMinute()); // 초 단위 제거
24+
25+
// 로그 추가
26+
System.out.println("Current Time: " + currentTime);
27+
System.out.println("Current Day: " + currentDay);
2428

2529
// 해당 location의 강의 일정 가져오기
2630
List<LectureSchedule> schedules = lectureScheduleRepository.findByLocationAndLectureDay(location, currentDay);
2731

32+
if (schedules.isEmpty()) {
33+
System.out.println("No schedules found for location: " + location + " on day: " + currentDay);
34+
}
35+
2836
// 현재 강의 중인지 확인
2937
boolean isLecturing = schedules.stream()
30-
.anyMatch(schedule -> currentTime.isAfter(LocalTime.parse(schedule.getStartTime()))
31-
&& currentTime.isBefore(LocalTime.parse(schedule.getEndTime())));
38+
.anyMatch(schedule -> {
39+
LocalTime startTime = LocalTime.parse(schedule.getStartTime().trim());
40+
LocalTime endTime = LocalTime.parse(schedule.getEndTime().trim());
41+
42+
// 로그 추가
43+
System.out.println("Schedule Start: " + startTime + ", End: " + endTime);
44+
System.out.println("Is Current Time After Start: " + currentTime.isAfter(startTime));
45+
System.out.println("Is Current Time Before End: " + currentTime.isBefore(endTime));
46+
47+
return currentTime.isAfter(startTime) && currentTime.isBefore(endTime);
48+
});
3249

3350
// 상태 계산
3451
boolean occupancyStatus = !isLecturing;

0 commit comments

Comments
 (0)