package com.njcn.influx.bo.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 
 * Description:
 * Date: 2024/1/8  12:27【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@TableName(value = "JOB_DETAIL_INFLUXDB")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class JobDetailInfluxDB {
    /**
     * 指标表名
     */
    @MppMultiId(value = "TABLE_NAME")
    private String tableName;
    @TableField(exist = false)
    private String tableName_CN;

    /**
     * 起始时间
     */
    @JsonFormat(
            pattern = "yyyy-MM-dd"
    )
    @MppMultiId(value = "EXCUTE_DATE")
    private LocalDate excuteDate;


    /**
     * 状态（0-执行中、1-成功、2-失败,3未执行）
     */
    @TableField(value = "STATE")
    private Integer state;

    /**
     * 记录数
     */
    @TableField(value = "\"ROW_COUNT\"")
    private Integer rowCount;

    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss"
    )
    @TableField(value = "UPDATE_TIME")
    private LocalDateTime updateTime;

    @TableField(value = "DURATION")
    private Double duration;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        JobDetailInfluxDB jobDetail = (JobDetailInfluxDB) o;
        return Objects.equals(tableName, jobDetail.tableName) && Objects.equals(excuteDate, jobDetail.excuteDate);
    }


    public JobDetailInfluxDB(String tableName, LocalDate excuteDate, Integer state, Integer rowCount, LocalDateTime updateTime) {
        this.tableName = tableName;
        this.excuteDate = excuteDate;
        this.state = state;
        this.rowCount = rowCount;
        this.updateTime = updateTime;
    }

    public JobDetailInfluxDB(String tableName, LocalDate excuteDate, Integer rowCount) {
        this.tableName = tableName;
        this.excuteDate = excuteDate;
        this.rowCount = rowCount;
    }
}