package com.qmth.themis.business.dto.request;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.themis.business.base.BaseEntity;
import com.qmth.themis.business.constant.SystemConstant;
import com.qmth.themis.business.entity.TEExam;
import com.qmth.themis.business.enums.*;
import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * @Description: 考试请求dto
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/8/8
 */
public class TEExamDto extends BaseEntity {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "机构ID")
    @TableField(value = "org_id")
    private Long orgId;

    @ApiModelProperty(value = "批次编码，机构唯一")
    @TableField(value = "code")
    private String code;

    @ApiModelProperty(value = "批次名称")
    @TableField(value = "name")
    private String name;

    @ApiModelProperty(value = "批次标注，可用于多个考试批次归类")
    @TableField(value = "tag")
    private String tag;

    @ApiModelProperty(value = "批次开始时间")
    @TableField(value = "start_time")
    private Long startTime;

    @ApiModelProperty(value = "批次结束时间")
    @TableField(value = "end_time")
    private Long endTime;

    @ApiModelProperty(value = "考试口令")
    @TableField(value = "short_code")
    private String shortCode;

    @ApiModelProperty(value = "提前多长时间开始候考(分钟)")
    @TableField(value = "prepare_seconds")
    private Integer prepareSeconds;

    @ApiModelProperty(value = "最短考试时长，相当于考试冻结时间(分钟)")
    @TableField(value = "min_duration_seconds")
    private Integer minDurationSeconds;

    @ApiModelProperty(value = "考前须知")
    @TableField(value = "pre_notice")
    private String preNotice;

    @ApiModelProperty(value = "考试须知阅读时长(秒)")
    @TableField(value = "pre_notice_stay_seconds")
    private Integer preNoticeStaySeconds;

    @ApiModelProperty(value = "考后说明，针对一个场次进行设置")
    @TableField(value = "post_notice")
    private String postNotice;

    @ApiModelProperty(value = "允许考试次数")
    @TableField(value = "exam_count")
    private Integer examCount;

    @ApiModelProperty(value = "断点失效时间(秒)")
    @TableField(value = "break_expire_seconds")
    private Integer breakExpireSeconds;

    @ApiModelProperty(value = "断点续考次数")
    @TableField(value = "break_resume_count")
    private Integer breakResumeCount;

    @ApiModelProperty(value = "是否允许使用摄像头拍照答题，0：不允许，1：允许")
    @TableField(value = "camera_photo_upload")
    private Integer cameraPhotoUpload;

    @ApiModelProperty(value = "重考是否审批，0：不审批，1：审批")
    @TableField(value = "reexam_auditing")
    private Integer reexamAuditing;

    @ApiModelProperty(value = "交卷后是否显示客观得分，0：不显示，1：显示")
    @TableField(value = "show_objective_score")
    private Integer showObjectiveScore;

    @ApiModelProperty(value = "模式，0：集中统一，1：随到随考")
    @TableField(value = "mode")
    private ExamModeEnum mode;

    @ApiModelProperty(value = "是否启用，0：停用，1：启用")
    @TableField(value = "enable")
    private Integer enable;

    @ApiModelProperty(value = "是否归档，0：不归档，1：归档")
    @TableField(value = "archived")
    private Integer archived;

    @ApiModelProperty(value = "允许开考开放时长(分钟)，相当于迟到时间")
    @TableField(value = "opening_seconds")
    private Integer openingSeconds;

    @ApiModelProperty(value = "最大考试时长(分钟)")
    @TableField(value = "max_duration_seconds")
    private Integer maxDurationSeconds;

    @ApiModelProperty(value = "是否在结束时间集中强制收卷，0：不强制，1：强制")
    @TableField(value = "force_finish")
    private Integer forceFinish;

    @ApiModelProperty(value = "开考身份验证策略，off：关闭，face_verify_optional：非强制人脸验证，face_verify_force：强制人脸验证，liveness：活体验证")
    @TableField(value = "entry_authentication_policy")
    private EntryAuthenticationPolicyEnum entryAuthenticationPolicy;

    @ApiModelProperty(value = "考试过程中人脸检测是否开启，0：不开启，1：开启")
    @TableField(value = "in_process_face_verify")
    private Integer inProcessFaceVerify;

    @ApiModelProperty(value = "考试过程中人脸检测是否忽略陌生人 ，0：不忽略，1：忽略")
    @TableField(value = "in_process_face_stranger_ignore")
    private Integer inProcessFaceStrangerIgnore;

    @ApiModelProperty(value = "考试过程中是否启用活体检测 ，0：不启用，1：启用")
    @TableField(value = "in_process_liveness_verify")
    private Integer inProcessLivenessVerify;

    @ApiModelProperty(value = "考试过程中活体检测间隔时间")
    @TableField(value = "in_process_liveness_fixed_range")
    private List<Integer> inProcessLivenessFixedRange;

    @ApiModelProperty(value = "考试过程中活体检测结果判定规则，any：任意一次通过，all：全部都要通过，more：通过次数大于失败次数")
    @TableField(value = "in_process_liveness_judge_policy")
    private InProcessLivenessJudgePolicyEnum inProcessLivenessJudgePolicy;

    @ApiModelProperty(value = "多次考试记录的选择逻辑，highest_total_score：全部阅卷后取最高分，highest_objective_score：客观分最高，latest：最后一次提交")
    @TableField(value = "record_select_strategy")
    private RecordSelectStrategyEnum recordSelectStrategy;

    @ApiModelProperty(value = "是否IP段限制，0：不允许，1：允许")
    @TableField(value = "enable_ip_limit")
    private Integer enableIpLimit;

    @ApiModelProperty(value = "允许IP段")
    @TableField(value = "ip_allow")
    private String ipAllow;

    @ApiModelProperty(value = "算分状态，never：从未算分，calculating：正在算分，finish：算分完成")
    @TableField(value = "score_status")
    private ScoreStatusEnum scoreStatus;

    @ApiModelProperty(value = "客观题给分策略，equal: 全对给分，partial: 漏选给一半分")
    @TableField(value = "objective_score_policy")
    private ObjectiveScorePolicyEnum objectiveScorePolicy;

    @ApiModelProperty(value = "开启监控的视频源")
    @TableField(value = "monitor_video_source")
    private List<String> monitorVideoSource;

