package cn.com.qmth.stmms.admin.dto;

import java.util.LinkedList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import cn.com.qmth.stmms.biz.exam.model.ExamStudent;
import cn.com.qmth.stmms.biz.utils.ScoreItem;
import cn.com.qmth.stmms.common.annotation.ExcelField;

public class ExamStudentDTO {

    @ExcelField(title = "课程代码", align = 2, sort = 20)
    private String subjectCode;

    @ExcelField(title = "课程名称", align = 2, sort = 30)
    private String subjectName;

    @ExcelField(title = "层次", align = 2, sort = 40)
    private String subjectLevel;

    @ExcelField(title = "专业类型", align = 2, sort = 50)
    private String subjectCategory;

    @ExcelField(title = "准考证号", align = 2, sort = 60)
    private String examNumber;

    @ExcelField(title = "学号", align = 2, sort = 70)
    private String studentCode;

    @ExcelField(title = "姓名", align = 2, sort = 80)
    private String name;

    @ExcelField(title = "客观总分", align = 2, sort = 90)
    private String objectiveScore;

    @ExcelField(title = "主观总分", align = 2, sort = 100)
    private String subjectiveScore;

    @ExcelField(title = "总分", align = 2, sort = 110)
    private String totalScore;

    @ExcelField(title = "违纪", align = 2, sort = 120)
    private String breach;

    @ExcelField(title = "评分明细", align = 2, sort = 130)
    private String subjectiveScoreList;

    @ExcelField(title = "备注", align = 2, sort = 140)
    private String remark;

    @ExcelField(title = "机组", align = 2, sort = 150)
    private String className;

    @ExcelField(title = "电厂", align = 2, sort = 160)
    private String college;

    @ExcelField(title = "总评", align = 2, sort = 170)
    private String teacher;

    private List<ScoreItem> objectiveList;

    private List<String> subjectiveList;

    public static final String SPLIT = ";";

    public ExamStudentDTO(ExamStudent student) {
        setSubjectCode(student.getSubjectCode());
        setSubjectName(student.getSubjectName());
        setSubjectLevel(student.getSubjectLevel());
        setSubjectCategory(student.getSubjectCategory());
        setExamNumber(student.getExamNumber());
        setStudentCode(student.getStudentCode());
        setName(student.getName());
        setSubjectiveScoreList(StringUtils.trimToEmpty(student.getSubjectiveScoreList()));
        if (!student.isUpload() || student.isAbsent()) {
            setTotalScore("-");
            setObjectiveScore("-");
            setSubjectiveScore("-");
        } else {
            setObjectiveScore(String.valueOf(student.getObjectiveScore()));
            setSubjectiveScore(String.valueOf(student.getSubjectiveScore()));
            setTotalScore(String.valueOf(student.getTotalScore()));
        }
        if (student.isBreach()) {
            setBreach("是");
        } else {
            setBreach("否");
        }
        setRemark(StringUtils.trimToEmpty(student.getRemark()));
        setClassName(student.getClassName());
        setCollege(student.getCollege());
        setTeacher(student.getTeacher());
        setObjectiveList(student.getScoreList(true));
        List<String> subjectiveList = new LinkedList<String>();
        if (StringUtils.isNotBlank(student.getSubjectiveScoreList())) {
            String[] values = StringUtils.split(student.getSubjectiveScoreList(), SPLIT);
            for (String value : values) {
                subjectiveList.add(value);
            }
        }
        setSubjectiveList(subjectiveList);
    }

    public String getSubjectCode() {
        return subjectCode;
    }

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

    public String getSubjectName() {
        return subjectName;
    }

    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }

    public String getStudentCode() {
        return studentCode;
    }

    public void setStudentCode(String studentCode) {
        this.studentCode = studentCode;
    }

    public String getName() {
        return name;
    }

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

    public String getExamNumber() {
        return examNumber;
    }

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

    public String getTotalScore() {
        return totalScore;
    }

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

    public String getObjectiveScore() {
        return objectiveScore;
    }

    public void setObjectiveScore(String objectiveScore) {
        this.objectiveScore = objectiveScore;
    }

    public String getSubjectiveScore() {
        return subjectiveScore;
    }

    public void setSubjectiveScore(String subjectiveScore) {
        this.subjectiveScore = subjectiveScore;
    }

    public String getSubjectiveScoreList() {
        return subjectiveScoreList;
    }

    public void setSubjectiveScoreList(String subjectiveScoreList) {
        this.subjectiveScoreList = subjectiveScoreList;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getSubjectLevel() {
        return subjectLevel;
    }

    public void setSubjectLevel(String subjectLevel) {
        this.subjectLevel = subjectLevel;
    }

    public String getSubjectCategory() {
        return subjectCategory;
    }

    public void setSubjectCategory(String subjectCategory) {
        this.subjectCategory = subjectCategory;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getTeacher() {
        return teacher;
    }

    public void setTeacher(String teacher) {
        this.teacher = teacher;
    }

    public List<ScoreItem> getObjectiveList() {
        return objectiveList;
    }

    public void setObjectiveList(List<ScoreItem> objectiveList) {
        this.objectiveList = objectiveList;
    }

    public List<String> getSubjectiveList() {
        return subjectiveList;
    }

    public void setSubjectiveList(List<String> subjectiveList) {
        this.subjectiveList = subjectiveList;
    }

    public String getBreach() {
        return breach;
    }

    public void setBreach(String breach) {
        this.breach = breach;
    }

}
