package com.njcn.supervision.enums;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum ProblemTypeEnum {

    PLAN(1, "技术监督计划"),
    ONLINE(2, "在线监测超标问题"),
    USER(3, "用户投诉问题"),
    SITE_TEST(4, "试运行监测点问题");

    private final Integer code;

    private final String name;

    ProblemTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(Integer code) {
        ProblemTypeEnum problemTypeEnumTemp = Arrays.stream(ProblemTypeEnum.values())
                .filter(problemTypeEnum -> problemTypeEnum.getCode().equals(code))
                .findAny()
                .orElse(PLAN);
        return problemTypeEnumTemp.getName();
    }
}
