package com.njcn.harmonic.service.specialanalysis.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenDTO;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.api.PwMonitorClient;
import com.njcn.device.pms.pojo.dto.PwPmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PwPmsMonitorParam;
import com.njcn.harmonic.mapper.specialanalysis.*;
import com.njcn.harmonic.pojo.param.OverviewParam;
import com.njcn.harmonic.pojo.param.PowerQualityParam;
import com.njcn.harmonic.pojo.po.RStatOrgPvPowerQualityMPO;
import com.njcn.harmonic.pojo.po.RStatOrgPvPowerQualityQPO;
import com.njcn.harmonic.pojo.vo.OverviewVO;
import com.njcn.harmonic.pojo.vo.RStatOrgPvDetailVO;
import com.njcn.harmonic.pojo.vo.RStatOrgPvPowerStreamVO;
import com.njcn.harmonic.service.specialanalysis.RStatOrgPvPowerQualityService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.user.pojo.po.Dept;
import lombok.RequiredArgsConstructor;
import org.apache.commons.math3.analysis.function.Add;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 分布式光伏_台区电能质量明细
 *
 * @author wr
 * @date 2022-11-22 14:34:42
 */
@Service
@RequiredArgsConstructor
public class RStatOrgPvPowerQualityServiceImpl extends ServiceImpl<RStatOrgPvPowerQualityQMapper, RStatOrgPvPowerQualityQPO> implements RStatOrgPvPowerQualityService {

    private final RStatOrgPvPowerQualityYMapper rStatOrgPvPowerQualityYPOMapper;
    private final DicDataFeignClient dicDataFeignClient;
    private final DeptFeignClient deptFeignClient;
    private final PwMonitorClient pwMonitorClient;
    private final RStatOrgPvPowerQualityMMapper rStatOrgPvPowerQualityMMapper;
    private final CommTerminalGeneralClient commTerminalGeneralClient;


