package com.xhkjedu.smarking.mapper.stupaper;

import com.xhkjedu.base.TkMapper;
import com.xhkjedu.smarking.model.exam.MsClassStudent;
import com.xhkjedu.smarking.model.paper.MsPaperQtype;
import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
import com.xhkjedu.smarking.model.stupaper.MsPaperStudent;
import com.xhkjedu.smarking.model.stupaper.MsPaperStudentScore;
import com.xhkjedu.smarking.vo.exam.CStudentVo;
import com.xhkjedu.smarking.vo.scan.ScanParams;
import com.xhkjedu.smarking.vo.stupaper.PaperStuExamVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.scheduling.annotation.Async;

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

/**
 * @Description 阅卷试卷学生表 Mapper 接口
 * @Author auto
 * @Date 2024-10-15
 */
public interface MsPaperStudentMapper extends TkMapper<MsPaperStudent> {
    //批量保存学生试卷
    void batchSave(@Param("list") List<MsPaperStudent> paperStudents);

    //获取学生科目试卷状态
    Integer getStateByStudentIdAndSubjectId(@Param("cs") CStudentVo cs);

    //获取试卷学生信息
    MsPaperStudent getPaperStudentByStudentidAndMpid(@Param("studentId") Integer studentId, @Param("mpId") Integer mpId);

    //学生考试列表-待进行
    List<Map<String,Object>> listExamPrePapersForStudent(@Param("studentid")Integer studentid, @Param("nowtime")String nowtime);

    //学生考试列表-已结束
    List<Map<String,Object>> listExamEndPapersForStudent(@Param("studentid")Integer studentid);

    //学生待考-考试科目状态和学生试卷状态
    PaperStuExamVo getSubjectStateAndSstageByMpsid(@Param("mpsid")Integer mpsid);
    //学生待考-考试科目时间信息
    Map<String,Object> getExamPaperSubjectByMpsid(@Param("mpsid")Integer mpsid);
    //学生待考-Web题库试卷
    List<MsPaperQtype> listStuPaperQuestionsForWebTk(@Param("mpsid")Integer mpsid);
    //学生待考-Web附件试卷
    List<MsPaperQtype> listStuPaperQuestionsForWebFj(@Param("mpsid")Integer mpsid);
    //学生待考-Android题库试卷
    List<Map<String,Object>> listStuPaperQuestionsForAndroidTk(@Param("mpsid")Integer mpsid);
    //学生待考-Android附件试卷
    List<Map<String,Object>> listStuPaperQuestionsForAndroidFj(@Param("mpsid")Integer mpsid);
    //学生待考-进入考试-修改学生考试状态
    int updatePaperStuStartime(@Param("mpsid")Integer mpsid, @Param("starttime")Integer starttime);
    //学生待考-进入考试-获取考试结束时间
    PaperStuExamVo getSubjectEndtime(@Param("msid")Integer msid,@Param("studentid")Integer studentid);

    //学生考试-获取单科状态
    PaperStuExamVo getSubjectStateByMpsid(@Param("mpsid")Integer mpsid);
    //学生考试-提交试卷
    Integer updateStudentPaper(@Param("ps")MsPaperStudent ps);
    //试卷答案-客观题-批量更新学生试卷分值
    int updateBathStudentPaperScoreByMpsid(@Param("mpid") Integer mpid,@Param("mpsids") List<Integer> mpsids);

    //学生考试-获取开始考试学生数量
    Integer getNumByExamIdAndSubjectIdAndStuId(@Param("student") MsClassStudent student);

    //学生考试-获取开始考试学生数量
    Integer getStartNumByExamIdExamMode(@Param("examid") Integer examid,@Param("exammode") Integer exammode);
    //删除试卷学生信息
    int deletePaperStuByMpid(@Param("mpid") Integer mpid);

    //扫描异常-清空学生扫描试卷信息
    int updateStuPaperForScanErrorClear(@Param("mpsid")Integer mpsid);
    //扫描异常-缺考异常-更改状态
    int updateBatchStuPaperSstate(@Param("list") List<MsPaperStudent> paperStudents);
    //扫描-清空学生试卷扫描信息
    int updateStuPaperForScanClearByMpid(@Param("mpid") Integer mpid);
    //补录成绩-学生科目成绩
    List<MsPaperStudent> listPaperStudentForFillScore(@Param("examid") Integer examid,@Param("studentid") Integer studentid);
    //补录成绩-补录单科
    int updateStuScoreForFillScore(@Param("psc") MsPaperStudentScore psc);
    //补录成绩-补录多科
    int updateBatchStuScoreForFillScore(@Param("list") List<MsPaperStudentScore> list);
    //补录成绩-清空学生补录分数
    int updateStuScoreForRestoreFillScore(@Param("examid") Integer examid,@Param("studentid") Integer studentid);

    //删除考试学生信息
    void deleteByExamId(@Param("examid") Integer examid);

    @Async("asyncPoolTaskExecutor")
    //更新学生总分
    void updateStudentPaperScoreByMpsId(@Param("mpsid") Integer mpsid);

    //试学生成绩列表
    List<MsrStudent> listPaperStudentByExamId(@Param("examid") Integer examid, @Param("mpids") List<Integer> mpids);

    //清空试卷下所有学生识别作答及批阅信息
    int updateStudentBlockQuestionForReIdentify(@Param("param") ScanParams param);
}
