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.InstanceRunType;
import org.springblade.etl.enums.InstanceStatus;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * SQL任务实例表 sql_job_instance
 * 
 * @author aokunsang
 * @date 2023-12-03
 */
@Data
@TableName("sql_job_instance")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SqlJobInstance对象", description = "SQL任务实例")
public class SqlJobInstance extends TenantEntity{

	private static final long serialVersionUID = 1L;
	
 	/** 
	 *  
	 */
	@TableId(type = IdType.AUTO)
	private Integer id;
	
	/** 
	 * 任务ID 
	 */
	@ApiModelProperty(value = "任务ID")
	private Integer jobId;

	/** 
	 * 任务脚本ID 
	 */
	@ApiModelProperty(value = "任务脚本ID")
	private Integer jobScriptId;
	
	/** 
	 * 任务脚本执行顺序号
	 */
	@ApiModelProperty(value = "任务脚本执行顺序号")
	private Integer jobScriptSortNum;
	
	/** 
	 * 作业开始时间 
	 */
	@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 InstanceStatus instanceStatus;

	/** 
	 * 错误描述 
	 */
	@ApiModelProperty(value = "错误描述")
	private String errMsg;

	/** 
	 * 任务创建时间 
	 */
	@ApiModelProperty(value = "任务创建时间")
	private LocalDateTime createTime;
	
	@ApiModelProperty(value = "SQL任务名称[仅用于展示]")
	@TableField(exist = false)
	private String jobName;
	
	@ApiModelProperty(value = "SQL脚本名称[仅用于展示]")
	@TableField(exist = false)
	private String sqlScriptName;
	
	@ApiModelProperty(value = "运行总耗时[仅用于展示]")
	@TableField(exist = false)
	private Long totalSecs;
}
