package cn.estsh.i3plus.pojo.lac.bean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.LacEnumUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.List;

/**
 * @Description :
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 19-10-18 下午6:04
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="LAC_LOG_TASK")
@Api(value="适配任务记录",description = "适配任务记录")
public class LacLogTask extends BaseBean {

    private static final long serialVersionUID = 674009105885048131L;

    @Column(name="COMMAND_STACK_RECORD_ID")
    @ApiParam(value ="指令集记录ID" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long commandStackRecordId;

    @Column(name="commandStackId")
    @ApiParam(value ="指令集ID" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long commandStackId;

    @Column(name="COMMAND_STACK_NAME_RDD")
    @ApiParam(value ="指令集名称")
    private String commandStackNameRdd;

    @Column(name="COMMAND_STACK_CODE_RDD")
    @ApiParam(value ="指令集代码")
    private String commandStackCodeRdd;

    @Column(name="COMMAND_STACK_TYPE_ID")
    @ApiParam(value ="指令集类型")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long commandStackTypeId;

    @Column(name="COMMAND_STACK_TYPE_NAME_RDD")
    @ApiParam(value ="指令集类型名称")
    private String commandStackTypeNameRdd;

    @Column(name="STEP_ID")
    @ApiParam(value ="步骤ID" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long stepId;

    @Column(name="STEP_NAME_RDD")
    @ApiParam(value ="步骤名称")
    private String stepNameRdd;

    @Column(name="STEP_SEQUENCE")
    @ApiParam(value ="步骤顺序")
    private Integer stepSequence;

    @Column(name="TASK_ID")
    @ApiParam(value ="任务ID" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long taskId;

    @Column(name="TASK_NAME_RDD")
    @ApiParam(value ="任务名称")
    private String taskNameRdd;

    @Column(name="TASK_TYPE_ID")
    @ApiParam(value ="任务类型")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long taskTypeId;

    @Column(name="TASK_TYPE_NAME_RDD")
    @ApiParam(value ="任务类型")
    private String taskTypeNameRdd;

    @Column(name="adapterId")
    @ApiParam(value ="适配器ID" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long adapterId;

    @Column(name="TASK_DETAIL_ID")
    @ApiParam(value ="任务执行记录明细" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long taskDetailId;

    @Lob
    @Column(name="INPUT_PARAMETER")
    @ApiParam(value ="任务入参")
    private String inputParameter;

    @Column(name="TASK_START_TIME")
    @ApiParam(value ="任务开始时间")
    private String taskStartTime;

    @Column(name="TASK_END_TIME")
    @ApiParam(value ="任务结束时间")
    private String taskEndTime;

    @Column(name="TASK_SPEND")
    @ApiParam(value ="任务耗时")
    private Long taskSpend;

    @Column(name="TASK_STATUS")
    @ApiParam(value ="任务状态")
    private Integer taskStatus;

    public String getTaskStatusTxt(){
        return LacEnumUtil.STACK_STATUS.valueOfDescription(taskStatus == null ? 0 : taskStatus);
    }

    @Column(name="EXECUTION_DESCRIPTION")
    @ApiParam(value ="执行说明")
    private String executionDescription;


    @Transient
    @ApiParam(value ="任务记录")
    private LacCommandStackRecord record;

    @Transient
    @ApiParam(value ="任务记录")
    private LacCommandStackTemplate template;

    @Transient
    @ApiParam(value ="任务步骤")
    private LacCommandStackStep step;

    @Transient
    @ApiParam(value ="任务记录")
    private LacCommandStackStepTask stackStepTask;

    @Transient
    @ApiParam(value ="执行任务参数")
    private List<LacLogTaskDetail> detailList;
}
