package cn.com.qmth.stmms.biz.exam.service;

import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
import cn.com.qmth.stmms.biz.exam.query.ExamStudentSearchQuery;
import cn.com.qmth.stmms.biz.mark.model.PictureConfigItem;
import cn.com.qmth.stmms.biz.utils.OriginTag;
import cn.com.qmth.stmms.biz.utils.PictureTag;
import cn.com.qmth.stmms.common.enums.SubjectiveStatus;

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

public interface ExamStudentService {

    public ExamStudent findById(int id);

    public int batchSave(List<ExamStudent> list);

    public ExamStudent save(ExamStudent student);

    public void deleteById(int id);

    public void delete(ExamStudent student);

    public void deleteByExamId(int examId);

    public ExamStudentSearchQuery findByQuery(ExamStudentSearchQuery query);

    public long countByQuery(final ExamStudentSearchQuery query);

    List<ExamStudent> findByExamId(int examId);

    List<ExamStudent> findByExamIdAndUploadAndAbsent(int examId, boolean upload, boolean absent, int pageNumber,
            int pageSize);

    ExamStudent findByExamIdAndExamNumber(int examId, String examNumber);

    ExamStudent findByExamIdAndSecretNumber(int examId, String secretNumber);

    public long countByExamId(int examId);

    public long countByExamIdAndSubjectCode(int examId, String subjectCode);

    public long countByExamIdAndSubjectCode(int examId, String subjectCode, boolean upload);

    List<String> findDistinctCampusName(int examId);

    // List<ExamStudent> findByExamIdAndCampusName(int examId, String
    // campusCode, int pageNumber, int pageSize);

    List<String> findDistinctPackageCode(int examId);

    long countByExamIdAndCampusName(int examId, String campusName);

    long countByExamIdAndCampusName(int examId, String campusName, boolean upload);

    long countByExamIdAndSubjectCode(int examId, String subjectCode, boolean upload, boolean absent);

    long countCampusByExam(int examId);

    long countByExamIdAndUpload(int examId, boolean upload);

    void updateSubjectInfo(ExamSubject subject);

    void updateSubjectiveStatusAndScore(Integer examId, String subjectCode, SubjectiveStatus status, double score,
            String scoreList);

    void updateSubjectiveStatusAndScore(Integer id, SubjectiveStatus status, double score, String scoreList);

    void resetSubjectiveStatusByGroupStatus(Integer examId, String subjectCode);

    void updateObjectiveScore(int id, double score, String scoreList);

    void updateManualAbsent(int id, boolean manualAbsent);

    boolean updateBreach(int id, boolean breach);

    void updateManualAbsent(int examId, String examNumber, boolean manualAbsent);

    void clearManualAbsent(int examId);

    void updateException(int id, boolean exception);

    public ExamStudent findBySchoolIdAndSubjectCodeAndStudentCode(Integer schoolId, String subjectCode,
            String studentCode);

    public ExamStudent findBySchoolIdAndSubjectCodeAndStudentCodeAndRemark(Integer schoolId, String subjectCode,
            String studentCode, String examSeqCode);

    public ExamStudent findByExamIdAndSubjectCodeAndUploadTimeAfter(int examId, String code, Date date);

    public List<ExamStudent> findByExamIdAndUploadTimeAfter(int examId, Date date);

    public long countByExamIdAndSubjectiveScoreListIsNotNull(Integer examId);

    List<ExamStudent> findUploadedByExamIdAndSubjectCode(int examId, String code);

    List<ExamStudent> findUnLibraryStudent(int examId, String subjectCode, int groupNumber, int count);

    List<ExamStudent> findAbsentOrBreachLibraryStudent(int examId, String subjectCode);

    public Long countByExamIdAndSubjectCodeAndCampus(Integer examId, String code, String campusName, boolean upload,
            boolean absent);

    public long countByNoAbsentAndBreach(int examId, String subjectCode, boolean upload, boolean absent, boolean breach);

