package com.qmth.teachcloud.common.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
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.teachcloud.common.base.BaseEntity;
import com.qmth.teachcloud.common.contant.SystemConstant;
import com.qmth.teachcloud.common.enums.TaskResultEnum;
import com.qmth.teachcloud.common.enums.TaskStatusEnum;
import com.qmth.teachcloud.common.enums.TaskTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * <p>
 * 导入导出任务表
 * </p>
 *
 * @author wangliang
 * @since 2021-03-19
 */
@ApiModel(value = "TBTask对象", description = "导入导出任务表")
public class TBTask extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "任务类型，USER_IMPORT：用户导入， QUESTION_MISSION_BATCH_CREATE：批量新建命题任务， SAMPLE_EXPORT：导出审核样本， PAPER_DOWNLOAD：卷库下载， EXAMINATION_IMPORT：考务数据导入， EXAMINATION_EXPORT：考务数据导出， PRINT_PDF_DOWNLOAD：批量下载pdf， CREATE_PDF：生成pdf， COURSE_IMPORT：课程导入，STATISTICS_IMPORT：命题统计导入")
    @TableField(value = "type")
    private TaskTypeEnum type;

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

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "学校id")
    @TableField(value = "school_id")
    private Long schoolId;

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

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "印刷计划id")
    @TableField(value = "print_plan_id")
    private Long printPlanId;

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

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

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

    @ApiModelProperty(value = "数据结果，SUCCESS：成功，ERROR：失败")
    @TableField(value = "result")
    private TaskResultEnum result;

    @ApiModelProperty(value = "是否启用，false：停用，true：启用")
    @TableField(value = "enable")
    private Boolean enable;

    @ApiModelProperty(value = "导入文件名")
    @TableField(value = "import_file_name", updateStrategy = FieldStrategy.IGNORED)
    private String importFileName;

    @ApiModelProperty(value = "导入文件路径")
    @TableField(value = "import_file_path", updateStrategy = FieldStrategy.IGNORED)
    private String importFilePath;

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

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

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

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

    @ApiModelProperty(value = "重试次数")
    @TableField(value = "reset_count")
    private int resetCount;

    @ApiModelProperty(value = "更新版本号")
    @TableField(value = "version")
    private int version;

    @ApiModelProperty(value = "人工错误")
    @TableField(value = "error_message", updateStrategy = FieldStrategy.IGNORED)
    private String errorMessage;

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public int getResetCount() {
        return resetCount;
    }

    public void setResetCount(int resetCount) {
        this.resetCount = resetCount;
    }

    public String getObjName() {
        return objName;
    }

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

    public String getRemark() {
        return remark;
    }

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

    public Long getPrintPlanId() {
        return printPlanId;
    }

    public void setPrintPlanId(Long printPlanId) {
        this.printPlanId = printPlanId;
    }

    public TBTask() {

    }

    public TBTask(TaskTypeEnum type, Long entityId, TaskStatusEnum status, String summary, String importFileName, String importFilePath, Long createId, Long schoolId) {
        setId(SystemConstant.getDbUuid());
        this.type = type;
        this.entityId = entityId;
        this.status = status;
        this.summary = summary;
        this.importFileName = importFileName;
        this.importFilePath = importFilePath;
        setCreateId(createId);
        setCreateTime(System.currentTimeMillis());
        this.schoolId = schoolId;
    }

    public TBTask(TaskTypeEnum type, TaskStatusEnum status, String summary, String importFileName, String importFilePath, Long createId, Long schoolId) {
        setId(SystemConstant.getDbUuid());
        this.type = type;
        this.status = status;
        this.summary = summary;
        this.importFileName = importFileName;
        this.importFilePath = importFilePath;
        setCreateId(createId);
        setCreateTime(System.currentTimeMillis());
        this.schoolId = schoolId;
    }

    public TBTask(TaskTypeEnum type, TaskStatusEnum status, String importFileName, String importFilePath, Long createId, Long schoolId) {
        setId(SystemConstant.getDbUuid());
        this.type = type;
        this.status = status;
        this.importFileName = importFileName;
        this.importFilePath = importFilePath;
        setCreateId(createId);
        setCreateTime(System.currentTimeMillis());
        this.schoolId = schoolId;
    }

    public Long getSchoolId() {
        return schoolId;
    }

    public void setSchoolId(Long schoolId) {
        this.schoolId = schoolId;
    }

    public Long getOrgId() {
        return orgId;
    }

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

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getEntityId() {
        return entityId;
    }

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

    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 TaskTypeEnum getType() {
        return type;
    }

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

    public TaskStatusEnum getStatus() {
        return status;
    }

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

    public TaskResultEnum getResult() {
        return result;
    }

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

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

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