无关风月
2024-07-11 eb6b6dbb35a9f029e0b7d269773685c19fd40976
cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageStudentServiceImpl.java
@@ -1,7 +1,9 @@
package com.dsh.course.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.course.entity.CoursePackageScheduling;
import com.dsh.course.entity.CoursePackageStudent;
import com.dsh.course.entity.StudentClassInfo;
import com.dsh.course.entity.TAppUser;
@@ -10,8 +12,10 @@
import com.dsh.course.feignclient.account.StudentClient;
import com.dsh.course.feignclient.account.model.AppUser;
import com.dsh.course.feignclient.account.model.Student;
import com.dsh.course.mapper.CoursePackageSchedulingMapper;
import com.dsh.course.mapper.CoursePackageStudentMapper;
import com.dsh.course.model.QueryCoursePackageStudentList;
import com.dsh.course.service.CoursePackageSchedulingService;
import com.dsh.course.service.CoursePackageStudentService;
import com.dsh.course.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +23,7 @@
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -42,11 +47,12 @@
    private StudentClient studentClient;
    @Autowired
    private CoursePackageSchedulingMapper coursePackageSchedulingService;
    /**
     * 获取排课预约数据
     *
     * @param queryCoursePackageStudentList
     * @return
     */
@@ -54,31 +60,47 @@
    public List<Map<String, Object>> queryCoursePackageStudentList(Page<Map<String, Object>> page, QueryCoursePackageStudentList queryCoursePackageStudentList) {
        List<Integer> userId = null;
        List<Integer> studentId = null;
        if(ToolUtil.isNotEmpty(queryCoursePackageStudentList.getUserName())){
        if (ToolUtil.isNotEmpty(queryCoursePackageStudentList.getUserName())) {
            List<AppUser> appUsers = appUserClient.queryAppUserListByName(queryCoursePackageStudentList.getUserName());
            if(appUsers.size() > 0){
            if (appUsers.size() > 0) {
                userId = appUsers.stream().map(AppUser::getId).collect(Collectors.toList());
            }
        }
        if(ToolUtil.isNotEmpty(queryCoursePackageStudentList.getStudentName())){
        if (ToolUtil.isNotEmpty(queryCoursePackageStudentList.getStudentName())) {
            List<Student> students = studentClient.queryStudentListByName(queryCoursePackageStudentList.getStudentName());
            if(students.size() > 0){
            if (students.size() > 0) {
                studentId = students.stream().map(Student::getId).collect(Collectors.toList());
            }
        }
        List<Map<String, Object>> list = this.baseMapper.queryCoursePackageStudentList(page, queryCoursePackageStudentList.getCoursePackageSchedulingId(), userId, studentId);
        CoursePackageScheduling coursePackageScheduling = coursePackageSchedulingService.selectById(queryCoursePackageStudentList.getCoursePackageSchedulingId());
        List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingService.selectList(new QueryWrapper<CoursePackageScheduling>()
                .eq("coursePackageId", coursePackageScheduling.getCoursePackageId()).eq("classDate", coursePackageScheduling.getClassDate()));
        List<Long> ids = new ArrayList<>();
        for (CoursePackageScheduling packageScheduling : coursePackageSchedulings) {
            ids.add(packageScheduling.getId());
        }
        List<Map<String, Object>> list = this.baseMapper.queryCoursePackageStudentList(page, ids, userId, studentId);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        Integer now = Integer.valueOf(sdf.format(new Date()));
        for (Map<String, Object> map : list) {
            Integer appUserId = Integer.valueOf(map.get("appUserId").toString());
            Integer student_Id = Integer.valueOf(map.get("studentId").toString());
            TAppUser appUser = appUserClient.queryAppUser1(appUserId);
            if(null != appUser){
                map.put("userName", appUser.getName());
                map.put("phone", appUser.getPhone());
            }
            Student student = studentClient.queryStudentById(student_Id);
            map.put("userName", appUser.getName());
            map.put("phone", student.getPhone());
            map.put("studentName", student.getName());
            map.put("age", null != student.getBirthday() ? now - Integer.valueOf(sdf.format(student.getBirthday())) : "-");
            map.put("sex", student.getSex());
            if(null != student){
                map.put("studentName", student.getName());
                map.put("age", null != student.getBirthday() ? now - Integer.valueOf(sdf.format(student.getBirthday())) : "-");
                map.put("sex", student.getSex());
            }
        }
        return list;
    }
@@ -90,7 +112,11 @@
    @Override
    public List<ClassListDto> getClassList(Integer tStudentId) {
        return this.baseMapper.getClassList(tStudentId);
        List<ClassListDto> classList = this.baseMapper.getClassList(tStudentId);
        List<ClassListDto> holiList = this.baseMapper.getHoliList(tStudentId);
        classList.addAll(holiList);
        return classList;
    }
    @Override