package com.njcn.executor.handler;

import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.device.api.LineFeignClient;
import com.njcn.device.pojo.dto.PollutionParamDTO;
import com.njcn.device.pojo.po.Overlimit;
import com.njcn.executor.pojo.vo.*;
import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.pojo.po.LimitTarget;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.InfluxDB;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2022/5/17 14:34
 */
@Slf4j
@Component
@AllArgsConstructor
public class LimitTargetJob {

    private final String DATABASE = "pqsbase";

    private final InfluxDbUtils influxDbUtils;

    private final LineFeignClient lineFeignClient;

    @XxlJob("limitTargetJobHandler")
    public void getLimitTarget() throws ParseException {
        List<String> list = new ArrayList<>(),paramList = new ArrayList<>();;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)-1, 0, 0, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Calendar calendar2 = Calendar.getInstance();
        calendar2.set(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DAY_OF_MONTH)-1, 23, 59, 59);
        calendar2.set(Calendar.MILLISECOND, 0);
        String startTime = format.format(calendar.getTime());
        String endTime = format.format(calendar2.getTime());
        String command = XxlJobHelper.getJobParam();
        if (!StringUtils.isEmpty(command)){
            paramList = Arrays.asList(command.split(","));
            startTime = paramList.get(0);
            endTime = paramList.get(1);
            list = paramList.subList(2,paramList.size());
            if (CollectionUtils.isEmpty(list)){
                log.info("补招未传入监测点，默认使用系统查询的监测点");
                list = lineFeignClient.getLineList().getData();
            }
            boolean s1 = Pattern.matches(PatternRegex.TIME_FORMAT,startTime);
            boolean e1 = Pattern.matches(PatternRegex.TIME_FORMAT,endTime);
            if (!s1 || !e1){
                log.error("补招时间格式错误");
                return;
            } else {
                startTime = startTime + " 00:00:00";
                endTime = endTime + " 23:59:59";
            }
        } else {
            list = lineFeignClient.getLineList().getData();
        }
        long diff,diffDays,a,b = 0;
        Date d1 = format.parse(startTime);
        Date d2 = format.parse(endTime);
        diff = d2.getTime() - d1.getTime();
        diffDays = diff / (24 * 60 * 60 * 1000-1000);
        int days = (int) diffDays;
        if (!CollectionUtils.isEmpty(list)){
            Map<String,List<Overlimit>> overLimitMap = new HashMap<>();
            PollutionParamDTO pollutionParamDTO = new PollutionParamDTO();
            pollutionParamDTO.setLineList(list);
            List<Overlimit> overLimitList = lineFeignClient.getOverLimitByList(pollutionParamDTO).getData();
            if (!CollectionUtils.isEmpty(overLimitList)){
                overLimitMap = overLimitList.stream().collect(Collectors.groupingBy(Overlimit::getId));
            }
            for (int i = 1; i <= days; i++) {
                a = d1.getTime() + (long)(i-1)*(24 * 60 * 60) * 1000;
                b = d1.getTime() + (long)i*(24 * 60 * 60) * 1000-1000;
                startTime = format.format(a);
                endTime = format.format(b);
                Map<String,List<DayV>> map1 = getAllTime(list,startTime,endTime);
                Map<String,List<DayPlt>> map2 = getFlickerAllTime(list,startTime,endTime);
                Map<String,List<DayHarmrateV>> map3 = getDayHarmrateV(list,startTime,endTime);
                Map<String,List<DayI>> map4 = getDayI(list,startTime,endTime);
                Map<String,List<DayInharmV>> map5 = getDayInharmV(list,startTime,endTime);
                Map<String,List<DayV>> map6 = getDayV(list,startTime,endTime);
                Map<String,List<DayV>> map7 = getDayVUnbalance(list,startTime,endTime);
                Map<String,List<DayI>> map8 = getDayINeg(list,startTime,endTime);
                Map<String,List<DayV>> map9 = getDayVFreq(list,startTime,endTime);
                Map<String,List<DayV>> map10 = getDayVDev(list,startTime,endTime);
                Map<String,List<DayPlt>> map11 = getDayPlt(list,startTime,endTime);
                List<LimitTarget> result = getData(overLimitMap,map1,map2,map3,map4,map5,map6,map7,map8,map9,map10,map11);
                //入库
                if (!CollectionUtils.isEmpty(result)){
                    insert(result,a);
                }
            }
        }
    }


    /**
     * 组装T项数据
     */
    private List<LimitTarget> getData(Map<String,List<Overlimit>> limitMap, Map<String,List<DayV>> map1, Map<String,List<DayPlt>> map2, Map<String,List<DayHarmrateV>> map3,Map<String,List<DayI>> map4,Map<String,List<DayInharmV>> map5,Map<String,List<DayV>> map6,Map<String,List<DayV>> map7,Map<String,List<DayI>> map8,Map<String,List<DayV>> map9,Map<String,List<DayV>> map10,Map<String,List<DayPlt>> map11){
        List<LimitTarget> result = new ArrayList<>();
        for (String item:limitMap.keySet()){
            Integer allTime = 0;
            Integer flickerAllTime = 0;
            Overlimit overlimit = limitMap.get(item).get(0);
            if (!CollectionUtils.isEmpty(map1.get(item))){
                allTime = map1.get(item).get(0).getAllTime();
                if (allTime > 0){
                    allTime = 1;
                }
            }
            if (!CollectionUtils.isEmpty(map2.get(item))){
                flickerAllTime = map2.get(item).get(0).getFlickerAllTime();
                if (flickerAllTime > 0){
                    flickerAllTime = 1;
                }
            }
            List<DayHarmrateV> list1 = map3.get(item);
            List<DayI> list2 = map4.get(item);
            List<DayInharmV> list3 = map5.get(item);
            List<DayV> list4 = map6.get(item);
            List<DayV> list5 = map7.get(item);
            List<DayI> list6 = map8.get(item);
            List<DayV> list7 = map9.get(item);
            List<DayV> list8 = map10.get(item);
            List<DayPlt> list9 = map11.get(item);
            LimitTarget t = limitTargetDataT(overlimit,allTime,flickerAllTime,item,list1,list2,list3,list4,list5,list6,list7,list8,list9);
            result.add(t);
        };
        return result;
    }

    /**
     * T项指标统计
     */
    public LimitTarget limitTargetDataT(Overlimit overlimit, Integer allTime, Integer flickerAllTime, String lineId,  List<DayHarmrateV> list1, List<DayI> list2, List<DayInharmV> list3 ,List<DayV> list4 ,List<DayV> list5, List<DayI> list6, List<DayV> list7, List<DayV> list8, List<DayPlt> list9){
        LimitTarget limitTarget = new LimitTarget();
        int v2 = 0,v3 = 0,v4 = 0,v5 = 0,v6 = 0,v7 = 0,v8 = 0,v9 = 0,v10 = 0,v11 = 0,v12 = 0,v13 = 0,v14 = 0,v15 = 0,v16 = 0,v17 = 0,v18 = 0,v19 = 0,v20 = 0,v21 = 0,v22 = 0,v23 = 0,v24 = 0,v25 = 0;
        int i2 = 0,i3 = 0,i4 = 0,i5 = 0,i6 = 0,i7 = 0,i8 = 0,i9 = 0,i10 = 0,i11 = 0,i12 = 0,i13 = 0,i14 = 0,i15 = 0,i16 = 0,i17 = 0,i18 = 0,i19 = 0,i20 = 0,i21 = 0,i22 = 0,i23 = 0,i24 = 0,i25 = 0;
        int uHarm1 = 0,uHarm2 = 0,uHarm3 = 0,uHarm4 = 0,uHarm5 = 0,uHarm6 = 0,uHarm7 = 0,uHarm8 = 0,uHarm9 = 0,uHarm10 = 0,uHarm11 = 0,uHarm12 = 0,uHarm13 = 0,uHarm14 = 0,uHarm15 = 0,uHarm16 = 0;
        int thd = 0,uDev = 0,flicker = 0,freqDev = 0,uAberrance = 0,iNeg = 0;
        //2-25次谐波电压含有率
        if (!CollectionUtils.isEmpty(list1)){
            List<DayHarmrateV> l2 = list1.stream().filter(s->s.getV2()>overlimit.getUharm2()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l2)){
                v2 = 1;
            }
            List<DayHarmrateV> l3 = list1.stream().filter(s->s.getV3()>overlimit.getUharm3()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l3)){
                v3 = 1;
            }
            List<DayHarmrateV> l4 = list1.stream().filter(s->s.getV4()>overlimit.getUharm4()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l4)){
                v4 = 1;
            }
            List<DayHarmrateV> l5 = list1.stream().filter(s->s.getV5()>overlimit.getUharm5()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l5)){
                v5 = 1;
            }
            List<DayHarmrateV> l6 = list1.stream().filter(s->s.getV6()>overlimit.getUharm6()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l6)){
                v6 = 1;
            }
            List<DayHarmrateV> l7 = list1.stream().filter(s->s.getV7()>overlimit.getUharm7()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l7)){
                v7 = 1;
            }
            List<DayHarmrateV> l8 = list1.stream().filter(s->s.getV8()>overlimit.getUharm8()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l8)){
                v8 = 1;
            }
            List<DayHarmrateV> l9 = list1.stream().filter(s->s.getV9()>overlimit.getUharm9()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l9)){
                v9 = 1;
            }
            List<DayHarmrateV> l10 = list1.stream().filter(s->s.getV10()>overlimit.getUharm10()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l10)){
                v10 = 1;
            }
            List<DayHarmrateV> l11 = list1.stream().filter(s->s.getV11()>overlimit.getUharm11()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l11)){
                v11 = 1;
            }
            List<DayHarmrateV> l12 = list1.stream().filter(s->s.getV12()>overlimit.getUharm12()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l12)){
                v12 = 1;
            }
            List<DayHarmrateV> l13 = list1.stream().filter(s->s.getV13()>overlimit.getUharm13()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l13)){
                v13 = 1;
            }
            List<DayHarmrateV> l14 = list1.stream().filter(s->s.getV14()>overlimit.getUharm14()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l14)){
                v14 = 1;
            }
            List<DayHarmrateV> l15 = list1.stream().filter(s->s.getV15()>overlimit.getUharm15()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l15)){
                v15 = 1;
            }
            List<DayHarmrateV> l16 = list1.stream().filter(s->s.getV16()>overlimit.getUharm16()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l16)){
                v16 = 1;
            }
            List<DayHarmrateV> l17 = list1.stream().filter(s->s.getV17()>overlimit.getUharm17()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l17)){
                v17 = 1;
            }
            List<DayHarmrateV> l18 = list1.stream().filter(s->s.getV18()>overlimit.getUharm18()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l18)){
                v18 = 1;
            }
            List<DayHarmrateV> l19 = list1.stream().filter(s->s.getV19()>overlimit.getUharm19()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l19)){
                v19 = 1;
            }
            List<DayHarmrateV> l20 = list1.stream().filter(s->s.getV20()>overlimit.getUharm20()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l20)){
                v20 = 1;
            }
            List<DayHarmrateV> l21 = list1.stream().filter(s->s.getV21()>overlimit.getUharm21()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l21)){
                v21 = 1;
            }
            List<DayHarmrateV> l22 = list1.stream().filter(s->s.getV22()>overlimit.getUharm22()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l22)){
                v22 = 1;
            }
            List<DayHarmrateV> l23 = list1.stream().filter(s->s.getV23()>overlimit.getUharm23()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l23)){
                v23 = 1;
            }
            List<DayHarmrateV> l24 = list1.stream().filter(s->s.getV24()>overlimit.getUharm24()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l24)){
                v24 = 1;
            }
            List<DayHarmrateV> l25 = list1.stream().filter(s->s.getV25()>overlimit.getUharm25()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l25)){
                v25 = 1;
            }
        }
        //2-25次谐波电流
        if (!CollectionUtils.isEmpty(list2)){
            List<DayI> l2 = list2.stream().filter(s->s.getI2()>overlimit.getIharm2()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l2)){
                i2 = 1;
            }
            List<DayI> l3 = list2.stream().filter(s->s.getI3()>overlimit.getIharm3()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l3)){
                i3 = 1;
            }
            List<DayI> l4 = list2.stream().filter(s->s.getI4()>overlimit.getIharm4()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l4)){
                i4 = 1;
            }
            List<DayI> l5 = list2.stream().filter(s->s.getI5()>overlimit.getIharm5()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l5)){
                i5 = 1;
            }
            List<DayI> l6 = list2.stream().filter(s->s.getI6()>overlimit.getIharm6()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l6)){
                i6 = 1;
            }
            List<DayI> l7 = list2.stream().filter(s->s.getI7()>overlimit.getIharm7()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l7)){
                i7 = 1;
            }
            List<DayI> l8 = list2.stream().filter(s->s.getI8()>overlimit.getIharm8()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l8)){
                i8 = 1;
            }
            List<DayI> l9 = list2.stream().filter(s->s.getI9()>overlimit.getIharm9()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l9)){
                i9 = 1;
            }
            List<DayI> l10 = list2.stream().filter(s->s.getI10()>overlimit.getIharm10()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l10)){
                i10 = 1;
            }
            List<DayI> l11 = list2.stream().filter(s->s.getI11()>overlimit.getIharm11()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l11)){
                i11 = 1;
            }
            List<DayI> l12 = list2.stream().filter(s->s.getI12()>overlimit.getIharm12()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l12)){
                i12 = 1;
            }
            List<DayI> l13 = list2.stream().filter(s->s.getI13()>overlimit.getIharm13()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l13)){
                i13 = 1;
            }
            List<DayI> l14 = list2.stream().filter(s->s.getI14()>overlimit.getIharm14()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l14)){
                i14 = 1;
            }
            List<DayI> l15 = list2.stream().filter(s->s.getI15()>overlimit.getIharm15()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l15)){
                i15 = 1;
            }
            List<DayI> l16 = list2.stream().filter(s->s.getI16()>overlimit.getIharm16()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l16)){
                i16 = 1;
            }
            List<DayI> l17 = list2.stream().filter(s->s.getI17()>overlimit.getIharm17()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l17)){
                i17 = 1;
            }
            List<DayI> l18 = list2.stream().filter(s->s.getI18()>overlimit.getIharm18()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l18)){
                i18 = 1;
            }
            List<DayI> l19 = list2.stream().filter(s->s.getI19()>overlimit.getIharm19()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l19)){
                i19 = 1;
            }
            List<DayI> l20 = list2.stream().filter(s->s.getI20()>overlimit.getIharm20()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l20)){
                i20 = 1;
            }
            List<DayI> l21 = list2.stream().filter(s->s.getI21()>overlimit.getIharm21()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l21)){
                i21 = 1;
            }
            List<DayI> l22 = list2.stream().filter(s->s.getI22()>overlimit.getIharm22()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l22)){
                i22 = 1;
            }
            List<DayI> l23 = list2.stream().filter(s->s.getI23()>overlimit.getIharm23()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l23)){
                i23 = 1;
            }
            List<DayI> l24 = list2.stream().filter(s->s.getI24()>overlimit.getIharm24()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l24)){
                i24 = 1;
            }
            List<DayI> l25 = list2.stream().filter(s->s.getI25()>overlimit.getIharm25()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l25)){
                i25 = 1;
            }
        }
        //0.5-15.5次间谐波电压含有率
        if (!CollectionUtils.isEmpty(list3)){
            List<DayInharmV> l2 = list3.stream().filter(s->s.getV1()>overlimit.getInuharm1()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l2)){
                uHarm1 = 1;
            }
            List<DayInharmV> l3 = list3.stream().filter(s->s.getV2()>overlimit.getInuharm2()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l3)){
                uHarm2 = 1;
            }
            List<DayInharmV> l4 = list3.stream().filter(s->s.getV3()>overlimit.getInuharm3()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l4)){
                uHarm3 = 1;
            }
            List<DayInharmV> l5 = list3.stream().filter(s->s.getV4()>overlimit.getInuharm4()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l5)){
                uHarm4 = 1;
            }
            List<DayInharmV> l6 = list3.stream().filter(s->s.getV5()>overlimit.getInuharm5()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l6)){
                uHarm5 = 1;
            }
            List<DayInharmV> l7 = list3.stream().filter(s->s.getV6()>overlimit.getInuharm6()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l7)){
                uHarm6 = 1;
            }
            List<DayInharmV> l8 = list3.stream().filter(s->s.getV7()>overlimit.getInuharm7()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l8)){
                uHarm7 = 1;
            }
            List<DayInharmV> l9 = list3.stream().filter(s->s.getV8()>overlimit.getInuharm8()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l9)){
                uHarm8 = 1;
            }
            List<DayInharmV> l10 = list3.stream().filter(s->s.getV9()>overlimit.getInuharm9()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l10)){
                uHarm9 = 1;
            }
            List<DayInharmV> l11 = list3.stream().filter(s->s.getV10()>overlimit.getInuharm10()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l11)){
                uHarm10 = 1;
            }
            List<DayInharmV> l12 = list3.stream().filter(s->s.getV11()>overlimit.getInuharm11()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l12)){
                uHarm11 = 1;
            }
            List<DayInharmV> l13 = list3.stream().filter(s->s.getV12()>overlimit.getInuharm12()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l13)){
                uHarm12 = 1;
            }
            List<DayInharmV> l14 = list3.stream().filter(s->s.getV13()>overlimit.getInuharm13()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l14)){
                uHarm13 = 1;
            }
            List<DayInharmV> l15 = list3.stream().filter(s->s.getV14()>overlimit.getInuharm14()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l15)){
                uHarm14 = 1;
            }
            List<DayInharmV> l16 = list3.stream().filter(s->s.getV15()>overlimit.getInuharm15()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l16)){
                uHarm15 = 1;
            }
            List<DayInharmV> l17 = list3.stream().filter(s->s.getV16()>overlimit.getInuharm16()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l17)){
                uHarm16 = 1;
            }
        }
        //电压总谐波畸变率
        if (!CollectionUtils.isEmpty(list4)){
            List<DayV> l = list4.stream().filter(s->s.getVThd()>overlimit.getUaberrance()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l)){
                thd = 1;
            }
        }
        //三相电压不平衡度
        if (!CollectionUtils.isEmpty(list5)){
            List<DayV> l = list5.stream().filter(s->s.getVUnbalance()>overlimit.getUbalance()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l)){
                uAberrance = 1;
            }
        }
        //负序电流
        if (!CollectionUtils.isEmpty(list6)){
            List<DayI> l = list6.stream().filter(s->s.getINeg()>overlimit.getINeg()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l)){
                iNeg = 1;
            }
        }
        //频率偏差
        if (!CollectionUtils.isEmpty(list7)){
            List<DayV> l = list7.stream().filter(s->s.getFreqDev()>overlimit.getFreqDev()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l)){
                freqDev = 1;
            }
        }
        //电压上偏差、电压下偏差
        if (!CollectionUtils.isEmpty(list8)){
            Map<String,List<DayV>> devMap = list8.stream().collect(Collectors.groupingBy(DayV::getValueType));
            List<DayV> maxList = devMap.get("MAX");
            List<DayV> minList = devMap.get("MIN");
            List<DayV> l1 = maxList.stream().filter(s->s.getVuDev()>overlimit.getVoltageDev()).collect(Collectors.toList());
            List<DayV> l2 = minList.stream().filter(s->s.getVlDev()>overlimit.getUvoltageDev()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l1) || !CollectionUtils.isEmpty(l2)){
                uDev = 1;
            }
        }
        //长时间闪变
        if (!CollectionUtils.isEmpty(list9)){
            List<DayPlt> l = list9.stream().filter(s->s.getPlt()>overlimit.getFlicker()).collect(Collectors.toList());
            if (!CollectionUtils.isEmpty(l)){
                flicker = 1;
            }
        }
        limitTarget.setLineId(lineId);
        limitTarget.setPhasicType("T");
        limitTarget.setAllTime(allTime);
        limitTarget.setFlickerAllTime(flickerAllTime);
        limitTarget.setUAberranceOverTime(uAberrance);
        limitTarget.setINegOverTime(iNeg);
        limitTarget.setFreqDevOverTime(freqDev);
        limitTarget.setUHarm2OverTime(v2);
        limitTarget.setUHarm3OverTime(v3);
        limitTarget.setUHarm4OverTime(v4);
        limitTarget.setUHarm5OverTime(v5);
        limitTarget.setUHarm6OverTime(v6);
        limitTarget.setUHarm7OverTime(v7);
        limitTarget.setUHarm8OverTime(v8);
        limitTarget.setUHarm9OverTime(v9);
        limitTarget.setUHarm10OverTime(v10);
        limitTarget.setUHarm11OverTime(v11);
        limitTarget.setUHarm12OverTime(v12);
        limitTarget.setUHarm13OverTime(v13);
        limitTarget.setUHarm14OverTime(v14);
        limitTarget.setUHarm15OverTime(v15);
        limitTarget.setUHarm16OverTime(v16);
        limitTarget.setUHarm17OverTime(v17);
        limitTarget.setUHarm18OverTime(v18);
        limitTarget.setUHarm19OverTime(v19);
        limitTarget.setUHarm20OverTime(v20);
        limitTarget.setUHarm21OverTime(v21);
        limitTarget.setUHarm22OverTime(v22);
        limitTarget.setUHarm23OverTime(v23);
        limitTarget.setUHarm24OverTime(v24);
        limitTarget.setUHarm25OverTime(v25);
        limitTarget.setIHarm2OverTime(i2);
        limitTarget.setIHarm3OverTime(i3);
        limitTarget.setIHarm4OverTime(i4);
        limitTarget.setIHarm5OverTime(i5);
        limitTarget.setIHarm6OverTime(i6);
        limitTarget.setIHarm7OverTime(i7);
        limitTarget.setIHarm8OverTime(i8);
        limitTarget.setIHarm9OverTime(i9);
        limitTarget.setIHarm10OverTime(i10);
        limitTarget.setIHarm11OverTime(i11);
        limitTarget.setIHarm12OverTime(i12);
        limitTarget.setIHarm13OverTime(i13);
        limitTarget.setIHarm14OverTime(i14);
        limitTarget.setIHarm15OverTime(i15);
        limitTarget.setIHarm16OverTime(i16);
        limitTarget.setIHarm17OverTime(i17);
        limitTarget.setIHarm18OverTime(i18);
        limitTarget.setIHarm19OverTime(i19);
        limitTarget.setIHarm20OverTime(i20);
        limitTarget.setIHarm21OverTime(i21);
        limitTarget.setIHarm22OverTime(i22);
        limitTarget.setIHarm23OverTime(i23);
        limitTarget.setIHarm24OverTime(i24);
        limitTarget.setIHarm25OverTime(i25);
        limitTarget.setInuHarm1OverTime(uHarm1);
        limitTarget.setInuHarm2OverTime(uHarm2);
        limitTarget.setInuHarm3OverTime(uHarm3);
        limitTarget.setInuHarm4OverTime(uHarm4);
        limitTarget.setInuHarm5OverTime(uHarm5);
        limitTarget.setInuHarm6OverTime(uHarm6);
        limitTarget.setInuHarm7OverTime(uHarm7);
        limitTarget.setInuHarm8OverTime(uHarm8);
        limitTarget.setInuHarm9OverTime(uHarm9);
        limitTarget.setInuHarm10OverTime(uHarm10);
        limitTarget.setInuHarm11OverTime(uHarm11);
        limitTarget.setInuHarm12OverTime(uHarm12);
        limitTarget.setInuHarm13OverTime(uHarm13);
        limitTarget.setInuHarm14OverTime(uHarm14);
        limitTarget.setInuHarm15OverTime(uHarm15);
        limitTarget.setInuHarm16OverTime(uHarm16);
        limitTarget.setUBalanceOverTime(thd);
        limitTarget.setVoltageDevOverTime(uDev);
        limitTarget.setFlickerOverTime(flicker);
        return limitTarget;
    }

    /**
     * 功能描述:获取influxDB -> DayV -> 总计算次数(用DayV中phasic_type=A,quality_flag=0来参与统计)
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayV>> getAllTime(List<String> line, String startTime, String endTime){
        Map<String,List<DayV>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and value_type = 'AVG' and quality_flag = '0' group by line_id tz('Asia/Shanghai')");
        String sql = "SELECT count(freq) AS all_time FROM day_v where " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayV::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB ->DayPlt -> 闪变总次数(用DayPlt中phasic_type=A,quality_flag=0来参与统计)
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayPlt>> getFlickerAllTime(List<String> line, String startTime, String endTime){
        Map<String,List<DayPlt>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and quality_flag = '0' group by line_id tz('Asia/Shanghai')");
        String sql = "SELECT count(plt) AS flicker_all_time FROM day_plt where " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayPlt> list = resultMapper.toPOJO(sqlResult, DayPlt.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayPlt::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB -> DayHarmrateV -> 2-25次谐波电压含有率 -> 日95%概率值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayHarmrateV>> getDayHarmrateV(List<String> line, String startTime, String endTime){
        Map<String,List<DayHarmrateV>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_harmrate_v WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayHarmrateV> list = resultMapper.toPOJO(sqlResult, DayHarmrateV.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayHarmrateV::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB -> DayI -> 2-25次谐波电流 -> 日95%概率值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayI>> getDayI(List<String> line, String startTime, String endTime){
        Map<String,List<DayI>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_i WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayI> list = resultMapper.toPOJO(sqlResult, DayI.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayI::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB -> DayInharmV -> 0.5-15.5次间谐波电压含有率 -> 日95%概率值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayInharmV>> getDayInharmV(List<String> line, String startTime, String endTime){
        Map<String,List<DayInharmV>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_inharm_v WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayInharmV> list = resultMapper.toPOJO(sqlResult, DayInharmV.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayInharmV::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB -> DayV -> 电压总谐波畸变率 -> 日95%概率值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayV>> getDayV(List<String> line, String startTime, String endTime){
        Map<String,List<DayV>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_v WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayV::getLineId));
        }
        return map;
    }


    /**
     * 功能描述:获取influxDB -> DayV -> 负序电压不平衡度 -> 最大值 && 日95%概率值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayV>> getDayVUnbalance(List<String> line, String startTime, String endTime){
        Map<String,List<DayV>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_v WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayV::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB -> DayI -> 负序电流 -> 最大值 && 日95%概率值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayI>> getDayINeg(List<String> line, String startTime, String endTime){
        Map<String,List<DayI>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_i WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayI> list = resultMapper.toPOJO(sqlResult, DayI.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayI::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB -> DayV -> 频率偏差 -> 最大值 && 最小值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayV>> getDayVFreq(List<String> line, String startTime, String endTime){
        Map<String,List<DayV>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_v WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayV::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB -> DayV -> 电压偏差 -> 最大值 && 最小值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayV>> getDayVDev(List<String> line, String startTime, String endTime){
        Map<String,List<DayV>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_v WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayV::getLineId));
        }
        return map;
    }

    /**
     * 功能描述:获取influxDB -> DayPlt -> 长时间闪变 -> 最大值
     * @author xy
     * @param line          监测点集合
     * @param startTime     开始时间
     * @param endTime       结束时间
     * @date 2022/5/23 10:51
     * @return
     */
    public Map<String,List<DayPlt>> getDayPlt(List<String> line, String startTime, String endTime){
        Map<String,List<DayPlt>> map = new HashMap<>();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("(");
        for (int i = 0; i < line.size(); i++) {
            if (line.size() - i != 1) {
                stringBuilder.append("line_id='").append(line.get(i)).append("' or ");
            } else {
                stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
            }
        }
        stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and quality_flag = '0' tz('Asia/Shanghai')");
        String sql = "SELECT * FROM day_plt WHERE " + stringBuilder;
        QueryResult sqlResult = influxDbUtils.query(sql);
        InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
        List<DayPlt> list = resultMapper.toPOJO(sqlResult, DayPlt.class);
        if (!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.groupingBy(DayPlt::getLineId));
        }
        return map;
    }

    private void insert(List<LimitTarget> list, long time){
        List<String> records = new ArrayList<>();
        list.forEach(item->{
            Map<String, String> tags = new HashMap<>();
            Map<String, Object> fields = new HashMap<>();
            tags.put("line_id",item.getLineId());
            tags.put("phasic_type",item.getPhasicType());
            fields.put("all_time",item.getAllTime());
            fields.put("flicker_all_time",item.getFlickerAllTime());
            fields.put("flicker_overtime",item.getFlickerOverTime());
            fields.put("freq_dev_overtime",item.getFreqDevOverTime());
            fields.put("ubalance_overtime",item.getUBalanceOverTime());
            fields.put("uaberrance_overtime",item.getUAberranceOverTime());
            fields.put("i_neg_overtime",item.getINegOverTime());
            fields.put("voltage_dev_overtime",item.getVoltageDevOverTime());
            fields.put("uharm_2_overtime",item.getUHarm2OverTime());
            fields.put("uharm_3_overtime",item.getUHarm3OverTime());
            fields.put("uharm_4_overtime",item.getUHarm4OverTime());
            fields.put("uharm_5_overtime",item.getUHarm5OverTime());
            fields.put("uharm_6_overtime",item.getUHarm6OverTime());
            fields.put("uharm_7_overtime",item.getUHarm7OverTime());
            fields.put("uharm_8_overtime",item.getUHarm8OverTime());
            fields.put("uharm_9_overtime",item.getUHarm9OverTime());
            fields.put("uharm_10_overtime",item.getUHarm10OverTime());
            fields.put("uharm_11_overtime",item.getUHarm11OverTime());
            fields.put("uharm_12_overtime",item.getUHarm12OverTime());
            fields.put("uharm_13_overtime",item.getUHarm13OverTime());
            fields.put("uharm_14_overtime",item.getUHarm14OverTime());
            fields.put("uharm_15_overtime",item.getUHarm15OverTime());
            fields.put("uharm_16_overtime",item.getUHarm16OverTime());
            fields.put("uharm_17_overtime",item.getUHarm17OverTime());
            fields.put("uharm_18_overtime",item.getUHarm18OverTime());
            fields.put("uharm_19_overtime",item.getUHarm19OverTime());
            fields.put("uharm_20_overtime",item.getUHarm20OverTime());
            fields.put("uharm_21_overtime",item.getUHarm21OverTime());
            fields.put("uharm_22_overtime",item.getUHarm22OverTime());
            fields.put("uharm_23_overtime",item.getUHarm23OverTime());
            fields.put("uharm_24_overtime",item.getUHarm24OverTime());
            fields.put("uharm_25_overtime",item.getUHarm25OverTime());
            fields.put("iharm_2_overtime",item.getIHarm2OverTime());
            fields.put("iharm_3_overtime",item.getIHarm3OverTime());
            fields.put("iharm_4_overtime",item.getIHarm4OverTime());
            fields.put("iharm_5_overtime",item.getIHarm5OverTime());
            fields.put("iharm_6_overtime",item.getIHarm6OverTime());
            fields.put("iharm_7_overtime",item.getIHarm7OverTime());
            fields.put("iharm_8_overtime",item.getIHarm8OverTime());
            fields.put("iharm_9_overtime",item.getIHarm9OverTime());
            fields.put("iharm_10_overtime",item.getIHarm10OverTime());
            fields.put("iharm_11_overtime",item.getIHarm11OverTime());
            fields.put("iharm_12_overtime",item.getIHarm12OverTime());
            fields.put("iharm_13_overtime",item.getIHarm13OverTime());
            fields.put("iharm_14_overtime",item.getIHarm14OverTime());
            fields.put("iharm_15_overtime",item.getIHarm15OverTime());
            fields.put("iharm_16_overtime",item.getIHarm16OverTime());
            fields.put("iharm_17_overtime",item.getIHarm17OverTime());
            fields.put("iharm_18_overtime",item.getIHarm18OverTime());
            fields.put("iharm_19_overtime",item.getIHarm19OverTime());
            fields.put("iharm_20_overtime",item.getIHarm20OverTime());
            fields.put("iharm_21_overtime",item.getIHarm21OverTime());
            fields.put("iharm_22_overtime",item.getIHarm22OverTime());
            fields.put("iharm_23_overtime",item.getIHarm23OverTime());
            fields.put("iharm_24_overtime",item.getIHarm24OverTime());
            fields.put("iharm_25_overtime",item.getIHarm25OverTime());
            fields.put("inuharm_1_overtime",item.getInuHarm1OverTime());
            fields.put("inuharm_2_overtime",item.getInuHarm2OverTime());
            fields.put("inuharm_3_overtime",item.getInuHarm3OverTime());
            fields.put("inuharm_4_overtime",item.getInuHarm4OverTime());
            fields.put("inuharm_5_overtime",item.getInuHarm5OverTime());
            fields.put("inuharm_6_overtime",item.getInuHarm6OverTime());
            fields.put("inuharm_7_overtime",item.getInuHarm7OverTime());
            fields.put("inuharm_8_overtime",item.getInuHarm8OverTime());
            fields.put("inuharm_9_overtime",item.getInuHarm9OverTime());
            fields.put("inuharm_10_overtime",item.getInuHarm10OverTime());
            fields.put("inuharm_11_overtime",item.getInuHarm11OverTime());
            fields.put("inuharm_12_overtime",item.getInuHarm12OverTime());
            fields.put("inuharm_13_overtime",item.getInuHarm13OverTime());
            fields.put("inuharm_14_overtime",item.getInuHarm14OverTime());
            fields.put("inuharm_15_overtime",item.getInuHarm15OverTime());
            fields.put("inuharm_16_overtime",item.getInuHarm16OverTime());
            Point point = influxDbUtils.pointBuilder("limit_target", time, TimeUnit.MILLISECONDS, tags, fields);
            BatchPoints batchPoints = BatchPoints.database(DATABASE).tag("line_id", item.getLineId()).tag("phasic_type",item.getPhasicType()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
            batchPoints.point(point);
            records.add(batchPoints.lineProtocol());
        });
        influxDbUtils.batchInsert(DATABASE,"", InfluxDB.ConsistencyLevel.ALL, records);
    }
}
