package com.gyee.frame.service.websocket;


import com.gyee.frame.common.spring.Constant;
import com.gyee.frame.common.spring.InitialRunner;
import com.gyee.frame.model.auto.WindPowerStationTestingPoint;
import com.gyee.frame.model.auto.Windpowerstation;
import com.gyee.frame.model.auto.Windturbine;
import com.gyee.frame.model.auto.WpMttrAndMtbMonth;
import com.gyee.frame.model.custom.DNAVal;
import com.gyee.frame.model.custom.DataVo;
import com.gyee.frame.model.custom.PointData;
import com.gyee.frame.model.custom.ZtjsVo;
import com.gyee.frame.service.*;
import com.gyee.frame.service.weather.WeatherService;
import com.gyee.frame.util.IRealTimeDataBaseUtil;
import com.gyee.frame.util.MathUtil;
import com.gyee.frame.util.RealTimeDataBaseFactory;
import com.gyee.frame.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;

@Service
public class WpInfoPushService {


    @Resource
    private WindPowerstationTestingPoint2Service windPowerstationTestingPoint2Service;
    @Resource
    private WindpowerinfodayService windpowerinfodayService;
    @Resource
    private ProjectPlanService projectPlanService;
    @Resource
    private MatrixPushByWpService matrixPushByWpService;
    @Resource
    private RealPowerPushService realPowerPushService;
    @Resource
    private WpMttrAndMtbMonthService wpMttrAndMtbMonthService;
    @Resource
    private WeatherService weatherService;

    @Resource
    WindTurbineTestingPointAiService windTurbineTestingPointAiService;

    IRealTimeDataBaseUtil realApiUtil = RealTimeDataBaseFactory.createRealTimeDataBase();
    private final double YCFDLXS = 1.08;
    String[] ycPoints1 = Constant.TPOINT_WP_FGLYC.split(",");

    public Map<String, Object> genreSetMap() throws Exception {

        Map<String, Object> map = findWpInfo();

//        map.put("SBQ_FDC",findWpInfo("SBQ_FDC"));
//        map.put("SBQ02_GC",findWpInfo("SBQ02_GC"));
//        map.put("SBQ05_XL",findWpInfo("SBQ05_XL"));

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

        return map;

    }


    public Map<String, Object> genreSetMap(String wpId) throws Exception {

        Map<String, Object> map = findWpInfoBy(wpId);

//        map.put("SBQ_FDC",findWpInfo("SBQ_FDC"));
//        map.put("SBQ02_GC",findWpInfo("SBQ02_GC"));
//        map.put("SBQ05_XL",findWpInfo("SBQ05_XL"));

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

        return map;

    }

    /**
     * 状态监视页面
     *
     * @return
     * @throws Exception
     */
    public Map<String, Object> findWpInfo() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();

        List<ZtjsVo> vos = new ArrayList<>();
        List<Map<String, Object>> maps = new ArrayList<>();
        for (Windpowerstation wp : InitialRunner.wpallls) {

            ZtjsVo vo = new ZtjsVo();
            String id = wp.getId();
            double scadafdl = 0.0;
            Double zjrl = 0.0;
            Double zjts = 0.0;

            Double sjgl = 0.0;
            Double bzgl = 0.0;
            Double yfgl = 0.0;

/*************************************************基础指标*************************************************************/

            zjrl = wp.getCapacity();
            zjts = Double.valueOf(wp.getQuantity());

            vo.setWpId(wp.getId());
            vo.setWpName(wp.getName());
            vo.setZjrl(zjrl);
            Map<String, Object> jczbmap = new HashMap<>();

//          jczbmap.put("zjrl", zjrl);
            jczbmap.put("zjts", zjts);
            jczbmap.put("name", wp.getName());
            List<String> jczbls = new ArrayList<>();

            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_SJGL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_RFDL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_YFDL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_NFDL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_SSFS).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_SWDL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.ZBZGL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_ZZSGL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.FJZT).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WT_RFDL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, ycPoints1[0]).getCode());

            if (InitialRunner.wpmap.containsKey(id)) {
                jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.AGC001).getCode());
                jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.AGC002).getCode());
            }


            List<PointData> jczblist = realApiUtil.getRealData(jczbls);

            if (!jczblist.isEmpty() && jczblist.size() == jczbls.size()) {
                //实际功率
                sjgl = MathUtil.twoBit(jczblist.get(0).getPointValueInDouble());
                vo.setGl(sjgl);
                //jczbmap.put("sjgl", sjgl);
                //日发电量
                double fdl = MathUtil.twoBit(jczblist.get(1).getPointValueInDouble());
                vo.setFdl(fdl);
                // jczbmap.put("rfdl", rfdl);

//                //月发电量
//                double yfdl=MathUtil.twoBit(jczblist.get(2).getPointValueInDouble());
//                jczbmap.put("yfdl", yfdl);
//                //年发电量
//                double nfdl=MathUtil.twoBit(jczblist.get(3).getPointValueInDouble());
//                jczbmap.put("nfdl", nfdl);
                //月利用小时
                double ylyxs = (new BigDecimal(jczblist.get(2).getPointValueInDouble()).multiply(new BigDecimal(10))).divide(new BigDecimal(zjrl), 2, RoundingMode.HALF_EVEN).doubleValue();
                //jczbmap.put("ylyxs",ylyxs );
                vo.setLyxs(ylyxs);
//                //年利用小时
//                double nlyxs= (new BigDecimal(jczblist.get(3).getPointValueInDouble()).multiply(new BigDecimal(10))).divide(new BigDecimal(zjrl), 2, RoundingMode.HALF_EVEN).doubleValue();
//                jczbmap.put("nlyxs",nlyxs);
                //实时风速
                double ssfs = MathUtil.twoBit(jczblist.get(4).getPointValueInDouble());
                //        jczbmap.put("ssfs",ssfs );
                vo.setFs(ssfs);
                //上网电量
                double swdl = MathUtil.twoBit(jczblist.get(5).getPointValueInDouble());
                // jczbmap.put("swdl",swdl );
                vo.setSwdl(swdl);
                //保证功率
                bzgl = new BigDecimal(jczblist.get(6).getPointValueInDouble()).divide(new BigDecimal(1000), 2, RoundingMode.HALF_EVEN).doubleValue();
                //jczbmap.put("bzgl", bzgl);
                vo.setBzgl(bzgl);
                //应发功率
                yfgl = new BigDecimal(jczblist.get(7).getPointValueInDouble()).divide(new BigDecimal(1000), 2, RoundingMode.HALF_EVEN).doubleValue();
                // jczbmap.put("yfgl", yfgl);
                vo.setLlgl(yfgl);
                //目标状态
                double fczt = StringUtils.round(jczblist.get(8).getPointValueInDouble(), 0);
                jczbmap.put("fczt", fczt);

                //SCADA发电量
                scadafdl = StringUtils.round(jczblist.get(9).getPointValueInDouble(), 2);
                //jczbmap.put("scadafdl",scadafdl );
                vo.setScadafdl(scadafdl);
                //预测功率
                double ycgl = StringUtils.round(jczblist.get(10).getPointValueInDouble(), 2);
                jczbmap.put("ycgl", ycgl);
                vo.setYcgl(ycgl);
                //AGC出线有功
                double agccxyg = StringUtils.round(jczblist.get(11).getPointValueInDouble(), 2);
                jczbmap.put("agccxyg", agccxyg);
                vo.setCxgl(agccxyg);
                //AGC有功设定
                double agcygsd = StringUtils.round(jczblist.get(12).getPointValueInDouble(), 2);
                jczbmap.put("agcygsd", agcygsd);
                vo.setAGCzl(agcygsd);

            } else {
                //实际功率
                jczbmap.put("sjgl", 0.0);
                //日发电量
                jczbmap.put("rfdl", 0.0);
                //月发电量
                jczbmap.put("yfdl", 0.0);
                //年发电量
                jczbmap.put("nfdl", 0.0);
                //月利用小时
                jczbmap.put("ylyxs", 0.0);
                //年利用小时
                jczbmap.put("nlyxs", 0.0);
                //实时风速
                jczbmap.put("ssfs", 0.0);
                //上网电量
                jczbmap.put("swdl", 0.0);
                //保证功率
                jczbmap.put("bzgl", 0.0);
                //应发功率
                jczbmap.put("yfgl", 0.0);
                //目标状态
                jczbmap.put("fczt", -1.0);
                //SCADA发电量
                jczbmap.put("scadafdl", 0.0);
                //预测功率
                jczbmap.put("ycgl", 0.0);
                //AGC出线有功
                jczbmap.put("agccxyg", 0.0);
                //AGC有功设定
                jczbmap.put("agcygsd", 0.0);


            }


            List<WindPowerStationTestingPoint> wpoints= windPowerstationTestingPoint2Service.getJsztList(id);

            if(!wpoints.isEmpty())
            {
                for(WindPowerStationTestingPoint wpoint:wpoints)
                {
                    if(StringUtils.notEmp(wpoint) && StringUtils.notEmp(wpoint.getName()))
                    {
                        String name=wpoint.getName();
                        if(name.indexOf("风机")!=-1)
                        {
                            PointData pointData=realApiUtil.getRealData(wpoint.getCode());
                            jczbmap.put("zxzt_fjzt",pointData.getPointValueInDouble());
                        }else if(name.indexOf("升压站")!=-1)
                        {
                            PointData pointData=realApiUtil.getRealData(wpoint.getCode());
                            jczbmap.put("zxzt_syzzt",pointData.getPointValueInDouble());
                        }else if(name.indexOf("电计量")!=-1)
                        {
                            PointData pointData=realApiUtil.getRealData(wpoint.getCode());
                            jczbmap.put("zxzt_djlzt",pointData.getPointValueInDouble());
                        }else if(name.indexOf("agc")!=-1)
                        {
                            PointData pointData=realApiUtil.getRealData(wpoint.getCode());
                            jczbmap.put("zxzt_acgzt",pointData.getPointValueInDouble());
                        }else if(name.indexOf("测风塔")!=-1)
                        {
                            PointData pointData=realApiUtil.getRealData(wpoint.getCode());
                            jczbmap.put("zxzt_cftzt",pointData.getPointValueInDouble());
                        }
                    }
                }
            }
            Calendar c = Calendar.getInstance();

            int tempyear = c.get(Calendar.YEAR);
            int tempmonth = c.get(Calendar.MONTH) + 1;
            int daynum = c.get(Calendar.DAY_OF_MONTH);
            List<WpMttrAndMtbMonth> mmls = wpMttrAndMtbMonthService.getMttrAndMtbf(id, tempyear, tempmonth);

            if (!mmls.isEmpty()) {
                WpMttrAndMtbMonth mm = mmls.get(0);
                double stoptimes = mm.getStoprtimes();
                double stophours = mm.getStophours();
                double mttr = 0.0;
                double mtbf = mm.getWthours();
                if (stoptimes != 0) {
                    mttr = new BigDecimal(stophours).divide(new BigDecimal(stoptimes), 2, RoundingMode.HALF_EVEN).doubleValue();
                    mtbf = new BigDecimal(mm.getWthours()).divide(new BigDecimal(stoptimes), 2, RoundingMode.HALF_EVEN).doubleValue();

                }

                jczbmap.put("mttr", mttr);
                jczbmap.put("mtbf", mtbf);
            }
