package com.ningdatech.carapi.industry.enums;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 运营商考核指标枚举
 *
 * @author CMM
 * @since 2023/01/05 09:37
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "OperatorAssessmentIndexEnum", description = "运营商考核指标-枚举")
public enum OperatorAssessmentIndexEnum {
    /**
     * 上传资质
     */
    UPLOAD_QUALIFICATION(1,"上传资质"),

    /**
     *上传频率、数量
     */
    UPLOAD_FREQUENCY_QUANTITY(2,"上传频率、数量"),

    /**
     * 字段完整性
     */
    FIELD_INTEGRITY(3,"字段完整性"),

    /**
     * 时效性
     */
    TIME_SENSITIVE(4,"时效性"),

    /**
     * 位置及方向的正确性、一致性
     */
    POSITION_DIRECTION_CORRECTNESS_CONSISTENCY(5,"位置及方向的正确性、一致性"),

    /**
     * 速度的正确性、一致性
     */
    SPEED_CORRECTNESS_CONSISTENCY(6,"速度的正确性、一致性"),

    /**
     * 时间一致性
     */
    TIME_CONSISTENCY(7,"时间一致性"),

    /**
     * 位置一致性
     */
    POSITION_CONSISTENCY(8,"位置一致性");


    private Integer code;
    private String desc;

    public String getDesc() {
        return desc;
    }

    public Integer getCode() {
        return code;
    }

    public static String getDescByCode(Integer code) {
        if(Objects.isNull(code)){
            return StringUtils.EMPTY;
        }
        for (OperatorAssessmentIndexEnum t : OperatorAssessmentIndexEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static OperatorAssessmentIndexEnum getEnumByValue(Integer code) {
        if(Objects.isNull(code)){
            return null;
        }
        for (OperatorAssessmentIndexEnum t : OperatorAssessmentIndexEnum.values()) {
            if (code.equals(t.getCode())) {
                return t;
            }
        }
        return null;
    }
    public boolean eq(String val) {
        return this.name().equals(val);
    }
}
