package com.ssj.service.kmt.exercisesys.dto;

import com.alibaba.fastjson.annotation.JSONField;
import com.ssj.service.kmt.exercisesys.enums.ExerciseBookHalfBookEnum;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author yrf
 * @time 2020/5/20 16:32
 */
public class DistributionExerciseBookDTO implements Serializable {

    private static final long serialVersionUID = 8818192568415925382L;

    private String exerciseBookId;

    @JSONField(format = "yyyy.MM.dd")
    private Date importDate;

    private String subject;
    private String grade;
    private String versionName;
    private Integer semester;
    private String bookName;

    @JSONField(serialize = false)
    private Integer bookType;

    private String halfBook;
    private Integer unitNum;
    private Integer courseNum;

    @JSONField(serialize = false)
    private Integer intHandleAccuracy;
    private String handleAccuracy;

    @JSONField(serialize = false)
    private Integer intHandleAuditAccuracy;
    private String handleAuditAccuracy;

    @JSONField(serialize = false)
    private Integer intAnalysisAccuracy;
    private String analysisAccuracy;

    private String assignedBatch;

    private List<DistributionTeacherDTO> handleUserList;
    private List<DistributionTeacherDTO> auditingUserList;
    private List<DistributionTeacherDTO> analysisUserList;
    private List<DistributionTeacherDTO> analysisAuditerList;

    public String getExerciseBookId() {
        return exerciseBookId;
    }

    public void setExerciseBookId(String exerciseBookId) {
        this.exerciseBookId = exerciseBookId;
    }

    public Date getImportDate() {
        return importDate;
    }

    public void setImportDate(Date importDate) {
        this.importDate = importDate;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public String getVersionName() {
        return versionName;
    }

    public void setVersionName(String versionName) {
        this.versionName = versionName;
    }

    public Integer getSemester() {
        return semester;
    }

    public void setSemester(Integer semester) {
        this.semester = semester;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public Integer getBookType() {
        return bookType;
    }

    public void setBookType(Integer bookType) {
        this.bookType = bookType;
    }

    public String getHalfBook() {
        if (StringUtils.isNotBlank(halfBook)) {
            return halfBook;
        }

        halfBook = ExerciseBookHalfBookEnum.getDescriptionByCode(bookType);

        return halfBook;
    }

    public void setHalfBook(String halfBook) {
        this.halfBook = halfBook;
    }

    public Integer getUnitNum() {
        return unitNum;
    }

    public void setUnitNum(Integer unitNum) {
        this.unitNum = unitNum;
    }

    public Integer getCourseNum() {
        return courseNum;
    }

    public void setCourseNum(Integer courseNum) {
        this.courseNum = courseNum;
    }

    public Integer getIntHandleAccuracy() {
        return intHandleAccuracy;
    }

    public void setIntHandleAccuracy(Integer intHandleAccuracy) {
        this.intHandleAccuracy = intHandleAccuracy;
    }

    public String getHandleAccuracy() {
        if (StringUtils.isBlank(handleAccuracy) && intHandleAccuracy != null) {
            handleAccuracy = BigDecimal.valueOf(intHandleAccuracy * 0.01).setScale(2, BigDecimal.ROUND_DOWN).toPlainString();
        }
        return handleAccuracy;
    }

    public void setHandleAccuracy(String handleAccuracy) {
        this.handleAccuracy = handleAccuracy;
    }

    public Integer getIntHandleAuditAccuracy() {
        return intHandleAuditAccuracy;
    }

    public void setIntHandleAuditAccuracy(Integer intHandleAuditAccuracy) {
        this.intHandleAuditAccuracy = intHandleAuditAccuracy;
    }

    public String getHandleAuditAccuracy() {
        if (StringUtils.isBlank(handleAuditAccuracy) && intHandleAuditAccuracy != null) {
            handleAuditAccuracy = BigDecimal.valueOf(intHandleAuditAccuracy * 0.01).setScale(2, BigDecimal.ROUND_DOWN).toPlainString();
        }
        return handleAuditAccuracy;
    }

    public void setHandleAuditAccuracy(String handleAuditAccuracy) {
        this.handleAuditAccuracy = handleAuditAccuracy;
    }

    public Integer getIntAnalysisAccuracy() {
        return intAnalysisAccuracy;
    }

    public void setIntAnalysisAccuracy(Integer intAnalysisAccuracy) {
        this.intAnalysisAccuracy = intAnalysisAccuracy;
    }

    public String getAnalysisAccuracy() {
        if (StringUtils.isBlank(analysisAccuracy) && intAnalysisAccuracy != null) {
            analysisAccuracy = BigDecimal.valueOf(intAnalysisAccuracy * 0.01).setScale(2, BigDecimal.ROUND_DOWN).toPlainString();
        }
        return analysisAccuracy;
    }

    public void setAnalysisAccuracy(String analysisAccuracy) {
        this.analysisAccuracy = analysisAccuracy;
    }

    public List<DistributionTeacherDTO> getHandleUserList() {
        if (handleUserList != null) {
            Collections.sort(handleUserList);
        }
        return handleUserList;
    }

    public void setHandleUserList(List<DistributionTeacherDTO> handleUserList) {
        this.handleUserList = handleUserList;
    }

    public List<DistributionTeacherDTO> getAuditingUserList() {
        if (auditingUserList != null) {
            Collections.sort(auditingUserList);
        }
        return auditingUserList;
    }

    public void setAuditingUserList(List<DistributionTeacherDTO> auditingUserList) {
        this.auditingUserList = auditingUserList;
    }

    public List<DistributionTeacherDTO> getAnalysisUserList() {
        if (analysisUserList != null) {
            Collections.sort(analysisUserList);
        }
        return analysisUserList;
    }

    public void setAnalysisUserList(List<DistributionTeacherDTO> analysisUserList) {
        this.analysisUserList = analysisUserList;
    }

    public List<DistributionTeacherDTO> getAnalysisAuditerList() {
        if (analysisAuditerList != null) {
            Collections.sort(analysisAuditerList);
        }
        return analysisAuditerList;
    }

    public void setAnalysisAuditerList(List<DistributionTeacherDTO> analysisAuditerList) {
        this.analysisAuditerList = analysisAuditerList;
    }

    public String getAssignedBatch() {
        return assignedBatch;
    }

    public void setAssignedBatch(String assignedBatch) {
        this.assignedBatch = assignedBatch;
    }
}
