package com.ruoyi.device.mqtt.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 设备型号枚举
 */
public enum DeviceModelEnum
{
    GATEWAY_DEVICE_TYPE(1, "0101", "加油机路由器A"),
    GATEWAY_DEVICE_TYPE_0102(1, "0102", "加油机路由器B"),
    GATEWAY_DEVICE_TYPE_0103(1, "0103", "加油机路由器B"),
    GATEWAY_DEVICE_TYPE_0104(1, "0104", "加油机路由器B"),
    INVENT_GATEWAY_DEVICE(1, "0109", "定制加油机路由器"),

    COLLECTOR_DEVICE_TYPE(2, "0201", "加油机采集器A"),
    COLLECTOR_DEVICE_TYPE_0202(2, "0202", "加油机采集器B"),
    INVENT_COLLECTOR_DEVICE(2, "0209", "定制加油机采集器"),

    OPW_GATEWAY(3, "0301", "液位仪网关A"),
    OPW_GATEWAY_0302(3, "0302", "液位仪网关B"),

//    SCREEN(4, "1XXX", "屏采集器"),

    CODER(5,"0501", "编码器"),

//    ENCRYPTION_MODULE(6,"0601", "加密模块"),

    GUN_BLOCKER(7, "0701", "加油枪阻断器"),

    TAX(8, "0801", "报税口"),

    PROBE_0901(9, "0901", "探针板A"),
    PROBE_0902(9, "0902", "探针板B"),
    PROBE_0904(9, "0904", "探针板D"),
    PROBE_0906(9, "0906", "探针板E");

    private final Integer type;
    private final String model;
    private final String message;

    DeviceModelEnum(Integer type, String model, String message)
    {
        this.type = type;
        this.model = model;
        this.message = message;
    }

    public Integer getType()
    {
        return type;
    }

    public String getModel()
    {
        return model;
    }

    public String getMessage()
    {
        return message;
    }

    public static Integer getTypeByModel(String model)
    {
        if (StringUtils.isBlank(model))
        {
            return null;
        }

        if (model.startsWith("10"))
        {
            return 10;
        }

        for (DeviceModelEnum value : DeviceModelEnum.values())
        {
            if (value.getModel().equals(model))
            {
                return value.getType();
            }
        }

        return null;
    }

    public static String getMessageByModel(String model)
    {
        if (StringUtils.isBlank(model))
        {
            return null;
        }

        for (DeviceModelEnum value : DeviceModelEnum.values())
        {
            if (value.getModel().equals(model))
            {
                return value.getMessage();
            }
        }

        return null;
    }
}
