List coaches = adminService.queryAllCoachByAdminId(admin.getAdminId());//查询当前管理员所有教练 List coachDtoList = new ArrayList<>();

//筛选教练 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 filteredList = coachDtoList.stream() .filter(coachDto -> coachDto.getWorkStatus() == isWorking && coachDto.getDrivingProjectType() != null && coachDto.getDrivingProjectType().contains(drivingProjectType)) .collect(Collectors.toList()); coachDtoList = filteredList; }

//按照姓名与工作状态排序 Comparator comparator = Comparator.comparing(CoachDto::getWorkStatus, Comparator.reverseOrder()) .thenComparing((c1, c2) -> Collator.getInstance(Locale.CHINESE).compare(c1.getRealName(), c2.getRealName())); coachDtoList.sort(comparator);

//进行分页 int total = coachDtoList.size(); int start = (queryRequest.getPageNum() - 1) * queryRequest.getPageSize(); int end = Math.min(start + queryRequest.getPageSize(), total); List coachDtoListByPage = coachDtoList.subList(start, end);

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;
2普通管理员 ListCoach coaches = adminServicequeryAllCoachByAdminIdadmingetAdminId;查询当前管理员所有教练 1通过姓名和电话查询-普通管理员 if !StringUtilsisEmptytext ListCoachDto coachDtoList = new Ar

原文地址: https://www.cveoy.top/t/topic/iAPe 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录