Pu Zhibing
2025-04-22 fd7b8fb7c89832c28a838b0449bbb8a392433ee2
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/enums/status/ChargingGunStatusEnum.java
New file
@@ -0,0 +1,50 @@
package com.ruoyi.common.core.enums.status;
import lombok.Getter;
/**
 * @Description
 * @Author xiaochen
 * @Date 2023/6/8 16:42
 */
public enum ChargingGunStatusEnum {
    OFFLINE(1, "离线"),
    IDLE(2, "空闲"),
    OCCUPATION_UNCHARGED(3, "占用(未充电)"),
    OCCUPATION_CHARGING(4, "占用(充电中)"),
    OCCUPATION_FULL(5, "占用(已充满)"),
    OCCUPATION_LOCK(6, "占用(预约锁定)"),
    FAULT(7, "故障");
    @Getter
    private String desc;
    @Getter
    private int code;
    ChargingGunStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    /**
     * 通过code获取枚举
     *
     * @param code
     * @return
     */
    public static ChargingGunStatusEnum fromCode(Integer code) {
        ChargingGunStatusEnum[] resultTypes = ChargingGunStatusEnum.values();
        for (ChargingGunStatusEnum resultType : resultTypes) {
            if (code.equals(resultType.getCode())) {
                return resultType;
            }
        }
        return null;
    }
}