package com.gyee.runeconomy.service.monitor;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.common.contant.ContantXk;
import com.gyee.common.model.PointData;
import com.gyee.common.util.DateUtils;
import com.gyee.runeconomy.dto.PowercurveVo;
import com.gyee.runeconomy.init.CacheContext;
import com.gyee.runeconomy.model.auto.*;
import com.gyee.runeconomy.service.TokenService;
import com.gyee.runeconomy.service.auto.*;
import com.gyee.runeconomy.util.MathUtil;
import com.gyee.runeconomy.util.StringUtils;
import com.gyee.runeconomy.util.realtimesource.IEdosUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class MonitorService {
    private static Logger logger = LoggerFactory.getLogger(MonitorService.class);
    @Resource
    private IProBasicProjectPlanService proBasicProjectPlanService;
    @Resource
    private IProBasicPowerstationPointService proBasicPowerstationPointService;
    @Resource
    private IProBasicEquipmentPointService proBasicEquipmentPointService;
    @Resource
    private MonitorprojectplanService planService;
    @Resource
    private IProEconTargetdataService proEconTargetdataService;
    @Resource
    private IProEconTargetdataFristService proEconTargetdataFristService;

    @Resource
    private IProBasicPowerPointService powerPointService;

    @Resource
    private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;

    private final String QS = "0";
    private final String FD = "-1";
    private final String GF = "-2";

    @Resource
    private IEdosUtil edosUtil;
    Map<String, Object> map = new HashMap<>();
    @Resource
    private TokenService tokenService;

    public Map getcockpit(String wpId) throws Exception {

        if (wpId.endsWith(QS) || wpId.endsWith(FD) || wpId.endsWith(GF) || CacheContext.wpmapls.containsKey(wpId)) {

            List<ProBasicPowerstation> wplist = new ArrayList<>();
            if (CacheContext.wpmapls.containsKey(wpId)) {
                wplist = CacheContext.wpmapls.get(wpId);
            }
            //            HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
            //            List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
            List<ProBasicPowerstation> wplsToken = CacheContext.wpls;

            for (ProBasicPowerstation wp : wplsToken) {
                if (wpId.contains(FD)) {
                    if (wp.getId().endsWith("FDC_STA")) {
                        wplist.add(wp);
                    }
                } else if (wpId.contains(GF)) {
                    if (wp.getId().endsWith("GDC_STA")) {
                        wplist.add(wp);
                    }
                } else if (wpId.contains(QS)) {
                    wplist.add(wp);
                }
            }

            /**********************************************首页各风电场容量、线路、装机容量、风机台数统计**********************************************************/
            //
            //            if (!wpId.isEmpty()) {
            //                for (ProBasicPowerstation wp : CacheContext.wpls) {
            //                    if (wp.getId().equals(wpId)) {
            //                        ProBasicPowerstation station = CacheContext.wpmap.get(wpId);
            //
            //                        String code = station.getId();
            //                        List<ProBasicProject> project = CacheContext.projmap.get(code);
            //                        Map czxx = new LinkedHashMap();
            //                        List<Map> qc = new ArrayList<>();
            //
            //                        int linenum = 0;
            //                        int i = 0;
            //
            //                        czxx.put("zjrl", station.getCapacity());//装机容量
            //                        czxx.put("scbwsj", station.getFirstGridTime());//首次并网时间
            //                        czxx.put("zctysj", station.getWholeGridTime());//整场投运时间
            //                        czxx.put("dlwz", station.getLongitude());
            //                        for (ProBasicProject p : project) {
            //                            Map qcls = new LinkedHashMap();
            //                            i++;
            //                            qcls.put("id", i);
            //                            qcls.put("name", p.getName()); //name
            //                            qcls.put("value", p.getCapacity() / 1000);//value :45
            //                            linenum = linenum + CacheContext.prolinemap.get(p.getId()).size();
            //                            qc.add(qcls);
            //                        }
            //
            //                        czxx.put("linenum", linenum);
            //                        czxx.put("fjts", station.getJrwindQuantityLd());//风机台数
            //                        czxx.put("issue", qc);
            //                        map.put("czxx", czxx);
            //                    }
            //                }
            //            }
            /**********************************************首页各风电场容量、线路、装机容量、风机台数统计**********************************************************/


            /**********************************************首页场站所有风场信息展示统计**********************************************************/


            Map<String, Object> station = new LinkedHashMap<>();
            if (!wplsToken.isEmpty()) {
                for (ProBasicPowerstation wp : wplsToken) {
                    Map<String, Object> xx = new LinkedHashMap<>();
                    String id = wp.getId();
                    if (CacheContext.wpmap.containsKey(id) && id.endsWith("FDC_STA")) {
                        xx.put("name", wp.getName());
                        xx.put("companyid", wp.getCompanyId());
                        xx.put("zjts", Double.valueOf(wp.getJrwindQuantityLd()));
                        xx.put("zjrl", wp.getJrwindCapacity());
                        xx.put("hszjts", wp.getJrwindQuantityHs());
                        double gl = 0.0;
                        ProBasicPowerstationPoint glvalue = proBasicPowerstationPointService.getPowerstationPoint(id, ContantXk.SSZGL);
                        gl = edosUtil.getRealData(glvalue).getPointValueInDouble();
                        xx.put("gl", MathUtil.twoBit(gl));
                    } else if (CacheContext.wpmap.containsKey(id) && id.endsWith("GDC_STA")) {
                        xx.put("name", wp.getName());
                        xx.put("companyid", wp.getCompanyId());
                        xx.put("zczjts", Double.valueOf(wp.getJrquantityZc()));
                        xx.put("jzzjts", Double.valueOf(wp.getJrquantityJz()));
                        xx.put("zjrl", wp.getJrCapacity());
                        double gl = 0.0;
                        ProBasicPowerstationPoint glvalue = proBasicPowerstationPointService.getPowerstationPoint(id, ContantXk.SSZGL);
                        gl = edosUtil.getRealData(glvalue).getPointValueInDouble();
                        xx.put("gl", MathUtil.twoBit(gl));
                    }
                    station.put(id, xx);
                }
            }
            map.put("station", station);

            /**********************************************首页场站所有风场信息展示统计**********************************************************/

            /**********************************************首页穿透线路信息统计**********************************************************/


            //            Map<String, Object> xlmap = new LinkedHashMap<>();
            //
            //            if (!wpls1.isEmpty()) {
            //                double xlgl = 0.0;
            //                double i = 0;
            //                for (ProBasicLine ls : CacheContext.lnls) {
            //                    Map<String, Double> xl = new LinkedHashMap<>();
            //                    String lineid = ls.getId();
            //                    i++;
            //                    ProBasicPowerstationPoint xlglvalue = proBasicPowerstationPointService.getPowerstationPoint(lineid, ContantXk.SSZGL);
            //                    xlgl = edosUtil.getRealData(xlglvalue).getPointValueInDouble();
            //                    xl.put("i", i);
            //                    xl.put("xlgl", MathUtil.twoBit(xlgl));
            //                    xlmap.put(lineid, xl);
            //                }
            //            }
            //            map.put("xlmap", xlmap);


            /**********************************************首页穿透线路信息统计**********************************************************/


            /**********************************************首页明细状态统计**********************************************************/

            //待风
            double fd_dfnum = 0;
            //手动停机
            double fd_sdtjnum = 0;
            //正常发电
            double fd_zcfdnum = 0;
            //降出力运行
            double fd_jclyxnum = 0;
            //限电降出力
            double fd_xdjclnum = 0;
            //限电停机
            double fd_tjnum = 0;
            //故障停机
            double fd_gztjnum = 0;
            //故障场内受累
            double fd_gzcnslnum = 0;
            //检修停机
            double fd_jxtjnum = 0;
            //检修场内受累
            double fd_jxclslnum = 0;
            //受累电网
            double fd_sldwnum = 0;
            //受累环境
            double fd_slhjnum = 0;
            //离线
            double fd_lxnum = 0;
            //未知
            double fd_wznum = 0;

            //待风
            double gf_dfnum = 0;
            //手动停机
            double gf_sdtjnum = 0;
            //正常发电
            double gf_zcfdnum = 0;
            //降出力运行
            double gf_jclyxnum = 0;
            //限电降出力
            double gf_xdjclnum = 0;
            //停机
            double gf_tjnum = 0;
            //故障停机
            double gf_gztjnum = 0;
            //故障场内受累
            double gf_gzcnslnum = 0;
            //检修停机
            double gf_jxtjnum = 0;
            //检修场内受累
            double gf_jxclslnum = 0;
            //受累电网
            double gf_sldwnum = 0;
            //受累环境
            double gf_slhjnum = 0;
            //离线
            double gf_lxnum = 0;
            //未知
            double gf_wznum = 0;

            Map<String, Double> mxztmap = new LinkedHashMap<>();

            if (wpId.endsWith(QS) || wpId.endsWith(FD) || wpId.endsWith(GF)) {

                List<String> fjztls = new ArrayList<>();
                List<String> gfztls = new ArrayList<>();

                String str1 = null;
                if (wpId.endsWith(QS)) {
                    String str = wpId;
                    str1 = str.substring(0, str.indexOf("0")) + "-1";
                } else {
                    str1 = wpId;
                }
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.GZTSMX).getNemCode());    //故障台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.CNSLGZTSMX).getNemCode()); //场内受累故障台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.JXTSMX).getNemCode());    //检修台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.CNSLJXTSMX).getNemCode());//场内受累检修台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.DJTSMX).getNemCode());//待机台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.QXJCLTSMX).getNemCode());//缺陷降出力台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.SDTJTSMX).getNemCode());//手动停机台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.XNTSMX).getNemCode());//性能台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.XDTJTSMX).getNemCode());//限电停机台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.XDJCLTSMX).getNemCode());//限电降出力台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.CWSLDWTSMX).getNemCode());//场外受累电网台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.CWSLTQTSMX).getNemCode());//场外受累天气台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.LXTSMX).getNemCode());//离线台数
                fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(str1, ContantXk.TXZDTSMX).getNemCode());//通讯中断台数
                fjztls = fjztls.stream().filter(a -> a != null).collect(Collectors.toList());
                if (StringUtils.isNotEmpty(fjztls)) {
                    List<PointData> fjztlist = edosUtil.getRealData(fjztls);

                    fd_gztjnum += fjztlist.get(0).getPointValueInDouble();
                    fd_gzcnslnum += fjztlist.get(1).getPointValueInDouble();
                    fd_jxtjnum += fjztlist.get(2).getPointValueInDouble();
                    fd_jxclslnum += fjztlist.get(3).getPointValueInDouble();
                    fd_dfnum += fjztlist.get(4).getPointValueInDouble();
                    fd_jclyxnum += fjztlist.get(5).getPointValueInDouble();
                    fd_sdtjnum += fjztlist.get(6).getPointValueInDouble();
                    fd_zcfdnum += fjztlist.get(7).getPointValueInDouble();
                    fd_tjnum += fjztlist.get(8).getPointValueInDouble();
                    fd_xdjclnum += fjztlist.get(9).getPointValueInDouble();
                    fd_sldwnum += fjztlist.get(10).getPointValueInDouble();
                    fd_slhjnum += fjztlist.get(11).getPointValueInDouble();
                    fd_lxnum += fjztlist.get(12).getPointValueInDouble();
                    fd_wznum += fjztlist.get(13).getPointValueInDouble();
                }
                String str2 = null;
                if (wpId.endsWith(QS)) {
                    String str = wpId;
                    str2 = str.substring(0, str.indexOf("0")) + "-2";
                } else {
                    str2 = wpId;
                }
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.GZTSMX).getNemCode());    //故障台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.CNSLGZTSMX).getNemCode()); //场内受累故障台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.JXTSMX).getNemCode());    //检修台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.CNSLJXTSMX).getNemCode());//场内受累检修台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.DJTSMX).getNemCode());//待机台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.QXJCLTSMX).getNemCode());//缺陷降出力台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.SDTJTSMX).getNemCode());//手动停机台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.XNTSMX).getNemCode());//性能台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.XDTJTSMX).getNemCode());//限电停机台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.XDJCLTSMX).getNemCode());//限电降出力台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.CWSLDWTSMX).getNemCode());//场外受累电网台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.CWSLTQTSMX).getNemCode());//场外受累天气台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.LXTSMX).getNemCode());//离线台数
                gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(str2, ContantXk.TXZDTSMX).getNemCode());//通讯中断台数
                gfztls = gfztls.stream().filter(a -> a != null).collect(Collectors.toList());
                if (StringUtils.isNotEmpty(gfztls)) {
                    List<PointData> gfztlist = edosUtil.getRealData(gfztls);

                    gf_gztjnum += gfztlist.get(0).getPointValueInDouble();
                    gf_gzcnslnum += gfztlist.get(1).getPointValueInDouble();
                    gf_jxtjnum += gfztlist.get(2).getPointValueInDouble();
                    gf_jxclslnum += gfztlist.get(3).getPointValueInDouble();
                    gf_dfnum += gfztlist.get(4).getPointValueInDouble();
                    gf_jclyxnum += gfztlist.get(5).getPointValueInDouble();
                    gf_sdtjnum += gfztlist.get(6).getPointValueInDouble();
                    gf_zcfdnum += gfztlist.get(7).getPointValueInDouble();
                    gf_tjnum += gfztlist.get(8).getPointValueInDouble();
                    gf_xdjclnum += gfztlist.get(9).getPointValueInDouble();
                    gf_sldwnum += gfztlist.get(10).getPointValueInDouble();
                    gf_slhjnum += gfztlist.get(11).getPointValueInDouble();
                    gf_lxnum += gfztlist.get(12).getPointValueInDouble();
                    gf_wznum += gfztlist.get(13).getPointValueInDouble();
                }
            } else {
                for (ProBasicPowerstation wp : wplist) {

                    List<String> fjztls = new ArrayList<>();
                    List<String> gfztls = new ArrayList<>();

                    if (wp.getId().endsWith("FDC_STA") && CacheContext.wpmapls.containsKey(wp.getId())) {
                        List<ProBasicPowerstation> wpls = CacheContext.wpmapls.get(wp.getId());
                        for (ProBasicPowerstation wt : wpls) {
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.GZTSMX).getNemCode());    //故障台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.CNSLGZTSMX).getNemCode()); //场内受累故障台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.JXTSMX).getNemCode());    //检修台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.CNSLJXTSMX).getNemCode());//场内受累检修台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.DJTSMX).getNemCode());//待机台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.QXJCLTSMX).getNemCode());//缺陷降出力台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.SDTJTSMX).getNemCode());//手动停机台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.XNTSMX).getNemCode());//性能台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.XDTJTSMX).getNemCode());//限电停机台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.XDJCLTSMX).getNemCode());//限电降出力台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.CWSLDWTSMX).getNemCode());//场外受累电网台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.CWSLTQTSMX).getNemCode());//场外受累天气台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.LXTSMX).getNemCode());//离线台数
                            fjztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.TXZDTSMX).getNemCode());//通讯中断台数
                            fjztls = fjztls.stream().filter(a -> a != null).collect(Collectors.toList());
                            if (StringUtils.isNotEmpty(fjztls)) {
                                List<PointData> fjztlist = edosUtil.getRealData(fjztls);

                                fd_gztjnum += fjztlist.get(0).getPointValueInDouble();
                                fd_gzcnslnum += fjztlist.get(1).getPointValueInDouble();
                                fd_jxtjnum += fjztlist.get(2).getPointValueInDouble();
                                fd_jxclslnum += fjztlist.get(3).getPointValueInDouble();
                                fd_dfnum += fjztlist.get(4).getPointValueInDouble();
                                fd_jclyxnum += fjztlist.get(5).getPointValueInDouble();
                                fd_sdtjnum += fjztlist.get(6).getPointValueInDouble();
                                fd_zcfdnum += fjztlist.get(7).getPointValueInDouble();
                                fd_tjnum += fjztlist.get(8).getPointValueInDouble();
                                fd_xdjclnum += fjztlist.get(9).getPointValueInDouble();
                                fd_sldwnum += fjztlist.get(10).getPointValueInDouble();
                                fd_slhjnum += fjztlist.get(11).getPointValueInDouble();
                                fd_lxnum += fjztlist.get(12).getPointValueInDouble();
                                fd_wznum += fjztlist.get(13).getPointValueInDouble();
                            }
                        }

                    } else if (wp.getId().endsWith("GDC_STA") && CacheContext.wpmapls.containsKey(wp.getId())) {
                        List<ProBasicPowerstation> wtls = CacheContext.wpmapls.get(wp.getId());
                        for (ProBasicPowerstation wt : wtls) {
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.GZTSMX).getNemCode());    //故障台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.CNSLGZTSMX).getNemCode()); //场内受累故障台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.JXTSMX).getNemCode());    //检修台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.CNSLJXTSMX).getNemCode());//场内受累检修台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.DJTSMX).getNemCode());//待机台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.QXJCLTSMX).getNemCode());//缺陷降出力台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.SDTJTSMX).getNemCode());//手动停机台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.XNTSMX).getNemCode());//性能台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.XDTJTSMX).getNemCode());//限电停机台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.XDJCLTSMX).getNemCode());//限电降出力台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.CWSLDWTSMX).getNemCode());//场外受累电网台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.CWSLTQTSMX).getNemCode());//场外受累天气台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.LXTSMX).getNemCode());//离线台数
                            gfztls.add(proBasicPowerstationPointService.getPowerstationPoint(wt.getId(), ContantXk.TXZDTSMX).getNemCode());//通讯中断台数
                            gfztls = gfztls.stream().filter(a -> a != null).collect(Collectors.toList());
                            if (StringUtils.isNotEmpty(gfztls)) {
                                List<PointData> gfztlist = edosUtil.getRealData(gfztls);

                                gf_gztjnum += gfztlist.get(0).getPointValueInDouble();
                                gf_gzcnslnum += gfztlist.get(1).getPointValueInDouble();
                                gf_jxtjnum += gfztlist.get(2).getPointValueInDouble();
                                gf_jxclslnum += gfztlist.get(3).getPointValueInDouble();
                                gf_dfnum += gfztlist.get(4).getPointValueInDouble();
                                gf_jclyxnum += gfztlist.get(5).getPointValueInDouble();
                                gf_sdtjnum += gfztlist.get(6).getPointValueInDouble();
                                gf_zcfdnum += gfztlist.get(7).getPointValueInDouble();
                                gf_tjnum += gfztlist.get(8).getPointValueInDouble();
                                gf_xdjclnum += gfztlist.get(9).getPointValueInDouble();
                                gf_sldwnum += gfztlist.get(10).getPointValueInDouble();
                                gf_slhjnum += gfztlist.get(11).getPointValueInDouble();
                                gf_lxnum += gfztlist.get(12).getPointValueInDouble();
                                gf_wznum += gfztlist.get(13).getPointValueInDouble();
                            }
                        }
                    }
                }
            }
            mxztmap.put("fd_dfnum", fd_dfnum);
            mxztmap.put("fd_sdtjnum", fd_sdtjnum);
            mxztmap.put("fd_zcfdnum", fd_zcfdnum);
            mxztmap.put("fd_jclyxnum", fd_jclyxnum);
            mxztmap.put("fd_gztjnum", fd_gztjnum);
            mxztmap.put("fd_gzcnslnum", fd_gzcnslnum);
            mxztmap.put("fd_jxtjnum", fd_jxtjnum);
            mxztmap.put("fd_jxclslnum", fd_jxclslnum);
            mxztmap.put("fd_xdjclnum", fd_xdjclnum);
            mxztmap.put("fd_tjnum", fd_tjnum);
            mxztmap.put("fd_sldwnum", fd_sldwnum);
            mxztmap.put("fd_slhjnum", fd_slhjnum);
            mxztmap.put("fd_wznum", fd_wznum);
            mxztmap.put("fd_lxnum", fd_lxnum);

            mxztmap.put("fd_djnum", fd_dfnum + fd_sdtjnum);
            mxztmap.put("fd_yxnum", fd_zcfdnum + fd_jclyxnum);
            mxztmap.put("fd_gznum", fd_gzcnslnum + fd_gztjnum);
            mxztmap.put("fd_jxnum", fd_jxtjnum + fd_jxclslnum);
            mxztmap.put("fd_xdnum", fd_xdjclnum + fd_tjnum);
            mxztmap.put("fd_slnum", fd_slhjnum + fd_sldwnum);
            mxztmap.put("fd_lxyznum", fd_wznum + fd_lxnum);

            mxztmap.put("gf_dfnum", gf_dfnum);
            mxztmap.put("gf_sdtjnum", gf_sdtjnum);
            mxztmap.put("gf_zcfdnum", gf_zcfdnum);
            mxztmap.put("gf_jclyxnum", gf_jclyxnum);
            mxztmap.put("gf_gztjnum", gf_gztjnum);
            mxztmap.put("gf_gzcnslnum", gf_gzcnslnum);
            mxztmap.put("gf_jxtjnum", gf_jxtjnum);
            mxztmap.put("gf_jxclslnum", gf_jxclslnum);
            mxztmap.put("gf_xdjclnum", gf_xdjclnum);
            mxztmap.put("gf_tjnum", gf_tjnum);
            mxztmap.put("gf_sldwnum", gf_sldwnum);
            mxztmap.put("gf_slhjnum", gf_slhjnum);
            mxztmap.put("gf_wznum", gf_wznum);
            mxztmap.put("gf_lxnum", gf_lxnum);

            mxztmap.put("gf_djnum", gf_dfnum + gf_sdtjnum);
            mxztmap.put("gf_yxnum", gf_zcfdnum + gf_jclyxnum);
            mxztmap.put("gf_gznum", gf_gzcnslnum + gf_gztjnum);
            mxztmap.put("gf_jxnum", gf_jxtjnum + gf_jxclslnum);
            mxztmap.put("gf_xdnum", gf_xdjclnum + gf_tjnum);
            mxztmap.put("gf_slnum", gf_slhjnum + gf_sldwnum);
            mxztmap.put("gf_lxyznum", gf_wznum + gf_lxnum);


            map.put("mxztmap", mxztmap);


            /**********************************************首页明细状态统计**********************************************************/


            /**********************************************首页安全天数、实时功率及节能减排等信息统计**********************************************************/

            Double zjrl = 0.0;
            Double czyfdl = 0.0;
            Double cznfdl = 0.0;

            double aqts = 0.0;
            double sjgl = 0.0;
            double llgl = 0.0;
            double ssfs = 0.0;
            double gzzs = 0.0;
            double fnlyl = 0.0;
            double fdfnlyl = 0.0;
            double gffnlyl = 0.0;
            double rfdl = 0.0;
            double yfdl = 0.0;
            double nfdl = 0.0;
            double jys = 0.0;
            double fdjys = 0.0;
            double gfjys = 0.0;
            double jym = 0.0;
            double fdjym = 0.0;
            double gfjym = 0.0;
            double co2 = 0.0;
            double fdco2 = 0.0;
            double gfco2 = 0.0;
            double so2 = 0.0;
            double fdso2 = 0.0;
            double gfso2 = 0.0;

            double fdsjgl = 0.0;
            double gfsjgl = 0.0;

            Map<String, Object> zjrlmap = new HashMap<>();

            if (wpId.contains(QS) || wpId.contains(FD) || wpId.contains(GF)) {
                for (ProBasicPowerstation wp : wplist) {
                    zjrl += wp.getJrCapacity() + wp.getJrwindCapacity();
                }
            } else {


                for (ProBasicPowerstation wp : wplsToken) {
                    if (wpId.equals(wp.getId())) {
                        zjrl += wp.getJrCapacity() + wp.getJrwindCapacity();
                    }
                }
                for (ProBasicProject pj : CacheContext.pjls) {
                    if (wpId.equals(pj.getId())) {
                        zjrl += pj.getCapacity();
                    }
                }
                for (ProBasicLine ln : CacheContext.lnls) {
                    if (wpId.equals(ln.getId())) {
                        zjrl += ln.getCapacity();
                    }
                }

            }
            Date current = com.gyee.common.util.DateUtils.getCurrentDate();

            double gflr = 0.0;
            double fdlr = 0.0;
            List<String> windpowerstationIds = Arrays.asList("MLJ_FDC", "GJY_FDC", "QYRG_GDC", "CZXY_GDC", "YQCX_GDC", "HJFA_GDC", "WXYX_GDC", "WXYL_GDC", "PSSX_GDC", "HGFD_GDC", "YX_GDC", "JK_GDC", "TZ_GDC", "YQ_GDC", "LHS_GDC", "FS_GDC", "ZK_FDC", "SY_GDC", "BHB_FDC", "HSM_FDC", "YTY_FDC", "BHB3_FDC", "JR_GDC", "PDL_FDC", "NJL_FDC", "YLZ_FDC", "YF_FDC", "PTZ_FDC", "XWT_FDC", "DJY_FDC", "HR_GDC", "YY_GDC", "PL_GDC", "TL_GDC", "YG_GDC");

            List<ProEconTargetdata> qwt = new ArrayList<>();
            //            Date current = com.gyee.common.util.DateUtils.getCurrentDate();

            for (String windpowerstationId : windpowerstationIds) {
                QueryWrapper<ProEconTargetdata> qw = new QueryWrapper<>();
                qw.like("windpowerstation_id", windpowerstationId);
                qw.ge("record_date", current);
                qw.orderByDesc("operation_time");
                qw.last("LIMIT 1");
                List<ProEconTargetdata> qwtList = proEconTargetdataService.list(qw);
                if (qwtList != null) {
                    qwt.addAll(qwtList);
                }
            }

            //            List<ProEconTargetdata> qwt = proEconTargetdataService.qwtlist();


            gflr = qwt.stream()
                    .filter(gf -> gf.getWindpowerstationId().endsWith("GDC_STA"))
                    .mapToDouble(gf -> gf.getPower())
                    .sum();

            fdlr = qwt.stream()
                    .filter(gf -> gf.getWindpowerstationId().endsWith("FDC_STA"))
                    .mapToDouble(gf -> gf.getPower())
                    .sum();


            zjrlmap.put("zjrl", zjrl);

            Map<String, Double> qt = new HashMap<>();

            if (wpId.contains(QS) || wpId.contains(FD) || wpId.contains(GF)) {
                ProBasicPowerstationPoint aqtsvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.AQTS);
                aqts = edosUtil.getRealData(aqtsvalue).getPointValueInDouble();

                if (wpId.contains(QS)) {
                    //实时功率
                    ProBasicPowerstationPoint sjglvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
                    sjgl = edosUtil.getRealData(sjglvalue).getPointValueInDouble() + (fdlr * 1000) + (gflr * 1000);
                    sjgl = sjgl / 1000;
                } else if (wpId.contains(FD)) {
                    //实时功率
                    ProBasicPowerstationPoint sjglvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
                    sjgl = edosUtil.getRealData(sjglvalue).getPointValueInDouble() + (fdlr * 1000);
                    sjgl = sjgl / 1000;
                } else if (wpId.contains(GF)) {
                    //实时功率
                    ProBasicPowerstationPoint sjglvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
                    sjgl = edosUtil.getRealData(sjglvalue).getPointValueInDouble() + (gflr * 1000);
                    sjgl = sjgl / 1000;
                }


                //实时风速
                ProBasicPowerstationPoint ssfsvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSPJFS);
                ssfs = edosUtil.getRealData(ssfsvalue).getPointValueInDouble();

                //日发电量
                ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RFDL);
                rfdl = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();

                //月发电量
                ProBasicPowerstationPoint yfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YFDL);
                yfdl = edosUtil.getRealData(yfdlvalue).getPointValueInDouble();

                //年发电量
                ProBasicPowerstationPoint nfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NFDL);
                nfdl = edosUtil.getRealData(nfdlvalue).getPointValueInDouble();

                //光照指数
                //                List<ProBasicPowerstation> czlss = CacheContext.wplsG.stream().filter(w -> w.getOrderNum().equals(15)).collect(Collectors.toList());
                //                ProBasicPowerstationPoint gzzsvalue = proBasicPowerstationPointService.getPowerstationPoint(czlss.get(0).getId(), ContantXk.GCGZQD);
                //                gzzs = edosUtil.getRealData(gzzsvalue).getPointValueInDouble();

                //风能利用率
                ProBasicPowerstationPoint fnlylvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.FNLYL);
                fnlyl = edosUtil.getRealData(fnlylvalue).getPointValueInDouble();

                //理论功率
                ProBasicPowerstationPoint llglvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZNHGLZS);
                llgl = edosUtil.getRealData(llglvalue).getPointValueInDouble();

                //节约水
                ProBasicPowerstationPoint jysvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.JYS);
                jys = edosUtil.getRealData(jysvalue).getPointValueInDouble();

                //减排二氧化碳
                ProBasicPowerstationPoint co2value = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.JYEYHT);
                co2 = edosUtil.getRealData(co2value).getPointValueInDouble();

                //减排二氧化硫
                ProBasicPowerstationPoint so2value = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.JYEYHL);
                so2 = edosUtil.getRealData(so2value).getPointValueInDouble();

                //节约煤
                ProBasicPowerstationPoint jymvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.JYM);
                jym = edosUtil.getRealData(jymvalue).getPointValueInDouble();

                Map<String, Double> map = (Map<String, Double>) planService.plan(wpId).get("proplanmap");


                double nfdltemp = 0.0;
                double fdnfdltemp = 0.0;
                double gfnfdltemp = 0.0;
                if (map.containsKey("gf_n_sjdl")) {
                    nfdltemp = nfdltemp + Double.valueOf(map.get("gf_n_sjdl"));
                    gfnfdltemp = nfdltemp + Double.valueOf(map.get("gf_n_sjdl"));
                }
                if (map.containsKey("fd_n_sjdl")) {
                    nfdltemp = nfdltemp + Double.valueOf(map.get("fd_n_sjdl"));
                    fdnfdltemp = nfdltemp + Double.valueOf(map.get("fd_n_sjdl"));
                }
                jym = new BigDecimal(nfdltemp * 0.37).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                jys = new BigDecimal(nfdltemp * 3.05).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                co2 = new BigDecimal(nfdltemp * 0.8568).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                so2 = new BigDecimal(nfdltemp * 0.0059).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                if (wpId.contains(QS)) {

                    String str = wpId;
                    //实时功率
                    ProBasicPowerstationPoint fdsjglvalue = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-1", ContantXk.SSZGL);
                    fdsjgl = edosUtil.getRealData(fdsjglvalue).getPointValueInDouble() + (fdlr * 1000);
                    fdsjgl = fdsjgl / 1000;
                    ProBasicPowerstationPoint gfsjglvalue = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-2", ContantXk.SSZGL);
                    gfsjgl = edosUtil.getRealData(gfsjglvalue).getPointValueInDouble() + (gflr * 1000);
                    gfsjgl = gfsjgl / 1000;

                    ProBasicPowerstationPoint fdfnlylvalue = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-1", ContantXk.FNLYL);
                    fdfnlyl = edosUtil.getRealData(fdfnlylvalue).getPointValueInDouble();
                    ProBasicPowerstationPoint gffnlylvalue = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-2", ContantXk.FNLYL);
                    gffnlyl = edosUtil.getRealData(gffnlylvalue).getPointValueInDouble();

                    //节约水
                    ProBasicPowerstationPoint fdjysvalue = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-1", ContantXk.JYS);
                    fdjys = edosUtil.getRealData(fdjysvalue).getPointValueInDouble();
                    ProBasicPowerstationPoint gfjysvalue = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-2", ContantXk.JYS);
                    gfjys = edosUtil.getRealData(gfjysvalue).getPointValueInDouble();

                    //减排二氧化碳
                    ProBasicPowerstationPoint fdco2value = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-1", ContantXk.JYEYHT);
                    fdco2 = edosUtil.getRealData(fdco2value).getPointValueInDouble();
                    ProBasicPowerstationPoint gfco2value = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-2", ContantXk.JYEYHT);
                    gfco2 = edosUtil.getRealData(gfco2value).getPointValueInDouble();

                    //减排二氧化硫
                    ProBasicPowerstationPoint fdso2value = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-1", ContantXk.JYEYHL);
                    fdso2 = edosUtil.getRealData(fdso2value).getPointValueInDouble();
                    ProBasicPowerstationPoint gfso2value = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-2", ContantXk.JYEYHL);
                    gfso2 = edosUtil.getRealData(gfso2value).getPointValueInDouble();

                    //节约煤
                    ProBasicPowerstationPoint fdjymvalue = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-1", ContantXk.JYM);
                    fdjym = edosUtil.getRealData(fdjymvalue).getPointValueInDouble();

                    ProBasicPowerstationPoint gfjymvalue = proBasicPowerstationPointService.getPowerstationPoint(str.substring(0, str.indexOf("0")) + "-2", ContantXk.JYM);
                    gfjym = edosUtil.getRealData(gfjymvalue).getPointValueInDouble();


                    fdjym = new BigDecimal(fdnfdltemp * 0.37).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                    fdjys = new BigDecimal(fdnfdltemp * 3.05).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                    fdco2 = new BigDecimal(fdnfdltemp * 0.8568).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                    fdso2 = new BigDecimal(fdnfdltemp * 0.0059).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                    gfjym = new BigDecimal(gfnfdltemp * 0.37).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                    gfjys = new BigDecimal(gfnfdltemp * 3.05).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                    gfco2 = new BigDecimal(gfnfdltemp * 0.8568).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                    gfso2 = new BigDecimal(gfnfdltemp * 0.0059).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                }
                if (wpId.contains(FD)) {
                    ProBasicPowerstationPoint fdsjglvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
                    fdsjgl = edosUtil.getRealData(fdsjglvalue).getPointValueInDouble() + (fdlr * 1000);
                    fdsjgl = fdsjgl / 1000;
                }
                if (wpId.contains(GF)) {
                    ProBasicPowerstationPoint gfsjglvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
                    gfsjgl = edosUtil.getRealData(gfsjglvalue).getPointValueInDouble() + (gflr * 1000);
                    gfsjgl = gfsjgl / 1000;
                }

                for (ProBasicPowerstation wp : wplist) {
                    //                    if (wp.getSpare4().equals("1")) {
                    //                        //实时功率
                    //                        ProBasicPowerstationPoint fdglvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.SSZGL);
                    //                        fdsjgl += edosUtil.getRealData(fdglvalue).getPointValueInDouble();
                    //                    } else {
                    //                        //实时功率
                    //                        ProBasicPowerstationPoint gfglvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.SSZGL);
                    //                        gfsjgl += edosUtil.getRealData(gfglvalue).getPointValueInDouble();
                    //                    }

                    ProBasicPowerstationPoint czyfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.YFDL);
                    czyfdl += edosUtil.getRealData(czyfdlvalue).getPointValueInDouble();
                    ProBasicPowerstationPoint cznfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wp.getId(), ContantXk.NFDL);
                    cznfdl += edosUtil.getRealData(cznfdlvalue).getPointValueInDouble();
                }

            } else {
                //安全天数
                ProBasicPowerstationPoint aqtsvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.AQTS);
                aqts = edosUtil.getRealData(aqtsvalue).getPointValueInDouble();

                //实时功率
                ProBasicPowerstationPoint sjglvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
                sjgl = edosUtil.getRealData(sjglvalue).getPointValueInDouble();
                sjgl = sjgl / 1000;
                fdsjgl = sjgl;
                gfsjgl = sjgl;

                //实时风速
                ProBasicPowerstationPoint ssfsvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSPJFS);
                ssfs = edosUtil.getRealData(ssfsvalue).getPointValueInDouble();

                //光照指数
                ProBasicPowerstationPoint gzzsvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.GCGZQD);
                gzzs = edosUtil.getRealData(gzzsvalue).getPointValueInDouble();
                //风能利用率
                ProBasicPowerstationPoint fnlylvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.FNLYL);
                fnlyl = edosUtil.getRealData(fnlylvalue).getPointValueInDouble();

                //月发电量
                ProBasicPowerstationPoint yfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.YFDL);
                yfdl = edosUtil.getRealData(yfdlvalue).getPointValueInDouble();

                //年发电量
                ProBasicPowerstationPoint nfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.NFDL);
                nfdl = edosUtil.getRealData(nfdlvalue).getPointValueInDouble();

                //理论功率
                ProBasicPowerstationPoint llglvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZNHGLZS);
                llgl = edosUtil.getRealData(llglvalue).getPointValueInDouble();
                llgl = llgl / 1000;

                //节约水
                ProBasicPowerstationPoint jysvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.JYS);
                jys = edosUtil.getRealData(jysvalue).getPointValueInDouble();

                //减排二氧化碳
                ProBasicPowerstationPoint co2value = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.JYEYHT);
                co2 = edosUtil.getRealData(co2value).getPointValueInDouble();

                //减排二氧化硫
                ProBasicPowerstationPoint so2value = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.JYEYHL);
                so2 = edosUtil.getRealData(so2value).getPointValueInDouble();

                //节约煤
                ProBasicPowerstationPoint jymvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.JYM);
                jym = edosUtil.getRealData(jymvalue).getPointValueInDouble();

                Map<String, Double> map = (Map<String, Double>) planService.plan(wpId).get("proplanmap");


                double nfdltemp = 0.0;
                if (map.containsKey("gf_n_sjdl")) {
                    nfdltemp = nfdltemp + Double.valueOf(map.get("gf_n_sjdl"));
                }
                if (map.containsKey("fd_n_sjdl")) {
                    nfdltemp = nfdltemp + Double.valueOf(map.get("fd_n_sjdl"));
                }
                jym = new BigDecimal(nfdltemp * 0.37).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                jys = new BigDecimal(nfdltemp * 3.05).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                co2 = new BigDecimal(nfdltemp * 0.8568).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                so2 = new BigDecimal(nfdltemp * 0.0059).divide(new BigDecimal(10000 * 10000), 2, RoundingMode.HALF_EVEN).doubleValue();


            }
            List<ProBasicEnergyGroup> gpls = CacheContext.gpls;
            List<ProBasicRegion> rgls = CacheContext.rgls;
            List<ProBasicCompany> cpls = CacheContext.cpls;

            // 获取当前日期 暂时
            Date currentDate8 = new Date();

            // 创建 Calendar 对象，并设置为当前日期
            Calendar calendar8 = Calendar.getInstance();
            calendar8.setTime(currentDate8);

            // 设置 beginDate 为前一天的早上六点
            calendar8.add(Calendar.DAY_OF_MONTH, -1);
            calendar8.set(Calendar.HOUR_OF_DAY, 6);
            calendar8.set(Calendar.MINUTE, 0);
            calendar8.set(Calendar.SECOND, 0);
            calendar8.set(Calendar.MILLISECOND, 0);
            Date beginDate8 = calendar8.getTime();

            // 设置 endDate 为当天的23点59分59秒
            calendar8.set(Calendar.HOUR_OF_DAY, 23);
            calendar8.set(Calendar.MINUTE, 59);
            calendar8.set(Calendar.SECOND, 59);
            calendar8.set(Calendar.MILLISECOND, 999);
            Date endDate8 = calendar8.getTime();
            List<ProEconPowerstationInfoDay5> qwt1 = null;
            QueryWrapper<ProEconPowerstationInfoDay5> qw1 = new QueryWrapper<>();
            double rfdlsj = 0.0;
            if (wpId.equals("SXJ_RGN0")) {
                qw1.lambda().in(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-1", "SXJ_RGN-2");
            } else if (wpId.equals("SXJ_RGN-1")) {
                qw1.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-1");
            } else if (wpId.equals("SXJ_RGN-2")) {
                qw1.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_RGN-2");
            } else if (wpId.equals("KGDL_FGS0")) {
                qw1.lambda().in(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_GFFD_ZGS-2", "SXJ_KGDL_FLFD_ZGS-1");
            } else if (wpId.equals("KGDL_FGS-1")) {
                qw1.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_FLFD_ZGS-1");
            } else if (wpId.equals("KGDL_FGS-2")) {
                qw1.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, "SXJ_KGDL_GFFD_ZGS-2");
            }
            qw1.lambda().between(ProEconPowerstationInfoDay5::getRecordDate, beginDate8, endDate8);

            qwt1 = proEconPowerstationInfoDay5Service.list(qw1);

            ProBasicPowerstationPoint rfdlvalue = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RFDL);
            rfdlsj = edosUtil.getRealData(rfdlvalue).getPointValueInDouble();

            List<ProEconPowerstationInfoDay5> qwt3 = null;

            QueryWrapper<ProEconPowerstationInfoDay5> qw3 = new QueryWrapper<>();

            qw3.lambda().eq(ProEconPowerstationInfoDay5::getForeignKeyId, wpId);
            qw3.lambda().between(ProEconPowerstationInfoDay5::getRecordDate, beginDate8, endDate8);
            qwt3 = proEconPowerstationInfoDay5Service.list(qw3);

            double yfdl8 = 0.0;
            double nfdl8 = 0.0;

            double fdyfdl = 0.0;
            double fdnfdl = 0.0;

            double gfyfdl = 0.0;
            double gfnfdl = 0.0;
            double sxzjrl = 0.0;
            double fdsxzjrl = 0.0;
            double gfsxzjrl = 0.0;

            for (ProBasicEnergyGroup gp : gpls) {
                if (wpId.contains(gp.getId())) {

                    for (ProEconPowerstationInfoDay5 dl : qwt1) {
                        if (dl.getForeignKeyId().endsWith("-1")) {
                            StringUtils.round(fdyfdl += dl.getYfdldb().doubleValue(), 2);
                            StringUtils.round(fdnfdl += dl.getNfdldb().doubleValue(), 2);
                        } else {
                            StringUtils.round(gfyfdl += dl.getYfdldb().doubleValue(), 2);
                            StringUtils.round(gfnfdl += dl.getNfdldb().doubleValue(), 2);
                        }
                    }

                    qt.put("fdzzjrl", gp.getWindCapacity() / 1000);
                    qt.put("gfzzjrl", gp.getCapacity() / 1000);
                    qt.put("zzjrl", (gp.getWindCapacity() + gp.getCapacity()) / 1000);
                    qt.put("fdylyxs", StringUtils.round((fdyfdl / 10000) / (gp.getWindCapacity() / 10000), 2));
                    qt.put("fdnlyxs", StringUtils.round((fdnfdl / 10000) / (gp.getWindCapacity() / 10000), 2));
                    qt.put("gfylyxs", StringUtils.round((gfyfdl / 10000) / (gp.getCapacity() / 10000), 2));
                    qt.put("gfnlyxs", StringUtils.round((gfnfdl / 10000) / (gp.getCapacity() / 10000), 2));
                }
            }
            for (ProBasicRegion rg : rgls) {
                if (wpId.contains(rg.getId())) {
                    qt.put("fdzzjrl", rg.getJrwindCapacity() / 1000);
                    qt.put("gfzzjrl", rg.getJrCapacity() / 1000);
                    qt.put("zzjrl", (rg.getJrwindCapacity() + rg.getJrCapacity()) / 1000);
                    //                    qt.put("ylyxs", MathUtil.twoBit(yfdl / 1000) / ((rg.getJrwindCapacity() + rg.getJrCapacity()) / 1000));

                    for (ProEconPowerstationInfoDay5 dl : qwt1) {
                        StringUtils.round(yfdl8 += dl.getYfdldb().doubleValue(), 2);
                        StringUtils.round(nfdl8 += dl.getNfdldb().doubleValue(), 2);

                        if (dl.getForeignKeyId().endsWith("-1")) {
                            StringUtils.round(fdyfdl += dl.getYfdldb().doubleValue(), 2);
                            StringUtils.round(fdnfdl += dl.getNfdldb().doubleValue(), 2);
                        } else {
                            StringUtils.round(gfyfdl += dl.getYfdldb().doubleValue(), 2);
                            StringUtils.round(gfnfdl += dl.getNfdldb().doubleValue(), 2);
                        }

                    }


                    for (ProBasicCompany cp : cpls) {
                        if (wpId.endsWith("0")) {
                            sxzjrl += (cp.getJrwindCapacity() + cp.getJrCapacity()) / 10000;
                        } else if (wpId.endsWith("-1")) {
                            sxzjrl += cp.getJrwindCapacity() / 10000;
                        } else if (wpId.endsWith("-2")) {
                            sxzjrl += cp.getJrCapacity() / 10000;
                        }
                        fdsxzjrl += cp.getJrwindCapacity() / 10000;
                        gfsxzjrl += cp.getJrCapacity() / 10000;
                    }
                    //                    qt.put("ylyxs", StringUtils.round(((yfdl8 + rfdlsj) / 10000) / sxzjrl,2));
                    qt.put("ylyxs", StringUtils.round(((yfdl8) / 10000) / sxzjrl, 2));
                    //                    qt.put("nlyxs", MathUtil.twoBit(nfdl / 1000) / ((rg.getJrwindCapacity() + rg.getJrCapacity()) / 1000));
                    //                    qt.put("nlyxs", StringUtils.round(((nfdl8 + rfdlsj) / 10000) / sxzjrl,2));
                    qt.put("nlyxs", StringUtils.round(((nfdl8) / 10000) / sxzjrl, 2));

                    qt.put("fdylyxs", StringUtils.round((fdyfdl / 10000) / fdsxzjrl, 2));
                    qt.put("fdnlyxs", StringUtils.round((fdnfdl / 10000) / fdsxzjrl, 2));
                    qt.put("gfylyxs", StringUtils.round((gfyfdl / 10000) / gfsxzjrl, 2));
                    qt.put("gfnlyxs", StringUtils.round((gfnfdl / 10000) / gfsxzjrl, 2));
                }
            }

            for (ProBasicCompany cp : cpls) {
                if (wpId.contains(cp.getId())) {
                    qt.put("fdzzjrl", cp.getJrwindCapacity() / 1000);
                    qt.put("gfzzjrl", cp.getJrCapacity() / 1000);
                    qt.put("zzjrl", (cp.getJrwindCapacity() + cp.getJrCapacity()) / 1000);
                    qt.put("ylyxs", MathUtil.twoBit(yfdl / 1000) / ((cp.getJrwindCapacity() + cp.getJrCapacity()) / 1000));
                    qt.put("nlyxs", MathUtil.twoBit(nfdl / 1000) / ((cp.getJrwindCapacity() + cp.getJrCapacity()) / 1000));
                }
            }

            for (ProBasicPowerstation wp : wplist) {
                if (wpId.contains(wp.getId())) {

                    for (ProEconPowerstationInfoDay5 czdl : qwt3) {
                        yfdl8 = czdl.getYfdldb().doubleValue();
                        nfdl8 = czdl.getNfdldb().doubleValue();
                    }
                    //                    qt.put("ylyxs", MathUtil.twoBit(yfdl / 1000) / ((wp.getJrwindCapacity() + wp.getJrCapacity()) / 1000));
                    //                    qt.put("nlyxs", MathUtil.twoBit(nfdl / 1000) / ((wp.getJrwindCapacity() + wp.getJrCapacity()) / 1000));
                    //                    qt.put("ylyxs", MathUtil.twoBit((yfdl8 + rfdlsj) / 10000) / ((wp.getJrwindCapacity() + wp.getJrCapacity()) / 10000));
                    //                    qt.put("nlyxs", MathUtil.twoBit((nfdl8 + rfdlsj)/ 10000) / ((wp.getJrwindCapacity() + wp.getJrCapacity()) / 10000));
                    qt.put("ylyxs", MathUtil.twoBit((yfdl8) / 10000) / ((wp.getJrwindCapacity() + wp.getJrCapacity()) / 10000));
                    qt.put("nlyxs", MathUtil.twoBit((nfdl8) / 10000) / ((wp.getJrwindCapacity() + wp.getJrCapacity()) / 10000));
                }
            }
            //            fnlyl= Math.random() * 10 + 90;
            //            fdfnlyl= Math.random() * 10 + 90;
            //            gffnlyl= Math.random() * 10 + 90;
            qt.put("aqts", MathUtil.twoBit(aqts));
            qt.put("sjgl", MathUtil.twoBit(sjgl));
            qt.put("rfdl", MathUtil.twoBit(rfdl));
            qt.put("yfdl", MathUtil.twoBit(yfdl));
            qt.put("nfdl", MathUtil.twoBit(nfdl));
            qt.put("llgl", MathUtil.twoBit(llgl));
            qt.put("gzzs", MathUtil.twoBit(gzzs));
            qt.put("fnlyl", MathUtil.twoBit(fnlyl));
            qt.put("ssfs", MathUtil.twoBit(ssfs));
            qt.put("jys", MathUtil.twoBit(jys));
            qt.put("jym", MathUtil.twoBit(jym));
            qt.put("co2", MathUtil.twoBit(co2));
            qt.put("so2", MathUtil.twoBit(so2));

            qt.put("fdjys", MathUtil.twoBit(fdjys));
            qt.put("fdjym", MathUtil.twoBit(fdjym));
            qt.put("fdco2", MathUtil.twoBit(fdco2));
            qt.put("fdso2", MathUtil.twoBit(fdso2));
            qt.put("fdfnlyl", MathUtil.twoBit(fdfnlyl));

            qt.put("gfjys", MathUtil.twoBit(gfjys));
            qt.put("gfjym", MathUtil.twoBit(gfjym));
            qt.put("gfco2", MathUtil.twoBit(gfco2));
            qt.put("gfso2", MathUtil.twoBit(gfso2));
            qt.put("gffnlyl", MathUtil.twoBit(gffnlyl));

            qt.put("fdsjgl", MathUtil.twoBit(fdsjgl));
            qt.put("gfsjgl", MathUtil.twoBit(gfsjgl));


            map.put("qt", qt);
            /**********************************************首页安全天数、实时功率及节能减排等信息统计**********************************************************/


            /**********************************************首页电量统计**********************************************************/

            /**********************************************首页电量统计**********************************************************/


            /**********************************************首页弹窗**********************************************************/
            List<ProBasicRegion> wpls = CacheContext.rgls;
            Map<String, Double> sxqyxx = new LinkedHashMap<>();
            Map<String, Double> nmqyxx = new LinkedHashMap<>();
            Map<String, Double> xjqyxx = new LinkedHashMap<>();
            Map<String, Double> hbqyxx = new LinkedHashMap<>();
            Map<String, Double> xsqyxx = new LinkedHashMap<>();
            Map<String, Double> sdqyxx = new LinkedHashMap<>();
            Map<String, Double> xzqyxx = new LinkedHashMap<>();
            Map<String, Map> sytc = new LinkedHashMap<>();

            Double sxcyfdzjrl = 0.0;
            double sxcyfdcsl = 0;

            Double sxcygfzjrl = 0.0;
            double sxcygfcsl = 0;

            Double sxgsfdzjrl = 0.0;
            double sxgsfdcsl = 0;

            Double sxgsgfzjrl = 0.0;
            double sxgsgfcsl = 0;

            Double nmcyfdzjrl = 0.0;
            double nmcyfdcsl = 0;

            Double nmcygfzjrl = 0.0;
            double nmcygfcsl = 0;

            Double nmgsfdzjrl = 0.0;
            double nmgsfdcsl = 0;

            Double nmgsgfzjrl = 0.0;
            double nmgsgfcsl = 0;

            Double xjcyfdzjrl = 0.0;
            double xjcyfdcsl = 0;

            Double xjcygfzjrl = 0.0;
            double xjcygfcsl = 0;

            Double hbcyfdzjrl = 0.0;
            double hbcyfdcsl = 0;

            Double hbcygfzjrl = 0.0;
            double hbcygfcsl = 0;

            Double xscyfdzjrl = 0.0;
            double xscyfdcsl = 0;

            Double xscygfzjrl = 0.0;
            double xscygfcsl = 0;

            Double sdcyfdzjrl = 0.0;
            double sdcyfdcsl = 0;

            Double sdcygfzjrl = 0.0;
            double sdcygfcsl = 0;

            Double xzcyfdzjrl = 0.0;
            double xzcyfdcsl = 0;

            Double xzcygfzjrl = 0.0;
            double xzcygfcsl = 0;


            for (ProBasicRegion reg : wpls) {
                if (reg.getOrderNum().equals(1)) {
                    sxcyfdcsl = reg.getWindNumber() != null ? reg.getWindNumber() : 0;
                    sxcyfdzjrl = reg.getWindCapacity() != null ? reg.getWindCapacity() : 0;
                    sxcygfcsl = reg.getNumber() != null ? reg.getNumber() : 0;
                    sxcygfzjrl = reg.getCapacity() != null ? reg.getCapacity() : 0;

                    sxgsfdcsl = reg.getJrWindNumber() != null ? reg.getJrWindNumber() : 0;
                    sxgsfdzjrl = reg.getJrwindCapacity() != null ? reg.getJrwindCapacity() : 0;
                    sxgsgfcsl = reg.getJrNumber() != null ? reg.getJrNumber() : 0;
                    sxgsgfzjrl = reg.getJrCapacity() != null ? reg.getJrCapacity() : 0;
                }
                if (reg.getOrderNum().equals(4)) {
                    hbcyfdcsl = reg.getWindNumber() != null ? reg.getWindNumber() : 0;
                    hbcyfdzjrl = reg.getWindCapacity() != null ? reg.getWindCapacity() : 0;
                    hbcygfcsl = reg.getNumber() != null ? reg.getNumber() : 0;
                    hbcygfzjrl = reg.getCapacity() != null ? reg.getCapacity() : 0;
                }
                if (reg.getOrderNum().equals(3)) {
                    xscyfdcsl = reg.getWindNumber() != null ? reg.getWindNumber() : 0;
                    xscyfdzjrl = reg.getWindCapacity() != null ? reg.getWindCapacity() : 0;
                    xscygfcsl = reg.getNumber() != null ? reg.getNumber() : 0;
                    xscygfzjrl = reg.getCapacity() != null ? reg.getCapacity() : 0;
                }
                if (reg.getOrderNum().equals(5)) {
                    sdcyfdcsl = reg.getWindNumber() != null ? reg.getWindNumber() : 0;
                    sdcyfdzjrl = reg.getWindCapacity() != null ? reg.getWindCapacity() : 0;
                    sdcygfcsl = reg.getNumber() != null ? reg.getNumber() : 0;
                    sdcygfzjrl = reg.getCapacity() != null ? reg.getCapacity() : 0;
                }
                if (reg.getOrderNum().equals(6)) {
                    xzcyfdcsl = reg.getWindNumber() != null ? reg.getWindNumber() : 0;
                    xzcyfdzjrl = reg.getWindCapacity() != null ? reg.getWindCapacity() : 0;
                    xzcygfcsl = reg.getNumber() != null ? reg.getNumber() : 0;
                    xzcygfzjrl = reg.getCapacity() != null ? reg.getCapacity() : 0;
                }
                if (reg.getOrderNum().equals(2)) {
                    nmcyfdcsl = reg.getNumber() != null ? reg.getWindNumber() : 0;
                    nmcyfdzjrl = reg.getWindCapacity() != null ? reg.getWindCapacity() : 0;
                    nmcygfcsl = reg.getNumber() != null ? reg.getNumber() : 0;
                    nmcygfzjrl = reg.getCapacity() != null ? reg.getCapacity() : 0;

                    nmgsfdcsl = reg.getJrWindNumber() != null ? reg.getJrWindNumber() : 0;
                    nmgsfdzjrl = reg.getJrwindCapacity() != null ? reg.getJrwindCapacity() : 0;
                    nmgsgfcsl = reg.getJrNumber() != null ? reg.getJrNumber() : 0;
                    nmgsgfzjrl = reg.getJrCapacity() != null ? reg.getJrCapacity() : 0;
                }
                if (reg.getOrderNum().equals(7)) {
                    xjcyfdcsl = reg.getWindNumber() != null ? reg.getWindNumber() : 0;
                    xjcyfdzjrl = reg.getWindCapacity() != null ? reg.getWindCapacity() : 0;
                    xjcygfcsl = reg.getNumber() != null ? reg.getNumber() : 0;
                    xjcygfzjrl = reg.getCapacity() != null ? reg.getCapacity() : 0;
                }

            }


            sxqyxx.put("sxcyzzjrl", (sxcyfdzjrl + sxcygfzjrl) / 1000);
            sxqyxx.put("sxcyfdzjrl", sxcyfdzjrl / 1000);
            sxqyxx.put("sxcyfdcsl", StringUtils.round(sxcyfdcsl, 0));
            sxqyxx.put("sxcygfzjrl", sxcygfzjrl / 1000);
            sxqyxx.put("sxcygfcsl", sxcygfcsl);

            sxqyxx.put("sxgszzjrl", (sxgsfdzjrl + sxgsgfzjrl) / 1000);
            sxqyxx.put("sxgsfdzjrl", sxgsfdzjrl / 1000);
            sxqyxx.put("sxgsfdcsl", StringUtils.round(sxgsfdcsl, 0));
            sxqyxx.put("sxgsgfzjrl", sxgsgfzjrl / 1000);
            sxqyxx.put("sxgsgfcsl", StringUtils.round(sxgsgfcsl, 0));
            sytc.put("sxqyxx", sxqyxx);

            nmqyxx.put("nmcyzzjrl", (nmcyfdzjrl + nmcygfzjrl) / 1000);
            nmqyxx.put("nmcyfdzjrl", nmcyfdzjrl / 1000);
            nmqyxx.put("nmcyfdcsl", StringUtils.round(nmcyfdcsl, 0));
            nmqyxx.put("nmcygfzjrl", nmcygfzjrl / 1000);
            nmqyxx.put("nmcygfcsl", nmcygfcsl);

            nmqyxx.put("nmgszzjrl", (nmgsfdzjrl + nmgsgfzjrl) / 1000);
            nmqyxx.put("nmgsfdzjrl", nmgsfdzjrl / 1000);
            nmqyxx.put("nmgsfdcsl", StringUtils.round(nmgsfdcsl, 0));
            nmqyxx.put("nmgsgfzjrl", nmgsgfzjrl / 1000);
            nmqyxx.put("nmgsgfcsl", StringUtils.round(nmgsgfcsl, 0));
            sytc.put("nmqyxx", nmqyxx);

            xjqyxx.put("xjcyzzjrl", (xjcyfdzjrl + xjcygfzjrl) / 1000);
            xjqyxx.put("xjcyfdzjrl", xjcyfdzjrl / 1000);
            xjqyxx.put("xjcyfdcsl", StringUtils.round(xjcyfdcsl, 0));
            xjqyxx.put("xjcygfzjrl", xjcygfzjrl / 1000);
            xjqyxx.put("xjcygfcsl", xjcygfcsl);
            sytc.put("xjqyxx", xjqyxx);

            hbqyxx.put("hbcyzzjrl", (hbcyfdzjrl + hbcygfzjrl) / 1000);
            hbqyxx.put("hbcyfdzjrl", hbcyfdzjrl / 1000);
            hbqyxx.put("hbcyfdcsl", StringUtils.round(hbcyfdcsl, 0));
            hbqyxx.put("hbcygfzjrl", hbcygfzjrl / 1000);
            hbqyxx.put("hbcygfcsl", hbcygfcsl);
            sytc.put("hbqyxx", hbqyxx);

            xsqyxx.put("xscyzzjrl", (xscyfdzjrl + xscygfzjrl) / 1000);
            xsqyxx.put("xscyfdzjrl", xscyfdzjrl / 1000);
            xsqyxx.put("xscyfdcsl", StringUtils.round(xscyfdcsl, 0));
            xsqyxx.put("xscygfzjrl", xscygfzjrl / 1000);
            xsqyxx.put("xscygfcsl", xscygfcsl);
            sytc.put("xsqyxx", xsqyxx);

            sdqyxx.put("sdcyzzjrl", (sdcyfdzjrl + sdcygfzjrl) / 1000);
            sdqyxx.put("sdcyfdzjrl", sdcyfdzjrl / 1000);
            sdqyxx.put("sdcyfdcsl", StringUtils.round(sdcyfdcsl, 0));
            sdqyxx.put("sdcygfzjrl", sdcygfzjrl / 1000);
            sdqyxx.put("sdcygfcsl", sdcygfcsl);
            sytc.put("sdqyxx", sdqyxx);

            xzqyxx.put("xzcyzzjrl", (xzcyfdzjrl + xzcygfzjrl) / 1000);
            xzqyxx.put("xzcyfdzjrl", xzcyfdzjrl / 1000);
            xzqyxx.put("xzcyfdcsl", StringUtils.round(xzcyfdcsl, 0));
            xzqyxx.put("xzcygfzjrl", xzcygfzjrl / 1000);
            xzqyxx.put("xzcygfcsl", xzcygfcsl);
            sytc.put("xzqyxx", xzqyxx);


            map.put("sytc", sytc);

            /**********************************************首页弹窗**********************************************************/


            /**********************************************首页清洁能源公司以及系统接入信息展示**********************************************************/


            double qjny_fd_zjrl = 0;
            double qjny_gf_zjrl = 0;
            double qjny_fcts = 0;
            double qjny_gfts = 0;
            double qjny_fj_ts = 0;
            double qjny_gf_zcts = 0;
            double qjny_gf_jzts = 0;

            double jr_fd_zjrl = 0;
            double jr_gf_zjrl = 0;
            double jr_fcts = 0;
            double jr_gfts = 0;
            double jr_fj_ts = 0;
            double jr_gf_zcts = 0;
            double jr_gf_jzts = 0;

            double qjny_hsfj_ts = 0;


            List<ProBasicCompany> cplist = CacheContext.cpls1;
            //            List<ProBasicCompany> cplist = null;

            //            QueryWrapper<ProBasicCompany> qw = new QueryWrapper<>();
            //            qw.eq("spare2", "1");
            //            cplist = proBasicCompanyService.list(qw);

            Map<String, Double> cblpoint = new LinkedHashMap<>();


            if (!cplist.isEmpty()) {
                for (ProBasicCompany pg : cplist) {

                    //集团
                    if (wpId.contains("KGDL_FGS")) {

                        //清洁能源风电装机容量
                        qjny_fd_zjrl += null != pg.getWindCapacity() ? pg.getWindCapacity() : 0.0;
                        //清洁能源光伏装机容量
                        qjny_gf_zjrl += null != pg.getCapacity() ? pg.getCapacity() : 0.0;
                        //接入风电装机容量
                        jr_fd_zjrl += null != pg.getJrwindCapacity() ? pg.getJrwindCapacity() : 0.0;
                        //接入光伏装机容量
                        jr_gf_zjrl += null != pg.getJrCapacity() ? pg.getJrCapacity() : 0.0;
                        //清洁能源风场数量
                        qjny_fcts += null != pg.getWindNumber() ? pg.getWindNumber() : 0.0;
                        //清洁能源光伏电站数量
                        qjny_gfts += null != pg.getNumber() ? pg.getNumber() : 0.0;
                        //接入风场数量
                        jr_fcts += null != pg.getJrWindNumber() ? pg.getJrWindNumber() : 0.0;
                        //接入光伏电站数量
                        jr_gfts += null != pg.getJrNumber() ? pg.getJrNumber() : 0.0;
                        //清洁能源风机数量
                        qjny_fj_ts += null != pg.getWindQuantityLd() ? pg.getWindQuantityLd() : 0.0;
                        //清洁能源光伏组串数量
                        qjny_gf_zcts += null != pg.getQuantityZc() ? pg.getQuantityZc() : 0.0;
                        //清洁能源光伏集中数量
                        qjny_gf_jzts += null != pg.getQuantityJz() ? pg.getQuantityJz() : 0.0;
                        //接入风机数量
                        jr_fj_ts += null != pg.getJrwindQuantityLd() ? pg.getJrwindQuantityLd() : 0.0;
                        //接入光伏组串数量
                        jr_gf_zcts += null != pg.getJrquantityZc() ? pg.getJrquantityZc() : 0.0;
                        //接入光伏集中数量
                        jr_gf_jzts += null != pg.getJrquantityJz() ? pg.getJrquantityJz() : 0.0;

                        qjny_hsfj_ts += null != pg.getJrwindQuantityHs() ? pg.getJrwindQuantityHs() : 0.0;

                    } else if (wpId.contains(pg.getId()) && pg.getOrderNum().equals(1)) {  //风电公司
                        //清洁能源风电装机容量
                        qjny_fd_zjrl += null != pg.getWindCapacity() ? pg.getWindCapacity() : 0.0;
                        //清洁能源光伏装机容量
                        qjny_gf_zjrl += null != pg.getCapacity() ? pg.getCapacity() : 0.0;
                        //接入风电装机容量
                        jr_fd_zjrl += null != pg.getJrwindCapacity() ? pg.getJrwindCapacity() : 0.0;
                        //接入光伏装机容量
                        jr_gf_zjrl += null != pg.getJrCapacity() ? pg.getJrCapacity() : 0.0;
                        //清洁能源风场数量
                        qjny_fcts += null != pg.getWindNumber() ? pg.getWindNumber() : 0.0;
                        //清洁能源光伏电站数量
                        qjny_gfts += null != pg.getNumber() ? pg.getNumber() : 0.0;
                        //接入风场数量
                        jr_fcts += null != pg.getJrWindNumber() ? pg.getJrWindNumber() : 0.0;
                        //接入光伏电站数量
                        jr_gfts += null != pg.getJrNumber() ? pg.getJrNumber() : 0.0;
                        //清洁能源风机数量
                        qjny_fj_ts += null != pg.getWindQuantityLd() ? pg.getWindQuantityLd() : 0.0;
                        //清洁能源光伏组串数量
                        qjny_gf_zcts += null != pg.getQuantityZc() ? pg.getQuantityZc() : 0.0;
                        //清洁能源光伏集中数量
                        qjny_gf_jzts += null != pg.getQuantityJz() ? pg.getQuantityJz() : 0.0;
                        //接入风机数量
                        jr_fj_ts += null != pg.getJrwindQuantityLd() ? pg.getJrwindQuantityLd() : 0.0;
                        //接入光伏组串数量
                        jr_gf_zcts += null != pg.getJrquantityZc() ? pg.getJrquantityZc() : 0.0;
                        //接入光伏集中数量
                        jr_gf_jzts += null != pg.getJrquantityJz() ? pg.getJrquantityJz() : 0.0;
                        qjny_hsfj_ts += null != pg.getJrwindQuantityHs() ? pg.getJrwindQuantityHs() : 0.0;

                    } else if (wpId.contains(pg.getId()) && pg.getOrderNum().equals(3)) {   //光伏公司

                        //清洁能源风电装机容量
                        qjny_fd_zjrl += null != pg.getWindCapacity() ? pg.getWindCapacity() : 0.0;
                        //清洁能源光伏装机容量
                        qjny_gf_zjrl += null != pg.getCapacity() ? pg.getCapacity() : 0.0;
                        //接入风电装机容量
                        jr_fd_zjrl += null != pg.getJrwindCapacity() ? pg.getJrwindCapacity() : 0.0;
                        //接入光伏装机容量
                        jr_gf_zjrl += null != pg.getJrCapacity() ? pg.getJrCapacity() : 0.0;
                        //清洁能源风场数量
                        qjny_fcts += null != pg.getWindNumber() ? pg.getWindNumber() : 0.0;
                        //清洁能源光伏电站数量
                        qjny_gfts += null != pg.getNumber() ? pg.getNumber() : 0.0;
                        //接入风场数量
                        jr_fcts += null != pg.getJrWindNumber() ? pg.getJrWindNumber() : 0.0;
                        //接入光伏电站数量
                        jr_gfts += null != pg.getJrNumber() ? pg.getJrNumber() : 0.0;
                        //清洁能源风机数量
                        qjny_fj_ts += null != pg.getWindQuantityLd() ? pg.getWindQuantityLd() : 0.0;
                        //清洁能源光伏组串数量
                        qjny_gf_zcts += null != pg.getQuantityZc() ? pg.getQuantityZc() : 0.0;
                        //清洁能源光伏集中数量
                        qjny_gf_jzts += null != pg.getQuantityJz() ? pg.getQuantityJz() : 0.0;
                        //接入风机数量
                        jr_fj_ts += null != pg.getJrwindQuantityLd() ? pg.getJrwindQuantityLd() : 0.0;
                        //接入光伏组串数量
                        jr_gf_zcts += null != pg.getJrquantityZc() ? pg.getJrquantityZc() : 0.0;
                        //接入光伏集中数量
                        jr_gf_jzts += null != pg.getJrquantityJz() ? pg.getJrquantityJz() : 0.0;
                        qjny_hsfj_ts += null != pg.getJrwindQuantityHs() ? pg.getJrwindQuantityHs() : 0.0;

                    } else if (wpId.contains(pg.getId()) && pg.getOrderNum().equals(2)) {  //七和

                        //清洁能源风电装机容量
                        qjny_fd_zjrl += null != pg.getWindCapacity() ? pg.getWindCapacity() : 0.0;
                        //清洁能源光伏装机容量
                        qjny_gf_zjrl += null != pg.getCapacity() ? pg.getCapacity() : 0.0;
                        //接入风电装机容量
                        jr_fd_zjrl += null != pg.getJrwindCapacity() ? pg.getJrwindCapacity() : 0.0;
                        //接入光伏装机容量
                        jr_gf_zjrl += null != pg.getJrCapacity() ? pg.getJrCapacity() : 0.0;
                        //清洁能源风场数量
                        qjny_fcts += null != pg.getWindNumber() ? pg.getWindNumber() : 0.0;
                        //清洁能源光伏电站数量
                        qjny_gfts += null != pg.getNumber() ? pg.getNumber() : 0.0;
                        //接入风场数量
                        jr_fcts += null != pg.getJrWindNumber() ? pg.getJrWindNumber() : 0.0;
                        //接入光伏电站数量
                        jr_gfts += null != pg.getJrNumber() ? pg.getJrNumber() : 0.0;
                        //清洁能源风机数量
                        qjny_fj_ts += null != pg.getWindQuantityLd() ? pg.getWindQuantityLd() : 0.0;
                        //清洁能源光伏组串数量
                        qjny_gf_zcts += null != pg.getQuantityZc() ? pg.getQuantityZc() : 0.0;
                        //清洁能源光伏集中数量
                        qjny_gf_jzts += null != pg.getQuantityJz() ? pg.getQuantityJz() : 0.0;
                        //接入风机数量
                        jr_fj_ts += null != pg.getJrwindQuantityLd() ? pg.getJrwindQuantityLd() : 0.0;
                        //接入光伏组串数量
                        jr_gf_zcts += null != pg.getJrquantityZc() ? pg.getJrquantityZc() : 0.0;
                        //接入光伏集中数量
                        jr_gf_jzts += null != pg.getJrquantityJz() ? pg.getJrquantityJz() : 0.0;

                        qjny_hsfj_ts += null != pg.getJrwindQuantityHs() ? pg.getJrwindQuantityHs() : 0.0;

                    }

                }

                cblpoint.put("qjny_fd_zjrl", StringUtils.round(qjny_fd_zjrl / 1000, 2));
                cblpoint.put("qjny_gf_zjrl", StringUtils.round(qjny_gf_zjrl / 1000, 2));
                cblpoint.put("qjny_zzjrl", StringUtils.round((qjny_gf_zjrl + qjny_fd_zjrl) / 1000, 2));
                cblpoint.put("jr_fd_zjrl", StringUtils.round(jr_fd_zjrl / 1000, 2));
                cblpoint.put("jr_gf_zjrl", StringUtils.round(jr_gf_zjrl / 1000, 2));
                cblpoint.put("jr_zzjrl", StringUtils.round((jr_gf_zjrl + jr_fd_zjrl) / 1000, 2));
                cblpoint.put("qjny_fcts", StringUtils.round(qjny_fcts, 2));
                cblpoint.put("qjny_gfts", StringUtils.round(qjny_gfts, 2));
                cblpoint.put("jr_fcts", StringUtils.round(jr_fcts, 2));
                cblpoint.put("jr_gfts", StringUtils.round(jr_gfts, 2));
                cblpoint.put("qjny_fj_ts", StringUtils.round(qjny_fj_ts, 2));
                cblpoint.put("qjny_gf_zcts", StringUtils.round(qjny_gf_zcts, 2));
                cblpoint.put("qjny_gf_jzts", StringUtils.round(qjny_gf_jzts, 2));
                cblpoint.put("jr_fj_ts", StringUtils.round(jr_fj_ts, 2));
                cblpoint.put("jr_gf_zcts", StringUtils.round(jr_gf_zcts, 2));
                cblpoint.put("jr_gf_jzts", StringUtils.round(jr_gf_jzts, 2));
                cblpoint.put("qjny_hsfj_ts", StringUtils.round(qjny_hsfj_ts, 2));


            }
            if (wpId.contains("SXJ_RGN")) {

                List<ProBasicCompany> sxj_rgn = cplist.stream().filter(i -> i.getRegionId().equals("SXJ_RGN")).collect(Collectors.toList());

                if (!cplist.isEmpty()) {

                    for (ProBasicCompany pg1 : sxj_rgn) {

                        //清洁能源风电装机容量
                        qjny_fd_zjrl += null != pg1.getWindCapacity() ? pg1.getWindCapacity() : 0.0;
                        //清洁能源光伏装机容量
                        qjny_gf_zjrl += null != pg1.getCapacity() ? pg1.getCapacity() : 0.0;
                        //接入风电装机容量
                        jr_fd_zjrl += null != pg1.getJrwindCapacity() ? pg1.getJrwindCapacity() : 0.0;
                        //接入光伏装机容量
                        jr_gf_zjrl += null != pg1.getJrCapacity() ? pg1.getJrCapacity() : 0.0;
                        //清洁能源风场数量
                        qjny_fcts += null != pg1.getWindNumber() ? pg1.getWindNumber() : 0.0;
                        //清洁能源光伏电站数量
                        qjny_gfts += null != pg1.getNumber() ? pg1.getNumber() : 0.0;
                        //接入风场数量
                        jr_fcts += null != pg1.getJrWindNumber() ? pg1.getJrWindNumber() : 0.0;
                        //接入光伏电站数量
                        jr_gfts += null != pg1.getJrNumber() ? pg1.getJrNumber() : 0.0;
                        //清洁能源风机数量
                        qjny_fj_ts += null != pg1.getWindQuantityLd() ? pg1.getWindQuantityLd() : 0.0;
                        //清洁能源光伏组串数量
                        qjny_gf_zcts += null != pg1.getQuantityZc() ? pg1.getQuantityZc() : 0.0;
                        //清洁能源光伏集中数量
                        qjny_gf_jzts += null != pg1.getQuantityJz() ? pg1.getQuantityJz() : 0.0;
                        //接入风机数量
                        jr_fj_ts += null != pg1.getJrwindQuantityLd() ? pg1.getJrwindQuantityLd() : 0.0;
                        //接入光伏组串数量
                        jr_gf_zcts += null != pg1.getJrquantityZc() ? pg1.getJrquantityZc() : 0.0;
                        //接入光伏集中数量
                        jr_gf_jzts += null != pg1.getJrquantityJz() ? pg1.getJrquantityJz() : 0.0;

                        qjny_hsfj_ts += null != pg1.getJrwindQuantityHs() ? pg1.getJrwindQuantityHs() : 0.0;

                    }
                }
                cblpoint.put("qjny_fd_zjrl", StringUtils.round(qjny_fd_zjrl / 1000, 2));
                cblpoint.put("qjny_gf_zjrl", StringUtils.round(qjny_gf_zjrl / 1000, 2));
                cblpoint.put("qjny_zzjrl", StringUtils.round((qjny_gf_zjrl + qjny_fd_zjrl) / 1000, 2));
                cblpoint.put("jr_fd_zjrl", StringUtils.round(jr_fd_zjrl / 1000, 2));
                cblpoint.put("jr_gf_zjrl", StringUtils.round(jr_gf_zjrl / 1000, 2));
                cblpoint.put("jr_zzjrl", StringUtils.round((jr_gf_zjrl + jr_fd_zjrl) / 1000, 2));
                cblpoint.put("qjny_fcts", StringUtils.round(qjny_fcts, 2));
                cblpoint.put("qjny_gfts", StringUtils.round(qjny_gfts, 2));
                cblpoint.put("jr_fcts", StringUtils.round(jr_fcts, 2));
                cblpoint.put("jr_gfts", StringUtils.round(jr_gfts, 2));
                cblpoint.put("qjny_fj_ts", StringUtils.round(qjny_fj_ts, 2));
                cblpoint.put("qjny_gf_zcts", StringUtils.round(qjny_gf_zcts, 2));
                cblpoint.put("qjny_gf_jzts", StringUtils.round(qjny_gf_jzts, 2));
                cblpoint.put("jr_fj_ts", StringUtils.round(jr_fj_ts, 2));
                cblpoint.put("jr_gf_zcts", StringUtils.round(jr_gf_zcts, 2));
                cblpoint.put("jr_gf_jzts", StringUtils.round(jr_gf_jzts, 2));
                cblpoint.put("qjny_hsfj_ts", StringUtils.round(qjny_hsfj_ts, 2));

            }


            for (ProBasicPowerstation wp : wplist) {
                if (wpId.contains(wp.getId()) && wp.getWindType().equals("-1")) {
                    //清洁能源风电装机容量
                    qjny_fd_zjrl += null != wp.getWindCapacity() ? wp.getWindCapacity() : 0.0;

                    //接入风电装机容量
                    jr_fd_zjrl += null != wp.getJrwindCapacity() ? wp.getJrwindCapacity() : 0.0;

                    //清洁能源风机数量
                    qjny_fj_ts += null != wp.getWindQuantityLd() ? wp.getWindQuantityLd() : 0.0;

                    //接入风机数量
                    jr_fj_ts += null != wp.getJrwindQuantityLd() ? wp.getJrwindQuantityLd() : 0.0;

                    cblpoint.put("qjny_fd_zjrl", StringUtils.round(qjny_fd_zjrl / 1000, 2));
                    cblpoint.put("jr_fd_zjrl", StringUtils.round(jr_fd_zjrl / 1000, 2));
                    cblpoint.put("qjny_fj_ts", StringUtils.round(qjny_fj_ts, 2));
                    cblpoint.put("jr_fj_ts", StringUtils.round(jr_fj_ts, 2));
                } else if (wpId.contains(wp.getId()) && wp.getWindType().equals("-2")) {

                    //清洁能源光伏装机容量
                    qjny_gf_zjrl += null != wp.getCapacity() ? wp.getCapacity() : 0.0;
                    //接入光伏装机容量
                    jr_gf_zjrl += null != wp.getJrCapacity() ? wp.getJrCapacity() : 0.0;
                    //清洁能源光伏组串数量
                    qjny_gf_zcts += null != wp.getQuantityZc() ? wp.getQuantityZc() : 0.0;
                    //清洁能源光伏集中数量
                    qjny_gf_jzts += null != wp.getQuantityJz() ? wp.getQuantityJz() : 0.0;
                    //接入光伏组串数量
                    jr_gf_zcts += null != wp.getJrquantityZc() ? wp.getJrquantityZc() : 0.0;
                    //接入光伏集中数量
                    jr_gf_jzts += null != wp.getJrquantityJz() ? wp.getJrquantityJz() : 0.0;

                    cblpoint.put("qjny_gf_zjrl", StringUtils.round(qjny_gf_zjrl / 1000, 2));
                    cblpoint.put("jr_gf_zjrl", StringUtils.round(jr_gf_zjrl / 1000, 2));
                    cblpoint.put("qjny_gf_zcts", StringUtils.round(qjny_gf_zcts, 2));
                    cblpoint.put("qjny_gf_jzts", StringUtils.round(qjny_gf_jzts, 2));
                    cblpoint.put("jr_gf_zcts", StringUtils.round(jr_gf_zcts, 2));
                    cblpoint.put("jr_gf_jzts", StringUtils.round(jr_gf_jzts, 2));

                }

            }

            map.put("cblpoint", cblpoint);

            /**********************************************首页清洁能源公司以及系统接入信息展示**********************************************************/


        }
        return map;
    }

    //实时数据
    public List<PowercurveVo> Realtimevalue(String wpId, String uniformCode) throws Exception {

        Date beginDate = com.gyee.common.util.DateUtils.getSamedayZero();   //当日零点
        Date endDate = com.gyee.common.util.DateUtils.getCurrentDate();   //当前时间
        List<PowercurveVo> vos = new ArrayList<PowercurveVo>();

        int day = DateUtils.getCurrentHour();//4

        for (int i = 0; i < day; i++) {
            PowercurveVo vo = new PowercurveVo();
            vo.setLlgl(0.0); //理论功率
            vo.setBzgl(0.0); //保证功率
            vo.setSjgl(0.0); //实际功率
            vo.setSsfs(0.0); //实时风速
            vo.setGzzs(0.0); //光照指数
            vo.setFnlyl(0.0); //风能利用率
            vo.setHours(i);  //时间戳
            vo.setName(wpId);
            vos.add(vo);
        }

        ProBasicPowerstationPoint ssfs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSPJFS);
        ProBasicPowerstationPoint llgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.TPOINT_WP_YCGL); //预测功率
        ProBasicPowerstationPoint sjgl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.SSZGL);
        ProBasicPowerstationPoint gzzs = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.RPJGZD);
        ProBasicPowerstationPoint fnlyl = proBasicPowerstationPointService.getPowerstationPoint(wpId, ContantXk.FNLYL);

        if (uniformCode.contains("SSPJFS")) {

            List<PointData> ssfsls = edosUtil.getHistoryDatasSnap(ssfs, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 3600L);
            double temp1 = 0;
            for (int i = 0; i < ssfsls.size(); i++) {
                temp1 = ssfsls.get(i).getPointValueInDouble();
                vos.get(i).setSsfs(StringUtils.round(temp1, 2));
            }
        }

        if (uniformCode.contains("SSZLLGL")) {
            List<PointData> llglls = edosUtil.getHistoryDatasSnap(llgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 3600L);
            double temp2 = 0;
            for (int i = 0; i < llglls.size(); i++) {
                temp2 = llglls.get(i).getPointValueInDouble();
                vos.get(i).setLlgl(StringUtils.round(temp2 / 1000, 2));
            }
        }

        if (uniformCode.contains("SSZGL")) {
            List<PointData> sjglls = edosUtil.getHistoryDatasSnap(sjgl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 3600L);
            double temp3 = 0;
            for (int i = 0; i < sjglls.size(); i++) {
                temp3 = sjglls.get(i).getPointValueInDouble();
                vos.get(i).setSjgl(StringUtils.round(temp3 / 1000, 2));
            }
        }

        if (uniformCode.contains("RPJGZD")) {
            List<PointData> gzzsls = edosUtil.getHistoryDatasSnap(gzzs, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 3600L);
            double temp4 = 0;
            for (int i = 0; i < gzzsls.size(); i++) {
                temp4 = gzzsls.get(i).getPointValueInDouble();
                vos.get(i).setGzzs(StringUtils.round(temp4 / 1000, 2));
            }
        }
        if (uniformCode.contains("FNLYL")) {
            List<PointData> fnlylls = edosUtil.getHistoryDatasSnap(fnlyl, beginDate.getTime() / 1000, endDate.getTime() / 1000, null, 3600L);
            double temp5 = 0;
            for (int i = 0; i < fnlylls.size(); i++) {
                temp5 = fnlylls.get(i).getPointValueInDouble();
                vos.get(i).setFnlyl(StringUtils.round(temp5, 2));
            }
        }

        return vos;
    }
}
