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.DataInharmI;
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
 * @createTime 2022/5/12 11:27
 */
@Data
@Measurement(name = "data_inharm_i")
public class InfluxDBDataInharmI {

    @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<InfluxDBDataInharmI> oralceToInfluxDB(DataInharmI dataInharmI) {
        if (dataInharmI == null) {
            return null;
        }
        List<InfluxDBDataInharmI> influxDBDataInHarmIList = new ArrayList<>();
        List<String> valueTypeList = Stream.of("AVG", "MAX", "MIN", "CP95").collect(Collectors.toList());
        for (String valueType : valueTypeList) {
            InfluxDBDataInharmI influxDBDataInHarmI = new InfluxDBDataInharmI();
            Instant instant = dataInharmI.getTimeid().atZone(ZoneId.systemDefault()).toInstant();

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

            influxDBDataInHarmIList.add(influxDBDataInHarmI);

        }



        return influxDBDataInHarmIList;
    }


}
