package jnpf.model.cultivate.po.exam;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import jnpf.base.entity.SuperEntity;
import lombok.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.UUID;

/**
 * 考试用户表
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "ftb_cultivate_exam_user")
public class FtbCultivateExamUser extends SuperEntity.SuperCUBaseEntity<String> {

    /**
     * 考试主键ID
     */
    @TableField(value = "F_ExamId")
    private String examId;

    /**
     * 用户主键ID
     */
    @TableField(value = "F_UserId")
    private String userId;

    /**
     * 用时，单位秒
     */
    @TableField(value = "F_Duration")
    private Long duration;

    /**
     * 考试时限(秒)
     */
    @TableField(value = "F_ExamTime")
    private Integer examTime;

    /**
     * 总考分
     */
    @TableField(value = "F_Score")
    private Integer score;
    /**
     * 批阅分数
     */
    @TableField(value = "F_ReadOverScore")
    private Integer readOverScore;
    /**
     * 自动阅卷分数
     */
    @TableField(value = "F_AutoScore")
    private Integer autoScore;


    /**
     * 用户开始考试的时间
     */
    @TableField(value = "F_UserStartTime")
    private Date userStartTime;
    /**
     * 用户完成考试时间
     */
    @TableField(value = "F_FinishTime")
    private Date finishTime;

    /**
     * 考试状态（0待考试，1待批阅，2已逾期，3合格，4不合格 5优秀）
     */
    @TableField(value = "F_Status")
    private Integer status;

    /**
     * 排名，用于百分比合格判断是否通过
     */
    @TableField(value = "F_Rank")
    private Integer ranks;


    /**
     * 有效标志 有效标志，0无效 1有效
     */
    @TableField(value = "F_EnabledMark")
    private Integer enabledMark;


    /**
     * 删除用户
     */
    @TableField(value = "F_DeleteUserId")
    private String deleteUserId;

    /**
     * 删除时间
     */
    @TableField(value = "F_DeleteTime")
    private Date deleteTime;

    /**
     * 考试内容,json数组，包含每一个题目，用户历史追溯
     */
    @TableField(value = "F_Content")
    private String content;

    /**
     * 开始考试时间
     */
    @TableField(value = "F_StartTime")
    private Date startTime;

    /**
     * 正确数
     */
    @TableField(value = "F_correctCount")
    private Integer correctCount;

    /**
     * 试卷名称
     */
    @TableField(value = "F_PaperId")
    private String paperId;

    /**
     * 考试截止时间
     */
    @TableField(value = "F_EndTime")
    private Date endTime;

    /**
     * 考试类型,0岗位学习考试,1常规考试
     */
    @TableField(value = "F_ExamType")
    private Integer examType;

    /**
     * 考试批次，重复考试
     */
    @TableField(value = "F_Batch")
    private String batch;


    /**
     * 来源：1、岗位学习课程关联考试，2、岗位学习 3、常规考试 4-任务考试
     */
    @TableField(value = "F_ExamSource")
    private Integer examSource;


    /**
     * 岗位ID
     */
    @TableField(value = "F_RelationPositionId")
    private String relationPositionId;
    /**
     * 职等ID
     */
    @TableField(value = "F_RelationRankId")
    private String relationRankId;

    /**
     * 岗位学习关联考试
     */
    @TableField(value = "F_RelationPositionExamId")
    private String relationPositionExamId;
    /**
     * 课程关联考试
     */
    @TableField(value = "F_RelationCourseExamId")
    private String relationCourseExamId;

    /**
     * 可阅卷人ID,逗号分割
     */
    @TableField(value = "F_ReviewerUserIds")
    private String reviewerUserIds;

    /**
     * 可以阅卷的角色
     */
    @TableField(value = "F_ReviewerRoleId")
    private String reviewerRoleId;


    /**
     * 实际批阅人id
     */
    @TableField(value = "F_ReviewerUserId")
    private String reviewerUserId;


    /**
     * 是否在App上显示 0显示 1不显示
     */
    @TableField(value = "F_AppShow")
    private Integer appShow;

    /**
     * 用户组织列表，逗号分割，方便统计
     */
    @TableField(value = "F_UserOrgList")
    private String userOrgList;

    /**
     * 用户第几次考试
     */
    @TableField(value = "F_UserExamCount")
    private Integer userExamCount;

    /**
     * 用户考试结果是否有效:0-有效,1-超过切屏次数视为作弊,2-超过考试时间无交互视为作弊'
     */
    @TableField(value = "F_UserExamResultValid")
    private Integer userExamResultValid;

    /**
     * 题目总数
     */
    @TableField(value = "F_QuestionNumber")
    private Integer questionNumber;

    /**
     * 题目的总分数
     */
    @TableField(value = "F_TotalScore")
    private Integer totalScore;

    /**
     * 合格分
     */
    @TableField(value = "F_PassScore")
    private BigDecimal passScore;

    /**
     * 优秀分
     */
    @TableField(value = "F_ExcellentScore")
    private BigDecimal excellentScore;

    /**
     * 是否加入统计，0-参加统计，1-不参加统计(同时也不批阅了)
     */
    @TableField(value = "F_IsJoinCount")
    private Integer isJoinCount;

    /**
     * 考试批次，区分考试记录归属历史
     */
    @TableField(value = "F_VersionBatch")
    private String versionBatch;


    /**
     * 得分比
     */
    @TableField(value = "F_ScoreRatio")
    private BigDecimal scoreRatio;

    /**
     * 是否是考试合格才能触发鉴定,0-否 1-是
     */
    @TableField(value = "F_ExamIdentifyConfig")
    private Integer examIdentifyConfig;

    /**
     * 是否完成鉴定,0-否 1-是
     */
    @TableField(value = "F_CompleteIdentify")
    private Integer completeIdentify;

    /**
     * 关联的任务考试ID
     */
    @TableField(value = "F_RelationTaskId")
    private String relationTaskId;

    /**
     *  是否是离职删除 0-否  1-是
     */
    @TableField(value = "F_LeaveOut")
    private Integer leaveOut;

    /**
     * 抽题规则(json)
     */
    @TableField(value = "F_PickQuestionRule")
    private String pickQuestionRule;

    /**
     * 备注
     */
    @TableField(value = "F_Remark")
    private String remark;

    /**
     * 新增自定义考试初始化
     * @param examId 考试id
     * @param userId 用户id
     * @param startTime 考试开始时间
     * @param endTime 考试结束时间
     * @param userOrgList 用户组织id
     * @param totalScore 考试总分
     * @param questionNumber 总题目数
     */
    public FtbCultivateExamUser(String examId, Integer examTime, BigDecimal passScore, BigDecimal excellentScore, String userId, Date startTime, Date endTime,
                                String userOrgList, Integer totalScore, Integer questionNumber, String pickQuestionRule) {
        this.examId = examId;
        this.examTime = examTime;
        this.passScore = passScore;
        this.excellentScore = excellentScore;
        this.userId = userId;
        this.status = 0;
        this.examType = 1;
        this.examSource = 3;
        this.startTime = startTime;
        this.endTime = endTime;
        this.batch = UUID.randomUUID().toString().replaceAll("-", "");
        this.versionBatch = "dfa";
        this.userOrgList = userOrgList;
        this.userExamCount = 1;
        this.totalScore = totalScore;
        this.questionNumber = questionNumber;
        this.pickQuestionRule = pickQuestionRule;
    }
}