//            if (bzgl == 0.0) {
//                bzgl = 1.0;
//            }
//            Double glbz = new BigDecimal(sjgl).divide(new BigDecimal(bzgl), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
//            if (bzgl == 1) {
//                bzgl = 0.0;
//            }
//            if (glbz > 100) {
//                glbz = 100.0;
//            }
//            jczbmap.put("glbz", StringUtils.round(glbz, 2));


/*************************************************基础指标*************************************************************/

/***********************************************************************************************************************/

            List<String> zbls = new ArrayList<>();
            switch (id) {
                case "MHS_FDC":
//            MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0037	电压
//            MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0246	电压
//            MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0009	电流
                    zbls.add("MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0037");
                    zbls.add("MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0246");
                    zbls.add("MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0009");
                    zbls.add("MHSDJL.NX_GD_MHSF_DD_P1_L1_001_ZXYG057");

                    List<PointData> zblist = realApiUtil.getRealData(zbls);

                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();
                        double temp2 = zblist.get(1).getPointValueInDouble();
                        jczbmap.put("uab", MathUtil.twoBit(temp1 + temp2));
                        double temp3 = zblist.get(2).getPointValueInDouble();
                        jczbmap.put("ia", MathUtil.twoBit(temp3));
                        double temp4 = zblist.get(3).getPointValueInDouble();
                        jczbmap.put("dnlb", MathUtil.twoBit(temp4));
                    }
                    break;
                case "NSS_FDC":
//            NSSDQN.NX_GD_NSSF_DQ_P1_L1_001_AI0004	电压
//            NSSDQN.NX_GD_NSSF_DQ_P1_L1_001_AI0085	电压
//            NSSDQN.NX_GD_NSSF_DQ_P1_L1_001_AI0009	电流
//            NSSDQN.NX_GD_NSSF_DQ_P1_L1_001_AI0014	电流
                    zbls.add("NSSDQN.NX_GD_NSSF_DQ_P1_L1_001_AI0004");
                    zbls.add("NSSDQN.NX_GD_NSSF_DQ_P1_L1_001_AI0085");
                    zbls.add("NSSDQN.NX_GD_NSSF_DQ_P1_L1_001_AI0009");
                    zbls.add("NSSDQN.NX_GD_NSSF_DQ_P1_L1_001_AI0014");

                    zbls.add("NSSDJL.NX_GD_NSSF_DD_P1_L1_001_ZXYG025");
                    zbls.add("NSSDJL.NX_GD_NSSF_DD_P1_L1_001_ZXYG029");

                    zblist = realApiUtil.getRealData(zbls);

                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();
                        double temp2 = zblist.get(1).getPointValueInDouble();
                        jczbmap.put("uab", MathUtil.twoBit(temp1 + temp2));
                        double temp3 = zblist.get(2).getPointValueInDouble();
                        double temp4 = zblist.get(3).getPointValueInDouble();
                        jczbmap.put("ia", MathUtil.twoBit(temp3 + temp4));
                        double temp5 = zblist.get(4).getPointValueInDouble();
                        double temp6 = zblist.get(5).getPointValueInDouble();
                        jczbmap.put("dnlb", MathUtil.twoBit(temp5 + temp6));
                    }
                    break;
                case "QS_FDC":
//            QSDQ.NX_GD_QSF_DQ_P1_L1_001_AI0007	电压
//            QSDQ.NX_GD_QSF_DQ_P1_L1_001_AI0324	电流
//            SLDQ.NX_GD_QSF_DQ_P1_L1_001_AI0009	电压
//            SLDQ.NX_GD_QSF_DQ_P1_L1_001_AI0004	电流
                    zbls.add("NX_GD_QSF_DQ_P1_L1_001_AI0007");
                    zbls.add("SLDQ.NX_GD_QSF_DQ_P1_L1_001_AI0009");
                    zbls.add("QSDQ.NX_GD_QSF_DQ_P1_L1_001_AI0324");
                    zbls.add("SLDQ.NX_GD_QSF_DQ_P1_L1_001_AI0004");

//            QSDJL.NX_GD_QSF_DD_P1_L1_001_ZXYG001
//            SLDJL.NX_GD_QSF_DD_P1_L1_001_ZXYG001
                    zbls.add("QSDJL.NX_GD_QSF_DD_P1_L1_001_ZXYG001");
                    zbls.add("SLDJL.NX_GD_QSF_DD_P1_L1_001_ZXYG001");
                    zblist = realApiUtil.getRealData(zbls);
                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();
                        double temp2 = zblist.get(1).getPointValueInDouble();
                        jczbmap.put("uab", MathUtil.twoBit(temp1 + temp2));
                        double temp3 = zblist.get(2).getPointValueInDouble();
                        double temp4 = zblist.get(3).getPointValueInDouble();
                        jczbmap.put("ia", MathUtil.twoBit(temp3 + temp4));
                        double temp5 = zblist.get(4).getPointValueInDouble();
                        double temp6 = zblist.get(5).getPointValueInDouble();

                        jczbmap.put("dnlb", MathUtil.twoBit(temp5 + temp6));
                    }
                    break;
                case "SBQ_FDC":
//            SBQXLDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0133	电压
//            SBQNWDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0141	电压
//            SBQXLDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0009	电流
//            SBQNWDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0681	电流
                    zbls.add("SBQXLDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0133");
                    zbls.add("SBQNWDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0141");
                    zbls.add("SBQXLDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0009");
                    zbls.add("SBQNWDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0681");

                    zbls.add("SBQDJL.NX_GD_SBQF_DD_P1_L1_001_ZXYG009");
                    zbls.add("SBQDJL.NX_GD_SBQF_DD_P1_L1_001_ZXYG061");
                    zbls.add("SBQDJL.NX_GD_SBQF_DD_P1_L1_001_ZXYG109");
//            SBQDJL.NX_GD_SBQF_DD_P1_L1_001_ZXYG009
//            SBQDJL.NX_GD_SBQF_DD_P1_L1_001_ZXYG061
//            SBQDJL.NX_GD_SBQF_DD_P1_L1_001_ZXYG109
                    zblist = realApiUtil.getRealData(zbls);

                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();
                        double temp2 = zblist.get(1).getPointValueInDouble();
                        jczbmap.put("uab", MathUtil.twoBit(temp1 + temp2));
                        double temp3 = zblist.get(2).getPointValueInDouble();
                        double temp4 = zblist.get(3).getPointValueInDouble();
                        jczbmap.put("ia", MathUtil.twoBit(temp3 + temp4));
                        double temp5 = zblist.get(4).getPointValueInDouble();
                        double temp6 = zblist.get(5).getPointValueInDouble();
                        double temp7 = zblist.get(6).getPointValueInDouble();
                        jczbmap.put("dnlb", MathUtil.twoBit(temp5 + temp6 + temp7));
                    }
                    break;
                case "XS_FDC":
//            XSDQ.NX_GD_XSF_DQ_P1_L1_001_AI0007	电压
//            XSDQ.NX_GD_XSF_DQ_P1_L1_001_AI0010	电流
                    zbls.add("XSDQ.NX_GD_XSF_DQ_P1_L1_001_AI0007");
                    zbls.add("XSDQ.NX_GD_XSF_DQ_P1_L1_001_AI0010");
//            XSDJL.NX_GD_XSF_DD_P1_L1_001_ZXYG017
                    zbls.add("XSDJL.NX_GD_XSF_DD_P1_L1_001_ZXYG017");
                    zblist = realApiUtil.getRealData(zbls);

                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();
                        jczbmap.put("uab", MathUtil.twoBit(temp1));
                        double temp3 = zblist.get(1).getPointValueInDouble();
                        jczbmap.put("ia", MathUtil.twoBit(temp3));
                        double temp2 = zblist.get(2).getPointValueInDouble();
                        jczbmap.put("dnlb", MathUtil.twoBit(temp2));
                    }
                    break;
                case "DWK_GDC":
//            DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0004	电压
//            DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0001	电流
                    zbls.add("DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0004");
                    zbls.add("DWKDQ.NX_GD_DWKG_DQ_P1_L1_001_AI0001");
                    zbls.add("DWKDJL.NX_GD_DWKG_DD_P1_L1_001_ZXYG001");

                    zblist = realApiUtil.getRealData(zbls);

                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();

                        jczbmap.put("uab", MathUtil.twoBit(temp1));
                        double temp3 = zblist.get(1).getPointValueInDouble();

                        jczbmap.put("ia", MathUtil.twoBit(temp3));
                        double temp2 = zblist.get(2).getPointValueInDouble();

                        jczbmap.put("dnlb", MathUtil.twoBit(temp2));
                    }
                    break;
                case "PL_GDC":
//            PLSJ1.NX_GD_PLG_DQ_P1_L1_001_AI0001	电压
//            PLSJ1.NX_GD_PLG_DQ_P1_L1_001_AI0013	电压
//            PLSJ1.NX_GD_PLG_DQ_P1_L1_001_AI0047	电流
//            PLSJ1.NX_GD_PLG_DQ_P1_L1_001_AI0007	电流
                    zbls.add("PLSJ1.NX_GD_PLG_DQ_P1_L1_001_AI0001");
                    zbls.add("PLSJ1.NX_GD_PLG_DQ_P1_L1_001_AI0013");
                    zbls.add("PLSJ1.NX_GD_PLG_DQ_P1_L1_001_AI0047");
                    zbls.add("PLSJ1.NX_GD_PLG_DQ_P1_L1_001_AI0007");

                    zbls.add("PLSJ1.NX_GD_PLG_DQ_P1_L1_001_PI0963");
//            PLSJ1.NX_GD_PLG_DQ_P1_L1_001_PI0963
                    zblist = realApiUtil.getRealData(zbls);

                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();
                        double temp2 = zblist.get(1).getPointValueInDouble();
                        jczbmap.put("uab", MathUtil.twoBit(temp1 + temp2));
                        double temp3 = zblist.get(2).getPointValueInDouble();
                        double temp4 = zblist.get(3).getPointValueInDouble();
                        jczbmap.put("ia", MathUtil.twoBit(temp3 + temp4));
                        double temp5 = zblist.get(4).getPointValueInDouble();

                        jczbmap.put("dnlb", MathUtil.twoBit(temp5));
                    }
                    break;
                case "XH_GDC":