//    @ApiModelProperty(value = "是否开始监控转录，off:禁用; mix:混流转录")
//    @TableField(value = "monitor_record")
//    private MonitorRecordEnum monitorRecord;

    @ApiModelProperty(value = "开启转录的视频源")
    @TableField(value = "monitor_record")
    private List<String> monitorRecord;

    @ApiModelProperty(value = "算分进度")
    @TableField(value = "progress")
    private Double progress;

//    @ApiModelProperty(value = "是否允许使用移动端拍照答题，0：不开启，1：开启")
//    @TableField(value = "mobile_photo_upload")
//    private Integer mobilePhotoUpload;

    @ApiModelProperty(value = "监考人工审核，now：实时审核，later：事后审核")
    @TableField(value = "invigilate_verify")
    private InvigilateVerifyEnum invigilateVerify;

    @ApiModelProperty(value = "监考状态，NOT_START：未开始，START：监考中，FINISHED：已结束")
    @TableField("monitor_status")
    private InvigilateMonitorStatusEnum monitorStatus;

    @ApiModelProperty(value = "考试过程中是否启用真实性检测，0：不启用，1：启用")
    @TableField(value = "in_process_realness_verify")
    private Integer inProcessRealnessVerify;

    @ApiModelProperty(value = "是否允许考生发起语音通话，0：否，1：是")
    private Integer examStudentCallEnable = 1;

    public TEExamDto() {

    }

    public TEExamDto(TEExam teExam) {
        setId(teExam.getId());
        this.orgId = teExam.getOrgId();
        this.name = teExam.getName();
        this.code = teExam.getCode();
        this.tag = teExam.getTag();
        this.startTime = teExam.getStartTime();
        this.endTime = teExam.getEndTime();
        this.shortCode = teExam.getShortCode();
        this.prepareSeconds = teExam.getPrepareSeconds();
        this.minDurationSeconds = teExam.getMinDurationSeconds();
        this.preNotice = teExam.getPreNotice();
        this.preNoticeStaySeconds = teExam.getPreNoticeStaySeconds();
        this.postNotice = teExam.getPostNotice();
        this.examCount = teExam.getExamCount();
        this.breakExpireSeconds = teExam.getBreakExpireSeconds();
        this.breakResumeCount = teExam.getBreakResumeCount();
        this.cameraPhotoUpload = teExam.getCameraPhotoUpload();
//        this.mobilePhotoUpload = teExam.getMobilePhotoUpload();
        this.reexamAuditing = teExam.getReexamAuditing();
        this.showObjectiveScore = teExam.getShowObjectiveScore();
        this.mode = teExam.getMode();
        this.enable = teExam.getEnable();
        this.archived = teExam.getArchived();
        this.openingSeconds = teExam.getOpeningSeconds();
        this.maxDurationSeconds = teExam.getMaxDurationSeconds();
        this.forceFinish = teExam.getForceFinish();
        this.entryAuthenticationPolicy = teExam.getEntryAuthenticationPolicy();
        this.inProcessFaceVerify = teExam.getInProcessFaceVerify();
        this.inProcessFaceStrangerIgnore = teExam.getInProcessFaceStrangerIgnore();
        this.inProcessLivenessVerify = teExam.getInProcessLivenessVerify();
        this.inProcessRealnessVerify = teExam.getInProcessRealnessVerify();
        if (Objects.nonNull(teExam.getInProcessLivenessFixedRange())) {
            String[] longs = teExam.getInProcessLivenessFixedRange().trim().replaceAll(" ", "").split(",");
            List inProcessLivenessFixedRange = new ArrayList();
            for (int i = 0; i < longs.length; i++) {
                Integer integer = Integer.valueOf(longs[i].trim().replaceAll(" ", ""));
                inProcessLivenessFixedRange.add(integer);
            }
            if (Objects.equals(inProcessLivenessFixedRange.toString().trim().replaceAll(" ", ""), "")) {
                setInProcessLivenessFixedRange(null);
            } else {
                setInProcessLivenessFixedRange(inProcessLivenessFixedRange);
            }
        }
        this.inProcessLivenessJudgePolicy = teExam.getInProcessLivenessJudgePolicy();
        this.recordSelectStrategy = teExam.getRecordSelectStrategy();
        this.enableIpLimit = teExam.getEnableIpLimit();
        this.ipAllow = teExam.getIpAllow();
        this.scoreStatus = teExam.getScoreStatus();
        this.objectiveScorePolicy = teExam.getObjectiveScorePolicy();
        if (Objects.nonNull(teExam.getMonitorVideoSource()) && !Objects.equals(teExam.getMonitorVideoSource().trim().replaceAll(" ", ""), "")) {
            setMonitorVideoSource(Arrays.asList(teExam.getMonitorVideoSource().trim().toUpperCase().replaceAll(" ", "").split(",")));
        } else {
            setMonitorVideoSource(null);
        }
        if (Objects.nonNull(teExam.getMonitorRecord()) && !Objects.equals(teExam.getMonitorRecord().trim().replaceAll(" ", ""), "")) {
            setMonitorRecord(Arrays.asList(teExam.getMonitorRecord().trim().toUpperCase().replaceAll(" ", "").split(",")));
        } else {
            setMonitorRecord(null);
        }
//        this.monitorRecord = teExam.getMonitorRecord();
        this.progress = teExam.getProgress();
        setCreateId(teExam.getCreateId());
        setCreateTime(teExam.getCreateTime());
        setUpdateId(teExam.getUpdateId());
        setUpdateTime(teExam.getUpdateTime());
        this.invigilateVerify = teExam.getInvigilateVerify();
        this.examStudentCallEnable = teExam.getExamStudentCallEnable();
    }

    public Integer getExamStudentCallEnable() {
        return examStudentCallEnable;
    }

    public void setExamStudentCallEnable(Integer examStudentCallEnable) {
        this.examStudentCallEnable = examStudentCallEnable;
    }

    public InvigilateMonitorStatusEnum getMonitorStatus() {
        return monitorStatus;
    }

    public void setMonitorStatus(InvigilateMonitorStatusEnum monitorStatus) {
        this.monitorStatus = monitorStatus;
    }

    public Integer getInProcessRealnessVerify() {
        return inProcessRealnessVerify;
    }

    public void setInProcessRealnessVerify(Integer inProcessRealnessVerify) {
        this.inProcessRealnessVerify = inProcessRealnessVerify;
    }

    public InvigilateVerifyEnum getInvigilateVerify() {
        return invigilateVerify;
    }

    public void setInvigilateVerify(InvigilateVerifyEnum invigilateVerify) {
        this.invigilateVerify = invigilateVerify;
    }

