package org.springblade.etl.entity;

import java.time.LocalDateTime;
import java.util.Date;

import org.springblade.core.mp.base.TenantEntity;
import org.springblade.etl.enums.DataSyncType;
import org.springblade.etl.enums.InstanceRunType;
import org.springblade.etl.enums.InstanceStatus;
import org.springblade.etl.enums.InstanceType;
import org.springframework.format.annotation.DateTimeFormat;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 数据同步任务实例表 dsy_job_instance
 * 
 * @author aokunsang
 * @date 2023-09-21
 */
@Data
@TableName("dsy_job_instance")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "DsyJobInstance对象", description = "数据同步任务实例")
public class DsyJobInstance extends TenantEntity{

	private static final long serialVersionUID = 1L;
	
 	/** 
	 *  
	 */
	@TableId(type = IdType.AUTO)
	private Integer id;

	/** 
	 * 任务ID 
	 */
	@ApiModelProperty(value = "任务ID")
	private Integer jobId;
	
	@ApiModelProperty(value = "任务的表数据ID")
	private Integer jobTableId;
	
	/** 
	 * 输入源表名 
	 */
	@ApiModelProperty(value = "输入源表名")
	private String sourceTableName;

	/** 
	 * 目标源表名 
	 */
	@ApiModelProperty(value = "目标源表名")
	private String targetTableName;

	/** 
	 * 服务器IP 
	 */
	@ApiModelProperty(value = "服务器IP")
	@JsonIgnore
	private String serverIp;

	/** 
	 * 开始时间 
	 */
	@ApiModelProperty(value = "开始时间")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@TableField(whereStrategy = FieldStrategy.NEVER)
	private Date startTime;

	/** 
	 * 结束时间 
	 */
	@ApiModelProperty(value = "结束时间")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@TableField(whereStrategy = FieldStrategy.NEVER)
	private Date endTime;

	/** 
	 * 作业运行类型(手动 自动) 
	 */
	@ApiModelProperty(value = "作业运行类型(手动 自动)")
	private InstanceRunType instanceRunType;

	/** 
	 * 作业类型(流作业 批作业) 
	 */
	@ApiModelProperty(value = "作业类型(流作业 批作业)")
	private InstanceType instanceType;

	/** 
	 * 作业状态 
	 */
	@ApiModelProperty(value = "作业状态")
	private InstanceStatus instanceStatus;
	
	/** 
	 * 错误描述 
	 */
	@ApiModelProperty(value = "错误描述")
	private String errMsg;

	/** 
	 * 读取行数 
	 */
	@ApiModelProperty(value = "读取行数")
	private Long readRowCount;

	/** 
	 * 写入行数 
	 */
	@ApiModelProperty(value = "写入行数")
	private Long writeRowCount;
	
	/**
	 * 写入失败的行数
	 */
	@ApiModelProperty(value = "写入行数")
	private Long errorRowCount;

	/** 
	 * 数据写入速度 
	 */
	@ApiModelProperty(value = "数据写入速度")
	private Integer writeSpeed;

	/** 
	 * 数据平均流量
	 */
	@ApiModelProperty(value = "数据平均流量")
	private String dataFlowAvg;

	/** 
	 * 任务创建时间 
	 */
	@ApiModelProperty(value = "任务创建时间")
	private LocalDateTime createTime;
	
	/**
	 * 数据同步类型
	 */
	@ApiModelProperty(value = "数据同步类型")
	private DataSyncType syncType;
	
	//开始和结束的增量数值
	@JsonIgnore
	private String startIncrementData;
	@JsonIgnore
	private String endIncrementData;
	//datax的日志和配置文件名称
	@JsonIgnore
	private String dataxLogName;
	@JsonIgnore
	private String dataxConfigName;
	//datax的进程id
	@JsonIgnore
	private String dataxPid;
	
	@TableField(exist = false)
	@ApiModelProperty(value = "任务名称[仅查询返回]")
	private String jobName;
	
	@ApiModelProperty(value = "运行总耗时[仅用于展示]")
	@TableField(exist = false)
	private Long totalSecs;
}