//            XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0004	电压
//            XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0001	电流
                    zbls.add("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0004");
                    zbls.add("XHDQ.NX_GD_XHG_DQ_P1_L1_001_AI0001");
                    zbls.add("XHDJL.NX_GD_XHG_DD_P1_L1_001_ZXYG001");
//            XHDJL.NX_GD_XHG_DD_P1_L1_001_ZXYG001
                    zblist = realApiUtil.getRealData(zbls);
                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();
                        jczbmap.put("uab", MathUtil.twoBit(temp1));
                        double temp3 = zblist.get(1).getPointValueInDouble();

                        jczbmap.put("ia", MathUtil.twoBit(temp3));
                        double temp5 = zblist.get(2).getPointValueInDouble();

                        jczbmap.put("dnlb", MathUtil.twoBit(temp5));
                    }

                    break;
                case "MCH_GDC":
//            MCHDQ.NX_GD_MCHG_DQ_P1_L1_001_AI0212	电压
//            MCHDQ.NX_GD_MCHG_DQ_P1_L1_001_AI0044	电压
//            "MCHDQ.NX_GD_MCHG_DQ_P1_L1_001_AI0013	"	电流
                    zbls.add("MCHDQ.NX_GD_MCHG_DQ_P1_L1_001_AI0212");
                    zbls.add("MCHDQ.NX_GD_MCHG_DQ_P1_L1_001_AI0044");
                    zbls.add("MCHDQ.NX_GD_MCHG_DQ_P1_L1_001_AI0013");

                    zblist = realApiUtil.getRealData(zbls);

                    if (!zblist.isEmpty() && zblist.size() == zbls.size()) {
                        double temp1 = zblist.get(0).getPointValueInDouble();
                        double temp2 = zblist.get(1).getPointValueInDouble();
                        jczbmap.put("uab", MathUtil.twoBit(temp1 + temp2));
                        double temp3 = zblist.get(2).getPointValueInDouble();

                        jczbmap.put("ia", MathUtil.twoBit(temp3));
                    }
                    break;
                default:
                    break;
            }


/*************************************************************************************************************************/
/*************************************************测风塔*************************************************************/

            if (InitialRunner.wpmap.containsKey(id)) {
                WindPowerStationTestingPoint point2 = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.FCCFTFX30);

                if (StringUtils.notEmp(point2.getCode())) {
                    PointData value = realApiUtil.getRealData(point2);
                    jczbmap.put("cftfx", MathUtil.twoBit(value.getPointValueInDouble()));
                }
                point2 = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.FCCFTFS30);

                if (StringUtils.notEmp(point2.getCode())) {
                    PointData value = realApiUtil.getRealData(point2);
                    jczbmap.put("cftfs", MathUtil.twoBit(value.getPointValueInDouble()));
                }

                //map.put(wp.getId() + "cftmap", cftmap);
            }

/*************************************************测风塔*************************************************************/

/*************************************************6种状态*************************************************************/

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

            List<String> ztls = new ArrayList<>();
            //待机台数
            ztls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WT_DJTS).getCode());
            //运行台数
            ztls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WT_YXTS).getCode());
            //故障台数
            ztls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WT_GZTJ).getCode());
            //离线台数
            ztls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WT_TXZD).getCode());
            //维护台数
            ztls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WT_WHTJ).getCode());
            //限电台数
            ztls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WT_XDTS).getCode());


            List<PointData> ztlist = realApiUtil.getRealData(ztls);

            if (!ztlist.isEmpty() && ztlist.size() == ztls.size()) {
                jczbmap.put("djts", MathUtil.twoBit(ztlist.get(0).getPointValueInDouble()));
                jczbmap.put("yxts", MathUtil.twoBit(ztlist.get(1).getPointValueInDouble()));
                jczbmap.put("gzts", MathUtil.twoBit(ztlist.get(2).getPointValueInDouble()));
                jczbmap.put("lxts", MathUtil.twoBit(ztlist.get(3).getPointValueInDouble()));
                jczbmap.put("whts", MathUtil.twoBit(ztlist.get(4).getPointValueInDouble()));
                jczbmap.put("xdts", MathUtil.twoBit(ztlist.get(5).getPointValueInDouble()));

            } else {

                jczbmap.put("djts", 0.0);
                jczbmap.put("yxts", 0.0);
                jczbmap.put("gzts", 0.0);
                jczbmap.put("lxts", 0.0);
                jczbmap.put("whts", 0.0);
                jczbmap.put("xdts", 0.0);

            }
            map.put("maps", maps);
//

/*************************************************6种状态*************************************************************/

/*************************************************五项损失**************************************************************/

