package com.njcn.influx.bo.po;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.njcn.influx.utils.InstantDateSerializer;
import com.njcn.oracle.bo.po.DataHarmphasicI;
import lombok.Data;
import org.influxdb.annotation.Column;
import org.influxdb.annotation.Measurement;
import org.influxdb.annotation.TimeColumn;

import java.time.Instant;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 */
@Data
@Measurement(name = "data_harmphasic_i")
public class InfluxDBDataHarmphasicI {

    @TimeColumn
    @Column(name = "time",tag = true)
    @JsonSerialize(using = InstantDateSerializer.class)
    private Instant time;

    @Column(name = "line_id",tag = true)
    private String lineId;

    @Column(name = "phasic_type",tag = true)
    private String phaseType;

    @Column(name = "quality_flag",tag = true)
    private String qualityFlag;

    @Column(name = "value_type",tag = true)
    private String valueType;

    @Column(name = "i_1")
    private Float i1;

    @Column(name = "i_2")
    private Float i2;

    @Column(name = "i_3")
    private Float i3;

    @Column(name = "i_4")
    private Float i4;

    @Column(name = "i_5")
    private Float i5;

    @Column(name = "i_6")
    private Float i6;

    @Column(name = "i_7")
    private Float i7;

    @Column(name = "i_8")
    private Float i8;

    @Column(name = "i_9")
    private Float i9;

    @Column(name = "i_10")
    private Float i10;

    @Column(name = "i_11")
    private Float i11;

    @Column(name = "i_12")
    private Float i12;

    @Column(name = "i_13")
    private Float i13;

    @Column(name = "i_14")
    private Float i14;

    @Column(name = "i_15")
    private Float i15;

    @Column(name = "i_16")
    private Float i16;

    @Column(name = "i_17")
    private Float i17;

    @Column(name = "i_18")
    private Float i18;

    @Column(name = "i_19")
    private Float i19;

    @Column(name = "i_20")
    private Float i20;

    @Column(name = "i_21")
    private Float i21;

    @Column(name = "i_22")
    private Float i22;

    @Column(name = "i_23")
    private Float i23;

    @Column(name = "i_24")
    private Float i24;

    @Column(name = "i_25")
    private Float i25;

    @Column(name = "i_26")
    private Float i26;

    @Column(name = "i_27")
    private Float i27;

    @Column(name = "i_28")
    private Float i28;

    @Column(name = "i_29")
    private Float i29;

    @Column(name = "i_30")
    private Float i30;

    @Column(name = "i_31")
    private Float i31;

    @Column(name = "i_32")
    private Float i32;

    @Column(name = "i_33")
    private Float i33;

    @Column(name = "i_34")
    private Float i34;

    @Column(name = "i_35")
    private Float i35;

    @Column(name = "i_36")
    private Float i36;

    @Column(name = "i_37")
    private Float i37;

    @Column(name = "i_38")
    private Float i38;

    @Column(name = "i_39")
    private Float i39;

    @Column(name = "i_40")
    private Float i40;

    @Column(name = "i_41")
    private Float i41;

    @Column(name = "i_42")
    private Float i42;

    @Column(name = "i_43")
    private Float i43;

    @Column(name = "i_44")
    private Float i44;

    @Column(name = "i_45")
    private Float i45;

    @Column(name = "i_46")
    private Float i46;

    @Column(name = "i_47")
    private Float i47;

    @Column(name = "i_48")
    private Float i48;

    @Column(name = "i_49")
    private Float i49;

    @Column(name = "i_50")
    private Float i50;


