package com.njcn.event.common.service.impl;


import cn.hutool.core.date.DateUtil;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.vo.*;
import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <功能描述>
 *
 * @author wr
 * @createTime: 2023-02-10
 */
@Service
@RequiredArgsConstructor
public class EventReportServiceImpl implements EventReportService {

    private final InfluxDbUtils influxDbUtils;

    @Override
    public List<DISDIPVO> eventDisdip(List<EventDetail> info) {
        List<DISDIPVO> result = new ArrayList<>();
        int[][] arr = new int[5][8];
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 8; j++) {
                arr[i][j] = 0;
            }
        }
        for (int i = 0; i < info.size(); i++) {
            Double eventvalue = info.get(i).getFeatureAmplitude();
            //mysql存的S要转换成ms
            double persisttime = info.get(i).getDuration()*1000;
            if (eventvalue * 100 < 10) {
                if (persisttime < 20) {
                    arr[4][0]++;
                } else if (persisttime < 100) {
                    arr[4][1]++;
                } else if (persisttime < 500) {
                    arr[4][2]++;
                } else if (persisttime < 1000) {
                    arr[4][3]++;
                } else if (persisttime < 3000) {
                    arr[4][4]++;
                } else if (persisttime < 20000) {
                    arr[4][5]++;
                } else if (persisttime < 60000) {
                    arr[4][6]++;
                } else if (persisttime < 180000) {
                    arr[4][7]++;
                }
            } else if (eventvalue * 100 < 40) {
                if (persisttime < 20) {
                    arr[3][0]++;
                } else if (persisttime < 100) {
                    arr[3][1]++;
                } else if (persisttime < 500) {
                    arr[3][2]++;
                } else if (persisttime < 1000) {
                    arr[3][3]++;
                } else if (persisttime < 3000) {
                    arr[3][4]++;
                } else if (persisttime < 20000) {
                    arr[3][5]++;
                } else if (persisttime < 60000) {
                    arr[3][6]++;
                } else if (persisttime < 180000) {
                    arr[3][7]++;
                }
            } else if (eventvalue * 100 < 70) {
                if (persisttime < 20) {
                    arr[2][0]++;
                } else if (persisttime < 100) {
                    arr[2][1]++;
                } else if (persisttime < 500) {
                    arr[2][2]++;
                } else if (persisttime < 1000) {
                    arr[2][3]++;
                } else if (persisttime < 3000) {
                    arr[2][4]++;
                } else if (persisttime < 20000) {
                    arr[2][5]++;
                } else if (persisttime < 60000) {
                    arr[2][6]++;
                } else if (persisttime < 180000) {
                    arr[2][7]++;
                }
            } else if (eventvalue * 100 < 85) {
                if (persisttime < 20) {
                    arr[1][0]++;
                } else if (persisttime < 100) {
                    arr[1][1]++;
                } else if (persisttime < 500) {
                    arr[1][2]++;
                } else if (persisttime < 1000) {
                    arr[1][3]++;
                } else if (persisttime < 3000) {
                    arr[1][4]++;
                } else if (persisttime < 20000) {
                    arr[1][5]++;
                } else if (persisttime < 60000) {
                    arr[1][6]++;
                } else if (persisttime < 180000) {
                    arr[1][7]++;
                }
            } else if (eventvalue * 100 <= 90) {
                if (persisttime < 20) {
                    arr[0][0]++;
                } else if (persisttime < 100) {
                    arr[0][1]++;
                } else if (persisttime < 500) {
                    arr[0][2]++;
                } else if (persisttime < 1000) {
                    arr[0][3]++;
                } else if (persisttime < 3000) {
                    arr[0][4]++;
                } else if (persisttime < 20000) {
                    arr[0][5]++;
                } else if (persisttime < 60000) {
                    arr[0][6]++;
                } else if (persisttime < 180000) {
                    arr[0][7]++;
                }
            }
        }
        result.add(new DISDIPVO("90%", String.valueOf(arr[0][0]), String.valueOf(arr[0][1]), String.valueOf(arr[0][2]), String.valueOf(arr[0][3]), String.valueOf(arr[0][4]), String.valueOf(arr[0][5]), String.valueOf(arr[0][6]), String.valueOf(arr[0][7])));
        result.add(new DISDIPVO("85%", String.valueOf(arr[1][0]), String.valueOf(arr[1][1]), String.valueOf(arr[1][2]), String.valueOf(arr[1][3]), String.valueOf(arr[1][4]), String.valueOf(arr[1][5]), String.valueOf(arr[1][6]), String.valueOf(arr[1][7])));
        result.add(new DISDIPVO("70%", String.valueOf(arr[2][0]), String.valueOf(arr[2][1]), String.valueOf(arr[2][2]), String.valueOf(arr[2][3]), String.valueOf(arr[2][4]), String.valueOf(arr[2][5]), String.valueOf(arr[2][6]), String.valueOf(arr[2][7])));
        result.add(new DISDIPVO("40%", String.valueOf(arr[3][0]), String.valueOf(arr[3][1]), String.valueOf(arr[3][2]), String.valueOf(arr[3][3]), String.valueOf(arr[3][4]), String.valueOf(arr[3][5]), String.valueOf(arr[3][6]), String.valueOf(arr[3][7])));
        result.add(new DISDIPVO("10%", String.valueOf(arr[4][0]), String.valueOf(arr[4][1]), String.valueOf(arr[4][2]), String.valueOf(arr[4][3]), String.valueOf(arr[4][4]), String.valueOf(arr[4][5]), String.valueOf(arr[4][6]), String.valueOf(arr[4][7])));
        return result;
    }

    @Override
    public List<IEC411VO> IEC411(List<EventDetail> info) {
        List<IEC411VO> result = new ArrayList<>();
        int[][] arr = new int[3][6];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 6; j++) {
                arr[i][j] = 0;
            }
        }
        for (int i = 0; i < info.size(); i++) {
            Double eventvalue = info.get(i).getFeatureAmplitude();
            //mysql存的S要转换成ms
            double persisttime = info.get(i).getDuration()*1000;
            if (eventvalue * 100 < 1) {
                if (persisttime < 20 && persisttime >= 10) {
                    arr[2][0]++;
                } else if (persisttime < 100) {
                    arr[2][1]++;
                } else if (persisttime < 200) {
                    arr[2][2]++;
                } else if (persisttime < 400) {
                    arr[2][3]++;
                } else if (persisttime < 1000) {
                    arr[2][4]++;
                } else {
                    arr[2][5]++;
                }
            } else if (eventvalue * 100 < 40) {
                if (persisttime < 20 && persisttime >= 10) {
                    arr[1][0]++;
                } else if (persisttime < 100) {
                    arr[1][1]++;
                } else if (persisttime < 200) {
                    arr[1][2]++;
                } else if (persisttime < 400) {
                    arr[1][3]++;
                } else if (persisttime < 1000) {
                    arr[1][4]++;
                } else {
                    arr[1][5]++;
                }
            } else if (eventvalue * 100 <= 70) {
                if (persisttime < 20 && persisttime >= 10) {
                    arr[0][0]++;
                } else if (persisttime < 100) {
                    arr[0][1]++;
                } else if (persisttime < 200) {
                    arr[0][2]++;
                } else if (persisttime < 400) {
                    arr[0][3]++;
                } else if (persisttime < 1000) {
                    arr[0][4]++;
                } else {
                    arr[0][5]++;
                }
            }
        }
        result.add(new IEC411VO("40~70%", String.valueOf(arr[0][0]), String.valueOf(arr[0][1]), String.valueOf(arr[0][2]), String.valueOf(arr[0][3]), String.valueOf(arr[0][4]), String.valueOf(arr[0][5])));
        result.add(new IEC411VO("1~40%", String.valueOf(arr[1][0]), String.valueOf(arr[1][1]), String.valueOf(arr[1][2]), String.valueOf(arr[1][3]), String.valueOf(arr[1][4]), String.valueOf(arr[1][5])));
        result.add(new IEC411VO("<1%", String.valueOf(arr[2][0]), String.valueOf(arr[2][1]), String.valueOf(arr[2][2]), String.valueOf(arr[2][3]), String.valueOf(arr[2][4]), String.valueOf(arr[2][5])));
        return result;
    }

    @Override
    public List<IEC28VO> IEC28(List<EventDetail> info) {
        List<IEC28VO> result = new ArrayList<>();
        int[][] arr = new int[17][8];
        for (int i = 0; i < 17; i++) {
            for (int j = 0; j < 8; j++) {
                arr[i][j] = 0;
            }
        }
        for (int i = 0; i < info.size(); i++) {
            Double eventvalue = info.get(i).getFeatureAmplitude();
            //mysql存的S要转换成ms
            double persisttime = info.get(i).getDuration()*1000;

            if (eventvalue * 100 < 1 && eventvalue * 100 >= 0) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[16][0]++;
                } else if (persisttime <= 250) {
                    arr[16][1]++;
                } else if (persisttime <= 500) {
                    arr[16][2]++;
                } else if (persisttime <= 1000) {
                    arr[16][3]++;
                } else if (persisttime <= 3000) {
                    arr[16][4]++;
                } else if (persisttime <= 20000) {
                    arr[16][5]++;
                } else if (persisttime <= 60000) {
                    arr[16][6]++;
                } else if (persisttime <= 180000) {
                    arr[16][7]++;
                }
            } else if (eventvalue * 100 < 10) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[15][0]++;
                } else if (persisttime <= 250) {
                    arr[15][1]++;
                } else if (persisttime <= 500) {
                    arr[15][2]++;
                } else if (persisttime <= 1000) {
                    arr[15][3]++;
                } else if (persisttime <= 3000) {
                    arr[15][4]++;
                } else if (persisttime <= 20000) {
                    arr[15][5]++;
                } else if (persisttime <= 60000) {
                    arr[15][6]++;
                } else if (persisttime <= 180000) {
                    arr[15][7]++;
                }
            } else if (eventvalue * 100 < 20) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[14][0]++;
                } else if (persisttime <= 250) {
                    arr[14][1]++;
                } else if (persisttime <= 500) {
                    arr[14][2]++;
                } else if (persisttime <= 1000) {
                    arr[14][3]++;
                } else if (persisttime <= 3000) {
                    arr[14][4]++;
                } else if (persisttime <= 20000) {
                    arr[14][5]++;
                } else if (persisttime <= 60000) {
                    arr[14][6]++;
                } else if (persisttime <= 180000) {
                    arr[14][7]++;
                }
            } else if (eventvalue * 100 < 30) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[13][0]++;
                } else if (persisttime <= 250) {
                    arr[13][1]++;
                } else if (persisttime <= 500) {
                    arr[13][2]++;
                } else if (persisttime <= 1000) {
                    arr[13][3]++;
                } else if (persisttime <= 3000) {
                    arr[13][4]++;
                } else if (persisttime <= 20000) {
                    arr[13][5]++;
                } else if (persisttime <= 60000) {
                    arr[13][6]++;
                } else if (persisttime <= 180000) {
                    arr[13][7]++;
                }
            } else if (eventvalue * 100 < 40) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[12][0]++;
                } else if (persisttime <= 250) {
                    arr[12][1]++;
                } else if (persisttime <= 500) {
                    arr[12][2]++;
                } else if (persisttime <= 1000) {
                    arr[12][3]++;
                } else if (persisttime <= 3000) {
                    arr[12][4]++;
                } else if (persisttime <= 20000) {
                    arr[12][5]++;
                } else if (persisttime <= 60000) {
                    arr[12][6]++;
                } else if (persisttime <= 180000) {
                    arr[12][7]++;
                }
            } else if (eventvalue * 100 < 50) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[11][0]++;
                } else if (persisttime <= 250) {
                    arr[11][1]++;
                } else if (persisttime <= 500) {
                    arr[11][2]++;
                } else if (persisttime <= 1000) {
                    arr[11][3]++;
                } else if (persisttime <= 3000) {
                    arr[11][4]++;
                } else if (persisttime <= 20000) {
                    arr[11][5]++;
                } else if (persisttime <= 60000) {
                    arr[11][6]++;
                } else if (persisttime <= 180000) {
                    arr[11][7]++;
                }
            } else if (eventvalue * 100 < 60) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[10][0]++;
                } else if (persisttime <= 250) {
                    arr[10][1]++;
                } else if (persisttime <= 500) {
                    arr[10][2]++;
                } else if (persisttime <= 1000) {
                    arr[10][3]++;
                } else if (persisttime <= 3000) {
                    arr[10][4]++;
                } else if (persisttime <= 20000) {
                    arr[10][5]++;
                } else if (persisttime <= 60000) {
                    arr[10][6]++;
                } else if (persisttime <= 180000) {
                    arr[10][7]++;
                }
            } else if (eventvalue * 100 < 70) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[9][0]++;
                } else if (persisttime <= 250) {
                    arr[9][1]++;
                } else if (persisttime <= 500) {
                    arr[9][2]++;
                } else if (persisttime <= 1000) {
                    arr[9][3]++;
                } else if (persisttime <= 3000) {
                    arr[9][4]++;
                } else if (persisttime <= 20000) {
                    arr[9][5]++;
                } else if (persisttime <= 60000) {
                    arr[9][6]++;
                } else if (persisttime <= 180000) {
                    arr[9][7]++;
                }
            } else if (eventvalue * 100 < 80) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[8][0]++;
                } else if (persisttime <= 250) {
                    arr[8][1]++;
                } else if (persisttime <= 500) {
                    arr[8][2]++;
                } else if (persisttime <= 1000) {
                    arr[8][3]++;
                } else if (persisttime <= 3000) {
                    arr[8][4]++;
                } else if (persisttime <= 20000) {
                    arr[8][5]++;
                } else if (persisttime <= 60000) {
                    arr[8][6]++;
                } else if (persisttime <= 180000) {
                    arr[8][7]++;
                }
            } else if (eventvalue * 100 <= 90) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[7][0]++;
                } else if (persisttime <= 250) {
                    arr[7][1]++;
                } else if (persisttime <= 500) {
                    arr[7][2]++;
                } else if (persisttime <= 1000) {
                    arr[7][3]++;
                } else if (persisttime <= 3000) {
                    arr[7][4]++;
                } else if (persisttime <= 20000) {
                    arr[7][5]++;
                } else if (persisttime <= 60000) {
                    arr[7][6]++;
                } else if (persisttime <= 180000) {
                    arr[7][7]++;
                }
            } else if (eventvalue * 100 < 120 && eventvalue * 100 >= 110) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[6][0]++;
                } else if (persisttime <= 250) {
                    arr[6][1]++;
                } else if (persisttime <= 500) {
                    arr[6][2]++;
                } else if (persisttime <= 1000) {
                    arr[6][3]++;
                } else if (persisttime <= 3000) {
                    arr[6][4]++;
                } else if (persisttime <= 20000) {
                    arr[6][5]++;
                } else if (persisttime <= 60000) {
                    arr[6][6]++;
                } else if (persisttime <= 180000) {
                    arr[6][7]++;
                }
            } else if (eventvalue * 100 < 130) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[5][0]++;
                } else if (persisttime <= 250) {
                    arr[5][1]++;
                } else if (persisttime <= 500) {
                    arr[5][2]++;
                } else if (persisttime <= 1000) {
                    arr[5][3]++;
                } else if (persisttime <= 3000) {
                    arr[5][4]++;
                } else if (persisttime <= 20000) {
                    arr[5][5]++;
                } else if (persisttime <= 60000) {
                    arr[5][6]++;
                } else if (persisttime <= 180000) {
                    arr[5][7]++;
                }
            } else if (eventvalue * 100 < 140) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[4][0]++;
                } else if (persisttime <= 250) {
                    arr[4][1]++;
                } else if (persisttime <= 500) {
                    arr[4][2]++;
                } else if (persisttime <= 1000) {
                    arr[4][3]++;
                } else if (persisttime <= 3000) {
                    arr[4][4]++;
                } else if (persisttime <= 20000) {
                    arr[4][5]++;
                } else if (persisttime <= 60000) {
                    arr[4][6]++;
                } else if (persisttime <= 180000) {
                    arr[4][7]++;
                }
            } else if (eventvalue * 100 < 150) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[3][0]++;
                } else if (persisttime <= 250) {
                    arr[3][1]++;
                } else if (persisttime <= 500) {
                    arr[3][2]++;
                } else if (persisttime <= 1000) {
                    arr[3][3]++;
                } else if (persisttime <= 3000) {
                    arr[3][4]++;
                } else if (persisttime <= 20000) {
                    arr[3][5]++;
                } else if (persisttime <= 60000) {
                    arr[3][6]++;
                } else if (persisttime <= 180000) {
                    arr[3][7]++;
                }
            } else if (eventvalue * 100 < 160) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[2][0]++;
                } else if (persisttime <= 250) {
                    arr[2][1]++;
                } else if (persisttime <= 500) {
                    arr[2][2]++;
                } else if (persisttime <= 1000) {
                    arr[2][3]++;
                } else if (persisttime <= 3000) {
                    arr[2][4]++;
                } else if (persisttime <= 20000) {
                    arr[2][5]++;
                } else if (persisttime <= 60000) {
                    arr[2][6]++;
                } else if (persisttime <= 180000) {
                    arr[2][7]++;
                }
            } else if (eventvalue * 100 < 170) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[1][0]++;
                } else if (persisttime <= 250) {
                    arr[1][1]++;
                } else if (persisttime <= 500) {
                    arr[1][2]++;
                } else if (persisttime <= 1000) {
                    arr[1][3]++;
                } else if (persisttime <= 3000) {
                    arr[1][4]++;
                } else if (persisttime <= 20000) {
                    arr[1][5]++;
                } else if (persisttime <= 60000) {
                    arr[1][6]++;
                } else if (persisttime <= 180000) {
                    arr[1][7]++;
                }
            } else if (eventvalue * 100 <= 180) {
                if (persisttime > 10 && persisttime <= 100) {
                    arr[0][0]++;
                } else if (persisttime <= 250) {
                    arr[0][1]++;
                } else if (persisttime <= 500) {
                    arr[0][2]++;
                } else if (persisttime <= 1000) {
                    arr[0][3]++;
                } else if (persisttime <= 3000) {
                    arr[0][4]++;
                } else if (persisttime <= 20000) {
                    arr[0][5]++;
                } else if (persisttime <= 60000) {
                    arr[0][6]++;
                } else if (persisttime <= 180000) {
                    arr[0][7]++;
                }
            }
        }
        result.add(new IEC28VO("180>U>=170", String.valueOf(arr[0][0]), String.valueOf(arr[0][1]), String.valueOf(arr[0][2]), String.valueOf(arr[0][3]), String.valueOf(arr[0][4]), String.valueOf(arr[0][5]), String.valueOf(arr[0][6]), String.valueOf(arr[0][7])));
        result.add(new IEC28VO("170>U>=160", String.valueOf(arr[1][0]), String.valueOf(arr[1][1]), String.valueOf(arr[1][2]), String.valueOf(arr[1][3]), String.valueOf(arr[1][4]), String.valueOf(arr[1][5]), String.valueOf(arr[1][6]), String.valueOf(arr[1][7])));
        result.add(new IEC28VO("160>U>=150", String.valueOf(arr[2][0]), String.valueOf(arr[2][1]), String.valueOf(arr[2][2]), String.valueOf(arr[2][3]), String.valueOf(arr[2][4]), String.valueOf(arr[2][5]), String.valueOf(arr[2][6]), String.valueOf(arr[2][7])));
        result.add(new IEC28VO("150>U>=140", String.valueOf(arr[3][0]), String.valueOf(arr[3][1]), String.valueOf(arr[3][2]), String.valueOf(arr[3][3]), String.valueOf(arr[3][4]), String.valueOf(arr[3][5]), String.valueOf(arr[3][6]), String.valueOf(arr[3][7])));
        result.add(new IEC28VO("140>U>=130", String.valueOf(arr[4][0]), String.valueOf(arr[4][1]), String.valueOf(arr[4][2]), String.valueOf(arr[4][3]), String.valueOf(arr[4][4]), String.valueOf(arr[4][5]), String.valueOf(arr[4][6]), String.valueOf(arr[4][7])));
        result.add(new IEC28VO("130>U>=120", String.valueOf(arr[5][0]), String.valueOf(arr[5][1]), String.valueOf(arr[5][2]), String.valueOf(arr[5][3]), String.valueOf(arr[5][4]), String.valueOf(arr[5][5]), String.valueOf(arr[5][6]), String.valueOf(arr[5][7])));
        result.add(new IEC28VO("120>U>=110", String.valueOf(arr[6][0]), String.valueOf(arr[6][1]), String.valueOf(arr[6][2]), String.valueOf(arr[6][3]), String.valueOf(arr[6][4]), String.valueOf(arr[6][5]), String.valueOf(arr[6][6]), String.valueOf(arr[6][7])));
        result.add(new IEC28VO("90>U>=80", String.valueOf(arr[7][0]), String.valueOf(arr[7][1]), String.valueOf(arr[7][2]), String.valueOf(arr[7][3]), String.valueOf(arr[7][4]), String.valueOf(arr[7][5]), String.valueOf(arr[7][6]), String.valueOf(arr[7][7])));
        result.add(new IEC28VO("80>U>=70", String.valueOf(arr[8][0]), String.valueOf(arr[8][1]), String.valueOf(arr[8][2]), String.valueOf(arr[8][3]), String.valueOf(arr[8][4]), String.valueOf(arr[8][5]), String.valueOf(arr[8][6]), String.valueOf(arr[8][7])));
        result.add(new IEC28VO("70>U>=60", String.valueOf(arr[9][0]), String.valueOf(arr[9][1]), String.valueOf(arr[9][2]), String.valueOf(arr[9][3]), String.valueOf(arr[9][4]), String.valueOf(arr[9][5]), String.valueOf(arr[9][6]), String.valueOf(arr[9][7])));
        result.add(new IEC28VO("60>U>=50", String.valueOf(arr[10][0]), String.valueOf(arr[10][1]), String.valueOf(arr[10][2]), String.valueOf(arr[10][3]), String.valueOf(arr[10][4]), String.valueOf(arr[10][5]), String.valueOf(arr[10][6]), String.valueOf(arr[10][7])));
        result.add(new IEC28VO("50>U>=40", String.valueOf(arr[11][0]), String.valueOf(arr[11][1]), String.valueOf(arr[11][2]), String.valueOf(arr[11][3]), String.valueOf(arr[11][4]), String.valueOf(arr[11][5]), String.valueOf(arr[11][6]), String.valueOf(arr[11][7])));
        result.add(new IEC28VO("40>U>=30", String.valueOf(arr[12][0]), String.valueOf(arr[12][1]), String.valueOf(arr[12][2]), String.valueOf(arr[12][3]), String.valueOf(arr[12][4]), String.valueOf(arr[12][5]), String.valueOf(arr[12][6]), String.valueOf(arr[12][7])));
        result.add(new IEC28VO("30>U>=20", String.valueOf(arr[13][0]), String.valueOf(arr[13][1]), String.valueOf(arr[13][2]), String.valueOf(arr[13][3]), String.valueOf(arr[13][4]), String.valueOf(arr[13][5]), String.valueOf(arr[13][6]), String.valueOf(arr[13][7])));
        result.add(new IEC28VO("20>U>=10", String.valueOf(arr[14][0]), String.valueOf(arr[14][1]), String.valueOf(arr[14][2]), String.valueOf(arr[14][3]), String.valueOf(arr[14][4]), String.valueOf(arr[14][5]), String.valueOf(arr[14][6]), String.valueOf(arr[14][7])));
        result.add(new IEC28VO("10>U>=1", String.valueOf(arr[15][0]), String.valueOf(arr[15][1]), String.valueOf(arr[15][2]), String.valueOf(arr[15][3]), String.valueOf(arr[15][4]), String.valueOf(arr[15][5]), String.valueOf(arr[15][6]), String.valueOf(arr[15][7])));
        result.add(new IEC28VO("1>U>=0", String.valueOf(arr[16][0]), String.valueOf(arr[16][1]), String.valueOf(arr[16][2]), String.valueOf(arr[16][3]), String.valueOf(arr[16][4]), String.valueOf(arr[16][5]), String.valueOf(arr[16][6]), String.valueOf(arr[16][7])));
        return result;
    }

    @Override
    public ProbabilityVO getProbabilityDistribution(List<EventDetail> info2) {
        ProbabilityVO result = new ProbabilityVO();
        List<EventDetail> info = new ArrayList<>();

        //总数
        Integer count = 0;
        for (EventDetail eventDetail : info2) {
            //过滤掉大于0.9的数据
            if (eventDetail.getFeatureAmplitude() <= 0.9) {
                count++;
                info.add(eventDetail);
            }
        }
        //计数map
        HashMap<String, Integer> countMap = new HashMap<>();
        countMap.put("<10", 0);
        countMap.put("<20", 0);
        countMap.put("<30", 0);
        countMap.put("<40", 0);
        countMap.put("<50", 0);
        countMap.put("<60", 0);
        countMap.put("<70", 0);
        countMap.put("<80", 0);
        countMap.put("<90", 0);
        //分段计数
        HashMap<String, Integer> subsectionMap = new HashMap<>();
        subsectionMap.put("0~10", 0);
        subsectionMap.put("10~20", 0);
        subsectionMap.put("20~30", 0);
        subsectionMap.put("30~40", 0);
        subsectionMap.put("40~50", 0);
        subsectionMap.put("50~60", 0);
        subsectionMap.put("60~70", 0);
        subsectionMap.put("70~80", 0);
        subsectionMap.put("80~90", 0);
        //求数量
        for (EventDetail eventDetail : info) {
            if (eventDetail.getFeatureAmplitude() < 0.1) {
                countMap.put("<10", (countMap.get("<10") + 1));
            }
            if (eventDetail.getFeatureAmplitude() < 0.2) {
                countMap.put("<20", (countMap.get("<20") + 1));
            }
            if (eventDetail.getFeatureAmplitude() < 0.3) {
                countMap.put("<30", (countMap.get("<30") + 1));
            }
            if (eventDetail.getFeatureAmplitude() < 0.4) {
                countMap.put("<40", (countMap.get("<40") + 1));
            }
            if (eventDetail.getFeatureAmplitude() < 0.5) {
                countMap.put("<50", (countMap.get("<50") + 1));
            }
            if (eventDetail.getFeatureAmplitude() < 0.6) {
                countMap.put("<60", (countMap.get("<60") + 1));
            }
            if (eventDetail.getFeatureAmplitude() < 0.7) {
                countMap.put("<70", (countMap.get("<70") + 1));
            }
            if (eventDetail.getFeatureAmplitude() < 0.8) {
                countMap.put("<80", (countMap.get("<80") + 1));
            }
            if (eventDetail.getFeatureAmplitude() < 0.9) {
                countMap.put("<90", (countMap.get("<90") + 1));
            }
        }
        //求每段数量
        for (EventDetail eventDetail : info) {
            if (eventDetail.getFeatureAmplitude() < 0.1) {
                subsectionMap.put("0~10", (subsectionMap.get("0~10") + 1));
            } else if (eventDetail.getFeatureAmplitude() > 0.1 && eventDetail.getFeatureAmplitude() < 0.2) {
                subsectionMap.put("10~20", (subsectionMap.get("10~20") + 1));
            } else if (eventDetail.getFeatureAmplitude() > 0.2 && eventDetail.getFeatureAmplitude() < 0.3) {
                subsectionMap.put("20~30", (subsectionMap.get("20~30") + 1));
            } else if (eventDetail.getFeatureAmplitude() > 0.3 && eventDetail.getFeatureAmplitude() < 0.4) {
                subsectionMap.put("30~40", (subsectionMap.get("30~40") + 1));
            } else if (eventDetail.getFeatureAmplitude() > 0.4 && eventDetail.getFeatureAmplitude() < 0.5) {
                subsectionMap.put("40~50", (subsectionMap.get("40~50") + 1));
            } else if (eventDetail.getFeatureAmplitude() > 0.5 && eventDetail.getFeatureAmplitude() < 0.6) {
                subsectionMap.put("50~60", (subsectionMap.get("50~60") + 1));
            } else if (eventDetail.getFeatureAmplitude() > 0.6 && eventDetail.getFeatureAmplitude() < 0.7) {
                subsectionMap.put("60~70", (subsectionMap.get("60~70") + 1));
            } else if (eventDetail.getFeatureAmplitude() > 0.7 && eventDetail.getFeatureAmplitude() < 0.8) {
                subsectionMap.put("70~80", (subsectionMap.get("70~80") + 1));
            } else if (eventDetail.getFeatureAmplitude() > 0.8 && eventDetail.getFeatureAmplitude() < 0.9) {
                subsectionMap.put("80~90", (subsectionMap.get("80~90") + 1));
            }
        }
        //求概率并求pereventvalue
        List<String> pereventvalue = new ArrayList<>();
        Set<String> subsectionSet = subsectionMap.keySet();
        List<String> strings1 = new ArrayList<>();
        strings1.add("0~10");
        strings1.add("10~20");
        strings1.add("20~30");
        strings1.add("30~40");
        strings1.add("40~50");
        strings1.add("50~60");
        strings1.add("60~70");
        strings1.add("70~80");
        strings1.add("80~90");
        for (int i = 0; i < strings1.size(); i++) {
            for (String s : subsectionSet) {
                if (strings1.get(i).equals(s)) {
                    if (subsectionMap.get(s) == 0) {
                        pereventvalue.add(".00");
                        break;
                    }
                    if (subsectionMap.get(s) / count.doubleValue() == 1.0) {
                        pereventvalue.add("100.00");
                    } else {
                        String s1 = String.format("%.4f", (subsectionMap.get(s) / count.doubleValue()));
                        pereventvalue.add(s1.substring(2, 4) + "." + s1.substring(4, 6));
                    }
                }
            }
        }
        result.setPereventvalue(pereventvalue);
        //求eventvalue
        List<String> eventvalue = new ArrayList<>();
        List<String> strings = new ArrayList<>();
        strings.add("<10");
        strings.add("<20");
        strings.add("<30");
        strings.add("<40");
        strings.add("<50");
        strings.add("<60");
        strings.add("<70");
        strings.add("<80");
        strings.add("<90");
        Set<String> countSet = countMap.keySet();
        //保证顺序
        for (int i = 0; i < strings.size(); i++) {
            for (String s : countSet) {
                if (strings.get(i).equals(s)) {
                    if (countMap.get(s) == 0) {
                        eventvalue.add(".00");
                        break;
                    }
                    if (countMap.get(s) / count.floatValue() == 1.0) {
                        eventvalue.add("100.00");
                    } else {
                        String s1 = String.format("%.4f", (countMap.get(s) / count.doubleValue()));
                        eventvalue.add(s1.substring(2, 4) + "." + s1.substring(4, 6));
                    }
                }
            }
        }
        eventvalue.add("100.00");
        result.setEventvalue(eventvalue);
        //时间
        HashMap<String, Integer> timeMap = new HashMap<>();
        timeMap.put("<0.1", 0);
        timeMap.put("<0.25", 0);
        timeMap.put("<0.5", 0);
        timeMap.put("<1", 0);
        timeMap.put("<3", 0);
        timeMap.put("<20", 0);
        timeMap.put("<60", 0);
        timeMap.put("<180", 0);
        //求不同时间段的总数
        for (EventDetail eventDetail : info) {
            //转换成ms
            Double persistTime = eventDetail.getDuration()*1000;
            if (persistTime / 1000 < 0.1) {
                timeMap.put("<0.1", timeMap.get("<0.1") + 1);
            } else if (persistTime / 1000 > 0.1 && persistTime / 1000 < 0.25) {
                timeMap.put("<0.25", timeMap.get("<0.25") + 1);
            } else if (persistTime / 1000 > 0.25 && persistTime / 1000 < 0.5) {
                timeMap.put("<0.5", timeMap.get("<0.5") + 1);
            } else if (persistTime / 1000 > 0.5 && persistTime / 1000 < 1) {
                timeMap.put("<1", timeMap.get("<1") + 1);
            } else if (persistTime / 1000 > 1 && persistTime / 1000 < 3) {
                timeMap.put("<3", timeMap.get("<3") + 1);
            } else if (persistTime / 1000 > 3 && persistTime / 1000 < 20) {
                timeMap.put("<20", timeMap.get("<20") + 1);
            } else if (persistTime / 1000 > 20 && persistTime / 1000 < 60) {
                timeMap.put("<60", timeMap.get("<60") + 1);
            } else if (persistTime / 1000 > 60 && persistTime / 1000 < 180) {
                timeMap.put("<180", timeMap.get("<180") + 1);
            }
        }
        List<String> strings2 = new ArrayList<>();
        strings2.add("<0.1");
        strings2.add("<0.25");
        strings2.add("<0.5");
        strings2.add("<1");
        strings2.add("<3");
        strings2.add("<20");
        strings2.add("<60");
        strings2.add("<180");
        //求persisttime
        List<String> persisttime = new ArrayList<>();
        Set<String> timeSet = timeMap.keySet();
        for (int i = 0; i < strings2.size(); i++) {
            for (String s : timeSet) {
                if (strings2.get(i).equals(s)) {
                    if (timeMap.get(s) == 0) {
                        persisttime.add(".00");
                        break;
                    }
                    if (timeMap.get(s) / count.floatValue() == 1.0) {
                        persisttime.add("100.00");
                    } else {
                        String s1 = String.format("%.4f", (timeMap.get(s) / count.doubleValue()));
                        persisttime.add(s1.substring(2, 4) + "." + s1.substring(4, 6));
                    }
                }
            }
        }
        result.setPersisttime(persisttime);

        HashMap<String, Integer> timeMap2 = new HashMap<>();
        timeMap2.put("<0.1", 0);
        timeMap2.put("<0.25", 0);
        timeMap2.put("<0.5", 0);
        timeMap2.put("<1", 0);
        timeMap2.put("<3", 0);
        timeMap2.put("<20", 0);
        timeMap2.put("<60", 0);
        timeMap2.put("<180", 0);
        //求sisttime
        List<String> sisttime = new ArrayList<>();
        for (EventDetail eventDetail : info) {
            Double persistTime = eventDetail.getDuration()*1000;
            if (persistTime / 1000 < 0.1) {
                timeMap2.put("<0.1", timeMap2.get("<0.1") + 1);
            }
            if (persistTime / 1000 < 0.25) {
                timeMap2.put("<0.25", timeMap2.get("<0.25") + 1);
            }
            if (persistTime / 1000 < 0.5) {
                timeMap2.put("<0.5", timeMap2.get("<0.5") + 1);
            }
            if (persistTime / 1000 < 1) {
                timeMap2.put("<1", timeMap2.get("<1") + 1);
            }
            if (persistTime / 1000 < 3) {
                timeMap2.put("<3", timeMap2.get("<3") + 1);
            }
            if (persistTime / 1000 < 20) {
                timeMap2.put("<20", timeMap2.get("<20") + 1);
            }
            if (persistTime / 1000 < 60) {
                timeMap2.put("<60", timeMap2.get("<60") + 1);
            }
            if (persistTime / 1000 < 180) {
                timeMap2.put("<180", timeMap2.get("<180") + 1);
            }
        }
        Set<String> time2Set = timeMap2.keySet();
        for (int i = 0; i < strings2.size(); i++) {
            for (String s : time2Set) {
                if (strings2.get(i).equals(s)) {
                    if (timeMap2.get(s) == 0) {
                        sisttime.add(".00");
                        break;
                    }
                    if (timeMap2.get(s) / count.floatValue() == 1.0) {
                        sisttime.add("100.00");
                    } else {
                        String s1 = String.format("%.4f", (timeMap2.get(s) / count.doubleValue()));
                        sisttime.add(s1.substring(2, 4) + "." + s1.substring(4, 6));
                    }
                }
            }
        }
        sisttime.add("100.00");
        result.setSisttime(sisttime);
        return result;
    }

    @Override
    public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam, List<EventDetail> info) throws ParseException {
        List<TimeVO> list = new ArrayList<>();
        //参数
        StringBuilder builder1 = new StringBuilder();
        StringBuilder builder2 = new StringBuilder();
        QueryResult query = null;
        //获取时间字符串
        String startTime = statisticsParam.getStartTime();
        String endTime = statisticsParam.getEndTime();
        Integer startDays = Integer.parseInt(startTime.substring(8, 10));
        Integer endDays = Integer.parseInt(endTime.substring(8, 10));
        Integer startMonth = Integer.parseInt(startTime.substring(5, 7));
        Integer endMonth = Integer.parseInt(endTime.substring(5, 7));
        Integer startYear = Integer.parseInt(startTime.substring(0, 4));
        Integer endYear = Integer.parseInt(endTime.substring(0, 4));
        if (statisticsParam.getFlag() == 0) {
            while (!startYear.equals(endYear) && !startMonth.equals(endMonth)) {
                builder1.delete(0, builder1.length());
                builder2.delete(0, builder2.length());
                builder1.append(startYear).append("-").append(startMonth).append("-").append(startDays);
                if (startMonth + 1 == 13) {
                    builder2.append(startYear + 1).append("-").append(1).append("-").append(startDays);
                } else {
                    builder2.append(startYear).append("-").append(startMonth + 1).append("-").append(startDays);
                }
                query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(), builder1.toString(), builder2.toString(), statisticsParam.getFlag(),null));
                InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
                List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class);
                long count = eventDetailList.stream().filter(x -> x.getEventType() == "1").count();
                if (startMonth < 10) {
                    list.add(new TimeVO(null, null, "", "0" + startMonth.toString(), count + "", startYear.toString(), startYear.toString() + "-" + "0" + startMonth.toString()));
                } else {
                    list.add(new TimeVO(null, null, "", startMonth.toString(), count + "", startYear.toString(), startYear.toString() + "-" + startMonth.toString()));
                }
                startMonth++;
                if (startMonth == 13) {
                    startYear++;
                    startMonth = 1;
                }
            }
            builder1.delete(0, builder1.length());
            builder2.delete(0, builder2.length());
            builder1.append(startYear).append("-").append(startMonth).append("-").append(startDays);
            builder2.append(startYear).append("-").append(startMonth).append("-").append(endDays);
            query = MonitorQuery(new StatisticsParam(statisticsParam.getLineIndex(), builder1.toString(), builder2.toString(), statisticsParam.getFlag(),null));
            InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
            List<EventDetail> eventDetailList = influxDBResultMapper.toPOJO(query, EventDetail.class);
            long count1 = eventDetailList.stream().filter(x -> x.getEventType() == "1").count();
            if (startMonth < 10) {
                list.add(new TimeVO(null, null, "", "0" + startMonth.toString(), count1 + "", startYear.toString(), startYear.toString() + "-" + "0" + startMonth.toString()));
            } else {
                list.add(new TimeVO(null, null, "", startMonth.toString(), count1 + "", startYear.toString(), startYear.toString() + "-" + startMonth.toString()));
            }
            return list;
        } else {
            QueryResult monitorQuery = MonitorQuery(statisticsParam);
            InfluxDBResultMapper influxDBResultMapper = new InfluxDBResultMapper();
            List<EventDetailNew> eventDetailList = influxDBResultMapper.toPOJO(monitorQuery, EventDetailNew.class);

            Map<String, List<EventDetailNew>> map = eventDetailList.stream().filter(x -> x.getEventType() == "1").collect(Collectors.groupingBy(s ->s.getStartTime().substring(0, 10)));
            Set<String> keySet = map.keySet();

            LocalDate parse1 = LocalDate.parse(startTime);
            LocalDate parse2 = LocalDate.parse(endTime);
            while (!parse1.equals(parse2.plus(1, ChronoUnit.DAYS))) {
                if (keySet.contains(parse1.toString())) {
                    List<EventDetailNew> eventDetailNews = map.get(parse1.toString());
                    TimeVO timeVO = new TimeVO();
                    timeVO.setTimes(eventDetailNews.size() + "");
                    if (parse1.getDayOfMonth() < 10) {
                        timeVO.setDay("0" + parse1.getDayOfMonth() + "");
                    } else {
                        timeVO.setDay(parse1.getDayOfMonth() + "");
                    }
                    timeVO.setYear(parse1.getYear() + "");
                    if (parse1.getMonthValue() < 10) {
                        timeVO.setMonth("0" + parse1.getMonthValue() + "");
                    } else {
                        timeVO.setMonth(parse1.getMonthValue() + "");
                    }
                    timeVO.setFulltime(parse1.toString());
                    list.add(timeVO);
                } else {
                    TimeVO timeVO = new TimeVO();
                    timeVO.setTimes("0");
                    if (parse1.getDayOfMonth() < 10) {
                        timeVO.setDay("0" + parse1.getDayOfMonth() + "");
                    } else {
                        timeVO.setDay(parse1.getDayOfMonth() + "");
                    }
                    timeVO.setYear(parse1.getYear() + "");
                    if (parse1.getMonthValue() < 10) {
                        timeVO.setMonth("0" + parse1.getMonthValue() + "");
                    } else {
                        timeVO.setMonth(parse1.getMonthValue() + "");
                    }
                    timeVO.setFulltime(parse1.toString());
                    list.add(timeVO);
                }
                parse1 = parse1.plus(1, ChronoUnit.DAYS);
            }
            return list;
        }
    }


    /**
     * 暂降事件点图
     *
     * @author wr
     */
    @Override
    public List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData) {
        //添加detail
        for (EventDetail detail : info) {
            for (DictData data : reasonData) {
                if (data.getId().equals(detail.getAdvanceReason())) {
                    detail.setAdvanceReason(data.getName());
                }
            }
            for (DictData data : typeData) {
                if (data.getId().equals(detail.getAdvanceType())) {
                    detail.setAdvanceType(data.getName());
                }
            }
        }
        return info;
    }

    @Override
    public StatisticVO getStatistic(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData) {
        StatisticVO result = new StatisticVO();
        List<EventDetail> list = new ArrayList<>();
        List<ReasonsVO> reasonsVOS = new ArrayList<>();
        List<TypesVO> typesVOS = new ArrayList<>();

        HashMap<String, Integer> reasonMap = new HashMap<>();
        HashMap<String, Integer> typeMap = new HashMap<>();
        //添加detail
        for (EventDetail detail : info) {
            for (DictData data : reasonData) {
                reasonMap.put(data.getName(), 0);
                if (data.getId().equals(detail.getAdvanceReason())) {
                    detail.setAdvanceReason(data.getName());
                }
            }
            for (DictData data : typeData) {
                typeMap.put(data.getName(), 0);
                if (data.getId().equals(detail.getAdvanceType())) {
                    detail.setAdvanceType(data.getName());
                }
            }
            list.add(detail);
        }

        //添加reason到map
        for (EventDetail data : list) {
            if (reasonMap.get(data.getAdvanceReason()) != null) {
                reasonMap.put(data.getAdvanceReason(), reasonMap.get(data.getAdvanceReason()) + 1);
            }
        }
        //添加type到map
        for (EventDetail data : list) {
            if (typeMap.get(data.getAdvanceType()) != null) {
                typeMap.put(data.getAdvanceType(), typeMap.get(data.getAdvanceType()) + 1);
            }
        }
        Set<String> reasonKeyset = reasonMap.keySet();
        Set<String> typeKeyset = typeMap.keySet();
        for (String s : reasonKeyset) {
            reasonsVOS.add(new ReasonsVO(s, reasonMap.get(s), null));
        }
        for (String s : typeKeyset) {
            typesVOS.add(new TypesVO(s, typeMap.get(s)));
        }
        result.setTypes(typesVOS);
        result.setReason(reasonsVOS);
        return result;
    }


    @Override
    public Integer[][] getCoords(List<EventDetail> info) {
        Integer[][] eventDensityData = new Integer[90][3];
        for (int i = 0; i < 10; i++) {
//            eventDensityData[i] = new Integer[]{i % 10, i % 9, 0};
            for (int j = 0; j < 9; j++) {
                eventDensityData[i * 9 + j] = new Integer[]{i, j % 9, 0};
            }
        }
        for (int i = 0; i < info.size(); i++) {
            Integer index = null;
            if (info.get(i).getFeatureAmplitude() >= 0 && info.get(i).getFeatureAmplitude() <= 0.1) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 0;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 1;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 2;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 3;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 4;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 5;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 6;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 7;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 8;
                }
            } else if (info.get(i).getFeatureAmplitude() > 0.1 && info.get(i).getFeatureAmplitude() <= 0.2) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 9;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 10;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 11;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 12;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 13;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 14;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 15;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 16;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 17;
                }
            } else if (info.get(i).getFeatureAmplitude() > 0.2 && info.get(i).getFeatureAmplitude() <= 0.3) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 18;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 19;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 20;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 21;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 22;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 23;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 24;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 25;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 26;
                }
            } else if (info.get(i).getFeatureAmplitude() > 0.3 && info.get(i).getFeatureAmplitude() <= 0.4) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 27;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 28;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 29;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 30;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 31;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 32;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 33;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 34;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 35;
                }
            } else if (info.get(i).getFeatureAmplitude() > 0.4 && info.get(i).getFeatureAmplitude() <= 0.5) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 36;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 37;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 38;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 39;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 40;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 41;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 42;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 43;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 44;
                }
            } else if (info.get(i).getFeatureAmplitude() > 0.5 && info.get(i).getFeatureAmplitude() <= 0.6) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 45;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 46;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 47;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 48;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 49;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 50;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 51;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 52;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 53;
                }
            } else if (info.get(i).getFeatureAmplitude() > 0.6 && info.get(i).getFeatureAmplitude() <= 0.7) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 54;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 55;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 56;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 57;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 58;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 59;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 60;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 61;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 62;
                }
            } else if (info.get(i).getFeatureAmplitude() > 0.7 && info.get(i).getFeatureAmplitude() <= 0.8) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 63;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 64;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 65;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 66;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 67;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 68;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 69;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 70;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 71;
                }
            } else if (info.get(i).getFeatureAmplitude() > 0.8 && info.get(i).getFeatureAmplitude() <= 0.9) {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 72;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 73;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 74;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 75;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 76;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 77;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 78;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 79;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 80;
                }
            } else {
                if (info.get(i).getDuration() / 1000 > 0 && info.get(i).getDuration() / 1000 <= 0.020) {
                    index = 81;
                } else if (info.get(i).getDuration() / 1000 <= 0.040 && info.get(i).getDuration() / 1000 > 0.020) {
                    index = 82;
                } else if (info.get(i).getDuration() / 1000 <= 0.060 && info.get(i).getDuration() / 1000 > 0.040) {
                    index = 83;
                } else if (info.get(i).getDuration() / 1000 <= 0.080 && info.get(i).getDuration() / 1000 > 0.060) {
                    index = 84;
                } else if (info.get(i).getDuration() / 1000 <= 0.120 && info.get(i).getDuration() / 1000 > 0.080) {
                    index = 85;
                } else if (info.get(i).getDuration() / 1000 > 0.120 && info.get(i).getDuration() / 1000 < 0.200) {
                    index = 86;
                } else if (info.get(i).getDuration() / 1000 >= 0.200 && info.get(i).getDuration() / 1000 < 0.400) {
                    index = 87;
                } else if (info.get(i).getDuration() / 1000 >= 0.400 && info.get(i).getDuration() / 1000 < 0.600) {
                    index = 88;
                } else if (info.get(i).getDuration() / 1000 >= 0.600 && info.get(i).getDuration() / 1000 <= 1.200) {
                    index = 89;
                }
            }
            if (Objects.nonNull(index)) {
                Integer[] temNumber = eventDensityData[index];
                temNumber[2] = temNumber[2] + 1;
            }
        }
        return eventDensityData;
    }

    /**
     * @return
     * @author xxy
     * 时间区间查询监测点抽取
     */
    public QueryResult MonitorQuery(StatisticsParam statisticsParam) {
        //构建sql语句
        String stringResult = Param.SELECT + Param.EVENT_DETAIL + Param.WHERE + "" + "time >= '" +
                DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime().toString())) +
                "' and " + "time <= '" +
                DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getEndTime().toString())) +
                "' and " + "line_id= '" +
                statisticsParam.getLineIndex() + "' " +
                Param.TZ_ASIA_SHANGHAI;
        //结果集映射到对象中
        return influxDbUtils.query(stringResult);
    }
}
