package com.qmth.themis.business.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qmth.themis.business.bean.backend.*;
import com.qmth.themis.business.dto.response.TEExamUnFinishDto;
import com.qmth.themis.business.entity.TOeExamRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

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

/**
 * @Description: 考试记录 Mapper 接口
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/25
 */
@Mapper
public interface TOeExamRecordMapper extends BaseMapper<TOeExamRecord> {

    /**
     * 获取考试未完列表
     *
     * @param studentId
     * @param examId
     * @param orgId
     * @return
     */
    public TEExamUnFinishDto getUnFinishExam(@Param("studentId") Long studentId, @Param("examId") Long examId, @Param("orgId") Long orgId);

    /**
     * 数据更新
     *
     * @param recordId
     * @param colName
     * @param colValue
     */
    public void dataUpdate(@Param("recordId") Long recordId, @Param("colName") String colName, @Param("colValue") Object colValue);

    /**
     * 查询实时监控台列表
     *
     * @param iPage
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param paperDownload
     * @param status
     * @param name
     * @param identity
     * @param minWarningCount
     * @param maxWarningCount
     * @param clientWebsocketStatus
     * @param monitorStatusSource
     * @param userId
     * @return
     */
    public IPage<InvigilateListBean> invigilatePageList(IPage<Map> iPage, @Param("examId") Long examId,
                                                        @Param("examActivityId") Long examActivityId,
                                                        @Param("roomCode") String roomCode,
                                                        @Param("paperDownload") Integer paperDownload,
                                                        @Param("status") String status,
                                                        @Param("name") String name,
                                                        @Param("identity") String identity,
                                                        @Param("minWarningCount") Integer minWarningCount,
                                                        @Param("maxWarningCount") Integer maxWarningCount,
                                                        @Param("clientWebsocketStatus") String clientWebsocketStatus,
                                                        @Param("monitorStatusSource") String monitorStatusSource,
                                                        @Param("userId") Long userId);

    /**
     * 查询实时监控台视频列表
     *
     * @param iPage
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param paperDownload
     * @param status
     * @param name
     * @param identity
     * @param minWarningCount
     * @param maxWarningCount
     * @param clientWebsocketStatus
     * @param monitorStatusSource
     * @param userId
     * @return
     */
    public IPage<InvigilateListVideoBean> invigilatePageListVideo(IPage<Map> iPage, @Param("examId") Long examId,
                                                                  @Param("examActivityId") Long examActivityId,
                                                                  @Param("roomCode") String roomCode,
                                                                  @Param("paperDownload") Integer paperDownload,
                                                                  @Param("status") String status,
                                                                  @Param("name") String name,
                                                                  @Param("identity") String identity,
                                                                  @Param("minWarningCount") Integer minWarningCount,
                                                                  @Param("maxWarningCount") Integer maxWarningCount,
                                                                  @Param("clientWebsocketStatus") String clientWebsocketStatus,
                                                                  @Param("monitorStatusSource") String monitorStatusSource,
                                                                  @Param("userId") Long userId);

    /**
     * 实时监控台视频随机列表
     *
     * @param examId
     * @param userId
     * @param randomNum
     * @return
     */
    public List<InvigilateListVideoBean> invigilatePageListVideoRandom(@Param("examId") Long examId, @Param("userId") Long userId, @Param("randomNum") Integer randomNum);

    /**
     * 查询在线巡考列表
     *
     * @param iPage
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param status
     * @param name
     * @param identity
     * @param minMultipleFaceCount
     * @param maxMultipleFaceCount
     * @param minExceptionCount
     * @param maxExceptionCount
     * @param minWarningCount
     * @param maxWarningCount
     * @param clientWebsocketStatus
     * @param monitorStatusSource
     * @param userId
     * @return
     */
    public IPage<InvigilateListPatrolBean> invigilatePagePatrolList(IPage<Map> iPage, @Param("examId") Long examId,
                                                                    @Param("examActivityId") Long examActivityId,
                                                                    @Param("roomCode") String roomCode,
                                                                    @Param("status") String status,
                                                                    @Param("name") String name,
                                                                    @Param("identity") String identity,
                                                                    @Param("minMultipleFaceCount") Integer minMultipleFaceCount,
                                                                    @Param("maxMultipleFaceCount") Integer maxMultipleFaceCount,
                                                                    @Param("minExceptionCount") Integer minExceptionCount,
                                                                    @Param("maxExceptionCount") Integer maxExceptionCount,
                                                                    @Param("minWarningCount") Integer minWarningCount,
                                                                    @Param("maxWarningCount") Integer maxWarningCount,
                                                                    @Param("clientWebsocketStatus") String clientWebsocketStatus,
                                                                    @Param("monitorStatusSource") String monitorStatusSource,
                                                                    @Param("userId") Long userId);

