package com.zcxk.vo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
 * 数据报警分析
 * @author lihui
 * @version V1.0
 * @date 2021/5/28
 **/
@Data
public class DataAlarmAnalysisVo implements Serializable {

    @ApiModelProperty("报警设置ID")
    @ExcelIgnore
    private Long id;

    @ApiModelProperty("报警名字")
    @ExcelProperty(value = {"名称"},index = 0)
    private String alarmName;

    @ApiModelProperty("报警设置规则")
    @ExcelProperty(value = {"数据分析条件"},index = 1)
    private String alarmSettingRules;

    @ApiModelProperty("分析值")
    @ExcelProperty(value = {"分析值"},index = 2)
    private BigDecimal resultAlarmValue;

    @ApiModelProperty("创建时间")
    @ExcelProperty(value = {"时间"},index = 3)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
    private Date dateCreate;

    @ApiModelProperty("场景名字")
    @ExcelIgnore
    private String beSceneName;

    @ApiModelProperty("设备名字")
    @ExcelIgnore
    private String beDeviceName;

    @ApiModelProperty("参数名字")
    @ExcelIgnore
    private String beAttributeName;

    @ApiModelProperty("报警值")
    @ExcelIgnore
    private BigDecimal beAlarmValue;

    @ApiModelProperty("单位")
    @ExcelIgnore
    private String beUnit;

    @ApiModelProperty("经纬度X")
    @ExcelIgnore
    private BigDecimal bePointX;

    @ApiModelProperty("经纬度Y")
    @ExcelIgnore
    private BigDecimal bePointY;

    @ApiModelProperty("地址")
    @ExcelIgnore
    private String beAddress;

    @ApiModelProperty("对比场景名字")
    @ExcelIgnore
    private String toSceneName;

    @ApiModelProperty("对比设备名字")
    @ExcelIgnore
    private String toDeviceName;

    @ApiModelProperty("对比参数名字")
    @ExcelIgnore
    private String toAttributeName;

    @ApiModelProperty("对比单位")
    @ExcelIgnore
    private String toUnit;

    @ApiModelProperty("对比报警值")
    @ExcelIgnore
    private BigDecimal toAlarmValue;

    @ApiModelProperty("对比地址")
    @ExcelIgnore
    private String toAddress;

    @ApiModelProperty("对比经纬度X")
    @ExcelIgnore
    private BigDecimal toPointX;

    @ApiModelProperty("对比经纬度Y")
    @ExcelIgnore
    private BigDecimal toPointY;

    @JsonIgnore
    @ExcelIgnore
    @ApiModelProperty("计算规则")
    private String computeRules;

    @JsonIgnore
    @ExcelIgnore
    @ApiModelProperty("报警规则")
    private String alarmRules;

    @JsonIgnore
    @ExcelIgnore
    @ApiModelProperty("设置的报警值")
    private BigDecimal alarmValue;

    /***
     * 规则描述
     * @author lihui
     * @date 16:41 2021/6/3
     * @return java.lang.String
     **/
    public String getAlarmSettingRules(){
        StringBuffer buf = new StringBuffer();
        buf.append(this.beSceneName).append(this.beDeviceName).append(this.beAttributeName)
                .append("(").append(this.beAlarmValue).append(this.beUnit).append(")")
                .append(this.computeRules).append(toSceneName).append(this.toDeviceName).append(this.toAttributeName)
                .append("(").append(this.toAlarmValue).append(this.toUnit).append(")")
                .append(this.alarmRules).append(this.alarmValue);
        return buf.toString();
    }

}
