package com.njcn.pojo.advanced;

import java.io.Serializable;
import java.util.Date;

public class SagEvent implements Comparable<SagEvent>,Serializable {
    // 事件的唯一标识
    private String indexEventDetail;

    private Integer waveType;
    // 暂降事件发生时间
    private Date sagTime;

    // 暂降事件发生时间毫秒
    private Integer msec;

    // 事件描述
    private String events;

    // 持续时间
    private Float persistTime;

    // 发生暂降事件的监测点层级信息
    private PlantInfo plantInfo;

    // 拼接sagTime和msec
    private String strTime;

    // 事件发生时刻的毫秒表示
    private Long time;

    // 监测点的唯一标识
    private Integer indexPoint;

    // 归一化事件的GUID
    private String indexEventAss;

    // 特征幅值
    private Float eventValue;

    // 暂降原因
    private String sagReason;

    // 暂降类型
    private String sagType;

    // 暂降类型描述
    private String sagTypeDes;

    public String getSagTypeDes() {
        return sagTypeDes;
    }

    public void setSagTypeDes(String sagTypeDes) {
        this.sagTypeDes = sagTypeDes;
    }

    // 暂降深度
    private String strEventValue;
    private String strPersist;

    // 事件是否经过高级算法处理(0-未处理，1-已处理，默认为0)
    private Integer dealFlag;

    // 事件是否经过高级算法处理中文描述(已处理、未处理)
    private String dealFlagDescription;

    // 录波文件是否存在(0-不存在，1-存在，默认为0)
    private Integer fileFlag;

    // 录波文件是否存在中文描述(存在、不存在)
    private String fileFlagDescription;

    // 高级算法返回dq持续时间
    private Float dqTime;

    // 高级算法处理事件个数记录
    private Integer number;

    // 归一化处理更新时间
    private Date dealTime;

    // 高级算法的对应关系
    private int cata;

    // 第一次事件的触发时间
    private Date firstTime;

    // 第一次事件的暂降类型
    private String firstType;

    // 第一次事件的触发时间毫秒
    private Integer firstMs;

    // 第一次事件触发时间date->毫秒
    private Long firstTimeMills;

    // 暂降严重度
    private Float severity;

    // 排序方式
    private int sortType = 0; // 初始化默认为0-按照时间排序 新增1-按暂降严重度排序 2-暂降发生时刻排序 3-先根据电压等级排序，如果相等再按照暂降幅值排序

    //电压等级
    private Double voltage;

    //监测点对象名称
    private String objName;

    public String getObjName() {
        return objName;
    }

    public void setObjName(String objName) {
        this.objName = objName;
    }

    public Integer getWaveType() {
        return waveType;
    }

    public void setWaveType(Integer waveType) {
        this.waveType = waveType;
    }

    private String strVoltage;

    public Double getVoltage() {
        return voltage;
    }

    public void setVoltage(Double voltage) {
        this.voltage = voltage;
    }

    public String getStrVoltage() {
        return strVoltage;
    }

    public void setStrVoltage(String strVoltage) {
        //转为double
        strVoltage = strVoltage.toUpperCase();
        String str = strVoltage.substring(0, strVoltage.indexOf("KV"));
        this.voltage = Double.parseDouble(str);
    }

    public int getSortType() {
        return sortType;
    }

    public void setSortType(int sortType) {
        this.sortType = sortType;
    }

    public Float getSeverity() {
        return severity;
    }

    public void setSeverity(Float severity) {
        this.severity = severity;
    }

    public Long getFirstTimeMills() {
        return firstTimeMills;
    }

    public void setFirstTimeMills(Long firstTimeMills) {
        this.firstTimeMills = firstTimeMills;
    }

    public Integer getFirstMs() {
        return firstMs;
    }

    public void setFirstMs(Integer firstMs) {
        this.firstMs = firstMs;
    }

    public Date getFirstTime() {
        return firstTime;
    }

    public void setFirstTime(Date firstTime) {
        this.firstTime = firstTime;
    }

    public String getFirstType() {
        return firstType;
    }

    public void setFirstType(String firstType) {
        this.firstType = firstType;
    }

    public Integer getFileFlag() {
        return fileFlag;
    }

    public void setFileFlag(Integer fileFlag) {
        this.fileFlag = fileFlag;
    }

    public String getFileFlagDescription() {
        return fileFlagDescription;
    }

    public void setFileFlagDescription(String fileFlagDescription) {
        this.fileFlagDescription = fileFlagDescription;
    }

    public int getCata() {
        return cata;
    }

    public void setCata(int cata) {
        this.cata = cata;
    }

    public Date getDealTime() {
        return dealTime;
    }