    public long countByAbsentAndBreach(int examId, String subjectCode, Boolean absent, Boolean breach);

    public String findIdsByMarkLogin(String markLogin);

    public String findIdsByMarkName(String markName);

    // List<ExamStudent> findByExamId(int examId, int pageNumber, int pageSize);

    List<ExamStudent> findByExamIdAndSubjectCode(int examId, String subjectCode, int pageNumber, int pageSize);

    List<Integer> findIdByExamIdAndSubjectCodeAndSubjectiveStatus(Integer examId, String subjectCode,
            SubjectiveStatus... status);

    List<PictureTag> buildSheetTags(ExamStudent student, int index, boolean withGroupScore);

    Map<Integer, List<PictureTag>> buildSheetTags(ExamStudent student, boolean withGroupScore, boolean sliceConfigFix);

    Map<MarkGroup, List<OriginTag>> getSliceTags(ExamStudent student, boolean withGroupScore,
            List<PictureConfigItem> sliceConfig);

    boolean updateScanInfo(ExamStudent student);

    boolean resetScanInfo(ExamStudent student);

    long countUploadedByExamIdAndSubjectCode(Integer examId, String subjectCode);

    long countUploadedByExamId(Integer examId);

    List<ExamStudent> findUnTrialStudent(Integer examId, String subjectCode, Integer groupNumber);

    long countByExamIdAndManualAbsent(int examId, boolean manualAbsent);

    boolean validateStatus(Integer id);

    public List<String> findDistinctClassName(Integer examId, String subjectCode);

    public List<String> findDistinctClassName(Integer examId);

    public void updateSubjectiveStatusAndTimeAndInspectorId(Integer studentId, SubjectiveStatus status,
            Date inspectTime, Integer inspectorId);

    public void inspect(Integer studentId, Date inspectTime, Integer inspectorId);

    public List<ExamStudent> findByExamIdAndStudentCodeAndSubjectCode(int examId, String studentCode, String subjectCode);

    public ExamStudent randomStudent(Integer examId, String code);

    public long countSheetCountByExamId(Integer examId);

    public long countSheetCountByExamIdAndSubjectCode(int examId, String code);

    public Set<String> findSubjectUnInspectedByExamId(int examId);

    public List<String> findDistinctCollege(int examId);

    public List<String> findDistinctSubjectCodeByCollege(int examId, String college);

    public int findMinInspectCountByExamIdAndSubjectCode(int examId, String subjectCode);

    public void updateInspectCount(Integer studentId, Integer inspectCount, Date inspectTime, Integer inspectorId);

    Map<Integer, List<PictureTag>> buildSliceTags(ExamStudent student, boolean withGroupScore);

    public long countByExamIdAndSubjectCodeAndCollege(Integer examId, String subjectCode, String collegeName);

    public long countByExamIdAndSubjectCodeAndClass(Integer examId, String subjectCode, String className);

    public long countByExamIdAndSubjectCodeAndTeacher(Integer examId, String subjectCode, String teacherName);

    public int batchUpdate(List<ExamStudent> updateList);

    void scoreVerifyTag(Integer userId, Integer studentId, Boolean tag);

    int cancelInspect(Integer studentId);

    public ExamStudentSearchQuery findByQueryPlus(ExamStudentSearchQuery query);

    public long countByExamIdAndSubjectCodeAndTrial(int examId, String code, boolean trial);

    public boolean updateTrialById(Integer studentId, boolean trial);

    public void scoreVerifyView(Integer userId, Integer studentId);

    public void resetTrial(Integer examId, String subjectCode, boolean trial);

    public void cancelInspect(int examId, String subjectCode);

    public List<String> findDistinctExamSite(int examId);

    public long countByExamIdAndExamSite(int examId, String examSite);

    public long countByExamIdAndExamSite(int examId, String examSite, boolean upload);

    public long countSheetCountByExamIdAndExamSite(int examId, String examSite);

}
