package com.qmth.teachcloud.mark.service;

import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qmth.teachcloud.common.entity.SysUser;
import com.qmth.teachcloud.mark.dto.mark.manage.Task;
import com.qmth.teachcloud.mark.dto.mark.mark.MarkGroupDto;
import com.qmth.teachcloud.mark.dto.mark.mark.MarkSettingDto;
import com.qmth.teachcloud.mark.dto.mark.mark.MarkStatusDto;
import com.qmth.teachcloud.mark.dto.mark.mark.SubmitResult;
import com.qmth.teachcloud.mark.entity.*;
import com.qmth.teachcloud.mark.params.MarkHeaderGroupResult;
import com.qmth.teachcloud.mark.params.MarkResult;

import io.lettuce.core.GeoArgs.Sort;

/**
 * <p>
 * 评卷相关 服务类
 */
public interface MarkService {

    /**
     * 释放某个评卷员已完成的评卷任务
     *
     * @param submitResult  评卷结果
     * @param markUserGroup 评卷员
     */
    void releaseTask(SubmitResult submitResult, MarkUserGroup markUserGroup);

    int applyCurrentCount(MarkGroup markGroup);

    void releaseByMarkUserGroup(MarkUserGroup markUserGroup);

    int applyCurrentCount(MarkGroup markGroup, Long markUserGroupId);

    void resetMarker(MarkUserGroup markUserGroup);

    void updateMarkedCount(Long examId, String paperNumber, Integer groupNumber);

    boolean rejectMarkTask(MarkProblemHistory markProblemHistory, MarkTask markTask, Long userId);

    String getGroupKey(MarkGroup markGroup);

    void updateQuality(MarkUserGroup markUserGroup);

    boolean needUpdateQuality(MarkUserGroup marker, int expireMinutes);

    void processArbitrate(MarkResult markResult, Long userId);

    void checkStudentSubjective(Long studentId, long groupCount, long unGroupQuestionCount);

    void buildMarkTask(MarkPaper markPaper);

    void deleteMarkTaskByStudent(MarkStudent student);

    void updateGroupAllCount(Long examId, String paperNumber);

    MarkSettingDto getSetting(SysUser user, Long examId, String paperNumber, Integer groupNumber);

    MarkStatusDto getStatus(Long userId, Long examId, String paperNumber, Integer groupNumber);

    List<MarkGroupDto> getGroup(Long userId, Long examId, String paperNumber);

    Task getTask(Long userId, Long examId, String paperNumber, Integer groupNumber);

    void deleteMarkGroup(MarkGroup markGroup, boolean deleteGroupInfo);

    /**
     * /** 释放某个大题的锁定任务
     *
     * @param markGroup
     */
    void releaseByMarkGroup(MarkGroup markGroup);

    void releaseByStudent(MarkStudent student);

    /**
     * 申请领取某个任务
     */
    boolean applyStudent(MarkStudent student, Long userId);

    void submitHeaderTask(List<MarkHeaderGroupResult> markResult, MarkStudent markUserGroup);

    IPage<Task> getHistory(Long userId, int pageNumber, int pageSize, Sort sort, String order, Long examId, String paperNumber,
                           Integer groupNumber, String secretNumber, Double markerScore);

    SubmitResult saveTask(Long examId, String paperNumber, Integer groupNumber, Long userId, MarkResult markResult);

    void clear(Long userId, Long examId, String paperNumber, Integer groupNumber);

    boolean applyTask(MarkTask t, Long userId);

    boolean hasApplied(MarkTask t, Long userId);

    void deleteInitMarkData(Long examId, String paperNumber);

    void calcObjectiveScore(MarkPaper markPaper);

    void updateMarkGroupStatus(Long examId, String paperNumber);
}
