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.DataInharmV;
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_v")
public class InfluxDBDataInharmV {

    @Column(name = "time",tag =true)
    @TimeColumn
    @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<InfluxDBDataInharmV> oralceToInfluxDB(DataInharmV dataInharmV) {
        if (dataInharmV == null) {
            return null;
        }
        List<InfluxDBDataInharmV> influxDBDataInHarmVList = new ArrayList<>();
        List<String> valueTypeList = Stream.of("AVG", "MAX", "MIN", "CP95").collect(Collectors.toList());
        for (String valueType : valueTypeList) {
            InfluxDBDataInharmV influxDBDataInHarmV = new InfluxDBDataInharmV();
            Instant instant = dataInharmV.getTimeid().atZone(ZoneId.systemDefault()).toInstant();

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

            influxDBDataInHarmVList.add(influxDBDataInHarmV);

        }



        return influxDBDataInHarmVList;
    }
    
}
