package com.yida.data.school.exam.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yida.data.common.core.entity.CurrentUser;
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
import com.yida.data.common.core.entity.exam.*;
import com.yida.data.school.exam.mapper.*;
import com.yida.data.school.exam.service.CoreExaminationCourseService;
import com.yida.data.school.exam.service.CoreExaminationStudentCourseService;
import com.yida.data.school.exam.service.CoreExaminationStudentService;
import com.yida.data.user.feign.RemoteStudentService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;

@Service
@Transactional
public class CoreExaminationStudentServiceImpl extends ServiceImpl<CoreExaminationStudentMapper,
        CoreExaminationStudent> implements CoreExaminationStudentService {

    @Resource
    private CoreExaminationStudentMapper coreExaminationStudentMapper;
    @Resource
    private RemoteStudentService remoteStudentService;
    @Resource
    private CoreExaminationMapper coreExaminationMapper;
    @Resource
    private CoreExaminationStudentCourseService coreExaminationStudentCourseService;
    @Resource
    private CoreExaminationStudentCourseMapper coreExaminationStudentCourseMapper;
    @Resource
    private CoreExaminationPublishMapper coreExaminationPublishMapper;
    @Resource
    private CoreExaminationPublishRecordMapper coreExaminationPublishRecordMapper;
    @Resource
    private CoreExaminationPublishGradeConvertTypeMapper coreExaminationPublishGradeConvertTypeMapper;

    @Resource
    private CoreExaminationCourseService coreExaminationCourseService;
    @Resource
    private EduExamAvgMapper eduExamAvgMapper;

    @Override
    public IPage<CoreExaminationStudent> findExaminationStudentPageList(Integer pageNum, Integer pageSize, Long examId, String searchName, Long classId) {
        return coreExaminationStudentMapper.findExaminationStudentPage(new Page(pageNum,pageSize),examId, searchName, classId);
    }

    @Override
    @Transactional
    public void saveExaminationStudent(CoreExaminationStudent coreExaminationStudent, CurrentUser currentUser) {

        Long schoolId = coreExaminationStudent.getSchoolId();
        String studentNumber = coreExaminationStudent.getStudentNumber();
        Long id = remoteStudentService.getStudentByStuNumAndSchool(studentNumber, schoolId).getData().getId();
        coreExaminationStudent.setCoreStudentId(id);
        //登录用户id
        Long userId = 1L;
        if (currentUser == null) {
            userId = currentUser.getUserId();
        }

        //判断是新增还是修改
        if (coreExaminationStudent.getId() == null) {
            //新增
            coreExaminationStudent.setCreateId(userId);
            coreExaminationStudentMapper.insert(coreExaminationStudent);
            //成绩新增
            coreExaminationStudentCourseService.saveBatch(coreExaminationStudent.getStudentCourseList());
        } else {
            //修改
            coreExaminationStudent.setUpdateId(userId);
            coreExaminationStudentMapper.updateById(coreExaminationStudent);
            //成绩修改
            coreExaminationStudentCourseService.saveOrUpdateBatch(coreExaminationStudent.getStudentCourseList());
        }
    }

    @Override
    public int checkStudentIdNumber(CoreExaminationStudent coreExaminationStudent) {
        return coreExaminationStudentMapper.checkStudentIdNumber(coreExaminationStudent);
    }

    @Override
    public CoreExaminationStudent findExaminationStudent(Long examinationStudentId) {
        return getById(examinationStudentId);
    }

    @Override
    @Transactional
    public void delExaminationStudentBatch(List<Long> examinationStudentIds) {
        //批量删除考生信息
        removeByIds(examinationStudentIds);
    }

    @Override
    public IPage<CoreExaminationStudent> findRankPageList(Integer pageNum,Integer pageSize,Long coreExaminationId, String studentName,
                                                         Long classId) {
        IPage<CoreExaminationStudent> rankPageList = coreExaminationStudentMapper.findRankPageList(new Page(pageNum,pageSize),coreExaminationId, studentName, classId);
        for (CoreExaminationStudent coreExaminationStudent : rankPageList.getRecords()) {
            Long id = coreExaminationStudent.getId();
            List<CoreExaminationStudentCourse> coreExaminationStudentCourses = coreExaminationStudentCourseMapper.selectList(Wrappers.lambdaQuery(
                    new CoreExaminationStudentCourse()).eq(CoreExaminationStudentCourse::getCoreExaminationStudentId, id));
            coreExaminationStudent.setStudentCourseList(coreExaminationStudentCourses);
        }
        return rankPageList;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveExamResults(CoreExaminationStudent coreExaminationStudent, CurrentUser currentUser) {
        //登录用户id
        Long userId = 1L;
        if (Optional.ofNullable(currentUser).map(o -> o.getUserId()).isPresent()) {
            userId = currentUser.getUserId();
        }

        coreExaminationStudent.setCreateId(userId);
        Long schoolId = coreExaminationStudent.getSchoolId();
        String schoolName = coreExaminationStudent.getSchoolName();

        // 设置学校id
        coreExaminationStudent.setSchoolId(schoolId);
        // 设置学校名称
        coreExaminationStudent.setSchoolName(schoolName);
        // 设置考场名称
        CoreExamination coreExamination = coreExaminationMapper.selectById(coreExaminationStudent.getCoreExaminationId());
        coreExaminationStudent.setExaminationRoom(coreExamination.getName());


        // 计算总分数
        for (CoreExaminationStudentCourse coreExaminationStudentCourse : coreExaminationStudent.getStudentCourseList()) {
            coreExaminationStudent.setScore(Optional.ofNullable(coreExaminationStudentCourse.getScore()).orElse(0.0) +
                    Optional.ofNullable(coreExaminationStudent).map(obj -> obj.getScore()).orElse(0.0));
        }

        if (Objects.equals(Optional.ofNullable(coreExaminationStudent).map(obj -> obj.getScore()).orElse(0D), 0D)) {
            coreExaminationStudent.setMiss("1");
        }

        coreExaminationStudentMapper.insert(coreExaminationStudent);

        // 判断是否有总成绩，没有则不更新排名操作
        if (Objects.nonNull(coreExaminationStudent.getScore())) {
            // 根据考场和年级id查询对应的所有成绩并返回排序
            List<CoreExaminationStudent> examinationIdAndGradeId =
                    coreExaminationStudentMapper.findByCoreExaminationIdAndGradeId(coreExaminationStudent.getCoreExaminationId(), coreExaminationStudent.getGradeId());
            // 更新所有考生年级排名
            if (!CollectionUtils.isEmpty(examinationIdAndGradeId)) {
                for (CoreExaminationStudent examinationStudent : examinationIdAndGradeId) {
                    coreExaminationStudentMapper.updateGradleRankOrClassRank(examinationStudent);

                }
            }

            // 根据考场,年级id,班级id查询对应的所有成绩并返回排序
            List<CoreExaminationStudent> examinationIdAndGradeIdClassId = coreExaminationStudentMapper.
                    findByCoreExaminationIdAndGradeIdClassId(coreExaminationStudent.getCoreExaminationId(),
                            coreExaminationStudent.getGradeId(),
                            coreExaminationStudent.getClassId());
            // 更新所有考生班级排名
            if (!CollectionUtils.isEmpty(examinationIdAndGradeIdClassId)) {
                for (CoreExaminationStudent examinationStudent : examinationIdAndGradeIdClassId) {
                    coreExaminationStudentMapper.updateGradleRankOrClassRank(examinationStudent);
                }
            }
        }


        if (!CollectionUtils.isEmpty(coreExaminationStudent.getStudentCourseList())) {
            for (CoreExaminationStudentCourse coreExaminationStudentCourse : coreExaminationStudent.getStudentCourseList()) {
                // 设置考生id
                coreExaminationStudentCourse.setCoreExaminationStudentId(coreExaminationStudent.getId());
                // 设置考场id
                coreExaminationStudentCourse.setCoreExaminationId(coreExaminationStudent.getCoreExaminationId());

                coreExaminationStudentCourse.setCreateId(userId);

                coreExaminationStudentCourse.setCreateId(userId);

                // 设置学校id和name
                coreExaminationStudentCourse.setSchoolId(schoolId);
                coreExaminationStudentCourse.setSchoolName(schoolName);
                // 设置年级id和name
                coreExaminationStudentCourse.setGradeId(coreExaminationStudent.getGradeId());
                coreExaminationStudentCourse.setGradeName(coreExaminationStudent.getGradeName());
                // 设置班级id和name
                coreExaminationStudentCourse.setClassId(coreExaminationStudent.getClassId());
                coreExaminationStudentCourse.setClassName(coreExaminationStudent.getClassName());
                // 设置考场name
                coreExaminationStudentCourse.setExaminationRoom(coreExamination.getName());
                // 设置考号
                coreExaminationStudentCourse.setExaminationNumber(coreExaminationStudent.getExaminationNumber());
                // 设置座位号
                coreExaminationStudentCourse.setSeatNumber(coreExaminationStudent.getSeatNumber());

                if (Objects.isNull(coreExaminationStudentCourse.getScore())) {
                    coreExaminationStudentCourse.setMiss("1");
                }
            }
            coreExaminationStudentCourseService.saveBatch(coreExaminationStudent.getStudentCourseList());

            for (CoreExaminationStudentCourse coreExaminationStudentCourse : coreExaminationStudent.getStudentCourseList()) {
                // 判断科目是否有输入成绩，有成绩在更新各科的最新排名
                if (Objects.nonNull(coreExaminationStudentCourse.getScore())) {
                    // 根据考场,年级id,科目id查询对应的所有成绩并返回排序
                    List<CoreExaminationStudentCourse> coreExaminationStudentCourses =
                            coreExaminationStudentCourseMapper.findByCoreExaminationIdAndGradeIdCourseId(coreExaminationStudentCourse.getCoreExaminationId(),
                                    coreExaminationStudentCourse.getGradeId(),
                                    coreExaminationStudentCourse.getCoreExaminationCourseId());
                    //更新年级排名
                    if (!CollectionUtils.isEmpty(coreExaminationStudentCourses)) {
                        for (CoreExaminationStudentCourse coreExaminationStudentCours : coreExaminationStudentCourses) {
                            coreExaminationStudentCourseMapper.updateGradleRankOrClassRank(coreExaminationStudentCours);

                        }
                    }
                    // 根据考场,年级id,年级id，科目id查询对应的所有成绩并返回排序
                    List<CoreExaminationStudentCourse> coreExaminationStudentCourses1 =
                            coreExaminationStudentCourseMapper.findByCoreExaminationIdAndGradeIdClassIdCourseId(coreExaminationStudentCourse.getCoreExaminationId(),
                                    coreExaminationStudentCourse.getGradeId(),
                                    coreExaminationStudentCourse.getClassId(),
                                    coreExaminationStudentCourse.getCoreExaminationCourseId());
                    //更新班级排名
                    if (!CollectionUtils.isEmpty(coreExaminationStudentCourses1)) {
                        for (CoreExaminationStudentCourse examinationStudentCourse : coreExaminationStudentCourses1) {
                            coreExaminationStudentCourseMapper.updateGradleRankOrClassRank(examinationStudentCourse);

                        }
                    }
                }
            }

        }

        System.out.println("测试");
    }

    @Override
    public CoreExaminationStudent findCoreExaminationStudentDetail(Long coreExaminationId,
                                                                   Long coreExaminationStudentId,
                                                                   Long classId, String name) {
        return coreExaminationStudentMapper.findCoreExaminationStudentDetail(coreExaminationStudentId,
                coreExaminationId, classId, name);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void editExamResultsDetail(CoreExaminationStudent coreExaminationStudent, CurrentUser currentUser) {

        CoreExaminationStudent student = getById(coreExaminationStudent.getId());
        coreExaminationStudentCourseMapper.delete(Wrappers.lambdaQuery(new CoreExaminationStudentCourse())
                .eq(CoreExaminationStudentCourse::getCoreExaminationStudentId, coreExaminationStudent.getId())
                .eq(CoreExaminationStudentCourse::getCoreExaminationId,
                        coreExaminationStudent.getCoreExaminationId()));
        //登录用户id
        Long userId = 1L;
        if (Optional.ofNullable(currentUser).map(o -> o.getUserId()).isPresent()) {
            userId = currentUser.getUserId();
        }
        coreExaminationStudent.setUpdateId(userId);
        // 计算总分数
        for (CoreExaminationStudentCourse coreExaminationStudentCourse : coreExaminationStudent.getStudentCourseList()) {
            coreExaminationStudent.setScore(Optional.ofNullable(coreExaminationStudentCourse.getScore()).orElse(0.0) +
                    Optional.ofNullable(coreExaminationStudent).map(obj -> obj.getScore()).orElse(0.0));
        }

        if (Objects.equals(coreExaminationStudent.getScore(), 0)) {

            coreExaminationStudent.setMiss("1");
        }

        // 修改总分数,去除误操作，实际未填写分数，更新缺考标记
        if (Optional.ofNullable(coreExaminationStudent.getScore()).orElse(0.0) > 0) {
            coreExaminationStudentMapper.updateById(coreExaminationStudent);
        }

        // 判断是否有总成绩，没有则不更新排名操作
        if (Objects.nonNull(coreExaminationStudent.getScore())) {
            // 根据考场和年级id查询对应的所有成绩并返回排序
            List<CoreExaminationStudent> examinationIdAndGradeId =
                    coreExaminationStudentMapper.findByCoreExaminationIdAndGradeId(coreExaminationStudent.getCoreExaminationId(), coreExaminationStudent.getGradeId());
            // 更新所有考生年级排名
            if (!CollectionUtils.isEmpty(examinationIdAndGradeId)) {
                for (CoreExaminationStudent examinationStudent : examinationIdAndGradeId) {
                    coreExaminationStudentMapper.updateGradleRankOrClassRank(examinationStudent);
                }
            }
            // 根据考场,年级id,班级id查询对应的所有成绩并返回排序
            List<CoreExaminationStudent> examinationIdAndGradeIdClassId = coreExaminationStudentMapper.
                    findByCoreExaminationIdAndGradeIdClassId(coreExaminationStudent.getCoreExaminationId(),
                            coreExaminationStudent.getGradeId(),
                            coreExaminationStudent.getClassId());
            // 更新所有考生班级排名
            if (!CollectionUtils.isEmpty(examinationIdAndGradeIdClassId)) {
                for (CoreExaminationStudent examinationStudent : examinationIdAndGradeIdClassId) {
                    coreExaminationStudentMapper.updateGradleRankOrClassRank(examinationStudent);

                }
            }
        }
        // 有分数才进行更新操作，更新缺考标记
        for (CoreExaminationStudentCourse coreExaminationStudentCourse : coreExaminationStudent.getStudentCourseList()) {
            if (Optional.ofNullable(coreExaminationStudentCourse.getScore()).orElse(0.0) > 0) {
                coreExaminationStudentCourse.setId(null);
                // 设置考生id
                coreExaminationStudentCourse.setCoreExaminationStudentId(student.getId());
                // 设置考场id
                coreExaminationStudentCourse.setCoreExaminationId(coreExaminationStudent.getCoreExaminationId());

                coreExaminationStudentCourse.setCreateId(userId);

                coreExaminationStudentCourse.setCreateId(userId);

                // 设置学校id和name
                coreExaminationStudentCourse.setSchoolId(student.getSchoolId());
                coreExaminationStudentCourse.setSchoolName(student.getSchoolName());
                // 设置年级id和name
                coreExaminationStudentCourse.setGradeId(student.getGradeId());
                coreExaminationStudentCourse.setGradeName(student.getGradeName());
                // 设置班级id和name
                coreExaminationStudentCourse.setClassId(student.getClassId());
                coreExaminationStudentCourse.setClassName(student.getClassName());
                // 设置考场name
                coreExaminationStudentCourse.setExaminationRoom(student.getExaminationRoom());
                // 设置考号
                coreExaminationStudentCourse.setExaminationNumber(coreExaminationStudent.getExaminationNumber());
                // 设置座位号
                coreExaminationStudentCourse.setSeatNumber(coreExaminationStudent.getSeatNumber());

                if (Objects.isNull(coreExaminationStudentCourse.getScore())) {
                    coreExaminationStudentCourse.setMiss("1");
                }
                coreExaminationStudentCourse.setUpdateId(userId);
                coreExaminationStudentCourse.setCoreExaminationStudentId(coreExaminationStudent.getId());
                coreExaminationStudentCourseService.saveOrUpdate(coreExaminationStudentCourse);
            }
        }


        for (CoreExaminationStudentCourse coreExaminationStudentCourse : coreExaminationStudent.getStudentCourseList()) {
            // 判断科目是否有输入成绩，有成绩在更新各科的最新排名
            if (Objects.nonNull(coreExaminationStudentCourse.getScore())) {
                coreExaminationStudentCourse.setCoreExaminationStudentId(coreExaminationStudent.getId());
                coreExaminationStudentCourse = coreExaminationStudentCourseMapper.findById(coreExaminationStudentCourse);
                // 根据考场,年级id,科目id查询对应的所有成绩并返回排序
                List<CoreExaminationStudentCourse> coreExaminationStudentCourses =
                        coreExaminationStudentCourseMapper.findByCoreExaminationIdAndGradeIdCourseId(coreExaminationStudentCourse.getCoreExaminationId(),
                                coreExaminationStudentCourse.getGradeId(),
                                coreExaminationStudentCourse.getCoreExaminationCourseId());
                //更新年级排名
                if (!CollectionUtils.isEmpty(coreExaminationStudentCourses)) {
                    for (CoreExaminationStudentCourse coreExaminationStudentCours : coreExaminationStudentCourses) {

                        coreExaminationStudentCourseMapper.updateGradleRankOrClassRank(coreExaminationStudentCours);
                    }
                }
                // 根据考场,年级id,年级id，科目id查询对应的所有成绩并返回排序
                List<CoreExaminationStudentCourse> coreExaminationStudentCourses1 =
                        coreExaminationStudentCourseMapper.findByCoreExaminationIdAndGradeIdClassIdCourseId(coreExaminationStudentCourse.getCoreExaminationId(),
                                coreExaminationStudentCourse.getGradeId(),
                                coreExaminationStudentCourse.getClassId(),
                                coreExaminationStudentCourse.getCoreExaminationCourseId());
                //更新班级排名
                if (!CollectionUtils.isEmpty(coreExaminationStudentCourses1)) {
                    for (CoreExaminationStudentCourse examinationStudentCourse : coreExaminationStudentCourses1) {
                        coreExaminationStudentCourseMapper.updateGradleRankOrClassRank(examinationStudentCourse);

                    }
                }
            }
        }

    }

    @Override
    @Transactional
    @CacheEvict(value = CachePrefixConstant.EXAM_STUDENT_SCORE_RANK, allEntries = true)
    public Integer delTeacherBatch(Long examinationId, CurrentUser currentUser) {
        Long userId = 1L;
        if (Optional.ofNullable(currentUser).map(o -> o.getUserId()).isPresent()) {
            userId = currentUser.getUserId();
        }
        CoreExamination coreExamination = new CoreExamination();
        coreExamination.setId(examinationId);
        coreExamination.setPublish("0");
        coreExamination.setUpdateId(userId);
        coreExamination.setUpdateDate(LocalDateTime.now());
        int num = coreExaminationMapper.updateById(coreExamination);

        List<CoreExaminationStudent> coreExaminationStudents = coreExaminationStudentMapper.selectList(
                Wrappers.lambdaQuery(new CoreExaminationStudent()).eq(CoreExaminationStudent::getCoreExaminationId, examinationId));
        for (CoreExaminationStudent examinationStudent : coreExaminationStudents) {
            examinationStudent.setReceiptStatus("0");
        }
        saveOrUpdateBatch(coreExaminationStudents);

        // 删除对应的主要信息的成绩发布信息
        coreExaminationPublishMapper.delete(Wrappers.lambdaQuery(new CoreExaminationPublish()).eq(CoreExaminationPublish::getCoreExaminationId, examinationId));
        // 删除发布的成绩信息
        coreExaminationPublishRecordMapper.delete(Wrappers.lambdaQuery(new CoreExaminationPublishRecord()).eq(CoreExaminationPublishRecord::getCoreExaminationId, examinationId));
        // 删除发布的成绩信息规则
        coreExaminationPublishGradeConvertTypeMapper.delete(Wrappers.lambdaQuery(new CoreExaminationPublishGradeConvertType()).eq(CoreExaminationPublishGradeConvertType::getCoreExaminationId, examinationId));
        // 删除平均分
        eduExamAvgMapper.delete(Wrappers.lambdaQuery(new EduExamAvg()).eq(EduExamAvg::getExamId,
                examinationId));
        return num;
    }

    @Override
    @Transactional
    public void delRankBatchIds(List<Long> rankIds) {
        List<CoreExaminationStudent> students = (List<CoreExaminationStudent>) listByIds(rankIds);
        Long gradeId = students.get(0).getGradeId();
        Long examId = students.get(0).getCoreExaminationId();
        List<CoreExaminationCourse> courses = coreExaminationCourseService.list(Wrappers.lambdaQuery(new CoreExaminationCourse())
                .eq(CoreExaminationCourse::getCoreExaminationId, examId));
        Set<Long> classIds = new HashSet<>();
        removeByIds(rankIds);
        coreExaminationStudentCourseMapper.delete(Wrappers.lambdaQuery(new CoreExaminationStudentCourse())
                .in(CoreExaminationStudentCourse::getCoreExaminationStudentId, rankIds));
        for (CoreExaminationStudent student : students) {
            classIds.add(student.getClassId());
        }

        // 根据考场和年级id查询对应的所有成绩并返回排序
        List<CoreExaminationStudent> examinationIdAndGradeId = coreExaminationStudentMapper.findByCoreExaminationIdAndGradeId(examId, gradeId);
        // 更新所有考生年级排名
        if (!CollectionUtils.isEmpty(examinationIdAndGradeId)) {
            for (CoreExaminationStudent examinationStudent : examinationIdAndGradeId) {
                coreExaminationStudentMapper.updateGradleRankOrClassRank(examinationStudent);
            }
        }
        for (Long classId : classIds) {
            // 根据考场,年级id,班级id查询对应的所有成绩并返回排序
            List<CoreExaminationStudent> examinationIdAndGradeIdClassId = coreExaminationStudentMapper.
                    findByCoreExaminationIdAndGradeIdClassId(examId, gradeId, classId);
            // 更新所有考生班级排名
            if (!CollectionUtils.isEmpty(examinationIdAndGradeIdClassId)) {
                for (CoreExaminationStudent examinationStudent : examinationIdAndGradeIdClassId) {
                    coreExaminationStudentMapper.updateGradleRankOrClassRank(examinationStudent);
                }
            }
        }

        for (CoreExaminationCourse course : courses) {
            // 根据考场,年级id,科目id查询对应的所有成绩并返回排序
            List<CoreExaminationStudentCourse> coreExaminationStudentCourses =
                    coreExaminationStudentCourseMapper.findByCoreExaminationIdAndGradeIdCourseId(examId,
                            gradeId, course.getCoreCourseId());
            //更新年级排名
            if (!CollectionUtils.isEmpty(coreExaminationStudentCourses)) {
                for (CoreExaminationStudentCourse coreExaminationStudentCours : coreExaminationStudentCourses) {
                    coreExaminationStudentCourseMapper.updateGradleRankOrClassRank(coreExaminationStudentCours);
                }
            }
            for (Long classId : classIds) {
                // 根据考场,年级id,年级id，科目id查询对应的所有成绩并返回排序
                List<CoreExaminationStudentCourse> coreExaminationStudentCourses1 =
                        coreExaminationStudentCourseMapper.findByCoreExaminationIdAndGradeIdClassIdCourseId(examId, gradeId, classId, course.getCoreCourseId());
                //更新班级排名
                if (!CollectionUtils.isEmpty(coreExaminationStudentCourses1)) {
                    for (CoreExaminationStudentCourse examinationStudentCourse : coreExaminationStudentCourses1) {
                        coreExaminationStudentCourseMapper.updateGradleRankOrClassRank(examinationStudentCourse);
                    }
                }
            }
        }
    }


    @Override
    public CoreExaminationStudent selectStudent(Long id, Long examId) {
        CoreExaminationStudent coreExaminationStudent = baseMapper.selectOne(Wrappers.lambdaQuery(new CoreExaminationStudent()).eq(CoreExaminationStudent::getCoreStudentId, id).
                eq(CoreExaminationStudent::getCoreExaminationId, examId));
        return coreExaminationStudent;
    }

}