//            Map<String, Double> wxssmap = new HashMap<>();
//            List<String> wxssls = new ArrayList<>();
//
//            // 日场内受累检修
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RLZSSDL).getCode());
//            // 日场内受累故障
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSZSSDL).getCode());
//            // 月场内受累检修
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YLZSSDL).getCode());
//            // 月场内受累故障
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YSZSSDL).getCode());
//            // 年场内受累检修
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NLZSSDL).getCode());
//            // 年场内受累故障
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NSZSSDL).getCode());
//
//            //日待机损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSDJZSDL).getCode());
//            //日手动停机损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSSTZSDL).getCode());
//            //日性能损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RXNZSDL).getCode());
//            //日缺陷降出力损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSQXZSDL).getCode());
//            //日故障损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RGZSSDL).getCode());
//            //日检修损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RJXSSDL).getCode());
//
//            //月待机损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YSDJZSDL).getCode());
//            //月手动停机损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YSSTZSDL).getCode());
//            //月性能损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YXNZSDL).getCode());
//            //月缺陷降出力损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YSQXZSDL).getCode());
//            //月故障损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YGZSSDL).getCode());
//            //月检修损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YJXSSDL).getCode());
//
//
//            //年待机损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NSDJZSDL).getCode());
//            //年手动停机损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NSSTZSDL).getCode());
//            //年性能损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NXNZSDL).getCode());
//            //年缺陷降出力损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NSQXZSDL).getCode());
//            //年故障损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NGZSSDL).getCode());
//            //年检修损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NJXSSDL).getCode());
//
//
//            //日限电损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RXDSSDL).getCode());
//            //月限电损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YXDSSDL).getCode());
//            //年限电损失
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NXDSSDL).getCode());
//
//
//            //日场外受累电网
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RWZSSDL).getCode());
//            // 日场外受累天气
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RTZSSDL).getCode());
//            // 月场外受累电网
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YWZSSDL).getCode());
//            // 月场外受累天气
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YTZSSDL).getCode());
//            // 年场外受累电网
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NWZSSDL).getCode());
//            // 年场外受累天气
//            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NTZSSDL).getCode());
//
//
//            List<PointData> wxsslist = realApiUtil.getRealData(wxssls);
//
//            if (!wxsslist.isEmpty() && wxsslist.size() == wxssls.size()) {
//
//                Double rjxsl = MathUtil.twoBit(wxsslist.get(0).getPointValueInDouble());
//                // 日场内受累故障
//                Double rgzzsl = MathUtil.twoBit(wxsslist.get(1).getPointValueInDouble());
//                // 月场内受累检修
//                Double yjxsl = MathUtil.twoBit(wxsslist.get(2).getPointValueInDouble());
//                // 月场内受累故障
//                Double ygzzsl = MathUtil.twoBit(wxsslist.get(3).getPointValueInDouble());
//                // 年场内受累检修
//                Double njxsl = MathUtil.twoBit(wxsslist.get(4).getPointValueInDouble());
//                // 年场内受累故障
//                Double ngzzsl = MathUtil.twoBit(wxsslist.get(5).getPointValueInDouble());
//
//                wxssmap.put("rjxsl", rjxsl);
//                wxssmap.put("rgzzsl", rgzzsl);
//                wxssmap.put("yjxsl", yjxsl);
//                wxssmap.put("ygzzsl", ygzzsl);
//                wxssmap.put("njxsl", njxsl);
//                wxssmap.put("ngzzsl", ngzzsl);
//
//                //日待机损失
//                Double rdjss = MathUtil.twoBit(wxsslist.get(6).getPointValueInDouble());
//                //日手动停机损失
//                Double rsdtjss = MathUtil.twoBit(wxsslist.get(7).getPointValueInDouble());
//                //日性能损失
//                Double rxnss = MathUtil.twoBit(wxsslist.get(8).getPointValueInDouble());
//                //日缺陷降出力损失
//                Double rqxjclss = MathUtil.twoBit(wxsslist.get(9).getPointValueInDouble());
//
//                //日欠发损失=日待机损失+日手动停机损失+日性能损失+日缺陷降出力损失
//                Double rqfssdl = new BigDecimal(rdjss + rsdtjss + rxnss + rqxjclss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//
//                Double rgzss = MathUtil.twoBit(wxsslist.get(10).getPointValueInDouble());
//                //日故障损失电量=日故障损失+日故障受累
//                Double rgzssdl = new BigDecimal(rgzss + rgzzsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//                //日检修损失电量=日检修损失+日检修受累
//                Double rjxss = MathUtil.twoBit(wxsslist.get(11).getPointValueInDouble());
//                Double rjxssdl = new BigDecimal(rjxss + rjxsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//
//
//                wxssmap.put("rqfssdl", rqfssdl);
//                wxssmap.put("rgzssdl", rgzssdl);
//                wxssmap.put("rjxssdl", rjxssdl);
//
//                // 月场内受累检修
//                Double ydjss = MathUtil.twoBit(wxsslist.get(12).getPointValueInDouble());
//                // 月场内受累检修
//                Double ysdtjss = MathUtil.twoBit(wxsslist.get(13).getPointValueInDouble());
//                // 月场内受累检修
//                Double yxnss = MathUtil.twoBit(wxsslist.get(14).getPointValueInDouble());
//                // 月场内受累检修
//                Double yqxjclss = MathUtil.twoBit(wxsslist.get(15).getPointValueInDouble());
//                //月欠发损失=月待机损失+月手动停机损失+月性能损失+月缺陷降出力损失
//                Double yqfssdl = new BigDecimal(ydjss + ysdtjss + yxnss + yqxjclss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//
//                Double ygzss = MathUtil.twoBit(wxsslist.get(16).getPointValueInDouble());
//                //月故障损失电量=月故障损失+月故障受累
//                Double ygzssdl = new BigDecimal(ygzss + ygzzsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//                Double yjxss = MathUtil.twoBit(wxsslist.get(17).getPointValueInDouble());
//                //月检修损失电量=月检修损失+月检修受累
//                Double yjxssdl = new BigDecimal(yjxss + yjxsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//
//                wxssmap.put("yqfssdl", yqfssdl);
//                wxssmap.put("ygzssdl", ygzssdl);
//                wxssmap.put("yjxssdl", yjxssdl);
//
//                // 年场内受累检修
//                Double ndjss = MathUtil.twoBit(wxsslist.get(18).getPointValueInDouble());
//                // 年场内受累检修
//                Double nsdtjss = MathUtil.twoBit(wxsslist.get(19).getPointValueInDouble());
//                // 年场内受累检修
//                Double nxnss = MathUtil.twoBit(wxsslist.get(20).getPointValueInDouble());
//                // 年场内受累检修
//                Double nqxjclss = MathUtil.twoBit(wxsslist.get(21).getPointValueInDouble());
//
//                Double nqfssdl = new BigDecimal(ndjss + nsdtjss + nxnss + nqxjclss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//
//                Double ngzss = MathUtil.twoBit(wxsslist.get(22).getPointValueInDouble());
//                //年故障损失电量=年故障损失+年故障受累
//                Double ngzssdl = new BigDecimal(ngzss + ngzzsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//                Double njxss = MathUtil.twoBit(wxsslist.get(23).getPointValueInDouble());
//                //年检修损失电量=年检修损失+年检修受累
//                Double njxssdl = new BigDecimal(njxss + njxsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//
//                wxssmap.put("nqfssdl", nqfssdl);
//                wxssmap.put("ngzssdl", ngzssdl);
//                wxssmap.put("njxssdl", njxssdl);
//
//                double temp = 0.0;
//                temp = MathUtil.twoBit(wxsslist.get(24).getPointValueInDouble());
//                Double rxdssdl = new BigDecimal(temp).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//                temp = MathUtil.twoBit(wxsslist.get(25).getPointValueInDouble());
//                Double yxdssdl = new BigDecimal(temp).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//                temp = MathUtil.twoBit(wxsslist.get(26).getPointValueInDouble());
//                Double nxdssdl = new BigDecimal(temp).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//
//                wxssmap.put("rxdssdl", StringUtils.round(rxdssdl < 0.0 ? 0.0 : rxdssdl, 2));
//                wxssmap.put("yxdssdl", StringUtils.round(yxdssdl < 0.0 ? 0.0 : yxdssdl, 2));
//                wxssmap.put("nxdssdl", StringUtils.round(nxdssdl < 0.0 ? 0.0 : nxdssdl, 2));
//
//                Double rdwsl = MathUtil.twoBit(wxsslist.get(27).getPointValueInDouble());
//                Double rtqsl = MathUtil.twoBit(wxsslist.get(28).getPointValueInDouble());
//                Double rslssdl = new BigDecimal(rdwsl + rtqsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//                Double ydwsl = MathUtil.twoBit(wxsslist.get(29).getPointValueInDouble());
//                Double ytqsl = MathUtil.twoBit(wxsslist.get(30).getPointValueInDouble());
//                Double yslssdl = new BigDecimal(ydwsl + ytqsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//                Double ndwsl = MathUtil.twoBit(wxsslist.get(31).getPointValueInDouble());
//                Double ntqsl = MathUtil.twoBit(wxsslist.get(32).getPointValueInDouble());
//                Double nslssdl = new BigDecimal(ndwsl + ntqsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
//
//                wxssmap.put("rslssdl", rslssdl);
//                wxssmap.put("yslssdl", yslssdl);
//                wxssmap.put("nslssdl", nslssdl);
//
//            } else {
//
//                wxssmap.put("rjxsl", 0.0);
//                wxssmap.put("rgzzsl", 0.0);
//                wxssmap.put("yjxsl", 0.0);
//                wxssmap.put("ygzzsl", 0.0);
//                wxssmap.put("njxsl", 0.0);
//                wxssmap.put("ngzzsl", 0.0);
//                wxssmap.put("rqfssdl", 0.0);
//                wxssmap.put("rgzssdl", 0.0);
//                wxssmap.put("rjxssdl", 0.0);
//
//                wxssmap.put("yqfssdl", 0.0);
//                wxssmap.put("ygzssdl", 0.0);
//                wxssmap.put("yjxssdl", 0.0);
//
//                wxssmap.put("nqfssdl", 0.0);
//                wxssmap.put("ngzssdl", 0.0);
//                wxssmap.put("njxssdl", 0.0);
//
//
//                wxssmap.put("rxdssdl", 0.0);
//                wxssmap.put("yxdssdl", 0.0);
//                wxssmap.put("nxdssdl", 0.0);
//
//
//                wxssmap.put("rslssdl", 0.0);
//                wxssmap.put("yslssdl", 0.0);
//                wxssmap.put("nslssdl", 0.0);
//
//            }
//            map.put("wxssmap", wxssmap);


            Map<String, Double> wxssmap = new HashMap<>();
            List<String> wxssls = new ArrayList<>();

            // 日场内受累检修
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RLZSSDL).getCode());
            // 日场内受累故障
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSZSSDL).getCode());
            //日待机损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSDJZSDL).getCode());
            //日手动停机损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSSTZSDL).getCode());
            //日性能损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RXNZSDL).getCode());
            //日缺陷降出力损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSQXZSDL).getCode());
            //日故障损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RGZSSDL).getCode());
            //日检修损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RJXSSDL).getCode());
            //日限电损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RXDSSDL).getCode());

            //日场外受累电网
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RWZSSDL).getCode());
            // 日场外受累天气
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RTZSSDL).getCode());

            List<PointData> wxsslist = realApiUtil.getRealData(wxssls);

            if (!wxsslist.isEmpty() && wxsslist.size() == wxssls.size()) {

                Double rjxsl = MathUtil.twoBit(wxsslist.get(0).getPointValueInDouble());
                // 日场内受累故障
                Double rgzzsl = MathUtil.twoBit(wxsslist.get(1).getPointValueInDouble());


                wxssmap.put("rjxsl", rjxsl);
                wxssmap.put("rgzzsl", rgzzsl);


                //日待机损失
                Double rdjss = MathUtil.twoBit(wxsslist.get(2).getPointValueInDouble());
                //日手动停机损失
                Double rsdtjss = MathUtil.twoBit(wxsslist.get(3).getPointValueInDouble());
                //日性能损失
                Double rxnss = MathUtil.twoBit(wxsslist.get(4).getPointValueInDouble());
                //日缺陷降出力损失
                Double rqxjclss = MathUtil.twoBit(wxsslist.get(5).getPointValueInDouble());

                //日欠发损失=日待机损失+日手动停机损失+日性能损失+日缺陷降出力损失
                Double rqfssdl = new BigDecimal(rdjss + rsdtjss + rxnss + rqxjclss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                Double rgzss = MathUtil.twoBit(wxsslist.get(6).getPointValueInDouble());
                //日故障损失电量=日故障损失+日故障受累
                Double rgzssdl = new BigDecimal(rgzss + rgzzsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                //日检修损失电量=日检修损失+日检修受累
                Double rjxss = MathUtil.twoBit(wxsslist.get(7).getPointValueInDouble());
                Double rjxssdl = new BigDecimal(rjxss + rjxsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();


                vo.setWhss(rjxssdl);
                vo.setGzss(rgzssdl);
                vo.setXnss(rqfssdl);
//                wxssmap.put("rqfssdl", rqfssdl);
//                wxssmap.put("rgzssdl", rgzssdl);
//                wxssmap.put("rjxssdl", rjxssdl);


                double temp = 0.0;
                temp = MathUtil.twoBit(wxsslist.get(8).getPointValueInDouble());
                Double rxdssdl = new BigDecimal(temp).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                // wxssmap.put("rxdssdl", StringUtils.round(rxdssdl < 0.0 ? 0.0 : rxdssdl, 2));
                vo.setXdss(rxdssdl);
                Double rdwsl = MathUtil.twoBit(wxsslist.get(9).getPointValueInDouble());
                Double rtqsl = MathUtil.twoBit(wxsslist.get(10).getPointValueInDouble());
                Double rslssdl = new BigDecimal(rdwsl + rtqsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                //wxssmap.put("rslssdl", rslssdl);
                vo.setSlss(rslssdl);
                vo.setLlfdl(MathUtil.twoBit(scadafdl + rjxssdl + rgzssdl + rqfssdl + rxdssdl + rslssdl));

            } else {

                wxssmap.put("rjxsl", 0.0);
                wxssmap.put("rgzzsl", 0.0);
                wxssmap.put("rqfssdl", 0.0);
                wxssmap.put("rgzssdl", 0.0);
                wxssmap.put("rjxssdl", 0.0);
                wxssmap.put("rxdssdl", 0.0);
                wxssmap.put("rslssdl", 0.0);


            }
            // map.put("wxssmap", wxssmap);

/****************************************************五项损失************************************************************/


/*************************************************关系库指标**************************************************************/
//
//            Map<String, Double> gxkmap = new HashMap<>();
//            List<Windpowerinfoday> wpdls = windpowerinfodayService.getWindpowerinfodayList(id, DateUtils.truncate(new Date()));
//            if (!wpdls.isEmpty()) {
//                Windpowerinfoday wd = wpdls.get(0);
//                gxkmap.put("ndxkyss", wd.getYeardxkyxs());
//                gxkmap.put("nsbklyl", wd.getYearsbklyl());
//
//                gxkmap.put("ydxkyss", wd.getMonthdxkyxs());
//                gxkmap.put("ysbklyl", wd.getMonthsbklyl());
//
//            } else {
//                gxkmap.put("ndxkyss", 0.0);
//                gxkmap.put("nsbklyl", 0.0);
//                gxkmap.put("ydxkyss", 0.0);
//                gxkmap.put("ysbklyl", 0.0);
//            }
//            map.put("gxkmap", gxkmap);

/*************************************************关系库指标**************************************************************/
            vos.add(vo);

            maps.add(jczbmap);
        }

        int gfsl = 0;
        int fcsl = 0;
        ZtjsVo gfvo = new ZtjsVo();
        gfvo.setWpId("-2");
        gfvo.setWpName("光伏合计");
        initalVo(gfvo);
        ZtjsVo fcvo = new ZtjsVo();
        fcvo.setWpId("-1");
        fcvo.setWpName("风电合计");
        initalVo(fcvo);
        ZtjsVo qsvo = new ZtjsVo();
        qsvo.setWpId("0");
        qsvo.setWpName("总计");
        initalVo(qsvo);
        for (ZtjsVo vo : vos) {
            if (vo.getWpId().endsWith("FDC")) {

                fcvo.setZjrl(fcvo.getZjrl() + vo.getZjrl());
                fcvo.setFdl(fcvo.getFdl() + vo.getFdl());
                fcvo.setSwdl(fcvo.getSwdl() + vo.getSwdl());
                fcvo.setLyxs(fcvo.getLyxs() + vo.getLyxs());
                fcvo.setFs(fcvo.getFs() + vo.getFs());
                fcvo.setGl(fcvo.getGl() + vo.getGl());
                fcvo.setCxgl(fcvo.getCxgl() + vo.getCxgl());
                fcvo.setLlgl(fcvo.getLlgl() + vo.getLlgl());
                fcvo.setBzgl(fcvo.getBzgl() + vo.getBzgl());
                fcvo.setYcgl(fcvo.getYcgl() + vo.getYcgl());
                fcvo.setAGCzl(fcvo.getAGCzl() + vo.getAGCzl());
                fcvo.setLlfdl(fcvo.getLlfdl() + vo.getLlfdl());
                fcvo.setScadafdl(fcvo.getScadafdl() + vo.getScadafdl());
                fcvo.setWhss(fcvo.getWhss() + vo.getWhss());
                fcvo.setGzss(fcvo.getGzss() + vo.getGzss());
                fcvo.setSlss(fcvo.getSlss() + vo.getSlss());
                fcvo.setXdss(fcvo.getXdss() + vo.getXdss());
                fcvo.setXnss(fcvo.getXnss() + vo.getXnss());

                fcsl++;
            } else if (vo.getWpId().endsWith("GDC")) {
                gfvo.setZjrl(gfvo.getZjrl() + vo.getZjrl());
                gfvo.setFdl(gfvo.getFdl() + vo.getFdl());
                gfvo.setSwdl(gfvo.getSwdl() + vo.getSwdl());
                gfvo.setLyxs(gfvo.getLyxs() + vo.getLyxs());
                gfvo.setFs(gfvo.getFs() + vo.getFs());
                gfvo.setGl(gfvo.getGl() + vo.getGl());
                gfvo.setCxgl(gfvo.getCxgl() + vo.getCxgl());
                gfvo.setLlgl(gfvo.getLlgl() + vo.getLlgl());
                gfvo.setBzgl(gfvo.getBzgl() + vo.getBzgl());
                gfvo.setYcgl(gfvo.getYcgl() + vo.getYcgl());
                gfvo.setAGCzl(gfvo.getAGCzl() + vo.getAGCzl());
                gfvo.setLlfdl(gfvo.getLlfdl() + vo.getLlfdl());
                gfvo.setScadafdl(gfvo.getScadafdl() + vo.getScadafdl());
                gfvo.setWhss(gfvo.getWhss() + vo.getWhss());
                gfvo.setGzss(gfvo.getGzss() + vo.getGzss());
                gfvo.setSlss(gfvo.getSlss() + vo.getSlss());
                gfvo.setXdss(gfvo.getXdss() + vo.getXdss());
                gfvo.setXnss(gfvo.getXnss() + vo.getXnss());
                gfsl++;
            }

            qsvo.setZjrl(qsvo.getZjrl() + vo.getZjrl());
            qsvo.setFdl(qsvo.getFdl() + vo.getFdl());
            qsvo.setSwdl(qsvo.getSwdl() + vo.getSwdl());
            qsvo.setLyxs(qsvo.getLyxs() + vo.getLyxs());
            qsvo.setFs(qsvo.getFs() + vo.getFs());
            qsvo.setGl(qsvo.getGl() + vo.getGl());
            qsvo.setCxgl(qsvo.getCxgl() + vo.getCxgl());
            qsvo.setLlgl(qsvo.getLlgl() + vo.getLlgl());
            qsvo.setBzgl(qsvo.getBzgl() + vo.getBzgl());
            qsvo.setYcgl(qsvo.getYcgl() + vo.getYcgl());
            qsvo.setAGCzl(qsvo.getAGCzl() + vo.getAGCzl());
            qsvo.setLlfdl(qsvo.getLlfdl() + vo.getLlfdl());
            qsvo.setScadafdl(qsvo.getScadafdl() + vo.getScadafdl());
            qsvo.setWhss(qsvo.getWhss() + vo.getWhss());
            qsvo.setGzss(qsvo.getGzss() + vo.getGzss());
            qsvo.setSlss(qsvo.getSlss() + vo.getSlss());
            qsvo.setXdss(qsvo.getXdss() + vo.getXdss());
            qsvo.setXnss(qsvo.getXnss() + vo.getXnss());
        }

        if (fcsl != 0) {
            Double fs = new BigDecimal(fcvo.getFs()).divide(new BigDecimal(fcsl), 2, RoundingMode.HALF_EVEN).doubleValue();

            fcvo.setFs(fs);
        }

        if (gfsl != 0) {
            Double fs = new BigDecimal(gfvo.getFs()).divide(new BigDecimal(gfsl), 2, RoundingMode.HALF_EVEN).doubleValue();

            gfvo.setFs(fs);
        }
        if (vos.size() != 0) {
            Double fs = new BigDecimal(qsvo.getFs()).divide(new BigDecimal(vos.size()), 2, RoundingMode.HALF_EVEN).doubleValue();

            qsvo.setFs(fs);
        }

        List<ZtjsVo> result = new ArrayList<>();

        for (ZtjsVo vo : vos) {
            if (vo.getWpId().endsWith("FDC")) {

                result.add(vo);

            }
        }
        roundVo(fcvo);
        result.add(fcvo);
        for (ZtjsVo vo : vos) {
            if (vo.getWpId().endsWith("GDC")) {

                result.add(vo);
            }
        }
        roundVo(gfvo);
        result.add(gfvo);
        roundVo(qsvo);
        result.add(qsvo);
        map.put("vos", result);
        return map;
    }

    public void initalVo(ZtjsVo vo) {

        vo.setZjrl(0.0);
        vo.setFdl(0.0);
        vo.setSwdl(0.0);
        vo.setLyxs(0.0);
        vo.setFs(0.0);
        vo.setGl(0.0);
        vo.setCxgl(0.0);
        vo.setLlgl(0.0);
        vo.setBzgl(0.0);
        vo.setYcgl(0.0);
        vo.setAGCzl(0.0);
        vo.setLlfdl(0.0);
        vo.setScadafdl(0.0);
        vo.setWhss(0.0);
        vo.setGzss(0.0);
        vo.setSlss(0.0);
        vo.setXdss(0.0);
        vo.setXnss(0.0);

    }

    public void roundVo(ZtjsVo vo) {

        vo.setZjrl(MathUtil.twoBit(vo.getZjrl()));
        vo.setFdl(MathUtil.twoBit(vo.getFdl()));
        vo.setSwdl(MathUtil.twoBit(vo.getSwdl()));
        vo.setLyxs(MathUtil.twoBit(vo.getLyxs()));
        vo.setFs(MathUtil.twoBit(vo.getFs()));
        vo.setGl(MathUtil.twoBit(vo.getGl()));
        vo.setCxgl(MathUtil.twoBit(vo.getCxgl()));
        vo.setLlgl(MathUtil.twoBit(vo.getLlgl()));
        vo.setBzgl(MathUtil.twoBit(vo.getBzgl()));
        vo.setYcgl(MathUtil.twoBit(vo.getYcgl()));
        vo.setAGCzl(MathUtil.twoBit(vo.getAGCzl()));
        vo.setLlfdl(MathUtil.twoBit(vo.getLlfdl()));
        vo.setScadafdl(MathUtil.twoBit(vo.getScadafdl()));
        vo.setWhss(MathUtil.twoBit(vo.getWhss()));
        vo.setGzss(MathUtil.twoBit(vo.getGzss()));
        vo.setSlss(MathUtil.twoBit(vo.getSlss()));
        vo.setXdss(MathUtil.twoBit(vo.getXdss()));
        vo.setXnss(MathUtil.twoBit(vo.getXnss()));

    }


    /**
     * 获取风场监视页面
     *
     * @param wpId
     * @return
     * @throws Exception
     */
    public Map<String, Object> findWpInfoBy(String wpId) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();

        List<ZtjsVo> vos = new ArrayList<>();
        List<Map<String, Object>> maps = new ArrayList<>();

        if (InitialRunner.wpmap.containsKey(wpId)) {

            Windpowerstation wp = InitialRunner.wpmap.get(wpId);


            Map<String, Object> jczbmap = new HashMap<String, Object>();
            String id = wp.getId();

            Double zjrl = 0.0;
            Double zjts = 0.0;

            Double sjgl = 0.0;
            Double bzgl = 0.0;
            Double yfgl = 0.0;

/*************************************************基础指标*************************************************************/

            zjrl = wp.getCapacity();
            zjts = Double.valueOf(wp.getQuantity());
            jczbmap.put("name", wp.getName());
            jczbmap.put("zjrl", zjrl);

            Map<String, Object> tqmap = weatherService.getWeatherRealInfo(id);
            map.put("tqmap", tqmap);
            List<String> jczbls = new ArrayList<>();

            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_RFDL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_YFDL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_NFDL).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_SSFS).getCode());
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.TPOINT_WP_SJGL).getCode());

            //待机台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.DJNUM).getCode());
            //手动停机台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.TJNUM).getCode());
            //正常发电台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.FDNUM).getCode());
            // 缺陷降出力台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.FDJCLNUM).getCode());
            // 限电降出力台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.XDJCLNUM).getCode());
            // 限电停机台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.XDTJNUM).getCode());
            // 故障停机台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.GZNUM).getCode());
            // 场内受累停机台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.CNGZNUM).getCode());
            // 检修停机台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.JXNUM).getCode());
            // 场内受累检修台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.CNJXNUM).getCode());
            // 电网受累台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.DWSLNUM).getCode());
            // 环境受累台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.HJSLNUM).getCode());
            // 风机离线台数
            jczbls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wp.getId(), Constant.LXNUM).getCode());


            List<PointData> jczblist = realApiUtil.getRealData(jczbls);

            if (!jczblist.isEmpty() && jczblist.size() == jczbls.size()) {
                //日发电量
                double rfdl = MathUtil.twoBit(jczblist.get(0).getPointValueInDouble());

                jczbmap.put("rfdl", rfdl);

                //月发电量
                double yfdl = MathUtil.twoBit(jczblist.get(1).getPointValueInDouble());
                jczbmap.put("yfdl", yfdl);
                //年发电量
                double nfdl = MathUtil.twoBit(jczblist.get(2).getPointValueInDouble());
                jczbmap.put("nfdl", nfdl);
                //月利用小时
                double ylyxs = (new BigDecimal(jczblist.get(1).getPointValueInDouble()).multiply(new BigDecimal(10))).divide(new BigDecimal(zjrl), 2, RoundingMode.HALF_EVEN).doubleValue();
                jczbmap.put("ylyxs", ylyxs);
                //年利用小时
                double nlyxs = (new BigDecimal(jczblist.get(2).getPointValueInDouble()).multiply(new BigDecimal(10))).divide(new BigDecimal(zjrl), 2, RoundingMode.HALF_EVEN).doubleValue();
                jczbmap.put("nlyxs", nlyxs);
                //实时风速
                double ssfs = MathUtil.twoBit(jczblist.get(3).getPointValueInDouble());
                jczbmap.put("ssfs", ssfs);
                //实际功率
                sjgl = MathUtil.twoBit(jczblist.get(4).getPointValueInDouble());

                jczbmap.put("sjgl", sjgl);


                //待机台数
                Double djnum = MathUtil.twoBit(jczblist.get(5).getPointValueInDouble());
                jczbmap.put("djnum", djnum);
                //手动停机台数
                Double sdtjnum = MathUtil.twoBit(jczblist.get(6).getPointValueInDouble());
                jczbmap.put("sdtjts", sdtjnum);
                //正常发电台数
                Double zcfdnum = MathUtil.twoBit(jczblist.get(7).getPointValueInDouble());
                jczbmap.put("zcfdnum", zcfdnum);
                //缺陷降出力台数
                Double qxjclnum = MathUtil.twoBit(jczblist.get(8).getPointValueInDouble());
                jczbmap.put("qxjclnum", qxjclnum);
                // 限电降出力台数
                Double xdjclnum = MathUtil.twoBit(jczblist.get(9).getPointValueInDouble());
                jczbmap.put("xdjclnum", xdjclnum);
                // 限电停机台数
                Double xdtjnum = MathUtil.twoBit(jczblist.get(10).getPointValueInDouble());
                jczbmap.put("xdtjnum", xdtjnum);
                // 故障停机台数
                Double gztjnum = MathUtil.twoBit(jczblist.get(11).getPointValueInDouble());
                jczbmap.put("gztjnum", gztjnum);
                // 场内受累停机台数
                Double cnsltjnum = MathUtil.twoBit(jczblist.get(12).getPointValueInDouble());
                jczbmap.put("cnsltjnum", cnsltjnum);
                // 检修停机台数
                Double jxtjnum = MathUtil.twoBit(jczblist.get(13).getPointValueInDouble());
                jczbmap.put("jxtjnum", jxtjnum);
                // 场内受累检修台数
                Double cnsljxnum = MathUtil.twoBit(jczblist.get(14).getPointValueInDouble());
                jczbmap.put("cnsljxnum", cnsljxnum);
                // 电网受累台数
                Double dwslnum = MathUtil.twoBit(jczblist.get(15).getPointValueInDouble());
                jczbmap.put("dwslnum", dwslnum);
                // 环境受累台数
                Double hjslnum = MathUtil.twoBit(jczblist.get(16).getPointValueInDouble());
                jczbmap.put("hjslnum", hjslnum);
                // 风机离线台数
                Double lxnum = MathUtil.twoBit(jczblist.get(17).getPointValueInDouble());
                jczbmap.put("lxnum", lxnum);

                /*************************************************光伏状态统计*************************************************************/

                if(wp.getId().endsWith("GDC")){

                    List<String> fjzbls = new ArrayList<>();
                    List<Windturbine> wtls=InitialRunner.wp_wtmap.get(wp.getId());
                    for(Windturbine wt:wtls) {

                        //状态
                        fjzbls.add(windTurbineTestingPointAiService.getWindTurbineTestingPointAi2(wt.getId(), Constant.FJZT).getId());
                    }
                    List<PointData> fjzblist = realApiUtil.getRealData(fjzbls);
                    if (!fjzblist.isEmpty() && fjzblist.size() == fjzbls.size()) {
                        for(int i=0;i<wtls.size();i++){
                            double fjzt = MathUtil.twoBit(MathUtil.twoBit(fjzblist.get(i).getPointValueInDouble()));
                            switch (Double.valueOf(fjzt).intValue()) {
                                case 0:
                                    djnum++;
                                    break;
                                case 1:
                                    zcfdnum++;
                                    break;
                                case 2:
                                    gztjnum++;
                                    break;
                                case 3:
                                    lxnum++;
                                    break;
                                case 4:
                                    jxtjnum++;
                                    break;
                                case 5:
                                    xdjclnum++;
                                    break;
                                case 6:
                                    xdjclnum++;
                                    break;

                                default:

                                    break;
                            }
                        }

                    }

                    //待机台数
                    jczbmap.put("djnum", djnum);
                    //正常发电台数
                    jczbmap.put("zcfdnum", zcfdnum);
                    // 限电降出力台数
                    jczbmap.put("xdjclnum", xdjclnum);
                    // 故障停机台数
                    jczbmap.put("gztjnum", gztjnum);
                    // 检修停机台数
                    jczbmap.put("jxtjnum", jxtjnum);
                    // 电网受累台数
                    jczbmap.put("dwslnum", dwslnum);
                    // 风机离线台数
                    jczbmap.put("lxnum", lxnum);
                }

//
//                double djts=djnum+sdtjnum;
//                double yxts=zcfdnum+qxjclnum;
//                double gzts=gztjnum+cnsltjnum;
//                double lxts=lxnum;
//                double whts=jxtjnum+cnsljxnum;
//                double xdts=xdjclnum+xdtjnum;
//                double slts=dwslnum+hjslnum;
//
//                jczbmap.put("djts", djts);
//                jczbmap.put("yxts", yxts);
//                jczbmap.put("gzts", gzts);
//                jczbmap.put("lxts", lxts);
//                jczbmap.put("whts", whts);
//                jczbmap.put("xdts", xdts);
//                jczbmap.put("slts", slts);

                jczbmap.put("jrts", djnum + sdtjnum + zcfdnum + qxjclnum + xdjclnum + xdtjnum + gztjnum + cnsltjnum + jxtjnum + cnsljxnum + dwslnum + hjslnum + lxnum);
            } else {
                //实际功率
                jczbmap.put("sjgl", 0.0);
                //日发电量
                jczbmap.put("rfdl", 0.0);
                //月发电量
                jczbmap.put("yfdl", 0.0);
                //年发电量
                jczbmap.put("nfdl", 0.0);
                //月利用小时
                jczbmap.put("ylyxs", 0.0);
                //年利用小时
                jczbmap.put("nlyxs", 0.0);
                //实时风速
                jczbmap.put("ssfs", 0.0);

                //待机台数
                jczbmap.put("djnum", 0.0);
                //手动停机台数
                jczbmap.put("sdtjts", 0.0);
                //正常发电台数
                jczbmap.put("zcfdnum", 0.0);
                //缺陷降出力台数
                jczbmap.put("qxjclnum", 0.0);
                // 限电降出力台数
                jczbmap.put("xdjclnum", 0.0);
                // 限电停机台数
                jczbmap.put("xdtjnum", 0.0);
                // 故障停机台数
                jczbmap.put("gztjnum", 0.0);
                // 场内受累停机台数
                jczbmap.put("cnsltjnum", 0.0);
                // 检修停机台数
                jczbmap.put("jxtjnum", 0.0);
                // 场内受累检修台数
                jczbmap.put("cnsljxnum", 0.0);
                // 电网受累台数
                jczbmap.put("dwslnum", 0.0);
                // 环境受累台数
                jczbmap.put("hjslnum", 0.0);
                // 风机离线台数
                jczbmap.put("lxnum", 0.0);
                // 接入台数
                jczbmap.put("jrts", 0.0);

            }

            Calendar c = Calendar.getInstance();

            int tempyear = c.get(Calendar.YEAR);
            int tempmonth = c.get(Calendar.MONTH) + 1;
            int daynum = c.get(Calendar.DAY_OF_MONTH);
            List<WpMttrAndMtbMonth> mmls = wpMttrAndMtbMonthService.getMttrAndMtbf(id, tempyear, tempmonth);

            if (!mmls.isEmpty()) {
                WpMttrAndMtbMonth mm = mmls.get(0);
                double stoptimes = mm.getStoprtimes();
                double stophours = mm.getStophours();
                double mttr = 0.0;
                double mtbf = mm.getWthours();
                if (stoptimes != 0) {
                    mttr = new BigDecimal(stophours).divide(new BigDecimal(stoptimes), 2, RoundingMode.HALF_EVEN).doubleValue();
                    mtbf = new BigDecimal(mm.getWthours()).divide(new BigDecimal(stoptimes), 2, RoundingMode.HALF_EVEN).doubleValue();

                }

                jczbmap.put("mttr", mttr);
                jczbmap.put("mtbf", mtbf);
            }
            map.put("jczbmap", jczbmap);

