package com.ningdatech.carapi.industry.enums;

import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @return
 * @author CMM
 * @since 2023/01/04 14:18
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "DataQualityMonitorGpsEnum", description = "数据质量监控Gps异常原因-枚举")
public enum DataQualityMonitorGpsEnum {
    /**
     * 上传资质异常
     */
    UPLOAD_QUALIFICATION_ANOMALY(1,"上传资质异常"),

    /**
     *上传频率异常
     */
    UPLOAD_FREQUENCY_ANOMALY(2,"上传频率异常"),

    /**
     *上传数量异常
     */
    UPLOAD_QUANTITY_ANOMALY(4,"上传数量异常"),

    /**
     * 字段完整性异常
     */
    FIELD_INTEGRITY_ANOMALY(8,"字段完整性异常"),

    /**
     * 时效性异常
     */
    TIME_SENSITIVE_ANOMALY(16,"时效性异常"),

    /**
     * 位置及方向的正确性、一致性异常
     */
    POSITION_DIRECTION_CORRECTNESS_CONSISTENCY_ANOMALY(32,"位置及方向的正确性、一致性异常"),

    /**
     * 速度的正确性、一致性异常
     */
    SPEED_CORRECTNESS_CONSISTENCY_ANOMALY(64,"速度的正确性、一致性异常"),

    /**
     * 时间一致性异常
     */
    TIME_CONSISTENCY_ANOMALY(128,"时间一致性异常"),

    /**
     * 位置一致性异常
     */
    POSITION_CONSISTENCY_ANOMALY(256,"位置一致性异常");


    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 (DataQualityMonitorGpsEnum t : DataQualityMonitorGpsEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static DataQualityMonitorGpsEnum getEnumByValue(Integer code) {
        if(Objects.isNull(code)){
            return null;
        }
        for (DataQualityMonitorGpsEnum t : DataQualityMonitorGpsEnum.values()) {
            if (code.equals(t.getCode())) {
                return t;
            }
        }
        return null;
    }


    public boolean eq(String val) {
        return this.name().equals(val);
    }
}
