package com.casic.PgInterface.devTable.domain;

import com.casic.PgInterface.patroler.domain.PgUser;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Created by yxw on 2017/10/30.
 */
@Entity
@Table(name = "PG_ALARM")
@SequenceGenerator(name = "SEQ_PG_ALARM_ID", sequenceName = "SEQ_PG_ALARM_ID", allocationSize = 1, initialValue = 1)
public class PgAlarm implements Serializable {

    private static final long serialVersionUID = 1L;
    private long id;
    private String alarmValue;//报警值
    private Date alarmDate;//报警时间
    private String description;//描述
    private PgAlarmType alarmTypeId;//报警类型
    private PgDevice alarmDevId;//报警设备
    private PgUser userId;//责任人
    private int active;//状态位

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ALARM_ID")
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    @Column(name = "ALARM_VALUE")
    public String getAlarmValue() {
        return alarmValue;
    }

    public void setAlarmValue(String alarmValue) {
        this.alarmValue = alarmValue;
    }

    @Column(name = "ALARM_DATE")
    public Date getAlarmDate() {
        return alarmDate;
    }

    public void setAlarmDate(Date alarmDate) {
        this.alarmDate = alarmDate;
    }

    @Column(name = "DESCRIPTION")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "ALARMTYPEID")
    public PgAlarmType getAlarmTypeId() {
        return alarmTypeId;
    }

    public void setAlarmTypeId(PgAlarmType alarmTypeId) {
        this.alarmTypeId = alarmTypeId;
    }

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "ALARMDEVID")
    public PgDevice getAlarmDevId() {
        return alarmDevId;
    }

    public void setAlarmDevId(PgDevice alarmDevId) {
        this.alarmDevId = alarmDevId;
    }

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "USERID")
    public PgUser getUserId() {
        return userId;
    }

    public void setUserId(PgUser userId) {
        this.userId = userId;
    }

    @Column(name = "ACTIVE")
    public int getActive() {
        return active;
    }

    public void setActive(int active) {
        this.active = active;
    }

}