package com.gyee.wisdom.dao.sql.alarm.Entity;
import com.gyee.wisdom.common.data.ToData;
import com.gyee.wisdom.common.data.alarm.AlertRule;
import com.gyee.wisdom.common.data.alarm.Alertsnap;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.beans.BeanUtils;

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

@Data
@Entity
@NoArgsConstructor
@Table(name = "alertrule2")
public class AlertRuleEntity implements ToData<AlertRule>,Serializable{
    private static final long serialVersionUID = -8348826240826071549L;
    @Id
    @Column(name = "id")
    private String id;
    @Column(name = "name")
    private String name;   //名称
    @Column(name = "expression")
    private String expression;     //表达式
    @Column(name = "description")
    private String description;    //描述
    @Column(name = "tag")
    private String tag;    //标签
    @Column(name = "rank")
    private String rank;      //级别
    @Column(name = "enabled")
    private boolean enabled;  //是否启用
    @Column(name = "modelid")
    private String modelId;    //设备类型
    @Column(name = "ednavalue")
    private int ednaValue;    //报警值
    @Column(name = "category")
    private String category;      //报警类别
    @Column(name = "range")
    private String range;      //范围
    @Column(name = "station")
    private String station;    //场站
    @Column(name = "windturbine")
    private String windturbine;    //风机
    @Column(name = "line")
    private String line;           //线路
    @Column(name = "project")
    private String project;        //工程
    @Column(name = "electrical")
    private String electrical;     //电气
    @Column(name="relatedparts")
    private String relatedParts;//关联部件

    @Override
    public AlertRule toData() {
        AlertRule ar = new AlertRule();
        BeanUtils.copyProperties(this, ar);
        return ar;
    }

    public AlertRuleEntity(AlertRule ar) {
            this.id = ar.getId();
            this.name = ar.getName();   //名称
            this.expression = ar.getExpression();     //表达式
            this.description  = ar.getDescription();    //描述
            this.tag= ar.getTag();    //标签
            this.rank = ar.getRank();
            this.enabled = ar.isEnabled();
            this.modelId = ar.getModelId();
            this.ednaValue = ar.getEdnaValue();    //报警值
            this.category = ar.getCategory();      //报警类别
            this.range = ar.getRange();      //范围
            this.station=ar.getStation();    //场站
            this.windturbine=ar.getWindturbine();    //风机
            this.line=ar.getLine();           //线路
            this.project=ar.getProject();        //工程
            this.electrical=ar.getElectrical();     //电气
    }

}
