package com.njcn.event.service.majornetwork.Impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.FileUtil;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
import com.njcn.device.pms.pojo.dto.PmsMonitorDTO;
import com.njcn.device.pms.pojo.dto.PwPmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.device.pms.pojo.param.PmsMonitorParam;
import com.njcn.device.pms.pojo.param.PwPmsMonitorParam;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.LineBaseQueryParam;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.echarts.pojo.constant.PicCommonData;
import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.mapper.majornetwork.ReportMapper;
import com.njcn.event.pojo.param.*;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.Eventass;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.ReportService;
import com.njcn.event.common.utils.WordUtils;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.poi.util.PoiUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.utils.WebUtil;
import freemarker.template.TemplateException;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import sun.misc.BASE64Decoder;


/**
 * @author xxy
 * @version 1.0.0
 * @date 2022年07月28日 13:33
 */
@Service
@RequiredArgsConstructor
public class ReportServiceImpl implements ReportService {

    private final GeneralDeviceInfoClient generalDeviceInfoClient;

    private final LineFeignClient lineFeignClient;

    private final DicDataFeignClient dicDataFeignClient;
    private final DeptFeignClient deptFeignClient;

    private final EventReportService eventReportService;
    //调用暂降密度接口
    private final EventAnalysisService eventAnalysisService;
    private final PmsGeneralDeviceInfoClient pmsGeneralDeviceInfoClient;
    private final MonitorClient monitorClient;
    private final PwMonitorClient pwMonitorClient;
    private final EventDetailService eventDetailService;
    private final EventDetailMapper eventDetailMapper;
    private final ReportMapper reportMapper;
    private final DrawPicUtil drawPicUtil;
    private final FileStorageUtil fileStorageUtil;

    public List<EventDetail> getED(DeviceInfoParam.BusinessParam businessParam, List<String> ids) {
        List<EventDetail> info = new ArrayList<>();
        List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
        List<String> lineIds = deviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
        if (CollectionUtil.isNotEmpty(lineIds)) {
            //数据暂降查询
            List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
                    .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
                    .in(RmpEventDetailPO::getEventType, ids)
                    .ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
                    .le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
            );
            info = BeanUtil.copyToList(eventDetails, EventDetail.class);
        } else {
            throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
        }

