fix:已预约会议室查询

This commit is contained in:
2025-09-16 10:01:37 +08:00
parent 29d8812019
commit 65c5d33a21

View File

@@ -29,10 +29,11 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
@@ -176,15 +177,16 @@ public class MeetBookingServiceImpl implements IMeetBookingService {
@Override
public List<MeetBookingWeekVo> appointmentIdList(String meetId) {
// 计算当前周的起止时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
// 设置为周一
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
Date startOfWeek = calendar.getTime();
// 加6天变为周日
calendar.add(Calendar.DAY_OF_MONTH, 6);
Date endOfWeek = calendar.getTime();
// 获取本周一00:00:00
LocalDateTime startOfWeek = LocalDate.now()
.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
.atStartOfDay();
// 获取本周日23:59:59
LocalDateTime endOfWeek = LocalDate.now()
.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY))
.atTime(23, 59, 59, 999000000);
// 构建查询条件
LambdaQueryWrapper<MeetBooking> bookingLambdaQueryWrapper = new LambdaQueryWrapper<>();
bookingLambdaQueryWrapper.eq(MeetBooking::getMeetId, meetId)
@@ -196,7 +198,7 @@ public class MeetBookingServiceImpl implements IMeetBookingService {
return new ArrayList<>();
}
List<MeetBookingWeekVo> meetBookingWeekVoList = BeanUtil.copyToList(meetBookingVoList, MeetBookingWeekVo.class);
String[] weekStr = {"星期", "星期", "星期二", "星期三", "星期四", "星期五", "星期六"};
String[] weekStr = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六","星期日"};
List<MeetBookingWeekVo> meetBookingWeekList = new ArrayList<>();
SimpleDateFormat df = new SimpleDateFormat("HH");
List<ResidentUnitVo> residentUnitVolist = residentUnitMapper.selectVoList();
@@ -214,11 +216,8 @@ public class MeetBookingServiceImpl implements IMeetBookingService {
.filter(vo -> vo.getUserId() != null && String.valueOf(vo.getUserId()).equals(s.getPerson())).findFirst().orElse(null);
s.setPersonName(ObjectUtil.isNotEmpty(residentPersonVo) ? residentPersonVo.getUserName() : null);
}
//设置指定的Date对象不设置默认返回当天的星期
calendar.setTime(s.getScheduledStarttime());
//获取当前时间的星期
int firstDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
s.setWeek(weekStr[firstDayOfWeek - 1]);
//设置当天的星期
s.setWeek(weekStr[LocalDate.now().getDayOfWeek().getValue()-1]);
String str = df.format(s.getScheduledStarttime());
int a = Integer.parseInt(str);
s.setSlots(a <= 12 ? "上午" : "下午");