package cn.cecep.talroad.data.analyse.task.real.concentration;

import cn.cecep.talroad.data.analyse.task.entity.PollutantEntity;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public enum GasConcentrationEnum {

    so2("so2","A21026","二氧化硫"),
    nox("nox","A21002","氮氧化物"),
    no("no","A21003","一氧化氮"),
    no2("no2","A21004","二氧化氮"),
    smokeDust("smokeDust","A34013","烟尘"),
    pm("pm","A99911","颗粒物实测"),
    vocs("vocs","A99907","voc实测"),

    ;

    /**
     * 表中的参数字段
     */
    private String param;

    /**
     * 污染物code
     */
    private String pollutantsCode;

    /**
     * 污染物名称
     */
    private String pollutantsName;

    GasConcentrationEnum(String param, String pollutantsCode, String pollutantsName) {
        this.param = param;
        this.pollutantsCode = pollutantsCode;
        this.pollutantsName = pollutantsName;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public String getPollutantsCode() {
        return pollutantsCode;
    }

    public void setPollutantsCode(String pollutantsCode) {
        this.pollutantsCode = pollutantsCode;
    }

    public String getPollutantsName() {
        return pollutantsName;
    }

    public void setPollutantsName(String pollutantsName) {
        this.pollutantsName = pollutantsName;
    }

    public static List<PollutantEntity> getPollutantEntity(){
        return Arrays.stream(GasConcentrationEnum.values()).map(GasConcentrationEnum::getPollutantEntity).collect(Collectors.toList());
    }

    public static PollutantEntity getPollutantEntity(GasConcentrationEnum gasConcentrationEnum){
        return PollutantEntity.builder()
                .propName(gasConcentrationEnum.getPollutantsName())
                .pollutantsCode(gasConcentrationEnum.getPollutantsCode())
                .pollutantsName(gasConcentrationEnum.getPollutantsName()).build();
    }

    public static PollutantEntity  getDataByPollutant(String pollutantsCode){

        for (GasConcentrationEnum value : GasConcentrationEnum.values()) {

            if (value.getPollutantsCode().equals(pollutantsCode)){

                return getPollutantEntity(value);

            }

        }
        return null;
    }
}