        return info;
    }


    /**
     * 暂态统计(区域)
     *
     * @param businessParam
     * @return
     */
    @Override
    public List<GeneralVO> getGeneralSituation(DeviceInfoParam.BusinessParam businessParam) {
        //获取事件类型
        List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
        if (CollectionUtil.isEmpty(dictType)) {
            return new ArrayList<>();
        }
        Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
        //查区域
        List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
        List<String> lineIds = data.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
        List<GeneralVO> generalVOS = new ArrayList<>();
        if (CollUtil.isNotEmpty(lineIds)) {
            HashMap<String, Object> condMap = new HashMap<>();
            condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
            condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
            condMap.put("ids", lineIds);
            condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降
            condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断
            condMap.put(DicDataEnum.VOLTAGE_RISE.getCode(), dictMap.get(DicDataEnum.VOLTAGE_RISE.getCode())); //电压暂升
            //根据id把所有的数据查询出来
            generalVOS = eventDetailMapper.ListEventType(condMap);
        }


        GeneralVO generalVO;
        List<GeneralVO> list = new ArrayList<>();
        for (GeneralDeviceDTO dto : data) {
            generalVO = new GeneralVO();
            generalVO.setName(dto.getName());

            if (CollUtil.isNotEmpty(dto.getLineIndexes())) {
                List<GeneralVO> collect = generalVOS.stream().filter(x -> dto.getLineIndexes().contains(x.getId())).collect(Collectors.toList());
                int sagsCount = collect.stream().mapToInt(GeneralVO::getSagsCount).sum();
                int breakCount = collect.stream().mapToInt(GeneralVO::getBreakCount).sum();
                int upCount = collect.stream().mapToInt(GeneralVO::getUpCount).sum();
                Integer onLineCount = lineFeignClient.getOnLineCount(dto.getLineIndexes()).getData();
                generalVO.setVol(0.0D);
                generalVO.setOnLine(onLineCount);
                generalVO.setOffLine(dto.getLineIndexes().size() - onLineCount);
                generalVO.setSagsCount(sagsCount);
                generalVO.setBreakCount(breakCount);
                generalVO.setUpCount(upCount);
            } else {
                generalVO.setVol(0.0D);
                generalVO.setOnLine(0);
                generalVO.setOffLine(0);
                generalVO.setSagsCount(0);
                generalVO.setBreakCount(0);
                generalVO.setUpCount(0);
            }
            list.add(generalVO);

        }
        return list;
    }

    /**
     * 暂态统计(电压)
     *
     * @param businessParam
     * @return
     */
    @Override
    public List<GeneralVO> getVoltage(DeviceInfoParam.BusinessParam businessParam) {
        //获取事件类型
        List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
        if (CollectionUtil.isEmpty(dictType)) {
            return new ArrayList<>();
        }
        Map<String, String> dictMap = dictType.stream().collect(Collectors.toMap(DictData::getCode, DictData::getId));
        //查电压
        List<GeneralDeviceDTO> data = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
        List<String> lineIds = data.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());

        HashMap<String, Object> condMap = new HashMap<>();
        condMap.put("startTime", DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())).toString());
        condMap.put("endTime", DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())).toString());
        condMap.put("ids", lineIds);
        condMap.put(DicDataEnum.VOLTAGE_DIP.getCode(), dictMap.get(DicDataEnum.VOLTAGE_DIP.getCode())); //电压暂降
        condMap.put(DicDataEnum.SHORT_INTERRUPTIONS.getCode(), dictMap.get(DicDataEnum.SHORT_INTERRUPTIONS.getCode())); //短时中断
        condMap.put(DicDataEnum.VOLTAGE_RISE.getCode(), dictMap.get(DicDataEnum.VOLTAGE_RISE.getCode())); //电压暂升

        //根据id把所有的数据查询出来
        List<GeneralVO> generalVOS = eventDetailMapper.ListEventType(condMap);

        GeneralVO generalVO;
        List<GeneralVO> list = new ArrayList<>();
        for (GeneralDeviceDTO dto : data) {
            generalVO = new GeneralVO();
            generalVO.setName(dto.getName());

            if (CollUtil.isNotEmpty(dto.getLineIndexes())) {
                List<GeneralVO> collect = generalVOS.stream().filter(x -> dto.getLineIndexes().contains(x.getId())).collect(Collectors.toList());
                int sagsCount = collect.stream().mapToInt(GeneralVO::getSagsCount).sum();
                int breakCount = collect.stream().mapToInt(GeneralVO::getBreakCount).sum();
                int upCount = collect.stream().mapToInt(GeneralVO::getUpCount).sum();
                Integer onLineCount = lineFeignClient.getOnLineCount(dto.getLineIndexes()).getData();
                generalVO.setVol(0.0D);
                generalVO.setOnLine(onLineCount);
                generalVO.setOffLine(dto.getLineIndexes().size() - onLineCount);
                generalVO.setSagsCount(sagsCount);
                generalVO.setBreakCount(breakCount);
                generalVO.setUpCount(upCount);
            } else {
                generalVO.setVol(0.0D);
                generalVO.setOnLine(0);
                generalVO.setOffLine(0);
                generalVO.setSagsCount(0);
                generalVO.setBreakCount(0);
                generalVO.setUpCount(0);
            }
            list.add(generalVO);

        }
        list.forEach(item -> item.setVol(Double.parseDouble(item.getName().substring(0, item.getName().indexOf("k")))));
        List<GeneralVO> sortedList = list.stream().sorted(Comparator.comparing(GeneralVO::getVol)).collect(Collectors.toList());
        return sortedList;
    }

    /**
     * 严重度前20
     *
     * @param businessParam
     * @return
     */
    @Override
    public List<WaveTypeVO> getSeverity(DeviceInfoParam.BusinessParam businessParam) {
        List<WaveTypeVO> result = new ArrayList<>();
        List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
        List<String> lineIds = deviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
        List<EventDetailNew> info = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(lineIds)) {
            //数据暂降查询
            List<RmpEventDetailPO> eventDetails = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
                    .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
                    .ge(StrUtil.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
                    .le(StrUtil.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
                    .orderByDesc(RmpEventDetailPO::getSeverity).last(" limit 20")
            );
            info =  eventDetails.stream().map(temp->{
                EventDetailNew eventDetailNew = new EventDetailNew();
                BeanUtils.copyProperties(temp,eventDetailNew);
                eventDetailNew.setStartTime(LocalDateTimeUtil.format(temp.getStartTime(),DatePattern.NORM_DATETIME_MS_PATTERN));
                return eventDetailNew;
            }).collect(Collectors.toList());

//            info = BeanUtil.copyToList(eventDetails, EventDetailNew.class);
        } else {
            throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
        }
        if (CollectionUtil.isNotEmpty(info)) {

            List<String> idlist = info.stream().map(EventDetailNew::getLineId).distinct().collect(Collectors.toList());

            //得到对应的监测点信息
            HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
            List<AreaLineInfoVO> data = AreaInfo.getData();
            //遍历集合比较id得到最终数据
            for (EventDetailNew detail : info) {
                WaveTypeVO waveTypeVO = new WaveTypeVO();
                for (AreaLineInfoVO vo : data) {
                    if (detail.getLineId().equals(vo.getLineId())) {
                        BeanUtils.copyProperties(detail, waveTypeVO);
                        BeanUtils.copyProperties(vo, waveTypeVO);
                        waveTypeVO.setStartTime(LocalDateTimeUtil.parse(detail.getStartTime(),DatePattern.NORM_DATETIME_MS_PATTERN));
                        result.add(waveTypeVO);
                    }
                }
            }
        }
        return result;
    }

    /**
     * 获取暂降原因
     *
     * @param businessParam
     * @return
     */
    @Override
    public List<ReasonsVO> getReason(DeviceInfoParam.BusinessParam businessParam) {
        //获取暂降字典信息
        DictData dictData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
        DictData shortInterruptionsData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();

        if(ObjectUtil.isNull(dictData)||ObjectUtil.isNull(shortInterruptionsData)){
            throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
        }
        List<ReasonsVO> result = new ArrayList<>();
        List<EventDetail> info = getED(businessParam,Stream.of(dictData.getId(),shortInterruptionsData.getId()).collect(Collectors.toList()) );
        //获取字典表
        HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName());
        List<DictData> data = reason.getData();
        //计数器初始化
        HashMap<String, Integer> count = new HashMap<>();
        for (DictData datum : data) {
            count.put(datum.getName(), 0);
        }
        //过滤掉原因的是空的
        info = info.stream().filter(temp->StringUtils.isNotEmpty(temp.getAdvanceReason())).collect(Collectors.toList());
        //替值
        for (EventDetail eventDetail : info) {
//            if (dictData.getId().equals(eventDetail.getEventType())) {
                for (DictData datum : data) {
                    if (datum.getId().equals(eventDetail.getAdvanceReason())) {
                        eventDetail.setAdvanceReason(datum.getName());
                    }
                }
//            }
        }
        //计数
        Set<String> keySet = count.keySet();
        for (EventDetail eventDetail : info) {
            for (String s : keySet) {
                if (s.equals(eventDetail.getAdvanceReason())) {
                    count.put(s, count.get(s) + 1);
                }
            }
        }
        for (String s : keySet) {
            if (count.get(s) == 0) {
                result.add(new ReasonsVO(s, 0, "0"));
            } else {
                if (count.get(s) == info.size()) {
                    result.add(new ReasonsVO(s, info.size(), "100"));
                } else {
                    String s2 = BigDecimal.valueOf((double) count.get(s) * 100 / info.size()).setScale(2, RoundingMode.HALF_UP).toString();
//                    String s1 = String.format("%.4f", (count.get(s).doubleValue() / info.size()));
                    result.add(new ReasonsVO(s, count.get(s), s2));
                }
            }
        }
        return result;
    }

    /**
     * 获取详细时间列表
     *
     * @param waveTypeParam
     * @return
     */
    @Override
    public Page<DetailVO> getContinueTime(WaveTypeParam waveTypeParam) {
        //获取暂降字典信息
        DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
        DictData shortInterruptionsData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();

        if(ObjectUtil.isNull(voltageData)||ObjectUtil.isNull(shortInterruptionsData)){
            throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
        }
        List<String> lineIds = new ArrayList<>();
        List<DetailVO> result = new ArrayList<>();
        if (waveTypeParam.getType() == 0) {
            //pq系统
            List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData();
            lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
        }
        if (waveTypeParam.getType() == 1) {
            //pms系统
            PmsDeviceInfoParam param = new PmsDeviceInfoParam();
            param.setDeptIndex(waveTypeParam.getDeptIndex());
            param.setStatisticalType(waveTypeParam.getStatisticalType());
            List<PmsGeneralDeviceDTO> data = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(param).getData();
            lineIds = data.stream().flatMap(list -> list.getMonitorIdList().stream()).collect(Collectors.toList());
        }
        if (waveTypeParam.getType() == 2) {
            PmsDeviceInfoParam param = new PmsDeviceInfoParam();
            param.setDeptIndex(waveTypeParam.getDeptIndex());
            param.setStatisticalType(waveTypeParam.getStatisticalType());
            List<PmsGeneralDeviceDTO> data = pmsGeneralDeviceInfoClient.getPwPmsDeviceInfoWithOrgId(param).getData();
            lineIds = data.stream().flatMap(list -> list.getMonitorIdList().stream()).collect(Collectors.toList());
        }
        if (waveTypeParam.getType() == 3) {
            //获取配网监测点
            PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
            pwPmsMonitorParam.setOrgId(waveTypeParam.getDeptIndex());
            List<PwPmsMonitorDTO> pwPmsMonitorDTOS = pwMonitorClient.getPwSubsetMonitorList(pwPmsMonitorParam).getData();
            //获取主网监测点
            List<PmsMonitorDTO> monitorList = this.getMonitorList(waveTypeParam.getDeptIndex());
            if (CollUtil.isNotEmpty(monitorList)) {
                lineIds.addAll(monitorList.stream().map(PmsMonitorDTO::getId).collect(Collectors.toList()));
            }
            lineIds.addAll(pwPmsMonitorDTOS.stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList()));

        }
        if (CollectionUtil.isEmpty(lineIds)) {
            throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
        }
        Page<RmpEventDetailPO> pageInfo = new Page<>();
        if (waveTypeParam.getType() != 3) {
            pageInfo = eventDetailService.page(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), new LambdaQueryWrapper<RmpEventDetailPO>()
                    .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
                    .in(RmpEventDetailPO::getEventType,Stream.of(voltageData.getId(),shortInterruptionsData.getId()).collect(Collectors.toList()))
                    .ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
                    .le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime())))
                    .orderByDesc(RmpEventDetailPO::getStartTime)
            );
        } else {
            pageInfo.setRecords(eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
                    .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
                    .eq(StrUtil.isNotBlank(voltageData.getId()), RmpEventDetailPO::getEventType, voltageData.getId())
                    .ge(StringUtils.isNotBlank(waveTypeParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(waveTypeParam.getSearchBeginTime())))
                    .le(StringUtils.isNotBlank(waveTypeParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(waveTypeParam.getSearchEndTime())))
                    .orderByDesc(RmpEventDetailPO::getStartTime)));
        }
        List<EventDetailNew> info = BeanUtil.copyToList(pageInfo.getRecords(), EventDetailNew.class);
        if (CollectionUtil.isNotEmpty(info)) {
            ArrayList<String> idlist = new ArrayList<>();
            for (EventDetailNew eventDetail : info) {
                DetailVO vo = new DetailVO();
                BeanUtils.copyProperties(eventDetail, vo);
                result.add(vo);
                idlist.add(eventDetail.getLineId());
            }
            if (CollUtil.isNotEmpty(idlist)) {
                if (waveTypeParam.getType() == 0) {
                    //pq系统
                    HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
                    List<AreaLineInfoVO> data = AreaInfo.getData();
                    for (DetailVO detailVO : result) {
                        for (AreaLineInfoVO vo : data) {
                            if (vo.getLineId().equals(detailVO.getLineId())) {
                                BeanUtils.copyProperties(vo, detailVO);
                            }
                        }
                    }

                } else {
                    //pms系统
                    List<Monitor> monitorInfo = monitorClient.getMonitorList(idlist).getData();
                    for (DetailVO detailVO : result) {
                        for (Monitor vo : monitorInfo) {
                            if (vo.getId().equals(detailVO.getLineId())) {
                                detailVO.setLineId(vo.getId());
                                detailVO.setLineName(vo.getName());
                                detailVO.setSubId(vo.getPowerrId());
                                detailVO.setSubName(vo.getPowerrName());
                                detailVO.setGdId(vo.getOrgId());
                                detailVO.setGdName(vo.getOrgName());
                                detailVO.setVoltageScale(vo.getVoltageLevel());
                            }
                        }
                    }
                }

                HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
                List<DictData> type = reason.getData();
                for (DetailVO detailVO : result) {
                    for (DictData dictData : type) {
                        if (dictData.getId().equals(detailVO.getAdvanceType())) {
                            detailVO.setAdvanceType(dictData.getName());
                        }
                    }
                }
            }
        }
        Page<DetailVO> page = BeanUtil.copyProperties(pageInfo, Page.class);
        page.setRecords(result);
        return page;

    }

    private List<PmsMonitorDTO> getMonitorList(String orgID) {
        //获取所有子部门信息
        List<DeptDTO> deptDTOList = deptFeignClient.getDeptDescendantIndexes(orgID, WebUtil.filterDeptType()).getData();
        if (CollUtil.isEmpty(deptDTOList)) {
            throw new BusinessException(CommonResponseEnum.NO_DATA, "部门不存在");
        }
        //单位code集合
        List<String> orgCodeList = deptDTOList.stream().map(DeptDTO::getCode).collect(Collectors.toList());
        //查询监测点信息
        PmsMonitorParam pmsMonitorParam = new PmsMonitorParam();
        pmsMonitorParam.setOrgIds(orgCodeList); //单位codes
        List<PmsMonitorDTO> monitorList = monitorClient.getMonitorInfoListByCond(pmsMonitorParam).getData(); //监测点信息
        return monitorList;
    }

    /**
     * 暂降次数统计
     *
     * @param waveTypeParam
     * @return
     */
    @Override
    public Page<DetailVO> getSagTimes(WaveTypeParam waveTypeParam) {
        //获取暂降字典信息
        DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();

        List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData();
        List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
        if (CollectionUtil.isEmpty(lineIds)) {
            throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
        }

        Page<DetailVO> detail = reportMapper.getSagTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), lineIds, waveTypeParam.getSearchBeginTime(), waveTypeParam.getSearchEndTime(), dictdata.getId());
        List<DetailVO> detailVO = detail.getRecords();
        ArrayList<String> idlist = new ArrayList<>();
        for (DetailVO vo : detailVO) {
            idlist.add(vo.getLineId());
        }
        if (CollUtil.isNotEmpty(idlist)) {
            HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
            List<AreaLineInfoVO> data = AreaInfo.getData();
            for (DetailVO v : detailVO) {
                for (AreaLineInfoVO vo : data) {
                    if (vo.getLineId().equals(v.getLineId())) {
                        BeanUtils.copyProperties(vo, v);
                    }
                }
            }
        }

        Page<DetailVO> page = BeanUtil.copyProperties(detail, Page.class);
        page.setRecords(detailVO);
        return page;
    }

    /**
     * 暂升次数统计
     *
     * @param waveTypeParam
     * @return
     */
    @Override
    public Page<DetailVO> getUpTimes(WaveTypeParam waveTypeParam) {
        //List<DetailVO> result = new ArrayList<>();
        //获取暂升字典信息
        DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();

        List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(waveTypeParam).getData();
        List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
        if (CollectionUtil.isEmpty(lineIds)) {
            throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
        }

        Page<DetailVO> detail = reportMapper.getUpTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), lineIds, waveTypeParam.getSearchBeginTime(), waveTypeParam.getSearchEndTime(), dictdata.getId());
        List<DetailVO> detailVO = detail.getRecords();

        //id集合
        ArrayList<String> idlist = new ArrayList<>();
        for (DetailVO vo : detailVO) {
            idlist.add(vo.getLineId());
        }
        if (CollUtil.isNotEmpty(idlist)) {
            HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
            List<AreaLineInfoVO> data = AreaInfo.getData();
            for (DetailVO v : detailVO) {
                for (AreaLineInfoVO vo : data) {
                    if (vo.getLineId().equals(v.getLineId())) {
                        BeanUtils.copyProperties(vo, v);
                    }
                }
            }
        }
        Page<DetailVO> page = BeanUtil.copyProperties(detail, Page.class);
        page.setRecords(detailVO);
        return page;


    }

    /**
     * 中断次数统计
     *
     * @param waveTypeParam
     * @return
     */
    @Override
    public Page<DetailVO> getBreakTimes(WaveTypeParam waveTypeParam) {
        //List<DetailVO> result = new ArrayList<>();

        //获取中断字典信息
        DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();

        List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(waveTypeParam).getData();
        List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
        if (CollectionUtil.isEmpty(lineIds)) {
            throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
        }

        Page<DetailVO> detail = reportMapper.getBreakTimes(new Page<>(waveTypeParam.getPageNum(), waveTypeParam.getPageSize()), lineIds, waveTypeParam.getSearchBeginTime(), waveTypeParam.getSearchEndTime(), dictdata.getId());
        List<DetailVO> detailVO = detail.getRecords();

        //id集合
        ArrayList<String> idlist = new ArrayList<>();
        for (DetailVO vo : detailVO) {
            idlist.add(vo.getLineId());
        }
        if (CollUtil.isNotEmpty(idlist)) {
            HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
            List<AreaLineInfoVO> data = AreaInfo.getData();

            for (DetailVO v : detailVO) {
                for (AreaLineInfoVO vo : data) {
                    if (vo.getLineId().equals(v.getLineId())) {
                        BeanUtils.copyProperties(vo, v);
                    }
                }
            }
        }

        Page<DetailVO> page = BeanUtil.copyProperties(detail, Page.class);
        page.setRecords(detailVO);
        return page;
    }

    @Override
    public void getExport(DeviceInfoParam.BusinessParam businessParam, HttpServletResponse response) throws IOException, TemplateException {
        HSSFWorkbook sheets = getSheets(businessParam);
        PoiUtil.exportFileByWorkbook(sheets, "电压暂降周报.xlsx", response);
    }

    /**
     * 生成暂态报告xlsx
     *
     * @param businessParam
     * @return
     * @throws TemplateException
     * @throws IOException
     */
    private HSSFWorkbook getSheets(DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException {
        //区域暂态统计数据
        List<GeneralVO> GereralList = getGeneralSituation(businessParam);
        //电压暂态统计数据
        SimpleDTO simpleDTOV = new SimpleDTO();
        simpleDTOV.setName("电压等级");
        simpleDTOV.setSort(1);
        simpleDTOV.setCode("Voltage_Level");
        businessParam.setStatisticalType(simpleDTOV);
        List<GeneralVO> VoltageList = getVoltage(businessParam);

        //表格操作
        HSSFWorkbook sheets = new HSSFWorkbook();
        sheets.createSheet("暂态总体概况");
        HSSFSheet sheetAt = sheets.getSheetAt(0);
        sheetAt.setColumnWidth(0, 24 * 256);
        sheetAt.setColumnWidth(1, 9 * 256);
        sheetAt.setColumnWidth(2, 9 * 256);
        sheetAt.setColumnWidth(3, 9 * 256);
        sheetAt.setColumnWidth(4, 9 * 256);
        sheetAt.setColumnWidth(5, 9 * 256);
        sheetAt.addMergedRegion(new CellRangeAddress(0, 0, 0, 5));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 1, 0, 5));
        sheetAt.addMergedRegion(new CellRangeAddress(2, 3, 0, 0));
        sheetAt.addMergedRegion(new CellRangeAddress(2, 2, 1, 2));
        sheetAt.addMergedRegion(new CellRangeAddress(2, 3, 3, 3));
        sheetAt.addMergedRegion(new CellRangeAddress(2, 3, 4, 4));
        sheetAt.addMergedRegion(new CellRangeAddress(2, 3, 5, 5));

        HSSFRow title = sheetAt.createRow(0);
        HSSFRow row1 = sheetAt.createRow(1);
        HSSFRow row2 = sheetAt.createRow(2);
        HSSFRow row3 = sheetAt.createRow(3);

        HSSFFont font = sheets.createFont();
        font.setFontName("微软雅黑");
        font.setBold(true);
        HSSFCellStyle cellStyle = sheets.createCellStyle();
        cellStyle.setAlignment(HorizontalAlignment.CENTER);
        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        cellStyle.setFont(font);

        HSSFCellStyle cellStylearea = sheets.createCellStyle();
        cellStylearea.setAlignment(HorizontalAlignment.CENTER);
        cellStylearea.setVerticalAlignment(VerticalAlignment.CENTER);
        cellStylearea.setFont(font);

        HSSFCell titleCell = title.createCell(0);
        setCellStyle(titleCell, "暂态统计", cellStyle);
        HSSFCell r1Cell0 = row1.createCell(0);
        setCellStyle(r1Cell0, "按区域统计", cellStyle);
        HSSFCell r2Cell0 = row2.createCell(0);
        setCellStyle(r2Cell0, "区域", cellStyle);
        HSSFCell r2Cell1 = row2.createCell(1);
        setCellStyle(r2Cell1, "监测点数量", cellStyle);
        HSSFCell r2Cell3 = row2.createCell(3);
        setCellStyle(r2Cell3, "暂降次数", cellStyle);
        HSSFCell r2Cell4 = row2.createCell(4);
        setCellStyle(r2Cell4, "中断次数", cellStyle);
        HSSFCell r2Cell5 = row2.createCell(5);
        setCellStyle(r2Cell5, "暂升次数", cellStyle);
        HSSFCell r3Cell1 = row3.createCell(1);
        setCellStyle(r3Cell1, "在线", cellStyle);
        HSSFCell r3Cell2 = row3.createCell(2);
        setCellStyle(r3Cell2, "离线", cellStyle);

        int titleSize = 4;
        HSSFCellStyle bodyStyle = sheets.createCellStyle();
        bodyStyle.setAlignment(HorizontalAlignment.CENTER);
        bodyStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        HSSFFont bodyFont = sheets.createFont();
        bodyFont.setFontName("微软雅黑");
        bodyFont.setFontHeightInPoints((short) 9);
        bodyStyle.setFont(bodyFont);

        sheet3(sheets, cellStyle, bodyStyle, businessParam);
        sheet2(sheets, cellStyle, bodyStyle, businessParam);
        sheet4(sheets, cellStyle, bodyStyle, businessParam);
        sheet5(sheets, cellStyle, bodyStyle, businessParam);
        sheet6(sheets, cellStyle, bodyStyle, businessParam);
        sheet7(sheets, cellStyle, bodyStyle, businessParam);


        ArrayList<Integer> online = new ArrayList<>();
        ArrayList<Integer> offline = new ArrayList<>();
        ArrayList<String> xdata = new ArrayList<>();

        ArrayList<Integer> online2 = new ArrayList<>();
        ArrayList<Integer> offline2 = new ArrayList<>();
        ArrayList<String> xdata2 = new ArrayList<>();

        List<Integer> up1 = new ArrayList<>();
        List<Integer> sag1 = new ArrayList<>();
        List<Integer> break1 = new ArrayList<>();

        List<Integer> up2 = new ArrayList<>();
        List<Integer> sag2 = new ArrayList<>();
        List<Integer> break2 = new ArrayList<>();

        for (int i = 0; i < GereralList.size(); i++) {
            GeneralVO vo = GereralList.get(i);

            xdata.add(vo.getName());
            online.add(vo.getOnLine());
            offline.add(vo.getOffLine());

            up1.add(vo.getUpCount());
            sag1.add(vo.getSagsCount());
            break1.add(vo.getBreakCount());

            HSSFRow row = sheetAt.createRow(i + titleSize);
            HSSFCell cell0 = row.createCell(0);
            HSSFCell cell1 = row.createCell(1);
            HSSFCell cell2 = row.createCell(2);
            HSSFCell cell3 = row.createCell(3);
            HSSFCell cell4 = row.createCell(4);
            HSSFCell cell5 = row.createCell(5);

            cell0.setCellStyle(bodyStyle);
            cell1.setCellStyle(bodyStyle);
            cell2.setCellStyle(bodyStyle);
            cell3.setCellStyle(bodyStyle);
            cell4.setCellStyle(bodyStyle);
            cell5.setCellStyle(bodyStyle);

            cell0.setCellValue(vo.getName());
            cell1.setCellValue(vo.getOnLine());
            cell2.setCellValue(vo.getOffLine());
            cell3.setCellValue(vo.getSagsCount());
            cell4.setCellValue(vo.getBreakCount());
            cell5.setCellValue(vo.getUpCount());
        }
        titleSize = titleSize + GereralList.size();

        sheetAt.addMergedRegion(new CellRangeAddress(titleSize, titleSize, 0, 5));
        sheetAt.addMergedRegion(new CellRangeAddress(titleSize + 1, titleSize + 2, 0, 0));
        sheetAt.addMergedRegion(new CellRangeAddress(titleSize + 1, titleSize + 1, 1, 2));
        sheetAt.addMergedRegion(new CellRangeAddress(titleSize + 1, titleSize + 2, 3, 3));
        sheetAt.addMergedRegion(new CellRangeAddress(titleSize + 1, titleSize + 2, 4, 4));
        sheetAt.addMergedRegion(new CellRangeAddress(titleSize + 1, titleSize + 2, 5, 5));

        HSSFRow rown = sheetAt.createRow(titleSize);
        HSSFRow row1v = sheetAt.createRow(titleSize + 1);
        HSSFRow row2v = sheetAt.createRow(titleSize + 2);

        HSSFCell cellvt = rown.createCell(0);
        setCellStyle(cellvt, "按电压等级统计", cellStyle);
        HSSFCell v1cell0 = row1v.createCell(0);
        setCellStyle(v1cell0, "电压等级", cellStyle);
        HSSFCell v1cell1 = row1v.createCell(1);
        setCellStyle(v1cell1, "监测点数量", cellStyle);
        HSSFCell v2cell1 = row2v.createCell(1);
        setCellStyle(v2cell1, "在线", cellStyle);
        HSSFCell v2cell2 = row2v.createCell(2);
        setCellStyle(v2cell2, "离线", cellStyle);
        HSSFCell v1cell3 = row1v.createCell(3);
        HSSFCell v1cell4 = row1v.createCell(4);
        HSSFCell v1cell5 = row1v.createCell(5);
        setCellStyle(v1cell3, "暂降次数", cellStyle);
        setCellStyle(v1cell4, "中断次数", cellStyle);
        setCellStyle(v1cell5, "暂升次数", cellStyle);
        titleSize = titleSize + 3;
        for (int i = 0; i < VoltageList.size(); i++) {
            GeneralVO vo = VoltageList.get(i);

            xdata2.add(vo.getName());
            online2.add(vo.getOnLine());
            offline2.add(vo.getOffLine());

            up2.add(vo.getUpCount());
            sag2.add(vo.getSagsCount());
            break2.add(vo.getBreakCount());

            HSSFRow row = sheetAt.createRow(titleSize + i);
            HSSFCell cell0 = row.createCell(0);
            HSSFCell cell1 = row.createCell(1);
            HSSFCell cell2 = row.createCell(2);
            HSSFCell cell3 = row.createCell(3);
            HSSFCell cell4 = row.createCell(4);
            HSSFCell cell5 = row.createCell(5);

            cell0.setCellStyle(bodyStyle);
            cell1.setCellStyle(bodyStyle);
            cell2.setCellStyle(bodyStyle);
            cell3.setCellStyle(bodyStyle);
            cell4.setCellStyle(bodyStyle);
            cell5.setCellStyle(bodyStyle);

            cell0.setCellValue(vo.getName());
            cell1.setCellValue(vo.getOnLine());
            cell2.setCellValue(vo.getOffLine());
            cell3.setCellValue(vo.getSagsCount());
            cell4.setCellValue(vo.getBreakCount());
            cell5.setCellValue(vo.getUpCount());
        }

        String str1 = drawPicUtil.drawEventRegionDevice(xdata, online, offline, "区域统计", "(区域)");

        String str2 = drawPicUtil.drawEventRegionDevice(xdata2, online2, offline2, "电压等级统计", "(电压等级)");

        String str3 = drawPicUtil.drawEventFrequency(xdata, sag1, break1, up1, "区域等级", "(区域)");

        String str4 = drawPicUtil.drawEventFrequency(xdata2, sag2, break2, up2, "电压等级统计", "(电压等级)");

        HSSFPatriarch drawingPatriarch = sheetAt.createDrawingPatriarch();
        //区域信息
        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, (short) 6, (short) 0, (short) 15, (short) 14);
        //电压信息
        HSSFClientAnchor anchor1 = new HSSFClientAnchor(0, 0, 0, 0, (short) 6, (short) 14, (short) 15, (short) 30);
        //区域次数
        HSSFClientAnchor anchor2 = new HSSFClientAnchor(0, 0, 0, 0, (short) 6, (short) 31, (short) 15, (short) 45);
        //电压等级次数
        HSSFClientAnchor anchor3 = new HSSFClientAnchor(0, 0, 0, 0, (short) 6, (short) 46, (short) 15, (short) 60);

        anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
        anchor1.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
        anchor2.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);
        anchor3.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE);

        drawingPatriarch.createPicture(anchor, addPicture(str1, sheets));
        drawingPatriarch.createPicture(anchor1, addPicture(str2, sheets));
        drawingPatriarch.createPicture(anchor2, addPicture(str3, sheets));
        drawingPatriarch.createPicture(anchor3, addPicture(str4, sheets));
        return sheets;
    }

    public Integer addPicture(String str, HSSFWorkbook sheets) throws IOException {
        BASE64Decoder decoder = new BASE64Decoder();
        if (str.contains(PicCommonData.PNG_PREFIX)) {
            str = str.replace(PicCommonData.PNG_PREFIX, "");
        }
        byte[] bytes = decoder.decodeBuffer(str);
        return sheets.addPicture(bytes, HSSFWorkbook.PICTURE_TYPE_PNG);
    }

    public void sheet2(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
        sheets.createSheet("暂态严重度统计");
        HSSFSheet sheetAt = sheets.getSheetAt(2);
        sheetAt.setColumnWidth(0, 24 * 256);
        sheetAt.setColumnWidth(1, 24 * 256);
        sheetAt.setColumnWidth(2, 24 * 256);
        sheetAt.setColumnWidth(3, 44 * 256);
        sheetAt.setColumnWidth(4, 24 * 256);
        sheetAt.setColumnWidth(5, 24 * 256);
        sheetAt.setColumnWidth(6, 24 * 256);
        sheetAt.setColumnWidth(7, 24 * 256);
        sheetAt.setColumnWidth(8, 24 * 256);
        sheetAt.setColumnWidth(9, 24 * 256);
        sheetAt.addMergedRegion(new CellRangeAddress(0, 0, 0, 10));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 3, 3));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 4, 4));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 5, 5));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 6, 6));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 7, 7));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 8, 8));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 9, 9));

        HSSFRow title = sheetAt.createRow(0);
        HSSFRow row1 = sheetAt.createRow(1);


        HSSFCell titleCell = title.createCell(0);
        setCellStyle(titleCell, "暂态事件严重度(前二十)", cellStyle);
        HSSFCell r1Cell0 = row1.createCell(0);
        HSSFCell r1Cell1 = row1.createCell(1);
        HSSFCell r1Cell2 = row1.createCell(2);
        HSSFCell r1Cell3 = row1.createCell(3);
        HSSFCell r1Cell4 = row1.createCell(4);
        HSSFCell r1Cell5 = row1.createCell(5);
        HSSFCell r1Cell6 = row1.createCell(6);
        HSSFCell r1Cell7 = row1.createCell(7);
        HSSFCell r1Cell8 = row1.createCell(8);
        HSSFCell r1Cell9 = row1.createCell(9);
        setCellStyle(r1Cell0, "序号", cellStyle);
        setCellStyle(r1Cell1, "暂态事件发生时刻", cellStyle);
        setCellStyle(r1Cell2, "供电公司", cellStyle);
        setCellStyle(r1Cell3, "变电站", cellStyle);
        setCellStyle(r1Cell4, "监测点", cellStyle);
        setCellStyle(r1Cell5, "监测点电压等级", cellStyle);
        setCellStyle(r1Cell6, "干扰源类型", cellStyle);
        setCellStyle(r1Cell7, "暂降(骤升)幅值(%)", cellStyle);
        setCellStyle(r1Cell8, "持续时间(s)", cellStyle);
        setCellStyle(r1Cell9, "暂态事件严重度", cellStyle);
        List<WaveTypeVO> severity = getSeverity(businessParam);
        for (int i = 0; i < severity.size(); i++) {
            WaveTypeVO vo = severity.get(i);

            HSSFRow row = sheetAt.createRow(i + 3);
            HSSFCell cell0 = row.createCell(0);
            HSSFCell cell1 = row.createCell(1);
            HSSFCell cell2 = row.createCell(2);
            HSSFCell cell3 = row.createCell(3);
            HSSFCell cell4 = row.createCell(4);
            HSSFCell cell5 = row.createCell(5);
            HSSFCell cell6 = row.createCell(6);
            HSSFCell cell7 = row.createCell(7);
            HSSFCell cell8 = row.createCell(8);
            HSSFCell cell9 = row.createCell(9);

            cell0.setCellStyle(bodyStyle);
            cell1.setCellStyle(bodyStyle);
            cell2.setCellStyle(bodyStyle);
            cell3.setCellStyle(bodyStyle);
            cell4.setCellStyle(bodyStyle);
            cell5.setCellStyle(bodyStyle);
            cell6.setCellStyle(bodyStyle);
            cell7.setCellStyle(bodyStyle);
            cell8.setCellStyle(bodyStyle);
            cell9.setCellStyle(bodyStyle);

            cell0.setCellValue(i + 1);
            cell1.setCellValue(LocalDateTimeUtil.format(vo.getStartTime(),DatePattern.NORM_DATETIME_MS_PATTERN));
            cell2.setCellValue(vo.getGdName());
            cell3.setCellValue(vo.getSubName());
            cell4.setCellValue(vo.getLineName());
            cell5.setCellValue(vo.getVoltageScale());
            cell6.setCellValue(vo.getLoadType());
            cell7.setCellValue(vo.getFeatureAmplitude() * 100);
            cell8.setCellValue(vo.getDuration());
            cell9.setCellValue(BigDecimal.valueOf(vo.getSeverity()).setScale(2, RoundingMode.HALF_UP).doubleValue());
        }

    }

    public void sheet3(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException {
        sheets.createSheet("暂态原因统计");
        HSSFSheet sheetAt = sheets.getSheetAt(1);
        sheetAt.setColumnWidth(0, 40 * 256);
        sheetAt.setColumnWidth(1, 40 * 256);
        sheetAt.setColumnWidth(2, 40 * 256);
        sheetAt.setColumnWidth(3, 40 * 256);
        sheetAt.setColumnWidth(4, 40 * 256);
        sheetAt.setColumnWidth(5, 40 * 256);
        sheetAt.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 2, 2));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 3, 3));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 4, 4));
        sheetAt.addMergedRegion(new CellRangeAddress(1, 2, 5, 5));

        HSSFRow title = sheetAt.createRow(0);
        HSSFRow row1 = sheetAt.createRow(1);


        HSSFCell titleCell = title.createCell(0);
        setCellStyle(titleCell, "暂态原因统计表", cellStyle);
        HSSFCell r1Cell0 = row1.createCell(0);
        HSSFCell r1Cell1 = row1.createCell(1);
        HSSFCell r1Cell2 = row1.createCell(2);
        HSSFCell r1Cell3 = row1.createCell(3);
        HSSFCell r1Cell4 = row1.createCell(4);
        HSSFCell r1Cell5 = row1.createCell(5);
        setCellStyle(r1Cell0, "暂态原因", cellStyle);
        setCellStyle(r1Cell1, "短路故障", cellStyle);
        setCellStyle(r1Cell2, "变压器激磁", cellStyle);
        setCellStyle(r1Cell3, "电压扰动", cellStyle);
        setCellStyle(r1Cell4, "大型感应电动机启动", cellStyle);
        setCellStyle(r1Cell5, "其他", cellStyle);

        List<ReasonsVO> reason = getReason(businessParam);
        HSSFRow row = sheetAt.createRow(3);
        HSSFCell cell0 = row.createCell(0);
        cell0.setCellValue("次数");
        cell0.setCellStyle(bodyStyle);

        HSSFRow row2 = sheetAt.createRow(4);
        HSSFCell cellR0 = row2.createCell(0);
        cellR0.setCellValue("占比(%)");
        cellR0.setCellStyle(bodyStyle);

        for (ReasonsVO reasonsVO : reason) {
            if (ObjectUtil.equals(reasonsVO.getReason(), "短路故障")) {
                HSSFCell cell1 = row.createCell(1);
                HSSFCell cellR1 = row2.createCell(1);
                cell1.setCellStyle(bodyStyle);
                cellR1.setCellStyle(bodyStyle);
                cell1.setCellValue(reasonsVO.getTimes());
                cellR1.setCellValue(reasonsVO.getRate());
            }
            if (ObjectUtil.equals(reasonsVO.getReason(), "变压器激磁")) {
                HSSFCell cell1 = row.createCell(2);
                HSSFCell cellR1 = row2.createCell(2);
                cell1.setCellStyle(bodyStyle);
                cellR1.setCellStyle(bodyStyle);
                cell1.setCellValue(reasonsVO.getTimes());
                cellR1.setCellValue(reasonsVO.getRate());
            }
            if (ObjectUtil.equals(reasonsVO.getReason(), "电压扰动")) {
                HSSFCell cell1 = row.createCell(3);
                HSSFCell cellR1 = row2.createCell(3);
                cell1.setCellStyle(bodyStyle);
                cellR1.setCellStyle(bodyStyle);
                cell1.setCellValue(reasonsVO.getTimes());
                cellR1.setCellValue(reasonsVO.getRate());
            }
            if (ObjectUtil.equals(reasonsVO.getReason(), "大型感应电动机启动")) {
                HSSFCell cell1 = row.createCell(4);
                HSSFCell cellR1 = row2.createCell(4);
                cell1.setCellStyle(bodyStyle);
                cellR1.setCellStyle(bodyStyle);
                cell1.setCellValue(reasonsVO.getTimes());
                cellR1.setCellValue(reasonsVO.getRate());
            }
            if (ObjectUtil.equals(reasonsVO.getReason(), "其他")) {
                HSSFCell cell1 = row.createCell(5);
                HSSFCell cellR1 = row2.createCell(5);
                cell1.setCellStyle(bodyStyle);
                cellR1.setCellStyle(bodyStyle);
                cell1.setCellValue(reasonsVO.getTimes());
                cellR1.setCellValue(reasonsVO.getRate());
            }
        }
        HSSFPatriarch drawingPatriarch = sheetAt.createDrawingPatriarch();

        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 10, 10, 6, (short) 0.5, (short) 6, (short) 6, (short) 36);


        List<String> xdata = new ArrayList<>();
        List<Map<String, Object>> reasonList = new ArrayList<>();


        for (ReasonsVO reasonsVO : reason) {
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("value", reasonsVO.getTimes());
            map.put("name", reasonsVO.getReason());
            reasonList.add(map);
            xdata.add(reasonsVO.getReason());
        }
        String tr = drawPicUtil.drawReason(xdata, reasonList);
        drawingPatriarch.createPicture(anchor, addPicture(tr, sheets));
    }

    public void sheet4(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
        sheets.createSheet("暂降事件列表");
        HSSFSheet sheetAt = sheets.getSheetAt(3);
        sheetAt.setColumnWidth(0, 24 * 256);
        sheetAt.setColumnWidth(1, 24 * 256);
        sheetAt.setColumnWidth(2, 24 * 256);
        sheetAt.setColumnWidth(3, 44 * 256);
        sheetAt.setColumnWidth(4, 24 * 256);
        sheetAt.setColumnWidth(5, 24 * 256);
        sheetAt.setColumnWidth(6, 24 * 256);
        sheetAt.setColumnWidth(7, 50 * 256);
        sheetAt.setColumnWidth(8, 24 * 256);
        sheetAt.setColumnWidth(9, 24 * 256);
        sheetAt.setColumnWidth(10, 24 * 256);
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 6, 6));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 7, 7));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 8, 8));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 9, 9));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 10, 10));

        HSSFRow row1 = sheetAt.createRow(0);


        HSSFCell r1Cell0 = row1.createCell(0);
        HSSFCell r1Cell1 = row1.createCell(1);
        HSSFCell r1Cell2 = row1.createCell(2);
        HSSFCell r1Cell3 = row1.createCell(3);
        HSSFCell r1Cell4 = row1.createCell(4);
        HSSFCell r1Cell5 = row1.createCell(5);
        HSSFCell r1Cell6 = row1.createCell(6);
        HSSFCell r1Cell7 = row1.createCell(7);
        HSSFCell r1Cell8 = row1.createCell(8);
        HSSFCell r1Cell9 = row1.createCell(9);
        HSSFCell r1Cell10 = row1.createCell(10);
        setCellStyle(r1Cell0, "序号", cellStyle);
        setCellStyle(r1Cell1, "暂态事件发生时刻", cellStyle);
        setCellStyle(r1Cell2, "供电公司", cellStyle);
        setCellStyle(r1Cell3, "变电站", cellStyle);
        setCellStyle(r1Cell4, "监测点", cellStyle);
        setCellStyle(r1Cell5, "监测点电压等级", cellStyle);
        setCellStyle(r1Cell6, "干扰源类型", cellStyle);
        setCellStyle(r1Cell7, "监测点对象名称", cellStyle);
        setCellStyle(r1Cell8, "暂降(骤升)幅值(%)", cellStyle);
        setCellStyle(r1Cell9, "持续时间(s)", cellStyle);
        setCellStyle(r1Cell10, "暂态类型(机器判断)", cellStyle);
        List<DetailVO> severity = sheetDetailed(businessParam);
        for (int i = 0; i < severity.size(); i++) {
            DetailVO vo = severity.get(i);

            HSSFRow row = sheetAt.createRow(i + 2);
            HSSFCell cell0 = row.createCell(0);
            HSSFCell cell1 = row.createCell(1);
            HSSFCell cell2 = row.createCell(2);
            HSSFCell cell3 = row.createCell(3);
            HSSFCell cell4 = row.createCell(4);
            HSSFCell cell5 = row.createCell(5);
            HSSFCell cell6 = row.createCell(6);
            HSSFCell cell7 = row.createCell(7);
            HSSFCell cell8 = row.createCell(8);
            HSSFCell cell9 = row.createCell(9);
            HSSFCell cell10 = row.createCell(10);

            cell0.setCellStyle(bodyStyle);
            cell1.setCellStyle(bodyStyle);
            cell2.setCellStyle(bodyStyle);
            cell3.setCellStyle(bodyStyle);
            cell4.setCellStyle(bodyStyle);
            cell5.setCellStyle(bodyStyle);
            cell6.setCellStyle(bodyStyle);
            cell7.setCellStyle(bodyStyle);
            cell8.setCellStyle(bodyStyle);
            cell9.setCellStyle(bodyStyle);
            cell10.setCellStyle(bodyStyle);

            cell0.setCellValue(i + 1);
            cell1.setCellValue(vo.getStartTime());
            cell2.setCellValue(vo.getGdName());
            cell3.setCellValue(vo.getSubName());
            cell4.setCellValue(vo.getLineName());
            cell5.setCellValue(vo.getVoltageScale());
            cell6.setCellValue(vo.getLoadType());
            cell7.setCellValue(vo.getObjName() == null || vo.getObjName() == "" ? "/" : vo.getObjName());
            cell8.setCellValue(vo.getFeatureAmplitude() * 100);
            cell9.setCellValue(vo.getDuration());
            cell10.setCellValue(vo.getAdvanceType());
        }

    }

    public void sheet5(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
        sheets.createSheet("暂降次数统计");
        HSSFSheet sheetAt = sheets.getSheetAt(4);
        sheetAt.setColumnWidth(0, 24 * 256);
        sheetAt.setColumnWidth(1, 30 * 256);
        sheetAt.setColumnWidth(2, 24 * 256);
        sheetAt.setColumnWidth(3, 50 * 256);
        sheetAt.setColumnWidth(4, 44 * 256);
        sheetAt.setColumnWidth(5, 24 * 256);
        sheetAt.setColumnWidth(6, 24 * 256);
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 6, 6));

        HSSFRow row1 = sheetAt.createRow(0);


        HSSFCell r1Cell0 = row1.createCell(0);
        HSSFCell r1Cell1 = row1.createCell(1);
        HSSFCell r1Cell2 = row1.createCell(2);
        HSSFCell r1Cell3 = row1.createCell(3);
        HSSFCell r1Cell4 = row1.createCell(4);
        HSSFCell r1Cell5 = row1.createCell(5);
        HSSFCell r1Cell6 = row1.createCell(6);
        setCellStyle(r1Cell0, "序号", cellStyle);
        setCellStyle(r1Cell1, "监测点", cellStyle);
        setCellStyle(r1Cell2, "干扰源类型", cellStyle);
        setCellStyle(r1Cell3, "监测点对象名称", cellStyle);
        setCellStyle(r1Cell4, "变电站", cellStyle);
        setCellStyle(r1Cell5, "供电公司", cellStyle);
        setCellStyle(r1Cell6, "暂降次数", cellStyle);
        DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
        List<DetailVO> severity = sheetList(businessParam, dictdata.getId());
        for (int i = 0; i < severity.size(); i++) {
            DetailVO vo = severity.get(i);

            HSSFRow row = sheetAt.createRow(i + 2);
            HSSFCell cell0 = row.createCell(0);
            HSSFCell cell1 = row.createCell(1);
            HSSFCell cell2 = row.createCell(2);
            HSSFCell cell3 = row.createCell(3);
            HSSFCell cell4 = row.createCell(4);
            HSSFCell cell5 = row.createCell(5);
            HSSFCell cell6 = row.createCell(6);

            cell0.setCellStyle(bodyStyle);
            cell1.setCellStyle(bodyStyle);
            cell2.setCellStyle(bodyStyle);
            cell3.setCellStyle(bodyStyle);
            cell4.setCellStyle(bodyStyle);
            cell5.setCellStyle(bodyStyle);
            cell6.setCellStyle(bodyStyle);

            cell0.setCellValue(i + 1);
            cell1.setCellValue(vo.getLineName());
            cell2.setCellValue(vo.getLoadType());
            cell3.setCellValue(vo.getObjName() == null || vo.getObjName() == "" ? "/" : vo.getObjName());
            cell4.setCellValue(vo.getSubName());
            cell5.setCellValue(vo.getGdName());
            cell6.setCellValue(vo.getTimes());
        }

    }

    public void sheet6(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
        sheets.createSheet("暂升次数统计");
        HSSFSheet sheetAt = sheets.getSheetAt(5);
        sheetAt.setColumnWidth(0, 24 * 256);
        sheetAt.setColumnWidth(1, 30 * 256);
        sheetAt.setColumnWidth(2, 24 * 256);
        sheetAt.setColumnWidth(3, 50 * 256);
        sheetAt.setColumnWidth(4, 44 * 256);
        sheetAt.setColumnWidth(5, 24 * 256);
        sheetAt.setColumnWidth(6, 24 * 256);
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 6, 6));

        HSSFRow row1 = sheetAt.createRow(0);


        HSSFCell r1Cell0 = row1.createCell(0);
        HSSFCell r1Cell1 = row1.createCell(1);
        HSSFCell r1Cell2 = row1.createCell(2);
        HSSFCell r1Cell3 = row1.createCell(3);
        HSSFCell r1Cell4 = row1.createCell(4);
        HSSFCell r1Cell5 = row1.createCell(5);
        HSSFCell r1Cell6 = row1.createCell(6);
        setCellStyle(r1Cell0, "序号", cellStyle);
        setCellStyle(r1Cell1, "监测点", cellStyle);
        setCellStyle(r1Cell2, "干扰源类型", cellStyle);
        setCellStyle(r1Cell3, "监测点对象名称", cellStyle);
        setCellStyle(r1Cell4, "变电站", cellStyle);
        setCellStyle(r1Cell5, "供电公司", cellStyle);
        setCellStyle(r1Cell6, "暂升次数", cellStyle);
        DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
        List<DetailVO> severity = sheetList(businessParam, dictdata.getId());
        for (int i = 0; i < severity.size(); i++) {
            DetailVO vo = severity.get(i);

            HSSFRow row = sheetAt.createRow(i + 2);
            HSSFCell cell0 = row.createCell(0);
            HSSFCell cell1 = row.createCell(1);
            HSSFCell cell2 = row.createCell(2);
            HSSFCell cell3 = row.createCell(3);
            HSSFCell cell4 = row.createCell(4);
            HSSFCell cell5 = row.createCell(5);
            HSSFCell cell6 = row.createCell(6);

            cell0.setCellStyle(bodyStyle);
            cell1.setCellStyle(bodyStyle);
            cell2.setCellStyle(bodyStyle);
            cell3.setCellStyle(bodyStyle);
            cell4.setCellStyle(bodyStyle);
            cell5.setCellStyle(bodyStyle);
            cell6.setCellStyle(bodyStyle);

            cell0.setCellValue(i + 1);
            cell1.setCellValue(vo.getLineName());
            cell2.setCellValue(vo.getLoadType());
            cell3.setCellValue(vo.getObjName() == null || vo.getObjName() == "" ? "/" : vo.getObjName());
            cell4.setCellValue(vo.getSubName());
            cell5.setCellValue(vo.getGdName());
            cell6.setCellValue(vo.getTimes());
        }

    }

    public void sheet7(HSSFWorkbook sheets, HSSFCellStyle cellStyle, HSSFCellStyle bodyStyle, DeviceInfoParam.BusinessParam businessParam) {
        sheets.createSheet("短时中断次数统计");
        HSSFSheet sheetAt = sheets.getSheetAt(6);
        sheetAt.setColumnWidth(0, 24 * 256);
        sheetAt.setColumnWidth(1, 30 * 256);
        sheetAt.setColumnWidth(2, 24 * 256);
        sheetAt.setColumnWidth(3, 50 * 256);
        sheetAt.setColumnWidth(4, 44 * 256);
        sheetAt.setColumnWidth(5, 24 * 256);
        sheetAt.setColumnWidth(6, 24 * 256);
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
        sheetAt.addMergedRegion(new CellRangeAddress(0, 1, 6, 6));

        HSSFRow row1 = sheetAt.createRow(0);


        HSSFCell r1Cell0 = row1.createCell(0);
        HSSFCell r1Cell1 = row1.createCell(1);
        HSSFCell r1Cell2 = row1.createCell(2);
        HSSFCell r1Cell3 = row1.createCell(3);
        HSSFCell r1Cell4 = row1.createCell(4);
        HSSFCell r1Cell5 = row1.createCell(5);
        HSSFCell r1Cell6 = row1.createCell(6);
        setCellStyle(r1Cell0, "序号", cellStyle);
        setCellStyle(r1Cell1, "监测点", cellStyle);
        setCellStyle(r1Cell2, "干扰源类型", cellStyle);
        setCellStyle(r1Cell3, "监测点对象名称", cellStyle);
        setCellStyle(r1Cell4, "变电站", cellStyle);
        setCellStyle(r1Cell5, "供电公司", cellStyle);
        setCellStyle(r1Cell6, "短时中断次数", cellStyle);
        DictData dictdata = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
        List<DetailVO> severity = sheetList(businessParam, dictdata.getId());
        for (int i = 0; i < severity.size(); i++) {
            DetailVO vo = severity.get(i);

            HSSFRow row = sheetAt.createRow(i + 2);
            HSSFCell cell0 = row.createCell(0);
            HSSFCell cell1 = row.createCell(1);
            HSSFCell cell2 = row.createCell(2);
            HSSFCell cell3 = row.createCell(3);
            HSSFCell cell4 = row.createCell(4);
            HSSFCell cell5 = row.createCell(5);
            HSSFCell cell6 = row.createCell(6);

            cell0.setCellStyle(bodyStyle);
            cell1.setCellStyle(bodyStyle);
            cell2.setCellStyle(bodyStyle);
            cell3.setCellStyle(bodyStyle);
            cell4.setCellStyle(bodyStyle);
            cell5.setCellStyle(bodyStyle);
            cell6.setCellStyle(bodyStyle);

            cell0.setCellValue(i + 1);
            cell1.setCellValue(vo.getLineName());
            cell2.setCellValue(vo.getLoadType());
            cell3.setCellValue(vo.getObjName() == null || vo.getObjName() == "" ? "/" : vo.getObjName());
            cell4.setCellValue(vo.getSubName());
            cell5.setCellValue(vo.getGdName());
            cell6.setCellValue(vo.getTimes());
        }

    }

    private List<DetailVO> sheetList(DeviceInfoParam.BusinessParam businessParam, String id) {
        List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
        List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
        if (CollectionUtil.isEmpty(lineIds)) {
            throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
        }
        List<DetailVO> listCount = reportMapper.getListCount(lineIds, businessParam.getSearchBeginTime(), businessParam.getSearchEndTime(), id);

        ArrayList<String> idlist = new ArrayList<>();
        for (DetailVO vo : listCount) {
            idlist.add(vo.getLineId());
        }
        if (CollUtil.isNotEmpty(idlist)) {
            HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
            List<AreaLineInfoVO> data = AreaInfo.getData();
            for (DetailVO v : listCount) {
                for (AreaLineInfoVO vo : data) {
                    if (vo.getLineId().equals(v.getLineId())) {
                        BeanUtils.copyProperties(vo, v);
                    }
                }
            }
        }
        return listCount;
    }


    /**
     * sheet 详细数据列表
     */
    private List<DetailVO> sheetDetailed(DeviceInfoParam.BusinessParam businessParam) {
        //获取暂降字典信息
        DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
        if (ObjectUtil.isNull(voltageData)) {
            throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
        }
        List<DetailVO> result = new ArrayList<>();
        //pq系统
        List<GeneralDeviceDTO> deviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(businessParam).getData();
        List<String> lineIds = deviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
        if (CollectionUtil.isEmpty(lineIds)) {
            throw new BusinessException(DeviceResponseEnum.DEPT_LINE_EMPTY);
        }
        List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
                .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
                .eq(StrUtil.isNotBlank(voltageData.getId()), RmpEventDetailPO::getEventType, voltageData.getId())
                .ge(StringUtils.isNotBlank(businessParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(businessParam.getSearchBeginTime())))
                .le(StringUtils.isNotBlank(businessParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(businessParam.getSearchEndTime())))
                .orderByDesc(RmpEventDetailPO::getStartTime)
        );
        if (CollectionUtil.isNotEmpty(info)) {
            ArrayList<String> idlist = new ArrayList<>();
            for (RmpEventDetailPO eventDetail : info) {
                DetailVO vo = new DetailVO();
                vo.setStartTime(eventDetail.getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN)));
                BeanUtils.copyProperties(eventDetail, vo);
                result.add(vo);
                idlist.add(eventDetail.getLineId());
            }
            if (CollUtil.isNotEmpty(idlist)) {
                //pq系统
                HttpResult<List<AreaLineInfoVO>> AreaInfo = lineFeignClient.getBaseLineAreaInfo(idlist);
                List<AreaLineInfoVO> data = AreaInfo.getData();
                for (DetailVO detailVO : result) {
                    for (AreaLineInfoVO vo : data) {
                        if (vo.getLineId().equals(detailVO.getLineId())) {
                            BeanUtils.copyProperties(vo, detailVO);
                        }
                    }
                }
                HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
                List<DictData> type = reason.getData();
                for (DetailVO detailVO : result) {
                    for (DictData dictData : type) {
                        if (dictData.getId().equals(detailVO.getAdvanceType())) {
                            detailVO.setAdvanceType(dictData.getName());
                        }
                    }
                }
            }
        }
        return result;
    }

    /**
     * 创建标题
     *
     * @param document 文档
     * @param message  标题内容
     * @param style    标题等级
     * @param line     缩进
     * @param fontSize 字体大小
     */
    public void createTitle(XWPFDocument document, String message, String style, int line, int fontSize) {
        XWPFParagraph summaeTableParagraph = WordUtils.getLeftParagraph(document);
        summaeTableParagraph.setStyle(style);
        summaeTableParagraph.setIndentationFirstLine(line);
        XWPFRun summaeTableRun = summaeTableParagraph.createRun();
        WordUtils.addParagraph(summaeTableRun, "宋体", fontSize, "000000", message, false);
    }

    /**
     * 监测点导出word
     *
     * @param exportParam .
     * @param response    .
     * @throws InvalidFormatException .
     * @throws IOException            .
     */
    @Override
    public void getLineExport(ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException {
        //创建word文档(poi生成word)
        XWPFDocument doc = new XWPFDocument(); //创建Word文件
        //设置标题样式
        WordUtils.setHeadingStyle(doc);
        XWPFParagraph p = doc.createParagraph(); //新建一个段落
        //设置对齐
        p.setAlignment(ParagraphAlignment.CENTER);
        p.setVerticalAlignment(TextAlignment.CENTER);
        XWPFRun r = p.createRun();//创建段落文本
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.setText("");
        r.setBold(true);//设置为粗体
        r.setFontSize(14);//字体大小
        r.addBreak();

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r1 = p.createRun();//创建段落文本
        r1.setText("电压暂降事件分析报告");
        r1.setBold(true);//设置为粗体
        r1.setFontSize(36);//字体大小
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r2 = p.createRun();//创建段落文本
        //获取当前时间
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日");
        String time = dateFormat.format(date);

        r2.setText("日期: " + time);
        r2.setBold(true);//设置为粗体
        r2.setFontSize(14);//字体大小

        r2.addBreak();
        r2.addBreak();
        r2.addBreak();

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r3 = p.createRun();//创建段落文本
        r3.setText("电压暂降事件区域报告");
        r3.setFontSize(24);//字体大小

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.LEFT);
        createTitle(doc, "1. 引言", "标题 1", 0, 15);

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r5 = p.createRun();//创建段落文本
        r5.setText("对所选中区间内电压暂降事件进行分析，能够直观清晰查看响应的暂降事件信息。");
        r5.setFontSize(11);//字体大小

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.LEFT);
        createTitle(doc, "2. 报告分析对象", "标题 1", 0, 15);

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r7 = p.createRun();//创建段落文本
        r7.setText(exportParam.getLineName());
        r7.setFontSize(11);//字体大小

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.LEFT);
        createTitle(doc, "3. 报告分析时间", "标题 1", 0, 15);

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r9 = p.createRun();//创建段落文本
        r9.setText(exportParam.getSearchBeginTime() + " 至 " + exportParam.getSearchEndTime());
        r9.setFontSize(11);//字体大小

        p = doc.createParagraph(); //新建一个段落
        p.setAlignment(ParagraphAlignment.LEFT);
        createTitle(doc, "4. 总汇信息", "标题 1", 0, 15);

        //查询参数
        StatisticsParam param = new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(), exportParam.getFlag(),null);
        //获取暂降原因字典
        List<DictData> reasonData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
        //获取暂降类型字典
        List<DictData> typeData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
        //influxdb查询结果（pqs_eventdetail表）
        List<EventDetail> info = info(param);

        //记录数
        int i = 1;
        //1.监测点信息
        if (exportParam.isXq()) {
            createTitle(doc, "4." + i + " 监测点信息", "标题 2", 200, 15);
            XWPFTable table = createTable(doc);
            XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
            if (exportParam.getType() == 0) {
                HttpResult<LineDetailDataVO> lineDetailData = lineFeignClient.getLineDetailData(exportParam.getLineId());
                if (ObjectUtil.isNull(lineDetailData)) {
                    throw new BusinessException(EventResponseEnum.NOT_FOUND);
                }
                insertRow(doc, table, centerParagraph, true, "项目", "描述");
                insertRow(doc, table, centerParagraph, false, "监测点名称", lineDetailData.getData().getLineName());
                insertRow(doc, table, centerParagraph, false, "电压等级", lineDetailData.getData().getScale());
                insertRow(doc, table, centerParagraph, false, "PT变比", lineDetailData.getData().getPt());
                insertRow(doc, table, centerParagraph, false, "CT变比", lineDetailData.getData().getCt());
                insertRow(doc, table, centerParagraph, false, "协议容量", lineDetailData.getData().getDealCapacity() + "");
                insertRow(doc, table, centerParagraph, false, "基准容量", lineDetailData.getData().getStandardCapacity() + "");
                insertRow(doc, table, centerParagraph, false, "设备容量", lineDetailData.getData().getDevCapacity() + "");
                insertRow(doc, table, centerParagraph, false, "最小短路容量", lineDetailData.getData().getShortCapacity() + "");
                insertRow(doc, table, centerParagraph, false, "接线方式", lineDetailData.getData().getPtType());
            } else {
                HttpResult<List<Monitor>> monitorList = monitorClient.getMonitorList(Arrays.asList(exportParam.getLineId()));
                if (ObjectUtil.isNull(monitorList)) {
                    throw new BusinessException(EventResponseEnum.NOT_FOUND);
                }
                insertRow(doc, table, centerParagraph, true, "项目", "描述");
                insertRow(doc, table, centerParagraph, false, "监测点名称", monitorList.getData().get(0).getName());
                insertRow(doc, table, centerParagraph, false, "电压等级", dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getVoltageLevel()).getData().getName());
                insertRow(doc, table, centerParagraph, false, "PT变比", monitorList.getData().get(0).getPt1() + "/" + monitorList.getData().get(0).getPt2());
                insertRow(doc, table, centerParagraph, false, "CT变比", monitorList.getData().get(0).getCt1() + "/" + monitorList.getData().get(0).getCt2());
                insertRow(doc, table, centerParagraph, false, "协议容量", monitorList.getData().get(0).getUserAgreementCapacity() + "");
//                insertRow(doc, table, centerParagraph, false, "基准容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
                insertRow(doc, table, centerParagraph, false, "设备容量", monitorList.getData().get(0).getPowerSupplyEqCapacity() + "");
                insertRow(doc, table, centerParagraph, false, "最小短路容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
                insertRow(doc, table, centerParagraph, false, "接线方式", dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getTerminalWiringMethod()).getData().getName());
            }
            i++;
        }
        //2.暂降事件暂降事件列表和暂降点图
        //2.1.判断列表和点图是否是要导出
        if (exportParam.isLb() || exportParam.isSjdF47() || exportParam.isSjdITIC()) {
//            List<EventDetail> plot = eventAnalysisService.getPlot(param);
            List<EventDetail> plot = eventReportService.getPlot(info, reasonData, typeData);
            //暂降事件列表
            if (exportParam.isLb()) {
                createTitle(doc, "4." + i + " 暂降事件列表", "标题 2", 200, 15);
                XWPFTable table = createTable(doc);
                XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
                insertRow(doc, table, centerParagraph, true, "序号", "暂降发生时刻", "暂降幅值(%)", "持续时间(s)", "暂降类型", "暂降原因", "严重度");
                for (int j = 0; j < plot.size(); j++) {
                    EventDetail eventDetail = plot.get(j);
                    String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));

                    insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
                }
                i++;
            }
            //暂降事件点图
            if (exportParam.isSjdF47() || exportParam.isSjdITIC()) {
                ArrayList<List<Double>> ass = getAss(plot);
                createTitle(doc, "4." + i + " 暂降事件点图", "标题 2", 200, 15);
                int two = 1;
                if (exportParam.isSjdITIC()) {
                    createTitle(doc, "4." + i + "." + two + " ITIC 曲线", "标题 3", 400, 15);
                    String itic = drawPicUtil.drawItic(ass);
                    createPic(doc, itic, "ITIC曲线");
                    two++;
                }
                if (exportParam.isSjdF47()) {
                    createTitle(doc, "4." + i + "." + two + " F47 曲线", "标题 3", 400, 15);
                    String f47 = drawPicUtil.drawF47(ass);
                    createPic(doc, f47, "SEMI F47曲线");
                    two++;
                }
                i++;
            }
        }


        //3.暂降密度
        if (exportParam.isMdbg() || exportParam.isMdtx()) {
            createTitle(doc, "4." + i + " 暂降密度", "标题 2", 200, 15);
            int two = 1;
            if (exportParam.isMdtx()) {
                createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
                Integer[][] eventDensityData = eventReportService.getCoords(info);
                String str = drawPicUtil.drawEventDensity(eventDensityData);
                createPic(doc, str, "暂降密度图");
                two++;
            }
            if (exportParam.isMdbg()) {
                XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
                createTitle(doc, "4." + i + "." + two + " DISDIP 表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 15);
//                List<DISDIPVO> eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
                List<DISDIPVO> eventDisdip = eventReportService.eventDisdip(info);

                XWPFTable table1 = createTable(doc);
                insertRow(doc, table1, centerParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s");
                for (int j = 0; j < eventDisdip.size(); j++) {
                    DISDIPVO disdipvo = eventDisdip.get(j);
                    insertRow(doc, table1, centerParagraph, false, disdipvo.getName(), disdipvo.getTwentyMs(), disdipvo.getOneHundredMs(), disdipvo.getFiveHundredMs(), disdipvo.getOneS(), disdipvo.getThreeS(), disdipvo.getTwentyS(), disdipvo.getSixtyS(), disdipvo.getOneEightyS());
                }
                two++;
                createTitle(doc, "4." + i + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 15);
//                List<IEC411VO> iec411VOS = eventAnalysisService.IEC411(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
                List<IEC411VO> iec411VOS = eventReportService.IEC411(info);
                XWPFTable table2 = createTable(doc);
                insertRow(doc, table2, centerParagraph, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");
                for (int j = 0; j < iec411VOS.size(); j++) {
                    IEC411VO iec411VO = iec411VOS.get(j);
                    insertRow(doc, table2, centerParagraph, false, iec411VO.getName(), iec411VO.getTenTwentyMs(), iec411VO.getTwentyOneHundredMs(), iec411VO.getZeroPiontOneTwoS(), iec411VO.getZeroPiontTwoFiveS(), iec411VO.getZeroPiontFive1S(), iec411VO.getGreater1S());
                }
                two++;
                createTitle(doc, "4." + i + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 15);
//                List<IEC28VO> iec28VOS = eventAnalysisService.IEC28(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
                List<IEC28VO> iec28VOS = eventReportService.IEC28(info);
                XWPFTable table3 = createTable(doc);
                insertRow(doc, table3, centerParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5s~1s", "1~3s", "3~20s", "20~60s", "60~180s");
                for (int j = 0; j < iec28VOS.size(); j++) {
                    IEC28VO iec28VO = iec28VOS.get(j);
                    insertRow(doc, table3, centerParagraph, false, iec28VO.getName(), iec28VO.getQ(), iec28VO.getW(), iec28VO.getE(), iec28VO.getR(), iec28VO.getT(), iec28VO.getY(), iec28VO.getU(), iec28VO.getI());
                }
                two++;
            }
            i++;
        }
        //4.暂降幅值概率分布
        if (exportParam.isGlfbfz() || exportParam.isGlfbsj()) {
            createTitle(doc, "4." + i + " 暂降幅值概率分布图", "标题 2", 200, 15);
//            ProbabilityVO probabilityVO = eventAnalysisService.getProbabilityDistribution(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
            ProbabilityVO probabilityVO = eventReportService.getProbabilityDistribution(info);
            int two = 1;
            if (exportParam.isGlfbfz()) {
                createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15);
                List<String> ybardata = probabilityVO.getPereventvalue();
                List<String> ylinedata = probabilityVO.getEventvalue();
                String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
                createPic(doc, fz, "暂降幅值的概率分布函数");
                two++;
            }
            if (exportParam.isGlfbsj()) {
                createTitle(doc, "4." + i + "." + two + " 持续时间的概率分函数", "标题 3", 400, 15);
                List<String> ybardata = probabilityVO.getPersisttime();
                List<String> ylinedata = probabilityVO.getSisttime();
                String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
                createPic(doc, sj, "持续时间的概率分布函数");
                two++;
            }
            i++;
        }


        //5.月份统计
        if (exportParam.isTjbg() || exportParam.isTjtx()) {
            createTitle(doc, "4." + i + " 月份统计", "标题 2", 200, 15);
            int two = 1;
            List<TimeVO> reasonTypeTime = eventAnalysisService.getReasonTypeTime(param);
            //暂时时间端按月查询不能查询
//            List<TimeVO> reasonTypeTime = eventReportService.getReasonTypeTime(param,null);
            if (exportParam.isTjtx()) {
                createTitle(doc, "4." + i + "." + two + " 月份统计图", "标题 3", 400, 15);
                List<Integer> count = new ArrayList<>();
                List<String> name = new ArrayList<>();
                if (exportParam.getFlag() == 0) {
                    for (TimeVO timeVO : reasonTypeTime) {
                        name.add(timeVO.getMonth() + "");
                        count.add(Integer.parseInt(timeVO.getTimes()));
                    }
                } else {
                    for (TimeVO timeVO : reasonTypeTime) {
                        name.add(timeVO.getDay() + "");
                        count.add(Integer.parseInt(timeVO.getTimes()));
                    }
                }
                String yftj = drawPicUtil.drawMonth(name, count, reasonTypeTime.get(0).getYear(), exportParam.getFlag());
                createPic(doc, yftj, "月份统计图");
                two++;
            }
            if (exportParam.isTjbg()) {
                XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
                createTitle(doc, "4." + i + "." + two + " 时间统计表格", "标题 3", 400, 15);

                XWPFTable table1 = createTable(doc);
                if (exportParam.getFlag() == 0) {
                    insertRow(doc, table1, centerParagraph, true, "时间(月)", "电压暂降次数");
                } else {
                    insertRow(doc, table1, centerParagraph, true, "时间(天)", "电压暂降次数");
                }
                if (exportParam.getFlag() == 0) {
                    for (int j = 0; j < reasonTypeTime.size(); j++) {
                        TimeVO timeVO = reasonTypeTime.get(j);
                        insertRow(doc, table1, centerParagraph, false, timeVO.getMonth(), timeVO.getTimes());
                    }
                } else {
                    for (int j = 0; j < reasonTypeTime.size(); j++) {
                        TimeVO timeVO = reasonTypeTime.get(j);
                        insertRow(doc, table1, centerParagraph, false,timeVO.getFulltime(), timeVO.getTimes());
                    }
                }
                two++;
            }
            i++;
        }


        //6.原因统计
        //6.1整合提出查询语句
        Boolean fly = exportParam.isYybg() || exportParam.isYytx() || exportParam.isLxbg() || exportParam.isLxtx();
        if (fly) {
            StatisticVO statistic = eventReportService.getStatistic(info, reasonData, typeData);
            if (exportParam.isYybg() || exportParam.isYytx()) {
                createTitle(doc, "4." + i + " 原因统计", "标题 2", 200, 15);
//            StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
                int two = 1;
                if (exportParam.isYytx()) {
                    createTitle(doc, "4." + i + "." + two + " 原因统计图", "标题 3", 400, 15);
                    List<String> xdata = new ArrayList<>();
                    List<Map<String, Object>> reasonList = new ArrayList<>();

                    List<ReasonsVO> reason = statistic.getReason();
                    for (ReasonsVO reasonsVO : reason) {
                        Map<String, Object> map = new LinkedHashMap<>();
                        map.put("value", reasonsVO.getTimes());
                        map.put("name", reasonsVO.getReason());
                        reasonList.add(map);
                        xdata.add(reasonsVO.getReason());
                    }
                    String tr = drawPicUtil.drawReason(xdata, reasonList);
                    createPic(doc, tr, "暂降原因图");
                    two++;
                }
                if (exportParam.isYybg()) {
                    XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
                    createTitle(doc, "4." + i + "." + two + " 原因统计表格", "标题 3", 400, 15);
                    XWPFTable table1 = createTable(doc);
                    insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
                    List<ReasonsVO> reason = statistic.getReason();
                    for (int j = 0; j < reason.size(); j++) {
                        ReasonsVO reasonsVO = reason.get(j);
                        insertRow(doc, table1, centerParagraph, false, reasonsVO.getReason(), reasonsVO.getTimes() + "");
                    }
                    two++;
                }
                i++;
            }
            //7.类型统计
            if (exportParam.isLxbg() || exportParam.isLxtx()) {
                createTitle(doc, "4." + i + " 类型统计", "标题 2", 200, 15);
//            StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
                int two = 1;
                if (exportParam.isLxtx()) {
                    createTitle(doc, "4." + i + "." + two + " 类型统计图", "标题 3", 400, 15);
                    List<String> xdata = new ArrayList<>();
                    List<TypesVO> types = statistic.getTypes();

                    List<Map<String, Object>> reasonList = new ArrayList<>();
                    for (TypesVO type : types) {
                        Map<String, Object> map = new LinkedHashMap<>();
                        map.put("value", type.getTimes());
                        map.put("name", type.getType());
                        reasonList.add(map);
                        xdata.add(type.getType());
                    }
                    String tr = drawPicUtil.drawType(xdata, reasonList);
                    createPic(doc, tr, "暂降类型图");
                    two++;
                }
                if (exportParam.isLxbg()) {
                    createTitle(doc, "4." + i + "." + two + " 类型统计表格", "标题 3", 400, 15);
                    XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
                    XWPFTable table1 = createTable(doc);
                    insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
                    List<TypesVO> types = statistic.getTypes();
                    for (int j = 0; j < types.size(); j++) {
                        TypesVO typesVO = types.get(j);
                        insertRow(doc, table1, centerParagraph, false, typesVO.getType(), typesVO.getTimes() + "");
                    }
                    two++;
                }
                i++;
            }
        }


        ServletOutputStream outputStream = response.getOutputStream();
        String fileName = URLEncoder.encode(exportParam.getLineName() + ".docx", "UTF-8");
        response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
        response.setContentType("application/octet-stream;charset=UTF-8");
        doc.write(outputStream);
        outputStream.close();
    }

    /**
     * 监测点暂降事件点图赋值
     *
     * @param plot
     * @return
     */
    private ArrayList<List<Double>> getAss(List<EventDetail> plot) {
        ArrayList<List<Double>> list = new ArrayList<>();
        for (EventDetail eventDetail : plot) {
            ArrayList<Double> doubles = new ArrayList<>();
            doubles.add(eventDetail.getDuration());
            doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
            list.add(doubles);
        }
        return list;
    }

    /**
     * influxdb查询结果集
     *
     * @param statisticsParam
     * @return
     */
    private List<EventDetail> info(StatisticsParam statisticsParam) {
        //获取事件类型
        List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
        List<String> typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode()) || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode()))
                .map(DictData::getId).collect(Collectors.toList());
        //数据暂降查询
        List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
                .eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
                .in(RmpEventDetailPO::getEventType, typeIds)
                .ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
                .le(StrUtil.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
        );

        return BeanUtil.copyToList(info, EventDetail.class);
    }


    /**
     * 表格插入行数据
     *
     * @param document 文档
     * @param table    表格
     * @param head     是否是表头
     * @param values   数据内容
     */
    public static void insertRow(XWPFDocument document, XWPFTable table, XWPFParagraph excelParagraph, boolean head,
                                 String... values) {
        if (head) {
            XWPFTableRow summaTableRowOne = table.getRow(0);
            WordUtils.setExcelHeadContent(excelParagraph, summaTableRowOne, values);
        } else {
            XWPFTableRow summaTableRowOne = table.createRow();
            WordUtils.setExcelContent(excelParagraph, summaTableRowOne, values);
        }
    }

    /**
     * 创建图片在word中
     *
     * @param document 文档
     * @param image    图片base64
     * @param name     图片名
     * @throws IOException
     * @throws InvalidFormatException
     */
    public void createPic(XWPFDocument document, String image, String name) throws IOException, InvalidFormatException, InvalidFormatException {
        XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document);
        XWPFRun createRun = picParagraph.createRun();
        if (image.contains(PicCommonData.PNG_PREFIX)) {
            image = image.replace(PicCommonData.PNG_PREFIX, "");
        }
        byte[] bytes = Base64.getDecoder().decode(image);
        InputStream in = new ByteArrayInputStream(bytes);
        createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
    }


    /**
     * 创建表格
     *
     * @param document
     * @return
     */
    public XWPFTable createTable(XWPFDocument document) {
        XWPFTable summaTable = document.createTable();
        // 列宽自动分割
        CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW();
        summaTableWidth.setType(STTblWidth.DXA);
        summaTableWidth.setW(BigInteger.valueOf(8160));
        return summaTable;
    }

    public void setCellStyle(HSSFCell cellname, String value, HSSFCellStyle style) {
        cellname.setCellValue(value);
        cellname.setCellStyle(style);
    }


    /**
     * 获取事件报告
     *
     * @author zbj
     * @date 2022/7/29
     */
    @Override
    public Page<WaveTypeVO> getEventReport(WaveTypeParam deviceInfoParam) {
        Page<WaveTypeVO> page = new Page<>(deviceInfoParam.getPageNum(), deviceInfoParam.getPageSize());
        List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(deviceInfoParam).getData();
        List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
        if (CollUtil.isEmpty(lineIds)) {
            return page;
        }

        LineBaseQueryParam lineBaseQueryParam = new LineBaseQueryParam();
        lineBaseQueryParam.setLineIds(lineIds);
        lineBaseQueryParam.setComFlag(deviceInfoParam.getComFlag());
        lineBaseQueryParam.setSearchValue(deviceInfoParam.getSearchValue());

        //调用查询监测点的方法
        List<AreaLineInfoVO> data = lineFeignClient.getRichLineInfo(lineBaseQueryParam).getData();
        //监测点集合
        List<String> ids = data.stream().map(AreaLineInfoVO::getLineId).collect(Collectors.toList());

        if (CollUtil.isNotEmpty(ids)) {
            Page<RmpEventDetailPO> pageInfo = eventDetailService.page(new Page<>(deviceInfoParam.getPageNum(), deviceInfoParam.getPageSize()), new LambdaQueryWrapper<RmpEventDetailPO>()
                    .in(RmpEventDetailPO::getMeasurementPointId, ids)
                    .eq(StrUtil.isNotBlank(deviceInfoParam.getWaveType()), RmpEventDetailPO::getEventType, deviceInfoParam.getWaveType())
                    .ge(StringUtils.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
                    .le(StringUtils.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
                    .orderByDesc(RmpEventDetailPO::getStartTime)
            );
            //集合拷贝
            List<WaveTypeVO> eventDetailList = BeanUtil.copyToList(pageInfo.getRecords(), WaveTypeVO.class);
            if (CollUtil.isEmpty(eventDetailList)) {
                return page;
            }

            //获取关于监测点发电站相关信息
            HttpResult<List<AreaLineInfoVO>> baseLineAreaInfo = lineFeignClient.getBaseLineAreaInfo(lineIds);

            //将返回的封装好的结果集进行还原成集合
            List<AreaLineInfoVO> areaLineList = baseLineAreaInfo.getData();


            //将监测点发电机相关信息copy到准备好的VO对象中
            for (WaveTypeVO waveTypeVO : eventDetailList) {
                if (waveTypeVO.getLineId() != null) {
                    for (AreaLineInfoVO lineInfoVO : areaLineList) {
                        if (waveTypeVO.getLineId().equals(lineInfoVO.getLineId())) {
                            waveTypeVO.setSubName(lineInfoVO.getSubName());
                            waveTypeVO.setLineId(lineInfoVO.getLineId());
                            waveTypeVO.setLineName(lineInfoVO.getLineName());
                            waveTypeVO.setGdId(lineInfoVO.getGdId());
                            waveTypeVO.setGdName(lineInfoVO.getGdName());
                            waveTypeVO.setVoltageId(lineInfoVO.getVoltageId());
                            waveTypeVO.setNoDealCount(lineInfoVO.getNoDealCount());
                            waveTypeVO.setCt1(lineInfoVO.getCt1());
                            waveTypeVO.setCt2(lineInfoVO.getCt2());
                            waveTypeVO.setPt1(lineInfoVO.getPt1());
                            waveTypeVO.setPt2(lineInfoVO.getPt2());
                            waveTypeVO.setRunFlag(lineInfoVO.getRunFlag());
                            waveTypeVO.setComFlag(lineInfoVO.getComFlag());
                            waveTypeVO.setIp(lineInfoVO.getIp());
                            waveTypeVO.setLat(lineInfoVO.getLat());
                            waveTypeVO.setLng(lineInfoVO.getLng());
                            waveTypeVO.setManufacturer(lineInfoVO.getManufacturer());
                            waveTypeVO.setVoltageScale(lineInfoVO.getVoltageScale());
                        }
                    }
                }
            }


            //使用字典表对暂态类型和暂态原因进行转换
            HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName());
            HttpResult<List<DictData>> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName());
            //获取字典数据暂态原因集合
            List<DictData> eventReasonList = reason.getData();
            //获取字典数据暂态类型集合
            List<DictData> eventTypeList = type.getData();

            for (WaveTypeVO waveTypeVO : eventDetailList) {
                for (DictData dictData : eventReasonList) {
                    //将字典数据id与VO中属性eventReason对应的字符串进行比较
                    if (dictData.getId().equals(waveTypeVO.getAdvanceReason())) {
                        waveTypeVO.setAdvanceReason(dictData.getName());
                    }
                }
            }

            for (WaveTypeVO waveTypeVO : eventDetailList) {
                for (DictData dictData : eventTypeList) {
                    //将字典数据id与VO中属性eventType对应的字符串进行比较
                    if (dictData.getId().equals(waveTypeVO.getAdvanceType())) {
                        waveTypeVO.setAdvanceType(dictData.getName());
                    }
                }
            }

            page = BeanUtil.copyProperties(pageInfo, Page.class);
            page.setRecords(eventDetailList);

        }
        return page;

    }


    /**
     * 获取区域报告
     *
     * @author zbj
     * @date 2022/8/4
     */
    @Override
    public void getAreaReport(AreaReportParam areaReportParam, HttpServletResponse response) throws Exception {

        //暂态事件
        String typeName;
        if (areaReportParam.getWaveType().equals(0)) {
            //设置类型变量名为暂态
            typeName = "暂态";
        } else {
            typeName = "暂降";
        }
        //事件统计表格（部门查询）
        List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaReportParam).getData();

        //这是总的监测点id
        List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());


        //创建部门参数数据
        AreaReportParam areaParam = new AreaReportParam();
        areaParam.setDeptIndex(areaReportParam.getDeptIndex());
        //创建Code对象
        SimpleDTO simpleDTO = new SimpleDTO();
        //电压等级
        simpleDTO.setCode(StatisticsEnum.VOLTAGE_LEVEL.getCode());
        simpleDTO.setName(StatisticsEnum.VOLTAGE_LEVEL.getName());


        areaParam.setStatisticalType(simpleDTO);
        areaParam.setMonitorFlag(areaReportParam.getMonitorFlag());
        areaParam.setPowerFlag(areaReportParam.getPowerFlag());
        areaParam.setServerName(areaReportParam.getServerName());
        areaParam.setStatFlag(areaReportParam.getStatFlag());
        areaParam.setSearchBeginTime(areaReportParam.getSearchBeginTime());
        areaParam.setSearchEndTime(areaReportParam.getSearchEndTime());


        //提前创建,不然获取不到（初始化数据）
        if (CollUtil.isEmpty(lineIds)) {
            throw new BusinessException(EventResponseEnum.NOT_FOUND);
        }
        List<EventDetailNew> eventDetailList = getEventDetailListInfo(areaReportParam, lineIds, areaReportParam.getWaveType());
        List<EventDetail> eventDetails = BeanUtil.copyToList(eventDetailList, EventDetail.class);
        List<GeneralDeviceDTO> voltageParamList = generalDeviceInfoClient.getPracticalAllDeviceInfo(areaParam).getData();


        //创建幅值计数器
        int oneCount2 = 0;

        //创建ITIC与F47计数器
        int oneCount3 = 0;
        int twoCount5 = 0;

        //创建暂降密度表和密度图的计数器
        int oneCount4 = 0;
        int twoCount1 = 0;

        //创建暂降事件表格和图的计数器
        int oneCount5 = 0;
        int twoCount2 = 0;

        //创建暂态类型图和暂态类型表格计数器
        int oneCount6 = 0;
        int twoCount3 = 0;

        //创建暂态原因图和暂态原因表格计数器
        int oneCount7 = 0;
        int twoCount4 = 0;

        //提前创建计数（累计监测点数量）
        Integer eventCount = 0;
        //如果集合中有id将id进行拼接
        if (CollectionUtil.isNotEmpty(lineIds)) {
            //获取累计监测点数量
            eventCount = eventDetailList.size();
        }


        //准备word表中参数
        //获取监测点总数量
        int size = lineIds.size();
        //还有当前传入的部门名称(例如:中国)需要等邓哥的公共方法
        String deptName = deptFeignClient.getDeptById(areaReportParam.getDeptIndex()).getData().getName();


        /**
         * =====================生成word===========================
         */
        //设置序号初始值
        int oneCount = 1;

        //创建word文档(poi生成word)
        XWPFDocument doc = new XWPFDocument();// 创建Word文件
        XWPFParagraph p = doc.createParagraph();// 新建一个段落

        // 设定标题格式,可以生成可点击的序号
        WordUtils.setHeadingStyle(doc);

        //设置对齐
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r = p.createRun();//创建段落文本
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.setText(deptName + "供电公司");
        r.setBold(true);//设置为粗体
        r.setFontSize(14);//字体大小
        r.addBreak();


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r1 = p.createRun();//创建段落文本
        r1.setText("电压" + typeName + "事件区域报告");
        r1.setBold(true);//设置为粗体
        r1.setFontSize(36);//字体大小
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r2 = p.createRun();//创建段落文本
        //获取当前时间
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日");
        String time = dateFormat.format(date);

        r2.setText("日期: " + time);
        r2.setBold(true);//设置为粗体
        r2.setFontSize(14);//字体大小

        r2.addBreak();
        r2.addBreak();
        r2.addBreak();


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r3 = p.createRun();//创建段落文本
        r3.setText("电压" + typeName + "事件区域报告");
        r3.setFontSize(24);//字体大小


        createTitle(doc, "1. 引言", "标题 1", 0, 15);


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r5 = p.createRun();//创建段落文本
        r5.setText("  " + deptName + "电网总共有" + size + "个监测点。" + deptName + "电网在所选择时间段" + areaReportParam.getSearchBeginTime() + " 至 " + areaReportParam.getSearchEndTime() +
                "累计监测到" + typeName + "事件" + eventCount + "条，本报告按照监测点分布，" + typeName + "事件统计，" + typeName + "事件点图，" + typeName + "热力图，" + typeName + "密度图，" + typeName + "概率分布图，事件关联统计，" + typeName + "类型统计，" + typeName + "原因统计等方面进行数据分析。");
        r5.setFontSize(11);//字体大小


        createTitle(doc, "2. 报告分析对象", "标题 1", 0, 15);


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r7 = p.createRun();//创建段落文本
        r7.setText("  " + deptName + "。");
        r7.setFontSize(11);//字体大小


        createTitle(doc, "3. 报告分析时间", "标题 1", 0, 15);


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r9 = p.createRun();//创建段落文本
        r9.setText("  " + areaReportParam.getSearchBeginTime() + " 至 " + areaReportParam.getSearchEndTime() + "。");
        r9.setFontSize(11);//字体大小


        createTitle(doc, "4. 汇总信息", "标题 1", 0, 15);

        //1.监测网分布
        if (areaReportParam.isMonitorDistributeChart()) {
            //监测网分布


            //在线监测点数
            Integer onLineIdCount = 0;
            if (CollectionUtil.isNotEmpty(lineIds)) {
                onLineIdCount = lineFeignClient.getOnLineCount(lineIds).getData();
            }

            //离线总监测点数
            Integer unLineCount = Integer.valueOf(lineIds.size()) - onLineIdCount;
            //在线率
            Double onlineRate = (onLineIdCount.doubleValue()) / (Double.valueOf(String.valueOf(lineIds.size()))) * 100;

            NumberFormat nf = NumberFormat.getNumberInstance();
            // 保留两位小数
            nf.setMaximumFractionDigits(2);
            // 如果不需要四舍五入
            nf.setRoundingMode(RoundingMode.UP);

            String onlineRateResult = nf.format(onlineRate);


            /**
             * =========================续写word文档==============================================
             */


            createTitle(doc, "4." + oneCount + " 监测网分布", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            r12.setText("  " + deptName + "电网总共有监测点" + size + "个。监测点在线率达到" + onlineRateResult + "%（通讯正常为：" + onLineIdCount + "个，通讯异常为：" + unLineCount + "个）" +
                    "[通讯正常/总监测点数（统计时候排除检修和热备用监测点）]，具体见下图：");
            r12.setFontSize(11);//字体大小


            //todo 分布地图代码未实现

            //序号计数进行++
            oneCount++;

            /**
             * =======================================word结束=========================================
             */
        }
        List<String> lindIds = eventDetailList.stream().map(EventDetailNew::getLineId).collect(Collectors.toList());
        //2.暂降事件三表季图像判断
        if (areaReportParam.isEventCountTable() || areaReportParam.isEventCountChart()) {

            //所有的表结果装入集合
            Map<String, Integer> areaCount = new HashMap<>();
            Map<String, Integer> voltageCount = new HashMap<>();
            //暂降事件最多的两个电压
            Set<String> topVoltage = new HashSet<>();

            //1.部门信息。传入参数（判断统计类型）
            if (Objects.nonNull(areaReportParam.getStatisticalType().getCode()) && areaReportParam.getStatisticalType().getCode().equals("Power_Network")) {
                //进行遍历集合获得子区域名及其所有监测点id
                for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {

                    //当前子部门下所有id
                    List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
                    //如果集合中有id将id进行拼接
                    if (CollectionUtil.isNotEmpty(lineIndexes)) {

                        List<String> countSize = lindIds.stream().filter(x -> lineIndexes.contains(x)).collect(Collectors.toList());

                        if (CollUtil.isNotEmpty(countSize)) {
                            areaCount.put(generalDeviceDTO.getName(), countSize.size());
                        } else {
                            areaCount.put(generalDeviceDTO.getName(), 0);
                        }

                    } else {
                        //为空put 0
                        areaCount.put(generalDeviceDTO.getName(), 0);
                    }
                }

                //2.电压集合(统计类型：电压)
                List<GeneralDeviceDTO> areaParamList = voltageParamList;
                //进行遍历集合获得子区域名及其所有监测点id
                for (GeneralDeviceDTO generalDeviceDTO : areaParamList) {

                    //当前子部门下所有id
                    List<String> lineIndexes = generalDeviceDTO.getLineIndexes();

                    //如果集合中有id将id进行拼接
                    if (CollectionUtil.isNotEmpty(lineIndexes)) {

                        //总条数
                        List<String> countSize = lindIds.stream().filter(x -> lineIndexes.contains(x)).collect(Collectors.toList());

                        if (CollUtil.isNotEmpty(countSize)) {
                            voltageCount.put(generalDeviceDTO.getName(), countSize.size());
                        } else {
                            voltageCount.put(generalDeviceDTO.getName(), 0);
                        }

                    } else {
                        //为空put 0
                        voltageCount.put(generalDeviceDTO.getName(), 0);
                    }
                }
                //数据排序
                Map<String, Integer> linkMap = getSort(voltageCount);
                //最多暂降事件的两个电压名称
                topVoltage = linkMap.keySet();

            }


            //根据月份来进行查看暂降
            //提前创建对象
            int dayOfMonth = 0;
            //最后集合
            List<TimeSVO> timeSVoList = new ArrayList<>();
            //表格参数
            String table;

            //月
            if ("0".equals(areaReportParam.getInterval())) {
                table = "月份";

                List<String> dayCount = new ArrayList<>();
                List<AreaEventMonthParam> timeList = new ArrayList<>();
                DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM");
                //进行for循环获取所有事件的时间
                for (EventDetailNew eventDetail : eventDetailList) {
                    //获取暂降事件时间

                    dayCount.add(DateUtil.format(DateUtil.parse(eventDetail.getStartTime()), fmt));

                    //创建对象
                    AreaEventMonthParam timeParam = new AreaEventMonthParam();
                    timeParam.setDayOrMonth(DateUtil.format(DateUtil.parse(eventDetail.getStartTime()), fmt));
                    timeParam.setEventAssIndex(eventDetail.getEventassIndex());
                    timeList.add(timeParam);
                }

                //Map集和
                Map<String, List<String>> relevanceMap = new HashMap<>();
                List<String> list = new ArrayList<>();

                for (AreaEventMonthParam areaEventMonthParam : timeList) {
                    //如果存在
                    if (relevanceMap.containsKey(areaEventMonthParam.getDayOrMonth())) {
                        list = relevanceMap.get(areaEventMonthParam.getDayOrMonth());
                        list.add(areaEventMonthParam.getEventAssIndex());
                        relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list));
                    } else {
                        List<String> list1 = new ArrayList<>();
                        list1.add(areaEventMonthParam.getEventAssIndex());
                        relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list1));
                    }
                }
                //创建map集和装当天和次数
                Map<String, Integer> resultMap = new HashMap<>();
                for (String day : dayCount) {
                    if (resultMap.containsKey(day)) {
                        resultMap.put(day, resultMap.get(day) + 1);
                    } else {
                        resultMap.put(day, 1);
                    }
                }

                //获取未关联的暂态事件
                Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
                        .collect(Collectors.groupingBy(x -> DateUtil.format(DateUtil.parse(x.getStartTime()), fmt), Collectors.counting()));

                //开始时间
                LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime());
                LocalDate end = LocalDate.parse(areaReportParam.getSearchEndTime());
                //因为是比较月份,将起始时间的天数加给结束时间,不然while一直不能结束循环

                String substring1 = end.toString().substring(0, 8);
                String substring2 = beginTime.toString().substring(8, 10);

                String s1 = substring1 + substring2;
                LocalDate endTime = LocalDate.parse(s1);
                Set<String> keySet = resultMap.keySet();

                while (!beginTime.equals(endTime.plus(1, ChronoUnit.MONTHS))) {
                    if (keySet.contains(beginTime.toString().substring(0, 7))) {
                        Integer countSize = resultMap.get(beginTime.toString().substring(0, 7));
                        TimeSVO timeVO = new TimeSVO();
                        timeVO.setTimes(countSize.toString());
                        timeVO.setYear(String.valueOf(beginTime.getYear()));

                        //todo 不知道代码是否是写错了，时间判断有问题
                        if (beginTime.getMonthValue() < 10) {
                            timeVO.setMonth("0" + beginTime.getMonthValue() + "");
                        } else {
                            timeVO.setMonth(beginTime.getMonthValue() + "");
                        }

                        timeVO.setFulltime(beginTime.toString().substring(0, 7));

                        //遍历 如果时间相同,将所有关联处理事件次数赋值上去
                        if (eventAssDetail.containsKey(beginTime.toString().substring(0, 7))) {
                            timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString().substring(0, 7))));
                        } else {
                            timeVO.setEventAssIndex(0);
                        }
                        timeSVoList.add(timeVO);
                    } else {
                        TimeSVO timeVO = new TimeSVO();
                        timeVO.setTimes("0");
                        timeVO.setYear(String.valueOf(beginTime.getYear()));

                        //todo 未知问题：是否是代码错误
                        if (beginTime.getMonthValue() < 10) {
                            timeVO.setMonth("0" + beginTime.getMonthValue() + "");
                        } else {
                            timeVO.setMonth(beginTime.getMonthValue() + "");
                        }
                        timeVO.setEventAssIndex(0);
                        timeVO.setFulltime(beginTime.toString().substring(0, 7));
                        timeSVoList.add(timeVO);
                    }

                    beginTime = beginTime.plus(1, ChronoUnit.MONTHS);
                }

                //数据排序
                Map<String, Integer> linkMap = getSort(resultMap);
                //暂降次数最多
                List<String> collect = linkMap.keySet().stream().collect(Collectors.toList());
                //赋值
                dayOfMonth = Integer.parseInt(collect.get(0).substring(5, 7));
            } else {
                table = "天数";

                List<String> dayCount = new ArrayList<>();
                List<AreaEventMonthParam> timeList = new ArrayList<>();


                //进行for循环获取所有事件的时间
                for (EventDetailNew eventDetail : eventDetailList) {
                    //获取暂降事件时间
                    dayCount.add(DateUtil.formatDate(DateUtil.parse(eventDetail.getStartTime())));

                    //创建对象
                    AreaEventMonthParam timeParam = new AreaEventMonthParam();
                    timeParam.setDayOrMonth(DateUtil.formatDate(DateUtil.parse(eventDetail.getStartTime())));
                    timeParam.setEventAssIndex(eventDetail.getEventassIndex());
                    timeList.add(timeParam);
                }

                //Map集和
                Map<String, List<String>> relevanceMap = new HashMap<>();
                List<String> list = new ArrayList<>();

                for (AreaEventMonthParam areaEventMonthParam : timeList) {
                    //如果存在
                    if (relevanceMap.containsKey(areaEventMonthParam.getDayOrMonth())) {
                        list = relevanceMap.get(areaEventMonthParam.getDayOrMonth());
                        list.add(areaEventMonthParam.getEventAssIndex());
                        relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list));
                    } else {
                        List<String> list1 = new ArrayList<>();
                        list1.add(areaEventMonthParam.getEventAssIndex());
                        relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list1));
                    }
                }
                //创建map集和装当天和次数
                Map<String, Integer> resultMap = new HashMap<>();
                for (String day : dayCount) {
                    if (resultMap.containsKey(day)) {
                        resultMap.put(day, resultMap.get(day) + 1);
                    } else {
                        resultMap.put(day, 1);
                    }
                }
                //获取未关联的暂态事件
                Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
                        .collect(Collectors.groupingBy(x -> DateUtil.formatDate(DateUtil.parse(x.getStartTime())), Collectors.counting()));

                DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                //开始时间
                LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime(), fmt);
                LocalDate endTime = LocalDate.parse(areaReportParam.getSearchEndTime(), fmt);

                Set<String> keySet = resultMap.keySet();

                while (!beginTime.equals(endTime.plus(1, ChronoUnit.DAYS))) {
                    if (keySet.contains(beginTime.toString())) {

                        //获取暂降次数
                        Integer countSize = resultMap.get(beginTime.toString());
                        TimeSVO timeVO = new TimeSVO();
                        timeVO.setTimes(countSize.toString());

                        if (beginTime.getDayOfMonth() < 10) {
                            timeVO.setDay("0" + beginTime.getDayOfMonth() + "");
                        } else {
                            timeVO.setDay(beginTime.getDayOfMonth() + "");
                        }

                        timeVO.setYear(String.valueOf(beginTime.getYear()));
                        //todo 不知道代码是否是写错了，时间判断有问题
                        if (beginTime.getMonthValue() < 10) {
                            timeVO.setMonth("0" + beginTime.getMonthValue() + "");
                        } else {
                            timeVO.setMonth(beginTime.getMonthValue() + "");
                        }
                        timeVO.setFulltime(beginTime.toString());
                        //遍历 如果时间相同,将所有关联处理事件次数赋值上去
                        if (eventAssDetail.containsKey(beginTime.toString())) {
                            timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString())));
                        } else {
                            timeVO.setEventAssIndex(0);
                        }
                        timeSVoList.add(timeVO);
                    } else {
                        TimeSVO timeVO = new TimeSVO();
                        timeVO.setTimes("0");
                        if (beginTime.getDayOfMonth() < 10) {
                            timeVO.setDay("0" + beginTime.getDayOfMonth() + "");
                        } else {
                            timeVO.setDay(beginTime.getDayOfMonth() + "");
                        }
                        timeVO.setYear(String.valueOf(beginTime.getYear()));

                        //todo 未知问题：是否是代码错误
                        if (beginTime.getMonthValue() < 10) {
                            timeVO.setMonth("0" + beginTime.getMonthValue() + "");
                        } else {
                            timeVO.setMonth(beginTime.getMonthValue() + "");
                        }
                        timeVO.setEventAssIndex(0);
                        timeVO.setFulltime(beginTime.toString());
                        timeSVoList.add(timeVO);
                    }

                    beginTime = beginTime.plus(1, ChronoUnit.DAYS);
                }

                //数据排序
                Map<String, Integer> linkMap = getSort(resultMap);
                //暂降次数最多
                List<String> collect = linkMap.keySet().stream().collect(Collectors.toList());

                //赋值
                dayOfMonth = LocalDate.parse(collect.get(0)).getDayOfMonth();

            }

            //最高暂降事件的两个电压值
