package com.qmth.teachcloud.mark.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.teachcloud.common.enums.mark.MarkArbitrateStatus;
import com.qmth.teachcloud.mark.dto.mark.ScoreItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

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

/**
 * <p>
 * 仲裁记录表
 * </p>
 *
 * @author xf
 * @since 2023-09-22
 */
@TableName("mark_arbitrate_history")
@ApiModel(value = "MarkArbitrateHistory对象", description = "仲裁记录表")
public class MarkArbitrateHistory implements Serializable {

    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "主键")
    @TableId(value = "id")
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "考试ID")
    private Long examId;

    @ApiModelProperty(value = "试卷编号")
    private String paperNumber;

    @ApiModelProperty(value = "大题号")
    private Integer groupNumber;

    @ApiModelProperty(value = "准考证号")
    private String studentCode;

    @ApiModelProperty(value = "考生密号")
    private String secretNumber;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "考生ID")
    private Long studentId;

    @ApiModelProperty(value = "状态")
    private MarkArbitrateStatus status;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "处理人ID")
    private Long updateUserId;

    @ApiModelProperty(value = "总分")
    private Double totalScore;

    @ApiModelProperty(value = "给分明细")
    private String scoreList;

    @ApiModelProperty(value = "创建时间")
    private Long createTime;

    @ApiModelProperty(value = "处理时间")
    private Long updateTime;

    public Long getId() {
        return id;
    }

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

    public Long getExamId() {
        return examId;
    }

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

    public String getPaperNumber() {
        return paperNumber;
    }

    public void setPaperNumber(String paperNumber) {
        this.paperNumber = paperNumber;
    }

    public Integer getGroupNumber() {
        return groupNumber;
    }

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

    public String getStudentCode() {
        return studentCode;
    }

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

    public String getSecretNumber() {
        return secretNumber;
    }

    public void setSecretNumber(String secretNumber) {
        this.secretNumber = secretNumber;
    }

    public Long getStudentId() {
        return studentId;
    }

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

    public MarkArbitrateStatus getStatus() {
        return status;
    }

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

    public Long getUpdateUserId() {
        return updateUserId;
    }

    public void setUpdateUserId(Long updateUserId) {
        this.updateUserId = updateUserId;
    }

    public Double getTotalScore() {
        return totalScore;
    }

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

    public String getScoreList() {
        return scoreList;
    }

    public void setScoreList(String scoreList) {
        this.scoreList = scoreList;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

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

    @Override
    public String toString() {
        return "MarkArbitrateHistory{" +
                "id=" + id +
                ", examId=" + examId +
                ", paperNumber=" + paperNumber +
                ", groupNumber=" + groupNumber +
                ", studentCode=" + studentCode +
                ", secretNumber=" + secretNumber +
                ", studentId=" + studentId +
                ", status=" + status +
                ", updateUserId=" + updateUserId +
                ", totalScore=" + totalScore +
                ", scoreList=" + scoreList +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                "}";
    }
}
