package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jxiop.api.Enum.AlarmDesc;
import com.yeejoin.amos.boot.module.jxiop.api.Enum.ElectricQuantity;
import com.yeejoin.amos.boot.module.jxiop.api.Enum.KGName;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.*;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
//import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IMonitorFanIndicator;
import com.yeejoin.amos.component.robot.BadRequest;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.DoubleValue;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.Collator;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;


/**
 * @description:
 * @author: tw
 * @createDate: 2023/7/3
 */
@Service
@EnableScheduling
@Slf4j
public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
    private final static List<String> fanStatesList = Arrays.asList("报警状态", "停机状态", "故障状态", "待机状态", "维护状态", "正常发电状态");
    @Autowired
    SystemEnumMapper systemEnumMapper;
    @Autowired
    SwitchPictureMapper switchPictureMapper;
    @Autowired
    SjglZsjZsbtzServiceImpl sjglZsjZsbtzServiceImpl;
    @Autowired
    TpriDmpDatabookServiceImpl tpriDmpDatabookServiceImpl;
    @Autowired
    TemporaryDataMapper temporaryDataMapper;
//    @Autowired
//    InfluxDButils influxDButils;
    @Autowired
    AlarmEventMapper alarmEventMapper;
    @Autowired
    AlarmEventServiceImpl alarmEventService;
    @Autowired
    TemporaryDataServiceImpl temporaryDataService;
    @Autowired
    CommonServiceImpl commonServiceImpl;
    @Autowired
    EquipAlarmEventMapper equipAlarmEventMapper;
    @Autowired
    EquipAlarmEventServiceImpl equipAlarmEventService;
    @Autowired
    EmqKeeper emqKeeper;
    @Value("${pictureUrl}")
    String pictureUrl;
    @Autowired
    private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper;
    @Autowired
    private StationBasicMapper stationBasicMapper;
    @Autowired
    private SjglZsjZsbtzMapper sjglZsjZsbtzMapper;
    @Autowired
    private RegionMapper regionMapper;
    //风机状态列表
    @Value("${fan.statuts.stattuspath}")
    private String fanStatusImagePathPrefix;
    @Value("classpath:/json/topic.json")
    private Resource topic;

    @Value("classpath:/json/fanlocation.json")
    private Resource fanlocation;
    @Autowired
    private IndicatorDataMapper indicatorDataMapper;

    private List<Map> list;


    @Override
    public void UpdateMonitorFanIndicator(List<IndexDto> list) {
        monitorFanIndicatorregionMapper.UpdateMonitorFanIndicator(list);
    }

    @Override
    public ResultsData getNationWideInfo(int current, int size, String gateway, String equipmentNumber) {
        String table = gateway;
        Map<String, List<String>> queryCodntion = new HashMap<>();
        queryCodntion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gateway));
        queryCodntion.put(CommonConstans.QueryStringIsAlarmKeyword, Arrays.asList("1"));
        List<ESEquipments> alldata = commonServiceImpl.getListDataByCondtionsAndLike(queryCodntion, null, ESEquipments.class, null);
        List<ESEquipments> waringData = alldata.stream().filter(esEquipments -> !esEquipments.getValue().equals("0.0") && !esEquipments.getValue().equals(esEquipments.getValueLabel())).collect(Collectors.toList());
        if (StringUtils.isNotEmpty(equipmentNumber)) {
            waringData = waringData.stream().filter(esEquipments -> esEquipments.getEquipmentNumber().equals(equipmentNumber)).collect(Collectors.toList());
        }
        if (CollectionUtils.isNotEmpty(waringData)) {
            Integer newSize = waringData.size() >= size ? size : waringData.size();
            waringData = waringData.stream().sorted(Comparator.comparing(ESEquipments::getCreatedTime).reversed()).collect(Collectors.toList()).subList(((current - 1) * newSize), (current * newSize));
        }
        //对于查询到的告警信息进行按照时间顺序进行排序
        DataGridMock DataGridMock = new DataGridMock(current, !waringData.isEmpty() ? waringData.size() : 0, false, current, waringData);
        ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentNumber", "设备", "设备", "dataGrid", "equipmentNumber");
        ColModel colModelvalueLabel = new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
        ColModel colModelcreatedTime = new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
        ColModel colModelvalue = new ColModel("value", "value", "告警值", "告警值", "dataGrid", "value");
        List<ColModel> listColModel = new ArrayList<>();
        listColModel.add(colModelequipmentNumber);
        listColModel.add(colModelvalueLabel);
        listColModel.add(colModelcreatedTime);
        listColModel.add(colModelvalue);
        ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
        return resultsData;
    }

    @Override
    public ResultsData getLsNationWideInfo(int current, int size, String stationBasicId, String equipmentNumber) {

        StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId);
        String gateway = stationBasic.getFanGatewayId();
        Map<String, List<String>> queryCodntion = new HashMap<>();
        queryCodntion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gateway));
        queryCodntion.put(CommonConstans.QueryStringIsAlarmKeyword, Arrays.asList("1"));
        HashMap<String, String> notMustMap = new HashMap<>();
        notMustMap.put(CommonConstans.QueryStringValueKeyword, "0.0");
        notMustMap.put(CommonConstans.QueryStringValueLabelKeyword, "0.0");
        Integer newSize = size;
        List<ESEquipments> lisSort = new ArrayList<>();
        List<ESEquipments> waringData = commonServiceImpl.getListDataByCondtionsByValueNotEqValueLabel(queryCodntion, null, notMustMap, ESEquipments.class);
        if (StringUtils.isNotEmpty(equipmentNumber) && CollectionUtils.isNotEmpty(waringData)) {
            waringData = waringData.stream().filter(esEquipments -> esEquipments.getEquipmentNumber().equals(equipmentNumber) && esEquipments.getEquipmentSpecificName().contains("风机")).collect(Collectors.toList());
            newSize = waringData.size() >= size ? size : waringData.size();
            lisSort = waringData.stream().sorted(Comparator.comparing(ESEquipments::getCreatedTime).reversed()).collect(Collectors.toList()).subList(((current - 1) * newSize), (current * newSize));

        }
        //对于查询到的告警信息进行按照时间顺序进行排序
        //构建平台数据
        DataGridMock DataGridMock = new DataGridMock(current, CollectionUtils.isNotEmpty(waringData) ? waringData.size() : 0, false, current, lisSort);
        ColModel colModelequipmentNumber = new ColModel("equipmentNumber", "equipmentSpecificName", "风机号", "风机号", "dataGrid", "equipmentNumber");
        ColModel colModelvalueLabel = new ColModel("valueLabel", "valueLabel", "事件描述", "事件描述", "dataGrid", "valueLabel");
        ColModel colModelcreatedTime = new ColModel("createdTime", "createdTime", "发生时间", "发生时间", "dataGrid", "createdTime");
        ColModel colModelvalue = new ColModel("value", "value", "告警值", "告警值", "dataGrid", "value");
        List<ColModel> listColModel = new ArrayList<>();
        listColModel.add(colModelequipmentNumber);
        listColModel.add(colModelvalueLabel);
        listColModel.add(colModelcreatedTime);
        listColModel.add(colModelvalue);
        ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
        return resultsData;
    }


    public IPage<ESEquipments> getFanIdxInfoByPage(String equipNum, String stationId, String frontModule, int current, int size, String systemType) {
        StationBasic stationBasic = getOneByStationNumber(stationId);
        Page<ESEquipments> page = new Page<>(current, size);
        String sql = "";
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put("frontModule", frontModule);
        likeMap.put("equipmentNumber", equipNum);
        if (StringUtils.isNotEmpty(systemType)) {
            likeMap.put("systemType", systemType);
        }
        List<ESEquipments> result = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);
        result.stream().forEach(e -> {
            e.setValue(String.format(CommonConstans.Twodecimalplaces, e.getValueF()));
        });
        Collator instance = Collator.getInstance(Locale.CHINA);
        Collections.sort(result, (e1, e2) -> {
            return instance.compare(e1.getEquipmentIndexName(), e2.getEquipmentIndexName());
        });
        List<ESEquipments> collect = result.stream()
                .skip((long) (current - 1) * size)
                .limit(size)
                .collect(Collectors.toList());
        List<String> powerOther = Arrays.asList("月发电量", "年发电量", "总发电量");
        if (!stationBasic.getStationType().equals("FDZ")) {
            collect.forEach(esEquipments -> {
                if (esEquipments.getEquipmentIndexName().equals("日发电量")) {
                    esEquipments.setValue(String.format(CommonConstans.Fourdecimalplaces, Double.valueOf(esEquipments.getValue()) * CommonConstans.pvGenPoweActor * CommonConstans.pvGenPoweActorDay));
                }
                if (powerOther.contains(esEquipments.getEquipmentIndexName())) {
                    esEquipments.setValue(String.format(CommonConstans.Fourdecimalplaces, Double.valueOf(esEquipments.getValue()) * CommonConstans.pvGenPoweActorCurrentData));
                }
            });
        }
        page.setTotal(result.size());
        page.setRecords(collect);
        return page;
    }

    public TreeDto getTreeInfo(String sequenceNbr) {
        StationBasic stationBasic = stationBasicMapper.selectById(sequenceNbr);
        List<Integer> integers = JSON.parseArray(stationBasic.getBelongArea(), Integer.class);
        if (CollectionUtils.isEmpty(integers)) {
            throw new BadRequest("所属地区不能为空");
        }
        LambdaQueryWrapper<Region> regionLambda = new LambdaQueryWrapper<>();
        regionLambda.eq(Region::getRegionCode, integers.get(0));
        Region region = regionMapper.selectOne(regionLambda);
        TreeDto treeDto = new TreeDto();
        treeDto.setCode(String.valueOf(region.getRegionCode()));
        treeDto.setName(region.getRegionName());
        treeDto.setId(String.valueOf(region.getSequenceNbr()));
        treeDto.setParentCode("0");
        treeDto.setIsOnClick(0);
        treeDto.setSceneId("987654321");
        List<TreeDto> stationListByRegionCode = stationBasicMapper.getStationListByRegionCode(String.valueOf(region.getRegionCode()));


        TreeDto fdzTreeDto = new TreeDto();
        fdzTreeDto.setName("风电站");
        fdzTreeDto.setCode("FDZ");
        fdzTreeDto.setParentCode(String.valueOf(region.getRegionCode()));
        fdzTreeDto.setIsOnClick(0);
        fdzTreeDto.setSceneId("12345678910");
        List<TreeDto> fdz = stationListByRegionCode.stream().filter(t -> t.getParentCode().contains("FDZ") && t.getParentCode().length() < 4).collect(Collectors.toList());
        fdzTreeDto.setChildren(fdz);

        TreeDto gfzTreeDto = new TreeDto();
        gfzTreeDto.setName("光伏站");
        gfzTreeDto.setCode("GFZ");
        gfzTreeDto.setParentCode(String.valueOf(region.getRegionCode()));
        gfzTreeDto.setIsOnClick(0);
        gfzTreeDto.setSceneId("1234567891011");
        List<TreeDto> gfz = stationListByRegionCode.stream().filter(t -> t.getParentCode().contains("GFDZ")).collect(Collectors.toList());
        gfzTreeDto.setChildren(gfz);
        List<TreeDto> treeDtos = Arrays.asList(fdzTreeDto, gfzTreeDto);
        treeDto.setChildren(treeDtos);
        return treeDto;
    }

    /**
     * 根据网关与指标获取指标的平均值
     *
     * @param gateway
     * @param indicator
     * @return
     */
    public Object getIndicatoralueAvage(String gateway, String indicator) {
        return monitorFanIndicatorregionMapper.getIndicatoralueAvage(gateway, indicator);
    }


    /**
     * 根据网关与指标获取指标的总值
     *
     * @param gateway
     * @param indicator
     * @return
     */
    public Object getIndicatoralueTotal(String gateway, String indicator) {
        return monitorFanIndicatorregionMapper.getIndicatoralueTotal(gateway, indicator);
    }


    public StationBasic getOneByStationNumber(String stationId) {
        return stationBasicMapper.selectById(stationId);
    }

    public List<ESEquipmentsDTO> getFanStatusList(String stationId) {
        StationBasic stationBasic = getOneByStationNumber(stationId);
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("发电状态", "报警状态", "停机状态", "故障状态", "待机状态", "维护状态", "正常发电状态", "实时故障22"));
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        Map<String, List<String>> queryCondtion1 = new HashMap<>();
        queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("报警状态"));
        queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        List<ESEquipments> equipNumList = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
        Map<String, String> collect = CollectionUtils.isEmpty(result) ? new HashMap<String, String>() : result.stream().collect(Collectors.toMap(ESEquipments::getEquipmentNumber, ESEquipments::getEquipmentIndexName, (item1, item2) -> item1));

        HashMap<String, String> colorMap = new HashMap<>();
        colorMap.put("正常运行", "#00aa00");
        colorMap.put("报警运行", "#ffc400");
        colorMap.put("停机状态", "#a3f5aa");
        colorMap.put("故障状态", "#ff0000");
        colorMap.put("限功率", "#0055ff");
        colorMap.put("待机状态", "#00aaff");
        colorMap.put("维护状态", "#ff00ff");
        colorMap.put("通讯中断", "#7d8e95");

        List<ESEquipmentsDTO> resultList = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(equipNumList)) {
            equipNumList.forEach(item -> {
                String status = ObjectUtils.isEmpty(CommonConstans.fanStatus.get(collect.get(item.getEquipmentNumber()))) ? "通讯中断" : CommonConstans.fanStatus.get(collect.get(item.getEquipmentNumber()));
                item.setAddress(status);
                ESEquipmentsDTO esEquipmentsDTO = new ESEquipmentsDTO();
                BeanUtil.copyProperties(item, esEquipmentsDTO);
                String color = colorMap.get(status);
                esEquipmentsDTO.setState(status);
                esEquipmentsDTO.setColor(color);
                resultList.add(esEquipmentsDTO);
            });
        }

        return resultList;

    }

    public List<IndexDto> getFanStatusStatistics(String stationId) {
        List<ESEquipmentsDTO> equipNumList = getFanStatusList(stationId);
        Map<String, Long> countMap = equipNumList.stream().collect(Collectors.groupingBy(ESEquipmentsDTO::getAddress, Collectors.counting()));
        List<IndexDto> resultList = new ArrayList<>();
        List<String> list = Arrays.asList("正常运行", "报警运行", "停机状态", "故障状态", "限功率", "待机状态", "维护状态", "通讯中断");
        HashMap<String, String> colorMap = new HashMap<>();
        colorMap.put("正常运行", "#00aa00");
        colorMap.put("报警运行", "#ffc400");
        colorMap.put("停机状态", "#a3f5aa");
        colorMap.put("故障状态", "#ff0000");
        colorMap.put("限功率", "#0055ff");
        colorMap.put("待机状态", "#00aaff");
        colorMap.put("维护状态", "#ff00ff");
        colorMap.put("通讯中断", "#7d8e95");
        list.forEach(item -> {
            IndexDto indexDto = new IndexDto();
            indexDto.setCountString(countMap.containsKey(item) ? String.valueOf(countMap.get(item)) : "0");
            indexDto.setEquipmentIndexName(item);
            indexDto.setColor(colorMap.get(item));
            resultList.add(indexDto);
        });
        return resultList;
    }

    public IndexDto getFanBasicInfoByEquipNum(String equipNum, String stationId) {
        String json = null;
        try {
            json = IOUtils.toString(fanlocation.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONArray jsonArray = JSONObject.parseArray(json);
        JSONObject jsonObject = (JSONObject) jsonArray.get(Integer.valueOf(equipNum) - 1);
        IndexDto indexDto = new IndexDto();
        indexDto.setLongitude(String.valueOf(jsonObject.get("longitude")));
        indexDto.setLatitude(String.valueOf(jsonObject.get("latitude")));
        StationBasic stationBasic = getOneByStationNumber(stationId);
        List<ESEquipmentsDTO> fanStatusList = getFanStatusList(stationId);
        String fanStatus = fanStatusList.stream().filter(esEquipments -> esEquipments.getEquipmentNumber().equals(equipNum)).collect(Collectors.toList()).get(0).getAddress();
        indexDto.setEquipmentIndexName(fanStatus);
        List<Map<String, String>> fanConfigPower = monitorFanIndicatorregionMapper.getFanConfigPower(stationBasic.getFanGatewayId(), equipNum);
        if (CollectionUtils.isEmpty(fanConfigPower)) {
            throw new BadRequest("fan_config_power表数据未维护该风机");
        }
        String equipmentSpecificName = fanConfigPower.get(0).get("equipmentSpecificName");
        String substring = equipmentSpecificName.substring(0, equipmentSpecificName.indexOf("#"));
        indexDto.setEquipmentSpecificName(substring);
        indexDto.setEquipmentNumber(equipNum);
        return indexDto;
    }

    /**
     * 根据风机号 场站号 模块获取实时温度
     *
     * @param equipNum
     * @param stationId
     * @param frontModule
     * @return 风机的实时温度数据
     */
    public HashMap<String, List<String>> getRealTimeTemperature(String equipNum, String stationId, String frontModule) {
        HashMap<String, List<String>> realTimeTemperatureResult = new HashMap<>();
        StationBasic stationBasic = getOneByStationNumber(stationId);
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        queryCondtion.put(CommonConstans.QueryStringEquipmentNumberKeyword, Arrays.asList(equipNum));
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, frontModule);
        List<ESEquipments> result = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);
        List<String> xList = new ArrayList<>();
        List<String> yList = new ArrayList<>();
        for (int i = 0; i < result.size(); i++) {
            ESEquipments esEquipments = result.get(i);
            if (esEquipments.getEquipmentIndexName().contains("温度")) {
                xList.add(esEquipments.getEquipmentIndexName());
                yList.add(null == esEquipments.getValueF() ? "0" : esEquipments.getValueF().toString());
            }
        }
        realTimeTemperatureResult.put("axisData", xList);
        realTimeTemperatureResult.put("seriesData", yList);
        return realTimeTemperatureResult;
    }

    public Integer getFanNum(String stationId) {
        StationBasic stationBasic = getOneByStationNumber(stationId);
        Map<String, List<String>> queryCondtion1 = new HashMap<>();
        queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("发电状态"));
        queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        List<ESEquipments> equipNumList = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
        return equipNumList.size();
    }

    public String getFanDataByType(String stationId, String equipNum, String frontModule, String typeName) {
        StationBasic stationBasic = getOneByStationNumber(stationId);
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, frontModule);
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(typeName));
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        queryCondtion.put(CommonConstans.QueryStringEquipmentNumberKeyword, Arrays.asList(equipNum));
        List<ESEquipments> equipNumList = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);
        if (CollectionUtils.isNotEmpty(equipNumList) && !ObjectUtils.isEmpty(equipNumList.get(0).getValueF())) {
            return equipNumList.get(0).getValueF().toString();
        } else {
            return "0";
        }
    }

    public String getEquipCount(String gatewayId, String stationType) {
        Map<String, List<String>> queryCondtion1 = new HashMap<>();
        if (stationType.equals("FDZ")) {
            queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("有功功率"));
        } else {
            queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行"));
        }
        queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        List<ESEquipments> equipNumList = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
        if (!CollectionUtils.isEmpty(equipNumList)) {
            return equipNumList.size() + "";
        }
        return "0";
    }


    public Map<String, Object> getDetailsWindSpeedAll(String gatewayId) {
        List<Map<String, Object>> list = temporaryDataMapper.timingTemporarysSorageData(gatewayId);
        Map<String, Object> map = new HashMap<>();
        List<String> values = new ArrayList<>();
        List<String> valueList = new ArrayList<>();
        Set<String> time = new TreeSet<>();

        for (Map<String, Object> stringStringMap : list) {
            if (stringStringMap.get("equipmentIndexName").toString().equals("有功功率")) {
                values.add(stringStringMap.get("value").toString());
            } else {
                valueList.add(stringStringMap.get("value").toString());
                time.add(stringStringMap.get("createdTime").toString());
            }
        }

        List<Map<String, Object>> seriesData = new ArrayList<>();
        Map<String, Object> map3 = new HashMap<>();
        Map<String, Object> map1 = new HashMap<>();
        Map<String, Object> map2 = new HashMap<>();
        map1.put("data", values);
        map2.put("data", valueList);
        seriesData.add(map2);
        seriesData.add(map1);
        map.put("seriesData", seriesData);
        map.put("axisData", time);

        return map;
    }

    public Map<String, Object> getDetailsWindSpeed(String gatewayId, String name) {

        Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
        Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
        String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
        String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
        List<IndicatorData> indicatorDataListWindSpeed = new ArrayList<>();
        List<IndicatorData> indicatorDataListActivePower = new ArrayList<>();
        indicatorDataListWindSpeed = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("瞬时风速", name, startTime, endTime, gatewayId);
        indicatorDataListActivePower = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("有功功率", name, startTime, endTime, gatewayId);
        List<String> windSpeeds = new ArrayList<>();
        List<String> activePowers = new ArrayList<>();
        List<String> axisData = new ArrayList<>();
        for (int i = 0; i < indicatorDataListWindSpeed.size(); i++) {
            windSpeeds.add(indicatorDataListWindSpeed.get(i).getValue());
            activePowers.add(indicatorDataListActivePower.get(i).getValue());
            axisData.add(DateUtil.format(indicatorDataListWindSpeed.get(i).getCreatedTime(), "HH:mm"));
        }
        List<Map<String, Object>> seriesData = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> map1 = new HashMap<>();
        Map<String, Object> map2 = new HashMap<>();
        map1.put("data", windSpeeds);
        map2.put("data", activePowers);
        seriesData.add(map1);
        seriesData.add(map2);
        map.put("seriesData", seriesData);
        map.put("axisData", axisData);
        return map;
    }


    public Map<String, Object> getDetailsWindSpeeds(String gatewayId, String name) {
        Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
        Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
        String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
        String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
        List<IndicatorData> indicatorDataListActivePowers = new ArrayList<>();
        indicatorDataListActivePowers = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumber("有功功率", name, startTime, endTime, gatewayId);
        List<String> axisData = new ArrayList<>();
        List<String> activePowers = new ArrayList<>();
        for (int i = 0; i < indicatorDataListActivePowers.size(); i++) {
            activePowers.add(indicatorDataListActivePowers.get(i).getValue());
            axisData.add(DateUtil.format(indicatorDataListActivePowers.get(i).getCreatedTime(), "HH:mm"));
        }
        List<Map<String, Object>> seriesData = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> map2 = new HashMap<>();
        map2.put("data", activePowers);
        seriesData.add(map2);
        map.put("seriesData", seriesData);
        map.put("axisData", axisData);
        return map;
    }


    @Scheduled(cron = "${windSpeed.Scheduled.cron}")
    private void schedTaskData() {

        LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BaseEntity::getIsDelete, false);
        List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
        long timeInMillis = new Date().getTime();

        for (StationBasic stationBasic : stationBasics) {
            if (stationBasic.getStationType().equals("FDZ")) {
                timingTemporarysSorageData(stationBasic, timeInMillis);
            }
            if (stationBasic.getStationType().equals("JZSGFDZ")) {
                schedSolarPower(stationBasic, timeInMillis);
            }
        }
    }

    @Scheduled(cron = "0 59 23 * * ?")
    private void deleteSchedData() {
        QueryWrapper<TemporaryData> wrapper = new QueryWrapper<>();
        temporaryDataMapper.delete(wrapper);
        String sort = alarmEventMapper.getLastDataBySort(null);
        LambdaQueryWrapper<AlarmEvent> params = new LambdaQueryWrapper<>();
        params.notIn(AlarmEvent::getSort, sort);
        alarmEventMapper.delete(params);
    }


    @Scheduled(cron = "0 */5 * * * ?")
    private void schedAlarmEventData() {
        LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BaseEntity::getIsDelete, false);
        List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
        long currentsort = new Date().getTime();
        for (StationBasic stationBasic : stationBasics) {
            schedAddAlarmEventData(stationBasic.getBoosterGatewayId(), stationBasic.getSequenceNbr().toString(), stationBasic.getStationName(), currentsort);
        }
    }


    public void schedAddAlarmEventData(String gatewayId, String stationId, String stationName, long currentsort) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion.put(CommonConstans.QueryStringSystemTypeKeyword, Arrays.asList("光字牌"));
        queryCondtion.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("false"));
        List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        List<AlarmEvent> newAlarmEvents = new ArrayList<>();
        List<String> alarmsNames = new ArrayList<>();

        for (ESEquipments esEquipments : indicatorsDtoList) {
            AlarmEvent alarmEvent = new AlarmEvent();
            alarmEvent.setEventDesc(esEquipments.getEquipmentIndexName());
            alarmEvent.setEventTime(esEquipments.getCreatedTime());
            alarmEvent.setStationId(stationId);
            alarmEvent.setStationName(stationName);
            alarmEvent.setGatewayId(gatewayId);
            alarmEvent.setCreatedTime(new Date());
            alarmEvent.setAlarmGroupName("运行告警");
            alarmEvent.setEventMovement(esEquipments.getValue());
            alarmEvent.setSort(currentsort);
            newAlarmEvents.add(alarmEvent);
            alarmsNames.add(esEquipments.getEquipmentIndexName());
        }
        alarmsNames.sort(Comparator.naturalOrder());
        String newAlarms = String.join(",", alarmsNames);

        String sort = alarmEventMapper.getLastDataBySort(gatewayId);
        List<String> oldAlarmEvents = alarmEventMapper.getOldAlarmsBySort(gatewayId, sort);
        oldAlarmEvents.sort(Comparator.naturalOrder());
        String oldName = String.join(",", oldAlarmEvents);

        if (!newAlarms.equals(oldName)) {
            for (String oldAlarmEvent : oldAlarmEvents) {
                if (newAlarms.contains(oldAlarmEvent)) {

                } else {
                    AlarmEvent alarmEvent = new AlarmEvent();
                    alarmEvent.setStationId(stationId);
                    alarmEvent.setStationName(stationName);
                    alarmEvent.setEventDesc(oldAlarmEvent);
                    alarmEvent.setEventTime(new Date());
                    alarmEvent.setGatewayId(gatewayId);
                    alarmEvent.setAlarmGroupName("运行告警");
                    alarmEvent.setCreatedTime(new Date());
                    alarmEvent.setEventMovement("false");
                    alarmEvent.setSort(currentsort);
                    newAlarmEvents.add(alarmEvent);
                }
            }
        }
        alarmEventService.saveBatch(newAlarmEvents);

    }


    public void timingTemporarysSorageData(StationBasic stationBasic, long timeInMillis) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("瞬时风速"));
        List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        Map<String, List<String>> queryCondtion1 = new HashMap<>();
        queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
        queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
        List<ESEquipments> indicatorsDtoLists = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
        List<TemporaryData> temporaryDatas = new ArrayList<>();
        List<TemporaryData> temporaryDatass = new ArrayList<>();
        String time = "";
        try {
            time = DateUtils.dateFormat(new Date(), DateUtils.MINUTE_PATTERN);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        // long timeInMillis = new Date().getTime();
        for (ESEquipments indicatorsDto : indicatorsDtoList) {
            try {
                TemporaryData temporaryData = new TemporaryData();
                temporaryData.setBatchNo(timeInMillis);
                temporaryData.setCreatedTime(time.split(" ")[1]);
                temporaryData.setEquipmentIndexName(indicatorsDto.getEquipmentIndexName());
                temporaryData.setGatewayId(stationBasic.getFanGatewayId());
                temporaryData.setValue(null == indicatorsDto.getValueF() ? 0 : indicatorsDto.getValueF());
                temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
                temporaryDatas.add(temporaryData);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        for (ESEquipments indicatorsDto : indicatorsDtoLists) {
            try {
                TemporaryData temporaryData = new TemporaryData();
                temporaryData.setBatchNo(timeInMillis);
                temporaryData.setCreatedTime(time.split(" ")[1]);
                temporaryData.setEquipmentIndexName("有功功率");
                temporaryData.setGatewayId(stationBasic.getFanGatewayId());
                temporaryData.setValue(null == indicatorsDto.getValueF() ? 0 : indicatorsDto.getValueF());
                temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
                temporaryDatass.add(temporaryData);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        temporaryDataService.saveBatch(temporaryDatas);
        temporaryDataService.saveBatch(temporaryDatass);
    }

    public void schedSolarPower(StationBasic stationBasic, long timeInMillis) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("WTX-801_25_WTX-801_总辐射"));
        List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        Map<String, List<String>> queryCondtion1 = new HashMap<>();
        queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
        queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P"));
        List<ESEquipments> indicatorsDtoLists = commonServiceImpl.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
        List<TemporaryData> temporaryDatas = new ArrayList<>();
        List<TemporaryData> temporaryDatass = new ArrayList<>();
        String time = "";
        try {
            time = DateUtils.dateFormat(new Date(), DateUtils.MINUTE_PATTERN);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        //   long timeInMillis = new Date().getTime();
        for (ESEquipments indicatorsDto : indicatorsDtoList) {
            try {
                TemporaryData temporaryData = new TemporaryData();
                temporaryData.setBatchNo(timeInMillis);
                temporaryData.setCreatedTime(time.split(" ")[1]);
                temporaryData.setGatewayId(indicatorsDto.getGatewayId());
                temporaryData.setValue(Float.valueOf(indicatorsDto.getValue()));
                temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
                temporaryData.setEquipmentIndexName("总辐射累计");
                temporaryDatas.add(temporaryData);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        for (ESEquipments indicatorsDto : indicatorsDtoLists) {
            try {
                TemporaryData temporaryData = new TemporaryData();
                temporaryData.setBatchNo(timeInMillis);
                temporaryData.setCreatedTime(time.split(" ")[1]);
                temporaryData.setGatewayId(indicatorsDto.getGatewayId());
                temporaryData.setValue(indicatorsDto.getValueF() / 1000);
                temporaryData.setEquipmentNumber(indicatorsDto.getEquipmentNumber());
                temporaryData.setEquipmentIndexName("有功功率");
                temporaryDatass.add(temporaryData);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        temporaryDataService.saveBatch(temporaryDatas);
        temporaryDataService.saveBatch(temporaryDatass);
    }


    public List<Map<String, Object>> getStatusMonitoring(String gatewayId, String equipNum, String systemName) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion.put(CommonConstans.QueryStringEquipmentNumber, Arrays.asList(equipNum));
        Map<String, String> shouldCondition = new HashMap<>();
        shouldCondition.put(CommonConstans.QueryStringEquipmentIndexName, "实时故障");
        List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldCondition, ESEquipments.class);
        String type = listData.get(0).getEquipmentSpecificName().substring(0, 5);
        List<SystemEnumDto> statusMonitoring = systemEnumMapper.getStatusMonitoring(type, systemName);
        List<Map<String, Object>> statusMaps = new ArrayList<>();
        for (SystemEnumDto systemEnumDto : statusMonitoring) {
            Map<String, Object> statusMap = new HashMap<>();
            statusMap.put("title1", systemEnumDto.getEnumDesc());
            for (ESEquipments listDatum : listData) {
                if (listDatum.getEquipmentSpecificName().contains(systemEnumDto.getCode()) &&
                        systemEnumDto.getEunmValue().equals(listDatum.getValue())) {
                    statusMap.put("state", "1");
                } else {
                    statusMap.put("state", "0");
                }
            }
            statusMaps.add(statusMap);
        }
        return statusMaps;
    }


    public List<Map<String, Object>> getStatusGzp(String gatewayId, String systemType, String frontModule, String equipNum) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion.put(CommonConstans.QueryStringSystemTypeKeyword, Arrays.asList(systemType));
        if (null != equipNum) {
            queryCondtion.put(CommonConstans.QueryStringEquipmentNumberKeyword, Arrays.asList(equipNum));
        }

        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, frontModule);
        List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);

        List<Map<String, Object>> statusMaps = new ArrayList<>();
        for (ESEquipments listDatum : indicatorsDtoList) {
            Map<String, Object> statusMap = new HashMap<>();
            String data = listDatum.getDisplayName();
            if (StringUtils.isEmpty(data)) {
                data = listDatum.getEquipmentIndexName();
            } else {
                if (data.equals(listDatum.getEquipmentNumber())) {
                    data = listDatum.getEquipmentIndexName();
                } else {
                    data = listDatum.getDisplayName();
                }
            }
            statusMap.put("data", data);
            statusMap.put("state", listDatum.getValue().equals("false") ? 0 : 1);
            statusMap.put("status", listDatum.getValue().equals("false") ? 0 : 1);
            statusMap.put("title", listDatum.getValue().equals("false") ? "通" : "断");
            statusMaps.add(statusMap);
        }

        Collator instance = Collator.getInstance(Locale.CHINA);
        Collections.sort(statusMaps, (e1, e2) -> {
            return instance.compare(e1.get("data"), e2.get("data"));
        });

        return statusMaps;
    }


    public List<Map<String, Object>> getAnalogQuantity(String gatewayId, String frontModule, String systemType) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, frontModule);
        likeMap.put(CommonConstans.QueryStringSystemType, systemType);
        List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);
        List<ESEquipments> listData = esEquipmentsList.stream().filter(esEquipments -> !esEquipments.getDisplayName().equals("")).collect(Collectors.toList());
        List<Map<String, Object>> statusMaps = new ArrayList<>();
        for (ESEquipments listDatum : listData) {
            Map<String, Object> statusMap = new HashMap<>();
            if (StringUtils.isEmpty(listDatum.getValue())) {
                statusMap.put("title", 0.00 + (StringUtils.isNotEmpty(listDatum.getUnit()) ? listDatum.getUnit() : ""));
            } else {
                statusMap.put("title", keepTwoDecimalPlaces(listDatum.getValue()) + " " + (StringUtils.isNotEmpty(listDatum.getUnit()) ? listDatum.getUnit() : ""));
            }
            statusMap.put("title1", listDatum.getDisplayName());
            statusMaps.add(statusMap);
        }
        return statusMaps;
    }

    public void getStatusJDX(String gatewayId, String stationId, String frontModule) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));

        Map<String, String> likeCodtion = new HashMap<>();
        likeCodtion.put(CommonConstans.QueryStringFrontMoudle, frontModule);
        likeCodtion.put(CommonConstans.QueryStringDisplayName + ".keyword", "合位");
        List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeCodtion);

        Collator instance = Collator.getInstance(Locale.CHINA);
        Collections.sort(listData, (e1, e2) -> {
            return instance.compare(e1.getFrontModule(), e2.getFrontModule());
        });
        List<Map<String, Object>> statusMaps = new ArrayList<>();
        Map<String, List<ESEquipments>> collect = listData.stream().collect(Collectors.groupingBy(ESEquipments::getFrontModule, LinkedHashMap::new, Collectors.toList()));

        for (String s : collect.keySet()) {
            Map<String, Object> statusMap = new HashMap<>();
            if (frontModule.equals("前光")) {

                likeCodtion.remove(CommonConstans.QueryStringDisplayName + ".keyword");
                likeCodtion.put(CommonConstans.QueryStringSystemType + ".keyword", "模拟量");
                List<ESEquipments> value = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeCodtion);

                for (ESEquipments indicatorsDto : value) {
                    Double aDouble = Double.valueOf(indicatorsDto.getValue());
                    statusMap.put(indicatorsDto.getDisplayName() + "Value", String.format(CommonConstans.Twodecimalplaces, aDouble));
                }
            }
            List<ESEquipments> indicatorsDtos = collect.get(s);
            for (ESEquipments indicatorsDto : indicatorsDtos) {
                if (indicatorsDto.getDisplayName().contains("断路器_合位")) {
                    statusMap.put("type", indicatorsDto.getValue());
                    statusMap.put("status", indicatorsDto.getValue().equals("false") ? "0" : "1");
                    statusMap.put("position", indicatorsDto.getDisplayName().split("_")[0] + "开关位置");
                }

            }
