package com.zcloud.primeport.plan.mjDevice.dto;

import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
public enum CarEnum {
    WHITE("white", "2"),
    BLUE("blue", "0"),
    YELLOW("yellow", "1"),
    GREEN("green", "4"),
    BLACK("black", "3"),
    OTHER_CARD("other_card", "5"),
    WXP("WXP", "WXP"),
    QH("qxhc", "QH"),
    XK("xxhc", "XK"),
    ZK("zxhc", "ZK"),
    DK("dxhc", "DK"),
    BG("zxbgqy", "BG"),
    TZ("tzzyc", "TZ"),
    ZX("zxzxhc", "ZX"),
    JSXH("jsgxhhc", "JSXH"),
    MV("qzyxjc", "MV"),
    IW("qzysjc", "IW"),
    CR("mbc", "CR"),
    CC("pk", "CC"),
    WXP_BLUE("wxplp", "WXP_BLUE"),
//    1-股份员工车辆，2-股份单位车辆，3-分公司员工车辆，4-分公司单位车辆 ，7检查部门车辆8，驻港单位员工车辆，9驻港单位公车
    GFDWC("2", "1"),
    FGSDWC("4", "1"),
    ZGDWC("9", "1"),

    GFYGC("1", "4"),
    FGSYGC("3", "4"),
    ZGDWYGC("8", "4"),
    INSPECTION_DEPARTMENT("7", "3");
//    WXP	危险品（黄牌）
//    QH	轻型货车
//    XK	小型客车
//    ZK	中型客车
//    DK	大型客车
//    BG	重型半挂牵引
//    TZ	特种作业车
//    ZX	重型自卸货车
//    JSXH	集疏港小型货车
//    MV	7座以下轿车
//    IW	7座以上轿车
//    CR	面包车
//    CC	皮卡
//    Z7	水泥罐车
//    WXP_BLUE	危险品（蓝牌）

    private final String path;
    private final String menuKey;

    private static final Map<String, CarEnum> PATH_MAP =
            Arrays.stream(values()).collect(Collectors.toMap(CarEnum::getPath, Function.identity()));

    CarEnum(String path, String menuKey) {
        this.path = path;
        this.menuKey = menuKey;
    }

    public String getPath() {
        return path;
    }

    public String getMenuKey() {
        return menuKey;
    }

    /**
     * 通过path获取menuKey
     */
    public static String getMenuKeyByPath(String path) {
        CarEnum entry = PATH_MAP.get(path);
        if (path.contains(",")) {
            return "MV";
        }
        return entry != null ? entry.getMenuKey() : null;
    }

    public static void main(String[] args) {
        System.out.println(getMenuKeyByPath("blue"));
        System.out.println(getMenuKeyByPath("1"));
        System.out.println(getMenuKeyByPath("2"));
        System.out.println(getMenuKeyByPath("3"));
    }
}
