Skip to content

Commit

Permalink
[fix]
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyeon330 committed Sep 14, 2023
1 parent f7896e9 commit f5dce9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ public ResponseEntity<Long> calender(@PathVariable(name = "year") final Long yea

if (conferenceCheckDay != null)
result = conferenceCheckDay.getDays();
if (conferenceRoomService.isTodayFull())
if (conferenceRoomService.isTodayFull()) {
log.info("isTodayFull 들어오나?");
result |= 1L << LocalDate.now().getDayOfMonth() - 1;
}
log.info("dayBit==> " + result);
return ResponseEntity.ok().body(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,20 @@ public ConferenceRoom findOne(Long id) {
}

public boolean isTodayFull() {
LocalDateTime now = LocalDateTime.now();
int nowTimeIdx = ConferenceUtil.getTimeIdx(now);
int nowTimeIdx = ConferenceUtil.getTimeIdx();
long afterNowBit = ConferenceUtil.getAfterTimeBit(nowTimeIdx);
int todayLeftTimeCnt = 0;

RoomCount[] roomCounts = RoomCount.values();
for (RoomCount roomCount : roomCounts) {
todayLeftTimeCnt += roomCount.getValue().intValue() * (PlaceInfoBitSize.TIME.getValue() - nowTimeIdx);
}
log.info("todayLeftFullCnt==> " + todayLeftTimeCnt);
List<ConferenceRoom> conferenceRooms = conferenceRoomRepository.findAllByDateAndAfterNow(LocalDate.now(), afterNowBit);
for (ConferenceRoom c : conferenceRooms) {
todayLeftTimeCnt -= ConferenceUtil.bitN(c.getReservationInfo() & (PlaceInfoBit.TIME.getValue() & afterNowBit));
}
log.info("todayLeftCnt==> " + todayLeftTimeCnt);
// true: full
// false: left
return todayLeftTimeCnt <= 0;
Expand Down

0 comments on commit f5dce9c

Please sign in to comment.