    /**
     * 预警提醒列表
     *
     * @param iPage
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param approveStatus
     * @param name
     * @param identity
     * @param minMultipleFaceCount
     * @param maxMultipleFaceCount
     * @param minExceptionCount
     * @param maxExceptionCount
     * @param minWarningCount
     * @param maxWarningCount
     * @param clientWebsocketStatus
     * @param monitorStatusSource
     * @param userId
     * @return
     */
    public IPage<InvigilateListWarningBean> invigilatePageWarningList(IPage<Map> iPage, @Param("examId") Long examId,
                                                                      @Param("examActivityId") Long examActivityId,
                                                                      @Param("roomCode") String roomCode,
                                                                      @Param("approveStatus") Integer approveStatus,
                                                                      @Param("name") String name,
                                                                      @Param("identity") String identity,
                                                                      @Param("minMultipleFaceCount") Integer minMultipleFaceCount,
                                                                      @Param("maxMultipleFaceCount") Integer maxMultipleFaceCount,
                                                                      @Param("minExceptionCount") Integer minExceptionCount,
                                                                      @Param("maxExceptionCount") Integer maxExceptionCount,
                                                                      @Param("minWarningCount") Integer minWarningCount,
                                                                      @Param("maxWarningCount") Integer maxWarningCount,
                                                                      @Param("clientWebsocketStatus") String clientWebsocketStatus,
                                                                      @Param("monitorStatusSource") String monitorStatusSource,
                                                                      @Param("userId") Long userId);

    /**
     * 进度查询列表
     *
     * @param iPage
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param courseCode
     * @param name
     * @param identity
     * @param userId
     * @return
     */
    public IPage<InvigilateListProgressBean> invigilatePageProgressList(IPage<Map> iPage, @Param("examId") Long examId,
                                                                        @Param("examActivityId") Long examActivityId,
                                                                        @Param("roomCode") String roomCode,
                                                                        @Param("courseCode") String courseCode,
                                                                        @Param("name") String name,
                                                                        @Param("identity") String identity,
                                                                        @Param("userId") Long userId);

    /**
     * 进度查询列表导出
     *
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param courseCode
     * @param name
     * @param identity
     * @param userId
     * @return
     */
    public List<InvigilateListProgressExcelBean> invigilatePageProgressListExport(@Param("examId") Long examId,
                                                                         @Param("examActivityId") Long examActivityId,
                                                                         @Param("roomCode") String roomCode,
                                                                         @Param("courseCode") String courseCode,
                                                                         @Param("name") String name,
                                                                         @Param("identity") String identity,
                                                                         @Param("userId") Long userId);

    /**
     * 监考明细管理列表
     *
     * @param iPage
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param courseCode
     * @param status
     * @param breachStatus
     * @param finishType
     * @param name
     * @param identity
     * @param minMultipleFaceCount
     * @param maxMultipleFaceCount
     * @param minExceptionCount
     * @param maxExceptionCount
     * @param minWarningCount
     * @param maxWarningCount
     * @param clientWebsocketStatus
     * @param monitorStatusSource
     * @param userId
     * @return
     */
    public IPage<InvigilateListHistoryBean> invigilatePageListHistory(IPage<Map> iPage, @Param("examId") Long examId,
                                                                      @Param("examActivityId") Long examActivityId,
                                                                      @Param("roomCode") String roomCode,
                                                                      @Param("courseCode") String courseCode,
                                                                      @Param("status") String status,
                                                                      @Param("breachStatus") Integer breachStatus,
                                                                      @Param("finishType") String finishType,
                                                                      @Param("name") String name,
                                                                      @Param("identity") String identity,
                                                                      @Param("minMultipleFaceCount") Integer minMultipleFaceCount,
                                                                      @Param("maxMultipleFaceCount") Integer maxMultipleFaceCount,
                                                                      @Param("minExceptionCount") Integer minExceptionCount,
                                                                      @Param("maxExceptionCount") Integer maxExceptionCount,
                                                                      @Param("minWarningCount") Integer minWarningCount,
                                                                      @Param("maxWarningCount") Integer maxWarningCount,
                                                                      @Param("clientWebsocketStatus") String clientWebsocketStatus,
                                                                      @Param("monitorStatusSource") String monitorStatusSource,
                                                                      @Param("userId") Long userId);

    public List<Map<String, Object>> getDoneCount(@Param("examId") Long examId, @Param("activityId") Long activityId,
                                                  @Param("roomCode") String roomCode, @Param("courseCode") String courseCode);

    public List<Map<String, Object>> getDoneCountByDay(@Param("examId") Long examId, @Param("activityId") Long activityId,
                                                       @Param("roomCode") String roomCode, @Param("courseCode") String courseCode);

    public Long getCountByExamId(@Param("examId") Long examId);

    public List<TOeExamRecord> getListByExamIdAndStartId(@Param("examId") Long examId, @Param("startId") Long startId);

    public void updateObjectiveScore(@Param("recordId") Long recordId, @Param("score") Double score);

    public TOeExamRecord findOneByPaperId(@Param("paperId") Long paperId);

    /**
     * 在线巡考报表接口
     *
     * @param examId
     * @param userId
     * @return
     */
    public List<InvigilateListPatrolReportBean> patrolReport(@Param("examId") Long examId, @Param("userId") Long userId);

    public TOeExamRecord findOneByExamId(@Param("examId") Long examId,@Param("status") String status);

    public Long getExamingCount();

    public Long getExceptionCount();

    public Long getWarnCount();

    public List<Map<String, Object>> getOrgExamingCount();

    public List<Map<String, Object>> getOrgDistribution();

    public List<Map<String, Object>> getTypeDistribution();

    public List<ExaminationMonitorHourWarnCountBean> getWarnTrend(@Param("startTime") Long startTime);
}
