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.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;
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_COMMAND_STACK_RECORD")
@Api(value="适配记录",description = "适配记录")
public class LacCommandStackRecord extends BaseBean {

    private static final long serialVersionUID = -2775980024345181459L;

    @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="STEP_INDEX")
    @ApiParam(value ="当前步骤")
    private Integer stepIndex;

    @Column(name="STEP_NUM")
    @ApiParam(value ="步骤总数")
    private Integer stepNum;

    @Column(name="TASK_COMPLETE_NUM")
    @ApiParam(value ="任务完成数量")
    private Integer taskCompleteNum;

    @Column(name="TASK_NUM")
    @ApiParam(value ="任务总数")
    private Integer taskNum;

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

    @Column(name="STACK_START_TIME")
    @ApiParam(value ="执行开始时间")
    private String stackStartTime;

    @Column(name="STACK_END_TIME")
    @ApiParam(value ="执行结束时间")
    private String stackEndTime;

    @Column(name="STACK_SPEND")
    @ApiParam(value ="执行耗时")
    private Long stackSpend;

    @Column(name="STACK_STATUS")
    @ApiParam(value ="执行状态")
    private Integer stackStatus;

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

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

    @Transient
    @ApiParam(value ="Lac实例id")
    private String lacInstanceId;

    @Transient
    @ApiParam(value ="指令集模板")
    private LacCommandStackTemplate template;

    @Transient
    @ApiParam(value ="步骤列表")
    private List<LacCommandStackStep> stepList;

}
