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

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
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.Table;
import javax.persistence.Transient;

/**
 * @Description :
 * <per>
 * <br/>   create table LacInstructionSetStepTask(
 * <br/>       templateId           bigint                         null,
 * <br/>       templateNameRdd      varchar(50)                    null,
 * <br/>       templateCode         varchar(50)                    null,
 * <br/>       stepId               bigint                         null,
 * <br/>       stepNameRdd          varchar(50)                    null,
 * <br/>       taskId               bigint                         null,
 * <br/>       taskNameRdd          varchar(50)                    null,
 * <br/>       taskCode             varchar(50)                    null,
 * <br/>       isCrux               int                            null
 * <br/>   );
 *
 * <br/>   comment on table LacInstructionSetStepTask is'指令集模板步骤任务';
 * <br/>   comment on column LacInstructionSetStepTask.templateId is'模板id';
 * <br/>   comment on column LacInstructionSetStepTask.templateNameRdd is'模板名称';
 * <br/>   comment on column LacInstructionSetStepTask.templateCode is'模板代码';
 * <br/>   comment on column LacInstructionSetStepTask.stepId is'步骤id';
 * <br/>   comment on column LacInstructionSetStepTask.stepNameRdd is'步骤名称';
 * <br/>   comment on column LacInstructionSetStepTask.taskId is'任务id';
 * <br/>   comment on column LacInstructionSetStepTask.taskNameRdd is'任务名称';
 * <br/>   comment on column LacInstructionSetStepTask.taskCode is'任务代码';
 * <br/>   comment on column LacInstructionSetStepTask.isCrux is'是否关键';
 * </per>
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 19-10-25 下午6:01
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="LAC_COMMAND_STACK_STEP_TASK")
@Api(value="步骤任务",description = "步骤任务信息")
public class LacCommandStackStepTask extends BaseBean {

    private static final long serialVersionUID = 7432247591995852126L;
    @Column(name="TEMPLATE_ID")
    @ApiParam(value ="模板ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long templateId;

//    @Column(name="TEMPLATE_NAME_RDD")
//    @ApiParam(value ="模板名称")
//    private String templateNameRdd;
//
//    @Column(name="TEMPLATE_CODE_RDD")
//    @ApiParam(value ="模板代码")
//    private String templateCodeRdd;

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

    /**
     * 不建议使用
     */
//    @Deprecated
//    @Column(name="TASK_INSTANCE_ID")
//    @ApiParam(value ="任务实例ID")
//    @JsonSerialize(using = ToStringSerializer.class)
//    private Long taskInstanceId;
//
//    @Column(name="STEP_NAME_RDD")
//    @ApiParam(value ="步骤名称")
//    private String stepNameRdd;

    @Column(name="STEP_CODE_RDD")
    @ApiParam(value ="步骤代码")
    private String stepCodeRdd;

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

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

    @Column(name="TASK_CODE_RDD")
    @ApiParam(value ="任务代码")
    private String taskCodeRdd;

    @Column(name="IS_CRUX")
    @ApiParam(value ="是否关键")
    private Integer isCrux;

    @Transient
    @ApiParam(value ="适配任务")
    private LacSuitTask lacSuitTask;

    @Transient
    @ApiParam(value ="适配任务记录")
    private LacLogTask logTask;

    public Long getTaskInstanceId(){
        if(logTask != null){
            return logTask.getId();
        }
        return null;
    }

    public LacCommandStackStepTask() {
    }

    public LacCommandStackStepTask(Long templateId) {
        this.templateId = templateId;
    }
}
