package com.qmth.teachcloud.mark.service;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qmth.teachcloud.mark.dto.mark.manage.MarkManageDto;
import com.qmth.teachcloud.mark.entity.MarkTask;
import com.qmth.teachcloud.mark.enums.MarkTaskStatus;

/**
 * <p>
 * 评卷任务表 服务类
 * </p>
 *
 * @author xf
 * @since 2023-09-22
 */
public interface MarkTaskService extends IService<MarkTask> {

    IPage<MarkManageDto> listPaperManage(Long examId, String courseCode, String paperNumber, Boolean progressStatus, Integer pageNumber, Integer pageSize);

    void exportMarker(Long examId, String courseCode, String paperNumber, HttpServletResponse response);

    List<MarkTask> listByExamIdAndPaperNumberAndGroupNumberAndUserIdAndClassName(Long examId, String paperNumber, Integer groupNumber, Long userId, String className);

    Integer markedCount(List<MarkTask> groupNumberMarkTask);

    int countByExamIdAndPaperNumberAndGroupNumberAndUserId(Long examId, String paperNumber, Integer groupNumber, Long userId);

    List<MarkTask> listByExamIdAndPaperNumberAndGroupNumberAndUserIdAndStatusNotIn(Long examId, String paperNumber, Integer groupNumber, Long userId, List<MarkTaskStatus> statusList);

    boolean resetById(Long markTaskId, Long userId, Long rejecterId, Long date, MarkTaskStatus newStatus);

    int countByExamIdAndPaperNumberAndGroupNumberAndStatusIn(Long examId, String paperNumber, Integer groupNumber, List<MarkTaskStatus> statusList);

    MarkTask getLastOneByUserIdAndStatus(Long examId, String paperNumber, Integer groupNumber, Long userId, MarkTaskStatus status);

    List<MarkTask> listByExamIdAndPaperNumberAndGroupNumberAndStudentId(Long examId, String paperNumber, Integer groupNumber, Long studentId);
    List<MarkTask> listByStudentIdAndGroupNumber(Long studentId, Integer groupNumber);

    void updateHeaderResult(Long examId, String paperNumber, Integer groupNumber, Long studentId, Long updateUserId, Double totalScore, String scoreList, Long updateTime, MarkTaskStatus arbitrated);

    void deleteByStudentId(Long studentId);

	int countByExamIdAndPaperNumberAndGroupNumber(Long examId, String paperNumber, Integer groupNumber);

	int countByExamIdAndPaperNumberAndGroupNumberAndUserIdAndAndClassNameStatusIn(Long examId, String paperNumber, Integer groupNumber, Long userId, List<String> className, MarkTaskStatus... status);
    void deleteByExamIdAndPaperNumberAndGroupNumber(Long examId, String paperNumber, Integer groupNumber);

	IPage<MarkTask> listPageHistory(Page<MarkTask> page, Long userId, Long examId, String paperNumber,
			Integer groupNumber, String secretNumber, Double markerScore);

	List<MarkTask> findUnMarked(Page<MarkTask> page, Long examId, String paperNumber, Integer groupNumber, Long userId);

	List<MarkTask> findUnMarkedFilterClass(Page<MarkTask> page, Long examId, String paperNumber, Integer groupNumber,
			Long userId);

	int countByIdAndStatus(Long id, MarkTaskStatus status);

	List<MarkTask> findByStudentIdAndGroupNumberAndStatus(Long studentId, Integer groupNumber, MarkTaskStatus... status);

	boolean updateProblemResult(Long taskId,Long userId, Long now, int spent);

	boolean updateStatusByStudentIdAndGroupNumber(Long studentId, Integer groupNumber, MarkTaskStatus status);

	int countByStudentIdAndMarkerIdAndIdNotEqual(Long studentId, Long examId, String paperNumber, Integer groupNumber, Long userId, Long taskId);

	boolean updateMarkerResult(Long taskId, MarkTaskStatus marked, Long userId, Double markerScore, String scoreList,
			Long now, int spent,MarkTaskStatus... inStatus);

    int countByExamIdAndPaperNumberAndGroupNumberAndTaskNumber(Long examId, String paperNumber, Integer groupNumber, int taskNumber);
}
