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.DataHarmpowerP;
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_harmpower_p")
public class InfluxDBDataHarmpowerP {

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

    @Column(name = "pf")
    private Float pf;

    @Column(name = "p")
    private Float p;

    @Column(name = "p_1")
    private Float p1;

    @Column(name = "p_2")
    private Float p2;

    @Column(name = "p_3")
    private Float p3;

    @Column(name = "p_4")
    private Float p4;

    @Column(name = "p_5")
    private Float p5;

    @Column(name = "p_6")
    private Float p6;

    @Column(name = "p_7")
    private Float p7;

    @Column(name = "p_8")
    private Float p8;

    @Column(name = "p_9")
    private Float p9;

    @Column(name = "p_10")
    private Float p10;

    @Column(name = "p_11")
    private Float p11;

    @Column(name = "p_12")
    private Float p12;

    @Column(name = "p_13")
    private Float p13;

    @Column(name = "p_14")
    private Float p14;

    @Column(name = "p_15")
    private Float p15;

    @Column(name = "p_16")
    private Float p16;

    @Column(name = "p_17")
    private Float p17;

    @Column(name = "p_18")
    private Float p18;

    @Column(name = "p_19")
    private Float p19;

    @Column(name = "p_20")
    private Float p20;

    @Column(name = "p_21")
    private Float p21;

    @Column(name = "p_22")
    private Float p22;

    @Column(name = "p_23")
    private Float p23;

    @Column(name = "p_24")
    private Float p24;

    @Column(name = "p_25")
    private Float p25;

    @Column(name = "p_26")
    private Float p26;

    @Column(name = "p_27")
    private Float p27;

    @Column(name = "p_28")
    private Float p28;

    @Column(name = "p_29")
    private Float p29;

    @Column(name = "p_30")
    private Float p30;

    @Column(name = "p_31")
    private Float p31;

    @Column(name = "p_32")
    private Float p32;

    @Column(name = "p_33")
    private Float p33;

    @Column(name = "p_34")
    private Float p34;

    @Column(name = "p_35")
    private Float p35;

    @Column(name = "p_36")
    private Float p36;

    @Column(name = "p_37")
    private Float p37;

    @Column(name = "p_38")
    private Float p38;

    @Column(name = "p_39")
    private Float p39;

    @Column(name = "p_40")
    private Float p40;

    @Column(name = "p_41")
    private Float p41;

    @Column(name = "p_42")
    private Float p42;

    @Column(name = "p_43")
    private Float p43;

    @Column(name = "p_44")
    private Float p44;

    @Column(name = "p_45")
    private Float p45;

    @Column(name = "p_46")
    private Float p46;

    @Column(name = "p_47")
    private Float p47;

    @Column(name = "p_48")
    private Float p48;

    @Column(name = "p_49")
    private Float p49;

    @Column(name = "p_50")
    private Float p50;

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

