package cn.com.qmth.stmms.ms.core.domain;

import cn.com.qmth.stmms.ms.core.domain.enums.TrialEnum;
import cn.com.qmth.stmms.ms.core.vo.Subject;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 科目
 * Created by zhengmin on 2016/9/21.
 */
@Entity
public class MarkSubject implements Serializable {

    private static final long serialVersionUID = -7205062745569303448L;

    /**
     * workId + "-" + subject
     */
    @Id
    private String id;

    private String name;

    private Long workId;

    private int totalScore = 100;

    private String collectConfig;

    @Enumerated(value = EnumType.ORDINAL)
    private MarkStage stage;

    /**
     * 标准卷
     */
    private int sampleCount;

    @Basic
    @Column(name = "is_test")
    private int test; //是否试评，1:数据已导入，2:试评中，3:正式任务

    @Basic
    @Column(name = "is_formal")
    private boolean formal;//是否正评，0:不是，1:是

    @Basic
    @Column(name = "all_level")
    private boolean allLevel;//是否全部根据档位分配完，0:不是，1:是

    //是否禁用0：禁用 1：启用
    private boolean enable;

    public boolean isAllLevel() {
        return allLevel;
    }

    public void setAllLevel(boolean allLevel) {
        this.allLevel = allLevel;
    }

    public boolean isFormal() {
        return formal;
    }

    public void setFormal(boolean formal) {
        this.formal = formal;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public int getTest() {
        return test == TrialEnum.START_FORMAL.getId() ? TrialEnum.DEFAULT.getId() : test;
    }

    public void setTest(int test) {
        this.test = test;
    }

    public MarkSubject(Subject subject, Long workId) {
        this.id = workId + "-" + subject;
        this.name = subject.getName();
        this.stage = MarkStage.INIT;
    }

    public MarkSubject(String name, Subject subject, Long workId) {
        this.id = workId + "-" + subject;
        this.name = name;
        this.stage = MarkStage.INIT;
    }

    public MarkSubject() {
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

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

    public int getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(int totalScore) {
        this.totalScore = totalScore;
    }

    public MarkStage getStage() {
        return stage;
    }

    public void setStage(MarkStage stage) {
        this.stage = stage;
    }

    public Long getWorkId() {
        return Long.parseLong(this.getId().split("-")[0]);
    }

    public Subject getSubject() {
        return Subject.valueOf(this.getId().split("-")[1]);
    }

    public void setWorkId(Long workId) {
        this.workId = workId;
    }

    public String getCollectConfig() {
        return collectConfig;
    }

    public void setCollectConfig(String collectConfig) {
        this.collectConfig = collectConfig;
    }

    public int getSampleCount() {
        return sampleCount;
    }

    public void setSampleCount(int sampleCount) {
        this.sampleCount = sampleCount;
    }

    public boolean isEnable() {
        return enable;
    }

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