//                System.out.println(topVoltage);
            //转为List
            List<String> topVoltageList = new ArrayList<>();
            for (String s : topVoltage) {
                topVoltageList.add(s);
            }
            //表格
            if (areaReportParam.isEventCountTable()) {

                //创建表题计数
                int twoCount = 1;

                //与暂降事件图形共享序号
                oneCount5 = oneCount;


                createTitle(doc, "4." + oneCount + " " + typeName + "事件列表", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条，" + topVoltageList.get(0) + "、" + topVoltageList.get(1) + "" + typeName + "事件居多，" +
                        "第" + dayOfMonth + "" + table + "" + typeName + "事件居多，具体见下表(图)：");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "事件表格", "标题 3", 400, 11);
                twoCount2 = twoCount;

                //第一张表
                XWPFTable monitorInfo = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc);
                // 表格第一行
                insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "区域", "电压" + typeName + "次数");
                //塞入数据
                for (String s : areaCount.keySet()) {
                    insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, s, areaCount.get(s).toString());
                }


                //第二张表
                XWPFTable monitorInfo1 = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph1 = WordUtils.getCenterParagraph(doc);
                // 表格第一行
                insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, true, "电压等级", "电压" + typeName + "次数");
                //塞入数据
                for (String s : voltageCount.keySet()) {
                    insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, false, s, voltageCount.get(s).toString());
                }


                //第三张表
                XWPFTable monitorInfo2 = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc);
                // 表格第一行
                insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "" + table + "", "电压" + typeName + "次数");
                //塞入数据
                for (int i = 0; i < timeSVoList.size(); i++) {
                    insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, timeSVoList.get(i).getFulltime(), timeSVoList.get(i).getTimes());
                }

                //序号计数进行++
                oneCount++;

                /**
                 * =======================================word结束=========================================
                 */

            }

            //图形
            if (areaReportParam.isEventCountChart()) {
                twoCount2++;
                createTitle(doc, "4." + oneCount5 + "." + twoCount2 + " " + typeName + "事件图形", "标题 3", 400, 11);


                //创建部门与监测点次数的map集合
                Map<String, Integer> lineCount = new HashMap<>();
                for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
                    lineCount.put(generalDeviceDTO.getName(), generalDeviceDTO.getLineIndexes().size());
                }

                //创建x,y参数
                List<String> xdata = new ArrayList<>();
                List<Integer> ydata = new ArrayList<>();
                //根据区域名称进行匹配
                for (String name : areaCount.keySet()) {
                    //将监测点的数量拼接在部门下面
                    for (String s : lineCount.keySet()) {
                        if (s.equals(name)) {
                            xdata.add(name + "\n" + "(" + lineCount.get(s) + ")");
                        }
                    }

                    ydata.add(areaCount.get(name));
                }

                String qytj = drawPicUtil.drawEventRegion(xdata, ydata);
                createPic(doc, qytj, "" + typeName + "事件图形");


                //月份统计
                //创建x,y参数
                List<String> xdata1 = new ArrayList<>();
                List<Integer> ydata1 = new ArrayList<>();
                List<Integer> ydata2 = new ArrayList<>();
                for (TimeSVO timeSVO : timeSVoList) {
                    if ("天数".equals(table)) {
                        xdata1.add(timeSVO.getFulltime().substring(5));
                    } else {
                        xdata1.add(timeSVO.getFulltime());
                    }
                    ydata1.add(Integer.parseInt(timeSVO.getTimes()));
                    ydata2.add(timeSVO.getEventAssIndex());
                }
                String yftj = drawPicUtil.drawEventAssociatedUnassociated(xdata1, ydata1, ydata2, table);
                createPic(doc, yftj, "" + typeName + "事件图形");


                //创建电压uiiiuuuu与监测点次数的map集合
                List<GeneralDeviceDTO> areaParamList = voltageParamList;
                Map<String, Integer> lineCount1 = new HashMap<>();
                for (GeneralDeviceDTO generalDeviceDTO : areaParamList) {
                    lineCount1.put(generalDeviceDTO.getName(), generalDeviceDTO.getLineIndexes().size());
                }
                //创建x,y参数
                List<String> xdata3 = new ArrayList<>();
                List<Integer> ydata3 = new ArrayList<>();
                //根据电压名称进行匹配
                for (String name : voltageCount.keySet()) {
                    //将监测点的数量拼接在部门下面
                    for (String s : lineCount1.keySet()) {
                        if (s.equals(name)) {
                            xdata3.add(name + "\n" + "(" + lineCount1.get(s) + ")");
                        }
                    }
                    ydata3.add(voltageCount.get(name));
                }

                String dydj = drawPicUtil.drawEventVoltageLevel(xdata3, ydata3);
                createPic(doc, dydj, "" + typeName + "事件图形");


                /**
                 * =======================================word结束=========================================
                 */
            }


        }

        //3.密度图
