package com.sckw.core.model.enums;

import java.util.*;

/**
 * @author lfdc
 * @description 字段检测要素枚举
 * @date 2023-11-05 15:11:30
 */

public enum DictItemEnum {

    LONGITUDE_X("longitude", "lng", "经度（X偏移）"),
    LATITUDE_Y("latitude", "lat", "纬度（Y偏移）"),
    ALTITUDE_Z("altitude", "high", "海拔（z偏移）"),
    ALTITUDE_NULL("ISNULL", "ISNULL", "ISNULL"),
    ;
    private final String codeType;
    private final String value;
    private final String name;

    DictItemEnum(String codeType, String value, String name) {
        this.codeType = codeType;
        this.value = value;
        this.name = name;
    }

    public String getCodeType() {
        return codeType;
    }

    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }

    public static String getName(String value) {
        for (DictItemEnum entry : values()) {
            if (entry.getValue().equals(value)) {
                return entry.getName();
            }
        }
        return null;
    }

    public static DictItemEnum getData(String value) {
        for (DictItemEnum entry : values()) {
            if(!Objects.isNull(entry.getValue())){
                if (entry.getValue().equals(value)) {
                    return entry;
                }
            }

        }
        return DictItemEnum.ALTITUDE_NULL;
    }
    public static int getHasBool(String value) {
        for (DictItemEnum entry : values()) {
            if(!Objects.isNull(entry.getValue())){
                if (entry.getValue().equals(value)) {
                    return 1;
                }
            }

        }

        return 0;
    }

    public static List<Map<String,String>> getAll() {
        Map<String,String> map = new HashMap<>();
        List<Map<String,String>> list = new ArrayList<>();
        for (DictItemEnum entry : values()) {
            if(!"ISNULL".equals(entry.getValue())){
                map.put(entry.getValue(),entry.getName());
            }
        }
        list.add(map);
        return list;
    }
}