    @Override
    public Page<RStatOrgPvPowerStreamVO> getPowerQualityStream(PowerQualityParam param) {
        PowerQualityParam.PowerQualityDetailParam bearParam = BeanUtil.copyProperties(param, PowerQualityParam.PowerQualityDetailParam.class);
        Map<String, String> list = new HashMap<>(3);
        List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.AREA_PQ_EVENT_TYPE.getCode()).getData();
        if (CollectionUtil.isEmpty(dictDataList)) {
            throw new BusinessException(CommonResponseEnum.NO_DATA, "台区电能质量事件类型为空");
        }
        //获取部门id集合
        List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(param.getId()).getData();
        if (CollectionUtil.isEmpty(deptDTOS)) {
            throw new BusinessException(CommonResponseEnum.NO_DATA, "获取部门信息为空");
        }
        //剔除本部门
        Map<String, DeptDTO> deptDTOMap = deptDTOS.stream().collect
                (Collectors.toMap(DeptDTO::getCode, Function.identity(), (key, key2) -> key2));
        List<String> OrgNOS = deptDTOS.stream().map(DeptDTO::getCode).collect(Collectors.toList());
        //根据字典Code，取出字典id，拼入sql中
        dictDataList.stream().forEach(dictData -> {
            if (DicDataEnum.EVENT_TYPE_L.getCode().equals(dictData.getCode())) {
                list.put("eventTypeL", dictData.getId());
            }
            if (DicDataEnum.EVENT_TYPE_P.getCode().equals(dictData.getCode())) {
                list.put("eventTypeP", dictData.getId());
            }
            if (DicDataEnum.EVENT_TYPE_O.getCode().equals(dictData.getCode())) {
                list.put("eventTypeO", dictData.getId());
            }
        });
        bearParam.setMapId(list);
        bearParam.setOrgNos(OrgNOS);
        //数据分页查询
        Page<RStatOrgPvPowerStreamVO> page = rStatOrgPvPowerQualityYPOMapper.selectListPage(new Page<>(param.getPageNum(), param.getPageSize()), bearParam);
        page.getRecords().stream().forEach(vo -> {
            if (deptDTOMap.containsKey(vo.getOrgNo())) {
                DeptDTO deptDTO = deptDTOMap.get(vo.getOrgNo());
                vo.setOrgNo(deptDTO.getName());
            }
        });
        return page;
    }

    @Override
    public Page<RStatOrgPvDetailVO> getPowerQualityInfo(PowerQualityParam.PowerQualityDetailInfoParam param) {
        //根据条件查询单位下面的所有配网监测点
        PwPmsMonitorParam pwPmsMonitorParam = new PwPmsMonitorParam();
        //单位id
        pwPmsMonitorParam.setOrgId(param.getId());
        //监测点类别
        pwPmsMonitorParam.setMonitorSort(param.getMonitorSort());
        //获取监测点信息
        PowerQualityParam.PowerQualityDetailParam bearParam = BeanUtil.copyProperties(param, PowerQualityParam.PowerQualityDetailParam.class);
        List<PwPmsMonitorDTO> pwMonitorList = pwMonitorClient.getPwPhotovoltaicMonitorList(pwPmsMonitorParam).getData();
        if (CollUtil.isEmpty(pwMonitorList)) {
            return new Page<>();
        }
        //监测点数据转换
        Map<String, PwPmsMonitorDTO> monitorMap = pwMonitorList.stream()
                .collect(Collectors.toMap(PwPmsMonitorDTO::getMonitorId, PwPmsMonitorDTO -> PwPmsMonitorDTO));
        //获取监测点id
        List<String> monitorIds = pwMonitorList
                .stream().map(PwPmsMonitorDTO::getMonitorId).collect(Collectors.toList());
        bearParam.setOrgNos(monitorIds);
        //数据库分页查询
        Page<RStatOrgPvDetailVO> page = rStatOrgPvPowerQualityYPOMapper.selectDetailListPage(new Page<>(param.getPageNum(), param.getPageSize()), bearParam);
        page.getRecords().stream().forEach(vo -> {
            if (monitorMap.containsKey(vo.getMeasurementPointId())) {
                PwPmsMonitorDTO monitorDTO = monitorMap.get(vo.getMeasurementPointId());
                vo.setOrgNo(monitorDTO.getOrgId());
                vo.setOrgName(monitorDTO.getOrgName());
                vo.setMeasurementPointName(monitorDTO.getMonitorName());
                vo.setVoltageLevels(monitorDTO.getVoltageLevel());
                vo.setMonitorSort(monitorDTO.getMonitorSort());
            }
        });
        return page;
    }

    @Override
    public List<OverviewVO.IcoVO> getVoltage(OverviewParam.OverviewVoltageParam param) {
        List<OverviewVO.IcoVO> vos=new ArrayList<>();

        //获取部门信息
        Dept dept = deptFeignClient.getDeptById(param.getId()).getData();

        if(ObjectUtil.isNotNull(dept)){
            //获取监测对象
            List<DictData> monitorType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.MONITOR_OBJ.getCode()).getData();
            Map<String, DictData> dictDataMap = monitorType.stream()
                    .collect(Collectors.toMap(DictData::getId, Function.identity()));
            //初始化对象
            OverviewVO.IcoVO vo;
            for (DictData dictData : monitorType) {
                vo=new OverviewVO.IcoVO();
                vo.setNumOne(0);
                vo.setNumTwo(0);
                vos.add(vo);
            }


            //获取台区电能质量事件类型
            List<DictData> areaType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.AREA_PQ_EVENT_TYPE.getCode()).getData();
            Map<String, DictData> areaMap = areaType.stream()
                    .collect(Collectors.toMap(DictData::getId, Function.identity()));

            List<String> typeID=new ArrayList<>();
            //取出电压相关的字典
            for (DictData dictData : areaType) {
                //1：高压 0是低压
                if (param.getType() == 1) {
                    //电压 电压越上限15%以上
                    if (DicDataEnum.EVENT_TYPE_T.getCode().equals(dictData.getCode())) {
                        typeID.add(dictData.getId());
                    }
                    //电压 电压越上限7%-15%
                    if (DicDataEnum.EVENT_TYPE_R.getCode().equals(dictData.getCode())) {
                        typeID.add(dictData.getId());
                    }
                } else {
                    //电压 超标3%-10%
                    if (DicDataEnum.EVENT_TYPE_Z.getCode().equals(dictData.getCode())) {
                        typeID.add(dictData.getId());
                    }
                    //电压 超标10%以下
                    if (DicDataEnum.EVENT_TYPE_X.getCode().equals(dictData.getCode())) {
                        typeID.add(dictData.getId());
                    }
                }
            }
            //数据库查询（里面有聚合查询，直接舍弃小数部分）
            List<OverviewVO.VoltageVO> voltageVOS = rStatOrgPvPowerQualityMMapper.selectVoltage(Arrays.asList(dept.getCode()), typeID,param);

            Map<String, List<OverviewVO.VoltageVO>> voltageMap = voltageVOS.stream().collect(
                    Collectors.groupingBy(OverviewVO.VoltageVO::getMonitoringObject));

            if(CollectionUtil.isNotEmpty(voltageMap)){
                //初始化对象
                voltageMap.forEach((key,value)-> {
                    OverviewVO.IcoVO typeVO = new OverviewVO.IcoVO();
                    typeVO.setNumOne(0);
                    typeVO.setNumTwo(0);

                    if (dictDataMap.containsKey(key)) {
                        DictData dictData = dictDataMap.get(key);
                        //一类监测点
                        if(DicDataEnum.MAIN_CHANGE.getCode().equals(dictData.getCode())){
                            getArea(areaMap, value, typeVO,param.getType());
                            vos.set(0,typeVO);
                        }
                        //二类监测点
                        if(DicDataEnum.PHOTOVOLT.getCode().equals(dictData.getCode())){
                            getArea(areaMap, value, typeVO,param.getType());
                            vos.set(1,typeVO);
                        }
                        //三类监测点
                        if(DicDataEnum.FEEDER_TENKV.getCode().equals(dictData.getCode())){
                            getArea(areaMap, value, typeVO,param.getType());
                            vos.set(2,typeVO);
                        }
                    }
                });

            }

        }
        return vos;
    }

    /**
     * 电压问题对象赋值
     * @param areaMap 台区事件字典
     * @param value   存在的台区事件
     * @param typeVO   对象赋值
     * @param type   区分高低压
     */
    private void getArea(Map<String, DictData> areaMap, List<OverviewVO.VoltageVO> value, OverviewVO.IcoVO typeVO,
                    Integer type) {
        //循环便利赋值判断电压类型
        for (OverviewVO.VoltageVO voltageVO : value) {
            if (areaMap.containsKey(voltageVO.getAreaPqEventType())) {
                DictData areaData = areaMap.get(voltageVO.getAreaPqEventType());
                //1：高压 0是低压
                if(type==1){
                    //电压 电压越上限7%-15%
                    if(DicDataEnum.EVENT_TYPE_R.getCode().equals(areaData.getCode())){
                        typeVO.setNumOne(voltageVO.getTotalMonitorNum());
                    }
                    //电压 电压越上限15%以上
                    if(DicDataEnum.EVENT_TYPE_T.getCode().equals(areaData.getCode())){
                        typeVO.setNumTwo(voltageVO.getTotalMonitorNum());

                    }
                }else{
                    //电压 超标-3%- -10%
                    if(DicDataEnum.EVENT_TYPE_Z.getCode().equals(areaData.getCode())){
                        typeVO.setNumOne(voltageVO.getTotalMonitorNum());
                    }
                    //电压 超标 -10%
                    if(DicDataEnum.EVENT_TYPE_X.getCode().equals(areaData.getCode())){
                        typeVO.setNumTwo(voltageVO.getTotalMonitorNum());

                    }
                }

            }
        }
    }

    @Override
    public  List<OverviewVO.NumVO> getPowerFactor(OverviewParam param) {
        List<OverviewVO.NumVO> info=new ArrayList<>();

        //获取部门信息
        Dept dept = deptFeignClient.getDeptById(param.getId()).getData();
        if(ObjectUtil.isNotNull(dept)){
            //获取监测对象
            List<DictData> monitorType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.MONITOR_OBJ.getCode()).getData();
            Map<String, DictData> dictDataMap = monitorType.stream()
                    .collect(Collectors.toMap(DictData::getId, Function.identity()));

            //初始化对象
            OverviewVO.NumVO vo;
            for (DictData dictData : monitorType) {
                vo=new OverviewVO.NumVO();
                vo.setNumOne(0);
                vo.setNumTwo(0);
                vo.setNumThree(0);
                info.add(vo);
            }

            //获取台区电能质量事件类型
            List<DictData> areaType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.AREA_PQ_EVENT_TYPE.getCode()).getData();
            Map<String, DictData> areaMap = areaType.stream()
                    .collect(Collectors.toMap(DictData::getId, Function.identity()));

            if(CollectionUtil.isNotEmpty(areaType)){
                List<String> typeID=new ArrayList<>();
                //取出电压相关的字典
                for (DictData dictData : areaType) {
                    //功率因数 低功率因数0.8-0.9
                    if(DicDataEnum.EVENT_TYPE_L.getCode().equals(dictData.getCode())){
                        typeID.add(dictData.getId());
                    }
                    //功率因数 低功率因数0.7-0.8
                    if(DicDataEnum.EVENT_TYPE_P.getCode().equals(dictData.getCode())){
                        typeID.add(dictData.getId());
                    }
                    //功率因数 低功率因数0.7以下
                    if(DicDataEnum.EVENT_TYPE_O.getCode().equals(dictData.getCode())){
                        typeID.add(dictData.getId());
                    }

                }
                //数据库查询
                List<OverviewVO.VoltageVO> factorVOS = rStatOrgPvPowerQualityMMapper.selectVoltage(Arrays.asList(dept.getCode()), typeID,param);

                Map<String, List<OverviewVO.VoltageVO>> voltageMap = factorVOS.stream().collect(
                        Collectors.groupingBy(OverviewVO.VoltageVO::getMonitoringObject));

                if(CollectionUtil.isNotEmpty(voltageMap)){
                    //初始化对象
                    voltageMap.forEach((key,value)->{
                        OverviewVO.NumVO numVO = new OverviewVO.NumVO();
                        numVO.setNumOne(0);
                        numVO.setNumTwo(0);
                        numVO.setNumThree(0);
                        if (dictDataMap.containsKey(key)) {
                            DictData dictData = dictDataMap.get(key);
                            //一类监测点
                            if(DicDataEnum.MAIN_CHANGE.getCode().equals(dictData.getCode())){
                                getAreaFactor(areaMap, value, numVO);
                                info.set(0,numVO);
                            }
                            //二类监测点
                            if(DicDataEnum.PHOTOVOLT.getCode().equals(dictData.getCode())){
                                getAreaFactor(areaMap, value, numVO);
                                info.set(1,numVO);
                            }
                            //三类监测点
                            if(DicDataEnum.FEEDER_TENKV.getCode().equals(dictData.getCode())){
                                getAreaFactor(areaMap, value, numVO);
                                info.set(2,numVO);
                            }
                        }
                    });
                }
            }
        }
        return info;
    }

    /**
     * 功率因数
     * @param areaMap
     * @param value
     * @param numVO
     */
    private void getAreaFactor(Map<String, DictData> areaMap, List<OverviewVO.VoltageVO> value, OverviewVO.NumVO numVO) {
        for (OverviewVO.VoltageVO voltageVO : value) {
            if (areaMap.containsKey(voltageVO.getAreaPqEventType())) {
                DictData areaData = areaMap.get(voltageVO.getAreaPqEventType());
                //功率因数 低功率因数0.8-0.9
                if(DicDataEnum.EVENT_TYPE_L.getCode().equals(areaData.getCode())){
                    numVO.setNumOne(voltageVO.getTotalMonitorNum());
                }
                //功率因数 低功率因数0.7-0.8
                if(DicDataEnum.EVENT_TYPE_P.getCode().equals(areaData.getCode())){
                    numVO.setNumTwo(voltageVO.getTotalMonitorNum());
                }
                //功率因数 低功率因数0.7以下
                if(DicDataEnum.EVENT_TYPE_O.getCode().equals(areaData.getCode())){
                    numVO.setNumThree(voltageVO.getTotalMonitorNum());
                }
            }
        }
    }

    @Override
    public List<OverviewVO.IcoVO> getBackTheTide(OverviewParam param) {
        List<OverviewVO.IcoVO> vos=new ArrayList<>();
        //获取部门信息
        Dept dept = deptFeignClient.getDeptById(param.getId()).getData();
        if(ObjectUtil.isNotNull(dept)) {
            //获取监测对象
            List<DictData> monitorType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.MONITOR_OBJ.getCode()).getData();
            Map<String, DictData> dictDataMap = monitorType.stream()
                    .collect(Collectors.toMap(DictData::getId, Function.identity()));

            //初始化对象
            OverviewVO.IcoVO vo;
            for (DictData dictData : monitorType) {
                vo = new OverviewVO.IcoVO();
                vo.setNumOne(0);
                vo.setNumTwo(0);
                vos.add(vo);
            }
            //获取台区电能质量事件类型
            List<DictData> areaType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.AREA_PQ_EVENT_TYPE.getCode()).getData();
            Map<String, DictData> areaMap = areaType.stream()
                    .collect(Collectors.toMap(DictData::getId, Function.identity()));

            if (CollectionUtil.isNotEmpty(areaType)) {
                List<String> typeID = new ArrayList<>();
                //取出电压相关的字典
                for (DictData dictData : areaType) {
                    //潮流倒送
                    if (DicDataEnum.EVENT_TYPE_U.getCode().equals(dictData.getCode())) {
                        typeID.add(dictData.getId());
                    }
                    //重过载
                    if (DicDataEnum.EVENT_TYPE_C.getCode().equals(dictData.getCode())) {
                        typeID.add(dictData.getId());
                    }

                }
                //数据库查询
                List<OverviewVO.VoltageVO> voltageVOS = rStatOrgPvPowerQualityMMapper.selectVoltage(Arrays.asList(dept.getCode()), typeID, param);
                Map<String, List<OverviewVO.VoltageVO>> voltageMap = voltageVOS.stream().collect(
                        Collectors.groupingBy(OverviewVO.VoltageVO::getMonitoringObject));

                if (CollectionUtil.isNotEmpty(voltageMap)) {
                    //初始化对象
                    voltageMap.forEach((key, value) -> {
                        OverviewVO.IcoVO typeVO = new OverviewVO.IcoVO();
                        typeVO.setNumOne(0);
                        typeVO.setNumTwo(0);
                        if (dictDataMap.containsKey(key)) {
                            DictData dictData = dictDataMap.get(key);
                            //一类监测点
                            if (DicDataEnum.MAIN_CHANGE.getCode().equals(dictData.getCode())) {
                                getAreaBackTheTide(areaMap, value, typeVO);
                                vos.set(0, typeVO);
                            }
                            //二类监测点
                            if (DicDataEnum.PHOTOVOLT.getCode().equals(dictData.getCode())) {
                                getAreaBackTheTide(areaMap, value, typeVO);
                                vos.set(1, typeVO);
                            }
                            //三类监测点
                            if (DicDataEnum.FEEDER_TENKV.getCode().equals(dictData.getCode())) {
                                getAreaBackTheTide(areaMap, value, typeVO);
                                vos.set(2, typeVO);
                            }
                        }
                    });
                }
            }
        }
        return vos;
    }

    @Override
    public List<List<Object>> getPVVoltage(StatisticsBizBaseParam param) {
        //获取部门信息
        Dept dept = deptFeignClient.getDeptById(param.getId()).getData();
        DeptGetLineParam deptGetLineParam =new DeptGetLineParam();
        deptGetLineParam.setDeptId(param.getId());
        List<DeptGetChildrenDTO> data = commTerminalGeneralClient.deptGetLineList(deptGetLineParam).getData();

         List<String> monitorIds = data.stream().flatMap(dto -> dto.getPwMonitorIds().stream()).collect(Collectors.toList());
        ArrayList<List<Object>> info = new ArrayList<List<Object>>(2) {
            {
                new ArrayList<Object>() {{
                    add(0);
                    add(0);
                    add(monitorIds.size());
                }};
            }

            {
                new ArrayList<Object>() {{
                    add(0);
                    add(0);
                    add(monitorIds.size());
                }};
            }
        };
         if(CollUtil.isNotEmpty(monitorIds)){
             //获取台区电能质量事件类型
             List<DictData> areaType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.AREA_PQ_EVENT_TYPE.getCode()).getData();
             //typeIDOne：高压 typeIDTwe是低压
             List<String> typeIDOne=new ArrayList<>();
             //取出电压相关的字典
             for (DictData dictData : areaType) {

                 //电压 电压越上限15%以上
                 if (DicDataEnum.EVENT_TYPE_T.getCode().equals(dictData.getCode())) {
                     typeIDOne.add(dictData.getId());
                 }
                 //电压 电压越上限7%-15%
                 if (DicDataEnum.EVENT_TYPE_R.getCode().equals(dictData.getCode())) {
                     typeIDOne.add(dictData.getId());
                 }
                 //电压 超标3%-10%
                 if (DicDataEnum.EVENT_TYPE_Z.getCode().equals(dictData.getCode())) {
                     typeIDOne.add(dictData.getId());
                 }
                 //电压 超标10%以下
                 if (DicDataEnum.EVENT_TYPE_X.getCode().equals(dictData.getCode())) {
                     typeIDOne.add(dictData.getId());
                 }
             }
             List<RStatOrgPvPowerQualityMPO> rStatOrgPvPowerQualityMPOS = rStatOrgPvPowerQualityMMapper.selectList(new LambdaQueryWrapper<RStatOrgPvPowerQualityMPO>()
                     .in(CollUtil.isNotEmpty(typeIDOne), RStatOrgPvPowerQualityMPO::getAreaPqEventType, typeIDOne)
                     .eq(ObjectUtil.isNotNull(dept), RStatOrgPvPowerQualityMPO::getOrgNo, dept.getCode())
                     .ge(StrUtil.isNotBlank(param.getStartTime()), RStatOrgPvPowerQualityMPO::getDataDate, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
                     .le(StrUtil.isNotBlank(param.getEndTime()), RStatOrgPvPowerQualityMPO::getDataDate, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
             );
             Map<String, RStatOrgPvPowerQualityMPO> count = rStatOrgPvPowerQualityMPOS.stream().collect(Collectors.toMap(RStatOrgPvPowerQualityMPO::getAreaPqEventType, Function.identity(), (Key1, kye2) -> Key1));
             List<Object> list1=new ArrayList<>();
             List<Object> list2=new ArrayList<>();
             for (int i = 0; i < typeIDOne.size(); i++) {
                 if(i<2){
                     if(count.containsKey(typeIDOne.get(i))){
                         list1.add(count.get(typeIDOne.get(i)).getTotalMonitorNum());
                     }else{
                         list1.add(0);
                     }
                 }else{
                     if(count.containsKey(typeIDOne.get(i))){
                         list2.add(count.get(typeIDOne.get(i)).getTotalMonitorNum());
                     }else{
                         list2.add(0);
                     }
                 }
             }
             list1.add(monitorIds.size());
             list2.add(monitorIds.size());
             info.clear();
             info.add(list1);
             info.add(list2);
         }
        return info;
    }

    /**
     * 潮流倒送对象赋值
     * @param areaMap
     * @param value
     * @param typeVO
     */
    private void getAreaBackTheTide(Map<String, DictData> areaMap, List<OverviewVO.VoltageVO> value, OverviewVO.IcoVO typeVO) {
        for (OverviewVO.VoltageVO voltageVO : value) {
            if (areaMap.containsKey(voltageVO.getAreaPqEventType())) {
                DictData areaData = areaMap.get(voltageVO.getAreaPqEventType());
                //潮流倒送
                if (DicDataEnum.EVENT_TYPE_U.getCode().equals(areaData.getCode())) {
                    typeVO.setNumOne(voltageVO.getTotalMonitorNum());
                }
                //重过载
                if (DicDataEnum.EVENT_TYPE_C.getCode().equals(areaData.getCode())) {
                    typeVO.setNumTwo(voltageVO.getTotalMonitorNum());
                }

            }

        }
    }
}
