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

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;

import cn.com.qmth.stmms.biz.utils.QuestionNumberBean;
import cn.com.qmth.stmms.biz.utils.QuestionNumberComparator;

import java.io.Serializable;

/**
 * 主观题得分详情状态
 */
@Entity
@Table(name = "eb_subjective_score")
public class SubjectiveScore implements Serializable, Comparable<SubjectiveScore>, QuestionNumberBean {

    private static final long serialVersionUID = 6637010422161820147L;

    @EmbeddedId
    private SubjectiveScorePK pk;

    /**
     * 考试ID
     */
    @Column(name = "exam_id", nullable = false)
    private Integer examId;

    /**
     * 科目代码
     */
    @Column(name = "subject_code", length = 32, nullable = false)
    private String subjectCode;

    /**
     * 分组序号
     */
    @Column(name = "group_number", nullable = false)
    private Integer groupNumber;

    /**
     * 分组总分
     */
    @Column(name = "group_score", nullable = false)
    private Double groupScore;

    /**
     * 大题总分
     */
    @Column(name = "main_score", nullable = false)
    private Double mainScore;

    /**
     * 小题得分
     */
    @Column(name = "score", nullable = false)
    private Double score;

    /**
     * 未作答的步骤数量
     */
    @Column(name = "unanswered_count", nullable = false)
    private Integer unansweredCount;

    /**
     * 未计分
     */
    @Column(name = "uncalculate", nullable = false)
    private Boolean uncalculate;

    /**
     * 未计分
     */
    @Column(name = "rejected", nullable = false)
    private Boolean rejected;

    public SubjectiveScore() {
        this.pk = new SubjectiveScorePK();
    }

    public Integer getStudentId() {
        return pk.getStudentId();
    }

    public void setStudentId(Integer studentId) {
        this.pk.setStudentId(studentId);
    }

    public Integer getMainNumber() {
        return pk.getMainNumber();
    }

    public void setMainNumber(Integer mainNumber) {
        this.pk.setMainNumber(mainNumber);
    }

    public String getSubNumber() {
        return pk.getSubNumber();
    }

    public void setSubNumber(String subNumber) {
        this.pk.setSubNumber(subNumber);
    }

    public Integer getExamId() {
        return examId;
    }

    public void setExamId(Integer examId) {
        this.examId = examId;
    }

    public String getSubjectCode() {
        return subjectCode;
    }

    public void setSubjectCode(String subjectCode) {
        this.subjectCode = subjectCode;
    }

    public Integer getGroupNumber() {
        return groupNumber;
    }

    public void setGroupNumber(Integer groupNumber) {
        this.groupNumber = groupNumber;
    }

    public Double getGroupScore() {
        return groupScore;
    }

    public void setGroupScore(Double groupScore) {
        this.groupScore = groupScore;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    public Double getMainScore() {
        return mainScore;
    }

    public void setMainScore(Double mainScore) {
        this.mainScore = mainScore;
    }

    public Integer getUnansweredCount() {
        return unansweredCount;
    }

    public void setUnansweredCount(Integer unansweredCount) {
        this.unansweredCount = unansweredCount;
    }

    @Override
    public int compareTo(SubjectiveScore other) {
        // int i = this.getMainNumber() - other.getMainNumber();
        // if (i == 0) {
        // if (this.getSubNumber().contains("-")) {
        // String[] o1s = this.getSubNumber().split("-");
        // String[] o2s = other.getSubNumber().split("-");
        // int j = Integer.parseUnsignedInt(o1s[0]) -
        // Integer.parseUnsignedInt(o2s[0]);
        // if (j == 0) {
        // return Integer.parseUnsignedInt(o1s[1]) -
        // Integer.parseUnsignedInt(o2s[1]);
        // } else {
        // return j;
        // }
        // } else {
        // return Integer.parseUnsignedInt(this.getSubNumber()) -
        // Integer.parseUnsignedInt(other.getSubNumber());
        // }
        // }
        return QuestionNumberComparator.instance.compare(this, other);
    }

    public Boolean getUncalculate() {
        return uncalculate;
    }

    public void setUncalculate(Boolean uncalculate) {
        this.uncalculate = uncalculate;
    }

    public Boolean getRejected() {
        return rejected;
    }

    public void setRejected(Boolean rejected) {
        this.rejected = rejected;
    }

}
