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.exam.*;
import com.qmth.themis.business.cache.bean.ExamCacheBean;
import com.qmth.themis.business.dto.MqDto;
import com.qmth.themis.business.dto.response.TEExamDto;
import com.qmth.themis.business.dto.response.TEExamQueryDto;
import com.qmth.themis.business.entity.TEExam;
import com.qmth.themis.business.enums.InvigilateMonitorStatusEnum;
import com.qmth.themis.business.enums.SystemOperationEnum;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * @Description: 考试批次 服务类
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/6/25
 */
public interface TEExamService extends IService<TEExam> {

    /**
     * 查询考试批次
     *
     * @param iPage
     * @param userId
     * @param id
     * @param code
     * @param name
     * @param mode
     * @param enable
     * @param orgId
     * @return
     */
    public IPage<TEExamQueryDto> examQuery(IPage<Map> iPage, Long userId, Long id, String code, String name, String mode, Integer enable, Long orgId);

    /**
     * 获取考试待考列表
     *
     * @param studentId
     * @param examId
     * @param orgId
     * @return
     */
    public List<TEExamDto> getWaitingExam(Long studentId, Long examId, Long orgId);

    /**
     * 开始候考
     *
     * @param studentId
     * @param activityId
     * @return
     */
    public ExamPrepareBean prepare(Long studentId, Long examStudentId);

    /**
     * 开始考试
     *
     * @param id
     * @param recordId
     * @return
     */
    public ExamStartBean start(Long studentId, Long recordId);

    /**
     * 上传个人试卷结构
     *
     * @param studentId
     * @param recordId
     * @param content
     * @return
     */
    public StudentPaperStructBean studentPaperStruct(Long studentId, Long recordId, String content);

    /**
     * 提交作答结果
     *
     * @param studentId
     * @param recordId
     * @param mainNumber
     * @param subNumber
     * @param subIndex
     * @param answer
     * @param version
     * @param durationSeconds
     * @return
     */
    public AnswerSubmitBean answerSubmit(Long studentId, Long recordId, Integer mainNumber, Integer subNumber, Integer subIndex,
                                         String answer, Long version, Integer durationSeconds);

    /**
     * 更新音频剩余播放次数
     *
     * @param id
     * @param recordId
     * @param key
     * @param count
     * @return
     */
    public AudioLeftPlayCountSubmitBean audioLeftPlayCountSubmit(Long studentId, Long recordId, String key, Integer count);


    /**
     * 文件上传
     *
     * @param studentId
     * @param recordId
     * @param file
     * @param suffix
     * @param md5
     * @return
     */
    public ExamFileUploadBean fileUpload(Long studentId, Long recordId, MultipartFile file, String suffix, String md5);

    /**
     * 断点恢复
     *
     * @param studentId
     * @param recordId
     * @return
     */
    public ExamResumeBean resume(Long studentId, Long recordId);

    /**
     * 结束考试
     *
     * @param studentId
     * @param recordId
     * @param type
     * @param durationSeconds
     * @return
     */
    public ExamFinishBean finish(Long studentId, Long recordId, String type, Integer durationSeconds);

    ExamCacheBean getExamCacheBean(Long examId);

    /**
     * 更新批次缓存
     *
     * @param examId
     * @return
     */
    ExamCacheBean updateExamCacheBean(Long examId);

    /**
     * 删除批次缓存
     *
     * @param examId
     */
    void deleteExamCacheBean(Long examId);

    /**
     * 查询交卷结果
     *
     * @param recordId
     * @return
     */
    public ExamResultBean result(Long recordId);

    /**
     * 监考端获取考试批次列表
     *
     * @param userId
     * @param orgId
     * @return
     */
    public List<Map> examList(Long userId, Long orgId);

    /**
     * 发送考试轨迹消息
     *
     * @param systemOperationEnum
     * @param examStudentId
     * @param recordId
     * @param mqDto
     */
    public void sendOeLogMessage(SystemOperationEnum systemOperationEnum, Long examStudentId, Long recordId, MqDto mqDto);

    /**
     * 考试批次权限过滤
     *
     * @param userId
     * @return
     */
    public List<TEExam> examPrivilegeQuery(Long userId);
    
	/**重新算分
	 * @param examId
	 * @param taskId
	 */
	void calculateScore(Long examId, Long taskId);

	void updateInvigilateMonitorStatus(InvigilateMonitorStatusEnum monitorStatus, Long examId);
	
	
}
