package com.qmth.sop.business.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.sop.common.base.BaseEntity;
import com.qmth.sop.common.contant.SystemConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.util.Objects;

/**
 * <p>
 * sop进程计划时间日志表
 * </p>
 *
 * @author wangliang
 * @since 2023-11-20
 */
@ApiModel(value = "TBSopPlanDateLog对象", description = "sop进程计划时间日志表")
public class TBSopPlanDateLog extends BaseEntity implements Serializable , Comparable<TBSopPlanDateLog>{

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "sopId")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long sopId;

    @ApiModelProperty(value = "流程Id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long flowId;

    @ApiModelProperty(value = "计划开始时间")
    private Long beginTime;

    @ApiModelProperty(value = "计划结束时间")
    private Long endTime;

    public TBSopPlanDateLog() {

    }

    public TBSopPlanDateLog(Long sopId, Long flowId, Long beginTime, Long endTime, Long userId) {
        setId(SystemConstant.getDbUuid());
        this.sopId = sopId;
        this.flowId = flowId;
        this.beginTime = beginTime;
        this.endTime = endTime;
        setCreateId(userId);
        setCreateTime(System.currentTimeMillis());
    }

    @Override
    public void updateInfo(Long userId) {
        setId(SystemConstant.getDbUuid());
        setCreateId(userId);
        setCreateTime(System.currentTimeMillis());
    }

    public Long getSopId() {
        return sopId;
    }

    public void setSopId(Long sopId) {
        this.sopId = sopId;
    }

    public Long getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Long beginTime) {
        this.beginTime = beginTime;
    }

    public Long getEndTime() {
        return endTime;
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
    }

    public Long getFlowId() {
        return flowId;
    }

    public void setFlowId(Long flowId) {
        this.flowId = flowId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TBSopPlanDateLog that = (TBSopPlanDateLog) o;
        return Objects.equals(sopId, that.sopId) && Objects.equals(flowId, that.flowId) && Objects.equals(beginTime, that.beginTime) && Objects.equals(endTime, that.endTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sopId, flowId, beginTime, endTime);
    }

    @Override
    public int compareTo(@NotNull TBSopPlanDateLog o) {
        if (o.getCreateTime() < this.getCreateTime()) {
            return 1;
        } else if (o.getCreateTime() > this.getCreateTime()) {
            return -1;
        } else {
            return 0;
        }
    }
}
