package com.gyee.wisdom.dao.sql.alarm.Entity;
import com.gyee.wisdom.common.data.ToData;
import com.gyee.wisdom.common.data.alarm.FaultSnap;
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 = "faultsnap")
public class FaultSnapEntity implements ToData<FaultSnap>,Serializable{
    private static final long serialVersionUID = -8348866240826071549L;
    @Id
    @Column(name = "id")
//    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_FAULTSNAP")
//    @SequenceGenerator(name = "SEQ_FAULTSNAP", sequenceName = "NXFD_FAULTSNAP_ID")
    @GeneratedValue
    private Long id;
    @Column(name = "stationid")
    private String stationId;
    @Column(name = "projectid")
    private String projectId;
    @Column(name = "lineid")
    private String lineId;
    @Column(name = "windturbineid")
    private String windturbineId;
    @Column(name = "alertvalue")
    private int alertValue;
    @Column(name = "category1")
    private String cateGory1;
    @Column(name = "category2")
    private String cateGory2;
    @Column(name = "category3")
    private String cateGory3;
    @Column(name = "rank")
    private String rank;
    @Column(name = "isopened")
    private int isOpened;
    @Column(name = "lastupdatetime")
    private Date lastUpdateTime;
    @Column(name = "lastupdateperson")
    private String lastUpdatePerson;
    @Column(name = "stationname")
    private String stationName;
    @Column(name = "projectname")
    private String projectName;
    @Column(name = "linename")
    private String lineName;
    @Column(name = "windturbinename")
    private String windturbineName;
    @Column(name = "alerttext")
    private String alertText;
    @Column(name = "modelid")
    private String modelId;
    @Column(name = "testingpointkey")
    private String testingpointKey;

    @Override
    public FaultSnap toData() {

        FaultSnap snap = new FaultSnap();
        BeanUtils.copyProperties(this,snap);
        return snap;

    }

    public FaultSnapEntity(FaultSnap snap) {

            this.id = snap.getId();
            this.stationId = snap.getStationId();
            this.projectId = snap.getProjectId();
            this.lineId = snap.getLineId();
            this.windturbineId = snap.getWindturbineId();
            this.alertValue = snap.getAlertValue();
            this.cateGory1 = snap.getCateGory1();
            this.cateGory2 = snap.getCateGory2();
            this.cateGory3 = snap.getCateGory3();
            this.rank = snap.getRank();
            this.isOpened = snap.getIsOpened();
            this.lastUpdateTime = snap.getLastUpdateTime();
            this.lastUpdatePerson = snap.getLastUpdatePerson();
            this.stationName = snap.getStationName();
            this.projectName = snap.getProjectName();
            this.lineName = snap.getLineName();
            this.windturbineName = snap.getWindturbineName();
            this.alertText = snap.getAlertText();
            this.modelId = snap.getModelId();
            this.testingpointKey = snap.getTestingpointKey();
    }

}
