package com.zcxk.charge.api.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zcxk.core.utils.encrypt.Md5;
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 implements Serializable {

    @ApiModelProperty(value = "租户标识")
    private String tenantId;

    @ApiModelProperty(value = "所属公司ID")
    private Integer companyOrgId;

    @ApiModelProperty(value = "所属部门ID")
    private Integer deptOrgId;

    @ApiModelProperty(value = "场景ID")
    private Long beSceneId;

    @ApiModelProperty(value = "设备ID")
    private Long beDeviceId;

    @ApiModelProperty(value = "参数ID")
    private Long beAttributeId;

    @ApiModelProperty(value = "类型 :-> DataAlarmTypeEnum")
    private int beType;

    @ApiModelProperty(value = "计算规则")
    private String computeRules;

    @ApiModelProperty(value = "对比场景ID")
    private Long toSceneId;

    @ApiModelProperty(value = "对比设备ID")
    private Long toDeviceId;

    @ApiModelProperty(value = "对比参数ID")
    private Long toAttributeId;

    @ApiModelProperty(value = "对比类型 :-> DataAlarmTypeEnum")
    private int toType;

    @ApiModelProperty(value = "对比报警规则")
    private String alarmRules;

    @ApiModelProperty(value = "报警值")
    private BigDecimal alarmValue;

    @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 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(getBeSceneId()).append(getBeDeviceId()).append(getBeAttributeId())
                .append(getBeType()).append(this.getComputeRules()).append(getToSceneId()).append(getToDeviceId())
                .append(getToAttributeId()).append(getToType()).append(this.getAlarmRules()).append(this.getAlarmValue());
        return Md5.hash(buffer.toString());
    }

}
