package com.haha.common.constant;

/**
 * 设备相关常量
 */
public final class DeviceConstants {
    
    private DeviceConstants() {}
    
    // ==================== 设备状态 ====================
    
    /**
     * 设备状态：正常/在线
     */
    public static final int STATUS_ONLINE = 1;
    
    /**
     * 设备状态：冻结
     */
    public static final int STATUS_FROZEN = 2;
    
    /**
     * 设备状态：离线
     */
    public static final int STATUS_OFFLINE = 3;
    
    /**
     * 设备状态：维护中
     */
    public static final int STATUS_MAINTENANCE = 4;
    
    // ==================== 门索引 ====================
    
    /**
     * 默认门索引
     */
    public static final String DEFAULT_DOOR_INDEX = "A";
    
    /**
     * A门
     */
    public static final String DOOR_A = "A";
    
    /**
     * B门
     */
    public static final String DOOR_B = "B";
    
    /**
     * C门
     */
    public static final String DOOR_C = "C";
    
    // ==================== 设备类型 ====================
    
    /**
     * 设备类型：智能柜
     */
    public static final String TYPE_SMART_CABINET = "智能柜";
    
    // ==================== 状态描述 ====================
    
    /**
     * 获取设备状态描述
     */
    public static String getStatusDesc(int status) {
        return switch (status) {
            case STATUS_ONLINE -> "正常";
            case STATUS_FROZEN -> "冻结";
            case STATUS_OFFLINE -> "离线";
            case STATUS_MAINTENANCE -> "维护中";
            default -> "未知";
        };
    }
    
    /**
     * 判断设备是否在线
     */
    public static boolean isOnline(Integer status) {
        return status != null && status == STATUS_ONLINE;
    }

    /**
     * 设备状态标签
     */
    public static class StatusLabel {
        private final String label;
        private final String color;

        public StatusLabel(String label, String color) {
            this.label = label;
            this.color = color;
        }

        public String getLabel() { return label; }
        public String getColor() { return color; }
    }

    /**
     * 根据状态码获取状态标签
     */
    public static StatusLabel getStatusLabel(Integer status) {
        if (status == null) return new StatusLabel("未知", "info");
        return switch (status) {
            case STATUS_ONLINE -> new StatusLabel("在线", "success");
            case STATUS_FROZEN -> new StatusLabel("冻结", "warning");
            case STATUS_OFFLINE -> new StatusLabel("离线", "danger");
            case STATUS_MAINTENANCE -> new StatusLabel("维护中", "info");
            default -> new StatusLabel("未知", "info");
        };
    }
}
