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;
import java.util.List;

/**
 * @Description :
 * <per>
 * <br/>   create table LacSuitTask(
 * <br/>        taskName             varchar(50)                    null,
 * <br/>        taskCode             varchar(50)                    null,
 * <br/>        taskTypeId           bigint                         null,
 * <br/>        taskTypeNameRdd      varchar(50)                    null,
 * <br/>        suitCaseId           bigint                         null,
 * <br/>        suitCaseCode         varchar(50)                    null,
 * <br/>        suitCaseNameRdd      varchar(50)                    null,
 * <br/>        successNum           int                            null,
 * <br/>        failNum              int                            null,
 * <br/>        countNum             int                            null,
 * <br/>        taskDescription      varchar(255)                   null
 * <br/>    );
 * <br/>    comment on table LacSuitTask is'适配任务';
 * <br/>    comment on column LacSuitTask.taskName is'任务名称';
 * <br/>    comment on column LacSuitTask.taskCode is'任务代码';
 * <br/>    comment on column LacSuitTask.taskTypeId is'任务大类id';
 * <br/>    comment on column LacSuitTask.taskTypeNameRdd is'任务大类名称';
 * <br/>    comment on column LacSuitTask.suitCaseId is'适配器id';
 * <br/>    comment on column LacSuitTask.suitCaseCode is'适配器代码';
 * <br/>    comment on column LacSuitTask.suitCaseNameRdd is'适配器名称';
 * <br/>    comment on column LacSuitTask.successNum is'成功次数';
 * <br/>    comment on column LacSuitTask.failNum is'适配次数';
 * <br/>    comment on column LacSuitTask.countNum is'总次数';
 * <br/>    comment on column LacSuitTask.taskDescription is'任务描述';
 * <br/>    comment on column LacSuitCase.timeout is'超时时间';     -> 移至 任务当中
 * <br/>    comment on column LacSuitCase.retryNum is'重试次数';    -> 移至 任务当中
 * </per>
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 19-10-25 下午6:47
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="LAC_SUIT_TASK")
@Api(value="调度任务",description = "调度任务信息")
public class LacSuitTask extends BaseBean {

    private static final long serialVersionUID = -6592851798133225109L;
    @Column(name="TASK_NAME")
    @ApiParam(value ="适配器名称")
    private String taskName;

    @Column(name="TASK_CODE")
    @ApiParam(value ="适配器代码")
    private String taskCode;

    @Column(name="TASK_TIMEOUT")
    @ApiParam(value ="超时时间")
    private Integer taskTimeout;

    public int getTaskTimeoutVal(){
        return taskTimeout == null ? -1 : taskTimeout.intValue();
    }

    @Column(name="TASK_RETRY_NUM")
    @ApiParam(value ="重试次数")
    private Integer taskRetryNum;

    @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="SUIT_CASE_ID")
    @ApiParam(value ="适配器ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long suitCaseId;

    @Column(name="SUTI_CASE_NAME_RDD")
    @ApiParam(value ="适配器名称")
    private String suitCaseNameRdd;

    @Column(name="SUIT_CASE_CODE_RDD")
    @ApiParam(value ="适配器代码")
    private String suitCaseCodeRdd;

    @Column(name="NUM_SUCCESS")
    @ApiParam(value ="执行成功次数")
    private Integer numSuccess = 0;

    @Column(name="NUM_FAIL")
    @ApiParam(value ="执行失败次数")
    private Integer numFail = 0;

    @Column(name="NUM_COUNT")
    @ApiParam(value ="执行次数")
    private Integer numCount = 0;

    @Column(name="TASK_DESCRIPTION")
    @ApiParam(value ="任务描述")
    private String taskDescription;

    /********************************** 虚拟字段 **********************************/

    @Transient
    @ApiParam(value ="适配套件")
    private LacSuitCase lacSuitCase;

    @Transient
    @ApiParam(value ="适配原始参数")
    private Object orginParam;

    @Transient
    @ApiParam(value ="适配转换后参数")
    private Object transParam;

    @Transient
    @ApiParam(value ="原始报文")
    private Object orginMessage;

    @Transient
    @ApiParam(value ="转换后报文")
    private Object transMessage;

    @Transient
    @ApiParam(value ="适配参数")
    private List<LacSuitTaskParam> lacSuitTaskParamList;

    @Transient
    @ApiParam(value ="适配出参")
    private List<LacSuitTaskParam> lacSuitTaskOutParamList;

    @Transient
    @ApiParam(value ="入参适配")
    private List<LacSuitTaskParamAdapter> inputParamAdapterList;

    @Transient
    @ApiParam(value ="出参适配")
    private List<LacSuitTaskParamAdapter> outputParamAdapterList;
}
