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.DataHarmphasicV;
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 9:13
 */
@Data
@Measurement(name = "data_harmphasic_v")
public class InfluxDBDataHarmphasicV {

    @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 = "v_1")
    private Float v1;

    @Column(name = "v_2")
    private Float v2;

    @Column(name = "v_3")
    private Float v3;

    @Column(name = "v_4")
    private Float v4;

    @Column(name = "v_5")
    private Float v5;

    @Column(name = "v_6")
    private Float v6;

    @Column(name = "v_7")
    private Float v7;

    @Column(name = "v_8")
    private Float v8;

    @Column(name = "v_9")
    private Float v9;

    @Column(name = "v_10")
    private Float v10;

    @Column(name = "v_11")
    private Float v11;

    @Column(name = "v_12")
    private Float v12;

    @Column(name = "v_13")
    private Float v13;

    @Column(name = "v_14")
    private Float v14;

    @Column(name = "v_15")
    private Float v15;

    @Column(name = "v_16")
    private Float v16;

    @Column(name = "v_17")
    private Float v17;

    @Column(name = "v_18")
    private Float v18;

    @Column(name = "v_19")
    private Float v19;

    @Column(name = "v_20")
    private Float v20;

    @Column(name = "v_21")
    private Float v21;

    @Column(name = "v_22")
    private Float v22;

    @Column(name = "v_23")
    private Float v23;

    @Column(name = "v_24")
    private Float v24;

    @Column(name = "v_25")
    private Float v25;

    @Column(name = "v_26")
    private Float v26;

    @Column(name = "v_27")
    private Float v27;

    @Column(name = "v_28")
    private Float v28;

    @Column(name = "v_29")
    private Float v29;

    @Column(name = "v_30")
    private Float v30;

    @Column(name = "v_31")
    private Float v31;

    @Column(name = "v_32")
    private Float v32;

    @Column(name = "v_33")
    private Float v33;

    @Column(name = "v_34")
    private Float v34;

    @Column(name = "v_35")
    private Float v35;

    @Column(name = "v_36")
    private Float v36;

    @Column(name = "v_37")
    private Float v37;

    @Column(name = "v_38")
    private Float v38;

    @Column(name = "v_39")
    private Float v39;

    @Column(name = "v_40")
    private Float v40;

    @Column(name = "v_41")
    private Float v41;

    @Column(name = "v_42")
    private Float v42;

    @Column(name = "v_43")
    private Float v43;

    @Column(name = "v_44")
    private Float v44;

    @Column(name = "v_45")
    private Float v45;

    @Column(name = "v_46")
    private Float v46;

    @Column(name = "v_47")
    private Float v47;

    @Column(name = "v_48")
    private Float v48;

    @Column(name = "v_49")
    private Float v49;

    @Column(name = "v_50")
    private Float v50;

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

            influxDBDataHarmPhasicV.setTime(instant);
            influxDBDataHarmPhasicV.setLineId(dataHarmphasicV.getLineid());
            influxDBDataHarmPhasicV.setPhaseType(dataHarmphasicV.getPhasicType());
            influxDBDataHarmPhasicV.setQualityFlag(dataHarmphasicV.getQualityflag()+"");
            influxDBDataHarmPhasicV.setValueType(valueType);
            if (valueType.equals("AVG")) {
                influxDBDataHarmPhasicV.setV1(dataHarmphasicV.getV1());
                influxDBDataHarmPhasicV.setV2(dataHarmphasicV.getV2());
                influxDBDataHarmPhasicV.setV3(dataHarmphasicV.getV3());
                influxDBDataHarmPhasicV.setV4(dataHarmphasicV.getV4());
                influxDBDataHarmPhasicV.setV5(dataHarmphasicV.getV5());
                influxDBDataHarmPhasicV.setV6(dataHarmphasicV.getV6());
                influxDBDataHarmPhasicV.setV7(dataHarmphasicV.getV7());
                influxDBDataHarmPhasicV.setV8(dataHarmphasicV.getV8());
                influxDBDataHarmPhasicV.setV9(dataHarmphasicV.getV9());
                influxDBDataHarmPhasicV.setV10(dataHarmphasicV.getV10());
                influxDBDataHarmPhasicV.setV11(dataHarmphasicV.getV11());
                influxDBDataHarmPhasicV.setV12(dataHarmphasicV.getV12());
                influxDBDataHarmPhasicV.setV13(dataHarmphasicV.getV13());
                influxDBDataHarmPhasicV.setV14(dataHarmphasicV.getV14());
                influxDBDataHarmPhasicV.setV15(dataHarmphasicV.getV15());
                influxDBDataHarmPhasicV.setV16(dataHarmphasicV.getV16());
                influxDBDataHarmPhasicV.setV17(dataHarmphasicV.getV17());
                influxDBDataHarmPhasicV.setV18(dataHarmphasicV.getV18());
                influxDBDataHarmPhasicV.setV19(dataHarmphasicV.getV19());
                influxDBDataHarmPhasicV.setV20(dataHarmphasicV.getV20());
                influxDBDataHarmPhasicV.setV21(dataHarmphasicV.getV21());
                influxDBDataHarmPhasicV.setV22(dataHarmphasicV.getV22());
                influxDBDataHarmPhasicV.setV23(dataHarmphasicV.getV23());
                influxDBDataHarmPhasicV.setV24(dataHarmphasicV.getV24());
                influxDBDataHarmPhasicV.setV25(dataHarmphasicV.getV25());
                influxDBDataHarmPhasicV.setV26(dataHarmphasicV.getV26());
                influxDBDataHarmPhasicV.setV27(dataHarmphasicV.getV27());
                influxDBDataHarmPhasicV.setV28(dataHarmphasicV.getV28());
                influxDBDataHarmPhasicV.setV29(dataHarmphasicV.getV29());
                influxDBDataHarmPhasicV.setV30(dataHarmphasicV.getV30());
                influxDBDataHarmPhasicV.setV31(dataHarmphasicV.getV31());
                influxDBDataHarmPhasicV.setV32(dataHarmphasicV.getV32());
                influxDBDataHarmPhasicV.setV33(dataHarmphasicV.getV33());
                influxDBDataHarmPhasicV.setV34(dataHarmphasicV.getV34());
                influxDBDataHarmPhasicV.setV35(dataHarmphasicV.getV35());
                influxDBDataHarmPhasicV.setV36(dataHarmphasicV.getV36());
                influxDBDataHarmPhasicV.setV37(dataHarmphasicV.getV37());
                influxDBDataHarmPhasicV.setV38(dataHarmphasicV.getV38());
                influxDBDataHarmPhasicV.setV39(dataHarmphasicV.getV39());
                influxDBDataHarmPhasicV.setV40(dataHarmphasicV.getV40());
                influxDBDataHarmPhasicV.setV41(dataHarmphasicV.getV41());
                influxDBDataHarmPhasicV.setV42(dataHarmphasicV.getV42());
                influxDBDataHarmPhasicV.setV43(dataHarmphasicV.getV43());
                influxDBDataHarmPhasicV.setV44(dataHarmphasicV.getV44());
                influxDBDataHarmPhasicV.setV45(dataHarmphasicV.getV45());
                influxDBDataHarmPhasicV.setV46(dataHarmphasicV.getV46());
                influxDBDataHarmPhasicV.setV47(dataHarmphasicV.getV47());
                influxDBDataHarmPhasicV.setV48(dataHarmphasicV.getV48());
                influxDBDataHarmPhasicV.setV49(dataHarmphasicV.getV49());
                influxDBDataHarmPhasicV.setV50(dataHarmphasicV.getV50());
            }
            else if (valueType.equals("MAX")){
                influxDBDataHarmPhasicV.setV1(dataHarmphasicV.getV1Max());
                influxDBDataHarmPhasicV.setV2(dataHarmphasicV.getV2Max());
                influxDBDataHarmPhasicV.setV3(dataHarmphasicV.getV3Max());
                influxDBDataHarmPhasicV.setV4(dataHarmphasicV.getV4Max());
                influxDBDataHarmPhasicV.setV5(dataHarmphasicV.getV5Max());
                influxDBDataHarmPhasicV.setV6(dataHarmphasicV.getV6Max());
                influxDBDataHarmPhasicV.setV7(dataHarmphasicV.getV7Max());
                influxDBDataHarmPhasicV.setV8(dataHarmphasicV.getV8Max());
                influxDBDataHarmPhasicV.setV9(dataHarmphasicV.getV9Max());
                influxDBDataHarmPhasicV.setV10(dataHarmphasicV.getV10Max());
                influxDBDataHarmPhasicV.setV11(dataHarmphasicV.getV11Max());
                influxDBDataHarmPhasicV.setV12(dataHarmphasicV.getV12Max());
                influxDBDataHarmPhasicV.setV13(dataHarmphasicV.getV13Max());
                influxDBDataHarmPhasicV.setV14(dataHarmphasicV.getV14Max());
                influxDBDataHarmPhasicV.setV15(dataHarmphasicV.getV15Max());
                influxDBDataHarmPhasicV.setV16(dataHarmphasicV.getV16Max());
                influxDBDataHarmPhasicV.setV17(dataHarmphasicV.getV17Max());
                influxDBDataHarmPhasicV.setV18(dataHarmphasicV.getV18Max());
                influxDBDataHarmPhasicV.setV19(dataHarmphasicV.getV19Max());
                influxDBDataHarmPhasicV.setV20(dataHarmphasicV.getV20Max());
                influxDBDataHarmPhasicV.setV21(dataHarmphasicV.getV21Max());
                influxDBDataHarmPhasicV.setV22(dataHarmphasicV.getV22Max());
                influxDBDataHarmPhasicV.setV23(dataHarmphasicV.getV23Max());
                influxDBDataHarmPhasicV.setV24(dataHarmphasicV.getV24Max());
                influxDBDataHarmPhasicV.setV25(dataHarmphasicV.getV25Max());
                influxDBDataHarmPhasicV.setV26(dataHarmphasicV.getV26Max());
                influxDBDataHarmPhasicV.setV27(dataHarmphasicV.getV27Max());
                influxDBDataHarmPhasicV.setV28(dataHarmphasicV.getV28Max());
                influxDBDataHarmPhasicV.setV29(dataHarmphasicV.getV29Max());
                influxDBDataHarmPhasicV.setV30(dataHarmphasicV.getV30Max());
                influxDBDataHarmPhasicV.setV31(dataHarmphasicV.getV31Max());
                influxDBDataHarmPhasicV.setV32(dataHarmphasicV.getV32Max());
                influxDBDataHarmPhasicV.setV33(dataHarmphasicV.getV33Max());
                influxDBDataHarmPhasicV.setV34(dataHarmphasicV.getV34Max());
                influxDBDataHarmPhasicV.setV35(dataHarmphasicV.getV35Max());
                influxDBDataHarmPhasicV.setV36(dataHarmphasicV.getV36Max());
                influxDBDataHarmPhasicV.setV37(dataHarmphasicV.getV37Max());
                influxDBDataHarmPhasicV.setV38(dataHarmphasicV.getV38Max());
                influxDBDataHarmPhasicV.setV39(dataHarmphasicV.getV39Max());
                influxDBDataHarmPhasicV.setV40(dataHarmphasicV.getV40Max());
                influxDBDataHarmPhasicV.setV41(dataHarmphasicV.getV41Max());
                influxDBDataHarmPhasicV.setV42(dataHarmphasicV.getV42Max());
                influxDBDataHarmPhasicV.setV43(dataHarmphasicV.getV43Max());
                influxDBDataHarmPhasicV.setV44(dataHarmphasicV.getV44Max());
                influxDBDataHarmPhasicV.setV45(dataHarmphasicV.getV45Max());
                influxDBDataHarmPhasicV.setV46(dataHarmphasicV.getV46Max());
                influxDBDataHarmPhasicV.setV47(dataHarmphasicV.getV47Max());
                influxDBDataHarmPhasicV.setV48(dataHarmphasicV.getV48Max());
                influxDBDataHarmPhasicV.setV49(dataHarmphasicV.getV49Max());
                influxDBDataHarmPhasicV.setV50(dataHarmphasicV.getV50Max());
            }
            else if (valueType.equals("MIN")){
                influxDBDataHarmPhasicV.setV1(dataHarmphasicV.getV1Min());
                influxDBDataHarmPhasicV.setV2(dataHarmphasicV.getV2Min());
                influxDBDataHarmPhasicV.setV3(dataHarmphasicV.getV3Min());
                influxDBDataHarmPhasicV.setV4(dataHarmphasicV.getV4Min());
                influxDBDataHarmPhasicV.setV5(dataHarmphasicV.getV5Min());
                influxDBDataHarmPhasicV.setV6(dataHarmphasicV.getV6Min());
                influxDBDataHarmPhasicV.setV7(dataHarmphasicV.getV7Min());
                influxDBDataHarmPhasicV.setV8(dataHarmphasicV.getV8Min());
                influxDBDataHarmPhasicV.setV9(dataHarmphasicV.getV9Min());
                influxDBDataHarmPhasicV.setV10(dataHarmphasicV.getV10Min());
                influxDBDataHarmPhasicV.setV11(dataHarmphasicV.getV11Min());
                influxDBDataHarmPhasicV.setV12(dataHarmphasicV.getV12Min());
                influxDBDataHarmPhasicV.setV13(dataHarmphasicV.getV13Min());
                influxDBDataHarmPhasicV.setV14(dataHarmphasicV.getV14Min());
                influxDBDataHarmPhasicV.setV15(dataHarmphasicV.getV15Min());
                influxDBDataHarmPhasicV.setV16(dataHarmphasicV.getV16Min());
                influxDBDataHarmPhasicV.setV17(dataHarmphasicV.getV17Min());
                influxDBDataHarmPhasicV.setV18(dataHarmphasicV.getV18Min());
                influxDBDataHarmPhasicV.setV19(dataHarmphasicV.getV19Min());
                influxDBDataHarmPhasicV.setV20(dataHarmphasicV.getV20Min());
                influxDBDataHarmPhasicV.setV21(dataHarmphasicV.getV21Min());
                influxDBDataHarmPhasicV.setV22(dataHarmphasicV.getV22Min());
                influxDBDataHarmPhasicV.setV23(dataHarmphasicV.getV23Min());
                influxDBDataHarmPhasicV.setV24(dataHarmphasicV.getV24Min());
                influxDBDataHarmPhasicV.setV25(dataHarmphasicV.getV25Min());
                influxDBDataHarmPhasicV.setV26(dataHarmphasicV.getV26Min());
                influxDBDataHarmPhasicV.setV27(dataHarmphasicV.getV27Min());
                influxDBDataHarmPhasicV.setV28(dataHarmphasicV.getV28Min());
                influxDBDataHarmPhasicV.setV29(dataHarmphasicV.getV29Min());
                influxDBDataHarmPhasicV.setV30(dataHarmphasicV.getV30Min());
                influxDBDataHarmPhasicV.setV31(dataHarmphasicV.getV31Min());
                influxDBDataHarmPhasicV.setV32(dataHarmphasicV.getV32Min());
                influxDBDataHarmPhasicV.setV33(dataHarmphasicV.getV33Min());
                influxDBDataHarmPhasicV.setV34(dataHarmphasicV.getV34Min());
                influxDBDataHarmPhasicV.setV35(dataHarmphasicV.getV35Min());
                influxDBDataHarmPhasicV.setV36(dataHarmphasicV.getV36Min());
                influxDBDataHarmPhasicV.setV37(dataHarmphasicV.getV37Min());
                influxDBDataHarmPhasicV.setV38(dataHarmphasicV.getV38Min());
                influxDBDataHarmPhasicV.setV39(dataHarmphasicV.getV39Min());
                influxDBDataHarmPhasicV.setV40(dataHarmphasicV.getV40Min());
                influxDBDataHarmPhasicV.setV41(dataHarmphasicV.getV41Min());
                influxDBDataHarmPhasicV.setV42(dataHarmphasicV.getV42Min());
                influxDBDataHarmPhasicV.setV43(dataHarmphasicV.getV43Min());
                influxDBDataHarmPhasicV.setV44(dataHarmphasicV.getV44Min());
                influxDBDataHarmPhasicV.setV45(dataHarmphasicV.getV45Min());
                influxDBDataHarmPhasicV.setV46(dataHarmphasicV.getV46Min());
                influxDBDataHarmPhasicV.setV47(dataHarmphasicV.getV47Min());
                influxDBDataHarmPhasicV.setV48(dataHarmphasicV.getV48Min());
                influxDBDataHarmPhasicV.setV49(dataHarmphasicV.getV49Min());
                influxDBDataHarmPhasicV.setV50(dataHarmphasicV.getV50Min());
            }
            else if (valueType.equals("CP95")){
                influxDBDataHarmPhasicV.setV1(dataHarmphasicV.getV1Cp95());
                influxDBDataHarmPhasicV.setV2(dataHarmphasicV.getV2Cp95());
                influxDBDataHarmPhasicV.setV3(dataHarmphasicV.getV3Cp95());
                influxDBDataHarmPhasicV.setV4(dataHarmphasicV.getV4Cp95());
                influxDBDataHarmPhasicV.setV5(dataHarmphasicV.getV5Cp95());
                influxDBDataHarmPhasicV.setV6(dataHarmphasicV.getV6Cp95());
                influxDBDataHarmPhasicV.setV7(dataHarmphasicV.getV7Cp95());
                influxDBDataHarmPhasicV.setV8(dataHarmphasicV.getV8Cp95());
                influxDBDataHarmPhasicV.setV9(dataHarmphasicV.getV9Cp95());
                influxDBDataHarmPhasicV.setV10(dataHarmphasicV.getV10Cp95());
                influxDBDataHarmPhasicV.setV11(dataHarmphasicV.getV11Cp95());
                influxDBDataHarmPhasicV.setV12(dataHarmphasicV.getV12Cp95());
                influxDBDataHarmPhasicV.setV13(dataHarmphasicV.getV13Cp95());
                influxDBDataHarmPhasicV.setV14(dataHarmphasicV.getV14Cp95());
                influxDBDataHarmPhasicV.setV15(dataHarmphasicV.getV15Cp95());
                influxDBDataHarmPhasicV.setV16(dataHarmphasicV.getV16Cp95());
                influxDBDataHarmPhasicV.setV17(dataHarmphasicV.getV17Cp95());
                influxDBDataHarmPhasicV.setV18(dataHarmphasicV.getV18Cp95());
                influxDBDataHarmPhasicV.setV19(dataHarmphasicV.getV19Cp95());
                influxDBDataHarmPhasicV.setV20(dataHarmphasicV.getV20Cp95());
                influxDBDataHarmPhasicV.setV21(dataHarmphasicV.getV21Cp95());
                influxDBDataHarmPhasicV.setV22(dataHarmphasicV.getV22Cp95());
                influxDBDataHarmPhasicV.setV23(dataHarmphasicV.getV23Cp95());
                influxDBDataHarmPhasicV.setV24(dataHarmphasicV.getV24Cp95());
                influxDBDataHarmPhasicV.setV25(dataHarmphasicV.getV25Cp95());
                influxDBDataHarmPhasicV.setV26(dataHarmphasicV.getV26Cp95());
                influxDBDataHarmPhasicV.setV27(dataHarmphasicV.getV27Cp95());
                influxDBDataHarmPhasicV.setV28(dataHarmphasicV.getV28Cp95());
                influxDBDataHarmPhasicV.setV29(dataHarmphasicV.getV29Cp95());
                influxDBDataHarmPhasicV.setV30(dataHarmphasicV.getV30Cp95());
                influxDBDataHarmPhasicV.setV31(dataHarmphasicV.getV31Cp95());
                influxDBDataHarmPhasicV.setV32(dataHarmphasicV.getV32Cp95());
                influxDBDataHarmPhasicV.setV33(dataHarmphasicV.getV33Cp95());
                influxDBDataHarmPhasicV.setV34(dataHarmphasicV.getV34Cp95());
                influxDBDataHarmPhasicV.setV35(dataHarmphasicV.getV35Cp95());
                influxDBDataHarmPhasicV.setV36(dataHarmphasicV.getV36Cp95());
                influxDBDataHarmPhasicV.setV37(dataHarmphasicV.getV37Cp95());
                influxDBDataHarmPhasicV.setV38(dataHarmphasicV.getV38Cp95());
                influxDBDataHarmPhasicV.setV39(dataHarmphasicV.getV39Cp95());
                influxDBDataHarmPhasicV.setV40(dataHarmphasicV.getV40Cp95());
                influxDBDataHarmPhasicV.setV41(dataHarmphasicV.getV41Cp95());
                influxDBDataHarmPhasicV.setV42(dataHarmphasicV.getV42Cp95());
                influxDBDataHarmPhasicV.setV43(dataHarmphasicV.getV43Cp95());
                influxDBDataHarmPhasicV.setV44(dataHarmphasicV.getV44Cp95());
                influxDBDataHarmPhasicV.setV45(dataHarmphasicV.getV45Cp95());
                influxDBDataHarmPhasicV.setV46(dataHarmphasicV.getV46Cp95());
                influxDBDataHarmPhasicV.setV47(dataHarmphasicV.getV47Cp95());
                influxDBDataHarmPhasicV.setV48(dataHarmphasicV.getV48Cp95());
                influxDBDataHarmPhasicV.setV49(dataHarmphasicV.getV49Cp95());
                influxDBDataHarmPhasicV.setV50(dataHarmphasicV.getV50Cp95());
            }

            influxDBDataHarmPhasicVList.add(influxDBDataHarmPhasicV);

        }



        return influxDBDataHarmPhasicVList;
    }

}