    public static List<InfluxDBDataHarmphasicI> oralceToInfluxDB(DataHarmphasicI dataHarmphasicI) {
        if (dataHarmphasicI == null) {
            return null;
        }
        List<InfluxDBDataHarmphasicI> influxDBDataHarmPhasicIList = new ArrayList<>();
        List<String> valueTypeList = Stream.of("AVG", "MAX", "MIN", "CP95").collect(Collectors.toList());
        for (String valueType : valueTypeList) {
            InfluxDBDataHarmphasicI influxDBDataHarmPhasicI = new InfluxDBDataHarmphasicI();
            Instant instant = dataHarmphasicI.getTimeid().atZone(ZoneId.systemDefault()).toInstant();

            influxDBDataHarmPhasicI.setTime(instant);
            influxDBDataHarmPhasicI.setLineId(dataHarmphasicI.getLineid());
            influxDBDataHarmPhasicI.setPhaseType(dataHarmphasicI.getPhasicType());
            influxDBDataHarmPhasicI.setQualityFlag(dataHarmphasicI.getQualityflag()+"");
            influxDBDataHarmPhasicI.setValueType(valueType);
            if (valueType.equals("AVG")) {
                influxDBDataHarmPhasicI.setI1(dataHarmphasicI.getI1());
                influxDBDataHarmPhasicI.setI2(dataHarmphasicI.getI2());
                influxDBDataHarmPhasicI.setI3(dataHarmphasicI.getI3());
                influxDBDataHarmPhasicI.setI4(dataHarmphasicI.getI4());
                influxDBDataHarmPhasicI.setI5(dataHarmphasicI.getI5());
                influxDBDataHarmPhasicI.setI6(dataHarmphasicI.getI6());
                influxDBDataHarmPhasicI.setI7(dataHarmphasicI.getI7());
                influxDBDataHarmPhasicI.setI8(dataHarmphasicI.getI8());
                influxDBDataHarmPhasicI.setI9(dataHarmphasicI.getI9());
                influxDBDataHarmPhasicI.setI10(dataHarmphasicI.getI10());
                influxDBDataHarmPhasicI.setI11(dataHarmphasicI.getI11());
                influxDBDataHarmPhasicI.setI12(dataHarmphasicI.getI12());
                influxDBDataHarmPhasicI.setI13(dataHarmphasicI.getI13());
                influxDBDataHarmPhasicI.setI14(dataHarmphasicI.getI14());
                influxDBDataHarmPhasicI.setI15(dataHarmphasicI.getI15());
                influxDBDataHarmPhasicI.setI16(dataHarmphasicI.getI16());
                influxDBDataHarmPhasicI.setI17(dataHarmphasicI.getI17());
                influxDBDataHarmPhasicI.setI18(dataHarmphasicI.getI18());
                influxDBDataHarmPhasicI.setI19(dataHarmphasicI.getI19());
                influxDBDataHarmPhasicI.setI20(dataHarmphasicI.getI20());
                influxDBDataHarmPhasicI.setI21(dataHarmphasicI.getI21());
                influxDBDataHarmPhasicI.setI22(dataHarmphasicI.getI22());
                influxDBDataHarmPhasicI.setI23(dataHarmphasicI.getI23());
                influxDBDataHarmPhasicI.setI24(dataHarmphasicI.getI24());
                influxDBDataHarmPhasicI.setI25(dataHarmphasicI.getI25());
                influxDBDataHarmPhasicI.setI26(dataHarmphasicI.getI26());
                influxDBDataHarmPhasicI.setI27(dataHarmphasicI.getI27());
                influxDBDataHarmPhasicI.setI28(dataHarmphasicI.getI28());
                influxDBDataHarmPhasicI.setI29(dataHarmphasicI.getI29());
                influxDBDataHarmPhasicI.setI30(dataHarmphasicI.getI30());
                influxDBDataHarmPhasicI.setI31(dataHarmphasicI.getI31());
                influxDBDataHarmPhasicI.setI32(dataHarmphasicI.getI32());
                influxDBDataHarmPhasicI.setI33(dataHarmphasicI.getI33());
                influxDBDataHarmPhasicI.setI34(dataHarmphasicI.getI34());
                influxDBDataHarmPhasicI.setI35(dataHarmphasicI.getI35());
                influxDBDataHarmPhasicI.setI36(dataHarmphasicI.getI36());
                influxDBDataHarmPhasicI.setI37(dataHarmphasicI.getI37());
                influxDBDataHarmPhasicI.setI38(dataHarmphasicI.getI38());
                influxDBDataHarmPhasicI.setI39(dataHarmphasicI.getI39());
                influxDBDataHarmPhasicI.setI40(dataHarmphasicI.getI40());
                influxDBDataHarmPhasicI.setI41(dataHarmphasicI.getI41());
                influxDBDataHarmPhasicI.setI42(dataHarmphasicI.getI42());
                influxDBDataHarmPhasicI.setI43(dataHarmphasicI.getI43());
                influxDBDataHarmPhasicI.setI44(dataHarmphasicI.getI44());
                influxDBDataHarmPhasicI.setI45(dataHarmphasicI.getI45());
                influxDBDataHarmPhasicI.setI46(dataHarmphasicI.getI46());
                influxDBDataHarmPhasicI.setI47(dataHarmphasicI.getI47());
                influxDBDataHarmPhasicI.setI48(dataHarmphasicI.getI48());
                influxDBDataHarmPhasicI.setI49(dataHarmphasicI.getI49());
                influxDBDataHarmPhasicI.setI50(dataHarmphasicI.getI50());
            }
            else if (valueType.equals("MAX")){
                influxDBDataHarmPhasicI.setI1(dataHarmphasicI.getI1Max());
                influxDBDataHarmPhasicI.setI2(dataHarmphasicI.getI2Max());
                influxDBDataHarmPhasicI.setI3(dataHarmphasicI.getI3Max());
                influxDBDataHarmPhasicI.setI4(dataHarmphasicI.getI4Max());
                influxDBDataHarmPhasicI.setI5(dataHarmphasicI.getI5Max());
                influxDBDataHarmPhasicI.setI6(dataHarmphasicI.getI6Max());
                influxDBDataHarmPhasicI.setI7(dataHarmphasicI.getI7Max());
                influxDBDataHarmPhasicI.setI8(dataHarmphasicI.getI8Max());
                influxDBDataHarmPhasicI.setI9(dataHarmphasicI.getI9Max());
                influxDBDataHarmPhasicI.setI10(dataHarmphasicI.getI10Max());
                influxDBDataHarmPhasicI.setI11(dataHarmphasicI.getI11Max());
                influxDBDataHarmPhasicI.setI12(dataHarmphasicI.getI12Max());
                influxDBDataHarmPhasicI.setI13(dataHarmphasicI.getI13Max());
                influxDBDataHarmPhasicI.setI14(dataHarmphasicI.getI14Max());
                influxDBDataHarmPhasicI.setI15(dataHarmphasicI.getI15Max());
                influxDBDataHarmPhasicI.setI16(dataHarmphasicI.getI16Max());
                influxDBDataHarmPhasicI.setI17(dataHarmphasicI.getI17Max());
                influxDBDataHarmPhasicI.setI18(dataHarmphasicI.getI18Max());
                influxDBDataHarmPhasicI.setI19(dataHarmphasicI.getI19Max());
                influxDBDataHarmPhasicI.setI20(dataHarmphasicI.getI20Max());
                influxDBDataHarmPhasicI.setI21(dataHarmphasicI.getI21Max());
                influxDBDataHarmPhasicI.setI22(dataHarmphasicI.getI22Max());
                influxDBDataHarmPhasicI.setI23(dataHarmphasicI.getI23Max());
                influxDBDataHarmPhasicI.setI24(dataHarmphasicI.getI24Max());
                influxDBDataHarmPhasicI.setI25(dataHarmphasicI.getI25Max());
                influxDBDataHarmPhasicI.setI26(dataHarmphasicI.getI26Max());
                influxDBDataHarmPhasicI.setI27(dataHarmphasicI.getI27Max());
                influxDBDataHarmPhasicI.setI28(dataHarmphasicI.getI28Max());
                influxDBDataHarmPhasicI.setI29(dataHarmphasicI.getI29Max());
                influxDBDataHarmPhasicI.setI30(dataHarmphasicI.getI30Max());
                influxDBDataHarmPhasicI.setI31(dataHarmphasicI.getI31Max());
                influxDBDataHarmPhasicI.setI32(dataHarmphasicI.getI32Max());
                influxDBDataHarmPhasicI.setI33(dataHarmphasicI.getI33Max());
                influxDBDataHarmPhasicI.setI34(dataHarmphasicI.getI34Max());
                influxDBDataHarmPhasicI.setI35(dataHarmphasicI.getI35Max());
                influxDBDataHarmPhasicI.setI36(dataHarmphasicI.getI36Max());
                influxDBDataHarmPhasicI.setI37(dataHarmphasicI.getI37Max());
                influxDBDataHarmPhasicI.setI38(dataHarmphasicI.getI38Max());
                influxDBDataHarmPhasicI.setI39(dataHarmphasicI.getI39Max());
                influxDBDataHarmPhasicI.setI40(dataHarmphasicI.getI40Max());
                influxDBDataHarmPhasicI.setI41(dataHarmphasicI.getI41Max());
                influxDBDataHarmPhasicI.setI42(dataHarmphasicI.getI42Max());
                influxDBDataHarmPhasicI.setI43(dataHarmphasicI.getI43Max());
                influxDBDataHarmPhasicI.setI44(dataHarmphasicI.getI44Max());
                influxDBDataHarmPhasicI.setI45(dataHarmphasicI.getI45Max());
                influxDBDataHarmPhasicI.setI46(dataHarmphasicI.getI46Max());
                influxDBDataHarmPhasicI.setI47(dataHarmphasicI.getI47Max());
                influxDBDataHarmPhasicI.setI48(dataHarmphasicI.getI48Max());
                influxDBDataHarmPhasicI.setI49(dataHarmphasicI.getI49Max());
                influxDBDataHarmPhasicI.setI50(dataHarmphasicI.getI50Max());
            }
            else if (valueType.equals("MIN")){
                influxDBDataHarmPhasicI.setI1(dataHarmphasicI.getI1Min());
                influxDBDataHarmPhasicI.setI2(dataHarmphasicI.getI2Min());
                influxDBDataHarmPhasicI.setI3(dataHarmphasicI.getI3Min());
                influxDBDataHarmPhasicI.setI4(dataHarmphasicI.getI4Min());
                influxDBDataHarmPhasicI.setI5(dataHarmphasicI.getI5Min());
                influxDBDataHarmPhasicI.setI6(dataHarmphasicI.getI6Min());
                influxDBDataHarmPhasicI.setI7(dataHarmphasicI.getI7Min());
                influxDBDataHarmPhasicI.setI8(dataHarmphasicI.getI8Min());
                influxDBDataHarmPhasicI.setI9(dataHarmphasicI.getI9Min());
                influxDBDataHarmPhasicI.setI10(dataHarmphasicI.getI10Min());
                influxDBDataHarmPhasicI.setI11(dataHarmphasicI.getI11Min());
                influxDBDataHarmPhasicI.setI12(dataHarmphasicI.getI12Min());
                influxDBDataHarmPhasicI.setI13(dataHarmphasicI.getI13Min());
                influxDBDataHarmPhasicI.setI14(dataHarmphasicI.getI14Min());
                influxDBDataHarmPhasicI.setI15(dataHarmphasicI.getI15Min());
                influxDBDataHarmPhasicI.setI16(dataHarmphasicI.getI16Min());
                influxDBDataHarmPhasicI.setI17(dataHarmphasicI.getI17Min());
                influxDBDataHarmPhasicI.setI18(dataHarmphasicI.getI18Min());
                influxDBDataHarmPhasicI.setI19(dataHarmphasicI.getI19Min());
                influxDBDataHarmPhasicI.setI20(dataHarmphasicI.getI20Min());
                influxDBDataHarmPhasicI.setI21(dataHarmphasicI.getI21Min());
                influxDBDataHarmPhasicI.setI22(dataHarmphasicI.getI22Min());
                influxDBDataHarmPhasicI.setI23(dataHarmphasicI.getI23Min());
                influxDBDataHarmPhasicI.setI24(dataHarmphasicI.getI24Min());
                influxDBDataHarmPhasicI.setI25(dataHarmphasicI.getI25Min());
                influxDBDataHarmPhasicI.setI26(dataHarmphasicI.getI26Min());
                influxDBDataHarmPhasicI.setI27(dataHarmphasicI.getI27Min());
                influxDBDataHarmPhasicI.setI28(dataHarmphasicI.getI28Min());
                influxDBDataHarmPhasicI.setI29(dataHarmphasicI.getI29Min());
                influxDBDataHarmPhasicI.setI30(dataHarmphasicI.getI30Min());
                influxDBDataHarmPhasicI.setI31(dataHarmphasicI.getI31Min());
                influxDBDataHarmPhasicI.setI32(dataHarmphasicI.getI32Min());
                influxDBDataHarmPhasicI.setI33(dataHarmphasicI.getI33Min());
                influxDBDataHarmPhasicI.setI34(dataHarmphasicI.getI34Min());
                influxDBDataHarmPhasicI.setI35(dataHarmphasicI.getI35Min());
                influxDBDataHarmPhasicI.setI36(dataHarmphasicI.getI36Min());
                influxDBDataHarmPhasicI.setI37(dataHarmphasicI.getI37Min());
                influxDBDataHarmPhasicI.setI38(dataHarmphasicI.getI38Min());
                influxDBDataHarmPhasicI.setI39(dataHarmphasicI.getI39Min());
                influxDBDataHarmPhasicI.setI40(dataHarmphasicI.getI40Min());
                influxDBDataHarmPhasicI.setI41(dataHarmphasicI.getI41Min());
                influxDBDataHarmPhasicI.setI42(dataHarmphasicI.getI42Min());
                influxDBDataHarmPhasicI.setI43(dataHarmphasicI.getI43Min());
                influxDBDataHarmPhasicI.setI44(dataHarmphasicI.getI44Min());
                influxDBDataHarmPhasicI.setI45(dataHarmphasicI.getI45Min());
                influxDBDataHarmPhasicI.setI46(dataHarmphasicI.getI46Min());
                influxDBDataHarmPhasicI.setI47(dataHarmphasicI.getI47Min());
                influxDBDataHarmPhasicI.setI48(dataHarmphasicI.getI48Min());
                influxDBDataHarmPhasicI.setI49(dataHarmphasicI.getI49Min());
                influxDBDataHarmPhasicI.setI50(dataHarmphasicI.getI50Min());
            }
            else if (valueType.equals("CP95")){
                influxDBDataHarmPhasicI.setI1(dataHarmphasicI.getI1Cp95());
                influxDBDataHarmPhasicI.setI2(dataHarmphasicI.getI2Cp95());
                influxDBDataHarmPhasicI.setI3(dataHarmphasicI.getI3Cp95());
                influxDBDataHarmPhasicI.setI4(dataHarmphasicI.getI4Cp95());
                influxDBDataHarmPhasicI.setI5(dataHarmphasicI.getI5Cp95());
                influxDBDataHarmPhasicI.setI6(dataHarmphasicI.getI6Cp95());
                influxDBDataHarmPhasicI.setI7(dataHarmphasicI.getI7Cp95());
                influxDBDataHarmPhasicI.setI8(dataHarmphasicI.getI8Cp95());
                influxDBDataHarmPhasicI.setI9(dataHarmphasicI.getI9Cp95());
                influxDBDataHarmPhasicI.setI10(dataHarmphasicI.getI10Cp95());
                influxDBDataHarmPhasicI.setI11(dataHarmphasicI.getI11Cp95());
                influxDBDataHarmPhasicI.setI12(dataHarmphasicI.getI12Cp95());
                influxDBDataHarmPhasicI.setI13(dataHarmphasicI.getI13Cp95());
                influxDBDataHarmPhasicI.setI14(dataHarmphasicI.getI14Cp95());
                influxDBDataHarmPhasicI.setI15(dataHarmphasicI.getI15Cp95());
                influxDBDataHarmPhasicI.setI16(dataHarmphasicI.getI16Cp95());
                influxDBDataHarmPhasicI.setI17(dataHarmphasicI.getI17Cp95());
                influxDBDataHarmPhasicI.setI18(dataHarmphasicI.getI18Cp95());
                influxDBDataHarmPhasicI.setI19(dataHarmphasicI.getI19Cp95());
                influxDBDataHarmPhasicI.setI20(dataHarmphasicI.getI20Cp95());
                influxDBDataHarmPhasicI.setI21(dataHarmphasicI.getI21Cp95());
                influxDBDataHarmPhasicI.setI22(dataHarmphasicI.getI22Cp95());
                influxDBDataHarmPhasicI.setI23(dataHarmphasicI.getI23Cp95());
                influxDBDataHarmPhasicI.setI24(dataHarmphasicI.getI24Cp95());
                influxDBDataHarmPhasicI.setI25(dataHarmphasicI.getI25Cp95());
                influxDBDataHarmPhasicI.setI26(dataHarmphasicI.getI26Cp95());
                influxDBDataHarmPhasicI.setI27(dataHarmphasicI.getI27Cp95());
                influxDBDataHarmPhasicI.setI28(dataHarmphasicI.getI28Cp95());
                influxDBDataHarmPhasicI.setI29(dataHarmphasicI.getI29Cp95());
                influxDBDataHarmPhasicI.setI30(dataHarmphasicI.getI30Cp95());
                influxDBDataHarmPhasicI.setI31(dataHarmphasicI.getI31Cp95());
                influxDBDataHarmPhasicI.setI32(dataHarmphasicI.getI32Cp95());
                influxDBDataHarmPhasicI.setI33(dataHarmphasicI.getI33Cp95());
                influxDBDataHarmPhasicI.setI34(dataHarmphasicI.getI34Cp95());
                influxDBDataHarmPhasicI.setI35(dataHarmphasicI.getI35Cp95());
                influxDBDataHarmPhasicI.setI36(dataHarmphasicI.getI36Cp95());
                influxDBDataHarmPhasicI.setI37(dataHarmphasicI.getI37Cp95());
                influxDBDataHarmPhasicI.setI38(dataHarmphasicI.getI38Cp95());
                influxDBDataHarmPhasicI.setI39(dataHarmphasicI.getI39Cp95());
                influxDBDataHarmPhasicI.setI40(dataHarmphasicI.getI40Cp95());
                influxDBDataHarmPhasicI.setI41(dataHarmphasicI.getI41Cp95());
                influxDBDataHarmPhasicI.setI42(dataHarmphasicI.getI42Cp95());
                influxDBDataHarmPhasicI.setI43(dataHarmphasicI.getI43Cp95());
                influxDBDataHarmPhasicI.setI44(dataHarmphasicI.getI44Cp95());
                influxDBDataHarmPhasicI.setI45(dataHarmphasicI.getI45Cp95());
                influxDBDataHarmPhasicI.setI46(dataHarmphasicI.getI46Cp95());
                influxDBDataHarmPhasicI.setI47(dataHarmphasicI.getI47Cp95());
                influxDBDataHarmPhasicI.setI48(dataHarmphasicI.getI48Cp95());
                influxDBDataHarmPhasicI.setI49(dataHarmphasicI.getI49Cp95());
                influxDBDataHarmPhasicI.setI50(dataHarmphasicI.getI50Cp95());
            }

            influxDBDataHarmPhasicIList.add(influxDBDataHarmPhasicI);

        }



        return influxDBDataHarmPhasicIList;
    }
}