//            statusMap.put("title", s.substring(3));
            statusMap.put("title", s);
            //如果是光伏则需要进行数据截取
            if (frontModule.equals("前光")) {
                statusMap.put("title", s.substring(3));
            }
            statusMap.put("power", "有功 (kW)");
            statusMap.put("windSpeed", "风速 (m/s)");
            statusMaps.add(statusMap);
        }

        IPage<Map<String, Object>> result = new Page<>();
        result.setRecords(statusMaps);
        result.setCurrent(1);
        result.setTotal(statusMaps.size());
        try {
            emqKeeper.getMqttClient().publish(stationId + "/fxqTree", JSON.toJSONString(result).getBytes(), 0, false);
        } catch (MqttException e) {
            log.info("消息发送失败");
            e.printStackTrace();
        }
    }

    public void getListByFJ(String gatewayId, String werks, String stationId) {
        HashMap<String, String> fanstatutsHashMap = new HashMap<>();
        StationBasic stationBasic = stationBasicMapper.selectById(stationId);
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("瞬时风速"));
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("有功功率"));
        List<ESEquipments> listData1 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        TpriDmpDatabook tpriDmpDatabook = tpriDmpDatabookServiceImpl.getTpriDmpDatabookByDataName("风机");
        List<Map<String, Object>> dataMaps = sjglZsjZsbtzServiceImpl.sjglZsjZsbtzMapper.getStationInfoMapByStationWerks(werks, tpriDmpDatabook.getDataid().toString());
        //获取风机列表
        List<ESEquipmentsDTO> fanStatusList = getFanStatusList(stationId);
        fanStatusList.forEach(equipments -> {
            fanstatutsHashMap.put(equipments.getEquipmentNumber(), equipments.getAddress());
        });
        String prefix = commonServiceImpl.getFanDevicePrefix(stationId);
        int i = 0;
        for (Map<String, Object> dataMap : dataMaps) {
            List<String> numList = Arrays.asList(dataMap.get("equipNum").toString().split(","));
            List<Map<String, Object>> statusMaps = new ArrayList<>();
            for (ESEquipments listDatum : listData) {
                if (null == listDatum.getValueF()) {
                    listDatum.setValueF(0F);
                }
                for (ESEquipments indicatorsDto : listData1) {
                    if (listDatum.getEquipmentNumber().equals(indicatorsDto.getEquipmentNumber())) {
                        listDatum.setValueLabel(String.valueOf(indicatorsDto.getValueF() == null ? 0 : indicatorsDto.getValueF()));
                    }
                }

                for (String num : numList) {
                    if (Integer.parseInt(num) == Integer.parseInt(listDatum.getEquipmentNumber())) {
                        Map<String, Object> map = new HashMap<>();
                        map.put("title", prefix + listDatum.getEquipmentNumber());
                        //用于参数传递
                        map.put("title1", listDatum.getEquipmentNumber());
                        map.put("windSpeed", listDatum.getValueF());
                        map.put("power", listDatum.getValueLabel());
                        //获取风机状态如果获取到的状态为空-则默认为正常运行状态
                        String fantStatus = ObjectUtils.isEmpty(fanstatutsHashMap.get(listDatum.getEquipmentNumber())) ? "通讯中断" : fanstatutsHashMap.get(listDatum.getEquipmentNumber());
                        map.put("url", fanStatusImagePathPrefix + File.separator + "风机-" + fantStatus + ".gif");
                        statusMaps.add(map);
                    }
                }
            }
            IPage<Map<String, Object>> result = new Page<>();
            result.setRecords(statusMaps);
            result.setCurrent(1);
            result.setTotal(statusMaps.size());
            i += 1;
            try {
                emqKeeper.getMqttClient().publish(stationId + "/fj/group" + i, JSON.toJSONString(result).getBytes(), 0, false);
            } catch (MqttException e) {
                log.info("消息发送失败");
                e.printStackTrace();
            }
        }

    }


    public List<Map<String, String>> getBoosterStationInfo(String stationId) {
        StationBasic stationBasic = getOneByStationNumber(stationId);
        List<Map<String, String>> boosterStationInfo = new ArrayList<>();
        if ("夏造风电站".equals(stationBasic.getStationName())) {
            boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfo2(stationBasic.getBoosterGatewayId());
        } else {
            boosterStationInfo = monitorFanIndicatorregionMapper.getBoosterStationInfoNormal(stationBasic.getBoosterGatewayId());
        }
        return boosterStationInfo;
    }

    public ResultsData runningPageByStationId(int current, int size, String stationId) {
        StationBasic stationBasic = stationBasicMapper.selectById(stationId);
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("风向角", "有功功率", "瞬时风速", "日发电量"));
        List<ESEquipments> allList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        List<ESEquipments> windSqlList = new ArrayList<>();
        List<ESEquipments> windSqlSortList = new ArrayList<>();
        List<ESEquipments> powerSqlList = new ArrayList<>();
        List<ESEquipments> windSpeedSqlList = new ArrayList<>();
        List<ESEquipments> electricitySqlList = new ArrayList<>();
        allList.forEach(item -> {
            if ("风向角".equals(item.getEquipmentIndexName())) {
                windSqlList.add(item);
            }
            if ("有功功率".equals(item.getEquipmentIndexName())) {
                if (!ObjectUtils.isEmpty(item.getValue())) {
                    item.setValue(String.format(CommonConstans.Twodecimalplaces, Double.parseDouble(item.getValue()) / 1000));
                }
                powerSqlList.add(item);
            }
            if ("瞬时风速".equals(item.getEquipmentIndexName())) {
                windSpeedSqlList.add(item);
            }
            if ("日发电量".equals(item.getEquipmentIndexName())) {
                electricitySqlList.add(item);
            }
        });
        Map<String, String> powerSqlMap = powerSqlList.stream().collect(Collectors.toMap(ESEquipments::getEquipmentNumber, ESEquipments::getValue));
        Map<String, String> windSpeedSqlMap = windSpeedSqlList.stream().collect(Collectors.toMap(ESEquipments::getEquipmentNumber, ESEquipments::getValue));
        windSqlSortList = windSqlList.stream().sorted(Comparator.comparing(ESEquipments::getEquipmentNumber,Comparator.comparing(Integer::parseInt))).collect(Collectors.toList());
        Map<String, String> electricitySqlMap = electricitySqlList.stream().collect(Collectors.toMap(ESEquipments::getEquipmentNumber, ESEquipments::getValue));
        ArrayList<Map<String, String>> resultList = new ArrayList<>();
        for (int i = 0; i < windSqlSortList.size(); i++) {
            ESEquipments esEquipments = windSqlSortList.get(i);
            HashMap<String, String> stringStringHashMap = new HashMap<>();
            stringStringHashMap.put("equipmentNumber", esEquipments.getEquipmentNumber());
            stringStringHashMap.put("wind", ObjectUtils.isEmpty(esEquipments.getValue()) ? "0.0" : esEquipments.getValue());
            stringStringHashMap.put("power", powerSqlMap.get(esEquipments.getEquipmentNumber()));
            stringStringHashMap.put("windSpeed", windSpeedSqlMap.get(esEquipments.getEquipmentNumber()));
            stringStringHashMap.put("electricity", String.format(CommonConstans.Fourdecimalplaces, ObjectUtils.isEmpty(electricitySqlMap.get(esEquipments.getEquipmentNumber())) ? 0.0000 : Double.valueOf(electricitySqlMap.get(esEquipments.getEquipmentNumber()))));
            resultList.add(stringStringHashMap);
        }
        //构建平台数据
        DataGridMock DataGridMock = new DataGridMock(current, resultList.size(), false, current, resultList);
        ColModel colModelEquipmentNumber = new ColModel("equipmentNumber", "equipmentNumber", "风机编码", "风机编码", "dataGrid", "equipmentNumber");
        ColModel colModelPower = new ColModel("power", "power", "有功功率(MW)", "有功功率(MW)", "dataGrid", "power");
        ColModel colModelWindSpeed = new ColModel("windSpeed", "windSpeed", "风速(m/s)", "风速(m/s)", "dataGrid", "windSpeed");
        ColModel colModelWind = new ColModel("wind", "wind", "风向(°)", "风向(°)", "dataGrid", "wind");
        ColModel colModelElectricity = new ColModel("electricity", "electricity", "日发电量(万KWh)", "日发电量(万KWh)", "dataGrid", "electricity");
        List<ColModel> listColModel = Arrays.asList(colModelEquipmentNumber, colModelPower, colModelWindSpeed, colModelWind, colModelElectricity);
        ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
        return resultsData;
    }


  public ResultsData getAlarmEventList(int current, int size, String stationId) {
    	
        LambdaQueryWrapper<AlarmEvent> queryWrapper = new LambdaQueryWrapper<>();
        if(stationId!=null) 
        {
            queryWrapper.eq(AlarmEvent::getStationId, stationId);
        }
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, -7);
        queryWrapper.gt(AlarmEvent::getCreatedTime, calendar.getTime());
        int count = alarmEventMapper.selectCount(queryWrapper);
        
        List<AlarmEventDto> alarmEventList = alarmEventMapper.getAlarmEventList(null, stationId,(current-1)*size,size,calendar.getTime());

        // List<AlarmEventDto> sorrtedAlarmEventList = alarmEventList.stream().sorted(Comparator.comparing(AlarmEventDto::getCreatedTime).reversed()).collect(Collectors.toList());