/*************************************************基础指标*************************************************************/


/*************************************************五项损失**************************************************************/

            Map<String, Double> wxssmap = new HashMap<>();
            List<String> wxssls = new ArrayList<>();

            // 日场内受累检修
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RLZSSDL).getCode());
            // 日场内受累故障
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSZSSDL).getCode());
            // 月场内受累检修
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YLZSSDL).getCode());
            // 月场内受累故障
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YSZSSDL).getCode());
            // 年场内受累检修
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NLZSSDL).getCode());
            // 年场内受累故障
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NSZSSDL).getCode());

            //日待机损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSDJZSDL).getCode());
            //日手动停机损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSSTZSDL).getCode());
            //日性能损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RXNZSDL).getCode());
            //日缺陷降出力损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RSQXZSDL).getCode());
            //日故障损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RGZSSDL).getCode());
            //日检修损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RJXSSDL).getCode());

            //月待机损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YSDJZSDL).getCode());
            //月手动停机损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YSSTZSDL).getCode());
            //月性能损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YXNZSDL).getCode());
            //月缺陷降出力损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YSQXZSDL).getCode());
            //月故障损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YGZSSDL).getCode());
            //月检修损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YJXSSDL).getCode());


            //年待机损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NSDJZSDL).getCode());
            //年手动停机损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NSSTZSDL).getCode());
            //年性能损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NXNZSDL).getCode());
            //年缺陷降出力损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NSQXZSDL).getCode());
            //年故障损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NGZSSDL).getCode());
            //年检修损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NJXSSDL).getCode());


            //日限电损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RXDSSDL).getCode());
            //月限电损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YXDSSDL).getCode());
            //年限电损失
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NXDSSDL).getCode());


            //日场外受累电网
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RWZSSDL).getCode());
            // 日场外受累天气
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.RTZSSDL).getCode());
            // 月场外受累电网
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YWZSSDL).getCode());
            // 月场外受累天气
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.YTZSSDL).getCode());
            // 年场外受累电网
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NWZSSDL).getCode());
            // 年场外受累天气
            wxssls.add(windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(id, Constant.NTZSSDL).getCode());


            List<PointData> wxsslist = realApiUtil.getRealData(wxssls);

            if (!wxsslist.isEmpty() && wxsslist.size() == wxssls.size()) {

                Double rjxsl = MathUtil.twoBit(wxsslist.get(0).getPointValueInDouble());
                // 日场内受累故障
                Double rgzzsl = MathUtil.twoBit(wxsslist.get(1).getPointValueInDouble());
                // 月场内受累检修
                Double yjxsl = MathUtil.twoBit(wxsslist.get(2).getPointValueInDouble());
                // 月场内受累故障
                Double ygzzsl = MathUtil.twoBit(wxsslist.get(3).getPointValueInDouble());
                // 年场内受累检修
                Double njxsl = MathUtil.twoBit(wxsslist.get(4).getPointValueInDouble());
                // 年场内受累故障
                Double ngzzsl = MathUtil.twoBit(wxsslist.get(5).getPointValueInDouble());

                wxssmap.put("rjxsl", rjxsl);
                wxssmap.put("rgzzsl", rgzzsl);
                wxssmap.put("yjxsl", yjxsl);
                wxssmap.put("ygzzsl", ygzzsl);
                wxssmap.put("njxsl", njxsl);
                wxssmap.put("ngzzsl", ngzzsl);

                //日待机损失
                Double rdjss = MathUtil.twoBit(wxsslist.get(6).getPointValueInDouble());
                //日手动停机损失
                Double rsdtjss = MathUtil.twoBit(wxsslist.get(7).getPointValueInDouble());
                //日性能损失
                Double rxnss = MathUtil.twoBit(wxsslist.get(8).getPointValueInDouble());
                //日缺陷降出力损失
                Double rqxjclss = MathUtil.twoBit(wxsslist.get(9).getPointValueInDouble());

                //日欠发损失=日待机损失+日手动停机损失+日性能损失+日缺陷降出力损失
                Double rqfssdl = new BigDecimal(rdjss + rsdtjss + rxnss + rqxjclss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                Double rgzss = MathUtil.twoBit(wxsslist.get(10).getPointValueInDouble());
                //日故障损失电量=日故障损失+日故障受累
                Double rgzssdl = new BigDecimal(rgzss + rgzzsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                //日检修损失电量=日检修损失+日检修受累
                Double rjxss = MathUtil.twoBit(wxsslist.get(11).getPointValueInDouble());
                Double rjxssdl = new BigDecimal(rjxss + rjxsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();


                wxssmap.put("rqfssdl", rqfssdl);
                wxssmap.put("rgzssdl", rgzssdl);
                wxssmap.put("rjxssdl", rjxssdl);

                // 月场内受累检修
                Double ydjss = MathUtil.twoBit(wxsslist.get(12).getPointValueInDouble());
                // 月场内受累检修
                Double ysdtjss = MathUtil.twoBit(wxsslist.get(13).getPointValueInDouble());
                // 月场内受累检修
                Double yxnss = MathUtil.twoBit(wxsslist.get(14).getPointValueInDouble());
                // 月场内受累检修
                Double yqxjclss = MathUtil.twoBit(wxsslist.get(15).getPointValueInDouble());
                //月欠发损失=月待机损失+月手动停机损失+月性能损失+月缺陷降出力损失
                Double yqfssdl = new BigDecimal(ydjss + ysdtjss + yxnss + yqxjclss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                Double ygzss = MathUtil.twoBit(wxsslist.get(16).getPointValueInDouble());
                //月故障损失电量=月故障损失+月故障受累
                Double ygzssdl = new BigDecimal(ygzss + ygzzsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                Double yjxss = MathUtil.twoBit(wxsslist.get(17).getPointValueInDouble());
                //月检修损失电量=月检修损失+月检修受累
                Double yjxssdl = new BigDecimal(yjxss + yjxsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                wxssmap.put("yqfssdl", yqfssdl);
                wxssmap.put("ygzssdl", ygzssdl);
                wxssmap.put("yjxssdl", yjxssdl);

                // 年场内受累检修
                Double ndjss = MathUtil.twoBit(wxsslist.get(18).getPointValueInDouble());
                // 年场内受累检修
                Double nsdtjss = MathUtil.twoBit(wxsslist.get(19).getPointValueInDouble());
                // 年场内受累检修
                Double nxnss = MathUtil.twoBit(wxsslist.get(20).getPointValueInDouble());
                // 年场内受累检修
                Double nqxjclss = MathUtil.twoBit(wxsslist.get(21).getPointValueInDouble());

                Double nqfssdl = new BigDecimal(ndjss + nsdtjss + nxnss + nqxjclss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                Double ngzss = MathUtil.twoBit(wxsslist.get(22).getPointValueInDouble());
                //年故障损失电量=年故障损失+年故障受累
                Double ngzssdl = new BigDecimal(ngzss + ngzzsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                Double njxss = MathUtil.twoBit(wxsslist.get(23).getPointValueInDouble());
                //年检修损失电量=年检修损失+年检修受累
                Double njxssdl = new BigDecimal(njxss + njxsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                wxssmap.put("nqfssdl", nqfssdl);
                wxssmap.put("ngzssdl", ngzssdl);
                wxssmap.put("njxssdl", njxssdl);

                double temp = 0.0;
                temp = MathUtil.twoBit(wxsslist.get(24).getPointValueInDouble());
                Double rxdssdl = new BigDecimal(temp).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                temp = MathUtil.twoBit(wxsslist.get(25).getPointValueInDouble());
                Double yxdssdl = new BigDecimal(temp).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                temp = MathUtil.twoBit(wxsslist.get(26).getPointValueInDouble());
                Double nxdssdl = new BigDecimal(temp).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                wxssmap.put("rxdssdl", StringUtils.round(rxdssdl < 0.0 ? 0.0 : rxdssdl, 2));
                wxssmap.put("yxdssdl", StringUtils.round(yxdssdl < 0.0 ? 0.0 : yxdssdl, 2));
                wxssmap.put("nxdssdl", StringUtils.round(nxdssdl < 0.0 ? 0.0 : nxdssdl, 2));

                Double rdwsl = MathUtil.twoBit(wxsslist.get(27).getPointValueInDouble());
                Double rtqsl = MathUtil.twoBit(wxsslist.get(28).getPointValueInDouble());
                Double rslssdl = new BigDecimal(rdwsl + rtqsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                Double ydwsl = MathUtil.twoBit(wxsslist.get(29).getPointValueInDouble());
                Double ytqsl = MathUtil.twoBit(wxsslist.get(30).getPointValueInDouble());
                Double yslssdl = new BigDecimal(ydwsl + ytqsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                Double ndwsl = MathUtil.twoBit(wxsslist.get(31).getPointValueInDouble());
                Double ntqsl = MathUtil.twoBit(wxsslist.get(32).getPointValueInDouble());
                Double nslssdl = new BigDecimal(ndwsl + ntqsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                wxssmap.put("rslssdl", rslssdl);
                wxssmap.put("yslssdl", yslssdl);
                wxssmap.put("nslssdl", nslssdl);

            } else {

                wxssmap.put("rjxsl", 0.0);
                wxssmap.put("rgzzsl", 0.0);
                wxssmap.put("yjxsl", 0.0);
                wxssmap.put("ygzzsl", 0.0);
                wxssmap.put("njxsl", 0.0);
                wxssmap.put("ngzzsl", 0.0);
                wxssmap.put("rqfssdl", 0.0);
                wxssmap.put("rgzssdl", 0.0);
                wxssmap.put("rjxssdl", 0.0);

                wxssmap.put("yqfssdl", 0.0);
                wxssmap.put("ygzssdl", 0.0);
                wxssmap.put("yjxssdl", 0.0);

                wxssmap.put("nqfssdl", 0.0);
                wxssmap.put("ngzssdl", 0.0);
                wxssmap.put("njxssdl", 0.0);


                wxssmap.put("rxdssdl", 0.0);
                wxssmap.put("yxdssdl", 0.0);
                wxssmap.put("nxdssdl", 0.0);


                wxssmap.put("rslssdl", 0.0);
                wxssmap.put("yslssdl", 0.0);
                wxssmap.put("nslssdl", 0.0);

            }
            map.put("wxssmap", wxssmap);
/*************************************************五项损失**************************************************************/

/*************************************************风机矩阵指标**************************************************************/


            Map<String, Object> fjjzmap = matrixPushByWpService.findSimpleMatrixById(wp.getId());

            map.put("fjjzmap", fjjzmap);
/*************************************************风机矩阵指标**************************************************************/

/*************************************************功率曲线**************************************************************/


            List<DataVo> glvos = realPowerPushService.findRealPower(wp.getId());

            map.put("glvos", glvos);
/*************************************************功率曲线**************************************************************/

/*************************************************日损失**************************************************************/

//
//            List<DataVo> lossvos=findLossWpBar(wp.getId());
//
//            map.put("lossvos", lossvos);
/*************************************************日损失**************************************************************/

/*************************************************日发电量**************************************************************/


//            List<DataVo> rfdlvos=findPowerWpBar(wp.getId());
//
//            map.put("rfdlvos", rfdlvos);
/*************************************************日发电量**************************************************************/

/*************************************************月发电量**************************************************************/


//            List<DataVo> yfdlvos=findMonthPowerWpBar(wp.getId());
//
//            map.put("yfdlvos", yfdlvos);
/*************************************************月发电量**************************************************************/

/*************************************************日发电量**************************************************************/

/*************************************************关系库**************************************************************/

//
//            Map<String, Double> gxkmap = new HashMap<>();
//            List<Windpowerinfoday> wpdls = windpowerinfodayService.getWindpowerinfodayList(id, DateUtils.truncate(new Date()));
//            if (!wpdls.isEmpty()) {
//                Windpowerinfoday wd = wpdls.get(0);
//                gxkmap.put("ndxkyss", wd.getYeardxkyxs());
//                gxkmap.put("nsbklyl", wd.getYearsbklyl());
//
//                gxkmap.put("ydxkyss", wd.getMonthdxkyxs());
//                gxkmap.put("ysbklyl", wd.getMonthsbklyl());
//
//            } else {
//                gxkmap.put("ndxkyss", 0.0);
//                gxkmap.put("nsbklyl", 0.0);
//                gxkmap.put("ydxkyss", 0.0);
//                gxkmap.put("ysbklyl", 0.0);
//            }
//            map.put("gxkmap", gxkmap);

/*************************************************关系库指标**************************************************************/

        }


        return map;
    }

    /**
     * 获得风场监视损失电量图表
     *
     * @param wpId
     * @return
     * @throws Exception
     */
    public List<DataVo> findLossWpBar(String wpId) throws Exception {
        List<DataVo> vos = new ArrayList<DataVo>();
        if (StringUtils.empty(wpId)) {
            wpId = "0";
        }

        Calendar c = Calendar.getInstance();
        c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH));
        c.add(Calendar.DAY_OF_MONTH, 1);
        // c.add(Calendar.MONTH, -1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        Date beginDate = c.getTime();

        c = Calendar.getInstance();
        // c.add(Calendar.MONTH, -1);
        c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
        c.add(Calendar.DAY_OF_MONTH, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        Date endDate = c.getTime();
        c = Calendar.getInstance();
        long num = c.get(Calendar.DAY_OF_MONTH);
        long monthdaynum = c.getActualMaximum(Calendar.DAY_OF_MONTH);


        WindPowerStationTestingPoint gzslai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RSZSSDL);
        WindPowerStationTestingPoint jxslai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RLZSSDL);

        WindPowerStationTestingPoint gzssai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RGZSSDL);
        WindPowerStationTestingPoint jxssai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RJXSSDL);

        WindPowerStationTestingPoint djssai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RSDJZSDL);
        WindPowerStationTestingPoint sdtjai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RSSTZSDL);
        WindPowerStationTestingPoint xnssai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RXNZSDL);
        WindPowerStationTestingPoint qxjclai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RSQXZSDL);

        WindPowerStationTestingPoint xdssai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RSSTZSDL);
        WindPowerStationTestingPoint dwslai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RXNZSDL);
        WindPowerStationTestingPoint tqslai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.RSQXZSDL);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        List<PointData> gzslls = realApiUtil.getHistoryDatasSnap(gzslai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> jxslls = realApiUtil.getHistoryDatasSnap(jxslai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> gzssls = realApiUtil.getHistoryDatasSnap(gzssai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> jxssls = realApiUtil.getHistoryDatasSnap(jxssai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);

        List<PointData> djssls = realApiUtil.getHistoryDatasSnap(djssai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> sdtjls = realApiUtil.getHistoryDatasSnap(sdtjai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> xnssls = realApiUtil.getHistoryDatasSnap(xnssai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> qxjclls = realApiUtil.getHistoryDatasSnap(qxjclai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);

        List<PointData> xdssls = realApiUtil.getHistoryDatasSnap(xdssai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> dwslls = realApiUtil.getHistoryDatasSnap(dwslai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> tqslls = realApiUtil.getHistoryDatasSnap(tqslai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);

        if (!gzslls.isEmpty() && !jxslls.isEmpty() && !gzssls.isEmpty()
                && !jxssls.isEmpty() && !djssls.isEmpty() && !sdtjls.isEmpty() && !xnssls.isEmpty()
                && !qxjclls.isEmpty() && !xdssls.isEmpty() && !dwslls.isEmpty() && !tqslls.isEmpty()

                && gzslls.size()==jxslls.size() &&  gzslls.size()==gzssls.size()
                &&  gzslls.size()==jxssls.size() &&  gzslls.size()==djssls.size() &&  gzslls.size()==sdtjls.size() &&  gzslls.size()==xnssls.size()
                &&  gzslls.size()==qxjclls.size() &&  gzslls.size()==xdssls.size() &&  gzslls.size()==dwslls.size() &&  gzslls.size()==tqslls.size()

        ) {
            Calendar cal = Calendar.getInstance();
            int today = c.get(Calendar.DAY_OF_MONTH);
            // int today = 30;
            for (int i = 0; i < gzslls.size(); i++) {
                DataVo vo = new DataVo();

                Date date = new Date(gzslls.get(i).getPointTime() * 1000);
                cal.setTime(date);

                // vo.setTime(dateformat.parse(entry.getKey()).getTime());

                if (i + 1 <= today) {
                    vo.setTimestr(i + 1 + "日");
                    //日待机损失
                    Double rdjss = MathUtil.twoBit(djssls.get(i).getPointValueInDouble());
                    //日手动停机损失
                    Double rsdtjss = MathUtil.twoBit(sdtjls.get(i).getPointValueInDouble());
                    //日性能损失
                    Double rxnss = MathUtil.twoBit(xnssls.get(i).getPointValueInDouble());
                    //日缺陷降出力损失
                    Double rqxjclss = MathUtil.twoBit(qxjclls.get(i).getPointValueInDouble());

                    //日欠发损失=日待机损失+日手动停机损失+日性能损失+日缺陷降出力损失
                    Double xnss = new BigDecimal(rdjss + rsdtjss + rxnss + rqxjclss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                    //日故障损失电量=日故障损失+日故障受累
                    Double rgzsl = MathUtil.twoBit(gzslls.get(i).getPointValueInDouble());
                    Double rgzss = MathUtil.twoBit(gzssls.get(i).getPointValueInDouble());
                    Double gzss = new BigDecimal(rgzsl + rgzss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                    //日检修损失电量=日检修损失+日检修受累
                    Double rjxsl = MathUtil.twoBit(jxssls.get(i).getPointValueInDouble());
                    Double rjxss = MathUtil.twoBit(jxslls.get(i).getPointValueInDouble());
                    Double jxss = new BigDecimal(rjxss + rjxsl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                    Double xdxss = new BigDecimal(xdssls.get(i).getPointValueInDouble()).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                    //受累损失电量=电网受累+天气受累
                    Double dwslss = new BigDecimal(dwslls.get(i).getPointValueInDouble()).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();
                    Double twslss = new BigDecimal(tqslls.get(i).getPointValueInDouble()).divide(new BigDecimal(10000), 2, RoundingMode.HALF_EVEN).doubleValue();

                    Double slss = MathUtil.twoBit(dwslss + twslss);

                    double ssdl = MathUtil.twoBit(xnss + gzss + jxss + xdxss + slss);
                    vo.setValue1(ssdl);// 损失电量

                } else {
                    vo.setTimestr("");
                    vo.setValue1(0.0);// 损失电量

                    //vo.setSpeed(0.0);
                }

                vos.add(vo);
            }
        }

        if (vos.size() < (monthdaynum)) {
            for (int i = vos.size(); i < (monthdaynum); i++) {
                DataVo vo = new DataVo();
                vo.setTimestr("");

                vo.setValue1(0.0);// 日发电量
                vo.setValue2(0.0);// 上网电量
                vo.setValue3(0.0);// 购网电量
                // vo.setSpeed(0.0);
                vos.add(vo);
                if (vos.size() == 31) {
                    break;
                }
            }
        }

        return vos;
    }

    /**
     * 获得风场监视日发电量图表
     *
     * @param wpId
     * @return
     * @throws Exception
     */
    public List<DataVo> findPowerWpBar(String wpId) throws Exception {
        List<DataVo> vos = new ArrayList<DataVo>();
        if (StringUtils.empty(wpId)) {
            wpId = "0";
        }

        Calendar c = Calendar.getInstance();

        // c.add(Calendar.MONTH, -1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        Date endDate = c.getTime();


        c = Calendar.getInstance();
        c.add(Calendar.DAY_OF_MONTH, -7);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        Date beginDate = c.getTime();
        c = Calendar.getInstance();
        long num = 7;
        // long num = 30;


        WindPowerStationTestingPoint rfdlai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.TPOINT_WP_RFDL);

        WindPowerStationTestingPoint fsai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.TPOINT_WP_SSFS);

        WindPowerStationTestingPoint swai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.TPOINT_WP_SWDL);
        WindPowerStationTestingPoint gwai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.TPOINT_WP_GWDL);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        List<PointData> rfdlls = realApiUtil.getHistoryDatasSnap(rfdlai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> fsls = realApiUtil.getHistoryDatasSnap(fsai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);

        List<PointData> swls = realApiUtil.getHistoryDatasSnap(swai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);
        List<PointData> gwls = realApiUtil.getHistoryDatasSnap(gwai, beginDate.getTime() / 1000, endDate.getTime() / 1000, num, 86400L);

        if (!rfdlls.isEmpty()) {
            Calendar cal = Calendar.getInstance();
            int today = c.get(Calendar.DAY_OF_MONTH);
            // int today = 30;
            for (int i = 0; i < rfdlls.size(); i++) {
                DataVo vo = new DataVo();

                Date date = new Date(rfdlls.get(i).getPointTime() * 1000);
                cal.setTime(date);

                // vo.setTime(dateformat.parse(entry.getKey()).getTime());

                vo.setTimestr(cal.get(Calendar.DAY_OF_MONTH) + "日");
                //日发电量
                Double rfdl = MathUtil.twoBit(rfdlls.get(i).getPointValueInDouble());
                //日预测发电量
                Double ycrfdl = MathUtil.twoBit(rfdl * YCFDLXS);
                //风速
                Double fs = MathUtil.twoBit(fsls.get(i).getPointValueInDouble());
                //风速
                Double sw = MathUtil.twoBit(swls.get(i).getPointValueInDouble());
                //风速
                Double gw = MathUtil.twoBit(gwls.get(i).getPointValueInDouble());
                vo.setValue1(rfdl);
                vo.setValue2(ycrfdl);
                vo.setValue3(fs);
                vo.setValue4(sw);
                vo.setValue5(gw);
                vos.add(vo);
            }
        }


        return vos;
    }

    /**
     * 获得风场监视月发电量图表
     *
     * @param wpId
     * @return
     * @throws Exception
     */
    public List<DataVo> findMonthPowerWpBar(String wpId) throws Exception {
        List<DataVo> vos = new ArrayList<DataVo>();
        if (StringUtils.empty(wpId)) {
            wpId = "0";
        }

        WindPowerStationTestingPoint fsai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.TPOINT_WP_SSFS);
        WindPowerStationTestingPoint yfdlai = windPowerstationTestingPoint2Service.getWindPowerStationTestingPoint2(wpId, Constant.TPOINT_WP_YFDL);
        String[] fdlpoints = new String[2];
        fdlpoints[0] = yfdlai.getCode();
        fdlpoints[1] = fsai.getCode();
        Calendar c = Calendar.getInstance();
        int month = c.get(Calendar.MONTH) + 1;
        c.set(Calendar.MONTH, 1);
        c.set(Calendar.DAY_OF_MONTH, 1);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);


        for (int i = 0; i < month; i++) {
            int current = new BigDecimal(c.getTime().getTime()).divide(new BigDecimal(1000), 0, RoundingMode.HALF_EVEN).intValue();

            // 获得发电量本月数据
            DNAVal[] currentfdlarr = realApiUtil.getHistMatrix(fdlpoints, current);

            DataVo vo = new DataVo();

            // vo.setTime(dateformat.parse(entry.getKey()).getTime());

            vo.setTimestr(c.get(Calendar.MONTH)  + "月");
            //日发电量
            Double rfdl = MathUtil.twoBit(currentfdlarr[0].DValue);
            //日预测发电量
            Double ycrfdl = MathUtil.twoBit(rfdl * YCFDLXS);
            //风速
            Double fs = MathUtil.twoBit(currentfdlarr[1].DValue);
            vo.setValue1(rfdl);// 日发电量
            vo.setValue2(ycrfdl);// 日预测发电量
            vo.setValue3(fs);
            vos.add(vo);

            c.add(Calendar.MONTH, 1);
        }


        return vos;
    }



}