//        if (areaReportParam.isDensityTable() || areaReportParam.isDensityChart()) {
//
//            //暂降密度图形
//            AreaTableParam areaTableParam = new AreaTableParam();
//
//            //创建结果集合
//            List<EventDetailNew> info = eventDetailList;
//
//            //将sql结果集放入,共用一个sql,减少查询时间
//            AreaTableParam areaTableParam1 = new AreaTableParam();
//            areaTableParam1.setInfo(info);
//
//
//            List<IEC28VO> iEC28VOResult = IEC28Area(areaTableParam1);
//            List<IEC411VO> iEC411VOResult = IEC411Area(areaTableParam1);
//            List<DISDIPVO> dISDIPVOResult = eventDisdipArea(areaTableParam1);
//
//
//            //IEC411 <1% 总共集合
//            List<IEC411VO> lessOneIEC411 = new ArrayList<>();
//            //IEC411 1~40% 总共集合
//            List<IEC411VO> lessFortyIEC411 = new ArrayList<>();
//            //IEC411 40~70% 总共集合
//            List<IEC411VO> lessSeventyIEC411 = new ArrayList<>();
//
//
//            //IEC28 <1% 总共集合
//            List<IEC28VO> lessOneIEC28 = new ArrayList<>();
//            //IEC411 <10 总共集合
//            List<IEC28VO> lessTenIEC28 = new ArrayList<>();
//            //IEC411 <20 总共集合
//            List<IEC28VO> lessTwentyIEC28 = new ArrayList<>();
//            //IEC411 <30 总共集合
//            List<IEC28VO> lessThirtyIEC28 = new ArrayList<>();
//            //IEC411 <40 总共集合
//            List<IEC28VO> lessFortyIEC28 = new ArrayList<>();
//            //IEC411 <50 总共集合
//            List<IEC28VO> lessFiftyIEC28 = new ArrayList<>();
//            //IEC411 <60 总共集合
//            List<IEC28VO> lessSixtyIEC28 = new ArrayList<>();
//            //IEC411 <70 总共集合
//            List<IEC28VO> lessSeventyIEC28 = new ArrayList<>();
//            //IEC411 <80 总共集合
//            List<IEC28VO> lessEightyIEC28 = new ArrayList<>();
//            //IEC411 <90 总共集合
//            List<IEC28VO> lessNinetyIEC28 = new ArrayList<>();
//            //IEC411 <120 总共集合
//            List<IEC28VO> lessHundredTwentyIEC28 = new ArrayList<>();
//            //IEC411 <130 总共集合
//            List<IEC28VO> lessHundredThirtyIEC28 = new ArrayList<>();
//            //IEC411 <140 总共集合
//            List<IEC28VO> lessHundredFortyIEC28 = new ArrayList<>();
//            //IEC411 <150 总共集合
//            List<IEC28VO> lessHundredFiftyIEC28 = new ArrayList<>();
//            //IEC411 <160 总共集合
//            List<IEC28VO> lessHundredSixtyIEC28 = new ArrayList<>();
//            //IEC411 <170 总共集合
//            List<IEC28VO> lessHundredSeventyIEC28 = new ArrayList<>();
//            //IEC411 <180 总共集合
//            List<IEC28VO> lessHundredEightyIEC28 = new ArrayList<>();
//
//
//            //DISDIP = 10%
//            List<DISDIPVO> equalTenDISDIP = new ArrayList<>();
//            //DISDIP = 40%
//            List<DISDIPVO> equalFortyDISDIP = new ArrayList<>();
//            //DISDIP = 70%
//            List<DISDIPVO> equalSeventyDISDIP = new ArrayList<>();
//            //DISDIP = 85%
//            List<DISDIPVO> equalEightyFiveDISDIP = new ArrayList<>();
//            //DISDIP = 90%
//            List<DISDIPVO> equalNinetyDISDIP = new ArrayList<>();
//
//
//            //遍历将集合按名称分开
//            for (int i1 = 0; i1 < iEC411VOResult.size(); i1++) {
//                if ("<1%".equals(iEC411VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessOneIEC411.add(iEC411VOResult.get(i1));
//                } else if ("1~40%".equals(iEC411VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessFortyIEC411.add(iEC411VOResult.get(i1));
//                } else {
//                    //放入集合
//                    lessSeventyIEC411.add(iEC411VOResult.get(i1));
//                }
//            }
//
//
//            //遍历将集合按名称分开
//            for (int i1 = 0; i1 < iEC28VOResult.size(); i1++) {
//                if ("1>U>=0".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessOneIEC28.add(iEC28VOResult.get(i1));
//                } else if ("10>U>=1".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessTenIEC28.add(iEC28VOResult.get(i1));
//                } else if ("20>U>=10".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessTwentyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("30>U>=20".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessThirtyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("40>U>=30".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessFortyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("50>U>=40".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessFiftyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("60>U>=50".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessSixtyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("70>U>=60".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessSeventyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("80>U>=70".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessEightyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("90>U>=80".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessNinetyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("120>U>=110".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessHundredTwentyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("130>U>=120".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessHundredThirtyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("140>U>=130".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessHundredFortyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("150>U>=140".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessHundredFiftyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("160>U>=150".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessHundredSixtyIEC28.add(iEC28VOResult.get(i1));
//                } else if ("170>U>=160".equals(iEC28VOResult.get(i1).getName())) {
//                    //放入集合
//                    lessHundredSeventyIEC28.add(iEC28VOResult.get(i1));
//                } else {
//                    //放入集合
//                    lessHundredEightyIEC28.add(iEC28VOResult.get(i1));
//
//                }
//            }
//
//            //遍历将集合按名称分开
//            for (int i1 = 0; i1 < dISDIPVOResult.size(); i1++) {
//                if ("10%".equals(dISDIPVOResult.get(i1).getName())) {
//                    //放入集合
//                    equalTenDISDIP.add(dISDIPVOResult.get(i1));
//                } else if ("40%".equals(dISDIPVOResult.get(i1).getName())) {
//                    //放入集合
//                    equalFortyDISDIP.add(dISDIPVOResult.get(i1));
//                } else if ("70%".equals(dISDIPVOResult.get(i1).getName())) {
//                    //放入集合
//                    equalSeventyDISDIP.add(dISDIPVOResult.get(i1));
//                } else if ("85%".equals(dISDIPVOResult.get(i1).getName())) {
//                    //放入集合
//                    equalEightyFiveDISDIP.add(dISDIPVOResult.get(i1));
//                } else {
//                    //放入集合
//                    equalNinetyDISDIP.add(dISDIPVOResult.get(i1));
//                }
//            }
//
//
//            //遍历集合中的参数
//            IEC411CountParam iec411LessOne = new IEC411CountParam();
//
//            for (IEC411VO iec411VO : lessOneIEC411) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec411LessOne.getName())) {
//                    iec411LessOne.setName(iec411VO.getName());
//                }
//
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec411VO.getTenTwentyMs())) {
//                    int tenToTwenty = iec411LessOne.getTenToTwenty();
//                    iec411LessOne.setTenToTwenty(tenToTwenty++);
//                }
//                if (!"0".equals(iec411VO.getTwentyOneHundredMs())) {
//                    int twentyToHundred = iec411LessOne.getTwentyToHundred();
//                    iec411LessOne.setTenToTwenty(twentyToHundred++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) {
//                    int zeroOneToZeroTwo = iec411LessOne.getZeroOneToZeroTwo();
//                    iec411LessOne.setTenToTwenty(zeroOneToZeroTwo++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) {
//                    int zeroTwoToZeroFive = iec411LessOne.getZeroTwoToZeroFive();
//                    iec411LessOne.setTenToTwenty(zeroTwoToZeroFive++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontFive1S())) {
//                    int zeroFiveToOne = iec411LessOne.getZeroFiveToOne();
//                    iec411LessOne.setTenToTwenty(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec411VO.getGreater1S())) {
//                    int lessOne = iec411LessOne.getLessOne();
//                    iec411LessOne.setTenToTwenty(lessOne++);
//                }
//            }
//
//            //遍历集合中的参数
//            IEC411CountParam iec411LessForty = new IEC411CountParam();
//
//            for (IEC411VO iec411VO : lessFortyIEC411) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec411LessForty.getName())) {
//                    iec411LessForty.setName(iec411VO.getName());
//                }
//
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec411VO.getTenTwentyMs())) {
//                    int tenToTwenty = iec411LessForty.getTenToTwenty();
//                    iec411LessForty.setTenToTwenty(tenToTwenty++);
//                }
//                if (!"0".equals(iec411VO.getTwentyOneHundredMs())) {
//                    int twentyToHundred = iec411LessForty.getTwentyToHundred();
//                    iec411LessForty.setTenToTwenty(twentyToHundred++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) {
//                    int zeroOneToZeroTwo = iec411LessForty.getZeroOneToZeroTwo();
//                    iec411LessForty.setTenToTwenty(zeroOneToZeroTwo++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) {
//                    int zeroTwoToZeroFive = iec411LessForty.getZeroTwoToZeroFive();
//                    iec411LessForty.setTenToTwenty(zeroTwoToZeroFive++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontFive1S())) {
//                    int zeroFiveToOne = iec411LessForty.getZeroFiveToOne();
//                    iec411LessForty.setTenToTwenty(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec411VO.getGreater1S())) {
//                    int lessOne = iec411LessForty.getLessOne();
//                    iec411LessForty.setTenToTwenty(lessOne++);
//                }
//            }
//
//            //遍历集合中的参数
//            IEC411CountParam iec411LessSeventy = new IEC411CountParam();
//
//            for (IEC411VO iec411VO : lessSeventyIEC411) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec411LessSeventy.getName())) {
//                    iec411LessSeventy.setName(iec411VO.getName());
//                }
//
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec411VO.getTenTwentyMs())) {
//                    int tenToTwenty = iec411LessSeventy.getTenToTwenty();
//                    iec411LessSeventy.setTenToTwenty(tenToTwenty++);
//                }
//                if (!"0".equals(iec411VO.getTwentyOneHundredMs())) {
//                    int twentyToHundred = iec411LessSeventy.getTwentyToHundred();
//                    iec411LessSeventy.setTenToTwenty(twentyToHundred++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) {
//                    int zeroOneToZeroTwo = iec411LessSeventy.getZeroOneToZeroTwo();
//                    iec411LessSeventy.setTenToTwenty(zeroOneToZeroTwo++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) {
//                    int zeroTwoToZeroFive = iec411LessSeventy.getZeroTwoToZeroFive();
//                    iec411LessSeventy.setTenToTwenty(zeroTwoToZeroFive++);
//                }
//                if (!"0".equals(iec411VO.getZeroPiontFive1S())) {
//                    int zeroFiveToOne = iec411LessSeventy.getZeroFiveToOne();
//                    iec411LessSeventy.setTenToTwenty(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec411VO.getGreater1S())) {
//                    int lessOne = iec411LessSeventy.getLessOne();
//                    iec411LessSeventy.setTenToTwenty(lessOne++);
//                }
//            }
//
//            /**
//             * ================第一张表结束======================
//             */
//
//            DISDIPCountParam disdipEqualTen = new DISDIPCountParam();
//
//            for (DISDIPVO disdipvo : equalTenDISDIP) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(disdipEqualTen.getName())) {
//                    disdipEqualTen.setName(disdipvo.getName());
//                }
//
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(disdipvo.getTwentyMs())) {
//                    int twenty = disdipEqualTen.getTwenty();
//                    disdipEqualTen.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getOneHundredMs())) {
//                    int oneHundredMS = disdipEqualTen.getOneHundredMS();
//                    disdipEqualTen.setOneHundredMS(oneHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getFiveHundredMs())) {
//                    int fiveHundredMS = disdipEqualTen.getFiveHundredMS();
//                    disdipEqualTen.setOneHundredMS(fiveHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getOneS())) {
//                    int one = disdipEqualTen.getOne();
//                    disdipEqualTen.setOne(one++);
//                }
//                if (!"0".equals(disdipvo.getThreeS())) {
//                    int three = disdipEqualTen.getThree();
//                    disdipEqualTen.setOne(three++);
//                }
//                if (!"0".equals(disdipvo.getTwentyS())) {
//                    int twenty = disdipEqualTen.getTwenty();
//                    disdipEqualTen.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getSixtyS())) {
//                    int sixty = disdipEqualTen.getSixty();
//                    disdipEqualTen.setSixty(sixty++);
//                }
//                if (!"0".equals(disdipvo.getOneEightyS())) {
//                    int oneHundredAndEighty = disdipEqualTen.getOneHundredAndEighty();
//                    disdipEqualTen.setOneHundredAndEighty(oneHundredAndEighty++);
//                }
//            }
//
//            DISDIPCountParam disdipEqualForty = new DISDIPCountParam();
//
//            for (DISDIPVO disdipvo : equalFortyDISDIP) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(disdipEqualForty.getName())) {
//                    disdipEqualForty.setName(disdipvo.getName());
//                }
//
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(disdipvo.getTwentyMs())) {
//                    int twenty = disdipEqualForty.getTwenty();
//                    disdipEqualForty.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getOneHundredMs())) {
//                    int oneHundredMS = disdipEqualForty.getOneHundredMS();
//                    disdipEqualForty.setOneHundredMS(oneHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getFiveHundredMs())) {
//                    int fiveHundredMS = disdipEqualForty.getFiveHundredMS();
//                    disdipEqualForty.setOneHundredMS(fiveHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getOneS())) {
//                    int one = disdipEqualForty.getOne();
//                    disdipEqualForty.setOne(one++);
//                }
//                if (!"0".equals(disdipvo.getThreeS())) {
//                    int three = disdipEqualForty.getThree();
//                    disdipEqualForty.setOne(three++);
//                }
//                if (!"0".equals(disdipvo.getTwentyS())) {
//                    int twenty = disdipEqualForty.getTwenty();
//                    disdipEqualForty.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getSixtyS())) {
//                    int sixty = disdipEqualForty.getSixty();
//                    disdipEqualForty.setSixty(sixty++);
//                }
//                if (!"0".equals(disdipvo.getOneEightyS())) {
//                    int oneHundredAndEighty = disdipEqualForty.getOneHundredAndEighty();
//                    disdipEqualForty.setOneHundredAndEighty(oneHundredAndEighty++);
//                }
//            }
//
//            DISDIPCountParam disdipEqualSeventy = new DISDIPCountParam();
//
//            for (DISDIPVO disdipvo : equalSeventyDISDIP) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(disdipEqualSeventy.getName())) {
//                    disdipEqualSeventy.setName(disdipvo.getName());
//                }
//
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(disdipvo.getTwentyMs())) {
//                    int twenty = disdipEqualSeventy.getTwenty();
//                    disdipEqualSeventy.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getOneHundredMs())) {
//                    int oneHundredMS = disdipEqualSeventy.getOneHundredMS();
//                    disdipEqualSeventy.setOneHundredMS(oneHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getFiveHundredMs())) {
//                    int fiveHundredMS = disdipEqualSeventy.getFiveHundredMS();
//                    disdipEqualSeventy.setOneHundredMS(fiveHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getOneS())) {
//                    int one = disdipEqualSeventy.getOne();
//                    disdipEqualSeventy.setOne(one++);
//                }
//                if (!"0".equals(disdipvo.getThreeS())) {
//                    int three = disdipEqualSeventy.getThree();
//                    disdipEqualSeventy.setOne(three++);
//                }
//                if (!"0".equals(disdipvo.getTwentyS())) {
//                    int twenty = disdipEqualSeventy.getTwenty();
//                    disdipEqualSeventy.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getSixtyS())) {
//                    int sixty = disdipEqualSeventy.getSixty();
//                    disdipEqualSeventy.setSixty(sixty++);
//                }
//                if (!"0".equals(disdipvo.getOneEightyS())) {
//                    int oneHundredAndEighty = disdipEqualSeventy.getOneHundredAndEighty();
//                    disdipEqualSeventy.setOneHundredAndEighty(oneHundredAndEighty++);
//                }
//            }
//
//            DISDIPCountParam disdipEqualEighty = new DISDIPCountParam();
//
//            for (DISDIPVO disdipvo : equalEightyFiveDISDIP) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(disdipEqualEighty.getName())) {
//                    disdipEqualEighty.setName(disdipvo.getName());
//                }
//
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(disdipvo.getTwentyMs())) {
//                    int twenty = disdipEqualEighty.getTwenty();
//                    disdipEqualEighty.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getOneHundredMs())) {
//                    int oneHundredMS = disdipEqualEighty.getOneHundredMS();
//                    disdipEqualEighty.setOneHundredMS(oneHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getFiveHundredMs())) {
//                    int fiveHundredMS = disdipEqualEighty.getFiveHundredMS();
//                    disdipEqualEighty.setOneHundredMS(fiveHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getOneS())) {
//                    int one = disdipEqualEighty.getOne();
//                    disdipEqualEighty.setOne(one++);
//                }
//                if (!"0".equals(disdipvo.getThreeS())) {
//                    int three = disdipEqualEighty.getThree();
//                    disdipEqualEighty.setOne(three++);
//                }
//                if (!"0".equals(disdipvo.getTwentyS())) {
//                    int twenty = disdipEqualEighty.getTwenty();
//                    disdipEqualEighty.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getSixtyS())) {
//                    int sixty = disdipEqualEighty.getSixty();
//                    disdipEqualEighty.setSixty(sixty++);
//                }
//                if (!"0".equals(disdipvo.getOneEightyS())) {
//                    int oneHundredAndEighty = disdipEqualEighty.getOneHundredAndEighty();
//                    disdipEqualEighty.setOneHundredAndEighty(oneHundredAndEighty++);
//                }
//            }
//            DISDIPCountParam disdipEqualNinety = new DISDIPCountParam();
//
//            for (DISDIPVO disdipvo : equalNinetyDISDIP) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(disdipEqualNinety.getName())) {
//                    disdipEqualNinety.setName(disdipvo.getName());
//                }
//
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(disdipvo.getTwentyMs())) {
//                    int twenty = disdipEqualNinety.getTwenty();
//                    disdipEqualNinety.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getOneHundredMs())) {
//                    int oneHundredMS = disdipEqualNinety.getOneHundredMS();
//                    disdipEqualNinety.setOneHundredMS(oneHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getFiveHundredMs())) {
//                    int fiveHundredMS = disdipEqualNinety.getFiveHundredMS();
//                    disdipEqualNinety.setOneHundredMS(fiveHundredMS++);
//                }
//                if (!"0".equals(disdipvo.getOneS())) {
//                    int one = disdipEqualNinety.getOne();
//                    disdipEqualNinety.setOne(one++);
//                }
//                if (!"0".equals(disdipvo.getThreeS())) {
//                    int three = disdipEqualNinety.getThree();
//                    disdipEqualNinety.setOne(three++);
//                }
//                if (!"0".equals(disdipvo.getTwentyS())) {
//                    int twenty = disdipEqualNinety.getTwenty();
//                    disdipEqualNinety.setTwenty(twenty++);
//                }
//                if (!"0".equals(disdipvo.getSixtyS())) {
//                    int sixty = disdipEqualNinety.getSixty();
//                    disdipEqualNinety.setSixty(sixty++);
//                }
//                if (!"0".equals(disdipvo.getOneEightyS())) {
//                    int oneHundredAndEighty = disdipEqualNinety.getOneHundredAndEighty();
//                    disdipEqualNinety.setOneHundredAndEighty(oneHundredAndEighty++);
//                }
//            }
//
//            /**
//             * ======================第二张表结束==============================
//             */
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessOne = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessOneIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessOne.getName())) {
//                    iec28CountLessOne.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessOne.getZeroZeroTwoToZeroOne();
//                    iec28CountLessOne.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessOne.getZeroOneToZeroTwentyFive();
//                    iec28CountLessOne.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessOne.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessOne.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessOne.getZeroFiveToOne();
//                    iec28CountLessOne.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessOne.getOneToThree();
//                    iec28CountLessOne.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessOne.getThreeToTwenty();
//                    iec28CountLessOne.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessOne.getTwentyToSixty();
//                    iec28CountLessOne.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessOne.getSixtyToOneHundredAndEighty();
//                    iec28CountLessOne.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessTen = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessTenIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessTen.getName())) {
//                    iec28CountLessTen.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessTen.getZeroZeroTwoToZeroOne();
//                    iec28CountLessTen.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessTen.getZeroOneToZeroTwentyFive();
//                    iec28CountLessTen.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessTen.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessTen.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessTen.getZeroFiveToOne();
//                    iec28CountLessTen.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessTen.getOneToThree();
//                    iec28CountLessTen.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessTen.getThreeToTwenty();
//                    iec28CountLessTen.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessTen.getTwentyToSixty();
//                    iec28CountLessTen.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessTen.getSixtyToOneHundredAndEighty();
//                    iec28CountLessTen.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessTwenty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessTwentyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessTwenty.getName())) {
//                    iec28CountLessTwenty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessTwenty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessTwenty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessTwenty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessTwenty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessTwenty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessTwenty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessTwenty.getZeroFiveToOne();
//                    iec28CountLessTwenty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessTwenty.getOneToThree();
//                    iec28CountLessTwenty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessTwenty.getThreeToTwenty();
//                    iec28CountLessTwenty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessTwenty.getTwentyToSixty();
//                    iec28CountLessTwenty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessTwenty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessTwenty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessThirty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessThirtyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessThirty.getName())) {
//                    iec28CountLessThirty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessThirty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessThirty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessThirty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessThirty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessThirty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessThirty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessThirty.getZeroFiveToOne();
//                    iec28CountLessThirty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessThirty.getOneToThree();
//                    iec28CountLessThirty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessThirty.getThreeToTwenty();
//                    iec28CountLessThirty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessThirty.getTwentyToSixty();
//                    iec28CountLessThirty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessThirty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessThirty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessForty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessFortyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessForty.getName())) {
//                    iec28CountLessForty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessForty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessForty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessForty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessForty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessForty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessForty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessForty.getZeroFiveToOne();
//                    iec28CountLessForty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessForty.getOneToThree();
//                    iec28CountLessForty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessForty.getThreeToTwenty();
//                    iec28CountLessForty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessForty.getTwentyToSixty();
//                    iec28CountLessForty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessForty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessForty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessFifty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessFiftyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessFifty.getName())) {
//                    iec28CountLessFifty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessFifty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessFifty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessFifty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessFifty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessFifty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessFifty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessFifty.getZeroFiveToOne();
//                    iec28CountLessFifty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessFifty.getOneToThree();
//                    iec28CountLessFifty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessFifty.getThreeToTwenty();
//                    iec28CountLessFifty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessFifty.getTwentyToSixty();
//                    iec28CountLessFifty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessFifty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessFifty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessSixty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessSixtyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessSixty.getName())) {
//                    iec28CountLessSixty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessSixty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessSixty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessSixty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessSixty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessSixty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessSixty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessSixty.getZeroFiveToOne();
//                    iec28CountLessSixty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessSixty.getOneToThree();
//                    iec28CountLessSixty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessSixty.getThreeToTwenty();
//                    iec28CountLessSixty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessSixty.getTwentyToSixty();
//                    iec28CountLessSixty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessSixty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessSixty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessSeventy = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessSeventyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessSeventy.getName())) {
//                    iec28CountLessSeventy.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessSeventy.getZeroZeroTwoToZeroOne();
//                    iec28CountLessSeventy.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessSeventy.getZeroOneToZeroTwentyFive();
//                    iec28CountLessSeventy.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessSeventy.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessSeventy.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessSeventy.getZeroFiveToOne();
//                    iec28CountLessSeventy.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessSeventy.getOneToThree();
//                    iec28CountLessSeventy.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessSeventy.getThreeToTwenty();
//                    iec28CountLessSeventy.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessSeventy.getTwentyToSixty();
//                    iec28CountLessSeventy.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessSeventy.getSixtyToOneHundredAndEighty();
//                    iec28CountLessSeventy.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessEighty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessEightyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessEighty.getName())) {
//                    iec28CountLessEighty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessEighty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessEighty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessEighty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessEighty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessEighty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessEighty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessEighty.getZeroFiveToOne();
//                    iec28CountLessEighty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessEighty.getOneToThree();
//                    iec28CountLessEighty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessEighty.getThreeToTwenty();
//                    iec28CountLessEighty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessEighty.getTwentyToSixty();
//                    iec28CountLessEighty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessEighty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessEighty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessNinety = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessNinetyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessNinety.getName())) {
//                    iec28CountLessNinety.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessNinety.getZeroZeroTwoToZeroOne();
//                    iec28CountLessNinety.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessNinety.getZeroOneToZeroTwentyFive();
//                    iec28CountLessNinety.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessNinety.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessNinety.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessNinety.getZeroFiveToOne();
//                    iec28CountLessNinety.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessNinety.getOneToThree();
//                    iec28CountLessNinety.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessNinety.getThreeToTwenty();
//                    iec28CountLessNinety.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessNinety.getTwentyToSixty();
//                    iec28CountLessNinety.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessNinety.getSixtyToOneHundredAndEighty();
//                    iec28CountLessNinety.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessHundredTwenty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessHundredTwentyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessHundredTwenty.getName())) {
//                    iec28CountLessHundredTwenty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessHundredTwenty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessHundredTwenty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessHundredTwenty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessHundredTwenty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredTwenty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessHundredTwenty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessHundredTwenty.getZeroFiveToOne();
//                    iec28CountLessHundredTwenty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessHundredTwenty.getOneToThree();
//                    iec28CountLessHundredTwenty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessHundredTwenty.getThreeToTwenty();
//                    iec28CountLessHundredTwenty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessHundredTwenty.getTwentyToSixty();
//                    iec28CountLessHundredTwenty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessHundredTwenty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessHundredTwenty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessHundredThirty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessHundredThirtyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessHundredThirty.getName())) {
//                    iec28CountLessHundredThirty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessHundredThirty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessHundredThirty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessHundredThirty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessHundredThirty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredThirty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessHundredThirty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessHundredThirty.getZeroFiveToOne();
//                    iec28CountLessHundredThirty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessHundredThirty.getOneToThree();
//                    iec28CountLessHundredThirty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessHundredThirty.getThreeToTwenty();
//                    iec28CountLessHundredThirty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessHundredThirty.getTwentyToSixty();
//                    iec28CountLessHundredThirty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessHundredThirty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessHundredThirty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessHundredForty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessHundredFortyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessHundredForty.getName())) {
//                    iec28CountLessHundredForty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessHundredForty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessHundredForty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessHundredForty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessHundredForty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredForty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessHundredForty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessHundredForty.getZeroFiveToOne();
//                    iec28CountLessHundredForty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessHundredForty.getOneToThree();
//                    iec28CountLessHundredForty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessHundredForty.getThreeToTwenty();
//                    iec28CountLessHundredForty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessHundredForty.getTwentyToSixty();
//                    iec28CountLessHundredForty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessHundredForty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessHundredForty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessHundredFifty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessHundredFiftyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessHundredFifty.getName())) {
//                    iec28CountLessHundredFifty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessHundredFifty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessHundredFifty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessHundredFifty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessHundredFifty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredFifty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessHundredFifty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessHundredFifty.getZeroFiveToOne();
//                    iec28CountLessHundredFifty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessHundredFifty.getOneToThree();
//                    iec28CountLessHundredFifty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessHundredFifty.getThreeToTwenty();
//                    iec28CountLessHundredFifty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessHundredFifty.getTwentyToSixty();
//                    iec28CountLessHundredFifty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessHundredFifty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessHundredFifty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessHundredSixty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessHundredSixtyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessHundredSixty.getName())) {
//                    iec28CountLessHundredSixty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessHundredSixty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessHundredSixty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessHundredSixty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessHundredSixty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredSixty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessHundredSixty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessHundredSixty.getZeroFiveToOne();
//                    iec28CountLessHundredSixty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessHundredSixty.getOneToThree();
//                    iec28CountLessHundredSixty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessHundredSixty.getThreeToTwenty();
//                    iec28CountLessHundredSixty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessHundredSixty.getTwentyToSixty();
//                    iec28CountLessHundredSixty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessHundredSixty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessHundredSixty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessHundredSeventy = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessHundredSeventyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessHundredSeventy.getName())) {
//                    iec28CountLessHundredSeventy.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessHundredSeventy.getZeroZeroTwoToZeroOne();
//                    iec28CountLessHundredSeventy.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessHundredSeventy.getZeroOneToZeroTwentyFive();
//                    iec28CountLessHundredSeventy.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredSeventy.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessHundredSeventy.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessHundredSeventy.getZeroFiveToOne();
//                    iec28CountLessHundredSeventy.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessHundredSeventy.getOneToThree();
//                    iec28CountLessHundredSeventy.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessHundredSeventy.getThreeToTwenty();
//                    iec28CountLessHundredSeventy.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessHundredSeventy.getTwentyToSixty();
//                    iec28CountLessHundredSeventy.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessHundredSeventy.getSixtyToOneHundredAndEighty();
//                    iec28CountLessHundredSeventy.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//
//            //创建计数对象
//            IEC28CountParam iec28CountLessHundredEighty = new IEC28CountParam();
//
//            for (IEC28VO iec28VO : lessHundredEightyIEC28) {
//                //获取当前剩余电压名称,不为空就进行添加
//                if (Objects.isNull(iec28CountLessHundredEighty.getName())) {
//                    iec28CountLessHundredEighty.setName(iec28VO.getName());
//                }
//                //如果参数不等于0对对象中的参数进行++
//                if (!"0".equals(iec28VO.getQ())) {
//                    int zeroZeroTwoToZeroOne = iec28CountLessHundredEighty.getZeroZeroTwoToZeroOne();
//                    iec28CountLessHundredEighty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
//                }
//                if (!"0".equals(iec28VO.getW())) {
//                    int zeroOneToZeroTwentyFive = iec28CountLessHundredEighty.getZeroOneToZeroTwentyFive();
//                    iec28CountLessHundredEighty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
//                }
//                if (!"0".equals(iec28VO.getE())) {
//                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredEighty.getZeroTwentyFiveToZeroFive();
//                    iec28CountLessHundredEighty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
//                }
//                if (!"0".equals(iec28VO.getR())) {
//                    int zeroFiveToOne = iec28CountLessHundredEighty.getZeroFiveToOne();
//                    iec28CountLessHundredEighty.setZeroFiveToOne(zeroFiveToOne++);
//                }
//                if (!"0".equals(iec28VO.getT())) {
//                    int oneToThree = iec28CountLessHundredEighty.getOneToThree();
//                    iec28CountLessHundredEighty.setOneToThree(oneToThree++);
//                }
//                if (!"0".equals(iec28VO.getY())) {
//                    int threeToTwenty = iec28CountLessHundredEighty.getThreeToTwenty();
//                    iec28CountLessHundredEighty.setThreeToTwenty(threeToTwenty++);
//                }
//                if (!"0".equals(iec28VO.getU())) {
//                    int twentyToSixty = iec28CountLessHundredEighty.getTwentyToSixty();
//                    iec28CountLessHundredEighty.setTwentyToSixty(twentyToSixty++);
//                }
//                if (!"0".equals(iec28VO.getI())) {
//                    int sixtyToOneHundredAndEighty = iec28CountLessHundredEighty.getSixtyToOneHundredAndEighty();
//                    iec28CountLessHundredEighty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
//                }
//            }
//
//            /**
//             * =========================第三张表结束===============================
//             */
//
//
//            //汇总放入集合
//            List<IEC411CountParam> iec411Result = new ArrayList<>();
//            iec411Result.add(iec411LessOne);
//            iec411Result.add(iec411LessForty);
//            iec411Result.add(iec411LessSeventy);
//
//            List<DISDIPCountParam> disdipResult = new ArrayList<>();
//            disdipResult.add(disdipEqualTen);
//            disdipResult.add(disdipEqualForty);
//            disdipResult.add(disdipEqualSeventy);
//            disdipResult.add(disdipEqualEighty);
//            disdipResult.add(disdipEqualNinety);
//
//            List<IEC28CountParam> iec28Result = new ArrayList<>();
//            iec28Result.add(iec28CountLessOne);
//            iec28Result.add(iec28CountLessTen);
//            iec28Result.add(iec28CountLessTwenty);
//            iec28Result.add(iec28CountLessThirty);
//            iec28Result.add(iec28CountLessForty);
//            iec28Result.add(iec28CountLessFifty);
//            iec28Result.add(iec28CountLessSixty);
//            iec28Result.add(iec28CountLessSeventy);
//            iec28Result.add(iec28CountLessEighty);
//            iec28Result.add(iec28CountLessNinety);
//            iec28Result.add(iec28CountLessHundredTwenty);
//            iec28Result.add(iec28CountLessHundredThirty);
//            iec28Result.add(iec28CountLessHundredForty);
//            iec28Result.add(iec28CountLessHundredFifty);
//            iec28Result.add(iec28CountLessHundredSixty);
//            iec28Result.add(iec28CountLessHundredSeventy);
//            iec28Result.add(iec28CountLessHundredEighty);
//
//
//            Map<String, Integer> resultMap = new HashMap<>();
//
//            for (int i = 0; i < iec28Result.size(); i++) {
//
//                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getSixtyToOneHundredAndEighty());
//                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getOneToThree());
//                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroFiveToOne());
//                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroOneToZeroTwentyFive());
//                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroTwentyFiveToZeroFive());
//                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getThreeToTwenty());
//                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getTwentyToSixty());
//                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroZeroTwoToZeroOne());
//            }
//
//            //todo 还要对集合中哪个次数最多挑出第一位
//            Map<String, Integer> linkMap = getSort(resultMap);
//
//            //存放结果的集合
//            List<String> resultList = new ArrayList<String>();
//
//            for (String s : linkMap.keySet()) {
//                resultList.add(s);
//                resultList.add(linkMap.get(s).toString());
//            }
//
//            //最多暂降事件名称
//            for (int i = 0; i < iec28Result.size(); i++) {
//                if (iec28Result.get(i).getName().equals(resultList.get(0))) {
//                    if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroZeroTwoToZeroOne()))) {
//                        resultList.add("0.02~0.1");
//                        break;
//                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroOneToZeroTwentyFive()))) {
//                        resultList.add("0.1~0.25");
//                        break;
//                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroTwentyFiveToZeroFive()))) {
//                        resultList.add("0.25~0.5");
//                        break;
//                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroFiveToOne()))) {
//                        resultList.add("0.5~1");
//                        break;
//                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getOneToThree()))) {
//                        resultList.add("1~3");
//                        break;
//                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getThreeToTwenty()))) {
//                        resultList.add("3~20");
//                        break;
//                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getTwentyToSixty()))) {
//                        resultList.add("20~60");
//                        break;
//                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getSixtyToOneHundredAndEighty()))) {
//                        resultList.add("60~180");
//                        break;
//                    }
//                }
//            }
//            //System.out.println(resultList);
//
//
//            //3.1密度密度表格
//            if (areaReportParam.isDensityTable()) {
//                //创建表题计数
//                int twoCount = 1;
//
//                //同步给暂降密度图
//                oneCount4 = oneCount;
//
//                createTitle(doc, "4." + oneCount + " " + typeName + "密度", "标题 2", 200, 11);
//
//                p = doc.createParagraph();// 新建一个段落
//                p.setAlignment(ParagraphAlignment.BOTH);
//                XWPFRun r12 = p.createRun();//创建段落文本
//                r12.setText("  " + typeName + "密度统计可以从幅值和持续时间两个维度直接地反映" + typeName + "事件发生情况，主要反应事件的发生次数，" +
//                        "中国电网在所选择的分析时间内" + typeName + "事件主要集中在幅值为" + resultList.get(0) + "，持续时间为" + resultList.get(2) + "[根据 IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)算出" + typeName + "事件发生最多的区间],具体见表（图）：");
//                r12.setFontSize(11);//字体大小
//
//
//                createTitle(doc, "4." + oneCount + "." + twoCount + " DISDIP表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 11);
//
//                //第一张表
//                XWPFTable monitorInfo = createTable(doc);
//                XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc);
//
//                // 表格第一行
//                insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s");
//
//
//                //塞入数据
//                for (int i = 0; i < disdipResult.size(); i++) {
//                    insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, disdipResult.get(i).getName(), String.valueOf(disdipResult.get(i).getTwentyMS()),
//                            String.valueOf(disdipResult.get(i).getOneHundredMS()), String.valueOf(disdipResult.get(i).getFiveHundredMS()), String.valueOf(disdipResult.get(i).getOne()), String.valueOf(disdipResult.get(i).getThree()),
//                            String.valueOf(disdipResult.get(i).getTwenty()), String.valueOf(disdipResult.get(i).getSixty()), String.valueOf(disdipResult.get(i).getOneHundredAndEighty()));
//                }
//
//                twoCount++;
//
//
//                createTitle(doc, "4." + oneCount + "." + twoCount + " IEC 61000-4-11:(用电终端的电压" + typeName + "抗度)", "标题 3", 400, 11);
//
//                //第二张表
//                XWPFTable monitorInfo1 = createTable(doc);
//                XWPFParagraph monitorInfoExcelParagraph1 = WordUtils.getCenterParagraph(doc);
//
//                // 表格第一行
//                insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");
//
//
//                //塞入数据
//                for (int i = 0; i < iec411Result.size(); i++) {
//                    insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, false, iec411Result.get(i).getName(), String.valueOf(iec411Result.get(i).getTenToTwenty()), String.valueOf(iec411Result.get(i).getTwentyToHundred()),
//                            String.valueOf(iec411Result.get(i).getZeroOneToZeroTwo()), String.valueOf(iec411Result.get(i).getZeroTwoToZeroFive()), String.valueOf(iec411Result.get(i).getZeroFiveToOne()), String.valueOf(iec411Result.get(i).getLessOne()));
//                }
//
//                twoCount++;
//
//
//                createTitle(doc, "4." + oneCount + "." + twoCount + " IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)", "标题 3", 400, 11);
//
//                //第二张表
//                XWPFTable monitorInfo2 = createTable(doc);
//                XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc);
//
//                // 表格第一行
//                insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5~1s", "1~3s", "3~20s", "20~60s", "60~180s");
//
//
//                //塞入数据
//                for (int i = 0; i < iec28Result.size(); i++) {
//                    insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, iec28Result.get(i).getName(), String.valueOf(iec28Result.get(i).getZeroZeroTwoToZeroOne()), String.valueOf(iec28Result.get(i).getZeroOneToZeroTwentyFive()),
//                            String.valueOf(iec28Result.get(i).getZeroTwentyFiveToZeroFive()), String.valueOf(iec28Result.get(i).getZeroFiveToOne()), String.valueOf(iec28Result.get(i).getOneToThree()), String.valueOf(iec28Result.get(i).getThreeToTwenty()),
//                            String.valueOf(iec28Result.get(i).getTwentyToSixty()), String.valueOf(iec28Result.get(i).getSixtyToOneHundredAndEighty()));
//                }
//
//                //同步给暂降密度表格
//                twoCount1 = twoCount;
//                //序号计数进行++
//                oneCount++;
//            }
//
//            //3.2暂降密度图表
//            if (areaReportParam.isDensityChart()) {
//
//                //如果暂降幅值被勾选,就不需要进行写段落
//                if (areaReportParam.isDensityTable()) {
//                    twoCount1++;
//
//                    //如果幅值图存在与幅值的序号保持同步
//                    createTitle(doc, "4." + oneCount4 + "." + twoCount1 + " " + typeName + "密度图", "标题 3", 400, 11);
//
//                    //代码
//                    List<EventDetail> eventDetails = BeanUtil.copyToList(info, EventDetail.class);
//                    Integer[][] eventDensityData = eventReportService.getCoords(eventDetails);
//                    String str = drawPicUtil.drawEventDensity(eventDensityData);
//                    createPic(doc, str, "" + typeName + "密度图形");
//                } else {
//                    int twoCount = 1;
//                    createTitle(doc, "4." + oneCount + " " + typeName + "密度", "标题 2", 200, 11);
//
//                    p = doc.createParagraph();// 新建一个段落
//                    p.setAlignment(ParagraphAlignment.BOTH);
//                    XWPFRun r12 = p.createRun();//创建段落文本
//                    r12.setText("  " + typeName + "密度统计可以从幅值和持续时间两个维度直接地反映" + typeName + "事件发生情况，主要反应事件的发生次数，" +
//                            "中国电网在所选择的分析时间内" + typeName + "事件主要集中在幅值为" + resultList.get(0) + "，持续时间为" + resultList.get(2) + "[根据 IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)算出" + typeName + "事件发生最多的区间],具体见表（图）：");
//                    r12.setFontSize(11);//字体大小
//
//
//                    createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "密度图", "标题 3", 400, 11);
//
//
//                    //代码
//                    List<EventDetail> eventDetails = BeanUtil.copyToList(info, EventDetail.class);
//                    Integer[][] eventDensityData = eventReportService.getCoords(eventDetails);
//                    String str = drawPicUtil.drawEventDensity(eventDensityData);
//                    createPic(doc, str, "" + typeName + "密度图形");
//
//                    //序号计数进行++
//                    oneCount++;
//                }
//            }
//        }
        //密度图代码有问题
//3.暂降密度
        if (areaReportParam.isDensityTable() || areaReportParam.isDensityChart()) {
            int i  = oneCount;
            createTitle(doc, "4." + i + " 暂降密度", "标题 2", 200, 15);
            int two = 1;
            if (areaReportParam.isDensityTable()) {
                createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
                Integer[][] eventDensityData = eventReportService.getCoords(eventDetails);
                String str = drawPicUtil.drawEventDensity(eventDensityData);
                createPic(doc, str, "暂降密度图");
                two++;
            }
            if (areaReportParam.isDensityChart()) {
                XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
                createTitle(doc, "4." + i + "." + two + " DISDIP 表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 15);
//                List<DISDIPVO> eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
                List<DISDIPVO> eventDisdip = eventReportService.eventDisdip(eventDetails);

                XWPFTable table1 = createTable(doc);
                insertRow(doc, table1, centerParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s");
                for (int j = 0; j < eventDisdip.size(); j++) {
                    DISDIPVO disdipvo = eventDisdip.get(j);
                    insertRow(doc, table1, centerParagraph, false, disdipvo.getName(), disdipvo.getTwentyMs(), disdipvo.getOneHundredMs(), disdipvo.getFiveHundredMs(), disdipvo.getOneS(), disdipvo.getThreeS(), disdipvo.getTwentyS(), disdipvo.getSixtyS(), disdipvo.getOneEightyS());
                }
                two++;
                createTitle(doc, "4." + i + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 15);
//                List<IEC411VO> iec411VOS = eventAnalysisService.IEC411(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
                List<IEC411VO> iec411VOS = eventReportService.IEC411(eventDetails);
                XWPFTable table2 = createTable(doc);
                insertRow(doc, table2, centerParagraph, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");
                for (int j = 0; j < iec411VOS.size(); j++) {
                    IEC411VO iec411VO = iec411VOS.get(j);
                    insertRow(doc, table2, centerParagraph, false, iec411VO.getName(), iec411VO.getTenTwentyMs(), iec411VO.getTwentyOneHundredMs(), iec411VO.getZeroPiontOneTwoS(), iec411VO.getZeroPiontTwoFiveS(), iec411VO.getZeroPiontFive1S(), iec411VO.getGreater1S());
                }
                two++;
                createTitle(doc, "4." + i + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 15);
//                List<IEC28VO> iec28VOS = eventAnalysisService.IEC28(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
                List<IEC28VO> iec28VOS = eventReportService.IEC28(eventDetails);
                XWPFTable table3 = createTable(doc);
                insertRow(doc, table3, centerParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5s~1s", "1~3s", "3~20s", "20~60s", "60~180s");
                for (int j = 0; j < iec28VOS.size(); j++) {
                    IEC28VO iec28VO = iec28VOS.get(j);
                    insertRow(doc, table3, centerParagraph, false, iec28VO.getName(), iec28VO.getQ(), iec28VO.getW(), iec28VO.getE(), iec28VO.getR(), iec28VO.getT(), iec28VO.getY(), iec28VO.getU(), iec28VO.getI());
                }
                two++;
            }
            oneCount++;
        }
        //4.itic图
        if (areaReportParam.isItic()) {
            //itic图
            List<EventDetailNew> detailList = eventDetailList;

            List<OB> obs = new ArrayList<>();
            ArrayList<List<Double>> list = new ArrayList<>();
            for (EventDetailNew eventDetail : detailList) {
                obs.add(new OB(Double.parseDouble(eventDetail.getDuration() + "")
                        , Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + "")));

                ArrayList<Double> doubles = new ArrayList<>();
                doubles.add(Double.parseDouble(eventDetail.getDuration() + ""));
                doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
                list.add(doubles);
            }

            List<Integer> result = getITICArea(obs);

            /**
             * =========================续写word文档==============================================
             */
            //创建表题计数
            int twoCount = 1;

            oneCount3 = oneCount;

            createTitle(doc, "4." + oneCount3 + " " + typeName + "事件点图", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            r12.setText("  " + typeName + "事件点图统计分成ITIC曲线和F47曲线展示。");
            r12.setFontSize(11);//字体大小


            createTitle(doc, "4." + oneCount3 + "." + twoCount + " ITIC 曲线", "标题 3", 400, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r13 = p.createRun();//创建段落文本
            r13.setText("  ITIC曲线中可容忍" + typeName + "记录为：" + result.get(0) + "条；不可容忍" + typeName + "记录为：" + result.get(1) + "条，具体见下表（图）：");
            r13.setFontSize(11);//字体大小


            String itic = drawPicUtil.drawItic(list);
            createPic(doc, itic, "ITIC曲线");


            twoCount5 = twoCount;
            //序号计数进行++
            oneCount++;

            /**
             * =======================================word结束=========================================
             */


        }

        //5.f47图
        if (areaReportParam.isF47()) {
            //f47图
            List<EventDetailNew> detailList = eventDetailList;

            List<OB> obs = new ArrayList<>();

            ArrayList<List<Double>> list = new ArrayList<>();
            for (EventDetailNew eventDetail : detailList) {
                obs.add(new OB(Double.parseDouble(eventDetail.getDuration()  + ""), Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + "")));

                ArrayList<Double> doubles = new ArrayList<>();
                doubles.add(Double.parseDouble(eventDetail.getDuration() + ""));
                doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
                list.add(doubles);
            }


            List<Integer> result = getF47Area(obs);

            /**
             * =========================续写word文档==============================================
             */

            if (areaReportParam.isItic()) {
                twoCount5++;

                createTitle(doc, "4." + oneCount3 + "." + twoCount5 + " F47 曲线", "标题 3", 400, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r13 = p.createRun();//创建段落文本
                r13.setText("  F47曲线中可容忍" + typeName + "记录为：" + result.get(0) + "条；不可容忍" + typeName + "记录为：" + result.get(1) + "条，具体见下表（图）：");
                r13.setFontSize(11);//字体大小

                String f47 = drawPicUtil.drawF47(list);
                createPic(doc, f47, "SEMI F47曲线");

                /**
                 * =======================================word结束=========================================
                 */
            } else {
                //创建表题计数
                int twoCount = 1;

                oneCount3 = oneCount;

                createTitle(doc, "4." + oneCount + " " + typeName + "事件点图", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + typeName + "事件点图统计分成ITIC曲线和F47曲线展示。");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " F47 曲线", "标题 3", 400, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r13 = p.createRun();//创建段落文本
                r13.setText("  F47曲线中可容忍" + typeName + "降记录为：" + result.get(0) + "条；不可容忍" + typeName + "记录为：" + result.get(1) + "条，具体见下表（图）：");
                r13.setFontSize(11);//字体大小


                String f47 = drawPicUtil.drawF47(list);
                createPic(doc, f47, "SEMI F47曲线");


                //序号计数进行++
                oneCount++;

                /**
                 * =======================================word结束=========================================
                 */
            }


        }

        //6.暂降增幅

//        if (areaReportParam.isSagAmplitude()) {
//            //暂降分布幅值
//            //创建结果集合
//            List<EventDetailNew> info = eventDetailList;
//
//            //将sql结果集放入,共用一个sql,减少查询时间
//            AreaTableParam areaTableParam1 = new AreaTableParam();
//            areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
//            areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
//            areaTableParam1.setInfo(info);
//            ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1);
//
//
//            List<String> eventvalue = probabilityDistributionArea.getEventvalue();
//
//            List<AmplitudeCountParam> amplitudeList = new ArrayList<>();
//
//            List<String> xName = new ArrayList<>();
//            xName.add("0");
//            xName.add("10%");
//            xName.add("20%");
//            xName.add("30%");
//            xName.add("40%");
//            xName.add("50%");
//            xName.add("60%");
//            xName.add("70%");
//            xName.add("80%");
//            xName.add("90%");
//            //将幅值绑定对应的x值,放入集合
//            for (int i = 0; i < eventvalue.size(); i++) {
//                AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam();
//                amplitudeCountParam.setXName(xName.get(i));
//                amplitudeCountParam.setYValue(eventvalue.get(i));
//                amplitudeList.add(amplitudeCountParam);
//            }
//            //存储幅值结果集合
//            List<String> amplitudeResult = new ArrayList<>();
//            for (int i = 1; i < amplitudeList.size(); i++) {
//                if (!amplitudeList.get(i).getYValue().equals(amplitudeList.get(i - 1).getYValue())) {
//                    amplitudeResult.add(amplitudeList.get(i - 1).getXName());
//                    amplitudeResult.add(amplitudeList.get(i).getXName());
//                    break;
//                } else if (amplitudeList.get(0).getYValue().equals(amplitudeList.get(amplitudeList.size() - 1).getYValue())) {
//                    amplitudeResult.add(amplitudeList.get(0).getXName());
//                    amplitudeResult.add(amplitudeList.get(amplitudeList.size() - 1).getXName());
//                    break;
//                }
//            }
//
//
//            List<String> eventvalue1 = probabilityDistributionArea.getSisttime();
//
//            List<AmplitudeCountParam> amplitudeList1 = new ArrayList<>();
//
//            List<String> xName1 = new ArrayList<>();
//            xName1.add("0.01");
//            xName1.add("0.1");
//            xName1.add("0.25");
//            xName1.add("0.5");
//            xName1.add("1");
//            xName1.add("3");
//            xName1.add("20");
//            xName1.add("60");
//            xName1.add("180");
//            //将幅值绑定对应的x值,放入集合
//            for (int i = 0; i < eventvalue1.size(); i++) {
//                AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam();
//                amplitudeCountParam.setXName(xName1.get(i));
//                amplitudeCountParam.setYValue(eventvalue1.get(i));
//                amplitudeList1.add(amplitudeCountParam);
//            }
//            //存储幅值结果集合
////            List<String> amplitudeResult1 = new ArrayList<>();
//            for (int i = 1; i < amplitudeList1.size(); i++) {
//                if (!amplitudeList1.get(i).getYValue().equals(amplitudeList1.get(i - 1).getYValue())) {
//                    amplitudeResult1.add(amplitudeList1.get(i - 1).getXName());
//                    amplitudeResult1.add(amplitudeList1.get(i).getXName());
//                    break;
//                } else if (amplitudeList1.get(0).getYValue().equals(amplitudeList1.get(amplitudeList1.size() - 1).getYValue())) {
//                    amplitudeResult1.add(amplitudeList1.get(0).getXName());
//                    amplitudeResult1.add(amplitudeList1.get(amplitudeList1.size() - 1).getXName());
//                    break;
//                }
//            }
//
//
//            /**
//             * =========================续写word文档==============================================
//             */
//            //创建表题计数
//            int twoCount = 1;
//
//            oneCount2 = oneCount;
//
//            createTitle(doc, "4." + oneCount2 + " " + typeName + "幅值概率分布图", "标题 2", 200, 11);
//
//            p = doc.createParagraph();// 新建一个段落
//            p.setAlignment(ParagraphAlignment.BOTH);
//            XWPFRun r12 = p.createRun();//创建段落文本
//            r12.setText("  " + typeName + "概率分布图分成" + typeName + "幅值概率分布和持续时间概率分布图，中国电网在所选择的分析时间内" + typeName + "事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间，" +
//                    "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序，选择" + typeName + "记录发生最多的区域]，如下表（图）：");
//            r12.setFontSize(11);//字体大小
//
//
//            createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "幅值的概率分布", "标题 3", 400, 11);
//
//
//            List<String> ybardata = probabilityDistributionArea.getPereventvalue();
//            List<String> ylinedata = probabilityDistributionArea.getEventvalue();
//            String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
//            createPic(doc, fz, "" + typeName + "幅值的概率分布");
//
//
//            //序号计数进行++
//            oneCount++;
//
//            /**
//             * =======================================word结束=========================================
//             */
//
//        }

        //7.暂降持续时间
//        if (areaReportParam.isDuration()) {
//
//            //持续时间概率分布
//            AreaTableParam areaTableParam = new AreaTableParam();
//
//            //创建结果集合
//            List<EventDetailNew> info = eventDetailList;
//
//            //将sql结果集放入,共用一个sql,减少查询时间
//            AreaTableParam areaTableParam1 = new AreaTableParam();
//            areaTableParam1.setInfo(info);
//            ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1);
//
//            List<String> eventvalue = probabilityDistributionArea.getEventvalue();
//            List<AmplitudeCountParam> amplitudeList = new ArrayList<>();
//
//            List<String> xName = new ArrayList<>();
//            xName.add("0");
//            xName.add("10%");
//            xName.add("20%");
//            xName.add("30%");
//            xName.add("40%");
//            xName.add("50%");
//            xName.add("60%");
//            xName.add("70%");
//            xName.add("80%");
//            xName.add("90%");
//            //将幅值绑定对应的x值,放入集合
//            for (int i = 0; i < eventvalue.size(); i++) {
//                AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam();
//                amplitudeCountParam.setXName(xName.get(i));
//                amplitudeCountParam.setYValue(eventvalue.get(i));
//                amplitudeList.add(amplitudeCountParam);
//            }
//            //存储幅值结果集合
//            List<String> amplitudeResult = new ArrayList<>();
//            for (int i = 1; i < amplitudeList.size(); i++) {
//                if (!amplitudeList.get(i).getYValue().equals(amplitudeList.get(i - 1).getYValue())) {
//                    amplitudeResult.add(amplitudeList.get(i - 1).getXName());
//                    amplitudeResult.add(amplitudeList.get(i).getXName());
//                    break;
//                } else if (amplitudeList.get(0).getYValue().equals(amplitudeList.get(amplitudeList.size() - 1).getYValue())) {
//                    amplitudeResult.add(amplitudeList.get(0).getXName());
//                    amplitudeResult.add(amplitudeList.get(amplitudeList.size() - 1).getXName());
//                    break;
//                }
//            }
//
//
//            List<String> eventvalue1 = probabilityDistributionArea.getSisttime();
//
//            List<AmplitudeCountParam> amplitudeList1 = new ArrayList<>();
//
//            List<String> xName1 = new ArrayList<>();
//            xName1.add("0.01");
//            xName1.add("0.1");
//            xName1.add("0.25");
//            xName1.add("0.5");
//            xName1.add("1");
//            xName1.add("3");
//            xName1.add("20");
//            xName1.add("60");
//            xName1.add("180");
//            //将幅值绑定对应的x值,放入集合
//            for (int i = 0; i < eventvalue1.size(); i++) {
//                AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam();
//                amplitudeCountParam.setXName(xName1.get(i));
//                amplitudeCountParam.setYValue(eventvalue1.get(i));
//                amplitudeList1.add(amplitudeCountParam);
//            }
//            //存储幅值结果集合
//            List<String> amplitudeResult1 = new ArrayList<>();
//            for (int i = 1; i < amplitudeList1.size(); i++) {
//                if (!amplitudeList1.get(i).getYValue().equals(amplitudeList1.get(i - 1).getYValue())) {
//                    amplitudeResult1.add(amplitudeList1.get(i - 1).getXName());
//                    amplitudeResult1.add(amplitudeList1.get(i).getXName());
//                    break;
//                } else if (amplitudeList1.get(0).getYValue().equals(amplitudeList1.get(amplitudeList1.size() - 1).getYValue())) {
//                    amplitudeResult1.add(amplitudeList1.get(0).getXName());
//                    amplitudeResult1.add(amplitudeList1.get(amplitudeList1.size() - 1).getXName());
//                    break;
//                }
//            }
//            /**
//             * =========================续写word文档==============================================
//             */
//
//            //创建表题计数
//            int twoCount = 1;
//
//            //如果暂降幅值被勾选,就不需要进行写段落
//            if (areaReportParam.isSagAmplitude()) {
//                twoCount++;
//
//                //如果幅值图存在与幅值的序号保持同步
//                createTitle(doc, "4." + oneCount2 + "." + twoCount + " 持续时间的概率分函数", "标题 3", 400, 11);
//
//
//                List<String> ybardata = probabilityDistributionArea.getPersisttime();
//                List<String> ylinedata = probabilityDistributionArea.getSisttime();
//                String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
//                createPic(doc, sj, "持续时间的概率分布函数");
//
//
//            } else {
//                createTitle(doc, "4." + oneCount2 + " " + typeName + "幅值概率分布图", "标题 2", 200, 11);
//
//                p = doc.createParagraph();// 新建一个段落
//                p.setAlignment(ParagraphAlignment.BOTH);
//                XWPFRun r12 = p.createRun();//创建段落文本
//                r12.setText("  " + typeName + "概率分布图分成" + typeName + "幅值概率分布和持续时间概率分布图，中国电网在所选择的分析时间内" + typeName + "事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间，" +
//                        "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序，选择" + typeName + "记录发生最多的区域]，如下表（图）：");
//                r12.setFontSize(11);//字体大小
//
//
//                createTitle(doc, "4." + oneCount + "." + twoCount + " 时序时间的概率分函数", "标题 3", 400, 11);
//
//
//                List<String> ybardata = probabilityDistributionArea.getPersisttime();
//                List<String> ylinedata = probabilityDistributionArea.getSisttime();
//                String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
//                createPic(doc, sj, "持续时间的概率分布函数");
//
//
//                //序号计数进行++
//                oneCount++;
//            }
//            /**
//             * =======================================word结束=========================================
//             */
//        }
        //持续时间代码有问题注释掉
        //4.暂降幅值概率分布
        if (areaReportParam.isSagAmplitude() || areaReportParam.isDuration()) {
            int i =oneCount;
            createTitle(doc, "4." + i + " 暂降幅值概率分布图", "标题 2", 200, 15);
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
//            r12.setText("  " + typeName + "概率分布图分成" + typeName + "幅值概率分布和持续时间概率分布图，中国电网在所选择的分析时间内" + typeName + "事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间，" +
//                    "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序，选择" + typeName + "记录发生最多的区域]，如下表（图）：");
//            r12.setFontSize(11);//字体大小
//            ProbabilityVO probabilityVO = eventAnalysisService.getProbabilityDistribution(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
            ProbabilityVO probabilityVO = eventReportService.getProbabilityDistribution(eventDetails);
            int two = 1;
            if (areaReportParam.isSagAmplitude()) {
                createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15);
                List<String> ybardata = probabilityVO.getPereventvalue();
                List<String> ylinedata = probabilityVO.getEventvalue();
                String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
                createPic(doc, fz, "暂降幅值的概率分布函数");
                two++;
            }
            if (areaReportParam.isDuration()) {
                createTitle(doc, "4." + i + "." + two + " 持续时间的概率分函数", "标题 3", 400, 15);
                List<String> ybardata = probabilityVO.getPersisttime();
                List<String> ylinedata = probabilityVO.getSisttime();
                String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
                createPic(doc, sj, "持续时间的概率分布函数");
                two++;
            }
            oneCount++;
        }


        //8.事件关联统计表格
        if (areaReportParam.isEventRelevanceCountTable()) {
            //事件关联统计表格

            int resultCount = 0;
            List<EventassCountParam> resultList = new ArrayList<>();

            List<EventDetailNew> eventList = eventDetailList.stream().filter(e -> StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());

            if (CollectionUtil.isNotEmpty(eventList)) {
                //记录条数
                resultCount = eventList.size();
                List<String> ids = eventList.stream().map(EventDetailNew::getEventassIndex).collect(Collectors.toList());
                List<Eventass> eventAssList = eventDetailMapper.ListEventass(ids);

                for (Eventass eventass : eventAssList) {
                    EventassCountParam eventassCountParam = new EventassCountParam();
                    String dateTime = LocalDateTimeUtil.format(eventass.getTimeId(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
                    eventassCountParam.setAssTime(dateTime);
                    //获取时间
                    eventassCountParam.setEventTime(dateTime);
                    eventassCountParam.setDescribe(eventass.getContentDes());
                    resultList.add(eventassCountParam);
                }
            }

            createTitle(doc, "4." + oneCount + " 事件关联分析", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            //归一化需要高级算法,先字符串代替
            r12.setText("  " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条，归一化统计后共" + resultCount + "[此为归一化后的暂态事件结果]条，,具体如下图所示：");
            r12.setFontSize(11);//字体大小


            //第三张表
            XWPFTable monitorInfo2 = createTable(doc);
            XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc);

            // 表格第一行
            insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "时间", "事件关联分析名称", "事件关联分析表述");


            //塞入数据
            for (int i = 0; i < resultList.size(); i++) {
                insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, resultList.get(i).getAssTime(), resultList.get(i).getEventTime(), resultList.get(i).getDescribe());
            }
            //序号计数进行++
            oneCount++;

            /**
             * =======================================word结束=========================================
             */

        }

        //9.暂降原因表和暂降原因图形生成
        if (areaReportParam.isEventReasonTable() || areaReportParam.isEventReasonChart()) {
            //查询字典表
            List<DictData> reasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();

            //新建map集合装入参数
            Map<String, String> reasonMap = reasonList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));

            //获得所有值
            Set<String> typeSet = reasonMap.keySet();
            List<String> listReason = new ArrayList<>(typeSet);

            //创建Map结果集合
            Map<String, Integer> resultMap = new HashMap<>();

            //优化数据（根据暂降原因，进行分组统计有多少条数据，key:暂降原因id，value：次数)
            Map<String, Long> reasonMapCount = eventDetailList.stream()
                    .filter(x -> StrUtil.isNotBlank(x.getAdvanceReason()))
                    .collect(Collectors.groupingBy(EventDetailNew::getAdvanceReason, Collectors.counting()));
            //将数据重新整合为（key：暂降原因的名称，value:暂降原因测次数）
            reasonMap.forEach((key, value) -> {
                if (reasonMapCount.containsKey(key)) {
                    resultMap.put(value, Math.toIntExact(reasonMapCount.get(key)));
                } else {
                    resultMap.put(value, 0);
                }
            });

            //todo 还要对集合中哪个次数最多挑出第一位
            //获取entrySet
            Map<String, Integer> linkMap = getSort(resultMap);
            //最多暂降事件名称
            Set<String> topSet = linkMap.keySet();
            List<String> topList = new ArrayList<>(topSet);

            //暂降原因表格
            if (areaReportParam.isEventReasonTable()) {
                //暂降原因表格
                //创建表题计数
                int twoCount = 1;

                oneCount7 = oneCount;
                createTitle(doc, "4." + oneCount + " 原因统计", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + deptName + "电网在所选择的分析时间内暂态事件主要的暂态原因为" + topList.get(0) + "[根据表格中的次数来进行分析]，见下表（图）：");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " 原因统计表格", "标题 3", 400, 11);

                //第一张表
                XWPFTable monitorInfo = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc);

                // 表格第一行
                insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "暂态类型", "电压" + typeName + "次数");

                //塞入数据
                for (String name : resultMap.keySet()) {
                    insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, name, resultMap.get(name).toString());

                }

                twoCount4 = twoCount;
                //序号计数进行++
                oneCount++;

            }

            //暂降原因图表
            if (areaReportParam.isEventReasonChart()) {
                if (areaReportParam.isEventReasonTable()) {

                    createTitle(doc, "4." + oneCount7 + "." + twoCount4 + " 原因统计图", "标题 3", 400, 11);

                    //创建x,y参数
                    List<String> xdata = new ArrayList<>();

                    List<Map<String, Object>> list = new ArrayList<>();
                    Map<String, Object> map;
                    for (String name : resultMap.keySet()) {
                        xdata.add(name);

                        map = new LinkedHashMap<>();
                        map.put("value", resultMap.get(name));
                        map.put("name", name);
                        list.add(map);
                    }

                    String tr = drawPicUtil.drawReason(xdata, list);
                    createPic(doc, tr, "" + typeName + "原因图");
                } else {
                    //创建表题计数
                    int twoCount = 1;

                    createTitle(doc, "4." + oneCount + " 原因统计", "标题 2", 200, 11);

                    p = doc.createParagraph();// 新建一个段落
                    p.setAlignment(ParagraphAlignment.BOTH);
                    XWPFRun r12 = p.createRun();//创建段落文本
                    r12.setText("  " + deptName + "电网在所选择的分析时间内暂态事件主要的暂态原因为" + topList.get(0) + "[根据表格中的次数来进行分析]，见下表（图）：");
                    r12.setFontSize(11);//字体大小


                    createTitle(doc, "4." + oneCount + "." + twoCount + " 原因统计图", "标题 3", 400, 11);

                    //创建x,y参数
                    List<String> xdata = new ArrayList<>();

                    List<Map<String, Object>> list = new ArrayList<>();
                    Map<String, Object> map;
                    for (String name : resultMap.keySet()) {
                        xdata.add(name);

                        map = new LinkedHashMap<>();
                        map.put("value", resultMap.get(name));
                        map.put("name", name);
                        list.add(map);
                    }

                    String tr = drawPicUtil.drawReason(xdata, list);
                    createPic(doc, tr, "" + typeName + "原因图");

                    //序号计数进行++
                    oneCount++;
                }
            }
        }

        //10.暂降类型表格 和 暂降类型图表
        if (areaReportParam.isEventTypeTable() || areaReportParam.isEventTypeChart()) {

            //查询字典表（暂降类型）
            List<DictData> typeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
            //新建map集合装入参数
            Map<String, String> typeMap = typeList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));

            //获得所有值
            Set<String> typeSet = typeMap.keySet();
            List<String> listReason = new ArrayList<>(typeSet);

            //创建Map结果集合
            Map<String, Integer> resultMap = new HashMap<>();

            //优化数据（根据暂降类型，进行分组统计有多少条数据，key:暂降类型id，value：次数)
            Map<String, Long> typeMapCount = eventDetailList.stream().filter(temp->Objects.nonNull(temp.getAdvanceType())).collect(Collectors.groupingBy(EventDetailNew::getAdvanceType, Collectors.counting()));
            //将数据重新整合为（key：暂降类型的名称，value:暂降类型次数）
            typeMap.forEach((key, value) -> {
                if (typeMapCount.containsKey(key)) {
                    resultMap.put(value, Math.toIntExact(typeMapCount.get(key)));
                } else {
                    resultMap.put(value, 0);
                }
            });

            //todo 还要对集合中哪个次数最多挑出第一位
            //获取entrySet
            Map<String, Integer> linkMap = getSort(resultMap);
            //最多暂降事件名称
            Set<String> topSet = linkMap.keySet();
            List<String> topList = new ArrayList<>(topSet);


            //暂降类型表格
            if (areaReportParam.isEventTypeTable()) {
                //创建表题计数
                int twoCount = 1;
                oneCount6 = oneCount;

                createTitle(doc, "4." + oneCount + " 类型统计", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + deptName + "电网在所选择的分析时间内暂态事件主要的暂态类型为" + topList.get(0) + "[根据表格中的次数来进行分析]，见下表（图）：");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " 类型统计表格", "标题 3", 400, 11);

                //第一张表
                XWPFTable monitorInfo = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc);

                // 表格第一行
                insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "暂态类型", "电压" + typeName + "次数");


                //塞入数据
                for (String name : resultMap.keySet()) {
                    insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, name, resultMap.get(name).toString());
                }

                twoCount3 = twoCount;
                //序号计数进行++
                oneCount++;
            }
            //暂降类型图形
            if (areaReportParam.isEventTypeChart()) {
                if (areaReportParam.isEventTypeTable()) {
                    twoCount3++;
                    createTitle(doc, "4." + oneCount6 + "." + twoCount3 + " 类型统计图", "标题 3", 400, 11);


                    //创建x,y参数
                    List<String> xdata = new ArrayList<>();

                    List<Map<String, Object>> reasonList = new ArrayList<>();
                    Map<String, Object> map;
                    for (String name : resultMap.keySet()) {
                        xdata.add(name);

                        map = new LinkedHashMap<>();
                        map.put("value", resultMap.get(name));
                        map.put("name", name);
                        reasonList.add(map);
                    }

                    String tr = drawPicUtil.drawType(xdata, reasonList);
                    createPic(doc, tr, "" + typeName + "类型图");

                } else {
                    //创建表题计数
                    int twoCount = 1;


                    createTitle(doc, "4." + oneCount + " 类型统计", "标题 2", 200, 11);

                    p = doc.createParagraph();// 新建一个段落
                    p.setAlignment(ParagraphAlignment.BOTH);
                    XWPFRun r12 = p.createRun();//创建段落文本
                    r12.setText("  " + deptName + "电网在所选择的分析时间内暂态事件主要的暂态类型为" + topList.get(0) + "[根据表格中的次数来进行分析]，见下表（图）：");
                    r12.setFontSize(11);//字体大小

                    createTitle(doc, "4." + oneCount + "." + twoCount + " 类型统计图", "标题 3", 400, 11);

                    //创建x,y参数
                    List<String> xdata = new ArrayList<>();

                    List<Map<String, Object>> reasonList = new ArrayList<>();
                    Map<String, Object> map;
                    for (String name : resultMap.keySet()) {
                        xdata.add(name);

                        map = new LinkedHashMap<>();
                        map.put("value", resultMap.get(name));
                        map.put("name", name);
                        reasonList.add(map);
                    }

                    String tr = drawPicUtil.drawType(xdata, reasonList);
                    createPic(doc, tr, "" + typeName + "类型图");

                    //序号计数进行++
                    oneCount++;
                }
            }

        }

        //11.暂降热力图
        if (areaReportParam.isThermodynamicChart()) {
            //暂降热力图
            createTitle(doc, "4." + oneCount + " " + typeName + "热力图", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            r12.setText("  " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条，使用颜色将地图上按照" + typeName + "记录发生频率进行描绘，所形成的热力具体见下图：");
            r12.setFontSize(11);//字体大小

            //所有的表结果装入集合
            Map<String, Integer> areaCount1 = new HashMap<>();

            //进行遍历集合获得子区域名及其所有监测点id
            //根据省级获取部门下面的信息图
            for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {

                //当前子部门下所有id
                List<String> lineIndexes = generalDeviceDTO.getLineIndexes();

                //如果集合中有id将id进行拼接
                if (CollectionUtil.isNotEmpty(lineIndexes)) {
                    //数据统计
                    Integer eventDetailCount = getEventDetailCount(areaReportParam, lineIndexes);
                    areaCount1.put(generalDeviceDTO.getName(), eventDetailCount);
                } else {
                    //为空put 0
                    areaCount1.put(generalDeviceDTO.getName(), 0);
                }
            }


            //转为List对象集合
            List<ReportCountParam> areaCountList1 = new ArrayList<>();
            for (String s : areaCount1.keySet()) {
                ReportCountParam reportCountParam = new ReportCountParam();
                reportCountParam.setName(s);
                reportCountParam.setCount(areaCount1.get(s).toString());
                areaCountList1.add(reportCountParam);
            }

            //序号计数进行++
            oneCount++;
        }


        //文件下载
        ServletOutputStream outputStream = response.getOutputStream();
        String fileName = URLEncoder.encode(deptName + "热力图.docx", "UTF-8");
        response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
        response.setContentType("application/octet-stream;charset=UTF-8");
        doc.write(outputStream);
        outputStream.close();

    }

    @Override
    public void getPmsAreaReport(AreaReportParam areaReportParam, HttpServletResponse response) throws Exception {
        String typeName;
        if (areaReportParam.getWaveType().equals(0)) {
            //设置类型变量名为暂态
            typeName = "暂态";
        } else {
            typeName = "暂降";
        }
        PmsDeviceInfoParam pmsDeviceInfoParam = new PmsDeviceInfoParam();
        pmsDeviceInfoParam.setDeptIndex(areaReportParam.getDeptIndex());
        //获取统计类型
        pmsDeviceInfoParam.setStatisticalType(areaReportParam.getStatisticalType());
        //获取主网台账信息
        List<PmsGeneralDeviceDTO> generalDeviceDTOList = pmsGeneralDeviceInfoClient.getPmsDeviceInfoWithInOrg(pmsDeviceInfoParam).getData();
        //这是总的监测点id
        List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getMonitorIdList().stream()).distinct().collect(Collectors.toList());


        //提前创建,不然获取不到（初始化数据）
        if (CollUtil.isEmpty(lineIds)) {
            throw new BusinessException(EventResponseEnum.NOT_LINEID);
        }
        List<EventDetailNew> eventDetailList = getEventDetailListInfo(areaReportParam, lineIds, areaReportParam.getWaveType());
        if (CollectionUtil.isEmpty(eventDetailList)) {
            throw new BusinessException(CommonResponseEnum.NO_DATA);
        }

        //电压集合(统计类型：电压)根据监测点数据进行电压分组
        List<PmsGeneralDeviceDTO> voltageParamList = new ArrayList<>();
        List<Monitor> data = monitorClient.getMonitorList(lineIds).getData();
        Map<String, List<Monitor>> voltageMap = data.stream().collect(Collectors.groupingBy(Monitor::getVoltageLevel));
        //获取电压字典
        List<DictData> voltageData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
        PmsGeneralDeviceDTO deviceDTO;
        for (DictData voltageDatum : voltageData) {
            deviceDTO = new PmsGeneralDeviceDTO();
            if (voltageMap.containsKey(voltageDatum.getId())) {
                deviceDTO.setIndex(voltageDatum.getId());
                deviceDTO.setName(voltageDatum.getName());
                //获取检测点id
                List<String> monitorIds = voltageMap.get(voltageDatum.getId()).stream().map(Monitor::getId).collect(Collectors.toList());
                deviceDTO.setMonitorIdList(monitorIds);
            } else {
                deviceDTO.setIndex(voltageDatum.getId());
                deviceDTO.setName(voltageDatum.getName());
            }
            voltageParamList.add(deviceDTO);
        }


        //创建幅值计数器
        int oneCount2 = 0;

        //创建ITIC与F47计数器
        int oneCount3 = 0;
        int twoCount5 = 0;

        //创建暂降密度表和密度图的计数器
        int oneCount4 = 0;
        int twoCount1 = 0;

        //创建暂降事件表格和图的计数器
        int oneCount5 = 0;
        int twoCount2 = 0;

        //创建暂态类型图和暂态类型表格计数器
        int oneCount6 = 0;
        int twoCount3 = 0;

        //创建暂态原因图和暂态原因表格计数器
        int oneCount7 = 0;
        int twoCount4 = 0;

        //提前创建计数（累计监测点数量）
        Integer eventCount = 0;
        //如果集合中有id将id进行拼接
        if (CollectionUtil.isNotEmpty(lineIds)) {
            //获取累计监测点数量
            eventCount = eventDetailList.size();
        }


        //准备word表中参数
        //获取监测点总数量
        int size = lineIds.size();
        //还有当前传入的部门名称(例如:中国)需要等邓哥的公共方法
        String deptName = deptFeignClient.getDeptById(areaReportParam.getDeptIndex()).getData().getName();


        /**
         * =====================生成word===========================
         */
        //设置序号初始值
        int oneCount = 1;

        //创建word文档(poi生成word)
        XWPFDocument doc = new XWPFDocument();// 创建Word文件
        XWPFParagraph p = doc.createParagraph();// 新建一个段落

        // 设定标题格式,可以生成可点击的序号
        WordUtils.setHeadingStyle(doc);

        //设置对齐
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r = p.createRun();//创建段落文本
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.addBreak();
        r.setText(deptName + "供电公司");
        r.setBold(true);//设置为粗体
        r.setFontSize(14);//字体大小
        r.addBreak();


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r1 = p.createRun();//创建段落文本
        r1.setText("电压" + typeName + "事件区域报告");
        r1.setBold(true);//设置为粗体
        r1.setFontSize(36);//字体大小
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();
        r1.addBreak();


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r2 = p.createRun();//创建段落文本
        //获取当前时间
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日");
        String time = dateFormat.format(date);

        r2.setText("日期: " + time);
        r2.setBold(true);//设置为粗体
        r2.setFontSize(14);//字体大小

        r2.addBreak();
        r2.addBreak();
        r2.addBreak();


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.CENTER);
        XWPFRun r3 = p.createRun();//创建段落文本
        r3.setText("电压" + typeName + "事件区域报告");
        r3.setFontSize(24);//字体大小


        createTitle(doc, "1. 引言", "标题 1", 0, 15);


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r5 = p.createRun();//创建段落文本
        r5.setText("  " + deptName + "电网总共有" + size + "个监测点。" + deptName + "电网在所选择时间段" + areaReportParam.getSearchBeginTime() + " 至 " + areaReportParam.getSearchEndTime() +
                "累计监测到" + typeName + "事件" + eventCount + "条，本报告按照监测点分布，" + typeName + "事件统计，" + typeName + "事件点图，" + typeName + "热力图，" + typeName + "密度图，" + typeName + "概率分布图，事件关联统计，" + typeName + "类型统计，" + typeName + "原因统计等方面进行数据分析。");
        r5.setFontSize(11);//字体大小


        createTitle(doc, "2. 报告分析对象", "标题 1", 0, 15);


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r7 = p.createRun();//创建段落文本
        r7.setText("  " + deptName + "。");
        r7.setFontSize(11);//字体大小


        createTitle(doc, "3. 报告分析时间", "标题 1", 0, 15);


        p = doc.createParagraph();// 新建一个段落
        p.setAlignment(ParagraphAlignment.BOTH);
        XWPFRun r9 = p.createRun();//创建段落文本
        r9.setText("  " + areaReportParam.getSearchBeginTime() + " 至 " + areaReportParam.getSearchEndTime() + "。");
        r9.setFontSize(11);//字体大小


        createTitle(doc, "4. 汇总信息", "标题 1", 0, 15);

        //1.监测网分布
        if (areaReportParam.isMonitorDistributeChart()) {
            //监测网分布


            //在线监测点数
            Integer onLineIdCount = 0;
            if (CollectionUtil.isNotEmpty(lineIds)) {
                //获取监测点状态运行
                DictData runState = dicDataFeignClient.getDicDataByName(DicDataEnum.RUN.getName()).getData();
                onLineIdCount = data.stream().filter(ol -> ol.getMonitorState().equals(runState.getId())).collect(Collectors.toList()).size();
            }

            //离线总监测点数
            Integer unLineCount = Integer.valueOf(lineIds.size()) - onLineIdCount;
            //在线率
            Double onlineRate = (onLineIdCount.doubleValue()) / (Double.valueOf(String.valueOf(lineIds.size()))) * 100;

            NumberFormat nf = NumberFormat.getNumberInstance();
            // 保留两位小数
            nf.setMaximumFractionDigits(2);
            // 如果不需要四舍五入
            nf.setRoundingMode(RoundingMode.UP);

            String onlineRateResult = nf.format(onlineRate);


            /**
             * =========================续写word文档==============================================
             */


            createTitle(doc, "4." + oneCount + " 监测网分布", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            r12.setText("  " + deptName + "电网总共有监测点" + size + "个。监测点在线率达到" + onlineRateResult + "%（通讯正常为：" + onLineIdCount + "个，通讯异常为：" + unLineCount + "个）" +
                    "[通讯正常/总监测点数（统计时候排除检修和热备用监测点）]，具体见下图：");
            r12.setFontSize(11);//字体大小


            //todo 分布地图代码未实现

            //序号计数进行++
            oneCount++;

            /**
             * =======================================word结束=========================================
             */
        }
        List<String> lindIds = eventDetailList.stream().map(EventDetailNew::getLineId).collect(Collectors.toList());
        //2.暂降事件三表季图像判断
        if (areaReportParam.isEventCountTable() || areaReportParam.isEventCountChart()) {

            //所有的表结果装入集合
            Map<String, Integer> areaCount = new HashMap<>();
            Map<String, Integer> voltageCount = new HashMap<>();
            //暂降事件最多的两个电压
            Set<String> topVoltage = new HashSet<>();

            //1.部门信息。传入参数（判断统计类型）
            if (Objects.nonNull(areaReportParam.getStatisticalType().getCode()) && areaReportParam.getStatisticalType().getCode().equals("Power_Network")) {
                //进行遍历集合获得子区域名及其所有监测点id
                for (PmsGeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {

                    //当前子部门下所有id
                    List<String> lineIndexes = generalDeviceDTO.getMonitorIdList();
                    //如果集合中有id将id进行拼接
                    if (CollectionUtil.isNotEmpty(lineIndexes)) {
                        //总条数
                        List<String> countSize = lindIds.stream().filter(x -> lineIndexes.contains(x)).collect(Collectors.toList());

                        if (CollUtil.isNotEmpty(countSize)) {
                            areaCount.put(generalDeviceDTO.getName(), countSize.size());
                        } else {
                            areaCount.put(generalDeviceDTO.getName(), 0);
                        }

                    } else {
                        //为空put 0
                        areaCount.put(generalDeviceDTO.getName(), 0);
                    }
                }

                //2.电压集合(统计类型：电压)
                List<PmsGeneralDeviceDTO> areaParamList = voltageParamList;
                //进行遍历集合获得子区域名及其所有监测点id
                for (PmsGeneralDeviceDTO generalDeviceDTO : areaParamList) {

                    //当前子部门下所有id
                    List<String> lineIndexes = generalDeviceDTO.getMonitorIdList();

                    //如果集合中有id将id进行拼接
                    if (CollectionUtil.isNotEmpty(lineIndexes)) {

                        List<String> countSize = lindIds.stream().filter(x -> lineIndexes.contains(x)).collect(Collectors.toList());

                        if (CollUtil.isNotEmpty(countSize)) {
                            voltageCount.put(generalDeviceDTO.getName(), countSize.size());
                        } else {
                            voltageCount.put(generalDeviceDTO.getName(), 0);
                        }

                    } else {
                        //为空put 0
                        voltageCount.put(generalDeviceDTO.getName(), 0);
                    }
                }
                //数据排序
                Map<String, Integer> linkMap = getSort(voltageCount);
                //最多暂降事件的两个电压名称
                topVoltage = linkMap.keySet();

            }


            //根据月份来进行查看暂降
            //提前创建对象
            int dayOfMonth = 0;
            //最后集合
            List<TimeSVO> timeSVoList = new ArrayList<>();
            //表格参数
            String table = "";

            //月
            if ("0".equals(areaReportParam.getInterval())) {
                table = "月份";

                List<String> dayCount = new ArrayList<>();
                List<AreaEventMonthParam> timeList = new ArrayList<>();
                DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM");
                //进行for循环获取所有事件的时间
                for (EventDetailNew eventDetail : eventDetailList) {
                    //获取暂降事件时间
                    dayCount.add(DateUtil.format(DateUtil.parse(eventDetail.getStartTime()), fmt));

                    //创建对象
                    AreaEventMonthParam timeParam = new AreaEventMonthParam();
                    timeParam.setDayOrMonth(DateUtil.format(DateUtil.parse(eventDetail.getStartTime()), fmt));
                    timeParam.setEventAssIndex(eventDetail.getEventassIndex());
                    timeList.add(timeParam);
                }

                //Map集和
                Map<String, List<String>> relevanceMap = new HashMap<>();
                List<String> list = new ArrayList<>();

                for (AreaEventMonthParam areaEventMonthParam : timeList) {
                    //如果存在
                    if (relevanceMap.containsKey(areaEventMonthParam.getDayOrMonth())) {
                        list = relevanceMap.get(areaEventMonthParam.getDayOrMonth());
                        list.add(areaEventMonthParam.getEventAssIndex());
                        relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list));
                    } else {
                        List<String> list1 = new ArrayList<>();
                        list1.add(areaEventMonthParam.getEventAssIndex());
                        relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list1));
                    }
                }
                //创建map集和装当天和次数
                Map<String, Integer> resultMap = new HashMap<>();
                for (String day : dayCount) {
                    if (resultMap.containsKey(day)) {
                        resultMap.put(day, resultMap.get(day) + 1);
                    } else {
                        resultMap.put(day, 1);
                    }
                }
                //获取未关联的暂态事件
                Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
                        .collect(Collectors.groupingBy(x -> DateUtil.format(DateUtil.parse(x.getStartTime()), fmt), Collectors.counting()));


                //开始时间
                LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime());
                LocalDate end = LocalDate.parse(areaReportParam.getSearchEndTime());
                //因为是比较月份,将起始时间的天数加给结束时间,不然while一直不能结束循环

                String substring1 = end.toString().substring(0, 8);
                String substring2 = beginTime.toString().substring(8, 10);

                String s1 = substring1 + substring2;
                LocalDate endTime = LocalDate.parse(s1);
                Set<String> keySet = resultMap.keySet();

                while (!beginTime.equals(endTime.plus(1, ChronoUnit.MONTHS))) {
                    if (keySet.contains(beginTime.toString().substring(0, 7))) {
                        Integer countSize = resultMap.get(beginTime.toString().substring(0, 7));
                        TimeSVO timeVO = new TimeSVO();
                        timeVO.setTimes(countSize.toString());
                        timeVO.setYear(String.valueOf(beginTime.getYear()));

                        //todo 不知道代码是否是写错了，时间判断有问题
//                            if (beginTime.getDayOfMonth() < 10) {
                        if (beginTime.getMonthValue() < 10) {
                            timeVO.setMonth("0" + beginTime.getMonthValue() + "");
                        } else {
                            timeVO.setMonth(beginTime.getMonthValue() + "");
                        }

                        timeVO.setFulltime(beginTime.toString().substring(0, 7));
                        //遍历 如果时间相同,将所有关联处理事件次数赋值上去
                        if (eventAssDetail.containsKey(beginTime.toString().substring(0, 7))) {
                            timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString().substring(0, 7))));
                        } else {
                            timeVO.setEventAssIndex(0);
                        }
                        timeSVoList.add(timeVO);
                    } else {
                        TimeSVO timeVO = new TimeSVO();
                        timeVO.setTimes("0");
                        timeVO.setYear(String.valueOf(beginTime.getYear()));

                        //todo 未知问题：是否是代码错误
                        if (beginTime.getMonthValue() < 10) {
                            timeVO.setMonth("0" + beginTime.getMonthValue() + "");
                        } else {
                            timeVO.setMonth(beginTime.getMonthValue() + "");
                        }
                        timeVO.setEventAssIndex(0);
                        timeVO.setFulltime(beginTime.toString().substring(0, 7));
                        timeSVoList.add(timeVO);
                    }

                    beginTime = beginTime.plus(1, ChronoUnit.MONTHS);
                }

                //数据排序
                Map<String, Integer> linkMap = getSort(resultMap);
                //暂降次数最多
                List<String> collect = linkMap.keySet().stream().collect(Collectors.toList());
                //赋值
                dayOfMonth = Integer.parseInt(collect.get(0).substring(5, 7));
            } else {
                table = "天数";

                List<String> dayCount = new ArrayList<>();
                List<AreaEventMonthParam> timeList = new ArrayList<>();

                //进行for循环获取所有事件的时间
                for (EventDetailNew eventDetail : eventDetailList) {
                    //获取暂降事件时间
                        /*    String timeId = eventDetail.getTimeId();
                            Date date1 = DateUtil.parse(timeId);
                            int day = Integer.parseInt(String.format("%td",date1));*/
                    dayCount.add(DateUtil.formatDate(DateUtil.parse(eventDetail.getStartTime())));

                    //创建对象
                    AreaEventMonthParam timeParam = new AreaEventMonthParam();
                    timeParam.setDayOrMonth(DateUtil.formatDate(DateUtil.parse(eventDetail.getStartTime())));
                    timeParam.setEventAssIndex(eventDetail.getEventassIndex());
                    timeList.add(timeParam);
                }

                //Map集和
                Map<String, List<String>> relevanceMap = new HashMap<>();
                List<String> list = new ArrayList<>();

                for (AreaEventMonthParam areaEventMonthParam : timeList) {
                    //如果存在
                    if (relevanceMap.containsKey(areaEventMonthParam.getDayOrMonth())) {
                        list = relevanceMap.get(areaEventMonthParam.getDayOrMonth());
                        list.add(areaEventMonthParam.getEventAssIndex());
                        relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list));
                    } else {
                        List<String> list1 = new ArrayList<>();
                        list1.add(areaEventMonthParam.getEventAssIndex());
                        relevanceMap.put(areaEventMonthParam.getDayOrMonth(), (list1));
                    }
                }
                //创建map集和装当天和次数
                Map<String, Integer> resultMap = new HashMap<>();
                for (String day : dayCount) {
                    if (resultMap.containsKey(day)) {
                        resultMap.put(day, resultMap.get(day) + 1);
                    } else {
                        resultMap.put(day, 1);
                    }
                }

                //获取未关联的暂态事件
                Map<String, Long> eventAssDetail = eventDetailList.stream().filter(x -> StrUtil.isBlank(x.getEventassIndex()))
                        .collect(Collectors.groupingBy(x -> DateUtil.formatDate(DateUtil.parse(x.getStartTime())), Collectors.counting()));

                DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                //开始时间
                LocalDate beginTime = LocalDate.parse(areaReportParam.getSearchBeginTime(), fmt);
                LocalDate endTime = LocalDate.parse(areaReportParam.getSearchEndTime(), fmt);

                Set<String> keySet = resultMap.keySet();

                while (!beginTime.equals(endTime.plus(1, ChronoUnit.DAYS))) {
                    if (keySet.contains(beginTime.toString())) {

                        //获取暂降次数
                        Integer countSize = resultMap.get(beginTime.toString());
                        TimeSVO timeVO = new TimeSVO();
                        timeVO.setTimes(countSize.toString());

                        if (beginTime.getDayOfMonth() < 10) {
                            timeVO.setDay("0" + beginTime.getDayOfMonth() + "");
                        } else {
                            timeVO.setDay(beginTime.getDayOfMonth() + "");
                        }

                        timeVO.setYear(String.valueOf(beginTime.getYear()));
                        //todo 不知道代码是否是写错了，时间判断有问题
                        if (beginTime.getMonthValue() < 10) {
                            timeVO.setMonth("0" + beginTime.getMonthValue() + "");
                        } else {
                            timeVO.setMonth(beginTime.getMonthValue() + "");
                        }
                        timeVO.setFulltime(beginTime.toString());
                        //遍历 如果时间相同,将所有关联处理事件次数赋值上去
                        if (eventAssDetail.containsKey(beginTime.toString())) {
                            timeVO.setEventAssIndex(Math.toIntExact(eventAssDetail.get(beginTime.toString())));
                        } else {
                            timeVO.setEventAssIndex(0);
                        }
                        timeSVoList.add(timeVO);
                    } else {
                        TimeSVO timeVO = new TimeSVO();
                        timeVO.setTimes("0");
                        if (beginTime.getDayOfMonth() < 10) {
                            timeVO.setDay("0" + beginTime.getDayOfMonth() + "");
                        } else {
                            timeVO.setDay(beginTime.getDayOfMonth() + "");
                        }
                        timeVO.setYear(String.valueOf(beginTime.getYear()));

                        //todo 未知问题：是否是代码错误
                        if (beginTime.getMonthValue() < 10) {
                            timeVO.setMonth("0" + beginTime.getMonthValue() + "");
                        } else {
                            timeVO.setMonth(beginTime.getMonthValue() + "");
                        }
                        timeVO.setEventAssIndex(0);
                        timeVO.setFulltime(beginTime.toString());
                        timeSVoList.add(timeVO);
                    }

                    beginTime = beginTime.plus(1, ChronoUnit.DAYS);
                }

                //数据排序
                Map<String, Integer> linkMap = getSort(resultMap);
                //暂降次数最多
                List<String> collect = linkMap.keySet().stream().collect(Collectors.toList());

                //赋值
                dayOfMonth = LocalDate.parse(collect.get(0)).getDayOfMonth();

            }

            //最高暂降事件的两个电压值
