package com.qmth.sop.business.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.sop.common.base.BaseEntity;
import com.qmth.sop.common.contant.SystemConstant;
import com.qmth.sop.common.enums.TaskResultEnum;
import com.qmth.sop.common.enums.TaskStatusEnum;
import com.qmth.sop.common.enums.TaskTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

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

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "任务类型，USER_ARCHIVES_IMPORT：人员档案导入，USER_ARCHIVES_EXPORT：人员档案导出，CUSTOM_IMPORT：客户导入")
    private TaskTypeEnum type;

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

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

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

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

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

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

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

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

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

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

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

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

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

    @ApiModelProperty(value = "重试次数")
    private Integer resetCount;

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

    @ApiModelProperty(value = "人工错误原因")
    private String errorMessage;

    public TBTask() {

    }

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

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

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

    public Long getOrgId() {
        return orgId;
    }

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

    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 Integer getResetCount() {
        return resetCount;
    }

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

    public Integer getVersion() {
        return version;
    }

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

    public String getErrorMessage() {
        return errorMessage;
    }

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