package com.artfess.rescue.external.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: wsf
 * @Description: 占道情况
 * @DateTime: 2025/4/17 11:19
 **/
@Getter
@AllArgsConstructor
public enum LaneOccupationEnum {
    NONE("1", "未占道", "0"),
    FIRST("2", "占用第一车道", "1"),
    SECOND("3", "占用第二车道", "2"),
    THIRD("4", "占用第三车道", "3"),
    FOURTH("5", "占用第四车道", "4"),
    EMERGENCY("6", "占用应急车道", "5");

    private final String code;
    private final String name;
    private final String xc_code;

    /**
     * 根据 xcCode 获取 code
     *
     * @param xcCode xcCode
     * @return code
     */
    public static String getCodeByXcCode(String xcCode) {
        for (LaneOccupationEnum e : values()) {
            if (e.getXc_code().equals(xcCode)) {
                return e.getCode();
            }
        }
        return null;
    }

    /**
     * 根据 code 获取 xcCode
     *
     * @param code code
     * @return xcCode
     */
    public static String getXcCodeByCode(String code) {
        for (LaneOccupationEnum e : values()) {
            if (e.getCode().equals(code)) {
                return e.getXc_code();
            }
        }
        return null;
    }
}