package com.qmth.themis.business.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.themis.business.bean.backend.*;
import com.qmth.themis.business.entity.TOeExamRecord;
import com.qmth.themis.business.enums.ExamRecordStatusEnum;
import com.qmth.themis.business.enums.ExamTypeEnum;
import com.qmth.themis.business.enums.LivenessTypeEnum;
import com.qmth.themis.business.enums.VerifyExceptionEnum;

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

/**
 * @Description: 考试记录 服务类
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/25
 */
public interface TOeExamRecordService extends IService<TOeExamRecord> {

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

    Long saveByPrepare(Long examId, Long examActivityId, Long examStudentId, Long paperId, Integer serialNumber);

    /**
     * 计算客观分
     *
     * @param param
     */
    void calculateObjectiveScore(Map<String, Object> param);

    /**
     * 考试记录数据持久化
     *
     * @param recordId
     */
    public void saveDataByCache(Long recordId);

    void saveFaceVerify(ExamTypeEnum type, Long recordId, Long entryAuthenticationId,
                        VerifyExceptionEnum entryAuthenticationResult);

    void saveLivenessVerify(LivenessTypeEnum type, Long recordId, Long entryAuthenticationId,
                            VerifyExceptionEnum entryAuthenticationResult);

    /**
     * 考试记录字段同步消息发送
     *
     * @param recordId
     * @param colName
     * @param colValue
     */
    void dataUpdateMq(Long recordId, String colName, Object colValue);

    /**
     * 单字段更新
     *
     * @param recordId
     * @param colName
     * @param colValue
     */
    void dataUpdate(Long recordId, String colName, Object colValue);

    /**
     * 考试记录字段同步消息发送
     *
     * @param recordId
     * @param colNames
     * @param colValues
     */
    void dataUpdatesMq(Long recordId, String[] colNames, Object[] colValues);

    /**
     * 考试记录初始化消息发送
     *
     * @param param
     */
    void dataInitMq(Map<String, Object> param);

    /**
     * 考试记录初始化
     *
     * @param param
     */
    void dataInit(Map<String, Object> param);

    /**
     * 查询实时监控台列表
     *
     * @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, Long examId,
                                                        Long examActivityId,
                                                        String roomCode,
                                                        Integer paperDownload,
                                                        String status,
                                                        String name,
                                                        String identity,
                                                        Integer minWarningCount,
                                                        Integer maxWarningCount,
                                                        String clientWebsocketStatus,
                                                        String monitorStatusSource,
                                                        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, Long examId,
                                                                  Long examActivityId,
                                                                  String roomCode,
                                                                  Integer paperDownload,
                                                                  String status,
                                                                  String name,
                                                                  String identity,
                                                                  Integer minWarningCount,
                                                                  Integer maxWarningCount,
                                                                  String clientWebsocketStatus,
                                                                  String monitorStatusSource,
                                                                  Long userId);

    /**
     * 实时监控台视频随机列表
     *
     * @param examId
     * @param userId
     * @param randomNum
     * @return
     */
    public List<InvigilateListVideoBean> invigilatePageListVideoRandom(Long examId, Long userId, 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, Long examId,
                                                                    Long examActivityId,
                                                                    String roomCode,
                                                                    String status,
                                                                    String name,
                                                                    String identity,
                                                                    Integer minMultipleFaceCount,
                                                                    Integer maxMultipleFaceCount,
                                                                    Integer minExceptionCount,
                                                                    Integer maxExceptionCount,
                                                                    Integer minWarningCount,
                                                                    Integer maxWarningCount,
                                                                    String clientWebsocketStatus,
                                                                    String monitorStatusSource,
                                                                    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, Long examId,
                                                                      Long examActivityId,
                                                                      String roomCode,
                                                                      Integer approveStatus,
                                                                      String name,
                                                                      String identity,
                                                                      Integer minMultipleFaceCount,
                                                                      Integer maxMultipleFaceCount,
                                                                      Integer minExceptionCount,
                                                                      Integer maxExceptionCount,
                                                                      Integer minWarningCount,
                                                                      Integer maxWarningCount,
                                                                      String clientWebsocketStatus,
                                                                      String monitorStatusSource,
                                                                      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, Long examId,
                                                                        Long examActivityId,
                                                                        String roomCode,
                                                                        String courseCode,
                                                                        String name,
                                                                        String identity,
                                                                        Long userId);

    /**
     * 进度查询列表导出
     *
     * @param examId
     * @param examActivityId
     * @param roomCode
     * @param courseCode
     * @param name
     * @param identity
     * @param userId
     * @return
     */
    public List<InvigilateListProgressExcelBean> invigilatePageProgressListExport(Long examId,
                                                                                  Long examActivityId,
                                                                                  String roomCode,
                                                                                  String courseCode,
                                                                                  String name,
                                                                                  String identity,
                                                                                  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, Long examId,
                                                                      Long examActivityId,
                                                                      String roomCode,
                                                                      String courseCode,
                                                                      String status,
                                                                      Integer breachStatus,
                                                                      String finishType,
                                                                      String name,
                                                                      String identity,
                                                                      Integer minMultipleFaceCount,
                                                                      Integer maxMultipleFaceCount,
                                                                      Integer minExceptionCount,
                                                                      Integer maxExceptionCount,
                                                                      Integer minWarningCount,
                                                                      Integer maxWarningCount,
                                                                      String clientWebsocketStatus,
                                                                      String monitorStatusSource,
                                                                      Long userId);


    /**
     * 重新算分
     */
    void calculateScore(Long recordId);

    /**
     * 获取考试记录数
     *
     * @param examId
     * @return
     */
    Long getCountByExamId(Long examId);

    /**
     * 批量获取考试记录
     *
     * @param examId
     * @param startId
     * @return
     */
    List<TOeExamRecord> getListByExamIdAndStartId(Long examId, Long startId);

    TOeExamRecord findOneByPaperId(Long paperId);

    TOeExamRecord findOneByExamId(Long examId, ExamRecordStatusEnum status);
}
