package com.qmth.teachcloud.report.business.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
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.PushTypeEnum;
import com.qmth.teachcloud.common.enums.TaskResultEnum;
import com.qmth.teachcloud.common.enums.TaskStatusEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 * 同步任务表
 * </p>
 *
 * @author wangliang
 * @since 2022-06-06
 */
@ApiModel(value = "TBSyncTask对象", description = "同步任务表")
public class TBSyncTask extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

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

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

    @ApiModelProperty(value = "任务类型，CALCULATE：分析计算")
    private PushTypeEnum type;

    @ApiModelProperty(value = "第三方关联ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long thirdRelateId;

    @ApiModelProperty(value = "实体信息")
    @TableField(value = "obj", updateStrategy = FieldStrategy.IGNORED)
    private String obj;

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

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

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

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

    @ApiModelProperty(value = "备注")
    @TableField(value = "remark", updateStrategy = FieldStrategy.IGNORED)
    private String remark;

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

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

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

    @ApiModelProperty(value = "原始数据")
    private String source;

    public TBSyncTask() {

    }

    public TBSyncTask(Long schoolId, Long thirdRelateId, String source) {
        setId(SystemConstant.getDbUuid());
        this.schoolId = schoolId;
        this.thirdRelateId = thirdRelateId;
        this.type = PushTypeEnum.CALCULATE;
        this.status = TaskStatusEnum.INIT;
        this.source = source;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

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

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

    public Long getThirdRelateId() {
        return thirdRelateId;
    }

    public void setThirdRelateId(Long thirdRelateId) {
        this.thirdRelateId = thirdRelateId;
    }

    public String getObj() {
        return obj;
    }

    public void setObj(String obj) {
        this.obj = obj;
    }

    public BigDecimal getProgress() {
        return progress;
    }

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

    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 TaskResultEnum getResult() {
        return result;
    }

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

    public String getRemark() {
        return remark;
    }

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

    public Integer getResetCount() {
        return resetCount;
    }

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

    public String getErrorMessage() {
        return errorMessage;
    }

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

    public String getReportFilePath() {
        return reportFilePath;
    }

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