package cn.estsh.i3plus.pojo.platform.platbean;

import cn.estsh.i3plus.pojo.base.annotation.AnnoOutputColumn;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
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;

/**
 * @Description : 定时任务执行记录
 * @Reference   :
 * @Author      : wei.peng
 * @Date        : 2018-10-22 16:58:43.992
 * @Modify      :
 **/
@Data
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Api(value="定时任务执行日志",description = "定时任务执行记录")
public class SysLogTaskTime extends BaseBean {

    private static final long serialVersionUID = -841008177433745529L;
    @ApiParam(value ="调度器实例id")
    private String schedulerInstanceId;

    @ApiParam(value ="调度服务器ip")
    private String schedulerServerIp;

    @ApiParam(value ="调度服务器端口")
    private Integer schedulerServerPort;

    @ApiParam(value ="任务线程id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long taskThreadId;

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

    @ApiParam(value ="任务组名称")
    private String groupName;

    @ApiParam(value ="任务计划id" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long taskPlanId;

    @ApiParam(value ="产品名称")
    private Integer softType;
    public String getSoftTypeTxt() {
        return softType == null ? null : CommonEnumUtil.SOFT_TYPE.valueOfDescription(softType);
    }

    @ApiParam(value ="任务周期名称")
    private String taskCycleNameRdd;

    @ApiParam(value ="任务周期表达式")
    private String taskCycleExpsRdd;

    @ApiParam(value ="执行耗时")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long executeTime;

    @ApiParam(value ="任务完成情况(枚举：1正常，2失败)")
    @AnnoOutputColumn(refClass = CommonEnumUtil.TRUE_OR_FALSE.class, refForeignKey = "value", value = "description")
    private Integer taskStatus;

    public int getTaskStatusVal() {
        return taskStatus == null ? CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue() : taskStatus;
    }

    @ApiParam(value ="任务异常日志")
    private String taskLogError;
}
