package com.qmth.jkserver.model;

//import com.qmth.jkserver.enums.TaskResultEnum;
//import com.qmth.jkserver.enums.TaskStatusEnum;
//import com.qmth.jkserver.enums.TaskTypeEnum;
//import io.swagger.annotations.ApiModelProperty;
//import org.springframework.data.annotation.Id;
//import org.springframework.data.mongodb.core.mapping.Document;
//import org.springframework.data.mongodb.core.mapping.Field;
//
//import java.io.Serializable;
//import java.math.BigDecimal;
//import java.util.Date;
//import java.util.Objects;
//import java.util.concurrent.atomic.AtomicInteger;
//
///**
// * @Description: 云阅卷同步考试任务
// * @Param:
// * @return:
// * @Author: wangliang
// * @Date: 2021/5/11
// */
//@Document(collection = "jk_exam_task")
//public class ExamTask implements Serializable {
//
//    private static final long serialVersionUID = -6624764888197088459L;
//
//    @Id
//    private String id;
//
//    @ApiModelProperty(value = "考试编码")
//    @Field("exam_code")
//    private String examCode;
//
//    @ApiModelProperty(value = "任务类型，SYNC_YUN_MARK：云阅卷同步")
//    @Field(value = "type")
//    private TaskTypeEnum type;
//
//    @ApiModelProperty(value = "云阅卷是否同步")
//    @Field("sync")
//    private Boolean sync;
//
//    @ApiModelProperty(value = "云阅卷同步结果")
//    @Field("result")
//    private TaskResultEnum result;
//
//    @ApiModelProperty(value = "云阅卷同步次数")
//    @Field("count")
//    private Integer count;
//
//    @ApiModelProperty(value = "任务状态，INIT：未开始，RUNNING：进行中，FINISH：已完成")
//    @Field(value = "status")
//    private TaskStatusEnum status;
//
//    @ApiModelProperty(value = "实时摘要信息")
//    @Field(value = "summary")
//    private String summary;
//
//    @ApiModelProperty(value = "总进度")
//    @Field(value = "total_progress")
//    private BigDecimal totalProgress;
//
//    @ApiModelProperty(value = "执行进度")
//    @Field(value = "progress")
//    private BigDecimal progress;
//
//    @ApiModelProperty(value = "已完成进度")
//    @Field(value = "complete_progress")
//    private AtomicInteger completeProgress;
//
//    @ApiModelProperty(value = "报告路径")
//    @Field(value = "report_file_path")
//    private String reportFilePath;
//
//    @ApiModelProperty(value = "任务创建时间")
//    @Field(value = "create_time")
//    private Date createTime;
//
//    @ApiModelProperty(value = "任务更新时间")
//    @Field(value = "update_time")
//    private Date updateTime;
//
//    @ApiModelProperty(value = "任务创建人")
//    @Field("create_user_id")
//    private String createUserId;
//
//    @ApiModelProperty(value = "任务更新人")
//    @Field("update_user_id")
//    private String updateUserId;
//
//    @ApiModelProperty(value = "备注")
//    @Field(value = "remark")
//    private String remark;
//
//    @ApiModelProperty(value = "实体名称")
//    @Field(value = "obj_name")
//    private String objName;
//
//    public ExamTask() {
//
//    }
//
//    public ExamTask(String examCode, String createUserId) {
//        this.examCode = examCode;
//        this.createUserId = createUserId;
//        this.sync = true;
//        this.count = new AtomicInteger(1).get();
//        this.status = TaskStatusEnum.INIT;
//        this.progress = new BigDecimal(0);
//        this.createTime = new Date();
//        this.type = TaskTypeEnum.SYNC_YUN_MARK;
//    }
//
//    public void updateInfo(ExamTask examTask, String updateUserId) {
//        examTask.setStatus(TaskStatusEnum.RUNNING);
//        examTask.setUpdateTime(new Date());
//        if (Objects.nonNull(updateUserId)) {
//            examTask.setUpdateUserId(updateUserId);
//        }
//    }
//
//    public void finishInfo(ExamTask examTask, String updateUserId) {
//        examTask.setStatus(TaskStatusEnum.FINISH);
//        examTask.setUpdateTime(new Date());
//        if (Objects.nonNull(updateUserId)) {
//            examTask.setUpdateUserId(updateUserId);
//        }
//    }
//
//    public TaskTypeEnum getType() {
//        return type;
//    }
//
//    public void setType(TaskTypeEnum type) {
//        this.type = type;
//    }
//
//    public BigDecimal getTotalProgress() {
//        return totalProgress;
//    }
//
//    public void setTotalProgress(BigDecimal totalProgress) {
//        this.totalProgress = totalProgress;
//    }
//
//    public AtomicInteger getCompleteProgress() {
//        return completeProgress;
//    }
//
//    public void setCompleteProgress(AtomicInteger completeProgress) {
//        this.completeProgress = completeProgress;
//    }
//
//    public String getExamCode() {
//        return examCode;
//    }
//
//    public void setExamCode(String examCode) {
//        this.examCode = examCode;
//    }
//
//    public static long getSerialVersionUID() {
//        return serialVersionUID;
//    }
//
//    public String getId() {
//        return id;
//    }
//
//    public void setId(String id) {
//        this.id = id;
//    }
//
//    public Boolean getSync() {
//        return sync;
//    }
//
//    public void setSync(Boolean sync) {
//        this.sync = sync;
//    }
//
//    public TaskResultEnum getResult() {
//        return result;
//    }
//
//    public void setResult(TaskResultEnum result) {
//        this.result = result;
//    }
//
//    public Integer getCount() {
//        return count;
//    }
//
//    public void setCount(Integer count) {
//        this.count = count;
//    }
//
//    public TaskStatusEnum getStatus() {
//        return status;
//    }
//
//    public void setStatus(TaskStatusEnum status) {
//        this.status = status;
//    }
//
//    public String getSummary() {
//        return summary;
//    }
//
//    public void setSummary(String summary) {
//        this.summary = summary;
//    }
//
//    public BigDecimal getProgress() {
//        return progress;
//    }
//
//    public void setProgress(BigDecimal progress) {
//        this.progress = progress;
//    }
//
//    public String getReportFilePath() {
//        return reportFilePath;
//    }
//
//    public void setReportFilePath(String reportFilePath) {
//        this.reportFilePath = reportFilePath;
//    }
//
//    public Date getCreateTime() {
//        return createTime;
//    }
//
//    public void setCreateTime(Date createTime) {
//        this.createTime = createTime;
//    }
//
//    public String getRemark() {
//        return remark;
//    }
//
//    public void setRemark(String remark) {
//        this.remark = remark;
//    }
//
//    public String getObjName() {
//        return objName;
//    }
//
//    public void setObjName(String objName) {
//        this.objName = objName;
//    }
//
//    public Date getUpdateTime() {
//        return updateTime;
//    }
//
//    public void setUpdateTime(Date updateTime) {
//        this.updateTime = updateTime;
//    }
//
//    public String getCreateUserId() {
//        return createUserId;
//    }
//
//    public void setCreateUserId(String createUserId) {
//        this.createUserId = createUserId;
//    }
//
//    public String getUpdateUserId() {
//        return updateUserId;
//    }
//
//    public void setUpdateUserId(String updateUserId) {
//        this.updateUserId = updateUserId;
//    }
//}

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.jkserver.constant.SystemConstant;
import com.qmth.jkserver.enums.TaskResultEnum;
import com.qmth.jkserver.enums.TaskStatusEnum;
import com.qmth.jkserver.enums.TaskTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * <p>
 * 云阅卷同步考试任务
 * </p>
 *
 * @author wangliang
 * @since 2023-03-01
 */
