package com.qmth.distributed.print.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qmth.distributed.print.business.bean.dto.*;
import com.qmth.distributed.print.business.bean.dto.initMarkData.ExamDetailCourseInitMarkDto;
import com.qmth.distributed.print.business.bean.dto.initMarkData.InitExamDetailDto;
import com.qmth.distributed.print.business.bean.result.ExaminationDetailResult;
import com.qmth.distributed.print.business.bean.result.ExaminationResult;
import com.qmth.distributed.print.business.bean.result.SummarizedDataResult;
import com.qmth.distributed.print.business.entity.ExamDetail;
import com.qmth.distributed.print.business.entity.ExamDetailCourse;
import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 考务数据 Mapper 接口
 * </p>
 *
 * @author xf
 * @since 2021-03-23
 */
public interface ExamDetailMapper extends BaseMapper<ExamDetail> {

    IPage<PrintTaskDto> listPrintTask(Page<PrintTaskDto> page, @Param("schoolId") Long schoolId,
                                      @Param("semesterId") Long semesterId,
                                      @Param("examId") Long examId,
                                      @Param("printPlanId") Long printPlanId,
                                      @Param("status") String status,
                                      @Param("courseCode") String courseCode,
                                      @Param("paperNumber") String paperNumber,
                                      @Param("examPlace") String examPlace,
                                      @Param("examRoom") String examRoom,
                                      @Param("examStartTime") Long examStartTime,
                                      @Param("examEndTime") Long examEndTime,
                                      @Param("printStartTime") Long printStartTime,
                                      @Param("printEndTime") Long printEndTime,
                                      @Param("printHouseId") Long printHouseId,
                                      @Param("dpr") DataPermissionRule dpr);

    IPage<ExaminationResult> findBriefPage(@Param("page") Page<ExaminationResult> page,
                                           @Param("schoolId") Long schoolId,
                                           @Param("semesterId") Long semesterId,
                                           @Param("examId") Long examId,
                                           @Param("printPlanIdList") List<Long> printPlanIdList,
                                           @Param("courseCode") String courseCode,
                                           @Param("paperNumber") String paperNumber,
                                           @Param("examPlace") String examPlace,
                                           @Param("examRoom") String examRoom,
                                           @Param("packageCode") String packageCode,
                                           @Param("startDate") Long startDate,
                                           @Param("endDate") Long endDate,
                                           @Param("dpr") DataPermissionRule dpr);

    IPage<ExaminationDetailResult> findDetailPage(@Param("page") Page<ExaminationDetailResult> page,
                                                  @Param("schoolId") Long schoolId,
                                                  @Param("semesterId") Long semesterId,
                                                  @Param("examId") Long examId,
                                                  @Param("printPlanIdList") List<Long> printPlanIdList,
                                                  @Param("courseCode") String courseCode,
                                                  @Param("paperNumber") String paperNumber,
                                                  @Param("examPlace") String examPlace,
                                                  @Param("examRoom") String examRoom,
                                                  @Param("studentParams") String studentParams,
                                                  @Param("startDate") Long startDate,
                                                  @Param("endDate") Long endDate,
                                                  @Param("dpr") DataPermissionRule dpr);

    IPage<ExaminationDetailResult> findDetailPageById(@Param("page") Page<ExaminationDetailResult> page,
                                                      @Param("examDetailId") Long examDetailId,
                                                      @Param("param") String param);

    PrintTaskTotalDto taskTotalData(@Param("schoolId") Long schoolId,
                                    @Param("semesterId") Long semesterId,
                                    @Param("examId") Long examId,
                                    @Param("printPlanId") Long printPlanId,
                                    @Param("status") String status,
                                    @Param("courseCode") String courseCode,
                                    @Param("paperNumber") String paperNumber,
                                    @Param("examPlace") String examPlace,
                                    @Param("examRoom") String examRoom,
                                    @Param("examStartTime") Long examStartTime,
                                    @Param("examEndTime") Long examEndTime,
                                    @Param("printStartTime") Long printStartTime,
                                    @Param("printEndTime") Long printEndTime,
                                    @Param("printHouseId") Long printHouseId,
                                    @Param("dpr") DataPermissionRule dpr);

    @SuppressWarnings("MybatisXMapperMethodInspection")
    List<Map> listStudentByExamDetailCourseId(@Param("schoolId") Long schoolId, @Param("examDetailCourseId") Long examDetailCourseId, @Param("studentCode") String studentCode, @Param("type") String type);

    List<ExamDetailCourse> selectPaperCount(@Param("schoolId") Long schoolId,
                                            @Param("semesterId") Long semesterId,
                                            @Param("examId") Long examId,
                                            @Param("printPlanId") Long printPlanId,
                                            @Param("status") String status,
                                            @Param("courseCode") String courseCode,
                                            @Param("paperNumber") String paperNumber,
                                            @Param("examPlace") String examPlace,
                                            @Param("examRoom") String examRoom,
                                            @Param("examStartTime") Long examStartTime,
                                            @Param("examEndTime") Long examEndTime,
                                            @Param("printStartTime") Long printStartTime,
                                            @Param("printEndTime") Long printEndTime,
                                            @Param("printHouseId") Long printHouseId,
                                            @Param("dpr") DataPermissionRule dpr);

    /**
     * 根据id下载examDetail
     *
     * @param ids
     * @return
     */
    List<ExamDetailPdfDownloadDto> findPdfDownload(@Param("ids") List<Long> ids);

    SummarizedDataResult findSummarizedData(@Param("schoolId") Long schoolId, @Param("semesterId") Long semesterId, @Param("examId") Long examId, @Param("printPlanIdList") List<Long> printPlanIdList, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber, @Param("examPlace") String examPlace, @Param("examRoom") String examRoom, @Param("packageCode") String packageCode, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("dpr") DataPermissionRule dpr);

    List<ExamDetailCourseDto> listByExamIdAndCourseCode(@Param("schoolId") Long schoolId, @Param("examId") Long examId, @Param("courseCode") String courseCode);

    List<ExamDetailCourseInitMarkDto> listPrintFinishExamDetailCourse(@Param("printStatus") String printStatus, @Param("startTime") long startTime, @Param("markStatus") String markStatus);

    int countMakeupUsedByExamIdAndPaperNumber(@Param("examId") Long examId, @Param("paperNumber") String paperNumber);

    List<ExamDetail> listByExamIdAndCourseCodeAndPaperNumber(@Param("schoolId") Long schoolId, @Param("examId") Long examId, @Param("courseCode") String courseCode, @Param("paperNumber") String paperNumber);

    List<ExamDetailCourseInitMarkDto> listPrintFinishPackageCode(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("paperType") String paperType);

    List<InitExamDetailDto> listPrintFinishExamDetailCourseIds(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("paperType") String paperType);
}