    public void setDealTime(Date dealTime) {
        this.dealTime = dealTime;
    }

    public Float getDqTime() {
        return dqTime;
    }

    public void setDqTime(Float dqTime) {
        this.dqTime = dqTime;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public void setDealFlagDescription(String dealFlagDescription) {
        this.dealFlagDescription = dealFlagDescription;
    }

    public String getDealFlagDescription() {
        return dealFlagDescription;
    }

    public Integer getDealFlag() {
        return dealFlag;
    }

    public void setDealFlag(Integer dealFlag) {
        this.dealFlag = dealFlag;
    }

    public String getIndexEventDetail() {
        return indexEventDetail;
    }

    public void setIndexEventDetail(String indexEventDetail) {
        this.indexEventDetail = indexEventDetail;
    }

    public Date getSagTime() {
        return sagTime;
    }

    public void setSagTime(Date sagTime) {
        this.sagTime = sagTime;
    }

    public Integer getMsec() {
        return msec;
    }

    public void setMsec(Integer msec) {
        this.msec = msec;
    }

    public String getEvents() {
        return events;
    }

    public void setEvents(String events) {
        this.events = events;
    }

    public Float getPersistTime() {
        return persistTime;
    }

    public void setPersistTime(Float persistTime) {
        if (persistTime == null) {
            this.persistTime = 0f;
            return;
        }

        float f1 = (float) (Math.round(persistTime.floatValue() * 1000)) / 1000;
        this.persistTime = new Float(f1);
    }

    public PlantInfo getPlantInfo() {
        return plantInfo;
    }

    public void setPlantInfo(PlantInfo plantInfo) {
        this.plantInfo = plantInfo;
    }

    public String getStrTime() {
        return strTime;
    }

    public void setStrTime(String strTime) {
        this.strTime = strTime;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long time) {
        this.time = time;
    }

    public Integer getIndexPoint() {
        return indexPoint;
    }

    public void setIndexPoint(Integer indexPoint) {
        this.indexPoint = indexPoint;
    }

    public String getIndexEventAss() {
        return indexEventAss;
    }

    public void setIndexEventAss(String indexEventAss) {
        this.indexEventAss = indexEventAss;
    }

    public Float getEventValue() {
        return eventValue;
    }

    public void setEventValue(Float eventValue) {
        if (eventValue == null) {
            this.eventValue = 0f;
            return;
        }

        this.eventValue = eventValue;
    }

    public String getSagReason() {
        return sagReason;
    }

    public void setSagReason(String sagReason) {
        this.sagReason = sagReason;
    }

    public String getSagType() {
        return sagType;
    }

    public void setSagType(String sagType) {
        this.sagType = sagType;
    }

    public String getStrEventValue() {
        return strEventValue;
    }

    public void setStrEventValue(String strEventValue) {
        this.strEventValue = strEventValue;
    }

    public String getStrPersist() {
        return strPersist;
    }

    public void setStrPersist(String strPersist) {
        this.strPersist = strPersist;
    }

    @Override
    public String toString() {
        return "SagEvent [indexEventDetail=" + indexEventDetail + ", sagTime=" + sagTime + ", msec=" + msec
                + ", events=" + events + ", persistTime=" + persistTime + ", plantInfo=" + plantInfo + ", strTime="
                + strTime + ", time=" + time + ", indexPoint=" + indexPoint + ", indexEventAss=" + indexEventAss
                + ", eventValue=" + eventValue + ", sagReason=" + sagReason + ", sagType=" + sagType
                + ", strEventValue=" + strEventValue + ", strPersist=" + strPersist + ", dealFlag=" + dealFlag
                + ", dealFlagDescription=" + dealFlagDescription + ", fileFlag=" + fileFlag + ", fileFlagDescription="
                + fileFlagDescription + ", dqTime=" + dqTime + ", number=" + number + ", dealTime=" + dealTime
                + ", cata=" + cata + ", firstTime=" + firstTime + ", firstType=" + firstType + ", firstMs=" + firstMs
                + ", firstTimeMills=" + firstTimeMills + ", severity=" + severity + "]";
    }

    // 根据设定规则进行排序
    @Override
    public int compareTo(SagEvent obj) {
        switch (this.getSortType()) {
            case 1:
                return obj.getSeverity().compareTo(this.getSeverity());
            case 2:
                return this.getTime().compareTo(obj.getTime());
            case 3: {
                if (obj.getVoltage().compareTo(this.getVoltage()) != 0)
                    return obj.getVoltage().compareTo(this.getVoltage());
                else
                    return this.getEventValue().compareTo(obj.getEventValue());
            }
            default:
                break;
        }

        return this.getFirstTimeMills().compareTo(obj.getFirstTimeMills());
    }
}