//                System.out.println(topVoltage);
            //转为List
            List<String> topVoltageList = new ArrayList<>();
            for (String s : topVoltage) {
                topVoltageList.add(s);
            }
            //表格
            if (areaReportParam.isEventCountTable()) {

                //创建表题计数
                int twoCount = 1;

                //与暂降事件图形共享序号
                oneCount5 = oneCount;


                createTitle(doc, "4." + oneCount + " " + typeName + "事件列表", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条，" + topVoltageList.get(0) + "、" + topVoltageList.get(1) + "" + typeName + "事件居多，" +
                        "第" + dayOfMonth + "" + table + "" + typeName + "事件居多，具体见下表(图)：");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "事件表格", "标题 3", 400, 11);
                twoCount2 = twoCount;

                //第一张表
                XWPFTable monitorInfo = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc);
                // 表格第一行
                insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "区域", "电压" + typeName + "次数");
                //塞入数据
                for (String s : areaCount.keySet()) {
                    insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, s, areaCount.get(s).toString());
                }


                //第二张表
                XWPFTable monitorInfo1 = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph1 = WordUtils.getCenterParagraph(doc);
                // 表格第一行
                insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, true, "电压等级", "电压" + typeName + "次数");
                //塞入数据
                for (String s : voltageCount.keySet()) {
                    insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, false, s, voltageCount.get(s).toString());
                }


                //第三张表
                XWPFTable monitorInfo2 = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc);
                // 表格第一行
                insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "" + table + "", "电压" + typeName + "次数");
                //塞入数据
                for (int i = 0; i < timeSVoList.size(); i++) {
                    insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, timeSVoList.get(i).getFulltime(), timeSVoList.get(i).getTimes());
                }

                //序号计数进行++
                oneCount++;

                /**
                 * =======================================word结束=========================================
                 */

            }

            //图形
            if (areaReportParam.isEventCountChart()) {
                twoCount2++;
                createTitle(doc, "4." + oneCount5 + "." + twoCount2 + " " + typeName + "事件图形", "标题 3", 400, 11);


                //创建部门与监测点次数的map集合
                Map<String, Integer> lineCount = new HashMap<>();
                for (PmsGeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {
                    lineCount.put(generalDeviceDTO.getName(), generalDeviceDTO.getMonitorIdList().size());
                }

                //创建x,y参数
                List<String> xdata = new ArrayList<>();
                List<Integer> ydata = new ArrayList<>();
                //根据区域名称进行匹配
                for (String name : areaCount.keySet()) {
                    //将监测点的数量拼接在部门下面
                    for (String s : lineCount.keySet()) {
                        if (s.equals(name)) {
                            xdata.add(name + "\n" + "(" + lineCount.get(s) + ")");
                        }
                    }

                    ydata.add(areaCount.get(name));
                }

                String qytj = drawPicUtil.drawEventRegion(xdata, ydata);
                createPic(doc, qytj, "" + typeName + "事件图形");


                //月份统计
                //创建x,y参数
                List<String> xdata1 = new ArrayList<>();
                List<Integer> ydata1 = new ArrayList<>();
                List<Integer> ydata2 = new ArrayList<>();
                for (TimeSVO timeSVO : timeSVoList) {
                    if ("天数".equals(table)) {
                        xdata1.add(timeSVO.getFulltime().substring(5));
                    } else {
                        xdata1.add(timeSVO.getFulltime());
                    }
                    ydata1.add(Integer.parseInt(timeSVO.getTimes()));
                    ydata2.add(timeSVO.getEventAssIndex());
                }


                String yftj = drawPicUtil.drawEventAssociatedUnassociated(xdata1, ydata1, ydata2, table);
                createPic(doc, yftj, "" + typeName + "事件图形");


                //创建电压uiiiuuuu与监测点次数的map集合
                List<PmsGeneralDeviceDTO> areaParamList = voltageParamList;
                Map<String, Integer> lineCount1 = new HashMap<>();
                for (PmsGeneralDeviceDTO generalDeviceDTO : areaParamList) {
                    lineCount1.put(generalDeviceDTO.getName(), generalDeviceDTO.getMonitorIdList().size());
                }
                //创建x,y参数
                List<String> xdata3 = new ArrayList<>();
                List<Integer> ydata3 = new ArrayList<>();
                //根据电压名称进行匹配
                for (String name : voltageCount.keySet()) {
                    //将监测点的数量拼接在部门下面
                    for (String s : lineCount1.keySet()) {
                        if (s.equals(name)) {
                            xdata3.add(name + "\n" + "(" + lineCount1.get(s) + ")");
                        }
                    }
                    ydata3.add(voltageCount.get(name));
                }

                String dydj = drawPicUtil.drawEventVoltageLevel(xdata3, ydata3);
                createPic(doc, dydj, "" + typeName + "事件图形");


                /**
                 * =======================================word结束=========================================
                 */
            }


        }

        //3.密度图
        if (areaReportParam.isDensityTable() || areaReportParam.isDensityChart()) {

            //暂降密度图形
            AreaTableParam areaTableParam = new AreaTableParam();

            //创建结果集合
            List<EventDetailNew> info = eventDetailList;

            //将sql结果集放入,共用一个sql,减少查询时间
            AreaTableParam areaTableParam1 = new AreaTableParam();
            areaTableParam1.setInfo(info);


            List<IEC28VO> iEC28VOResult = IEC28Area(areaTableParam1);
            List<IEC411VO> iEC411VOResult = IEC411Area(areaTableParam1);
            List<DISDIPVO> dISDIPVOResult = eventDisdipArea(areaTableParam1);


            //IEC411 <1% 总共集合
            List<IEC411VO> lessOneIEC411 = new ArrayList<>();
            //IEC411 1~40% 总共集合
            List<IEC411VO> lessFortyIEC411 = new ArrayList<>();
            //IEC411 40~70% 总共集合
            List<IEC411VO> lessSeventyIEC411 = new ArrayList<>();


            //IEC28 <1% 总共集合
            List<IEC28VO> lessOneIEC28 = new ArrayList<>();
            //IEC411 <10 总共集合
            List<IEC28VO> lessTenIEC28 = new ArrayList<>();
            //IEC411 <20 总共集合
            List<IEC28VO> lessTwentyIEC28 = new ArrayList<>();
            //IEC411 <30 总共集合
            List<IEC28VO> lessThirtyIEC28 = new ArrayList<>();
            //IEC411 <40 总共集合
            List<IEC28VO> lessFortyIEC28 = new ArrayList<>();
            //IEC411 <50 总共集合
            List<IEC28VO> lessFiftyIEC28 = new ArrayList<>();
            //IEC411 <60 总共集合
            List<IEC28VO> lessSixtyIEC28 = new ArrayList<>();
            //IEC411 <70 总共集合
            List<IEC28VO> lessSeventyIEC28 = new ArrayList<>();
            //IEC411 <80 总共集合
            List<IEC28VO> lessEightyIEC28 = new ArrayList<>();
            //IEC411 <90 总共集合
            List<IEC28VO> lessNinetyIEC28 = new ArrayList<>();
            //IEC411 <120 总共集合
            List<IEC28VO> lessHundredTwentyIEC28 = new ArrayList<>();
            //IEC411 <130 总共集合
            List<IEC28VO> lessHundredThirtyIEC28 = new ArrayList<>();
            //IEC411 <140 总共集合
            List<IEC28VO> lessHundredFortyIEC28 = new ArrayList<>();
            //IEC411 <150 总共集合
            List<IEC28VO> lessHundredFiftyIEC28 = new ArrayList<>();
            //IEC411 <160 总共集合
            List<IEC28VO> lessHundredSixtyIEC28 = new ArrayList<>();
            //IEC411 <170 总共集合
            List<IEC28VO> lessHundredSeventyIEC28 = new ArrayList<>();
            //IEC411 <180 总共集合
            List<IEC28VO> lessHundredEightyIEC28 = new ArrayList<>();


            //DISDIP = 10%
            List<DISDIPVO> equalTenDISDIP = new ArrayList<>();
            //DISDIP = 40%
            List<DISDIPVO> equalFortyDISDIP = new ArrayList<>();
            //DISDIP = 70%
            List<DISDIPVO> equalSeventyDISDIP = new ArrayList<>();
            //DISDIP = 85%
            List<DISDIPVO> equalEightyFiveDISDIP = new ArrayList<>();
            //DISDIP = 90%
            List<DISDIPVO> equalNinetyDISDIP = new ArrayList<>();


            //遍历将集合按名称分开
            for (int i1 = 0; i1 < iEC411VOResult.size(); i1++) {
                if ("<1%".equals(iEC411VOResult.get(i1).getName())) {
                    //放入集合
                    lessOneIEC411.add(iEC411VOResult.get(i1));
                } else if ("1~40%".equals(iEC411VOResult.get(i1).getName())) {
                    //放入集合
                    lessFortyIEC411.add(iEC411VOResult.get(i1));
                } else {
                    //放入集合
                    lessSeventyIEC411.add(iEC411VOResult.get(i1));
                }
            }


            //遍历将集合按名称分开
            for (int i1 = 0; i1 < iEC28VOResult.size(); i1++) {
                if ("1>U>=0".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessOneIEC28.add(iEC28VOResult.get(i1));
                } else if ("10>U>=1".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessTenIEC28.add(iEC28VOResult.get(i1));
                } else if ("20>U>=10".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessTwentyIEC28.add(iEC28VOResult.get(i1));
                } else if ("30>U>=20".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessThirtyIEC28.add(iEC28VOResult.get(i1));
                } else if ("40>U>=30".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessFortyIEC28.add(iEC28VOResult.get(i1));
                } else if ("50>U>=40".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessFiftyIEC28.add(iEC28VOResult.get(i1));
                } else if ("60>U>=50".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessSixtyIEC28.add(iEC28VOResult.get(i1));
                } else if ("70>U>=60".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessSeventyIEC28.add(iEC28VOResult.get(i1));
                } else if ("80>U>=70".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessEightyIEC28.add(iEC28VOResult.get(i1));
                } else if ("90>U>=80".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessNinetyIEC28.add(iEC28VOResult.get(i1));
                } else if ("120>U>=110".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessHundredTwentyIEC28.add(iEC28VOResult.get(i1));
                } else if ("130>U>=120".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessHundredThirtyIEC28.add(iEC28VOResult.get(i1));
                } else if ("140>U>=130".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessHundredFortyIEC28.add(iEC28VOResult.get(i1));
                } else if ("150>U>=140".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessHundredFiftyIEC28.add(iEC28VOResult.get(i1));
                } else if ("160>U>=150".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessHundredSixtyIEC28.add(iEC28VOResult.get(i1));
                } else if ("170>U>=160".equals(iEC28VOResult.get(i1).getName())) {
                    //放入集合
                    lessHundredSeventyIEC28.add(iEC28VOResult.get(i1));
                } else {
                    //放入集合
                    lessHundredEightyIEC28.add(iEC28VOResult.get(i1));

                }
            }

            //遍历将集合按名称分开
            for (int i1 = 0; i1 < dISDIPVOResult.size(); i1++) {
                if ("10%".equals(dISDIPVOResult.get(i1).getName())) {
                    //放入集合
                    equalTenDISDIP.add(dISDIPVOResult.get(i1));
                } else if ("40%".equals(dISDIPVOResult.get(i1).getName())) {
                    //放入集合
                    equalFortyDISDIP.add(dISDIPVOResult.get(i1));
                } else if ("70%".equals(dISDIPVOResult.get(i1).getName())) {
                    //放入集合
                    equalSeventyDISDIP.add(dISDIPVOResult.get(i1));
                } else if ("85%".equals(dISDIPVOResult.get(i1).getName())) {
                    //放入集合
                    equalEightyFiveDISDIP.add(dISDIPVOResult.get(i1));
                } else {
                    //放入集合
                    equalNinetyDISDIP.add(dISDIPVOResult.get(i1));
                }
            }


            //遍历集合中的参数
            IEC411CountParam iec411LessOne = new IEC411CountParam();

            for (IEC411VO iec411VO : lessOneIEC411) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec411LessOne.getName())) {
                    iec411LessOne.setName(iec411VO.getName());
                }

                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec411VO.getTenTwentyMs())) {
                    int tenToTwenty = iec411LessOne.getTenToTwenty();
                    iec411LessOne.setTenToTwenty(tenToTwenty++);
                }
                if (!"0".equals(iec411VO.getTwentyOneHundredMs())) {
                    int twentyToHundred = iec411LessOne.getTwentyToHundred();
                    iec411LessOne.setTenToTwenty(twentyToHundred++);
                }
                if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) {
                    int zeroOneToZeroTwo = iec411LessOne.getZeroOneToZeroTwo();
                    iec411LessOne.setTenToTwenty(zeroOneToZeroTwo++);
                }
                if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) {
                    int zeroTwoToZeroFive = iec411LessOne.getZeroTwoToZeroFive();
                    iec411LessOne.setTenToTwenty(zeroTwoToZeroFive++);
                }
                if (!"0".equals(iec411VO.getZeroPiontFive1S())) {
                    int zeroFiveToOne = iec411LessOne.getZeroFiveToOne();
                    iec411LessOne.setTenToTwenty(zeroFiveToOne++);
                }
                if (!"0".equals(iec411VO.getGreater1S())) {
                    int lessOne = iec411LessOne.getLessOne();
                    iec411LessOne.setTenToTwenty(lessOne++);
                }
            }

            //遍历集合中的参数
            IEC411CountParam iec411LessForty = new IEC411CountParam();

            for (IEC411VO iec411VO : lessFortyIEC411) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec411LessForty.getName())) {
                    iec411LessForty.setName(iec411VO.getName());
                }

                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec411VO.getTenTwentyMs())) {
                    int tenToTwenty = iec411LessForty.getTenToTwenty();
                    iec411LessForty.setTenToTwenty(tenToTwenty++);
                }
                if (!"0".equals(iec411VO.getTwentyOneHundredMs())) {
                    int twentyToHundred = iec411LessForty.getTwentyToHundred();
                    iec411LessForty.setTenToTwenty(twentyToHundred++);
                }
                if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) {
                    int zeroOneToZeroTwo = iec411LessForty.getZeroOneToZeroTwo();
                    iec411LessForty.setTenToTwenty(zeroOneToZeroTwo++);
                }
                if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) {
                    int zeroTwoToZeroFive = iec411LessForty.getZeroTwoToZeroFive();
                    iec411LessForty.setTenToTwenty(zeroTwoToZeroFive++);
                }
                if (!"0".equals(iec411VO.getZeroPiontFive1S())) {
                    int zeroFiveToOne = iec411LessForty.getZeroFiveToOne();
                    iec411LessForty.setTenToTwenty(zeroFiveToOne++);
                }
                if (!"0".equals(iec411VO.getGreater1S())) {
                    int lessOne = iec411LessForty.getLessOne();
                    iec411LessForty.setTenToTwenty(lessOne++);
                }
            }

            //遍历集合中的参数
            IEC411CountParam iec411LessSeventy = new IEC411CountParam();

            for (IEC411VO iec411VO : lessSeventyIEC411) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec411LessSeventy.getName())) {
                    iec411LessSeventy.setName(iec411VO.getName());
                }

                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec411VO.getTenTwentyMs())) {
                    int tenToTwenty = iec411LessSeventy.getTenToTwenty();
                    iec411LessSeventy.setTenToTwenty(tenToTwenty++);
                }
                if (!"0".equals(iec411VO.getTwentyOneHundredMs())) {
                    int twentyToHundred = iec411LessSeventy.getTwentyToHundred();
                    iec411LessSeventy.setTenToTwenty(twentyToHundred++);
                }
                if (!"0".equals(iec411VO.getZeroPiontOneTwoS())) {
                    int zeroOneToZeroTwo = iec411LessSeventy.getZeroOneToZeroTwo();
                    iec411LessSeventy.setTenToTwenty(zeroOneToZeroTwo++);
                }
                if (!"0".equals(iec411VO.getZeroPiontTwoFiveS())) {
                    int zeroTwoToZeroFive = iec411LessSeventy.getZeroTwoToZeroFive();
                    iec411LessSeventy.setTenToTwenty(zeroTwoToZeroFive++);
                }
                if (!"0".equals(iec411VO.getZeroPiontFive1S())) {
                    int zeroFiveToOne = iec411LessSeventy.getZeroFiveToOne();
                    iec411LessSeventy.setTenToTwenty(zeroFiveToOne++);
                }
                if (!"0".equals(iec411VO.getGreater1S())) {
                    int lessOne = iec411LessSeventy.getLessOne();
                    iec411LessSeventy.setTenToTwenty(lessOne++);
                }
            }

            /**
             * ================第一张表结束======================
             */

            DISDIPCountParam disdipEqualTen = new DISDIPCountParam();

            for (DISDIPVO disdipvo : equalTenDISDIP) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(disdipEqualTen.getName())) {
                    disdipEqualTen.setName(disdipvo.getName());
                }

                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(disdipvo.getTwentyMs())) {
                    int twenty = disdipEqualTen.getTwenty();
                    disdipEqualTen.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getOneHundredMs())) {
                    int oneHundredMS = disdipEqualTen.getOneHundredMS();
                    disdipEqualTen.setOneHundredMS(oneHundredMS++);
                }
                if (!"0".equals(disdipvo.getFiveHundredMs())) {
                    int fiveHundredMS = disdipEqualTen.getFiveHundredMS();
                    disdipEqualTen.setOneHundredMS(fiveHundredMS++);
                }
                if (!"0".equals(disdipvo.getOneS())) {
                    int one = disdipEqualTen.getOne();
                    disdipEqualTen.setOne(one++);
                }
                if (!"0".equals(disdipvo.getThreeS())) {
                    int three = disdipEqualTen.getThree();
                    disdipEqualTen.setOne(three++);
                }
                if (!"0".equals(disdipvo.getTwentyS())) {
                    int twenty = disdipEqualTen.getTwenty();
                    disdipEqualTen.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getSixtyS())) {
                    int sixty = disdipEqualTen.getSixty();
                    disdipEqualTen.setSixty(sixty++);
                }
                if (!"0".equals(disdipvo.getOneEightyS())) {
                    int oneHundredAndEighty = disdipEqualTen.getOneHundredAndEighty();
                    disdipEqualTen.setOneHundredAndEighty(oneHundredAndEighty++);
                }
            }

            DISDIPCountParam disdipEqualForty = new DISDIPCountParam();

            for (DISDIPVO disdipvo : equalFortyDISDIP) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(disdipEqualForty.getName())) {
                    disdipEqualForty.setName(disdipvo.getName());
                }

                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(disdipvo.getTwentyMs())) {
                    int twenty = disdipEqualForty.getTwenty();
                    disdipEqualForty.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getOneHundredMs())) {
                    int oneHundredMS = disdipEqualForty.getOneHundredMS();
                    disdipEqualForty.setOneHundredMS(oneHundredMS++);
                }
                if (!"0".equals(disdipvo.getFiveHundredMs())) {
                    int fiveHundredMS = disdipEqualForty.getFiveHundredMS();
                    disdipEqualForty.setOneHundredMS(fiveHundredMS++);
                }
                if (!"0".equals(disdipvo.getOneS())) {
                    int one = disdipEqualForty.getOne();
                    disdipEqualForty.setOne(one++);
                }
                if (!"0".equals(disdipvo.getThreeS())) {
                    int three = disdipEqualForty.getThree();
                    disdipEqualForty.setOne(three++);
                }
                if (!"0".equals(disdipvo.getTwentyS())) {
                    int twenty = disdipEqualForty.getTwenty();
                    disdipEqualForty.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getSixtyS())) {
                    int sixty = disdipEqualForty.getSixty();
                    disdipEqualForty.setSixty(sixty++);
                }
                if (!"0".equals(disdipvo.getOneEightyS())) {
                    int oneHundredAndEighty = disdipEqualForty.getOneHundredAndEighty();
                    disdipEqualForty.setOneHundredAndEighty(oneHundredAndEighty++);
                }
            }

            DISDIPCountParam disdipEqualSeventy = new DISDIPCountParam();

            for (DISDIPVO disdipvo : equalSeventyDISDIP) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(disdipEqualSeventy.getName())) {
                    disdipEqualSeventy.setName(disdipvo.getName());
                }

                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(disdipvo.getTwentyMs())) {
                    int twenty = disdipEqualSeventy.getTwenty();
                    disdipEqualSeventy.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getOneHundredMs())) {
                    int oneHundredMS = disdipEqualSeventy.getOneHundredMS();
                    disdipEqualSeventy.setOneHundredMS(oneHundredMS++);
                }
                if (!"0".equals(disdipvo.getFiveHundredMs())) {
                    int fiveHundredMS = disdipEqualSeventy.getFiveHundredMS();
                    disdipEqualSeventy.setOneHundredMS(fiveHundredMS++);
                }
                if (!"0".equals(disdipvo.getOneS())) {
                    int one = disdipEqualSeventy.getOne();
                    disdipEqualSeventy.setOne(one++);
                }
                if (!"0".equals(disdipvo.getThreeS())) {
                    int three = disdipEqualSeventy.getThree();
                    disdipEqualSeventy.setOne(three++);
                }
                if (!"0".equals(disdipvo.getTwentyS())) {
                    int twenty = disdipEqualSeventy.getTwenty();
                    disdipEqualSeventy.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getSixtyS())) {
                    int sixty = disdipEqualSeventy.getSixty();
                    disdipEqualSeventy.setSixty(sixty++);
                }
                if (!"0".equals(disdipvo.getOneEightyS())) {
                    int oneHundredAndEighty = disdipEqualSeventy.getOneHundredAndEighty();
                    disdipEqualSeventy.setOneHundredAndEighty(oneHundredAndEighty++);
                }
            }

            DISDIPCountParam disdipEqualEighty = new DISDIPCountParam();

            for (DISDIPVO disdipvo : equalEightyFiveDISDIP) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(disdipEqualEighty.getName())) {
                    disdipEqualEighty.setName(disdipvo.getName());
                }

                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(disdipvo.getTwentyMs())) {
                    int twenty = disdipEqualEighty.getTwenty();
                    disdipEqualEighty.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getOneHundredMs())) {
                    int oneHundredMS = disdipEqualEighty.getOneHundredMS();
                    disdipEqualEighty.setOneHundredMS(oneHundredMS++);
                }
                if (!"0".equals(disdipvo.getFiveHundredMs())) {
                    int fiveHundredMS = disdipEqualEighty.getFiveHundredMS();
                    disdipEqualEighty.setOneHundredMS(fiveHundredMS++);
                }
                if (!"0".equals(disdipvo.getOneS())) {
                    int one = disdipEqualEighty.getOne();
                    disdipEqualEighty.setOne(one++);
                }
                if (!"0".equals(disdipvo.getThreeS())) {
                    int three = disdipEqualEighty.getThree();
                    disdipEqualEighty.setOne(three++);
                }
                if (!"0".equals(disdipvo.getTwentyS())) {
                    int twenty = disdipEqualEighty.getTwenty();
                    disdipEqualEighty.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getSixtyS())) {
                    int sixty = disdipEqualEighty.getSixty();
                    disdipEqualEighty.setSixty(sixty++);
                }
                if (!"0".equals(disdipvo.getOneEightyS())) {
                    int oneHundredAndEighty = disdipEqualEighty.getOneHundredAndEighty();
                    disdipEqualEighty.setOneHundredAndEighty(oneHundredAndEighty++);
                }
            }
            DISDIPCountParam disdipEqualNinety = new DISDIPCountParam();

            for (DISDIPVO disdipvo : equalNinetyDISDIP) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(disdipEqualNinety.getName())) {
                    disdipEqualNinety.setName(disdipvo.getName());
                }

                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(disdipvo.getTwentyMs())) {
                    int twenty = disdipEqualNinety.getTwenty();
                    disdipEqualNinety.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getOneHundredMs())) {
                    int oneHundredMS = disdipEqualNinety.getOneHundredMS();
                    disdipEqualNinety.setOneHundredMS(oneHundredMS++);
                }
                if (!"0".equals(disdipvo.getFiveHundredMs())) {
                    int fiveHundredMS = disdipEqualNinety.getFiveHundredMS();
                    disdipEqualNinety.setOneHundredMS(fiveHundredMS++);
                }
                if (!"0".equals(disdipvo.getOneS())) {
                    int one = disdipEqualNinety.getOne();
                    disdipEqualNinety.setOne(one++);
                }
                if (!"0".equals(disdipvo.getThreeS())) {
                    int three = disdipEqualNinety.getThree();
                    disdipEqualNinety.setOne(three++);
                }
                if (!"0".equals(disdipvo.getTwentyS())) {
                    int twenty = disdipEqualNinety.getTwenty();
                    disdipEqualNinety.setTwenty(twenty++);
                }
                if (!"0".equals(disdipvo.getSixtyS())) {
                    int sixty = disdipEqualNinety.getSixty();
                    disdipEqualNinety.setSixty(sixty++);
                }
                if (!"0".equals(disdipvo.getOneEightyS())) {
                    int oneHundredAndEighty = disdipEqualNinety.getOneHundredAndEighty();
                    disdipEqualNinety.setOneHundredAndEighty(oneHundredAndEighty++);
                }
            }

            /**
             * ======================第二张表结束==============================
             */

            //创建计数对象
            IEC28CountParam iec28CountLessOne = new IEC28CountParam();

            for (IEC28VO iec28VO : lessOneIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessOne.getName())) {
                    iec28CountLessOne.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessOne.getZeroZeroTwoToZeroOne();
                    iec28CountLessOne.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessOne.getZeroOneToZeroTwentyFive();
                    iec28CountLessOne.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessOne.getZeroTwentyFiveToZeroFive();
                    iec28CountLessOne.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessOne.getZeroFiveToOne();
                    iec28CountLessOne.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessOne.getOneToThree();
                    iec28CountLessOne.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessOne.getThreeToTwenty();
                    iec28CountLessOne.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessOne.getTwentyToSixty();
                    iec28CountLessOne.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessOne.getSixtyToOneHundredAndEighty();
                    iec28CountLessOne.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessTen = new IEC28CountParam();

            for (IEC28VO iec28VO : lessTenIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessTen.getName())) {
                    iec28CountLessTen.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessTen.getZeroZeroTwoToZeroOne();
                    iec28CountLessTen.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessTen.getZeroOneToZeroTwentyFive();
                    iec28CountLessTen.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessTen.getZeroTwentyFiveToZeroFive();
                    iec28CountLessTen.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessTen.getZeroFiveToOne();
                    iec28CountLessTen.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessTen.getOneToThree();
                    iec28CountLessTen.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessTen.getThreeToTwenty();
                    iec28CountLessTen.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessTen.getTwentyToSixty();
                    iec28CountLessTen.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessTen.getSixtyToOneHundredAndEighty();
                    iec28CountLessTen.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessTwenty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessTwentyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessTwenty.getName())) {
                    iec28CountLessTwenty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessTwenty.getZeroZeroTwoToZeroOne();
                    iec28CountLessTwenty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessTwenty.getZeroOneToZeroTwentyFive();
                    iec28CountLessTwenty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessTwenty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessTwenty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessTwenty.getZeroFiveToOne();
                    iec28CountLessTwenty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessTwenty.getOneToThree();
                    iec28CountLessTwenty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessTwenty.getThreeToTwenty();
                    iec28CountLessTwenty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessTwenty.getTwentyToSixty();
                    iec28CountLessTwenty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessTwenty.getSixtyToOneHundredAndEighty();
                    iec28CountLessTwenty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessThirty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessThirtyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessThirty.getName())) {
                    iec28CountLessThirty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessThirty.getZeroZeroTwoToZeroOne();
                    iec28CountLessThirty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessThirty.getZeroOneToZeroTwentyFive();
                    iec28CountLessThirty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessThirty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessThirty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessThirty.getZeroFiveToOne();
                    iec28CountLessThirty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessThirty.getOneToThree();
                    iec28CountLessThirty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessThirty.getThreeToTwenty();
                    iec28CountLessThirty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessThirty.getTwentyToSixty();
                    iec28CountLessThirty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessThirty.getSixtyToOneHundredAndEighty();
                    iec28CountLessThirty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessForty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessFortyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessForty.getName())) {
                    iec28CountLessForty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessForty.getZeroZeroTwoToZeroOne();
                    iec28CountLessForty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessForty.getZeroOneToZeroTwentyFive();
                    iec28CountLessForty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessForty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessForty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessForty.getZeroFiveToOne();
                    iec28CountLessForty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessForty.getOneToThree();
                    iec28CountLessForty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessForty.getThreeToTwenty();
                    iec28CountLessForty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessForty.getTwentyToSixty();
                    iec28CountLessForty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessForty.getSixtyToOneHundredAndEighty();
                    iec28CountLessForty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessFifty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessFiftyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessFifty.getName())) {
                    iec28CountLessFifty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessFifty.getZeroZeroTwoToZeroOne();
                    iec28CountLessFifty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessFifty.getZeroOneToZeroTwentyFive();
                    iec28CountLessFifty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessFifty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessFifty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessFifty.getZeroFiveToOne();
                    iec28CountLessFifty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessFifty.getOneToThree();
                    iec28CountLessFifty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessFifty.getThreeToTwenty();
                    iec28CountLessFifty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessFifty.getTwentyToSixty();
                    iec28CountLessFifty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessFifty.getSixtyToOneHundredAndEighty();
                    iec28CountLessFifty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessSixty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessSixtyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessSixty.getName())) {
                    iec28CountLessSixty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessSixty.getZeroZeroTwoToZeroOne();
                    iec28CountLessSixty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessSixty.getZeroOneToZeroTwentyFive();
                    iec28CountLessSixty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessSixty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessSixty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessSixty.getZeroFiveToOne();
                    iec28CountLessSixty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessSixty.getOneToThree();
                    iec28CountLessSixty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessSixty.getThreeToTwenty();
                    iec28CountLessSixty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessSixty.getTwentyToSixty();
                    iec28CountLessSixty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessSixty.getSixtyToOneHundredAndEighty();
                    iec28CountLessSixty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessSeventy = new IEC28CountParam();

            for (IEC28VO iec28VO : lessSeventyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessSeventy.getName())) {
                    iec28CountLessSeventy.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessSeventy.getZeroZeroTwoToZeroOne();
                    iec28CountLessSeventy.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessSeventy.getZeroOneToZeroTwentyFive();
                    iec28CountLessSeventy.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessSeventy.getZeroTwentyFiveToZeroFive();
                    iec28CountLessSeventy.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessSeventy.getZeroFiveToOne();
                    iec28CountLessSeventy.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessSeventy.getOneToThree();
                    iec28CountLessSeventy.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessSeventy.getThreeToTwenty();
                    iec28CountLessSeventy.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessSeventy.getTwentyToSixty();
                    iec28CountLessSeventy.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessSeventy.getSixtyToOneHundredAndEighty();
                    iec28CountLessSeventy.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessEighty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessEightyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessEighty.getName())) {
                    iec28CountLessEighty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessEighty.getZeroZeroTwoToZeroOne();
                    iec28CountLessEighty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessEighty.getZeroOneToZeroTwentyFive();
                    iec28CountLessEighty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessEighty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessEighty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessEighty.getZeroFiveToOne();
                    iec28CountLessEighty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessEighty.getOneToThree();
                    iec28CountLessEighty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessEighty.getThreeToTwenty();
                    iec28CountLessEighty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessEighty.getTwentyToSixty();
                    iec28CountLessEighty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessEighty.getSixtyToOneHundredAndEighty();
                    iec28CountLessEighty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }

            //创建计数对象
            IEC28CountParam iec28CountLessNinety = new IEC28CountParam();

            for (IEC28VO iec28VO : lessNinetyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessNinety.getName())) {
                    iec28CountLessNinety.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessNinety.getZeroZeroTwoToZeroOne();
                    iec28CountLessNinety.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessNinety.getZeroOneToZeroTwentyFive();
                    iec28CountLessNinety.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessNinety.getZeroTwentyFiveToZeroFive();
                    iec28CountLessNinety.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessNinety.getZeroFiveToOne();
                    iec28CountLessNinety.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessNinety.getOneToThree();
                    iec28CountLessNinety.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessNinety.getThreeToTwenty();
                    iec28CountLessNinety.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessNinety.getTwentyToSixty();
                    iec28CountLessNinety.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessNinety.getSixtyToOneHundredAndEighty();
                    iec28CountLessNinety.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }

            //创建计数对象
            IEC28CountParam iec28CountLessHundredTwenty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessHundredTwentyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessHundredTwenty.getName())) {
                    iec28CountLessHundredTwenty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessHundredTwenty.getZeroZeroTwoToZeroOne();
                    iec28CountLessHundredTwenty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessHundredTwenty.getZeroOneToZeroTwentyFive();
                    iec28CountLessHundredTwenty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredTwenty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessHundredTwenty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessHundredTwenty.getZeroFiveToOne();
                    iec28CountLessHundredTwenty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessHundredTwenty.getOneToThree();
                    iec28CountLessHundredTwenty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessHundredTwenty.getThreeToTwenty();
                    iec28CountLessHundredTwenty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessHundredTwenty.getTwentyToSixty();
                    iec28CountLessHundredTwenty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessHundredTwenty.getSixtyToOneHundredAndEighty();
                    iec28CountLessHundredTwenty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessHundredThirty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessHundredThirtyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessHundredThirty.getName())) {
                    iec28CountLessHundredThirty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessHundredThirty.getZeroZeroTwoToZeroOne();
                    iec28CountLessHundredThirty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessHundredThirty.getZeroOneToZeroTwentyFive();
                    iec28CountLessHundredThirty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredThirty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessHundredThirty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessHundredThirty.getZeroFiveToOne();
                    iec28CountLessHundredThirty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessHundredThirty.getOneToThree();
                    iec28CountLessHundredThirty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessHundredThirty.getThreeToTwenty();
                    iec28CountLessHundredThirty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessHundredThirty.getTwentyToSixty();
                    iec28CountLessHundredThirty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessHundredThirty.getSixtyToOneHundredAndEighty();
                    iec28CountLessHundredThirty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }

            //创建计数对象
            IEC28CountParam iec28CountLessHundredForty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessHundredFortyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessHundredForty.getName())) {
                    iec28CountLessHundredForty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessHundredForty.getZeroZeroTwoToZeroOne();
                    iec28CountLessHundredForty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessHundredForty.getZeroOneToZeroTwentyFive();
                    iec28CountLessHundredForty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredForty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessHundredForty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessHundredForty.getZeroFiveToOne();
                    iec28CountLessHundredForty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessHundredForty.getOneToThree();
                    iec28CountLessHundredForty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessHundredForty.getThreeToTwenty();
                    iec28CountLessHundredForty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessHundredForty.getTwentyToSixty();
                    iec28CountLessHundredForty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessHundredForty.getSixtyToOneHundredAndEighty();
                    iec28CountLessHundredForty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessHundredFifty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessHundredFiftyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessHundredFifty.getName())) {
                    iec28CountLessHundredFifty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessHundredFifty.getZeroZeroTwoToZeroOne();
                    iec28CountLessHundredFifty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessHundredFifty.getZeroOneToZeroTwentyFive();
                    iec28CountLessHundredFifty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredFifty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessHundredFifty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessHundredFifty.getZeroFiveToOne();
                    iec28CountLessHundredFifty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessHundredFifty.getOneToThree();
                    iec28CountLessHundredFifty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessHundredFifty.getThreeToTwenty();
                    iec28CountLessHundredFifty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessHundredFifty.getTwentyToSixty();
                    iec28CountLessHundredFifty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessHundredFifty.getSixtyToOneHundredAndEighty();
                    iec28CountLessHundredFifty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessHundredSixty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessHundredSixtyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessHundredSixty.getName())) {
                    iec28CountLessHundredSixty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessHundredSixty.getZeroZeroTwoToZeroOne();
                    iec28CountLessHundredSixty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessHundredSixty.getZeroOneToZeroTwentyFive();
                    iec28CountLessHundredSixty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredSixty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessHundredSixty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessHundredSixty.getZeroFiveToOne();
                    iec28CountLessHundredSixty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessHundredSixty.getOneToThree();
                    iec28CountLessHundredSixty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessHundredSixty.getThreeToTwenty();
                    iec28CountLessHundredSixty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessHundredSixty.getTwentyToSixty();
                    iec28CountLessHundredSixty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessHundredSixty.getSixtyToOneHundredAndEighty();
                    iec28CountLessHundredSixty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessHundredSeventy = new IEC28CountParam();

            for (IEC28VO iec28VO : lessHundredSeventyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessHundredSeventy.getName())) {
                    iec28CountLessHundredSeventy.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessHundredSeventy.getZeroZeroTwoToZeroOne();
                    iec28CountLessHundredSeventy.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessHundredSeventy.getZeroOneToZeroTwentyFive();
                    iec28CountLessHundredSeventy.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredSeventy.getZeroTwentyFiveToZeroFive();
                    iec28CountLessHundredSeventy.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessHundredSeventy.getZeroFiveToOne();
                    iec28CountLessHundredSeventy.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessHundredSeventy.getOneToThree();
                    iec28CountLessHundredSeventy.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessHundredSeventy.getThreeToTwenty();
                    iec28CountLessHundredSeventy.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessHundredSeventy.getTwentyToSixty();
                    iec28CountLessHundredSeventy.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessHundredSeventy.getSixtyToOneHundredAndEighty();
                    iec28CountLessHundredSeventy.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }


            //创建计数对象
            IEC28CountParam iec28CountLessHundredEighty = new IEC28CountParam();

            for (IEC28VO iec28VO : lessHundredEightyIEC28) {
                //获取当前剩余电压名称,不为空就进行添加
                if (Objects.isNull(iec28CountLessHundredEighty.getName())) {
                    iec28CountLessHundredEighty.setName(iec28VO.getName());
                }
                //如果参数不等于0对对象中的参数进行++
                if (!"0".equals(iec28VO.getQ())) {
                    int zeroZeroTwoToZeroOne = iec28CountLessHundredEighty.getZeroZeroTwoToZeroOne();
                    iec28CountLessHundredEighty.setZeroZeroTwoToZeroOne(zeroZeroTwoToZeroOne++);
                }
                if (!"0".equals(iec28VO.getW())) {
                    int zeroOneToZeroTwentyFive = iec28CountLessHundredEighty.getZeroOneToZeroTwentyFive();
                    iec28CountLessHundredEighty.setZeroOneToZeroTwentyFive(zeroOneToZeroTwentyFive++);
                }
                if (!"0".equals(iec28VO.getE())) {
                    int zeroTwentyFiveToZeroFive = iec28CountLessHundredEighty.getZeroTwentyFiveToZeroFive();
                    iec28CountLessHundredEighty.setZeroTwentyFiveToZeroFive(zeroTwentyFiveToZeroFive++);
                }
                if (!"0".equals(iec28VO.getR())) {
                    int zeroFiveToOne = iec28CountLessHundredEighty.getZeroFiveToOne();
                    iec28CountLessHundredEighty.setZeroFiveToOne(zeroFiveToOne++);
                }
                if (!"0".equals(iec28VO.getT())) {
                    int oneToThree = iec28CountLessHundredEighty.getOneToThree();
                    iec28CountLessHundredEighty.setOneToThree(oneToThree++);
                }
                if (!"0".equals(iec28VO.getY())) {
                    int threeToTwenty = iec28CountLessHundredEighty.getThreeToTwenty();
                    iec28CountLessHundredEighty.setThreeToTwenty(threeToTwenty++);
                }
                if (!"0".equals(iec28VO.getU())) {
                    int twentyToSixty = iec28CountLessHundredEighty.getTwentyToSixty();
                    iec28CountLessHundredEighty.setTwentyToSixty(twentyToSixty++);
                }
                if (!"0".equals(iec28VO.getI())) {
                    int sixtyToOneHundredAndEighty = iec28CountLessHundredEighty.getSixtyToOneHundredAndEighty();
                    iec28CountLessHundredEighty.setSixtyToOneHundredAndEighty(sixtyToOneHundredAndEighty++);
                }
            }

            /**
             * =========================第三张表结束===============================
             */


            //汇总放入集合
            List<IEC411CountParam> iec411Result = new ArrayList<>();
            iec411Result.add(iec411LessOne);
            iec411Result.add(iec411LessForty);
            iec411Result.add(iec411LessSeventy);

            List<DISDIPCountParam> disdipResult = new ArrayList<>();
            disdipResult.add(disdipEqualTen);
            disdipResult.add(disdipEqualForty);
            disdipResult.add(disdipEqualSeventy);
            disdipResult.add(disdipEqualEighty);
            disdipResult.add(disdipEqualNinety);

            List<IEC28CountParam> iec28Result = new ArrayList<>();
            iec28Result.add(iec28CountLessOne);
            iec28Result.add(iec28CountLessTen);
            iec28Result.add(iec28CountLessTwenty);
            iec28Result.add(iec28CountLessThirty);
            iec28Result.add(iec28CountLessForty);
            iec28Result.add(iec28CountLessFifty);
            iec28Result.add(iec28CountLessSixty);
            iec28Result.add(iec28CountLessSeventy);
            iec28Result.add(iec28CountLessEighty);
            iec28Result.add(iec28CountLessNinety);
            iec28Result.add(iec28CountLessHundredTwenty);
            iec28Result.add(iec28CountLessHundredThirty);
            iec28Result.add(iec28CountLessHundredForty);
            iec28Result.add(iec28CountLessHundredFifty);
            iec28Result.add(iec28CountLessHundredSixty);
            iec28Result.add(iec28CountLessHundredSeventy);
            iec28Result.add(iec28CountLessHundredEighty);


            Map<String, Integer> resultMap = new HashMap<>();

            for (int i = 0; i < iec28Result.size(); i++) {

                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getSixtyToOneHundredAndEighty());
                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getOneToThree());
                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroFiveToOne());
                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroOneToZeroTwentyFive());
                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroTwentyFiveToZeroFive());
                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getThreeToTwenty());
                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getTwentyToSixty());
                resultMap.put(iec28Result.get(i).getName(), iec28Result.get(i).getZeroZeroTwoToZeroOne());
            }

            //todo 还要对集合中哪个次数最多挑出第一位
            Map<String, Integer> linkMap = getSort(resultMap);

            //存放结果的集合
            List<String> resultList = new ArrayList<String>();

            for (String s : linkMap.keySet()) {
                resultList.add(s);
                resultList.add(linkMap.get(s).toString());
            }

            //最多暂降事件名称
            for (int i = 0; i < iec28Result.size(); i++) {
                if (iec28Result.get(i).getName().equals(resultList.get(0))) {
                    if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroZeroTwoToZeroOne()))) {
                        resultList.add("0.02~0.1");
                        break;
                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroOneToZeroTwentyFive()))) {
                        resultList.add("0.1~0.25");
                        break;
                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroTwentyFiveToZeroFive()))) {
                        resultList.add("0.25~0.5");
                        break;
                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getZeroFiveToOne()))) {
                        resultList.add("0.5~1");
                        break;
                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getOneToThree()))) {
                        resultList.add("1~3");
                        break;
                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getThreeToTwenty()))) {
                        resultList.add("3~20");
                        break;
                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getTwentyToSixty()))) {
                        resultList.add("20~60");
                        break;
                    } else if (resultList.get(1).equals(String.valueOf(iec28Result.get(i).getSixtyToOneHundredAndEighty()))) {
                        resultList.add("60~180");
                        break;
                    }
                }
            }
            //System.out.println(resultList);


            //3.1密度密度表格
            if (areaReportParam.isDensityTable()) {
                //创建表题计数
                int twoCount = 1;

                //同步给暂降密度图
                oneCount4 = oneCount;

                createTitle(doc, "4." + oneCount + " " + typeName + "密度", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + typeName + "密度统计可以从幅值和持续时间两个维度直接地反映" + typeName + "事件发生情况，主要反应事件的发生次数，" +
                        "中国电网在所选择的分析时间内" + typeName + "事件主要集中在幅值为" + resultList.get(0) + "，持续时间为" + resultList.get(2) + "[根据 IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)算出" + typeName + "事件发生最多的区间],具体见表（图）：");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " DISDIP表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 11);

                //第一张表
                XWPFTable monitorInfo = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc);

                // 表格第一行
                insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s");


                //塞入数据
                for (int i = 0; i < disdipResult.size(); i++) {
                    insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, disdipResult.get(i).getName(), String.valueOf(disdipResult.get(i).getTwentyMS()),
                            String.valueOf(disdipResult.get(i).getOneHundredMS()), String.valueOf(disdipResult.get(i).getFiveHundredMS()), String.valueOf(disdipResult.get(i).getOne()), String.valueOf(disdipResult.get(i).getThree()),
                            String.valueOf(disdipResult.get(i).getTwenty()), String.valueOf(disdipResult.get(i).getSixty()), String.valueOf(disdipResult.get(i).getOneHundredAndEighty()));
                }

                twoCount++;


                createTitle(doc, "4." + oneCount + "." + twoCount + " IEC 61000-4-11:(用电终端的电压" + typeName + "抗度)", "标题 3", 400, 11);

                //第二张表
                XWPFTable monitorInfo1 = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph1 = WordUtils.getCenterParagraph(doc);

                // 表格第一行
                insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");


                //塞入数据
                for (int i = 0; i < iec411Result.size(); i++) {
                    insertRow(doc, monitorInfo1, monitorInfoExcelParagraph1, false, iec411Result.get(i).getName(), String.valueOf(iec411Result.get(i).getTenToTwenty()), String.valueOf(iec411Result.get(i).getTwentyToHundred()),
                            String.valueOf(iec411Result.get(i).getZeroOneToZeroTwo()), String.valueOf(iec411Result.get(i).getZeroTwoToZeroFive()), String.valueOf(iec411Result.get(i).getZeroFiveToOne()), String.valueOf(iec411Result.get(i).getLessOne()));
                }

                twoCount++;


                createTitle(doc, "4." + oneCount + "." + twoCount + " IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)", "标题 3", 400, 11);

                //第二张表
                XWPFTable monitorInfo2 = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc);

                // 表格第一行
                insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5~1s", "1~3s", "3~20s", "20~60s", "60~180s");


                //塞入数据
                for (int i = 0; i < iec28Result.size(); i++) {
                    insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, iec28Result.get(i).getName(), String.valueOf(iec28Result.get(i).getZeroZeroTwoToZeroOne()), String.valueOf(iec28Result.get(i).getZeroOneToZeroTwentyFive()),
                            String.valueOf(iec28Result.get(i).getZeroTwentyFiveToZeroFive()), String.valueOf(iec28Result.get(i).getZeroFiveToOne()), String.valueOf(iec28Result.get(i).getOneToThree()), String.valueOf(iec28Result.get(i).getThreeToTwenty()),
                            String.valueOf(iec28Result.get(i).getTwentyToSixty()), String.valueOf(iec28Result.get(i).getSixtyToOneHundredAndEighty()));
                }

                //同步给暂降密度表格
                twoCount1 = twoCount;
                //序号计数进行++
                oneCount++;
            }

            //3.2暂降密度图表
            if (areaReportParam.isDensityChart()) {

                //如果暂降幅值被勾选,就不需要进行写段落
                if (areaReportParam.isDensityTable()) {
                    twoCount1++;

                    //如果幅值图存在与幅值的序号保持同步
                    createTitle(doc, "4." + oneCount4 + "." + twoCount1 + " " + typeName + "密度图", "标题 3", 400, 11);

                    List<EventDetail> eventDetails = BeanUtil.copyToList(info, EventDetail.class);
                    Integer[][] eventDensityData = eventReportService.getCoords(eventDetails);
                    String str = drawPicUtil.drawEventDensity(eventDensityData);
                    createPic(doc, str, "" + typeName + "密度图形");
                } else {
                    int twoCount = 1;
                    createTitle(doc, "4." + oneCount + " " + typeName + "密度", "标题 2", 200, 11);

                    p = doc.createParagraph();// 新建一个段落
                    p.setAlignment(ParagraphAlignment.BOTH);
                    XWPFRun r12 = p.createRun();//创建段落文本
                    r12.setText("  " + typeName + "密度统计可以从幅值和持续时间两个维度直接地反映" + typeName + "事件发生情况，主要反应事件的发生次数，" +
                            "中国电网在所选择的分析时间内" + typeName + "事件主要集中在幅值为" + resultList.get(0) + "，持续时间为" + resultList.get(2) + "[根据 IEC 61000-2-8:(公共电网电压" + typeName + "测量统计)算出" + typeName + "事件发生最多的区间],具体见表（图）：");
                    r12.setFontSize(11);//字体大小


                    createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "密度图", "标题 3", 400, 11);


                    //代码
                    List<EventDetail> eventDetails = BeanUtil.copyToList(info, EventDetail.class);
                    Integer[][] eventDensityData = eventReportService.getCoords(eventDetails);
                    String str = drawPicUtil.drawEventDensity(eventDensityData);
                    createPic(doc, str, "" + typeName + "密度图形");

                    //序号计数进行++
                    oneCount++;
                }
            }
        }

        //4.itic图
        if (areaReportParam.isItic()) {
            //itic图

            List<EventDetailNew> detailList = eventDetailList;

            List<OB> obs = new ArrayList<>();
            ArrayList<List<Double>> list = new ArrayList<>();
            for (EventDetailNew eventDetail : detailList) {
                obs.add(new OB(Double.parseDouble(eventDetail.getDuration()  + "")
                        , Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + "")));

                ArrayList<Double> doubles = new ArrayList<>();
                doubles.add(Double.parseDouble(eventDetail.getDuration()  + ""));
                doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
                list.add(doubles);
            }

            List<Integer> result = getITICArea(obs);

            /**
             * =========================续写word文档==============================================
             */
            //创建表题计数
            int twoCount = 1;

            oneCount3 = oneCount;

            createTitle(doc, "4." + oneCount3 + " " + typeName + "事件点图", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            r12.setText("  " + typeName + "事件点图统计分成ITIC曲线和F47曲线展示。");
            r12.setFontSize(11);//字体大小


            createTitle(doc, "4." + oneCount3 + "." + twoCount + " ITIC 曲线", "标题 3", 400, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r13 = p.createRun();//创建段落文本
            r13.setText("  ITIC曲线中可容忍" + typeName + "记录为：" + result.get(0) + "条；不可容忍" + typeName + "记录为：" + result.get(1) + "条，具体见下表（图）：");
            r13.setFontSize(11);//字体大小


            String itic = drawPicUtil.drawItic(list);
            createPic(doc, itic, "ITIC曲线");


            twoCount5 = twoCount;
            //序号计数进行++
            oneCount++;

            /**
             * =======================================word结束=========================================
             */


        }

        //5.f47图
        if (areaReportParam.isF47()) {
            //f47图
            List<EventDetailNew> detailList = eventDetailList;

            List<OB> obs = new ArrayList<>();

            ArrayList<List<Double>> list = new ArrayList<>();
            for (EventDetailNew eventDetail : detailList) {
                obs.add(new OB(Double.parseDouble(eventDetail.getDuration() + ""), Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + "")));

                ArrayList<Double> doubles = new ArrayList<>();
                doubles.add(Double.parseDouble(eventDetail.getDuration()  + ""));
                doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
                list.add(doubles);
            }


            List<Integer> result = getF47Area(obs);

            /**
             * =========================续写word文档==============================================
             */

            if (areaReportParam.isItic()) {
                twoCount5++;

                createTitle(doc, "4." + oneCount3 + "." + twoCount5 + " F47 曲线", "标题 3", 400, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r13 = p.createRun();//创建段落文本
                r13.setText("  F47曲线中可容忍" + typeName + "记录为：" + result.get(0) + "条；不可容忍" + typeName + "记录为：" + result.get(1) + "条，具体见下表（图）：");
                r13.setFontSize(11);//字体大小


                String f47 = drawPicUtil.drawF47(list);
                createPic(doc, f47, "SEMI F47曲线");

                /**
                 * =======================================word结束=========================================
                 */
            } else {
                //创建表题计数
                int twoCount = 1;

                oneCount3 = oneCount;

                createTitle(doc, "4." + oneCount + " " + typeName + "事件点图", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + typeName + "事件点图统计分成ITIC曲线和F47曲线展示。");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " F47 曲线", "标题 3", 400, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r13 = p.createRun();//创建段落文本
                r13.setText("  F47曲线中可容忍" + typeName + "降记录为：" + result.get(0) + "条；不可容忍" + typeName + "记录为：" + result.get(1) + "条，具体见下表（图）：");
                r13.setFontSize(11);//字体大小

                String f47 = drawPicUtil.drawF47(list);
                createPic(doc, f47, "SEMI F47曲线");


                //序号计数进行++
                oneCount++;

                /**
                 * =======================================word结束=========================================
                 */
            }


        }

        //6.暂降增幅
        if (areaReportParam.isSagAmplitude()) {
            //暂降分布幅值
            List<EventDetailNew> info = eventDetailList;

            //将sql结果集放入,共用一个sql,减少查询时间
            AreaTableParam areaTableParam1 = new AreaTableParam();
            areaTableParam1.setStartTime(areaReportParam.getSearchBeginTime());
            areaTableParam1.setEndTime(areaReportParam.getSearchEndTime());
            areaTableParam1.setInfo(info);
            ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1);


            List<String> eventvalue = probabilityDistributionArea.getEventvalue();

            List<AmplitudeCountParam> amplitudeList = new ArrayList<>();

            List<String> xName = new ArrayList<>();
            xName.add("0");
            xName.add("10%");
            xName.add("20%");
            xName.add("30%");
            xName.add("40%");
            xName.add("50%");
            xName.add("60%");
            xName.add("70%");
            xName.add("80%");
            xName.add("90%");
            //将幅值绑定对应的x值,放入集合
            for (int i = 0; i < eventvalue.size(); i++) {
                AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam();
                amplitudeCountParam.setXName(xName.get(i));
                amplitudeCountParam.setYValue(eventvalue.get(i));
                amplitudeList.add(amplitudeCountParam);
            }
            //存储幅值结果集合
            List<String> amplitudeResult = new ArrayList<>();
            for (int i = 1; i < amplitudeList.size(); i++) {
                if (!amplitudeList.get(i).getYValue().equals(amplitudeList.get(i - 1).getYValue())) {
                    amplitudeResult.add(amplitudeList.get(i - 1).getXName());
                    amplitudeResult.add(amplitudeList.get(i).getXName());
                    break;
                } else if (amplitudeList.get(0).getYValue().equals(amplitudeList.get(amplitudeList.size() - 1).getYValue())) {
                    amplitudeResult.add(amplitudeList.get(0).getXName());
                    amplitudeResult.add(amplitudeList.get(amplitudeList.size() - 1).getXName());
                    break;
                }
            }


            List<String> eventvalue1 = probabilityDistributionArea.getSisttime();

            List<AmplitudeCountParam> amplitudeList1 = new ArrayList<>();

            List<String> xName1 = new ArrayList<>();
            xName1.add("0.01");
            xName1.add("0.1");
            xName1.add("0.25");
            xName1.add("0.5");
            xName1.add("1");
            xName1.add("3");
            xName1.add("20");
            xName1.add("60");
            xName1.add("180");
            //将幅值绑定对应的x值,放入集合
            for (int i = 0; i < eventvalue1.size(); i++) {
                AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam();
                amplitudeCountParam.setXName(xName1.get(i));
                amplitudeCountParam.setYValue(eventvalue1.get(i));
                amplitudeList1.add(amplitudeCountParam);
            }
            //存储幅值结果集合
            List<String> amplitudeResult1 = new ArrayList<>();
            for (int i = 1; i < amplitudeList1.size(); i++) {
                if (!amplitudeList1.get(i).getYValue().equals(amplitudeList1.get(i - 1).getYValue())) {
                    amplitudeResult1.add(amplitudeList1.get(i - 1).getXName());
                    amplitudeResult1.add(amplitudeList1.get(i).getXName());
                    break;
                } else if (amplitudeList1.get(0).getYValue().equals(amplitudeList1.get(amplitudeList1.size() - 1).getYValue())) {
                    amplitudeResult1.add(amplitudeList1.get(0).getXName());
                    amplitudeResult1.add(amplitudeList1.get(amplitudeList1.size() - 1).getXName());
                    break;
                }
            }


            /**
             * =========================续写word文档==============================================
             */
            //创建表题计数
            int twoCount = 1;

            oneCount2 = oneCount;

            createTitle(doc, "4." + oneCount2 + " " + typeName + "幅值概率分布图", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            r12.setText("  " + typeName + "概率分布图分成" + typeName + "幅值概率分布和持续时间概率分布图，中国电网在所选择的分析时间内" + typeName + "事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间，" +
                    "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序，选择" + typeName + "记录发生最多的区域]，如下表（图）：");
            r12.setFontSize(11);//字体大小


            createTitle(doc, "4." + oneCount + "." + twoCount + " " + typeName + "幅值的概率分布函数", "标题 3", 400, 11);


            List<String> ybardata = probabilityDistributionArea.getPereventvalue();
            List<String> ylinedata = probabilityDistributionArea.getEventvalue();
            String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
            createPic(doc, fz, "" + typeName + "幅值的概率分布函数");


            //序号计数进行++
            oneCount++;

            /**
             * =======================================word结束=========================================
             */

        }

        //7.暂降持续时间
        if (areaReportParam.isDuration()) {
            //持续时间概率分布
            AreaTableParam areaTableParam = new AreaTableParam();


            //创建结果集合
            List<EventDetailNew> info = eventDetailList;

            //将sql结果集放入,共用一个sql,减少查询时间
            AreaTableParam areaTableParam1 = new AreaTableParam();
            areaTableParam1.setInfo(info);
            ProbabilityVO probabilityDistributionArea = getProbabilityDistributionArea(areaTableParam1);


            List<String> eventvalue = probabilityDistributionArea.getEventvalue();

            List<AmplitudeCountParam> amplitudeList = new ArrayList<>();

            List<String> xName = new ArrayList<>();
            xName.add("0");
            xName.add("10%");
            xName.add("20%");
            xName.add("30%");
            xName.add("40%");
            xName.add("50%");
            xName.add("60%");
            xName.add("70%");
            xName.add("80%");
            xName.add("90%");
            //将幅值绑定对应的x值,放入集合
            for (int i = 0; i < eventvalue.size(); i++) {
                AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam();
                amplitudeCountParam.setXName(xName.get(i));
                amplitudeCountParam.setYValue(eventvalue.get(i));
                amplitudeList.add(amplitudeCountParam);
            }
            //存储幅值结果集合
            List<String> amplitudeResult = new ArrayList<>();
            for (int i = 1; i < amplitudeList.size(); i++) {
                if (!amplitudeList.get(i).getYValue().equals(amplitudeList.get(i - 1).getYValue())) {
                    amplitudeResult.add(amplitudeList.get(i - 1).getXName());
                    amplitudeResult.add(amplitudeList.get(i).getXName());
                    break;
                } else if (amplitudeList.get(0).getYValue().equals(amplitudeList.get(amplitudeList.size() - 1).getYValue())) {
                    amplitudeResult.add(amplitudeList.get(0).getXName());
                    amplitudeResult.add(amplitudeList.get(amplitudeList.size() - 1).getXName());
                    break;
                }
            }


            List<String> eventvalue1 = probabilityDistributionArea.getSisttime();

            List<AmplitudeCountParam> amplitudeList1 = new ArrayList<>();

            List<String> xName1 = new ArrayList<>();
            xName1.add("0.01");
            xName1.add("0.1");
            xName1.add("0.25");
            xName1.add("0.5");
            xName1.add("1");
            xName1.add("3");
            xName1.add("20");
            xName1.add("60");
            xName1.add("180");
            //将幅值绑定对应的x值,放入集合
            for (int i = 0; i < eventvalue1.size(); i++) {
                AmplitudeCountParam amplitudeCountParam = new AmplitudeCountParam();
                amplitudeCountParam.setXName(xName1.get(i));
                amplitudeCountParam.setYValue(eventvalue1.get(i));
                amplitudeList1.add(amplitudeCountParam);
            }
            //存储幅值结果集合
            List<String> amplitudeResult1 = new ArrayList<>();
            for (int i = 1; i < amplitudeList1.size(); i++) {
                if (!amplitudeList1.get(i).getYValue().equals(amplitudeList1.get(i - 1).getYValue())) {
                    amplitudeResult1.add(amplitudeList1.get(i - 1).getXName());
                    amplitudeResult1.add(amplitudeList1.get(i).getXName());
                    break;
                } else if (amplitudeList1.get(0).getYValue().equals(amplitudeList1.get(amplitudeList1.size() - 1).getYValue())) {
                    amplitudeResult1.add(amplitudeList1.get(0).getXName());
                    amplitudeResult1.add(amplitudeList1.get(amplitudeList1.size() - 1).getXName());
                    break;
                }
            }
            /**
             * =========================续写word文档==============================================
             */

            //创建表题计数
            int twoCount = 1;

            //如果暂降幅值被勾选,就不需要进行写段落
            if (areaReportParam.isSagAmplitude()) {
                twoCount++;

                //如果幅值图存在与幅值的序号保持同步
                createTitle(doc, "4." + oneCount2 + "." + twoCount + " 时序时间的概率分函数", "标题 3", 400, 11);


                List<String> ybardata = probabilityDistributionArea.getPersisttime();
                List<String> ylinedata = probabilityDistributionArea.getSisttime();
                String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
                createPic(doc, sj, "持续时间的概率分布函数");


            } else {
                createTitle(doc, "4." + oneCount2 + " " + typeName + "幅值概率分布图", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + typeName + "概率分布图分成" + typeName + "幅值概率分布和持续时间概率分布图，中国电网在所选择的分析时间内" + typeName + "事件从幅值概率分布统计主要集中在幅值为" + amplitudeResult.get(0) + "~" + amplitudeResult.get(1) + "之间，" +
                        "从持续时间统计主要集中在持续时间为" + amplitudeResult1.get(0) + "~" + amplitudeResult1.get(1) + "[持续时间排序，选择" + typeName + "记录发生最多的区域]，如下表（图）：");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " 时序时间的概率分函数", "标题 3", 400, 11);


                List<String> ybardata = probabilityDistributionArea.getPersisttime();
                List<String> ylinedata = probabilityDistributionArea.getSisttime();
                String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
                createPic(doc, sj, "持续时间的概率分布函数");


                //序号计数进行++
                oneCount++;
            }
            /**
             * =======================================word结束=========================================
             */
        }

        //8.事件关联统计表格
        if (areaReportParam.isEventRelevanceCountTable()) {
            //事件关联统计表格
            int resultCount = 0;
            List<EventassCountParam> resultList = new ArrayList<>();

            List<EventDetailNew> eventList = eventDetailList.stream().filter(e -> StrUtil.isNotBlank(e.getEventassIndex())).collect(Collectors.toList());

            if (CollectionUtil.isNotEmpty(eventList)) {
                //记录条数
                resultCount = eventList.size();

                List<String> ids = eventList.stream().map(EventDetailNew::getEventassIndex).collect(Collectors.toList());
                List<Eventass> eventAssList = eventDetailMapper.ListEventass(ids);

                for (Eventass eventass : eventAssList) {
                    EventassCountParam eventassCountParam = new EventassCountParam();
                    String dateTime = LocalDateTimeUtil.format(eventass.getTimeId(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
                    eventassCountParam.setAssTime(dateTime);
                    //获取时间
                    eventassCountParam.setEventTime(dateTime);
                    eventassCountParam.setDescribe(eventass.getContentDes());
                    resultList.add(eventassCountParam);
                }
            }


            createTitle(doc, "4." + oneCount + " 事件关联分析", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            //归一化需要高级算法,先字符串代替
            r12.setText("  " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条，归一化统计后共" + resultCount + "[此为归一化后的暂态事件结果]条，,具体如下图所示：");
            r12.setFontSize(11);//字体大小


            //第三张表
            XWPFTable monitorInfo2 = createTable(doc);
            XWPFParagraph monitorInfoExcelParagraph2 = WordUtils.getCenterParagraph(doc);

            // 表格第一行
            insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, true, "时间", "事件关联分析名称", "事件关联分析表述");


            //塞入数据
            for (int i = 0; i < resultList.size(); i++) {
                insertRow(doc, monitorInfo2, monitorInfoExcelParagraph2, false, resultList.get(i).getAssTime(), resultList.get(i).getEventTime(), resultList.get(i).getDescribe());
            }
            //序号计数进行++
            oneCount++;

            /**
             * =======================================word结束=========================================
             */

        }

        //9.暂降原因表和暂降原因图形生成
        if (areaReportParam.isEventReasonTable() || areaReportParam.isEventReasonChart()) {
            //查询字典表
            List<DictData> reasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();

            //新建map集合装入参数
            Map<String, String> reasonMap = reasonList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));

            //获得所有值
            Set<String> typeSet = reasonMap.keySet();
            List<String> listReason = new ArrayList<>(typeSet);

            //创建Map结果集合
            Map<String, Integer> resultMap = new HashMap<>();

            //优化数据（根据暂降原因，进行分组统计有多少条数据，key:暂降原因id，value：次数)
            Map<String, Long> reasonMapCount = eventDetailList.stream().collect(Collectors.groupingBy(EventDetailNew::getAdvanceReason, Collectors.counting()));
            //将数据重新整合为（key：暂降原因的名称，value:暂降原因测次数）
            reasonMap.forEach((key, value) -> {
                if (reasonMapCount.containsKey(key)) {
                    resultMap.put(value, Math.toIntExact(reasonMapCount.get(key)));
                } else {
                    resultMap.put(value, 0);
                }
            });

            //todo 还要对集合中哪个次数最多挑出第一位
            //获取entrySet
            Map<String, Integer> linkMap = getSort(resultMap);
            //最多暂降事件名称
            Set<String> topSet = linkMap.keySet();
            List<String> topList = new ArrayList<>(topSet);

            //暂降原因表格
            if (areaReportParam.isEventReasonTable()) {
                //暂降原因表格
                //创建表题计数
                int twoCount = 1;

                oneCount7 = oneCount;
                createTitle(doc, "4." + oneCount + " 原因统计", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + deptName + "电网在所选择的分析时间内暂态事件主要的暂态原因为" + topList.get(0) + "[根据表格中的次数来进行分析]，见下表（图）：");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " 原因统计表格", "标题 3", 400, 11);

                //第一张表
                XWPFTable monitorInfo = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc);

                // 表格第一行
                insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "暂态类型", "电压" + typeName + "次数");

                //塞入数据
                for (String name : resultMap.keySet()) {
                    insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, name, resultMap.get(name).toString());

                }

                twoCount4 = twoCount;
                //序号计数进行++
                oneCount++;

            }

            //暂降原因图表
            if (areaReportParam.isEventReasonChart()) {
                if (areaReportParam.isEventReasonTable()) {

                    createTitle(doc, "4." + oneCount7 + "." + twoCount4 + " 原因统计图", "标题 3", 400, 11);

                    //创建x,y参数
                    List<String> xdata = new ArrayList<>();
                    List<Map<String, Object>> list = new ArrayList<>();
                    Map<String, Object> map;
                    for (String name : resultMap.keySet()) {
                        xdata.add(name);

                        map = new LinkedHashMap<>();
                        map.put("value", resultMap.get(name));
                        map.put("name", name);
                        list.add(map);
                    }

                    String tr = drawPicUtil.drawReason(xdata, list);
                    createPic(doc, tr, "" + typeName + "原因图");
                } else {
                    //创建表题计数
                    int twoCount = 1;

                    createTitle(doc, "4." + oneCount + " 原因统计", "标题 2", 200, 11);

                    p = doc.createParagraph();// 新建一个段落
                    p.setAlignment(ParagraphAlignment.BOTH);
                    XWPFRun r12 = p.createRun();//创建段落文本
                    r12.setText("  " + deptName + "电网在所选择的分析时间内暂态事件主要的暂态原因为" + topList.get(0) + "[根据表格中的次数来进行分析]，见下表（图）：");
                    r12.setFontSize(11);//字体大小


                    createTitle(doc, "4." + oneCount + "." + twoCount + " 原因统计图", "标题 3", 400, 11);

                    //创建x,y参数
                    List<String> xdata = new ArrayList<>();
                    List<Map<String, Object>> list = new ArrayList<>();
                    Map<String, Object> map;
                    for (String name : resultMap.keySet()) {
                        xdata.add(name);

                        map = new LinkedHashMap<>();
                        map.put("value", resultMap.get(name));
                        map.put("name", name);
                        list.add(map);
                    }

                    String tr = drawPicUtil.drawReason(xdata, list);
                    createPic(doc, tr, "" + typeName + "原因图");

                    //序号计数进行++
                    oneCount++;
                }
            }
        }

        //10.暂降类型表格 和 暂降类型图表
        if (areaReportParam.isEventTypeTable() || areaReportParam.isEventTypeChart()) {

            //查询字典表（暂降类型）
            List<DictData> typeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
            //新建map集合装入参数
            Map<String, String> typeMap = typeList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));

            //获得所有值
            Set<String> typeSet = typeMap.keySet();
            List<String> listReason = new ArrayList<>(typeSet);

            //创建Map结果集合
            Map<String, Integer> resultMap = new HashMap<>();

            //优化数据（根据暂降类型，进行分组统计有多少条数据，key:暂降类型id，value：次数)
            Map<String, Long> typeMapCount = eventDetailList.stream().collect(Collectors.groupingBy(EventDetailNew::getEventType, Collectors.counting()));
            //将数据重新整合为（key：暂降类型的名称，value:暂降类型次数）
            typeMap.forEach((key, value) -> {
                if (typeMapCount.containsKey(key)) {
                    resultMap.put(value, Math.toIntExact(typeMapCount.get(key)));
                } else {
                    resultMap.put(value, 0);
                }
            });

            //todo 还要对集合中哪个次数最多挑出第一位
            //获取entrySet
            Map<String, Integer> linkMap = getSort(resultMap);
            //最多暂降事件名称
            Set<String> topSet = linkMap.keySet();
            List<String> topList = new ArrayList<>(topSet);


            //暂降类型表格
            if (areaReportParam.isEventTypeTable()) {
                //创建表题计数
                int twoCount = 1;
                oneCount6 = oneCount;

                createTitle(doc, "4." + oneCount + " 类型统计", "标题 2", 200, 11);

                p = doc.createParagraph();// 新建一个段落
                p.setAlignment(ParagraphAlignment.BOTH);
                XWPFRun r12 = p.createRun();//创建段落文本
                r12.setText("  " + deptName + "电网在所选择的分析时间内暂态事件主要的暂态类型为" + topList.get(0) + "[根据表格中的次数来进行分析]，见下表（图）：");
                r12.setFontSize(11);//字体大小


                createTitle(doc, "4." + oneCount + "." + twoCount + " 类型统计表格", "标题 3", 400, 11);

                //第一张表
                XWPFTable monitorInfo = createTable(doc);
                XWPFParagraph monitorInfoExcelParagraph = WordUtils.getCenterParagraph(doc);

                // 表格第一行
                insertRow(doc, monitorInfo, monitorInfoExcelParagraph, true, "暂态类型", "电压" + typeName + "次数");


                //塞入数据
                for (String name : resultMap.keySet()) {
                    insertRow(doc, monitorInfo, monitorInfoExcelParagraph, false, name, resultMap.get(name).toString());
                }

                twoCount3 = twoCount;
                //序号计数进行++
                oneCount++;
            }
            //暂降类型图形
            if (areaReportParam.isEventTypeChart()) {
                if (areaReportParam.isEventTypeTable()) {
                    twoCount3++;
                    createTitle(doc, "4." + oneCount6 + "." + twoCount3 + " 类型统计图", "标题 3", 400, 11);
                    //创建x,y参数
                    List<String> xdata = new ArrayList<>();
                    List<Map<String, Object>> reasonList = new ArrayList<>();
                    Map<String, Object> map;
                    for (String name : resultMap.keySet()) {
                        xdata.add(name);

                        map = new LinkedHashMap<>();
                        map.put("value", resultMap.get(name));
                        map.put("name", name);
                        reasonList.add(map);
                    }

                    String tr = drawPicUtil.drawType(xdata, reasonList);
                    createPic(doc, tr, "" + typeName + "类型图");

                } else {
                    //创建表题计数
                    int twoCount = 1;
                    createTitle(doc, "4." + oneCount + " 类型统计", "标题 2", 200, 11);

                    p = doc.createParagraph();// 新建一个段落
                    p.setAlignment(ParagraphAlignment.BOTH);
                    XWPFRun r12 = p.createRun();//创建段落文本
                    r12.setText("  " + deptName + "电网在所选择的分析时间内暂态事件主要的暂态类型为" + topList.get(0) + "[根据表格中的次数来进行分析]，见下表（图）：");
                    r12.setFontSize(11);//字体大小

                    createTitle(doc, "4." + oneCount + "." + twoCount + " 类型统计图", "标题 3", 400, 11);

                    //创建x,y参数
                    List<String> xdata = new ArrayList<>();
                    List<Map<String, Object>> reasonList = new ArrayList<>();
                    Map<String, Object> map;
                    for (String name : resultMap.keySet()) {
                        xdata.add(name);

                        map = new LinkedHashMap<>();
                        map.put("value", resultMap.get(name));
                        map.put("name", name);
                        reasonList.add(map);
                    }

                    String tr = drawPicUtil.drawType(xdata, reasonList);
                    createPic(doc, tr, "" + typeName + "类型图");

                    //序号计数进行++
                    oneCount++;
                }
            }

        }

        //11.暂降热力图
        if (areaReportParam.isThermodynamicChart()) {
            //暂降热力图
            createTitle(doc, "4." + oneCount + " " + typeName + "热力图", "标题 2", 200, 11);

            p = doc.createParagraph();// 新建一个段落
            p.setAlignment(ParagraphAlignment.BOTH);
            XWPFRun r12 = p.createRun();//创建段落文本
            r12.setText("  " + deptName + "电网在所选择的分析时间段内累计监测" + typeName + "记录" + eventCount + "条，使用颜色将地图上按照" + typeName + "记录发生频率进行描绘，所形成的热力具体见下图：");
            r12.setFontSize(11);//字体大小

            //所有的表结果装入集合
            Map<String, Integer> areaCount1 = new HashMap<>();

            //进行遍历集合获得子区域名及其所有监测点id
            //根据省级获取部门下面的信息图
            for (PmsGeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {

                //当前子部门下所有id
                List<String> lineIndexes = generalDeviceDTO.getMonitorIdList();


                //如果集合中有id将id进行拼接
                if (CollectionUtil.isNotEmpty(lineIndexes)) {
                    //数据统计
                    Integer eventDetailCount = getEventDetailCount(areaReportParam, lineIndexes);
                    areaCount1.put(generalDeviceDTO.getName(), eventDetailCount);

                } else {
                    //为空put 0
                    areaCount1.put(generalDeviceDTO.getName(), 0);
                }
            }


            //转为List对象集合
            List<ReportCountParam> areaCountList1 = new ArrayList<>();
            for (String s : areaCount1.keySet()) {
                ReportCountParam reportCountParam = new ReportCountParam();
                reportCountParam.setName(s);
                reportCountParam.setCount(areaCount1.get(s).toString());
                areaCountList1.add(reportCountParam);
            }
            //序号计数进行++
            oneCount++;
        }
        //文件下载
        ServletOutputStream outputStream = response.getOutputStream();
        String fileName = URLEncoder.encode(deptName + "热力图.docx", "UTF-8");
        response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
        response.setContentType("application/octet-stream;charset=UTF-8");
        doc.write(outputStream);
        outputStream.close();
    }

    @Override
    public String appEventExport(DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException {
        //临时缓冲区
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        HSSFWorkbook workbook = this.getSheets(businessParam);
        //创建临时文件
        workbook.write(out);
        byte[] bookByteAry = out.toByteArray();
        InputStream in = new ByteArrayInputStream(bookByteAry);
        String xlsx = fileStorageUtil.uploadStream(in, OssPath.RESPONSIBILITY_APP_REPORT, FileUtil.generateFileName("xlsx"));
        workbook.close();
        in.close();
        return xlsx;
    }

    /**
     * zbj
     *
     * @param areaTableParam
     * @return
     */
    //区域IEC28Area
    public List<IEC28VO> IEC28Area(AreaTableParam areaTableParam) {
        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 < areaTableParam.getInfo().size(); i++) {
            Double eventvalue = areaTableParam.getInfo().get(i).getFeatureAmplitude();
            double persisttime = areaTableParam.getInfo().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;
    }

    public List<IEC411VO> IEC411Area(AreaTableParam areaTableParam) {
        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 < areaTableParam.getInfo().size(); i++) {
            Double eventvalue = areaTableParam.getInfo().get(i).getFeatureAmplitude();
            double persisttime = areaTableParam.getInfo().get(i).getDuration();
            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;
    }

    public List<DISDIPVO> eventDisdipArea(AreaTableParam areaTableParam) {
        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 < areaTableParam.getInfo().size(); i++) {
            Double eventvalue = areaTableParam.getInfo().get(i).getFeatureAmplitude();
            double persisttime = areaTableParam.getInfo().get(i).getDuration();
            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;
    }


    //获取区域幅值
    public ProbabilityVO getProbabilityDistributionArea(AreaTableParam areaTableParam) {
        ProbabilityVO result = new ProbabilityVO();
        List<EventDetailNew> info = new ArrayList<>();

        //总数
        Integer count = 0;
        for (EventDetailNew eventDetail : areaTableParam.getInfo()) {
            //过滤掉大于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 (EventDetailNew 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 (EventDetailNew 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 (EventDetailNew eventDetail : info) {
            Double persistTime = eventDetail.getDuration();
            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 (EventDetailNew eventDetail : info) {
            Double persistTime = eventDetail.getDuration();
            if (persistTime  < 0.1) {
                timeMap2.put("<0.1", timeMap2.get("<0.1") + 1);
            }
            if (persistTime  < 0.25) {
                timeMap2.put("<0.25", timeMap2.get("<0.25") + 1);
            }
            if (persistTime  < 0.5) {
                timeMap2.put("<0.5", timeMap2.get("<0.5") + 1);
            }
            if (persistTime  < 1) {
                timeMap2.put("<1", timeMap2.get("<1") + 1);
            }
            if (persistTime  < 3) {
                timeMap2.put("<3", timeMap2.get("<3") + 1);
            }
            if (persistTime  < 20) {
                timeMap2.put("<20", timeMap2.get("<20") + 1);
            }
            if (persistTime  < 60) {
                timeMap2.put("<60", timeMap2.get("<60") + 1);
            }
            if (persistTime  < 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;
    }


    public List<Integer> getITICArea(List<OB> xbardata) {
        double[][] top = new double[7][2];
        top[0][0] = 0.001;
        top[0][1] = 200;
        top[1][0] = 0.003;
        top[1][1] = 140;
        top[2][0] = 0.003;
        top[2][1] = 120;
        top[3][0] = 0.5;
        top[3][1] = 120;
        top[4][0] = 0.5;
        top[4][1] = 110;
        top[5][0] = 10;
        top[5][1] = 110;
        top[6][0] = 1000;
        top[6][1] = 110;

        double[][] bot = new double[7][2];
        bot[0][0] = 0.02;
        bot[0][1] = 0;
        bot[1][0] = 0.02;
        bot[1][1] = 70;
        bot[2][0] = 0.5;
        bot[2][1] = 70;
        bot[3][0] = 0.5;
        bot[3][1] = 80;
        bot[4][0] = 10;
        bot[4][1] = 80;
        bot[5][0] = 10;
        bot[5][1] = 90;
        bot[6][0] = 1000;
        bot[6][1] = 90;

        double[][] point = new double[xbardata.size()][2];
        double[][] pointno = new double[xbardata.size()][2];
        int t = 0;
        int n = 0;
        for (int i = 0; i < xbardata.size(); i++) {
            OB ob = xbardata.get(i);
            //是否超过上限
            if (ob.getA() <= 0.003) {
                int line = 230 - 30000 * (int) ob.getA();
                if (ob.getB() > line) {
                    pointno[i][0] = ob.getA();
                    pointno[i][1] = ob.getB();
                    n++;
                } else {
                    point[i][0] = ob.getA();
                    point[i][1] = ob.getB();
                    t++;
                }
            } else if (ob.getA() <= 0.02) {
                if (ob.getB() > 120) {
                    pointno[i][0] = ob.getA();
                    pointno[i][1] = ob.getB();
                    n++;
                } else {
                    point[i][0] = ob.getA();
                    point[i][1] = ob.getB();
                    t++;
                }
            } else if (ob.getA() <= 0.5) {
                if (ob.getB() > 120 || ob.getB() < 70) {
                    pointno[i][0] = ob.getA();
                    pointno[i][1] = ob.getB();
                    n++;
                } else {
                    point[i][0] = ob.getA();
                    point[i][1] = ob.getB();
                    t++;
                }
            } else if (ob.getA() <= 10) {
                if (ob.getB() > 110 || ob.getB() < 80) {
                    pointno[i][0] = ob.getA();
                    pointno[i][1] = ob.getB();
                    n++;
                } else {
                    point[i][0] = ob.getA();
                    point[i][1] = ob.getB();
                    t++;
                }
            } else {
                if (ob.getB() > 110 || ob.getB() < 90) {
                    pointno[i][0] = ob.getA();
                    pointno[i][1] = ob.getB();
                    n++;
                } else {
                    point[i][0] = ob.getA();
                    point[i][1] = ob.getB();
                    t++;
                }
            }
        }


        ArrayList<Integer> list = new ArrayList<>();
        list.add(t);
        list.add(n);
        return list;
    }

    //重写了f47图形
    public List<Integer> getF47Area(List<OB> xbardata) {

        double[][] part = new double[8][2];
        part[0][0] = 0.05;
        part[0][1] = 0;
        part[1][0] = 0.05;
        part[1][1] = 50;
        part[2][0] = 0.2;
        part[2][1] = 50;
        part[3][0] = 0.2;
        part[3][1] = 70;
        part[4][0] = 0.5;
        part[4][1] = 70;
        part[5][0] = 0.5;
        part[5][1] = 80;
        part[6][0] = 10;
        part[6][1] = 80;
        part[7][0] = 1000;
        part[7][1] = 80;

        double[][] point = new double[xbardata.size()][2];
        double[][] pointno = new double[xbardata.size()][2];
        int t = 0;
        int n = 0;
        for (int i = 0; i < xbardata.size(); i++) {
            OB ob = xbardata.get(i);
            //是否超过上限
            if (ob.getA() < 0.05) {
                point[i][0] = ob.getA();
                point[i][1] = ob.getB();
                t++;
            } else if (ob.getA() < 0.2) {
                if (ob.getB() > 50) {
                    point[i][0] = ob.getA();
                    point[i][1] = ob.getB();
                    t++;
                } else {
                    pointno[i][0] = ob.getA();
                    pointno[i][1] = ob.getB();
                    n++;
                }
            } else if (ob.getA() < 0.5) {
                if (ob.getB() > 70) {
                    point[i][0] = ob.getA();
                    point[i][1] = ob.getB();
                    t++;
                } else {
                    pointno[i][0] = ob.getA();
                    pointno[i][1] = ob.getB();
                    n++;
                }
            } else {
                if (ob.getB() > 80) {
                    point[i][0] = ob.getA();
                    point[i][1] = ob.getB();
                    t++;
                } else {
                    pointno[i][0] = ob.getA();
                    pointno[i][1] = ob.getB();
                    n++;
                }
            }
        }
        ArrayList<Integer> list = new ArrayList<>();
        list.add(t);
        list.add(n);
        return list;
    }


    /**
     * wr(初始化数据)
     *
     * @param lineIds 监测点集合
     * @return
     */
    private List<EventDetailNew> getEventDetailListInfo(AreaReportParam areaReportParam, List<String> lineIds, Integer type) {
        //获取事件类型(短时中断 电压暂降 电压暂升 扰动 其他)
        List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
        List<String> typeIds;
        if (type == 0) {
            typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode())
                            || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode())
                            || DicDataEnum.DISTURBANCE.getCode().equals(x.getCode())
                            || DicDataEnum.OTHER.getCode().equals(x.getCode())
                            || DicDataEnum.VOLTAGE_RISE.getCode().equals(x.getCode())
                    )
                    .map(DictData::getId).collect(Collectors.toList());
        } else {
            //添加中断
            typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode())
                    || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode()))
                    .map(DictData::getId).collect(Collectors.toList());
        }
        //数据暂降查询
        List<RmpEventDetailPO> info = eventDetailService.list(new LambdaQueryWrapper<RmpEventDetailPO>()
                .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
                .in(RmpEventDetailPO::getEventType, typeIds)
                .ge(StrUtil.isNotBlank(areaReportParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime())))
                .le(StrUtil.isNotBlank(areaReportParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime())))
        );
        if (CollUtil.isEmpty(info)) {
            throw new BusinessException(EventResponseEnum.NOT_FOUND);
        }
        return BeanUtil.copyToList(info, EventDetailNew.class);

    }

    /**
     * wr(热力图数据统计)
     *
     * @param lineIds 监测点集合
     * @return
     */
    private Integer getEventDetailCount(AreaReportParam areaReportParam, List<String> lineIds) {

        //获取事件类型(短时中断 电压暂降 电压暂升 扰动 其他)
        List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
        List<String> typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode())
                        || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode())
                        || DicDataEnum.DISTURBANCE.getCode().equals(x.getCode())
                        || DicDataEnum.OTHER.getCode().equals(x.getCode())
                        || DicDataEnum.VOLTAGE_RISE.getCode().equals(x.getCode())
                )
                .map(DictData::getId).collect(Collectors.toList());

        //数据暂降查询
        int count = eventDetailService.count(new LambdaQueryWrapper<RmpEventDetailPO>()
                .in(RmpEventDetailPO::getMeasurementPointId, lineIds)
                .in(RmpEventDetailPO::getEventType, typeIds)
                .ge(StrUtil.isNotBlank(areaReportParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(areaReportParam.getSearchBeginTime())))
                .le(StrUtil.isNotBlank(areaReportParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(areaReportParam.getSearchEndTime())))
        );

        return count;
    }


    /**
     * 报表结果排序提取
     *
     * @param voltageCount
     * @return
     */
    private Map<String, Integer> getSort(Map<String, Integer> voltageCount) {
        //还要对集合中哪个电压暂降次数最多进行计算,挑选出前两位
        //获取entrySet
        Set<Map.Entry<String, Integer>> mapEntries = voltageCount.entrySet();

        //使用链表来对集合进行排序，使用LinkedList，利于插入元素
        List<Map.Entry<String, Integer>> result = new LinkedList<>(mapEntries);
        //自定义比较器来比较链表中的元素
        Collections.sort(result, new Comparator<Map.Entry<String, Integer>>() {
            //基于entry的值（Entry.getValue()），来排序链表
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                return o2.getValue().compareTo(o1.getValue());
            }
        });

        //将排好序的存入到LinkedHashMap(可保持顺序)中，需要存储键和值信息对到新的映射中。
        Integer sort = 1;
        Map<String, Integer> linkMap = new LinkedHashMap<>();
        for (Map.Entry<String, Integer> newEntry : result) {
            // 取出排名前2的值 (注意有的是需要1个值)
            if (sort <= 2) {
                linkMap.put(newEntry.getKey(), newEntry.getValue());
                ++sort;
            }
        }
        return linkMap;
    }


}