//    public Integer getMobilePhotoUpload() {
//        return mobilePhotoUpload;
//    }
//
//    public void setMobilePhotoUpload(Integer mobilePhotoUpload) {
//        this.mobilePhotoUpload = mobilePhotoUpload;
//    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public String getShortCode() {
        return shortCode;
    }

    public void setShortCode(String shortCode) {
        this.shortCode = shortCode;
    }

    public Integer getPrepareSeconds() {
        return prepareSeconds;
    }

    public void setPrepareSeconds(Integer prepareSeconds) {
        this.prepareSeconds = prepareSeconds;
    }

    public Integer getMinDurationSeconds() {
        return minDurationSeconds;
    }

    public void setMinDurationSeconds(Integer minDurationSeconds) {
        this.minDurationSeconds = minDurationSeconds;
    }

    public String getPreNotice() {
        return preNotice;
    }

    public void setPreNotice(String preNotice) {
        this.preNotice = preNotice;
    }

    public Integer getPreNoticeStaySeconds() {
        return preNoticeStaySeconds;
    }

    public void setPreNoticeStaySeconds(Integer preNoticeStaySeconds) {
        this.preNoticeStaySeconds = preNoticeStaySeconds;
    }

    public String getPostNotice() {
        return postNotice;
    }

    public void setPostNotice(String postNotice) {
        this.postNotice = postNotice;
    }

    public Integer getExamCount() {
        return examCount;
    }

    public void setExamCount(Integer examCount) {
        this.examCount = examCount;
    }

    public Integer getBreakExpireSeconds() {
        return breakExpireSeconds;
    }

    public void setBreakExpireSeconds(Integer breakExpireSeconds) {
        this.breakExpireSeconds = breakExpireSeconds;
    }

    public Integer getBreakResumeCount() {
        return breakResumeCount;
    }

    public void setBreakResumeCount(Integer breakResumeCount) {
        this.breakResumeCount = breakResumeCount;
    }

    public Integer getCameraPhotoUpload() {
        return cameraPhotoUpload;
    }

    public void setCameraPhotoUpload(Integer cameraPhotoUpload) {
        this.cameraPhotoUpload = cameraPhotoUpload;
    }

    public Integer getReexamAuditing() {
        return reexamAuditing;
    }

    public void setReexamAuditing(Integer reexamAuditing) {
        this.reexamAuditing = reexamAuditing;
    }

    public Integer getShowObjectiveScore() {
        return showObjectiveScore;
    }

    public void setShowObjectiveScore(Integer showObjectiveScore) {
        this.showObjectiveScore = showObjectiveScore;
    }

    public ExamModeEnum getMode() {
        return mode;
    }

    public void setMode(ExamModeEnum mode) {
        this.mode = mode;
    }

    public Integer getEnable() {
        return enable;
    }

    public void setEnable(Integer enable) {
        this.enable = enable;
    }

    public Integer getArchived() {
        return archived;
    }

    public void setArchived(Integer archived) {
        this.archived = archived;
    }

    public Integer getOpeningSeconds() {
        return openingSeconds;
    }

    public void setOpeningSeconds(Integer openingSeconds) {
        this.openingSeconds = openingSeconds;
    }

    public Integer getMaxDurationSeconds() {
        return maxDurationSeconds;
    }

    public void setMaxDurationSeconds(Integer maxDurationSeconds) {
        this.maxDurationSeconds = maxDurationSeconds;
    }

    public Integer getForceFinish() {
        return forceFinish;
    }

    public void setForceFinish(Integer forceFinish) {
        this.forceFinish = forceFinish;
    }

    public EntryAuthenticationPolicyEnum getEntryAuthenticationPolicy() {
        return entryAuthenticationPolicy;
    }

    public void setEntryAuthenticationPolicy(EntryAuthenticationPolicyEnum entryAuthenticationPolicy) {
        this.entryAuthenticationPolicy = entryAuthenticationPolicy;
    }

    public Integer getInProcessFaceVerify() {
        return inProcessFaceVerify;
    }

    public void setInProcessFaceVerify(Integer inProcessFaceVerify) {
        this.inProcessFaceVerify = inProcessFaceVerify;
    }

    public Integer getInProcessFaceStrangerIgnore() {
        return inProcessFaceStrangerIgnore;
    }

    public void setInProcessFaceStrangerIgnore(Integer inProcessFaceStrangerIgnore) {
        this.inProcessFaceStrangerIgnore = inProcessFaceStrangerIgnore;
    }

    public Integer getInProcessLivenessVerify() {
        return inProcessLivenessVerify;
    }

    public void setInProcessLivenessVerify(Integer inProcessLivenessVerify) {
        this.inProcessLivenessVerify = inProcessLivenessVerify;
    }

    public List<Integer> getInProcessLivenessFixedRange() {
        return inProcessLivenessFixedRange;
    }

    public void setInProcessLivenessFixedRange(List<Integer> inProcessLivenessFixedRange) {
        this.inProcessLivenessFixedRange = inProcessLivenessFixedRange;
    }

    public InProcessLivenessJudgePolicyEnum getInProcessLivenessJudgePolicy() {
        return inProcessLivenessJudgePolicy;
    }

    public void setInProcessLivenessJudgePolicy(InProcessLivenessJudgePolicyEnum inProcessLivenessJudgePolicy) {
        this.inProcessLivenessJudgePolicy = inProcessLivenessJudgePolicy;
    }

    public RecordSelectStrategyEnum getRecordSelectStrategy() {
        return recordSelectStrategy;
    }

    public void setRecordSelectStrategy(RecordSelectStrategyEnum recordSelectStrategy) {
        this.recordSelectStrategy = recordSelectStrategy;
    }

    public Integer getEnableIpLimit() {
        return enableIpLimit;
    }

    public void setEnableIpLimit(Integer enableIpLimit) {
        this.enableIpLimit = enableIpLimit;
    }

    public String getIpAllow() {
        return ipAllow;
    }

    public void setIpAllow(String ipAllow) {
        this.ipAllow = ipAllow;
    }

    public ScoreStatusEnum getScoreStatus() {
        return scoreStatus;
    }

    public void setScoreStatus(ScoreStatusEnum scoreStatus) {
        this.scoreStatus = scoreStatus;
    }

    public ObjectiveScorePolicyEnum getObjectiveScorePolicy() {
        return objectiveScorePolicy;
    }

    public void setObjectiveScorePolicy(ObjectiveScorePolicyEnum objectiveScorePolicy) {
        this.objectiveScorePolicy = objectiveScorePolicy;
    }

    public List<String> getMonitorVideoSource() {
        return monitorVideoSource;
    }

    public void setMonitorVideoSource(List<String> monitorVideoSource) {
        this.monitorVideoSource = monitorVideoSource;
    }

    public List<String> getMonitorRecord() {
        return monitorRecord;
    }

    public void setMonitorRecord(List<String> monitorRecord) {
        this.monitorRecord = monitorRecord;
    }

    public Double getProgress() {
        return progress;
    }

    public void setProgress(Double progress) {
        this.progress = progress;
    }
}
