package com.qmth.themis.business.entity;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.themis.business.constant.SystemConstant;
import com.qmth.themis.business.util.UidUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 同步云阅卷考生成绩表
 * </p>
 *
 * @author wangliang
 * @since 2022-07-14
 */
@ApiModel(value = "TSyncExamStudentScore对象", description = "同步云阅卷考生成绩表")
public class TSyncExamStudentScore implements Serializable {

    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty(value = "考试批次id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long examBatchId;

    @ApiModelProperty(value = "学院")
    private String college;

    @ApiModelProperty(value = "客观题分数")
    private Double objectiveScore;

    @ApiModelProperty(value = "卷型")
    private String paperType;

    @ApiModelProperty(value = "考试编码")
    private String examCode;

    @ApiModelProperty(value = "学号")
    private String studentCode;

    @ApiModelProperty(value = "班级")
    private String clazzName;

    @ApiModelProperty(value = "主观题分数明细")
    private String subjectiveScoreDetail;

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

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

    @ApiModelProperty(value = "原卷url")
    private String sheetUrls;

    @ApiModelProperty(value = "教师")
    private String teacher;

    @ApiModelProperty(value = "客观题分数明细")
    private String objectiveScoreDetail;

    @ApiModelProperty(value = "云阅卷考试id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long examId;

    @ApiModelProperty(value = "姓名")
    private String name;

    @ApiModelProperty(value = "主观题分数")
    private Double subjectiveScore;

    @ApiModelProperty(value = "科目编码")
    private String subjectCode;

    @ApiModelProperty(value = "科目名称")
    private String subjectName;

    @ApiModelProperty(value = "考生状态，1-正常，2-缺考(包含未上传)，3-违纪")
    private Integer status;

    @ApiModelProperty(value = "创建人id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long createId;

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

    public TSyncExamStudentScore() {

    }

    public TSyncExamStudentScore(Map map) {
        this.id = UidUtil.nextId();
        this.examBatchId = Long.parseLong(String.valueOf(map.get("exam_batch_id")));
        this.examId = Long.parseLong(String.valueOf(map.get("examId")));
        this.examCode = (String) map.get("examCode");
        this.examNumber = (String) map.get("examNumber");
        this.studentCode = (String) map.get("studentCode");
        this.name = (String) map.get("name");
        this.subjectCode = (String) map.get("subjectCode");
        this.subjectName = (String) map.get("subjectName");
        this.paperType = (String) map.get("paperType");
        this.college = (String) map.get("college");
        this.clazzName = (String) map.get("className");
        this.teacher = (String) map.get("teacher");
        this.status = (Integer) map.get("status");
        JSONArray jsonArray = (JSONArray) map.get("sheetUrls");
        if (Objects.nonNull(jsonArray) && jsonArray.size() > 0) {
            this.sheetUrls = jsonArray.toJSONString();
        }
        this.totalScore = Double.parseDouble(String.valueOf(map.get("totalScore")));
        this.objectiveScore = Double.parseDouble(String.valueOf(map.get("objectiveScore")));
        this.subjectiveScore = Double.parseDouble(String.valueOf(map.get("subjectiveScore")));
        this.createId = (Long) map.get(SystemConstant.CREATE_ID);
        this.createTime = System.currentTimeMillis();

        JSONArray objectiveScoreDetailJsonArray = (JSONArray) map.get("objectiveScoreDetail");
        JSONArray subjectiveScoreDetailJsonArray = (JSONArray) map.get("subjectiveScoreDetail");
        if (Objects.nonNull(objectiveScoreDetailJsonArray) && objectiveScoreDetailJsonArray.size() > 0) {
            this.objectiveScoreDetail = objectiveScoreDetailJsonArray.toJSONString();
        }
        if (Objects.nonNull(subjectiveScoreDetailJsonArray) && subjectiveScoreDetailJsonArray.size() > 0) {
            this.subjectiveScoreDetail = subjectiveScoreDetailJsonArray.toJSONString();
        }
    }

    public Long getId() {
        return id;
    }

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

    public Long getExamBatchId() {
        return examBatchId;
    }

    public void setExamBatchId(Long examBatchId) {
        this.examBatchId = examBatchId;
    }

    public String getCollege() {
        return college;
    }

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

    public Double getObjectiveScore() {
        return objectiveScore;
    }

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

    public String getPaperType() {
        return paperType;
    }

    public void setPaperType(String paperType) {
        this.paperType = paperType;
    }

    public String getExamCode() {
        return examCode;
    }

    public void setExamCode(String examCode) {
        this.examCode = examCode;
    }

    public String getStudentCode() {
        return studentCode;
    }

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

    public String getClazzName() {
        return clazzName;
    }

    public void setClazzName(String clazzName) {
        this.clazzName = clazzName;
    }

    public String getSubjectiveScoreDetail() {
        return subjectiveScoreDetail;
    }

    public void setSubjectiveScoreDetail(String subjectiveScoreDetail) {
        this.subjectiveScoreDetail = subjectiveScoreDetail;
    }

    public String getExamNumber() {
        return examNumber;
    }

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

    public Double getTotalScore() {
        return totalScore;
    }

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

    public String getSheetUrls() {
        return sheetUrls;
    }

    public void setSheetUrls(String sheetUrls) {
        this.sheetUrls = sheetUrls;
    }

    public String getTeacher() {
        return teacher;
    }

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

    public String getObjectiveScoreDetail() {
        return objectiveScoreDetail;
    }

    public void setObjectiveScoreDetail(String objectiveScoreDetail) {
        this.objectiveScoreDetail = objectiveScoreDetail;
    }

    public Long getExamId() {
        return examId;
    }

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

    public String getName() {
        return name;
    }

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

    public Double getSubjectiveScore() {
        return subjectiveScore;
    }

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

    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 Integer getStatus() {
        return status;
    }

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

    public Long getCreateId() {
        return createId;
    }

    public void setCreateId(Long createId) {
        this.createId = createId;
    }

    public Long getCreateTime() {
        return createTime;
    }

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