package com.zd.common.core.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zd.common.core.domain.hazard.HardwareType;

import java.util.Arrays;

/**
 * @Author: zhoupan
 * @Date: 2021/09/13/14:41
 * @Description:
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum SenseType implements BaseEnum<Integer>, HardwareType {


    TEMPERATURE(0, "温度", "温度", "icon_16", "℃"),
    HUMIDITY(1, "湿度", "湿度", "icon_17", "%"),
    VOC(2, "VOC", "VOC", "icon_23", ""),

    METHANE(3, "甲烷", "甲烷浓度", "icon_19", "%"),
    CO(4, "一氧化碳", "一氧化碳浓度", "icon_18", "%"),
    SMOKE(5, "烟感", "烟感", "icon_22", ""),
    COAL_DUST(6, "煤尘", "煤尘浓度", "icon_22", "%"),
    O2(7, "氧气", "氧气浓度", "icon_21", "%"),

    /**
     * 温湿度传感器
     */
    TEMPERATURE_AND_HUMIDITY(8, "温湿度", "温湿度", "icon_16", "℃"),
    ATMOSPHERIC_PRESSURE(9, "大气压", "大气压", "", ""),
    NITRIC_OXIDE(11, "一氧化氮", "一氧化氮", "", ""),
    SO2(12, "二氧化硫", "二氧化硫", "", ""),
    TVOC(13, "TVOC", "TVOC", "icon_23", ""),
    H2(14, "氢气", "氢气", "icon_23", ""),
    FLAME(15, "火焰", "火焰", "icon_22", ""),
    COCl2(16, "光气", "光气", "icon_22", "ppm"),
    Cl2(17, "氯气", "氯气", "icon_22", "ppm"),
    ;
    private Integer code;
    private String name;
    private String showName;
    private String img;
    private String unit;
    //排序
    private int order;

    SenseType(int code, String name, String showName, String img, String unit) {
        this.code = code;
        this.name = name;
        this.showName = showName;
        this.img = img;
        this.unit = unit;
        this.order = order;
    }

    public static SenseType getByCode(Integer code) {
        return Arrays.stream(SenseType.values()).filter(a -> a.code.equals(code)).findFirst().orElse(null);
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getShowName() {
        return showName;
    }

    @Override
    public Integer getDictKey() {
        return code;
    }

    @Override
    public Integer getHardwareTypeCode() {
        return code;
    }

    @Override
    public String getHardwareTypeName() {
        return showName;
    }

    public String getImg() {
        return img;
    }

    public String getUnit() {
        return unit;
    }

    public String getEnumName() {
        return super.toString();
    }
}
