package com.tofly.em;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

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

/**
 * 指标类型信息管理
 *
 * @author JF
 */
@Getter
@AllArgsConstructor
public enum IndexTypeInfoEnum {

    INSTANTANEOUS_FLOW("1", "instantaneous_flow", "瞬时流量", 0L, "m³/h"),
    CURRENT("2", "current", "电流", 2L, "A"),
    CUM_FLOW("4", "cum_flow", "累计流量", 1L, "m³"),
    PRESSURE("5", "pressure", "压力", 2L, "Mpa"),
    PH("6", "ph", "PH", 2L, null),
    LIQUID_LEVEL("7", "liquid_level", "液位", 2L, "m"),
    RESIDUAL_CHLORINE("8", "residual_chlorine", "余氯", 2L, "mg/L"),
    TOTAL_NITROGEN("9", "total_nitrogen", "总氮", 2L, "mg/L"),
    TURBIDITY("10", "turbidity", "浊度", 3L, "NTU"),
    FREQUENCY_FEEDBACK("11", "frequency_feedback", "频率反馈", 2L, "Hz"),
    OPENING_FEEDBACK("12", "opening_feedback", "阀门开度反馈", 2L, "%"),
    DO("13", "do", "溶解氧", 2L, "mg/L"),
    CONDUCTIVITY("14", "conductivity", "电导率", 2L, "S/m"),
    AMMONIA_NITROGEN("15", "ammonia_nitrogen", "氨氮", 2L, "mg/L"),
    PERMANGANATE("16", "permanganate", "高锰酸盐", 2L, "mg/L"),
    TOTAL_PHOSPHORUS("17", "total_phosphorus", "总磷", 2L, "mg/L"),
    SLUDGE_INTERFACE("18", "sludge_interface", "污泥界面仪", 1L, null),
    HEAD_LOSS("19", "head_loss", "水头损失", 2L, "m³"),
    TEMPERATURE("20", "temperature", "温度", 2L, "℃"),
    ORP("21", "orp", "ORP", 2L, ""),
    VOLTAGE("22", "voltage", "电压", 2L, "V"),
    ;

    /**
     * ID
     */
    private String id;
    /**
     * 编码
     */
    private String code;
    /**
     * 名称
     */
    private String name;
    /**
     * 精度
     */
    private Long accuracy;
    /**
     * 单位
     */
    private String unit;

    /**
     * 获取指标类型信息列表
     */
    public static List<IndexTypeInfoVo> getIndexTypeInfoList() {
        return Arrays.stream(values())
                .map(indexTypeInfoEnum -> new IndexTypeInfoVo(
                        indexTypeInfoEnum.getId(),
                        indexTypeInfoEnum.getCode(),
                        indexTypeInfoEnum.getName(),
                        indexTypeInfoEnum.getAccuracy(),
                        indexTypeInfoEnum.getUnit()))
                .collect(Collectors.toList());
    }

    @Data
    @AllArgsConstructor
    public static class IndexTypeInfoVo implements Serializable {
        private static final long serialVersionUID = 1L;

        /**
         * ID
         */
        private String id;
        /**
         * 编码
         */
        private String code;
        /**
         * 名称
         */
        private String name;
        /**
         * 精度
         */
        private Long accuracy;
        /**
         * 单位
         */
        private String unit;
    }
}