            influxDBDataHarmPhasicV.setTime(instant);
            influxDBDataHarmPhasicV.setLineId(dataHarmpowerP.getLineid());
            influxDBDataHarmPhasicV.setPhaseType(dataHarmpowerP.getPhasicType());
            influxDBDataHarmPhasicV.setQualityFlag(dataHarmpowerP.getQualityflag()+"");
            influxDBDataHarmPhasicV.setValueType(valueType);
            if (valueType.equals("AVG")) {
                influxDBDataHarmPhasicV.setDf(dataHarmpowerP.getDf());
                influxDBDataHarmPhasicV.setPf(dataHarmpowerP.getPf());
                influxDBDataHarmPhasicV.setP(dataHarmpowerP.getP());


                influxDBDataHarmPhasicV.setP1(dataHarmpowerP.getP1());
                influxDBDataHarmPhasicV.setP2(dataHarmpowerP.getP2());
                influxDBDataHarmPhasicV.setP3(dataHarmpowerP.getP3());
                influxDBDataHarmPhasicV.setP4(dataHarmpowerP.getP4());
                influxDBDataHarmPhasicV.setP5(dataHarmpowerP.getP5());
                influxDBDataHarmPhasicV.setP6(dataHarmpowerP.getP6());
                influxDBDataHarmPhasicV.setP7(dataHarmpowerP.getP7());
                influxDBDataHarmPhasicV.setP8(dataHarmpowerP.getP8());
                influxDBDataHarmPhasicV.setP9(dataHarmpowerP.getP9());
                influxDBDataHarmPhasicV.setP10(dataHarmpowerP.getP10());
                influxDBDataHarmPhasicV.setP11(dataHarmpowerP.getP11());
                influxDBDataHarmPhasicV.setP12(dataHarmpowerP.getP12());
                influxDBDataHarmPhasicV.setP13(dataHarmpowerP.getP13());
                influxDBDataHarmPhasicV.setP14(dataHarmpowerP.getP14());
                influxDBDataHarmPhasicV.setP15(dataHarmpowerP.getP15());
                influxDBDataHarmPhasicV.setP16(dataHarmpowerP.getP16());
                influxDBDataHarmPhasicV.setP17(dataHarmpowerP.getP17());
                influxDBDataHarmPhasicV.setP18(dataHarmpowerP.getP18());
                influxDBDataHarmPhasicV.setP19(dataHarmpowerP.getP19());
                influxDBDataHarmPhasicV.setP20(dataHarmpowerP.getP20());
                influxDBDataHarmPhasicV.setP21(dataHarmpowerP.getP21());
                influxDBDataHarmPhasicV.setP22(dataHarmpowerP.getP22());
                influxDBDataHarmPhasicV.setP23(dataHarmpowerP.getP23());
                influxDBDataHarmPhasicV.setP24(dataHarmpowerP.getP24());
                influxDBDataHarmPhasicV.setP25(dataHarmpowerP.getP25());
                influxDBDataHarmPhasicV.setP26(dataHarmpowerP.getP26());
                influxDBDataHarmPhasicV.setP27(dataHarmpowerP.getP27());
                influxDBDataHarmPhasicV.setP28(dataHarmpowerP.getP28());
                influxDBDataHarmPhasicV.setP29(dataHarmpowerP.getP29());
                influxDBDataHarmPhasicV.setP30(dataHarmpowerP.getP30());
                influxDBDataHarmPhasicV.setP31(dataHarmpowerP.getP31());
                influxDBDataHarmPhasicV.setP32(dataHarmpowerP.getP32());
                influxDBDataHarmPhasicV.setP33(dataHarmpowerP.getP33());
                influxDBDataHarmPhasicV.setP34(dataHarmpowerP.getP34());
                influxDBDataHarmPhasicV.setP35(dataHarmpowerP.getP35());
                influxDBDataHarmPhasicV.setP36(dataHarmpowerP.getP36());
                influxDBDataHarmPhasicV.setP37(dataHarmpowerP.getP37());
                influxDBDataHarmPhasicV.setP38(dataHarmpowerP.getP38());
                influxDBDataHarmPhasicV.setP39(dataHarmpowerP.getP39());
                influxDBDataHarmPhasicV.setP40(dataHarmpowerP.getP40());
                influxDBDataHarmPhasicV.setP41(dataHarmpowerP.getP41());
                influxDBDataHarmPhasicV.setP42(dataHarmpowerP.getP42());
                influxDBDataHarmPhasicV.setP43(dataHarmpowerP.getP43());
                influxDBDataHarmPhasicV.setP44(dataHarmpowerP.getP44());
                influxDBDataHarmPhasicV.setP45(dataHarmpowerP.getP45());
                influxDBDataHarmPhasicV.setP46(dataHarmpowerP.getP46());
                influxDBDataHarmPhasicV.setP47(dataHarmpowerP.getP47());
                influxDBDataHarmPhasicV.setP48(dataHarmpowerP.getP48());
                influxDBDataHarmPhasicV.setP49(dataHarmpowerP.getP49());
                influxDBDataHarmPhasicV.setP50(dataHarmpowerP.getP50());
            }
            else if (valueType.equals("MAX")){
                influxDBDataHarmPhasicV.setDf(dataHarmpowerP.getDfMax());
                influxDBDataHarmPhasicV.setPf(dataHarmpowerP.getPfMax());
                influxDBDataHarmPhasicV.setP(dataHarmpowerP.getPMax());

                influxDBDataHarmPhasicV.setP1(dataHarmpowerP.getP1Max());
                influxDBDataHarmPhasicV.setP2(dataHarmpowerP.getP2Max());
                influxDBDataHarmPhasicV.setP3(dataHarmpowerP.getP3Max());
                influxDBDataHarmPhasicV.setP4(dataHarmpowerP.getP4Max());
                influxDBDataHarmPhasicV.setP5(dataHarmpowerP.getP5Max());
                influxDBDataHarmPhasicV.setP6(dataHarmpowerP.getP6Max());
                influxDBDataHarmPhasicV.setP7(dataHarmpowerP.getP7Max());
                influxDBDataHarmPhasicV.setP8(dataHarmpowerP.getP8Max());
                influxDBDataHarmPhasicV.setP9(dataHarmpowerP.getP9Max());
                influxDBDataHarmPhasicV.setP10(dataHarmpowerP.getP10Max());
                influxDBDataHarmPhasicV.setP11(dataHarmpowerP.getP11Max());
                influxDBDataHarmPhasicV.setP12(dataHarmpowerP.getP12Max());
                influxDBDataHarmPhasicV.setP13(dataHarmpowerP.getP13Max());
                influxDBDataHarmPhasicV.setP14(dataHarmpowerP.getP14Max());
                influxDBDataHarmPhasicV.setP15(dataHarmpowerP.getP15Max());
                influxDBDataHarmPhasicV.setP16(dataHarmpowerP.getP16Max());
                influxDBDataHarmPhasicV.setP17(dataHarmpowerP.getP17Max());
                influxDBDataHarmPhasicV.setP18(dataHarmpowerP.getP18Max());
                influxDBDataHarmPhasicV.setP19(dataHarmpowerP.getP19Max());
                influxDBDataHarmPhasicV.setP20(dataHarmpowerP.getP20Max());
                influxDBDataHarmPhasicV.setP21(dataHarmpowerP.getP21Max());
                influxDBDataHarmPhasicV.setP22(dataHarmpowerP.getP22Max());
                influxDBDataHarmPhasicV.setP23(dataHarmpowerP.getP23Max());
                influxDBDataHarmPhasicV.setP24(dataHarmpowerP.getP24Max());
                influxDBDataHarmPhasicV.setP25(dataHarmpowerP.getP25Max());
                influxDBDataHarmPhasicV.setP26(dataHarmpowerP.getP26Max());
                influxDBDataHarmPhasicV.setP27(dataHarmpowerP.getP27Max());
                influxDBDataHarmPhasicV.setP28(dataHarmpowerP.getP28Max());
                influxDBDataHarmPhasicV.setP29(dataHarmpowerP.getP29Max());
                influxDBDataHarmPhasicV.setP30(dataHarmpowerP.getP30Max());
                influxDBDataHarmPhasicV.setP31(dataHarmpowerP.getP31Max());
                influxDBDataHarmPhasicV.setP32(dataHarmpowerP.getP32Max());
                influxDBDataHarmPhasicV.setP33(dataHarmpowerP.getP33Max());
                influxDBDataHarmPhasicV.setP34(dataHarmpowerP.getP34Max());
                influxDBDataHarmPhasicV.setP35(dataHarmpowerP.getP35Max());
                influxDBDataHarmPhasicV.setP36(dataHarmpowerP.getP36Max());
                influxDBDataHarmPhasicV.setP37(dataHarmpowerP.getP37Max());
                influxDBDataHarmPhasicV.setP38(dataHarmpowerP.getP38Max());
                influxDBDataHarmPhasicV.setP39(dataHarmpowerP.getP39Max());
                influxDBDataHarmPhasicV.setP40(dataHarmpowerP.getP40Max());
                influxDBDataHarmPhasicV.setP41(dataHarmpowerP.getP41Max());
                influxDBDataHarmPhasicV.setP42(dataHarmpowerP.getP42Max());
                influxDBDataHarmPhasicV.setP43(dataHarmpowerP.getP43Max());
                influxDBDataHarmPhasicV.setP44(dataHarmpowerP.getP44Max());
                influxDBDataHarmPhasicV.setP45(dataHarmpowerP.getP45Max());
                influxDBDataHarmPhasicV.setP46(dataHarmpowerP.getP46Max());
                influxDBDataHarmPhasicV.setP47(dataHarmpowerP.getP47Max());
                influxDBDataHarmPhasicV.setP48(dataHarmpowerP.getP48Max());
                influxDBDataHarmPhasicV.setP49(dataHarmpowerP.getP49Max());
                influxDBDataHarmPhasicV.setP50(dataHarmpowerP.getP50Max());
            }
            else if (valueType.equals("MIN")){
                influxDBDataHarmPhasicV.setDf(dataHarmpowerP.getDfMin());
                influxDBDataHarmPhasicV.setPf(dataHarmpowerP.getPfMin());
                influxDBDataHarmPhasicV.setP(dataHarmpowerP.getPMin());

                influxDBDataHarmPhasicV.setP1(dataHarmpowerP.getP1Min());
                influxDBDataHarmPhasicV.setP2(dataHarmpowerP.getP2Min());
                influxDBDataHarmPhasicV.setP3(dataHarmpowerP.getP3Min());
                influxDBDataHarmPhasicV.setP4(dataHarmpowerP.getP4Min());
                influxDBDataHarmPhasicV.setP5(dataHarmpowerP.getP5Min());
                influxDBDataHarmPhasicV.setP6(dataHarmpowerP.getP6Min());
                influxDBDataHarmPhasicV.setP7(dataHarmpowerP.getP7Min());
                influxDBDataHarmPhasicV.setP8(dataHarmpowerP.getP8Min());
                influxDBDataHarmPhasicV.setP9(dataHarmpowerP.getP9Min());
                influxDBDataHarmPhasicV.setP10(dataHarmpowerP.getP10Min());
                influxDBDataHarmPhasicV.setP11(dataHarmpowerP.getP11Min());
                influxDBDataHarmPhasicV.setP12(dataHarmpowerP.getP12Min());
                influxDBDataHarmPhasicV.setP13(dataHarmpowerP.getP13Min());
                influxDBDataHarmPhasicV.setP14(dataHarmpowerP.getP14Min());
                influxDBDataHarmPhasicV.setP15(dataHarmpowerP.getP15Min());
                influxDBDataHarmPhasicV.setP16(dataHarmpowerP.getP16Min());
                influxDBDataHarmPhasicV.setP17(dataHarmpowerP.getP17Min());
                influxDBDataHarmPhasicV.setP18(dataHarmpowerP.getP18Min());
                influxDBDataHarmPhasicV.setP19(dataHarmpowerP.getP19Min());
                influxDBDataHarmPhasicV.setP20(dataHarmpowerP.getP20Min());
                influxDBDataHarmPhasicV.setP21(dataHarmpowerP.getP21Min());
                influxDBDataHarmPhasicV.setP22(dataHarmpowerP.getP22Min());
                influxDBDataHarmPhasicV.setP23(dataHarmpowerP.getP23Min());
                influxDBDataHarmPhasicV.setP24(dataHarmpowerP.getP24Min());
                influxDBDataHarmPhasicV.setP25(dataHarmpowerP.getP25Min());
                influxDBDataHarmPhasicV.setP26(dataHarmpowerP.getP26Min());
                influxDBDataHarmPhasicV.setP27(dataHarmpowerP.getP27Min());
                influxDBDataHarmPhasicV.setP28(dataHarmpowerP.getP28Min());
                influxDBDataHarmPhasicV.setP29(dataHarmpowerP.getP29Min());
                influxDBDataHarmPhasicV.setP30(dataHarmpowerP.getP30Min());
                influxDBDataHarmPhasicV.setP31(dataHarmpowerP.getP31Min());
                influxDBDataHarmPhasicV.setP32(dataHarmpowerP.getP32Min());
                influxDBDataHarmPhasicV.setP33(dataHarmpowerP.getP33Min());
                influxDBDataHarmPhasicV.setP34(dataHarmpowerP.getP34Min());
                influxDBDataHarmPhasicV.setP35(dataHarmpowerP.getP35Min());
                influxDBDataHarmPhasicV.setP36(dataHarmpowerP.getP36Min());
                influxDBDataHarmPhasicV.setP37(dataHarmpowerP.getP37Min());
                influxDBDataHarmPhasicV.setP38(dataHarmpowerP.getP38Min());
                influxDBDataHarmPhasicV.setP39(dataHarmpowerP.getP39Min());
                influxDBDataHarmPhasicV.setP40(dataHarmpowerP.getP40Min());
                influxDBDataHarmPhasicV.setP41(dataHarmpowerP.getP41Min());
                influxDBDataHarmPhasicV.setP42(dataHarmpowerP.getP42Min());
                influxDBDataHarmPhasicV.setP43(dataHarmpowerP.getP43Min());
                influxDBDataHarmPhasicV.setP44(dataHarmpowerP.getP44Min());
                influxDBDataHarmPhasicV.setP45(dataHarmpowerP.getP45Min());
                influxDBDataHarmPhasicV.setP46(dataHarmpowerP.getP46Min());
                influxDBDataHarmPhasicV.setP47(dataHarmpowerP.getP47Min());
                influxDBDataHarmPhasicV.setP48(dataHarmpowerP.getP48Min());
                influxDBDataHarmPhasicV.setP49(dataHarmpowerP.getP49Min());
                influxDBDataHarmPhasicV.setP50(dataHarmpowerP.getP50Min());
            }
            else if (valueType.equals("CP95")){
                influxDBDataHarmPhasicV.setDf(dataHarmpowerP.getDfCp95());
                influxDBDataHarmPhasicV.setPf(dataHarmpowerP.getPfCp95());
                influxDBDataHarmPhasicV.setP(dataHarmpowerP.getPCp95());

                influxDBDataHarmPhasicV.setP1(dataHarmpowerP.getP1Cp95());
                influxDBDataHarmPhasicV.setP2(dataHarmpowerP.getP2Cp95());
                influxDBDataHarmPhasicV.setP3(dataHarmpowerP.getP3Cp95());
                influxDBDataHarmPhasicV.setP4(dataHarmpowerP.getP4Cp95());
                influxDBDataHarmPhasicV.setP5(dataHarmpowerP.getP5Cp95());
                influxDBDataHarmPhasicV.setP6(dataHarmpowerP.getP6Cp95());
                influxDBDataHarmPhasicV.setP7(dataHarmpowerP.getP7Cp95());
                influxDBDataHarmPhasicV.setP8(dataHarmpowerP.getP8Cp95());
                influxDBDataHarmPhasicV.setP9(dataHarmpowerP.getP9Cp95());
                influxDBDataHarmPhasicV.setP10(dataHarmpowerP.getP10Cp95());
                influxDBDataHarmPhasicV.setP11(dataHarmpowerP.getP11Cp95());
                influxDBDataHarmPhasicV.setP12(dataHarmpowerP.getP12Cp95());
                influxDBDataHarmPhasicV.setP13(dataHarmpowerP.getP13Cp95());
                influxDBDataHarmPhasicV.setP14(dataHarmpowerP.getP14Cp95());
                influxDBDataHarmPhasicV.setP15(dataHarmpowerP.getP15Cp95());
                influxDBDataHarmPhasicV.setP16(dataHarmpowerP.getP16Cp95());
                influxDBDataHarmPhasicV.setP17(dataHarmpowerP.getP17Cp95());
                influxDBDataHarmPhasicV.setP18(dataHarmpowerP.getP18Cp95());
                influxDBDataHarmPhasicV.setP19(dataHarmpowerP.getP19Cp95());
                influxDBDataHarmPhasicV.setP20(dataHarmpowerP.getP20Cp95());
                influxDBDataHarmPhasicV.setP21(dataHarmpowerP.getP21Cp95());
                influxDBDataHarmPhasicV.setP22(dataHarmpowerP.getP22Cp95());
                influxDBDataHarmPhasicV.setP23(dataHarmpowerP.getP23Cp95());
                influxDBDataHarmPhasicV.setP24(dataHarmpowerP.getP24Cp95());
                influxDBDataHarmPhasicV.setP25(dataHarmpowerP.getP25Cp95());
                influxDBDataHarmPhasicV.setP26(dataHarmpowerP.getP26Cp95());
                influxDBDataHarmPhasicV.setP27(dataHarmpowerP.getP27Cp95());
                influxDBDataHarmPhasicV.setP28(dataHarmpowerP.getP28Cp95());
                influxDBDataHarmPhasicV.setP29(dataHarmpowerP.getP29Cp95());
                influxDBDataHarmPhasicV.setP30(dataHarmpowerP.getP30Cp95());
                influxDBDataHarmPhasicV.setP31(dataHarmpowerP.getP31Cp95());
                influxDBDataHarmPhasicV.setP32(dataHarmpowerP.getP32Cp95());
                influxDBDataHarmPhasicV.setP33(dataHarmpowerP.getP33Cp95());
                influxDBDataHarmPhasicV.setP34(dataHarmpowerP.getP34Cp95());
                influxDBDataHarmPhasicV.setP35(dataHarmpowerP.getP35Cp95());
                influxDBDataHarmPhasicV.setP36(dataHarmpowerP.getP36Cp95());
                influxDBDataHarmPhasicV.setP37(dataHarmpowerP.getP37Cp95());
                influxDBDataHarmPhasicV.setP38(dataHarmpowerP.getP38Cp95());
                influxDBDataHarmPhasicV.setP39(dataHarmpowerP.getP39Cp95());
                influxDBDataHarmPhasicV.setP40(dataHarmpowerP.getP40Cp95());
                influxDBDataHarmPhasicV.setP41(dataHarmpowerP.getP41Cp95());
                influxDBDataHarmPhasicV.setP42(dataHarmpowerP.getP42Cp95());
                influxDBDataHarmPhasicV.setP43(dataHarmpowerP.getP43Cp95());
                influxDBDataHarmPhasicV.setP44(dataHarmpowerP.getP44Cp95());
                influxDBDataHarmPhasicV.setP45(dataHarmpowerP.getP45Cp95());
                influxDBDataHarmPhasicV.setP46(dataHarmpowerP.getP46Cp95());
                influxDBDataHarmPhasicV.setP47(dataHarmpowerP.getP47Cp95());
                influxDBDataHarmPhasicV.setP48(dataHarmpowerP.getP48Cp95());
                influxDBDataHarmPhasicV.setP49(dataHarmpowerP.getP49Cp95());
                influxDBDataHarmPhasicV.setP50(dataHarmpowerP.getP50Cp95());
            }

            influxDBDataHarmPhasicVList.add(influxDBDataHarmPhasicV);

        }



        return influxDBDataHarmPhasicVList;
    }
}
