package com.dcs.hnyz.enums;

import static com.dcs.framework.datasource.DynamicDataSourceContextHolder.log;

/**
 * equipmentType
 *
 * @author: hmy
 * @date: 2025/5/23 11:23
 */
public enum DeviceTypeEnum {
    /**
     * 设备类型
     */
    VALVE_WITH_FEEDBACK("1", "有反馈阀门"),
    PUMP("2", "泵"),
    TANK("3", "罐体"),
    SENSOR("4", "传感器"),
    VALVE_NO_FEEDBACK("5", "无反馈阀门"),
    UNDEFINED("10", "未定义");

    private final String code;
    private final String label;

    DeviceTypeEnum(String code, String label) {
        this.code = code;
        this.label = label;
    }

    public String getCode() {
        return code;
    }

    public String getLabel() {
        return label;
    }

    public static DeviceTypeEnum fromCode(String code) {
        for (DeviceTypeEnum type : values()) {
            if (code.equals(type.code)) return type;
        }
        log.warn("未知设备类型: {}", code);
        return null;
    }

}
