2普通管理员 ListCoach coaches = adminServicequeryAllCoachByAdminIdadmingetAdminId;查询当前管理员所有教练 1通过姓名和电话查询-普通管理员 if !StringUtilsisEmptytext ListCoachDto coachDtoList = new Ar
List
//筛选教练 for (Coach coach : coaches) { if (!StringUtils.isEmpty(text) && coach.getRealName() != null && (coach.getRealName().contains(text) || coach.getCoachPhone().contains(text))) { coachDtoList.add(generateCoachDto(coach)); } else if (StringUtils.isEmpty(text)) { coachDtoList.add(generateCoachDto(coach)); } }
//根据工作状态和科目筛选教练
if (!StringUtils.isEmpty(workStatus) || !StringUtils.isEmpty(drivingProjectType)) {
boolean isWorking = !StringUtils.isEmpty(workStatus) && Integer.parseInt(workStatus) == 1;
List
//按照姓名与工作状态排序
Comparator
//进行分页
int total = coachDtoList.size();
int start = (queryRequest.getPageNum() - 1) * queryRequest.getPageSize();
int end = Math.min(start + queryRequest.getPageSize(), total);
List
map.put("coaches", coachDtoListByPage); map.put("total", total);
return new Result<>(ResultCode.SUCCESS, map);
private CoachDto generateCoachDto(Coach coach) { CoachDto coachDto = new CoachDto(); BeanUtils.copyProperties(coach, coachDto);
// 判断教练是否在工作中
List<CourseDto> courseDtoList = courseInfoService.queryCourseByCoachId(coach.getCoachId(), RcqtUtils.getDay());
boolean isWorking = courseDtoList != null && courseDtoList.stream()
.anyMatch(c -> {
LocalTime currentTime = LocalTime.now();
return currentTime.isAfter(c.getStartReservationTime().toLocalTime()) && currentTime.isBefore(c.getEndReservationTime().toLocalTime());
});
coachDto.setWorkStatus(isWorking);
return coachDto;
原文地址: https://www.cveoy.top/t/topic/iAPe 著作权归作者所有。请勿转载和采集!