package com.yzt.airconditionersystem.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 
 * @TableName facility_alarm
 */
@TableName(value ="facility_alarm")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FacilityAlarm implements Serializable {
    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_UUID)
    private String id;

    /**
     * 时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime time;

    /**
     * 报警内容
     */
    @TableField(value = "alarm_content")
    private String alarmContent;

    /**
     * 状态
     */
    private String status;

    /**
     * 网关id
     */
    @TableField(value = "gateway_id")
    private String gatewayId;

    /**
     * 持续时间
     */
    @TableField(value = "lasting_time")
    private Long lastingTime;

    @TableField(exist = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String startTime;

    @TableField(exist = false)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String endTime;

    /**
     * 公司名称
     */
    @TableField(exist = false)
    private String companyName;

    @TableField(exist = false)
    private String companyId;

    /**
     * 所属运营商名
     */
//    @TableField(exist = false)
//    private String operatorName;

    /**
     * 所属运营商id
     */
//    @TableField(exist = false)
//    private String operatorId;

    /**
     * 地区
     */
    @TableField(exist = false)
    private String district;

    /**
     * 具体地址
     */
    @TableField(exist = false)
    private String detailedAddress;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public FacilityAlarm(String id, LocalDateTime time, String alarmContent, String status, String gatewayId, Long lastingTime) {
        this.id = id;
        this.time = time;
        this.alarmContent = alarmContent;
        this.status = status;
        this.gatewayId = gatewayId;
        this.lastingTime = lastingTime;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        FacilityAlarm other = (FacilityAlarm) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getTime() == null ? other.getTime() == null : this.getTime().equals(other.getTime()))
            && (this.getAlarmContent() == null ? other.getAlarmContent() == null : this.getAlarmContent().equals(other.getAlarmContent()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
            && (this.getGatewayId() == null ? other.getGatewayId() == null : this.getGatewayId().equals(other.getGatewayId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getTime() == null) ? 0 : getTime().hashCode());
        result = prime * result + ((getAlarmContent() == null) ? 0 : getAlarmContent().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getGatewayId() == null) ? 0 : getGatewayId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", time=").append(time);
        sb.append(", alarmContent=").append(alarmContent);
        sb.append(", status=").append(status);
        sb.append(", gatewayId=").append(gatewayId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

}