package com.cim.idm.constants.storage;

import lombok.Getter;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Getter
public enum StorageRulesEnums {
    // S：泗洪-老厂，J：泗洪-胶水，P：泗洪-PET
    GU_FEN("1010", new String[]{"S", "J", "P"}),
    SI_HONG("1020", new String[]{"S", "J", "P"}),
    // 太仓
    TAI_CANG("1030", new String[]{"T"}),
    // 重庆
    CHONG_QING("1050", new String[]{"C"}),
    // 东莞
    DONG_GUAN("1060", new String[]{"D"}),
    // 越南
    YUE_NAME("3500", new String[]{"Y"});

    private final String code;
    private final String[] prefix;

    StorageRulesEnums(String code, String[] prefix) {
        this.code = code;
        this.prefix = prefix;
    }

    /**
     * 根据组织编码获取前缀
     * @param code 组织编码
     * @return 前缀
     */
    public static List<String> getPrefix(String code) {
        for (StorageRulesEnums value : StorageRulesEnums.values()) {
            if (value.getCode().equals(code)) {
                return Arrays.asList(value.getPrefix());
            }
        }
        return Collections.emptyList();
    }
}
