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.DataHarmrateV;
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_harmrate_v")
public class InfluxDBDataHarmrateV {
    @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<InfluxDBDataHarmrateV> oralceToInfluxDB(DataHarmrateV dataHarmrateV) {
        if (dataHarmrateV == null) {
            return null;
        }
        List<InfluxDBDataHarmrateV> influxDBDataHarmRateVList = new ArrayList<>();
        List<String> valueTypeList = Stream.of("AVG", "MAX", "MIN", "CP95").collect(Collectors.toList());
        for (String valueType : valueTypeList) {
            InfluxDBDataHarmrateV influxDBDataHarmRateV = new InfluxDBDataHarmrateV();
            Instant instant = dataHarmrateV.getTimeid().atZone(ZoneId.systemDefault()).toInstant();

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

            influxDBDataHarmRateVList.add(influxDBDataHarmRateV);

        }



        return influxDBDataHarmRateVList;
    }
}