@ApiModel(value = "JkExamTask对象", description = "云阅卷同步考试任务")
@TableName("jk_exam_task")
public class ExamTask implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

    @ApiModelProperty(value = "任务类型，SYNC_YUN_MARK：云阅卷同步")
    private TaskTypeEnum type;

    @ApiModelProperty(value = "云阅卷是否同步，0：未同步，1：同步")
    private Boolean sync;

    @ApiModelProperty(value = "云阅卷同步结果，SUCCESS：成功，ERROR：失败")
    private TaskResultEnum result;

    @ApiModelProperty(value = "云阅卷同步次数")
    private Integer count;

    @ApiModelProperty(value = "任务状态，INIT：未开始，RUNNING：进行中，FINISH：已完成")
    private TaskStatusEnum status;

    @ApiModelProperty(value = "实时摘要信息")
    private String summary;

    @ApiModelProperty(value = "总进度")
    private BigDecimal totalProgress;

    @ApiModelProperty(value = "执行进度")
    private BigDecimal progress;

    @ApiModelProperty(value = "已完成进度")
    private Integer completeProgress = 0;

    @ApiModelProperty(value = "报告路径")
    private String reportFilePath;

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

    @ApiModelProperty(value = "更新时间")
    private Long updateTime;

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

    @ApiModelProperty(value = "更新人id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long updateUserId;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "实体名称")
    private String objName;

    public ExamTask() {

    }

    public ExamTask(String examCode, Long createUserId) {
        this.id = SystemConstant.getDbUuid();
        this.examCode = examCode;
        this.createUserId = createUserId;
        this.sync = true;
        this.count = new AtomicInteger(1).get();
        this.status = TaskStatusEnum.INIT;
        this.progress = new BigDecimal(0);
        this.createTime = System.currentTimeMillis();
        this.type = TaskTypeEnum.SYNC_YUN_MARK;
    }

    public void updateInfo(ExamTask examTask, Long updateUserId) {
        examTask.setStatus(TaskStatusEnum.RUNNING);
        examTask.setUpdateTime(System.currentTimeMillis());
        if (Objects.nonNull(updateUserId)) {
            examTask.setUpdateUserId(updateUserId);
        }
    }

    public void finishInfo(ExamTask examTask, Long updateUserId) {
        examTask.setStatus(TaskStatusEnum.FINISH);
        examTask.setUpdateTime(System.currentTimeMillis());
        if (Objects.nonNull(updateUserId)) {
            examTask.setUpdateUserId(updateUserId);
        }
    }

    public Long getId() {
        return id;
    }

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

    public String getExamCode() {
        return examCode;
    }

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

    public TaskTypeEnum getType() {
        return type;
    }

    public void setType(TaskTypeEnum type) {
        this.type = type;
    }

    public Boolean getSync() {
        return sync;
    }

    public void setSync(Boolean sync) {
        this.sync = sync;
    }

    public TaskResultEnum getResult() {
        return result;
    }

    public void setResult(TaskResultEnum result) {
        this.result = result;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public TaskStatusEnum getStatus() {
        return status;
    }

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

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public BigDecimal getTotalProgress() {
        return totalProgress;
    }

    public void setTotalProgress(BigDecimal totalProgress) {
        this.totalProgress = totalProgress;
    }

    public BigDecimal getProgress() {
        return progress;
    }

    public void setProgress(BigDecimal progress) {
        this.progress = progress;
    }

    public Integer getCompleteProgress() {
        return completeProgress;
    }

    public void setCompleteProgress(Integer completeProgress) {
        this.completeProgress = completeProgress;
    }

    public String getReportFilePath() {
        return reportFilePath;
    }

    public void setReportFilePath(String reportFilePath) {
        this.reportFilePath = reportFilePath;
    }

    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 Long getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(Long createUserId) {
        this.createUserId = createUserId;
    }

    public Long getUpdateUserId() {
        return updateUserId;
    }

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

    public String getRemark() {
        return remark;
    }

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

    public String getObjName() {
        return objName;
    }

    public void setObjName(String objName) {
        this.objName = objName;
    }
}
