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

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;

import cn.com.qmth.stmms.biz.utils.ScoreItem;
import cn.com.qmth.stmms.common.enums.LibraryStatus;

@Entity
@Table(name = "m_library")
public class MarkLibrary implements Serializable {

    private static final long serialVersionUID = 7121951721670633060L;

    @Id
    @GeneratedValue
    private Integer id;

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

    /**
     * 科目CODE
     */
    @Column(name = "subject_code")
    private String subjectCode;

    /**
     * 学习中心
     */
    @Column(name = "campus_id")
    private Integer campusId;

    /**
     * 考生编号
     */
    @Column(name = "student_id")
    private Integer studentId;

    /**
     * 准考证号
     */
    @Column(name = "exam_number")
    private String examNumber;

    /**
     * 小图起始页数
     */
    @Column(name = "pic_start")
    private Integer picStart;

    /**
     * 小图数量
     */
    @Column(name = "pic_count")
    private Integer picCount;

    /**
     * 评卷员
     */
    @Column(name = "marker_id")
    private Integer markerId;

    /**
     * 评卷时间
     */
    @Column(name = "marker_time")
    private Date markerTime;

    /**
     * 评卷员给分总分
     */
    @Column(name = "marker_score")
    private Double markerScore;

    /**
     * 评卷员给分明细
     */
    @Column(name = "marker_score_list")
    private String markerScoreList;

    /**
     * 评卷时长
     */
    @Column(name = "marker_duration", nullable = false, columnDefinition = " default 0 ")
    private long markerDuration;

    /**
     * 试卷标记信息
     */
    @Column(name = "tags")
    private String tags;

    /**
     * 任务状态
     */
    @Column(name = "status")
    @Enumerated(EnumType.ORDINAL)
    private LibraryStatus status;

    public Integer getId() {
        return id;
    }

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

    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 getStudentId() {
        return studentId;
    }

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

    public String getExamNumber() {
        return examNumber;
    }

    public void setExamNumber(String examNumber) {
        this.examNumber = examNumber;
    }

    public Integer getPicCount() {
        return picCount;
    }

    public void setPicCount(Integer picCount) {
        this.picCount = picCount;
    }

    public Integer getMarkerId() {
        return markerId;
    }

    public void setMarkerId(Integer markerId) {
        this.markerId = markerId;
    }

    public Date getMarkerTime() {
        return markerTime;
    }

    public void setMarkerTime(Date markerTime) {
        this.markerTime = markerTime;
    }

    public Double getMarkerScore() {
        return markerScore;
    }

    public void setMarkerScore(Double markerScore) {
        this.markerScore = markerScore;
    }

    public String getMarkerScoreList() {
        return markerScoreList;
    }

    public void setMarkerScoreList(String markerScoreList) {
        this.markerScoreList = markerScoreList;
    }

    public LibraryStatus getStatus() {
        return status;
    }

    public void setStatus(LibraryStatus status) {
        this.status = status;
    }

    public List<ScoreItem> getScoreList() {
        List<ScoreItem> list = new LinkedList<ScoreItem>();
        if (StringUtils.isNotBlank(markerScoreList)) {
            try {
                String[] values = markerScoreList.split(",");
                for (String value : values) {
                    ScoreItem item = ScoreItem.parse(value, false);
                    if (item != null) {
                        list.add(item);
                    }
                }
            } catch (Exception e) {
            }
        }
        return list;
    }

    public Integer getCampusId() {
        return campusId;
    }

    public void setCampusId(Integer campusId) {
        this.campusId = campusId;
    }

    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        this.tags = tags;
    }

    public Integer getPicStart() {
        return picStart;
    }

    public void setPicStart(Integer picStart) {
        this.picStart = picStart;
    }

    public long getMarkerDuration() {
        return markerDuration;
    }

    public void setMarkerDuration(long markerDuration) {
        this.markerDuration = markerDuration;
    }

}
