package com.zcxk.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zcxk.common.Md5Util;
import com.zcxk.entity.alarm.DataAlarmSetting;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

/**
 * 报警设置管理Vo
 *
 * @author lihui
 * @version V1.0
 * @date 2021/5/28
 **/
@Data
public class DataAlarmManageVo extends DataAlarmSetting implements Serializable {

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

    @ApiModelProperty("报警名字")
    private String alarmName;

    @ApiModelProperty("报警设置规则")
    private String alarmSettingRules;

    @ApiModelProperty
    @JsonIgnore
    private String beAttributeName;

    @ApiModelProperty
    @JsonIgnore
    private String beSceneName;

    @ApiModelProperty
    @JsonIgnore
    private String computeRules;

    @ApiModelProperty
    @JsonIgnore
    private String alarmRules;

    @ApiModelProperty
    @JsonIgnore
    private BigDecimal alarmValue;

    @ApiModelProperty
    @JsonIgnore
    private String toAttributeName;

    @ApiModelProperty
    @JsonIgnore
    private String toSceneName;

    public String getAlarmSettingRules(){
        StringBuffer buf = new StringBuffer();
        buf.append(this.beSceneName).append(this.beAttributeName ).append(this.computeRules).append(toSceneName)
                .append(this.toAttributeName).append(this.alarmRules).append(this.alarmValue);
        return buf.toString();
    }

    public String getMd5Query(){
        StringBuffer buffer = new StringBuffer();
        buffer.append(super.getBeSceneId()).append(super.getBeDeviceId()).append(super.getBeAttributeId())
                .append(super.getBeType()).append(this.getComputeRules()).append(super.getToSceneId()).append(super.getToDeviceId())
                .append(super.getToAttributeId()).append(super.getToType()).append(this.getAlarmRules()).append(this.getAlarmValue());
        return Md5Util.hash(buffer.toString());
    }

}