//        ArrayList<Map<String, String>> resultList = new ArrayList<>();
//        alarmEventList.forEach(item -> {
//            HashMap<String, String> stringStringHashMap = new HashMap<>();
//            stringStringHashMap.put("stationName", item.getStationName());
//            stringStringHashMap.put("eventDesc", item.getEventDesc());
//            stringStringHashMap.put("alarmGroupName", item.getAlarmGroupName());
//            stringStringHashMap.put("eventTime", item.getEventTime());
//            stringStringHashMap.put("eventMovement", item.getEventMovement());
//            resultList.add(stringStringHashMap);
//        });
        //构建平台数据
        DataGridMock DataGridMock = new DataGridMock(current, count, false, current, alarmEventList);
        ColModel colModelStationName = new ColModel("stationName", "stationName", "名称", "名称", "dataGrid", "stationName");
        ColModel colModelEventDesc = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc");
        ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件告警组", "事件告警组", "dataGrid", "alarmGroupName");
        ColModel colModelEventTime = new ColModel("eventTime", "eventTime", "事件发生时间", "事件发生时间", "dataGrid", "eventTime");
        ColModel colModelEventMovement = new ColModel("eventMovement", "eventMovement", "事件动作描述", "事件动作描述", "dataGrid", "eventMovement");
        List<ColModel> listColModel = Arrays.asList(colModelStationName, colModelEventDesc, colModelAlarmGroupName, colModelEventTime, colModelEventMovement);
        ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
        return resultsData;
    }


    public ResultsData getElectricQuantityList(int current, int size, String gatewayId, String stationType) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
