package com.haha.common.enums;

/**
 * 设备告警类型枚举
 */
public enum DeviceAlertType {

    OFFLINE(1, "设备离线"),
    WEAK_SIGNAL(2, "信号弱"),
    BACK_ONLINE(3, "恢复上线"),
    ABNORMAL_ORDER(4, "异常订单");

    private final int code;
    private final String description;

    DeviceAlertType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static DeviceAlertType fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (DeviceAlertType type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }
}
