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

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

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/***
 *
 * @Title:
 * @Author: xuxin
 * @CreateTime: 2023-07-04 13:17
 * @Description
 *
 **/
public enum WaterConcentrationEnum {

    cod_concentration("codConcentration","W01018","COD浓度"),
    nitrogen_concentration("nitrogenConcentration","W21001","总氮浓度"),
    phosphorus_concentration("phosphorusConcentration","W21011","总磷浓度"),
    ;

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

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

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

    WaterConcentrationEnum(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(WaterConcentrationEnum waterConcentrationEnum){
        return PollutantEntity.builder()
                .propName(waterConcentrationEnum.getPollutantsName())
                .pollutantsCode(waterConcentrationEnum.getPollutantsCode())
                .pollutantsName(waterConcentrationEnum.getPollutantsName()).build();
    }

    public static PollutantEntity  getDataByPollutant(String pollutantsCode){

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

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

                return getPollutantEntity(value);

            }

        }
        return null;
    }

}