//        queryCondtion.put(CommonConstans.QueryStringFrontMoudle, Arrays.asList("电量表计"));
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "电量表计");
        List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);
        List<ESEquipments> windSqlList = esEquipmentsList.stream().filter(esEquipments -> !esEquipments.getDisplayName().equals("") && !esEquipments.getDisplayName().equals("检修状态")).collect(Collectors.toList());
        Map<String, List<ESEquipments>> maps = windSqlList.stream().collect(Collectors.groupingBy(ESEquipments::getSystemType));
        ArrayList<Map<String, String>> resultList = new ArrayList<>();
        ArrayList<Map<String, String>> resultList1 = new ArrayList<>();
        for (Map.Entry<String, List<ESEquipments>> stringListEntry : maps.entrySet()) {
            HashMap<String, String> stringStringHashMap = new HashMap<>();
            stringStringHashMap.put("name", stringListEntry.getKey());
            for (ESEquipments indicatorsDto : stringListEntry.getValue()) {
                stringStringHashMap.put(ElectricQuantity.getCode(indicatorsDto.getDisplayName()), String.format("%.3f", ObjectUtils.isEmpty(indicatorsDto.getValueF()) ? 0.0 : indicatorsDto.getValueF()));
            }
            if (stringListEntry.getKey().contains("SVG")) {
                resultList1.add(stringStringHashMap);
            } else {
                resultList.add(stringStringHashMap);
            }
        }

        Collator instance = Collator.getInstance(Locale.CHINA);
        Collections.sort(resultList, (e1, e2) -> {
            return instance.compare(e1.get("name"), e2.get("name"));
        });
        resultList.addAll(resultList1);
        //构建平台数据
        DataGridMock DataGridMock = new DataGridMock(current, resultList.size(), false, current, resultList);
        ColModel colModelEventMovement = new ColModel("name", "name", "测量点", "测量点", "dataGrid", "name");
        ColModel colModelStationName = new ColModel("zxzyg", "zxzyg", "正向总有功", "正向总有功", "dataGrid", "zxzyg");
        ColModel colModelEventDesc = new ColModel("fxzyg", "fxzyg", "反向总有功", "反向总有功", "dataGrid", "fxzyg");
        ColModel colModelAlarmGroupName = new ColModel("zxzwg", "zxzwg", "正向总无功", "正向总无功", "dataGrid", "zxzwg");
        ColModel colModelEventTime = new ColModel("fxzwg", "fxzwg", "反向总无功", "反向总无功", "dataGrid", "fxzwg");
        if (null != stationType) {
            colModelEventMovement = new ColModel("name", "name", "测量点", "测量点", "dataGrid", "name");
            colModelStationName = new ColModel("zgxwg", "zgxwg", "正向无功总", "正向无功总", "dataGrid", "zgxwg");
            colModelEventDesc = new ColModel("zzxwg", "zzxwg", "正向有功总", "正向有功总", "dataGrid", "zzxwg");
            colModelAlarmGroupName = new ColModel("zrxwg", "zrxwg", "反向无功总", "反向无功总", "dataGrid", "zrxwg");
            colModelEventTime = new ColModel("zfxyg", "zfxyg", "反向有功总", "反向有功总", "dataGrid", "zfxyg");
        }
        List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelEventDesc, colModelAlarmGroupName, colModelEventTime);
        ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
        return resultsData;
    }


    public void getAnalogQuantityInfo(String gatewayId, String stationId, String routeName) {
        if (StringUtils.isNotEmpty(gatewayId)) {
            Map<String, String> map = monitorFanIndicatorregionMapper.getMajorBoosterStationInfoBySort(gatewayId, routeName);
            Map<String, List<String>> queryCodtion = new HashMap<>();
            Map<String, String> likeMap = new HashMap<>();
            queryCodtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
            queryCodtion.put(CommonConstans.QueryStringSystemTypeKeyword, Arrays.asList("模拟量"));
            likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, map.get("boosterName"));
            if ("1主变高压侧".equals(map.get("boosterName")) || "1主变低压侧".equals(map.get("boosterName"))) {
                likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, map.get("压侧"));
                List<ESEquipments> listData = commonServiceImpl.getListDataByCondtionsAndLike(queryCodtion, null, ESEquipments.class, likeMap);

                // 主变高压侧
                Map<String, String> zbGYC = listData.stream().filter(t -> t.getFrontModule().contains("1主变高压侧")).collect(Collectors.toMap(ESEquipments::getDisplayName, ESEquipments::getValue));
                List<Map<String, String>> zbList = new ArrayList<>();
                listData.stream().filter(t -> t.getFrontModule().contains("1主变低压侧")).forEach(item -> {
                    HashMap<String, String> zbMap = new HashMap<>();
                    zbMap.put("title", item.getDisplayName());
                    zbMap.put("grade1", keepTwoDecimalPlaces(item.getValue()));
                    zbMap.put("grade2", keepTwoDecimalPlaces(zbGYC.getOrDefault(item.getDisplayName(), "0.0")));
                    if (StringUtils.isNotEmpty(item.getUnit())) {
                        zbMap.put("title", String.format("%s(%s)", item.getDisplayName(), item.getUnit()));
                    }
                    zbList.add(zbMap);
                });
                IPage<Map<String, String>> zbResult = new Page<>();
                zbResult.setRecords(zbList);
                zbResult.setCurrent(1);
                zbResult.setTotal(zbList.size());
                try {
                    log.info("主变消息内容：{}", JSON.toJSONString(zbResult));
                    emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, routeName, "mnl"), JSON.toJSONString(zbResult).getBytes(), 2, false);
                } catch (MqttException e) {
                    log.info("消息发送失败");
                    e.printStackTrace();
                }
            } else {
                List<ESEquipments> listData = commonServiceImpl.getListDataByCondtionsAndLike(queryCodtion, null, ESEquipments.class, likeMap);
                ArrayList<Map<String, String>> resultList = new ArrayList<>();
                listData.forEach(item -> {
                    HashMap<String, String> stringStringHashMap = new HashMap<>();
                    stringStringHashMap.put("title", item.getDisplayName());
                    stringStringHashMap.put("value", keepTwoDecimalPlaces(item.getValue()));
                    if (StringUtils.isNotEmpty(item.getUnit())) {
                        stringStringHashMap.put("title", String.format("%s(%s)", item.getDisplayName(), item.getUnit()));
                    }
                    resultList.add(stringStringHashMap);
                });

                IPage<Map<String, String>> result = new Page<>();
                result.setRecords(resultList);
                result.setCurrent(1);
                result.setTotal(resultList.size());
                try {
                    log.info("消息内容：{}", JSON.toJSONString(result));
                    emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, routeName, "mnl"), JSON.toJSONString(result).getBytes(), 2, false);
                } catch (MqttException e) {
                    log.info("消息发送失败");
                    e.printStackTrace();
                }
            }
        }
    }

    public void getMajorAnalogQuantityByPage(String gatewayId, String stationId) {
        if (StringUtils.isNotEmpty(gatewayId)) {
            Map<String, List<String>> queryCondition = new HashMap<>();
            queryCondition.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
            queryCondition.put(CommonConstans.QueryStringSystemTypeKeyword, Arrays.asList("模拟量"));
            List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondition, null, ESEquipments.class);
            List<ESEquipments> xianData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getFrontModule().equals("220kVⅠ母PT") || esEquipments.getFrontModule().equals("35kVⅠ母PT")).collect(Collectors.toList());
            HashMap<String, Object> resultMap = new HashMap<>();
            xianData.forEach(item -> {
                if ("220kVⅠ母PT".equals(item.getFrontModule())) {
                    resultMap.put("220" + item.getDisplayName(), item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
                } else if ("35kVⅠ母PT".equals(item.getFrontModule())) {
                    resultMap.put("35" + item.getDisplayName(), item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
                }
            });
            List<String> xyxDisplayNameList = Arrays.asList("Ia", "P", "Q", "Ux");
            List<ESEquipments> xyxSqlData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getFrontModule().equals("夏雩线") && xyxDisplayNameList.contains(esEquipments.getDisplayName())).collect(Collectors.toList());
            xyxSqlData.forEach(item -> resultMap.put("xyx" + item.getDisplayName(), keepTwoDecimalPlaces(item.getValue())));
            List<ESEquipments> dlbjSqlData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getFrontModule().equals("模拟量")).collect(Collectors.toList());
            // 正向总有功正向总无功需要计算
            dlbjSqlData.forEach(item -> {
                if ("正向总有功".equals(item.getDisplayName())) {
                    resultMap.put("2000S1", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValueF().toString()) / 1000))));
                } else if ("正向总无功".equals(item.getDisplayName())) {
                    resultMap.put("2000S2", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(String.valueOf((Double.parseDouble(item.getValueF().toString()) / 1000))));
                }
            });

            List<String> zb1DisplayNameList = Arrays.asList("档位", "油面温1", "油面温2", "绕组温度");
            List<ESEquipments> zb1SqlData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getFrontModule().equals("1主变") && zb1DisplayNameList.contains(esEquipments.getDisplayName())).collect(Collectors.toList());
            resultMap.put("value1", "0.0");
            resultMap.put("value2", "0.0");
            resultMap.put("value3", "0.0");
            resultMap.put("value4", "0.0");
            zb1SqlData.forEach(item -> {
                if ("档位".equals(item.getDisplayName())) {
                    resultMap.put("value4", ObjectUtils.isEmpty(item.getValueF()) ? "0" : String.format("%.0f", Double.parseDouble(item.getValueF().toString())));
                } else if ("油面温1".equals(item.getDisplayName())) {
                    resultMap.put("value1", ObjectUtils.isEmpty(item.getValueF()) ? "0.0" : String.format("%.1f", Double.parseDouble(item.getValueF().toString())));
                } else if ("油面温2".equals(item.getDisplayName())) {
                    resultMap.put("value2", ObjectUtils.isEmpty(item.getValueF()) ? "0.0" : String.format("%.1f", Double.parseDouble(item.getValueF().toString())));
                } else if ("绕组温度".equals(item.getDisplayName())) {
                    resultMap.put("value3", ObjectUtils.isEmpty(item.getValueF()) ? "0.0" : String.format("%.1f", Double.parseDouble(item.getValueF().toString())));
                }
            });

            // 主线路图上各个路线名称
            resultMap.put("xyx", "夏雩线");
            resultMap.put("zbgy", "1主变高压侧");
            resultMap.put("220mpt", "220kVⅠ母PT");
            resultMap.put("jd1", "集电Ⅰ线");
            resultMap.put("jd2", "集电Ⅱ线");
            resultMap.put("jd3", "集电Ⅲ线");
            resultMap.put("jd4", "集电Ⅳ线");
            resultMap.put("zbdy", "1主变低压侧");
            resultMap.put("dy1", "待用Ⅰ线");
            resultMap.put("35mpt", "35kVⅠ母PT");
            resultMap.put("1jdb", "1接地变");
            resultMap.put("1svg", "1SVG");
            resultMap.put("2svg", "2SVG");

            resultMap.put("xzsvg", "夏造 SVG");
            resultMap.put("xzaggavc", "夏造 AGGAVC");
            resultMap.put("xzgyxh", "夏造 公用信号");
            resultMap.put("xzjzlp", "夏造 交直流屏");

            //下方重复列表数据
            List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getMajorBoosterStationInfo(gatewayId, "ASC", 10);
            ArrayList<Map<String, String>> resultList = new ArrayList<>();
            List<String> boosterDisplayNameList = Arrays.asList("Ia", "P", "Q");
            for (Map<String, String> map : boosterStationInfo) {
                List<ESEquipments> listData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getFrontModule().contains(map.get("boosterName")) && boosterDisplayNameList.contains(esEquipments.getDisplayName())).collect(Collectors.toList());
                HashMap<String, String> stringStringHashMap = new HashMap<>();
                stringStringHashMap.put("value1", "0.0");
                stringStringHashMap.put("value2", "0.0");
                stringStringHashMap.put("value3", "0.0");
                listData.forEach(item -> {
                    if (item.getDisplayName().equals("Ia")) {
                        stringStringHashMap.put("value1", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
                    }
                    if (item.getDisplayName().equals("P")) {
                        stringStringHashMap.put("value2", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
                    }
                    if (item.getDisplayName().equals("Q")) {
                        stringStringHashMap.put("value3", item.getValueF() == null ? "0" : keepTwoDecimalPlaces(item.getValueF().toString()));
                    }
                });
                resultList.add(stringStringHashMap);
            }
            resultMap.put("records", resultList);
            resultMap.put("current", 1);
            resultMap.put("size", resultList.size());

            // 开关信息
            Map<String, Object> switchUrl = getSwitchUrl(gatewayId, null);
            resultMap.putAll(switchUrl);

            List<Map<String, Object>> finallyResultList = Collections.singletonList(resultMap);
            // 主屏下方重复列表数据
            IPage<Map<String, Object>> resultPage = new Page<>();
            resultPage.setRecords(finallyResultList);
            resultPage.setCurrent(1);
            resultPage.setTotal(finallyResultList.size());
            try {
                log.info("消息内容：{}", JSON.toJSONString(resultPage));
                emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, "major", "data"), JSON.toJSONString(resultPage).getBytes(), 0, false);
            } catch (MqttException e) {
                log.info("消息发送失败");
                e.printStackTrace();
            }
        }
    }


    public void getMajorAnalogQuantityByPageByTHGF(String gatewayId, String stationId) {
        if (StringUtils.isNotEmpty(gatewayId)) {
            Map<String, List<String>> queryCondition = new HashMap<>();
            queryCondition.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
            queryCondition.put(CommonConstans.QueryStringSystemTypeKeyword, Arrays.asList("模拟量"));
            List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondition, null, ESEquipments.class);
            // 10kVⅡ段母线数据
            List<ESEquipments> xianData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getFrontModule().contains("35kVⅠ母PT")).collect(Collectors.toList());
            HashMap<String, Object> resultMap = new HashMap<>();
            xianData.forEach(item -> resultMap.put(item.getDisplayName(), keepTwoDecimalPlaces(item.getValueF().toString())));

            List<String> xyxDisplayNameList = Arrays.asList("Ia", "P", "Q");
            List<ESEquipments> xyxSqlData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getFrontModule().equals("35kV前万线") && xyxDisplayNameList.contains(esEquipments.getDisplayName())).collect(Collectors.toList());
            xyxSqlData.forEach(item -> resultMap.put("35qwx" + item.getDisplayName(), keepTwoDecimalPlaces(item.getValueF().toString())));

            // 主线路图上各个路线名称
            resultMap.put("35qwx", "35kV前万线");
            resultMap.put("35qg1x", "35kV前光Ⅰ线");
            resultMap.put("35qg2x", "35kV前光Ⅱ线");
            resultMap.put("1svg", "1SVG");
            resultMap.put("1zyb", "1站用变");
            resultMap.put("35mxpt", "35kV母线PT");

            resultMap.put("thsvg", "泰和SVG");
            resultMap.put("thglyc", "泰和功率预测");
            resultMap.put("thgyxh", "泰和公用信号");
            resultMap.put("thjzlp", "泰和交直流屏");

            //下方重复列表数据
            List<Map<String, String>> boosterStationInfo = monitorFanIndicatorregionMapper.getMajorBoosterStationInfo(gatewayId, "ASC", 5);
            ArrayList<Map<String, String>> resultList = new ArrayList<>();
            for (Map<String, String> map : boosterStationInfo) {
                if (map.get("boosterName").equals("35kVⅠ母PT")) {
                    continue;
                }
                List<ESEquipments> listData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getFrontModule().contains(map.get("boosterName")) && xyxDisplayNameList.contains(esEquipments.getDisplayName())).collect(Collectors.toList());
                HashMap<String, String> stringStringHashMap = new HashMap<>();
                stringStringHashMap.put("value1", "0.0");
                stringStringHashMap.put("value2", "0.0");
                stringStringHashMap.put("value3", "0.0");
                listData.forEach(item -> {
                    if (item.getDisplayName().equals("Ia")) {
                        stringStringHashMap.put("value1", keepTwoDecimalPlaces(item.getValueF().toString()));
                    }
                    if (item.getDisplayName().equals("P")) {
                        stringStringHashMap.put("value2", keepTwoDecimalPlaces(item.getValueF().toString()));
                    }
                    if (item.getDisplayName().equals("Q")) {
                        stringStringHashMap.put("value3", keepTwoDecimalPlaces(item.getValueF().toString()));
                    }
                });
                resultList.add(stringStringHashMap);
            }
            resultMap.put("records", resultList);
            resultMap.put("current", 1);
            resultMap.put("size", resultList.size());

            // 开关信息
            Map<String, Object> switchUrl = getSwitchUrl(gatewayId, null);
            resultMap.putAll(switchUrl);

            List<Map<String, Object>> finallyResultList = Collections.singletonList(resultMap);
            // 主屏下方重复列表数据
            IPage<Map<String, Object>> resultPage = new Page<>();
            resultPage.setRecords(finallyResultList);
            resultPage.setCurrent(1);
            resultPage.setTotal(finallyResultList.size());
            try {
                log.info("消息内容：{}", JSON.toJSONString(resultPage));
                emqKeeper.getMqttClient().publish(String.format("%s/%s/%s", stationId, "major", "data"), JSON.toJSONString(resultPage).getBytes(), 0, false);
            } catch (MqttException e) {
                log.info("消息发送失败");
                e.printStackTrace();
            }
        }
    }


    public void getSwitchUrlAll(StationBasic stationBasic) {
        String gatewayId = stationBasic.getBoosterGatewayId();
        Map<String, List<String>> queryCodtion = new HashMap<>();
        queryCodtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCodtion.put(CommonConstans.QueryStringSystemType, Arrays.asList("开关"));
        Map<String, String> shouldqueryCodtion = new HashMap<>();
        shouldqueryCodtion.put(CommonConstans.QueryStringDisplayName, "合位");
        List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCodtion, shouldqueryCodtion, ESEquipments.class);
        Set<String> names = new HashSet<>();

        for (ESEquipments listDatum : listData) {
            names.add(listDatum.getFrontModule());
        }

        for (String name : names) {
            getSwitchUrl(gatewayId, name);
        }

    }


    public Map<String, Object> getSwitchUrl(String gatewayId, String equipName) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringSystemTypeKeyword, "开关");
        List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class, likeMap);
        List<ESEquipments> listData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getDisplayName().contains("合位")).collect(Collectors.toList());
        List<ESEquipments> listDatas = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getDisplayName().contains("远方就地开关")).collect(Collectors.toList());
        List<ESEquipments> listDatass = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getDisplayName().contains("接地刀位置")).collect(Collectors.toList());
        if (StringUtils.isNotEmpty(equipName)) {
            listData = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getDisplayName().contains("合位") && esEquipments.getFrontModule().equals(equipName)).collect(Collectors.toList());
            listDatas = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getDisplayName().contains("远方就地开关") && esEquipments.getFrontModule().equals(equipName)).collect(Collectors.toList());
            listDatass = esEquipmentsList.stream().filter(esEquipments -> esEquipments.getDisplayName().contains("接地刀位置") && esEquipments.getFrontModule().equals(equipName)).collect(Collectors.toList());
        }
        Map<String, Object> photoUrls = new HashMap<>();

        for (ESEquipments datass : listDatass) {
            String url = "";
            String[] urls = datass.getPictureName().split(",");
            if (datass.getValue().equals("false")) {
                url = pictureUrl + urls[0];
            } else {
                url = pictureUrl + urls[1];
                ;
            }
            photoUrls.put(datass.getDisplayName().split("_")[0] + "jddwz", url);
        }

        for (ESEquipments data : listDatas) {
            String url = "";
            String[] urls = data.getPictureName().split(",");
            if (StringUtils.isNotEmpty(data.getValue()) && data.getValue().equals("false")) {
                url = pictureUrl + urls[1];
            } else {
                url = pictureUrl + urls[0];
            }
            if (data.getDisplayName().split("_").length > 2) {
                photoUrls.put(KGName.getCode(data.getDisplayName().split("_")[1]), url);
            } else {
                photoUrls.put(data.getDisplayName().split("_")[0] + "yfjdkgurl", url);
            }
        }

        for (ESEquipments listDatum : listData) {
            String url = "";
            if (listDatum.getDisplayName().contains("手车工作位置")) {
                String[] split = listDatum.getPictureName().split(":");
                if (listDatum.getValue().equals("false")) {
                    String[] split1 = split[0].split(",");
                    photoUrls.put(listDatum.getDisplayName().split("_")[0] + "scsurl", pictureUrl + split1[0]);
                    photoUrls.put(listDatum.getDisplayName().split("_")[0] + "scxurl", pictureUrl + split1[1]);
                } else {
                    String[] split1 = split[1].split(",");
                    photoUrls.put(listDatum.getDisplayName().split("_")[0] + "scsurl", pictureUrl + split1[0]);
                    photoUrls.put(listDatum.getDisplayName().split("_")[0] + "scxurl", pictureUrl + split1[1]);
                }
            } else {
                if (listDatum.getValue().equals("false")) {
                    url = pictureUrl + listDatum.getPictureName();
                } else {
                    url = pictureUrl + listDatum.getPictureName().replace("green", "red");
                }
                photoUrls.put(listDatum.getDisplayName().split("_")[0] + "url", url);
            }
        }
        return photoUrls;

    }


    public HashMap<String, Object> getyw(String gatewayId) {
        HashMap<String, Object> resultMap = new HashMap<>();
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion.put(CommonConstans.QueryStringFrontMoudle, Arrays.asList("1主变"));
        queryCondtion.put(CommonConstans.QueryStringSystemType, Arrays.asList("模拟量"));
        List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        // TODO: 2023/7/14 数据未整理  --->  油面温1   油面温2   绕组温度
        resultMap.put("value1", "0.0");
        resultMap.put("value2", "0.0");
        resultMap.put("value3", "0.0");
        resultMap.put("value4", "0.0");
        esEquipmentsList.forEach(item -> {
            if ("档位".equals(item.getDisplayName())) {
                resultMap.put("value4", item.getValue());
            } else if ("油面温1".equals(item.getDisplayName())) {
                resultMap.put("value1", item.getValue());
            } else if ("油面温2".equals(item.getDisplayName())) {
                resultMap.put("value2", item.getValue());
            } else if ("绕组温度".equals(item.getDisplayName())) {
                resultMap.put("value3", item.getValue());
            }
        });
        return resultMap;
    }


    public HashMap<String, Object> getEquipInfoByEquipNum(String gatewayId, String equipmentNumber) {
        HashMap<String, Object> resultMap = new HashMap<>();
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion.put(CommonConstans.QueryStringEquipmentNumberKeyword, Arrays.asList(equipmentNumber));
        List<ESEquipments> list = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class).subList(0, 1);
        if (!ValidationUtil.isEmpty(list)) {
//            resultMap.put("equipmentSpecificName", list.get(0).getEquipmentSpecificName());
//            resultMap.put("equipmentIndexName", list.get(0).getEquipmentSpecificName());
            //箱变名称与箱变型号去掉区域
            String type = "光伏阵区系统";
            String queryEquipNum = "";
            if (equipmentNumber.contains("-")) {
                String[] equipNames = equipmentNumber.split("-");
                if (equipNames.length > 2) {
                    type = "汇流箱系统";
                    queryEquipNum = equipNames[0] + equipNames[1] + Integer.parseInt(equipNames[2]);
                } else {
                    type = "光伏逆变器系统";
                    queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("待机", "故障停机", "告警运行", "限额运行", "停机", "通讯故障", "降额运行", "运行"));
                    queryCondtion.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("true"));
                    List<ESEquipments> list1 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
                    resultMap.put("status", AlarmDesc.getCode(list1.get(0).getEquipmentIndexName()));
                    queryEquipNum = "#" + Integer.parseInt(equipNames[0]);
                }
            } else {
                queryEquipNum = "#" + Integer.parseInt(equipmentNumber) + "";
            }
            queryEquipNum = queryEquipNum + type;

            LambdaQueryWrapper<SjglZsjZsbtz> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.like(SjglZsjZsbtz::getSbmc, queryEquipNum);
            SjglZsjZsbtz sjglZsjZsbtz = sjglZsjZsbtzMapper.selectOne(queryWrapper);

            resultMap.put("equipmentSpecificName", list.get(0).getEquipmentSpecificName().split("区域/")[1]);
            resultMap.put("equipmentIndexName", null == sjglZsjZsbtz.getGgxh() ? "" : sjglZsjZsbtz.getGgxh());
            resultMap.put("equipmentInfoName", list.get(0).getEquipmentSpecificName().substring(5).replace("/", " "));
        }
        return resultMap;
    }

    public Map<String, Object> getStatisticsInfo(String equipmentIndexName, String stationId) {
        StationCacheInfoDto stationCacheInfoDto = commonServiceImpl.getStationCacheInfoDtoByStationId(stationId);
        String gatewayId = stationCacheInfoDto.getFanGatewayId();
        if (!"FDZ".equals(stationCacheInfoDto.getStationType())) {
            gatewayId = stationCacheInfoDto.getBoosterGatewayId();
        }
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值", "南瑞光差保护_313P"));
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
        List<ESEquipments> listData = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        String load = String.format(CommonConstans.Twodecimalplaces, Double.parseDouble(String.valueOf(listData.get(0).getValueF())) / Double.parseDouble(stationCacheInfoDto.getInstalledCapacity()));


        List<Map<String, Object>> list = temporaryDataMapper.timingTemporarysSorageDataByIndexName(gatewayId, equipmentIndexName);
        Map<String, Object> map = new HashMap<>();
        List<String> values = new ArrayList<>();
        Set<String> time = new TreeSet<>();
        String v = null == list ? "" : list.get(0).get("value").toString();
        double min = Double.parseDouble(v);
        double max = Double.parseDouble(v);
        double mean = 0.0;
        String minTime = null == list ? "" : list.get(0).get("createdTime").toString();
        String maxTime = null == list ? "" : list.get(0).get("createdTime").toString();

        for (Map<String, Object> stringStringMap : list) {
            double value = Double.parseDouble(stringStringMap.get("value").toString());
            values.add(String.format("%.2f", value));
            if (value < min) {
                min = value;
                minTime = stringStringMap.get("createdTime").toString();
            } else if (value > max) {
                max = value;
                maxTime = stringStringMap.get("createdTime").toString();
            }
            time.add(stringStringMap.get("createdTime").toString());

        }

        for (String value : values) {
            mean += Double.parseDouble(value);
        }
        mean = Double.parseDouble(String.format(CommonConstans.Twodecimalplaces, mean / values.size()));
        max = Double.parseDouble(String.format(CommonConstans.Twodecimalplaces, max));
        min = Double.parseDouble(String.format(CommonConstans.Twodecimalplaces, min));

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

        map.put("mean", mean);
        map.put("max", max);
        map.put("min", min);
        map.put("maxTime", maxTime);
        map.put("minTime", minTime);
        map.put("load", load);

        return map;

    }


    public List<Map<String, Object>> getEquipmentNum(String gatewayId, String frontModule, String equipmentNumber) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion.put(CommonConstans.QueryStringFrontMoudle, Arrays.asList(frontModule));
        List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        List<ESEquipments> listData = esEquipmentsList.stream().filter(esEquipments -> !esEquipments.getEquipmentNumber().equals("")).sorted(Comparator.comparing(ESEquipments::getEquipmentNumber)).collect(Collectors.toList());
        if (null != equipmentNumber) {
            listData = esEquipmentsList.stream().filter(esEquipments -> !esEquipments.getEquipmentNumber().contains(equipmentNumber)).collect(Collectors.toList());
        }
        return listData.stream().map(item -> {
            HashMap<String, Object> map = new HashMap<>();
            map.put("equipmentNumber", item.getEquipmentNumber());
            map.put("equipmentSpecificName", item.getEquipmentSpecificName().substring(5).replace("/", " "));
            return map;
        }).distinct().collect(Collectors.toList());
    }

    public String keepTwoDecimalPlaces(String value) {
        String s = "0.00";
        if (!ObjectUtils.isEmpty(value)) {
            try {
                s = String.format(CommonConstans.Twodecimalplaces, Double.parseDouble(value));
            } catch (Exception ex) {

            }
        }
        return s;
    }
    public String keepFourDecimalPlaces(String value) {
        String s = "0.0000";
        if (!ObjectUtils.isEmpty(value)) {
            try {
                s = String.format(CommonConstans.Fourdecimalplaces, Double.parseDouble(value));
            } catch (Exception ex) {

            }
        }
        return s;
    }
    public HashMap<String, Object> SpeedIndicator(String gatewayId, String equipmentNumber, String equipmentIndexName) {
        HashMap<String, Object> resultMap = new HashMap<>();
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion.put(CommonConstans.QueryStringEquipmentNumberKeyword, Arrays.asList(equipmentNumber));
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList(equipmentIndexName));
        List<ESEquipments> list = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        if (!ValidationUtil.isEmpty(list)) {
            resultMap.put("value", String.format(CommonConstans.Twodecimalplaces, Double.parseDouble(list.get(0).getValueF().toString())));
        }
        return resultMap;
    }


    public void getEquipSwitchStatus(StationBasic stationBasic) {
        String gatewayId = stationBasic.getFanGatewayId();
        Long stationId = stationBasic.getSequenceNbr();
        Map<String, List<String>> queryConditon = new HashMap<>();
        queryConditon.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> shouldConditon = new HashMap<>();
        shouldConditon.put(CommonConstans.QueryStringEquipmentIndexName, "合闸");
        List<ESEquipments> list = commonServiceImpl.getListDataByCondtions(queryConditon, null, ESEquipments.class, shouldConditon);
        if (!ValidationUtil.isEmpty(list)) {
            Map<String, List<ESEquipments>> collect = list.stream().filter(e -> StringUtils.isNotBlank(e.getEquipmentNumber())).collect(Collectors.groupingBy(ESEquipments::getEquipmentNumber));
            for (String s : collect.keySet()) {
                HashMap<String, Object> resultMap = new HashMap<>();
                collect.get(s).stream().forEach(e -> {
                    String picturl = "";
                    if (e.getValue().equals("false")) {
                        picturl = pictureUrl + "dlg-h-red.png";
                    } else {
                        picturl = pictureUrl + "dlg-h-green.png";
                    }
                    if (e.getEquipmentIndexName().endsWith("断路器合闸")) {
                        resultMap.put(e.getEquipmentIndexName().substring(0, 3), picturl);
                    } else {
                        resultMap.put("gy", picturl);
                    }
                });
                IPage<Map<String, Object>> result = new Page<>();
                List<Map<String, Object>> data = new ArrayList<>();
                data.add(resultMap);
                result.setRecords(data);
                result.setCurrent(1);
                result.setTotal(100);
                try {
                    emqKeeper.getMqttClient().publish(stationId + "/xbjg/" + s, JSON.toJSONString(result).getBytes(), 0, false);
                } catch (MqttException e) {
                    e.printStackTrace();
                }

            }
        }

    }


    public ResultsData collectingBox(String gatewayId, int current, int size) {

        ArrayList<Map<String, Object>> resultList = new ArrayList<>();
        Map<String, List<String>> queryConditon = new HashMap<>();
        queryConditon.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringEquipmentIndexNameNotKeyword, "路电流");
        List<ESEquipments> list = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null, ESEquipments.class, likeMap);

        Map<String, List<String>> queryConditon1 = new HashMap<>();
        queryConditon1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> likeMap1 = new HashMap<>();
        likeMap1.put(CommonConstans.QueryStringEquipmentIndexNameNotKeyword, "平均电流");
        List<ESEquipments> list1 = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null, ESEquipments.class, likeMap1);

        if (!ValidationUtil.isEmpty(list)) {
            Map<String, List<ESEquipments>> collect = list.stream().collect(Collectors.groupingBy(ESEquipments::getEquipmentNumber));
            for (String s : collect.keySet()) {
                List<ESEquipments> indicatorsDtos = collect.get(s);
                HashMap<String, Object> resultMap = new HashMap<>();
                Double avageValue = 0.0;
                avageValue = indicatorsDtos.stream().filter(e -> !ObjectUtils.isEmpty(e.getValueF())).mapToDouble(l -> Double.parseDouble(l.getValueF().toString())).average().getAsDouble();
                avageValue = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, avageValue));
                resultMap.put("avg", avageValue);
                String[] name = s.split("-");
                resultMap.put("zz", "#" + name[0] + "子阵");
                resultMap.put("nbq", "逆变器" + name[1]);
                resultMap.put("hlx", "#" + name[2] + "汇流箱");
                double lsv = 0.00;
                if (!ValidationUtil.isEmpty(list1)) {
                    List<ESEquipments> dtos = list1.stream().filter(e -> e.getEquipmentNumber().equals(s)).collect(Collectors.toList());
                    if (!ValidationUtil.isEmpty(dtos)) {
                        for (ESEquipments esEquipments : indicatorsDtos) {
                            lsv = lsv + Math.pow(esEquipments.getValueF() - dtos.get(0).getValueF(), 2);
                        }
                    }
                    lsv = Math.sqrt(lsv) / dtos.get(0).getValueF();
                }


                resultMap.put("lsv", String.format(CommonConstans.Twodecimalplaces, lsv));
                resultList.add(resultMap);
            }
        }
        //构建平台数据
        DataGridMock DataGridMock = new DataGridMock(current, resultList.size(), false, current, resultList);
        ColModel colModelEventMovement = new ColModel("zz", "zz", "子阵", "子阵", "dataGrid", "zz");
        ColModel colModelStationName = new ColModel("nbq", "nbq", "逆变器", "逆变器", "dataGrid", "nvq");
        ColModel colModelEventDesc = new ColModel("hlx", "hlx", "汇流箱", "汇流箱", "dataGrid", "hlx");
        ColModel colModelAlarmGroupName = new ColModel("avg", "avg", "支路电流平均值", "支路电流平均值", "dataGrid", "avg");
        ColModel colModelEventTime = new ColModel("lsl", "lsv", "支路电流离散率", "支路电流离散率", "dataGrid", "lsv");
        List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelEventDesc, colModelAlarmGroupName, colModelEventTime);
        ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
        return resultsData;
    }


    public List<Map<String, Object>> solarPowerOperation(String gatewayId) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("有功功率", "逆变器效率", "总直流功率", "日发电量", "总发电量"));
        List<ESEquipments> list = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
        List<ESEquipments> collect = list.stream().filter(e -> StringUtils.isNotEmpty(e.getEquipmentNumber())).collect(Collectors.toList());
        Map<String, List<ESEquipments>> collects = collect.stream().collect(Collectors.groupingBy(ESEquipments::getEquipmentNumber));
        List<Map<String, Object>> result = new ArrayList();
        for (String s : collects.keySet()) {
            List<ESEquipments> indicatorsDtos = collects.get(s);
            Map<String, Object> map = new HashMap<>();
            map.put("name", s);
            map.put("sort", s.split("-")[0]);
            map.put("type", "兆能");//此处暂时未提供数据 待定 暂写死值
            map.put("status", "1");//此处暂时未提供数据 待定 暂写死值
            indicatorsDtos.forEach(e -> {
                switch (e.getEquipmentIndexName()) {
                    case "总直流功率":
                        map.put("sr", keepTwoDecimalPlaces(e.getValueF().toString()));
                        break;
                    case "有功功率":
                        map.put("sc", keepTwoDecimalPlaces(e.getValueF().toString()));
                        break;
                    case "逆变器效率":
                        map.put("efficiency", keepTwoDecimalPlaces(e.getValueF().toString()));
                        break;
                    case "日发电量":
                        double v = Double.parseDouble(e.getValueF().toString()) * CommonConstans.pvGenPoweActor;
                        map.put("dayNum", keepFourDecimalPlaces(String.valueOf(v)));
                        break;
                    case "总发电量":
                        double a = Double.parseDouble(e.getValueF().toString()) * CommonConstans.pvGenPoweActorCurrentData;
                        map.put("yearNum", keepFourDecimalPlaces(String.valueOf(a)));
                        break;
                }
            });
            result.add(map);
        }
        return result;
    }

    public Map<String, Object> hlWindSpeeds(String gatewayId, String equipNum) {
        Date currentDayStartTime = DateUtils.getCurrentDayStartTime(new Date());
        Date currentDayEndTime = DateUtils.getCurrentDayEndTime(new Date());
        String startTime = DateUtils.convertDateToString(currentDayStartTime, DateUtils.DATE_TIME_PATTERN);
        String endTime = DateUtils.convertDateToString(currentDayEndTime, DateUtils.DATE_TIME_PATTERN);
        List<IndicatorData> originarPVs = indicatorDataMapper.selectDataByequipmentIndexNameAndtimeAndEquipmentNumberPv(equipNum, startTime, endTime, gatewayId);
        originarPVs.size();
        Map<String, Object> resultMap = new HashMap<>();
        Map<String, List<IndicatorData>> data = originarPVs.stream().collect(Collectors.groupingBy(IndicatorData::getEquipmentIndexName, TreeMap::new, Collectors.toList()));
        List<String> axisData = new ArrayList<>();
        List<Map<String, Object>> seriesData = new ArrayList<>();
        for (String s : data.keySet()) {
            Map<String, Object> map = new HashMap<>();
            List<String> value = data.get(s).stream().map(IndicatorData::getValue).collect(Collectors.toList());
            axisData = data.get(s).stream().map(indicatorData -> DateUtil.format(indicatorData.getCreatedTime(), "HH:mm")).collect(Collectors.toList());
            map.put("data", value);
            seriesData.add(map);
        }
        resultMap.put("axisData", axisData);
        resultMap.put("seriesData", seriesData);
        return resultMap;
    }


    public void getListByNbq(String gatewayId, String werks, String stationId) {
        HashMap<String, String> equipStatesMap = getPvNBQStationBy(gatewayId);
        ArrayList<Map<String, Object>> resultList = new ArrayList<>();
        Map<String, List<String>> queryConditon = new HashMap<>();
        queryConditon.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("总直流功率"));
        queryConditon.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "逆变器");
        List<ESEquipments> listData = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null, ESEquipments.class, likeMap);

        Map<String, List<String>> queryConditon1 = new HashMap<>();
        queryConditon1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("有功功率"));
        queryConditon1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> likeMap1 = new HashMap<>();
        likeMap1.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "逆变器");
        List<ESEquipments> listData1 = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon1, null, ESEquipments.class, likeMap1);

        // 将两组数据合并成一个集合中 将总直流功率数据 放入 另一个集合的valueLable中
        for (ESEquipments listDatum : listData) {
            for (ESEquipments esEquipments : listData1) {
                if (esEquipments.getEquipmentNumber().equals(listDatum.getEquipmentNumber())) {
                    esEquipments.setValueLabel(listDatum.getValueF().toString());
                }
            }
        }
        List<Map<String, String>> maps = new ArrayList<>();
        Set<String> nums = new HashSet<>();
        //此处组装数据 每一个Map代表一个逆变器
        for (ESEquipments esEquipments : listData1) {
            int num = Integer.parseInt(esEquipments.getEquipmentNumber().substring(0, 2));
            nums.add(String.valueOf(num));
            Map<String, String> map = new HashMap<>();
            String equipNum = esEquipments.getEquipmentNumber();
            String number = equipNum.substring(equipNum.length() - 1);
            map.put("titie", String.valueOf(num));
            map.put("titie" + number, equipNum);
            map.put("value" + number, String.format(CommonConstans.Twodecimalplaces, esEquipments.getValueF()));
            map.put("valueLabel" + number, String.format(CommonConstans.Twodecimalplaces, Double.parseDouble(esEquipments.getValueLabel())));
            map.put("state" + number, equipStatesMap.get(esEquipments.getEquipmentNumber()));
            maps.add(map);
        }
        List<Map<String, Object>> dataMaps = sjglZsjZsbtzServiceImpl.sjglZsjZsbtzMapper.getStationInfoMapByStationGFWerks(werks, "集电线");
        int i = 0;
        //逆变器需要根据所属集电线分类组装 下面循环是将同一子阵下的不同逆变器组装为消息数据
        for (Map<String, Object> dataMap : dataMaps) {
            List<Map<String, String>> statusMaps = new ArrayList<>();
            String equipNum = dataMap.get("equipNum").toString();
            for (String num : nums) {
                int intNum = Integer.parseInt(num);
                Map<String, String> map = new HashMap<>();
                map.put("titie", "#" + num);
                for (Map<String, String> stringMap : maps) {
                    if (stringMap.get("titie").equals(num)) {
                        map.putAll(stringMap);
                    }
                }
                List<String> list = Arrays.asList(equipNum.split(","));

                list.forEach(e -> {
                    if (Integer.parseInt(e) == intNum) {
                        statusMaps.add(map);
                    }

                });
            }
            IPage<Map<String, String>> result = new Page<>();
            result.setRecords(statusMaps);
            result.setCurrent(1);
            result.setTotal(statusMaps.size());
            i += 1;
            try {
                emqKeeper.getMqttClient().publish(stationId + "/gf/group/" + i, JSON.toJSONString(result).getBytes(), 0, false);
            } catch (MqttException e) {
                log.info("消息发送失败");
                e.printStackTrace();
            }
        }

    }


    @Override
    public Map<String, Object> partofWaring3D(String stationId, String equipNum) {
        Map<String, Object> resultMap = new HashMap<>();
        StationBasic stationBasic = stationBasicMapper.selectById(stationId);
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
        queryCondtion.put(CommonConstans.QueryStringEquipmentNumber, Arrays.asList(equipNum));
        Map<String, String> shouldCondtion = new HashMap<>();
        shouldCondtion.put(CommonConstans.QueryStringEquipmentIndexName, "实时故障");
        List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldCondtion, ESEquipments.class);
        //获取风机型号
        String type = indicatorsDtoList.get(0).getEquipmentSpecificName().substring(0, 5);
        List<String> sytemNames = Arrays.asList("发电机系统", "机舱与塔筒系统", "变流与主控系统", "偏航与液压系统", "叶轮系统");
        List<SystemEnum> systemEnumListAll = systemEnumMapper.selectList(new QueryWrapper<SystemEnum>().isNotNull("system_name"));
        sytemNames.forEach(name -> {
            resultMap.put(name, false);
            List<SystemEnum> systemEnumList = systemEnumListAll.stream().filter(systemEnum -> systemEnum.getSyetemName().equals(name)).collect(Collectors.toList());
            outer:
            for (SystemEnum systemEnum : systemEnumList) {
                for (ESEquipments indicatorsDto : indicatorsDtoList) {
                    if (indicatorsDto.getEquipmentSpecificName().contains(systemEnum.getCode()) && indicatorsDto.getValue().equals(systemEnum.getEunmValue())) {
                        resultMap.put(name, true);
                        break outer;
                    }
                }
            }
        });
        return resultMap;
    }


    public Page<Map<String, Object>> nbqStatus(String gatewayId) {
        Map<String, List<String>> queryCondtion = new HashMap<>();
        queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行"));
        queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> likeMap = new HashMap<>();
        likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "逆变器");
        List<ESEquipments> result = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);
        // 逆变器总数量
        Integer totalNumber = result.size();
        List<String> zcEquipmentNumberList = result.stream().filter(t -> "true".equals(t.getValue())).map(ESEquipments::getEquipmentNumber).collect(Collectors.toList());
        Map<String, List<String>> queryCondtion1 = new HashMap<>();
        queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("待机", "故障停机", "告警运行", "限额运行", "停机", "通讯故障", "降额运行"));
        queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        queryCondtion1.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("true"));
        Map<String, String> likeMap1 = new HashMap<>();
        likeMap1.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "逆变器");
        List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion1, null, ESEquipments.class, likeMap1);
        List<String> equipmentNumberList = result1.stream().map(ESEquipments::getEquipmentNumber).distinct().collect(Collectors.toList());
        int djNum = 0;
        int gzNum = 0;
        int gjNum = 0;
        int xeNum = 0;
        int xdNum = 0;
        int txNum = 0;
        int tjNum = 0;
        int zcNum = 0;
        Set<String> equipNum = new HashSet<>();
        for (ESEquipments esEquipments : result1) {
            if (equipmentNumberList.contains(esEquipments.getEquipmentNumber()) && !zcEquipmentNumberList.contains(esEquipments.getEquipmentNumber())) {
                switch (esEquipments.getEquipmentIndexName()) {
                    case "待机":
                        djNum += 1;
                        equipmentNumberList.remove(esEquipments.getEquipmentNumber());
                        break;
                    case "故障停机":
                        gzNum += 1;
                        equipmentNumberList.remove(esEquipments.getEquipmentNumber());
                        break;
                    case "告警运行":
                        gjNum += 1;
                        equipmentNumberList.remove(esEquipments.getEquipmentNumber());
                        break;
                    case "限额运行":
                        xeNum += 1;
                        equipmentNumberList.remove(esEquipments.getEquipmentNumber());
                        equipNum.add(esEquipments.getEquipmentNumber());
                        break;
                    case "停机":
                        tjNum += 1;
                        equipmentNumberList.remove(esEquipments.getEquipmentNumber());
                        break;
                    case "通讯故障":
                        xdNum += 1;
                        equipmentNumberList.remove(esEquipments.getEquipmentNumber());
                        break;
                    case "降额运行":
                        txNum += 1;
                        equipmentNumberList.remove(esEquipments.getEquipmentNumber());
                        break;
                }
            }
        }
        zcNum = totalNumber - djNum - gzNum - gjNum - xeNum - xdNum - txNum - tjNum;
        Page<Map<String, Object>> mapPage = new Page<>();
        ArrayList<Map<String, Object>> resultList = new ArrayList<>();
        HashMap<String, Object> map = new HashMap<>();
        map.put("count", zcNum);
        map.put("equipmentIndexName", "正常运行");
        map.put("color", "#00AA00");
        resultList.add(map);
        HashMap<String, Object> map2 = new HashMap<>();
        map2.put("count", tjNum);
        map2.put("equipmentIndexName", "正常停机");
        map2.put("color", "#0055FF");
        resultList.add(map2);
        HashMap<String, Object> map3 = new HashMap<>();
        map3.put("count", xeNum);
        map3.put("equipmentIndexName", "限功率");
        map3.put("color", "#A3F5AA");
        resultList.add(map3);
        HashMap<String, Object> map4 = new HashMap<>();
        map4.put("count", xdNum);
        map4.put("equipmentIndexName", "限电停机");
        map4.put("color", "#FF00FF");
        resultList.add(map4);
        HashMap<String, Object> map5 = new HashMap<>();
        map5.put("count", gjNum);
        map5.put("equipmentIndexName", "告警运行");
        map5.put("color", "#F9AD14");
        resultList.add(map5);
        HashMap<String, Object> map6 = new HashMap<>();
        map6.put("count", gzNum);
        map6.put("equipmentIndexName", "故障停机");
        map6.put("color", "#00AAFF");
        resultList.add(map6);
        HashMap<String, Object> map7 = new HashMap<>();
        map7.put("count", djNum);
        map7.put("equipmentIndexName", "待机");
        map7.put("color", "#F91414");
        resultList.add(map7);
        HashMap<String, Object> map8 = new HashMap<>();
        map8.put("count", txNum);
        map8.put("equipmentIndexName", "通讯中断");
        map8.put("color", "#7D8E95");
        resultList.add(map8);
        mapPage.setTotal(8);
        mapPage.setSize(8);
        mapPage.setCurrent(1);
        mapPage.setRecords(resultList);
        return mapPage;
    }


    public void sendMqttByRanking(List<Map<String, Object>> list, String code, String topic) {
        list.stream().sorted((o1, o2) -> {
            double o1Num = Double.parseDouble(o1.get("value").toString());
            double o2Num = Double.parseDouble(o2.get("value").toString());
            if ((o1Num - o2Num) < 0) {
                return -1;
            } else if ((o1Num - o2Num) > 0) {
                return 1;
            } else {
                return 0;
            }
        });

        IPage<Map<String, Object>> result = new Page<>();
        result.setRecords(list);
        result.setCurrent(1);
        result.setTotal(list.size());
        try {
            emqKeeper.getMqttClient().publish(topic + "/" + code, JSON.toJSONString(result).getBytes(), 0, false);
        } catch (MqttException e) {
            e.printStackTrace();
        }

    }


    public Page<DeaviationRateDto> getDeaviAtionRate(String stationId, String equipNumber) {
        StationCacheInfoDto stationCacheInfoDto = commonServiceImpl.getStationCacheInfoDtoByStationId(stationId);
        Page<DeaviationRateDto> deaviationRateDtoPage = new Page<>(1, 100);
        List<DeaviationRateDto> deaviationRateDtoList = new ArrayList<>();
        Map<String, List<String>> queryCondition = new HashMap<>();
        queryCondition.put(CommonConstans.QueryStringEquipmentNumber, Arrays.asList(equipNumber));
        queryCondition.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
        Map<String, String> shouldCodtion = new HashMap<>();
        shouldCodtion.put(CommonConstans.QueryStringEquipmentIndexName, "路电流");
        List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondition, shouldCodtion, ESEquipments.class);
        Random random = new Random();
        indicatorsDtoList.forEach(esEquipments -> {
            DeaviationRateDto deaviationRateDto = new DeaviationRateDto();
            deaviationRateDto.setName(esEquipments.getEquipmentIndexName());
            deaviationRateDto.setCurrentValue(esEquipments.getValue());
            deaviationRateDto.setOffset(String.valueOf(random.nextDouble()));
            deaviationRateDto.setAttValue(String.valueOf(random.nextDouble()));
            deaviationRateDtoList.add(deaviationRateDto);
        });
        deaviationRateDtoPage.setRecords(deaviationRateDtoList);
        return deaviationRateDtoPage;
    }

    @Scheduled(cron = "0 */5 * * * ?")
    public void addNbqAlarmEvent() {

        LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(BaseEntity::getIsDelete, false);
        List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
        for (StationBasic stationBasic : stationBasics) {
            Map<String, List<String>> queryCondtion = new HashMap<>();
            Map<String, String> shouldCondtion = new HashMap<>();
            queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
            queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("待机", "停机", "告警运行", "限额运行", "降额运行", "故障停机", "通讯故障", "运行"));
            queryCondtion.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("true"));

            /**
             * 逆变器
             */
            List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
            /**
             * 汇流箱
             */
            queryCondtion.remove(CommonConstans.QueryStringEquipmentIndexName);
            queryCondtion.remove(CommonConstans.QueryStringValueKeyword);
            queryCondtion.put(CommonConstans.QueryStringDataType, Arrays.asList("state"));
            shouldCondtion.put(CommonConstans.QueryStringFrontMoudle, "汇流箱");
            List<ESEquipments> indicatorsDtoListHLX = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldCondtion, ESEquipments.class);
            /**
             * 箱变
             */
            shouldCondtion.put(CommonConstans.QueryStringFrontMoudle, "箱变");
            List<ESEquipments> indicatorsDtoListXB = commonServiceImpl.getListDataByCondtions(queryCondtion, shouldCondtion, ESEquipments.class);
            ;
            indicatorsDtoList.addAll(indicatorsDtoListHLX);
           indicatorsDtoList.addAll(indicatorsDtoListXB);

            List<EquipAlarmEvent> newEquipAlarmEvents = new ArrayList<>();
            List<EquipAlarmEvent> newEquipAlarmEvent = new ArrayList<>();
            long time = new Date().getTime();
            if (CollectionUtils.isNotEmpty(indicatorsDtoList)){
                for (ESEquipments esEquipments : indicatorsDtoList) {
                    EquipAlarmEvent equipAlarmEvent = new EquipAlarmEvent();
                    equipAlarmEvent.setEquipIndex(esEquipments.getEquipmentNumber());
                    equipAlarmEvent.setEquipName(esEquipments.getEquipmentSpecificName());
                    equipAlarmEvent.setAlarmDesc(AlarmDesc.getCode(esEquipments.getEquipmentIndexName()));
                    equipAlarmEvent.setAlarmDesc(StringUtils.isEmpty(equipAlarmEvent.getAlarmDesc()) ? esEquipments.getEquipmentIndexName() : equipAlarmEvent.getAlarmDesc());
                    equipAlarmEvent.setCreatedTime(esEquipments.getCreatedTime());
                    equipAlarmEvent.setGatewayId(stationBasic.getFanGatewayId());
                    equipAlarmEvent.setSort(time);
                    equipAlarmEvent.setFrontModule(esEquipments.getFrontModule());
                    equipAlarmEvent.setValue(esEquipments.getValue());
                    newEquipAlarmEvents.add(equipAlarmEvent);
                    newEquipAlarmEvent.add(equipAlarmEvent);
                }
            }


            String lastSort = equipAlarmEventMapper.getLastDataBySort(stationBasic.getFanGatewayId());
            if (null != lastSort) {
                List<EquipAlarmEvent> oldEquipAlarmEvents = equipAlarmEventMapper.getOldDataBySort(lastSort, stationBasic.getFanGatewayId());
                for (EquipAlarmEvent oldEquipAlarmEvent : oldEquipAlarmEvents) {
                    for (EquipAlarmEvent equipAlarmEvent : newEquipAlarmEvents) {
                        if (oldEquipAlarmEvent.getEquipIndex().equals(equipAlarmEvent.getEquipIndex()) &&
                                oldEquipAlarmEvent.getAlarmDesc().equals(equipAlarmEvent.getAlarmDesc()) &&
                                oldEquipAlarmEvent.getValue().equals(equipAlarmEvent.getValue())) {
                            newEquipAlarmEvent.remove(equipAlarmEvent);
                        }
                    }
                }
            }
            equipAlarmEventService.saveBatch(newEquipAlarmEvent);

        }
    }

    public HashMap<String, String> getPvNBQStationBy(String gatewayId) {
        HashMap<String, String> result = new HashMap<>();
        Map<String, List<String>> queryCondition = new HashMap<>();
        queryCondition.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行"));
        queryCondition.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        Map<String, String> shouldCondition = new HashMap<>();
        shouldCondition.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
        List<ESEquipments> totalEquipmentList = commonServiceImpl.getListDataByCondtions(queryCondition, shouldCondition, ESEquipments.class);
        totalEquipmentList.forEach(indicatorsDto -> result.put(indicatorsDto.getEquipmentNumber(), "正常运行"));
        Map<String, List<String>> queryCondition1 = new HashMap<>();
        queryCondition1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行", "待机", "故障停机", "告警运行", "限额运行", "停机", "通讯故障", "'降额运行'"));
        queryCondition1.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("true"));
        queryCondition1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
        List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondition1, shouldCondition, ESEquipments.class);
        indicatorsDtoList.forEach(esEquipments -> {
            if (!"运行".equals(esEquipments.getEquipmentIndexName())) {
                result.put(esEquipments.getEquipmentNumber(), CommonConstans.pvStatus.get(esEquipments.getEquipmentIndexName()));
            }
        });
        return result;
    }
}

