package com.qmth.themis.business.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
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.enums.TaskStatusEnum;
import com.qmth.themis.business.enums.TaskTypeEnum;
import com.qmth.themis.business.util.UidUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * @Description: 异步任务
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/9
 */
@ApiModel(value = "t_b_task_history", description = "异步任务")
public class TBTaskHistory implements Serializable {

    private static final long serialVersionUID = 1L;

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

    @ApiModelProperty(value = "任务类型，calculate_exam_score：考试重新算分，import_exam_student：导入考生，import_exam_paper：导入试卷，import_invigilate_user：导入监考员，export_invigilate_user：导出监考员")
    @TableField("type")
    private TaskTypeEnum type;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "关联业务对象ID")
    @TableField("entity_id")
    private Long entityId;

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

    @ApiModelProperty(value = "任务状态，init：未开始，running：开始执行，finish：执行结束")
    @TableField("status")
    private TaskStatusEnum status;

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

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

    @ApiModelProperty(value = "导入文件名")
    @TableField("import_file_name")
    private String importFileName;

    @ApiModelProperty(value = "导入文件路径")
    @TableField("import_file_path")
    private String importFilePath;

    @ApiModelProperty(value = "导出文件路径")
    @TableField("result_file_path")
    private String resultFilePath;

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

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

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Long createTime;

    @ApiModelProperty(value = "开始时间")
    @TableField(value = "start_time")
    private Long startTime;

    @ApiModelProperty(value = "结束时间")
    @TableField(value = "finish_time")
    private Long finishTime;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "机构id")
    private Long orgId;

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

    public TBTaskHistory() {

    }

    public TBTaskHistory(TaskTypeEnum type, Long entityId, TaskStatusEnum status, String summary, Double progress,
            String importFileName, String importFilePath, Long createId, Long orgId) {
        this.id = UidUtil.nextId();
        this.type = type;
        this.entityId = entityId;
        this.status = status;
        this.summary = summary;
        this.progress = progress;
        this.importFileName = importFileName;
        this.importFilePath = importFilePath;
        this.createId = createId;
        this.startTime = System.currentTimeMillis();
        this.orgId = orgId;
    }

    public TBTaskHistory(TaskTypeEnum type, TaskStatusEnum status, String summary, Double progress, Long createId,
            Long orgId) {
        this.id = UidUtil.nextId();
        this.type = type;
        this.status = status;
        this.summary = summary;
        this.progress = progress;
        this.createId = createId;
        this.startTime = System.currentTimeMillis();
        this.orgId = orgId;
    }

    public String getRemark() {
        return remark;
    }

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

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getId() {
        return id;
    }

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

    public TaskTypeEnum getType() {
        return type;
    }

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

    public Long getEntityId() {
        return entityId;
    }

    public void setEntityId(Long entityId) {
        this.entityId = entityId;
    }

    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 Double getProgress() {
        return progress;
    }

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

    public String getImportFileName() {
        return importFileName;
    }

    public void setImportFileName(String importFileName) {
        this.importFileName = importFileName;
    }

    public String getImportFilePath() {
        return importFilePath;
    }

    public void setImportFilePath(String importFilePath) {
        this.importFilePath = importFilePath;
    }

    public String getResultFilePath() {
        return resultFilePath;
    }

    public void setResultFilePath(String resultFilePath) {
        this.resultFilePath = resultFilePath;
    }

    public String getReportFilePath() {
        return reportFilePath;
    }

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

    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;
    }

    public Long getStartTime() {
        return startTime;
    }

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
    }

    public Long getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(Long finishTime) {
        this.finishTime = finishTime;
    }

    public Long getExamId() {
        return examId;
    }

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

}
