package com.qmth.jkserver.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.jkserver.dto.ExamPlanDto;
import com.qmth.jkserver.dto.ExamStudentDto;
import com.qmth.jkserver.enums.ExamKwProgressType;
import com.qmth.jkserver.enums.ExamStatus;
import com.qmth.jkserver.enums.ExamType;
import com.qmth.jkserver.model.*;
import org.springframework.data.domain.Page;

import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface JkExamPlanService extends IService<ExamPlan> {

    public String createExamCode();

    public ExamPlan save(ExamPlanDto examPlanDto) throws Exception;

    public ExamPlan update(ExamPlanDto examPlanDto) throws Exception;

    public void deleteById(Long id);

    public ExamPlan findById(Long id);

    public ExamPlan findByExamCode(String examCode);

    public List<ExamStudentTemp> findKwStudentTemp(String examCode, Long attachmentId, int skip, int
            limit);

    public List<ExamStudentAdditionalTemp> findKwStudentAdditionalTemp(String examCode, Long attachmentId, int skip, int
            limit);

    public List<ExamStudentAdditionalTemp> studentAdditionalTempGroupBy(String examCode, Long attachmentId);

    public List<ExamRoomTemp> findKwRoomsTemp(String examCode, Long attachmentId);

    public List<ExamStageTemp> findKwStageTemps(String examCode, Long attachmentId);

    public List<ExamStudentTemp> saveKwStudentTemp(List<ExamStudentTemp> temps);

    public List<ExamRoomTemp> saveKwRoomTemp(List<ExamRoomTemp> temps);

    public List<ExamRoomAddressTemp> saveKwRoomAddressTemp(List<ExamRoomAddressTemp> temps);

    public List<ExamStageTemp> saveKwStageTemp(List<ExamStageTemp> temps);

    public List<ExamPaperTemp> findKwCoursePaperTemp(String examCode, Long attachmentId);

    public List<ExamPaperTemp> saveKwCoursePaperTemp(List<ExamPaperTemp> examPaperTemps);

    /**
     * 删除paperTemp
     *
     * @param examCode
     */
    public void deleteKwCoursePaperTemp(String examCode);

    public List<ExamStudentAdditionalTemp> saveKwstudentAdditionalTemp(List<ExamStudentAdditionalTemp> temps);

    public Page<ExamPlan> findAll(ExamPlanDto searchCondition, int curPage, int pageSize);

    /**
     * 查询所有考试任务
     *
     * @return
     */
    public List<ExamPlan> findExamPlanAllByTask();

    public ExamPlan updatExamStatus(String id, ExamStatus status);

    public Long getExamPlanStartTime(String examCode) throws ParseException;

    public Long getExamPlanEndTime(String examCode) throws ParseException;

    public Page<ExamStudentTemp> queryExamStudetnsByPages(ExamStudentDto searchCondition, int curPage, int pageSize);

    public Page<ExamRoomTemp> queryExamRoomsByPages(ExamRoomTemp searchCondition, int curPage, int pageSize);

    public List<Map<String, Object>> distinctPlaceCodeExamRoomTemp(String examCode, Long attachmentId);

    public List<Map<String, Object>> distinctBatchIdStudentTemp(String examCode, Long attachmentId, ExamType examType);

    public List<Map<String, Object>> distinctStageIdStudentTemp(String examCode, Long attachmentId, String batchId, ExamType examType);

    public List<Map<String, Object>> distinctCourseCodeStudentTemp(String examCode, Long attachmentId, ExamType examType);

    public Long getBatchStartTime(String examCode, String batchId);

    public ExamPlan updateStatus(String id, ExamStatus status);

    public List<ExamPlan> findByStatus(ExamStatus status, User creator);

    public ExamCode findExamCode(String examCode);

    public List<ExamStage> findStageByExamCode(String examCode);

    public List<Map<String, Object>> distinctPlaceCodeExamStudentTemp(String examCode);

    public List<Map<String, Object>> distinctBatchExamStudent(String examCode);

    public List<Map<String, Object>> distinctBatch(String examCode);

    public List<Map<String, Object>> distinctRoomCodeExamStudentTemp(String examCode, String placeCode);

    List<Map<String, Object>> distinctRoomCodeExamRoomTemp(String examCode, Long attachmentId);

    public boolean canEdit(String examCode);

    public void updateRoomKjAlready(String examCode, String placeCode, String roomCode);

    public void updateRoomKwAlready(String examCode, String placeCode, String roomCode, ExamKwProgressType type);

    /**
     * 保存考试计划
     *
     * @param examCode
     * @param examTask
     */
    public void saveExamPlanByTask(String examCode, ExamTask examTask);

}
