package com.gyee.generation.service;//package com.gyee.generation.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.common.contant.ContantXk;
import com.gyee.common.model.PointData;
import com.gyee.common.model.StringUtils;
import com.gyee.generation.init.CacheContext;
import com.gyee.generation.model.auto.*;
import com.gyee.generation.service.auto.*;
import com.gyee.generation.task.thread.EquipmentInfo4Thread;
import com.gyee.generation.util.DateUtils;
import com.gyee.generation.util.realtimesource.IEdosUtil;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;

@Service
public class EquipmentInfo4Service {

    //    private static final Logger logger = LoggerFactory.getLogger(EquipmentInfo4Service.class);
    @Resource
    private IEdosUtil edosUtil;

    @Resource
    private IProEconEquipmentInfoDay4Service proEconEquipmentInfoDay4Service;
    @Resource
    private IProEconEquipmentInfoDay2Service proEconEquipmentInfoDay2Service;
    @Resource
    private IProEconEquipmentInfoDay3Service proEconEquipmentInfoDay3Service;
    @Resource
    private IProEconInOrOutSpeedTotalService proEconInOrOutSpeedTotalService;

    @Resource
    private IProEconCurveFittingSubService proEconCurveFittingSubService;

    @Resource
    private IProEconCurveFittMonthSubService proEconCurveFittMonthSubService;

    @Resource
    private IProEconCurveFittYearSubService proEconCurveFittYearSubService;

    @Resource
    private IProEconCurveFittingMainService proEconCurveFittingMainService;

    @Resource
    private IProEconCurveFittMonthMainService proEconCurveFittMonthMainService;

    @Resource
    private IProEconCurveFittYearMainService proEconCurveFittYearMainService;


    @Resource
    private IProEconEquipmentInfoDay5Service proEconEquipmentInfoDay5Service;

    @Resource
    private IProEconFaultLiminatedefectsService proEconFaultLiminatedefectsService;


    @Resource
    private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService;


    @Resource
    @Qualifier("applicationTaskExecutor")
    private Executor executor;

    public void calEquipmentInfoDay(Date recordDate) throws Exception {
        Calendar c = Calendar.getInstance();
        c.setTime(recordDate);
        if (c.get(Calendar.HOUR_OF_DAY) == 0) {
            //      if(c.get(Calendar.HOUR_OF_DAY)==0 && c.get(Calendar.MINUTE)==0)
            c.add(Calendar.DAY_OF_MONTH, -1);
        }

        c.set(Calendar.HOUR_OF_DAY, 23);
        c.set(Calendar.MINUTE, 59);
        c.set(Calendar.SECOND, 59);
        Date end = c.getTime();

        Date begin = DateUtils.truncate(c.getTime());

        Date lastDay = DateUtils.addDays(begin, -1);

        //        //判断是否有重复记录，先删除重复记录
        //        QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
        //        queryWrapper.eq("record_date",begin);
        //        List<String> idls = proEconEquipmentInfoDay4Service.list(queryWrapper).stream()
        //                .map(ProEconEquipmentInfoDay4::getId)
        //                .collect(Collectors.toList());
        //
        ////        if (idls.size() > 0) {
        ////
        ////            proEconEquipmentInfoDay4Service.removeByIds(idls);
        ////
        ////        }
        //        List<String> tempids=new ArrayList<>();
        //
        //        for(int i=0;i<idls.size();i++)
        //        {
        //            tempids.add(idls.get(i));
        //            if(tempids.size()==1000)
        //            {
        //                proEconEquipmentInfoDay4Service.removeByIds(tempids);
        //                tempids=new ArrayList<>();
        //            }
        //        }
        //
        //        if(!tempids.isEmpty())
        //        {
        //            proEconEquipmentInfoDay4Service.removeByIds(tempids);
        //        }


        Map<String, ProEconEquipmentInfoDay2> pep2map = new HashMap<>();
        Map<String, ProEconEquipmentInfoDay3> pep3map = new HashMap<>();
        Map<String, ProEconEquipmentInfoDay4> pep4map = new HashMap<>();
        Calendar cl = Calendar.getInstance();
        cl.setTime(recordDate);

        if (cl.get(Calendar.DAY_OF_MONTH) != 1) {
            cl.add(Calendar.DAY_OF_MONTH, -1);
            QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper2 = new QueryWrapper<>();
            queryWrapper2.eq("record_date", cl.getTime());
            List<ProEconEquipmentInfoDay2> pep2ls = proEconEquipmentInfoDay2Service.list(queryWrapper2);
            if (!pep2ls.isEmpty()) {
                for (ProEconEquipmentInfoDay2 pep : pep2ls) {
                    pep2map.put(pep.getWindturbineId(), pep);
                }
            }

            QueryWrapper<ProEconEquipmentInfoDay3> queryWrapper3 = new QueryWrapper<>();
            queryWrapper3.eq("record_date", cl.getTime());
            List<ProEconEquipmentInfoDay3> pep3ls = proEconEquipmentInfoDay3Service.list(queryWrapper3);
            if (!pep3ls.isEmpty()) {
                for (ProEconEquipmentInfoDay3 pep : pep3ls) {
                    pep3map.put(pep.getWindturbineId(), pep);
                }
            }

            QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper4 = new QueryWrapper<>();
            queryWrapper4.eq("record_date", cl.getTime());
            List<ProEconEquipmentInfoDay4> pep4ls = proEconEquipmentInfoDay4Service.list(queryWrapper4);
            if (!pep4ls.isEmpty()) {
                for (ProEconEquipmentInfoDay4 pep : pep4ls) {
                    pep4map.put(pep.getWindturbineId(), pep);
                }
            }

        }

        //获取曲线风机切入风速
        Map<String, ProEconInOrOutSpeedTotal> peioomap = new ConcurrentHashMap<>();

        QueryWrapper<ProEconInOrOutSpeedTotal> queryWrapper2 = new QueryWrapper<>();
        queryWrapper2.eq("record_date", lastDay);

        List<ProEconInOrOutSpeedTotal> peioostls = proEconInOrOutSpeedTotalService.list(queryWrapper2);
        //                .stream().filter(i ->
        //                i.getRecordDate().compareTo(begin) == 0
        //        ).collect(Collectors.toList());

        if (!peioostls.isEmpty()) {
            for (ProEconInOrOutSpeedTotal peioo : peioostls) {
                peioomap.put(peioo.getWindturbineId(), peioo);
            }
        }
        Map<String, ProEconWindturbineGoodness> wgmap = new HashMap<>();

        QueryWrapper<ProEconWindturbineGoodness> queryWrapper3 = new QueryWrapper<>();
        queryWrapper3.eq("record_date", lastDay);

        List<ProEconWindturbineGoodness> wgls = proEconWindturbineGoodnessService.list(queryWrapper3);
        //                .stream()
        //                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(begin))==0
        //                        && CacheContext.wtmap.containsKey(i.getWindturbineId()))
        //                .collect(Collectors.toList());

        if (!wgls.isEmpty()) {
            for (ProEconWindturbineGoodness wg : wgls) {
                wgmap.put(wg.getWindturbineId(), wg);
            }
        }
        //        //功率一致性接口调用
        //        Map<String, Map<String, Double>> glqxyizxMap = coefficientService.coefficient(begin);
        //        //拟合优度接口调用
        //        Map<String, Map<String, Double>> nhydMap = goodnessOfFitService.goodnessOfFit(begin);
        List<ProEconEquipmentInfoDay4> dayls = new CopyOnWriteArrayList<>();

        List<String> wpls = new ArrayList<>();
        //        final CountDownLatch latch = new CountDownLatch(CacheContext.wt_fjls.size());
        //        for (ProBasicEquipment wt : CacheContext.wt_fjls) {
        //            if(!wpls.contains(wt.getWindpowerstationId()))
        //            {
        //                wpls.add(wt.getWindpowerstationId());
        //            }
        //
        //            new Thread(new EquipmentInfo4Thread(executor,wt, pep2map,
        //                    pep3map,
        //                    pep4map,
        //                    recordDate,  end,  begin,  dayls,
        //                    edosUtil, peioomap,
        //                    wgmap,
        //                    proEconCurveFittingMainService,
        //                    proEconEquipmentInfoDay5Service,
        //                    proEconFaultLiminatedefectsService,
        //                    proEconCurveFittingSubService,
        //                    proEconCurveFittMonthMainService,
        //                    proEconCurveFittMonthSubService,
        //                    proEconCurveFittYearMainService,
        //                    proEconCurveFittYearSubService,latch)).start();
        //        }
        //
        //        latch.await();

        List<ProBasicEquipment> wttemps = new ArrayList<>();


        for (Map.Entry<String, List<ProBasicEquipment>> entry : CacheContext.wpwtmap.entrySet()) {


            if (entry.getKey().contains("FDC")) {
                for (ProBasicEquipment wt : entry.getValue()) {

                    if (!wpls.contains(wt.getWindpowerstationId())) {
                        wpls.add(wt.getWindpowerstationId());
                    }
                    wttemps.add(wt);

                    if (wttemps.size() == 120) {

                        final CountDownLatch latch = new CountDownLatch(120);
                        for (ProBasicEquipment wt1 : wttemps) {
                            new Thread(new EquipmentInfo4Thread(executor, wt1, pep2map,
                                    pep3map,
                                    pep4map,
                                    recordDate, end, begin, dayls,
                                    edosUtil, peioomap,
                                    wgmap,
                                    proEconCurveFittingMainService,
                                    proEconEquipmentInfoDay5Service,
                                    proEconFaultLiminatedefectsService,
                                    proEconCurveFittingSubService,
                                    proEconCurveFittMonthMainService,
                                    proEconCurveFittMonthSubService,
                                    proEconCurveFittYearMainService,
                                    proEconCurveFittYearSubService, latch)).start();

                        }
                        latch.await();
                        Thread.sleep(120);
                        wttemps = new ArrayList<>();
                    }

                }

            }

        }
        if (!wttemps.isEmpty()) {
            final CountDownLatch latch = new CountDownLatch(wttemps.size());
            for (ProBasicEquipment wt1 : wttemps) {
                new Thread(new EquipmentInfo4Thread(executor, wt1, pep2map,
                        pep3map,
                        pep4map,
                        recordDate, end, begin, dayls,
                        edosUtil, peioomap,
                        wgmap,
                        proEconCurveFittingMainService,
                        proEconEquipmentInfoDay5Service,
                        proEconFaultLiminatedefectsService,
                        proEconCurveFittingSubService,
                        proEconCurveFittMonthMainService,
                        proEconCurveFittMonthSubService,
                        proEconCurveFittYearMainService,
                        proEconCurveFittYearSubService, latch)).start();
            }
            latch.await();
            Thread.sleep(120);
        }


        c = Calendar.getInstance();
        c.setTime(recordDate);


        begin = DateUtils.truncate(c.getTime());


        //判断是否有重复记录，先删除重复记录
        QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("record_date", begin);
        queryWrapper.in("windpowerstation_id", wpls);
        List<String> idls = proEconEquipmentInfoDay4Service.list(queryWrapper).stream()
                .map(ProEconEquipmentInfoDay4::getId)
                .collect(Collectors.toList());

        List<String> tempids = new ArrayList<>();

        for (int i = 0; i < idls.size(); i++) {
            tempids.add(idls.get(i));
            if (tempids.size() == 1000) {
                proEconEquipmentInfoDay4Service.removeByIds(tempids);
                tempids = new ArrayList<>();
            }
        }

        if (!tempids.isEmpty()) {
            proEconEquipmentInfoDay4Service.removeByIds(tempids);
        }


        List<ProEconEquipmentInfoDay4> templs = new ArrayList<>();
        for (ProEconEquipmentInfoDay4 vo : dayls) {
            if (StringUtils.notEmp(vo) && StringUtils.notEmp(vo.getWindturbineId())) {
                templs.add(vo);
                if (templs.size() == 1000) {
                    proEconEquipmentInfoDay4Service.saveBatch(templs);
                    templs = new ArrayList<>();
                }
            }

        }

        if (!templs.isEmpty()) {
            proEconEquipmentInfoDay4Service.saveBatch(templs);
        }
        //  proEconEquipmentInfoDay4Service.saveBatch(dayls);
    }

    private void calDetiall(Map<String, ProEconInOrOutSpeedTotal> peioomap, ProEconEquipmentInfoDay4 pewp, Date end, Date begin,
                            ProBasicEquipment wt, List<ProEconEquipmentInfoDay4> pepidls, ProEconEquipmentInfoDay2 pepid2, ProEconEquipmentInfoDay3 pepid3,
                            Map<String, ProEconWindturbineGoodness> wgmap) throws Exception {

        //*****************************************日信息统计*********************************************************/
        Map<String, ProBasicEquipmentPoint> wtpointmap = CacheContext.wtpAimap.get(wt.getId());


        ProEconInOrOutSpeedTotal peiost;

        //获得功率一致性系数
        if (wgmap.containsKey(wt.getId())) {
            ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
            pewp.setRglyzxxs(wg.getDayCoefficient());
        }

        //获得拟合优度
        if (wgmap.containsKey(wt.getId())) {
            ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
            pewp.setRnhyd(wg.getDayGoodness());
        }

        if (StringUtils.notEmp(pepid2)) {
            //获得日有效风时数
            pewp.setRyxfss(StringUtils.round(24 - pepid2.getRgzxsmx() - pepid2.getRjxxsmx(), 2));


        }

        if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
            //故障小时
            double rgzxsmx = pepid2.getRgzxsmx();
            //故障次数
            double rgzcsmx = pepid3.getRgzcsmx();
            if (rgzcsmx != 0) {
                double mtbf = new BigDecimal(24).divide(new BigDecimal(rgzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
                double mttr = new BigDecimal(rgzxsmx).divide(new BigDecimal(rgzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
                double mttf = mtbf - mttr;

                pewp.setRmtbf(mtbf);
                pewp.setRmttr(mttr);
                pewp.setRmttf(mttf);
            } else {
                double mtbf = 24.0;
                double mttr = 0.0;
                double mttf = mtbf - mttr;

                pewp.setRmtbf(mtbf);
                pewp.setRmttr(mttr);
                pewp.setRmttf(mttf);
            }

        }


        if (peioomap.containsKey(wt.getId())) {
            //切入切出统计
            peiost = peioomap.get(wt.getId());
            //日小风切入风速
            pewp.setRxfqrfs(peiost.getDayInputSmall());
            //日小风切出风速
            pewp.setRxfqcfs(peiost.getDayOutputSmall());
            //日大风切入风速
            pewp.setRdfqrfs(peiost.getDayInputBig());
            //日大风切出风速
            pewp.setRdfqcfs(peiost.getDayOutputBig());
            if (StringUtils.notEmp(peiost)) {
                ProBasicEquipmentPoint point = wtpointmap.get(ContantXk.CJ_SSFS);

                //风速历史查询，每分钟一个点
                List<PointData> fsls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
                if (StringUtils.notEmp(peiost) && !fsls.isEmpty()) {
                    double dayjfsc = 0.0;
                    for (PointData po : fsls) {
                        //                        //小风切入风速
                        //                        double xfqr = peiost.getDayInputSmall();
                        //                        //小于小风切入算静风时长累计
                        if (po.getPointValueInDouble() < 3) {
                            dayjfsc++;
                        }

                    }
                    //将分钟转化为小时
                    dayjfsc = new BigDecimal(dayjfsc).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();

                    pewp.setRjfsc(dayjfsc);
                }

                if (CacheContext.modelMap.containsKey(wt.getModelId())) {
                    ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId());

                    point = wtpointmap.get(ContantXk.CJ_SSGL);
                    List<PointData> glls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
                    double powerProduction = model.getPowerProduction();
                    if (!glls.isEmpty() && glls.size() == fsls.size()) {
                        for (int i = 0; i < glls.size(); i++) {
                            //如果功率达到装机容量
                            if (glls.get(i).getPointValueInDouble() >= powerProduction) {
                                if (pewp.getRedfs() == 0) {
                                    //额定风速赋值
                                    pewp.setRedfs(fsls.get(i).getPointValueInDouble());
                                } else if (pewp.getRedfs() > fsls.get(i).getPointValueInDouble()) {
                                    //额定风速赋值,比较风速大小，取最小值
                                    pewp.setRedfs(fsls.get(i).getPointValueInDouble());
                                }
                            }
                        }
                    }

                    if (pewp.getRedfs() == 0) {
                        //如果没有满发，额定风速赋值保证功率达到满发的对应风速
                        pewp.setRedfs(11.0);
                    }

                    point = wtpointmap.get(ContantXk.BZGL);
                    List<PointData> bzglls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);
                    point = wtpointmap.get(ContantXk.CJ_FX);
                    List<PointData> fxls = edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime() / 1000, end.getTime() / 1000);

                    if (!bzglls.isEmpty() && !fsls.isEmpty() && glls.size() == bzglls.size() && fsls.size() == bzglls.size()) {
                        double number = 0.0;
                        double totalnumbere = 0.0;
                        double lastvalue = -1;
                        for (int i = 0; i < fxls.size(); i++) {
                            double bzgl = bzglls.get(i).getPointValueInDouble();
                            double sjgl = glls.get(i).getPointValueInDouble();
                            double fx = fxls.get(i).getPointValueInDouble();

                            if (lastvalue != fx) {
                                //日对风偏差大于（-50 +50之间）
                                if (Math.abs(bzgl - sjgl) > 50) {
                                    //日对风偏差次数
                                    number++;
                                }
                                //对风次数
                                totalnumbere++;
                            }

                        }
                        if (totalnumbere != 0) {
                            double dfpcl = new BigDecimal(number).divide(new BigDecimal(totalnumbere), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
                            pewp.setRdfpcl(dfpcl);
                        } else {
                            pewp.setRdfpcl(0.0);
                        }

                    }


                }

            }
        }

        QueryWrapper<ProEconCurveFittingMain> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("record_date", begin).eq("windturbine_id", wt.getId());
        List<ProEconCurveFittingMain> pecfmls = proEconCurveFittingMainService.list(queryWrapper);
        //                .stream().filter(i -> i.getRecordDate().compareTo(begin) == 0
        //                && i.getWindturbineId().equals(wt.getId())
        //        ).collect(Collectors.toList());

        if (!pecfmls.isEmpty()) {
            ProEconCurveFittingMain pecfm = pecfmls.get(0);
            pewp.setRqxpcbzysj(pecfm.getDeviationRate1());
            pewp.setRqxpcbbzsj(pecfm.getDeviationRate2());
            pewp.setRqxpcbzybz(pecfm.getDeviationRate3());
            pewp.setRqxpcbbg(pecfm.getStandardDeviationRate());
            pewp.setRqxpcbtb(pecfm.getYearDeviationRate());
            pewp.setRqxpcbhb(pecfm.getMonthDeviationRate());
        }

        //**************************************************日三率统计****************************************************************/

        QueryWrapper<ProEconEquipmentInfoDay5> queryWrapper2 = new QueryWrapper<>();
        queryWrapper2.eq("record_date", begin).eq("windturbine_id", wt.getId());
        List<ProEconEquipmentInfoDay5> pestrls = proEconEquipmentInfoDay5Service.list(queryWrapper2);
        //                .stream()
        //                .filter(i -> i.getRecordDate().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId())
        //                ).collect(Collectors.toList());
        //大于3米20分钟转换及时次数
        DoubleSummaryStatistics timerate8_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate8).summaryStatistics();
        //大于3米20分钟转换及时次数合计
        double timerate8_sum = timerate8_summary.getSum();

        //大于3米状态转换总次数次数
        DoubleSummaryStatistics timerate14_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate14).summaryStatistics();
        //大于3米状态转换总次数合计
        double timerate14_sum = timerate14_summary.getSum();

        if (timerate14_sum != 0) {
            //日状态转换及时率
            double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
            pewp.setRztzhjsl(temp);
        } else {
            pewp.setRztzhjsl(100.0);
        }

        //20分钟复位及时次数
        DoubleSummaryStatistics timerate19_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate19).summaryStatistics();
        //20分钟复位及时次数合计
        double timerate19_sum = timerate19_summary.getSum();

        //总复位次数
        DoubleSummaryStatistics timerate20_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate20).summaryStatistics();
        //总复位次数合计
        double timerate20_sum = timerate20_summary.getSum();

        if (timerate20_sum != 0) {
            //日复位及时率
            double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
            pewp.setRfwjsl(temp);
        } else {
            pewp.setRfwjsl(100.0);
        }
        QueryWrapper<ProEconFaultLiminatedefects> queryWrapper3 = new QueryWrapper<>();
        queryWrapper3.ge("date_time", begin).le("date_time", end).eq("windturbine_id", wt.getId());
        List<ProEconFaultLiminatedefects> peflls = proEconFaultLiminatedefectsService.list(queryWrapper3);
        //                .stream()
        //                .filter(i -> i.getDateTime().compareTo(begin) == 0 && i.getWindturbineId().equals(wt.getId())
        //                ).collect(Collectors.toList());
        //消缺及时次数
        DoubleSummaryStatistics right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
        //消缺及时次数合计
        double right_sum = right_summary.getSum();

        //故障次数次数
        DoubleSummaryStatistics fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
        //故障次数次数合计
        double fault_sum = fault_summary.getSum();

        if (fault_sum != 0) {
            //日消缺及时率
            double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
            pewp.setRgzxqjsl(temp);
        } else {
            pewp.setRgzxqjsl(100.0);
        }
        //**************************************************日三率统计****************************************************************/

        QueryWrapper<ProEconCurveFittingSub> queryWrapper6 = new QueryWrapper<>();
        queryWrapper6.eq("record_date", begin).isNotNull("speed")
                .lt("speed", 5.0)
                .ge("speed", 3.0)
                .eq("windturbine_id", wt.getId());
        List<ProEconCurveFittingSub> pointls = proEconCurveFittingSubService.list(queryWrapper6);
        //                .stream().filter(x-> x.getSpeed() !=null
        //                && Double.valueOf(x.getSpeed())>=3.0
        //                && Double.valueOf(x.getSpeed())<5.0
        //                && x.getRecordDate().compareTo(begin) == 0
        //                && x.getWindturbineId().equals(wt.getId())
        //        ).collect(Collectors.toList());

        DoubleSummaryStatistics summaryStatistics = pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
        pewp.setR35mqxpcl(summaryStatistics.getAverage());

        queryWrapper6 = new QueryWrapper<>();
        queryWrapper6.eq("record_date", begin).isNotNull("speed")
                .lt("speed", 11.0)
                .ge("speed", 5.0)
                .eq("windturbine_id", wt.getId());
        pointls = proEconCurveFittingSubService.list(queryWrapper6);
        //                  .stream().filter(x-> x.getSpeed() !=null
        //              && Double.valueOf(x.getSpeed())>=5.0
        //                && Double.valueOf(x.getSpeed())<11.0
        //                && x.getRecordDate().compareTo(begin) == 0
        //                && x.getWindturbineId().equals(wt.getId())
        //        ).collect(Collectors.toList());

        summaryStatistics = pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
        pewp.setR511mqxpcl(summaryStatistics.getAverage());

        queryWrapper6 = new QueryWrapper<>();
        queryWrapper6.eq("record_date", begin).isNotNull("speed")
                .ge("speed", 11.0)
                .eq("windturbine_id", wt.getId());
        pointls = proEconCurveFittingSubService.list(queryWrapper6);
        //                .stream().filter(x-> x.getSpeed() !=null
        //                && Double.valueOf(x.getSpeed())>=11.0
        //                && x.getRecordDate().compareTo(begin) == 0
        //                && x.getWindturbineId().equals(wt.getId())
        //        ).collect(Collectors.toList());

        summaryStatistics = pointls.stream().mapToDouble(ProEconCurveFittingSub::getDeviationRate1).summaryStatistics();
        pewp.setR11mycqxpcl(summaryStatistics.getAverage());
        //*******************************************日信息统计*********************************************************/

        //*******************************************月信息统计*********************************************************/

        Calendar c = Calendar.getInstance();
        c.setTime(begin);

        String year = String.valueOf(c.get(Calendar.YEAR));
        String month = String.valueOf(c.get(Calendar.MONTH) + 1);

        if (pepidls.isEmpty()) {
            setEquipmentInfoDay4Month(pewp);

        } else {


            ProEconEquipmentInfoDay4 pepid = pepidls.get(0);


            //获得功率一致性系数
            if (wgmap.containsKey(wt.getId())) {
                ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
                pewp.setYglyzxxs(wg.getMonthCoefficient());
            }

            //获得拟合优度
            if (wgmap.containsKey(wt.getId())) {
                ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
                pewp.setYnhyd(wg.getMonthGoodness());
            }

            if (StringUtils.notEmp(pepid2)) {


                //获得日有效风时数
                pewp.setYyxfss(StringUtils.round(c.get(Calendar.DAY_OF_MONTH) * 24 - pepid2.getYgzxsmx() - pepid2.getYjxxsmx(), 2));


            }

            if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
                //故障小时
                double ygzxsmx = pepid2.getYgzxsmx();
                //故障次数
                double ygzcsmx = pepid3.getYgzcsmx();
                if (ygzcsmx != 0) {
                    double mtbf = new BigDecimal(c.get(Calendar.DAY_OF_MONTH) * 24).divide(new BigDecimal(ygzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
                    double mttr = new BigDecimal(ygzxsmx).divide(new BigDecimal(ygzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
                    double mttf = mtbf - mttr;

                    pewp.setYmtbf(mtbf);
                    pewp.setYmttr(mttr);
                    pewp.setYmttf(mttf);
                } else {
                    double mtbf = c.get(Calendar.DAY_OF_MONTH) * 24;
                    double mttr = 0.0;
                    double mttf = mtbf - mttr;

                    pewp.setYmtbf(mtbf);
                    pewp.setYmttr(mttr);
                    pewp.setYmttf(mttf);
                }

            }


            if (peioomap.containsKey(wt.getId())) {
                //切入切出统计
                peiost = peioomap.get(wt.getId());
                //月小风切入风速
                pewp.setYxfqrfs(peiost.getMonthInputSmall());
                //月小风切出风速
                pewp.setYxfqcfs(peiost.getMonthOutputSmall());
                //月大风切入风速
                pewp.setYdfqrfs(peiost.getMonthInputBig());
                //月大风切出风速
                pewp.setYdfqcfs(peiost.getMonthOutputBig());

                if (StringUtils.notEmp(peiost)) {
                    //静风时长累计
                    pewp.setYjfsc(pewp.getYjfsc() + pepid.getRjfsc());

                    if (pewp.getYedfs() == 0) {
                        //如果没有满发，额定风速赋值保证功率达到满发的对应风速
                        pewp.setYedfs(11.0);
                    }

                    if (pewp.getRedfs() < pepid.getYedfs()) {
                        pewp.setYedfs(pewp.getRedfs());
                    } else {
                        pewp.setYedfs(pepid.getYedfs());
                    }


                    //月对风偏差次数（-50 +50之间）
                    pewp.setYdfpcl(pepid.getYdfpcl() + pewp.getRdfpcl());

                }
            }

            QueryWrapper<ProEconCurveFittMonthMain> queryWrapper4 = new QueryWrapper<>();
            queryWrapper4.eq("year", year).eq("month", month).eq("windturbine_id", wt.getId());
            List<ProEconCurveFittMonthMain> pecfmmls = proEconCurveFittMonthMainService.list(queryWrapper4);
            //                    .stream().filter(i -> i.getYear().equals(year) && i.getMonth().equals(month)
            //                    && i.getWindturbineId().equals(wt.getId())
            //            ).collect(Collectors.toList());

            if (!pecfmmls.isEmpty()) {
                ProEconCurveFittMonthMain pecfm = pecfmmls.get(0);
                pewp.setYqxpcbzysj(pecfm.getDeviationRate1());
                pewp.setYqxpcbbzsj(pecfm.getDeviationRate2());
                pewp.setYqxpcbzybz(pecfm.getDeviationRate3());
                pewp.setYqxpcbbg(pecfm.getStandardDeviationRate());
                pewp.setYqxpcbtb(pecfm.getYearDeviationRate());
                pewp.setYqxpcbhb(pecfm.getMonthDeviationRate());
            }


            //************************************************月三率统计****************************************************************/

            Calendar cal = Calendar.getInstance();
            cal.setTime(begin);
            cal.set(Calendar.DAY_OF_MONTH, 1);
            Date monthbiegin = c.getTime();

            queryWrapper2 = new QueryWrapper<>();
            queryWrapper2.ge("record_date", monthbiegin).le("record_date", end).eq("windturbine_id", wt.getId());

            pestrls = proEconEquipmentInfoDay5Service.list(queryWrapper2);
            //                    .stream()
            //                    .filter(i ->
            //                            (i.getRecordDate().compareTo(monthbiegin) == 0 || i.getRecordDate().after(monthbiegin))
            //                                    && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
            //                                    && i.getWindturbineId().equals(wt.getId())
            //                    ).collect(Collectors.toList());
            //大于3米20分钟转换及时次数
            timerate8_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate8).summaryStatistics();
            //大于3米20分钟转换及时次数合计
            timerate8_sum = timerate8_summary.getSum();

            //大于3米状态转换总次数次数
            timerate14_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate14).summaryStatistics();
            //大于3米状态转换总次数合计
            timerate14_sum = timerate14_summary.getSum();

            if (timerate14_sum != 0) {
                //月状态转换及时率
                double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
                pewp.setYztzhjsl(temp);
            } else {
                pewp.setYztzhjsl(100.0);
            }

            //20分钟复位及时次数
            timerate19_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate19).summaryStatistics();
            //20分钟复位及时次数合计
            timerate19_sum = timerate19_summary.getSum();

            //总复位次数
            timerate20_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate20).summaryStatistics();
            //总复位次数合计
            timerate20_sum = timerate20_summary.getSum();

            if (timerate20_sum != 0) {
                //月复位及时率
                double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
                pewp.setYfwjsl(temp);
            } else {
                pewp.setYfwjsl(100.0);
            }
            queryWrapper3 = new QueryWrapper<>();
            queryWrapper3.ge("date_time", monthbiegin).le("date_time", end).eq("windturbine_id", wt.getId());
            peflls = proEconFaultLiminatedefectsService.list(queryWrapper3);
            //                    .stream()
            //                    .filter(i ->
            //                            (i.getDateTime().compareTo(monthbiegin) == 0 || i.getDateTime().after(monthbiegin))
            //                                    && (i.getDateTime().compareTo(end) == 0 || i.getDateTime().before(end))
            //                                    && i.getWindturbineId().equals(wt.getId())
            //                    ).collect(Collectors.toList());
            //消缺及时次数
            right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
            //消缺及时次数合计
            right_sum = right_summary.getSum();

            //故障次数次数
            fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
            //故障次数次数合计
            fault_sum = fault_summary.getSum();

            if (fault_sum != 0) {
                //月消缺及时率
                double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
                pewp.setYgzxqjsl(temp);
            } else {
                pewp.setYgzxqjsl(100.0);
            }
            //**************************************************月三率统计****************************************************************/
            QueryWrapper<ProEconCurveFittMonthSub> queryWrapper7 = new QueryWrapper<>();
            queryWrapper7.isNotNull("speed")
                    .lt("speed", 5.0)
                    .ge("speed", 3.0)
                    .eq("year", year)
                    .eq("month", month)
                    .eq("windturbine_id", wt.getId());
            List<ProEconCurveFittMonthSub> monthpointls = proEconCurveFittMonthSubService.list(queryWrapper7);
            //            .stream().filter(x-> x.getSpeed() !=null
            //                    && Double.valueOf(x.getSpeed())>=3.0
            //                    && Double.valueOf(x.getSpeed())<5.0
            //                    && x.getYear().equals(year)
            //                    && x.getMonth().equals(month)
            //                    && x.getWindturbineId().equals(wt.getId())
            //            ).collect(Collectors.toList());

            summaryStatistics = monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
            pewp.setY35mqxpcl(summaryStatistics.getAverage());

            queryWrapper7 = new QueryWrapper<>();
            queryWrapper7.isNotNull("speed")
                    .lt("speed", 11.0)
                    .ge("speed", 5.0)
                    .eq("year", year)
                    .eq("month", month)
                    .eq("windturbine_id", wt.getId());
            monthpointls = proEconCurveFittMonthSubService.list(queryWrapper7);
            //            monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null
            //                    && Double.valueOf(x.getSpeed())>=5.0
            //                    && Double.valueOf(x.getSpeed())<11.0
            //                    && x.getYear().equals(year)
            //                    && x.getMonth().equals(month)
            //                    && x.getWindturbineId().equals(wt.getId())
            //            ).collect(Collectors.toList());

            summaryStatistics = monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
            pewp.setY511mqxpcl(summaryStatistics.getAverage());

            queryWrapper7 = new QueryWrapper<>();
            queryWrapper7.isNotNull("speed")
                    //                    .lt("speed",11.0)
                    .ge("speed", 11.0)
                    .eq("year", year)
                    .eq("month", month)
                    .eq("windturbine_id", wt.getId());
            monthpointls = proEconCurveFittMonthSubService.list(queryWrapper7);
            //            monthpointls=proEconCurveFittMonthSubService.list().stream().filter(x-> x.getSpeed() !=null
            //                    && Double.valueOf(x.getSpeed())>=11.0
            //                    && x.getYear().equals(year)
            //                    && x.getMonth().equals(month)
            //                    && x.getWindturbineId().equals(wt.getId())
            //            ).collect(Collectors.toList());

            summaryStatistics = monthpointls.stream().mapToDouble(ProEconCurveFittMonthSub::getDeviationRate1).summaryStatistics();
            pewp.setY11mycqxpcl(summaryStatistics.getAverage());
        }


        //*******************************************月信息统计*********************************************************/

        //*******************************************年信息统计*********************************************************/
        if (pepidls.isEmpty()) {
            setEquipmentInfoDay4Year(pewp);

        } else {


            ProEconEquipmentInfoDay4 pepid = pepidls.get(0);


            //获得功率一致性系数
            if (wgmap.containsKey(wt.getId())) {
                ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
                pewp.setNglyzxxs(wg.getYearCoefficient());
            }

            //获得拟合优度
            if (wgmap.containsKey(wt.getId())) {
                ProEconWindturbineGoodness wg = wgmap.get(wt.getId());
                pewp.setNnhyd(wg.getYearGoodness());
            }

            if (StringUtils.notEmp(pepid2)) {


                //获得日有效风时数
                pewp.setNyxfss(StringUtils.round(c.get(Calendar.DAY_OF_YEAR) * 24 - pepid2.getNgzxsmx() - pepid2.getNjxxsmx(), 2));


            }

            if (StringUtils.notEmp(pepid2) && StringUtils.notEmp(pepid3)) {
                //故障小时
                double ngzxsmx = pepid2.getYgzxsmx();
                //故障次数
                double ngzcsmx = pepid3.getYgzcsmx();
                if (ngzcsmx != 0) {
                    double mtbf = new BigDecimal(c.get(Calendar.DAY_OF_YEAR) * 24).divide(new BigDecimal(ngzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
                    double mttr = new BigDecimal(ngzxsmx).divide(new BigDecimal(ngzcsmx), 2, RoundingMode.HALF_EVEN).doubleValue();
                    double mttf = mtbf - mttr;

                    pewp.setNmtbf(mtbf);
                    pewp.setNmttr(mttr);
                    pewp.setNmttf(mttf);
                } else {
                    double mtbf = c.get(Calendar.DAY_OF_YEAR) * 24;
                    double mttr = 0.0;
                    double mttf = mtbf - mttr;

                    pewp.setNmtbf(mtbf);
                    pewp.setNmttr(mttr);
                    pewp.setNmttf(mttf);
                }

            }


            if (peioomap.containsKey(wt.getId())) {
                //切入切出统计
                peiost = peioomap.get(wt.getId());
                //年小风切入风速
                pewp.setNxfqrfs(peiost.getYearInputSmall());
                //年小风切出风速
                pewp.setNxfqcfs(peiost.getYearOutputSmall());
                //年大风切入风速
                pewp.setNdfqrfs(peiost.getYearInputBig());
                //年大风切出风速
                pewp.setNdfqcfs(peiost.getYearOutputBig());

                if (StringUtils.notEmp(peiost)) {
                    //静风时长累计
                    pewp.setNjfsc(pewp.getNjfsc() + pepid.getRjfsc());

                    if (pewp.getNedfs() == 0) {
                        //如果没有满发，额定风速赋值保证功率达到满发的对应风速
                        pewp.setNedfs(11.0);
                    }

                    if (pewp.getRedfs() < pepid.getNedfs()) {
                        pewp.setNedfs(pewp.getRedfs());
                    } else {
                        pewp.setNedfs(pepid.getNedfs());
                    }


                    //月对风偏差次数（-50 +50之间）
                    pewp.setNdfpcl(pepid.getNdfpcl() + pewp.getRdfpcl());


                }
            }

            QueryWrapper<ProEconCurveFittYearMain> queryWrapper8 = new QueryWrapper<>();
            queryWrapper8.eq("year", year).eq("windturbine_id", wt.getId());

            List<ProEconCurveFittYearMain> pecfYmls = proEconCurveFittYearMainService.list(queryWrapper8);
            //                    .stream().filter(i -> i.getYear().equals(year)
            //                    && i.getWindturbineId().equals(wt.getId())
            //            ).collect(Collectors.toList());

            if (!pecfYmls.isEmpty()) {
                ProEconCurveFittYearMain pecfm = pecfYmls.get(0);
                pewp.setNqxpcbzysj(pecfm.getDeviationRate1());
                pewp.setNqxpcbbzsj(pecfm.getDeviationRate2());
                pewp.setNqxpcbzybz(pecfm.getDeviationRate3());
                pewp.setNqxpcbbg(pecfm.getStandardDeviationRate());
                pewp.setNqxpcbtb(pecfm.getYearDeviationRate());
                pewp.setNqxpcbhb(pecfm.getMonthDeviationRate());
            }

            //************************************************年三率统计****************************************************************/

            Calendar cal = Calendar.getInstance();
            cal.setTime(begin);
            cal.set(Calendar.DAY_OF_YEAR, 1);
            Date yearbiegin = c.getTime();

            queryWrapper2 = new QueryWrapper<>();
            queryWrapper2.ge("record_date", yearbiegin).le("record_date", end).eq("windturbine_id", wt.getId());
            pestrls = proEconEquipmentInfoDay5Service.list(queryWrapper2);
            //                    .stream()
            //                    .filter(i ->
            //                            (i.getRecordDate().compareTo(yearbiegin) == 0 || i.getRecordDate().after(yearbiegin))
            //                                    && (i.getRecordDate().compareTo(end) == 0 || i.getRecordDate().before(end))
            //                                    && i.getWindturbineId().equals(wt.getId())
            //                    ).collect(Collectors.toList());
            //大于3米20分钟转换及时次数
            timerate8_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate8).summaryStatistics();
            //大于3米20分钟转换及时次数合计
            timerate8_sum = timerate8_summary.getSum();

            //大于3米状态转换总次数次数
            timerate14_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate14).summaryStatistics();
            //大于3米状态转换总次数合计
            timerate14_sum = timerate14_summary.getSum();

            if (timerate14_sum != 0) {
                //年状态转换及时率
                double temp = new BigDecimal(timerate8_sum).divide(new BigDecimal(timerate14_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
                pewp.setNztzhjsl(temp);
            } else {
                pewp.setNztzhjsl(100.0);
            }

            //20分钟复位及时次数
            timerate19_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate19).summaryStatistics();
            //20分钟复位及时次数合计
            timerate19_sum = timerate19_summary.getSum();

            //总复位次数
            timerate20_summary = pestrls.stream().mapToDouble(ProEconEquipmentInfoDay5::getTimerate20).summaryStatistics();
            //总复位次数合计
            timerate20_sum = timerate20_summary.getSum();

            if (timerate20_sum != 0) {
                //年复位及时率
                double temp = new BigDecimal(timerate19_sum).divide(new BigDecimal(timerate20_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
                pewp.setNfwjsl(temp);
            } else {
                pewp.setNfwjsl(100.0);
            }
            queryWrapper3 = new QueryWrapper<>();
            queryWrapper3.ge("date_time", yearbiegin).le("date_time", end).eq("windturbine_id", wt.getId());
            peflls = proEconFaultLiminatedefectsService.list(queryWrapper3);
            //                    .stream()
            //                    .filter(i ->
            //                            (i.getDateTime().compareTo(yearbiegin) == 0 || i.getDateTime().after(yearbiegin))
            //                                    && (i.getDateTime().compareTo(end) == 0 || i.getDateTime().before(end))
            //                                    && i.getWindturbineId().equals(wt.getId())
            //                    ).collect(Collectors.toList());
            //消缺及时次数
            right_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getRightCount).summaryStatistics();
            //消缺及时次数合计
            right_sum = right_summary.getSum();

            //故障次数次数
            fault_summary = peflls.stream().mapToDouble(ProEconFaultLiminatedefects::getFaultCount).summaryStatistics();
            //故障次数次数合计
            fault_sum = fault_summary.getSum();

            if (fault_sum != 0) {
                //年消缺及时率
                double temp = new BigDecimal(right_sum).divide(new BigDecimal(fault_sum), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();
                pewp.setNgzxqjsl(temp);
            } else {
                pewp.setNgzxqjsl(100.0);
            }
            //**************************************************年三率统计****************************************************************/
            QueryWrapper<ProEconCurveFittYearSub> queryWrapper7 = new QueryWrapper<>();
            queryWrapper.isNotNull("speed")
                    .lt("speed", 5.0)
                    .ge("speed", 3.0)
                    .eq("year", year)
                    .eq("windturbine_id", wt.getId());
            List<ProEconCurveFittYearSub> yearpointls = proEconCurveFittYearSubService.list(queryWrapper7);
            //                    .stream().filter(x-> x.getSpeed() !=null
            //                    && Double.valueOf(x.getSpeed())>=3.0
            //                    && Double.valueOf(x.getSpeed())<5.0
            //                    && x.getYear().equals(year)
            //                    && x.getWindturbineId().equals(wt.getId())
            //            ).collect(Collectors.toList());

            summaryStatistics = yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
            pewp.setN35mqxpcl(summaryStatistics.getAverage());
            queryWrapper7 = new QueryWrapper<>();
            queryWrapper7.isNotNull("speed")
                    .lt("speed", 11.0)
                    .ge("speed", 5.0)
                    .eq("year", year)
                    .eq("windturbine_id", wt.getId());
            yearpointls = proEconCurveFittYearSubService.list(queryWrapper7);
            //                    .stream().filter(x-> x.getSpeed() !=null
            //                    && Double.valueOf(x.getSpeed())>=5.0
            //                    && Double.valueOf(x.getSpeed())<11.0
            //                    && x.getYear().equals(year)
            //                    && x.getWindturbineId().equals(wt.getId())
            //            ).collect(Collectors.toList());

            summaryStatistics = yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
            pewp.setN511mqxpcl(summaryStatistics.getAverage());
            queryWrapper7 = new QueryWrapper<>();
            queryWrapper.isNotNull("speed")
                    .ge("speed", 11.0)
                    .eq("year", year)
                    .eq("windturbine_id", wt.getId());
            yearpointls = proEconCurveFittYearSubService.list(queryWrapper7);
            //            yearpointls=proEconCurveFittYearSubService.list().stream().filter(x-> x.getSpeed() !=null
            //                    && Double.valueOf(x.getSpeed())>=11.0
            //                    && x.getYear().equals(year)
            //                     && x.getWindturbineId().equals(wt.getId())
            //            ).collect(Collectors.toList());

            summaryStatistics = yearpointls.stream().mapToDouble(ProEconCurveFittYearSub::getDeviationRate1).summaryStatistics();
            pewp.setN11mycqxpcl(summaryStatistics.getAverage());
        }

    }

    private static void setEquipmentInfoDay4Year(ProEconEquipmentInfoDay4 pewp) {

        //* 年静风时长

        pewp.setNjfsc(pewp.getRjfsc());


        //* 年有效风时数

        pewp.setNyxfss(pewp.getRyxfss());


        //* 年小风切入风速

        pewp.setNxfqrfs(pewp.getRxfqrfs());


        //* 年大风切入风速

        pewp.setNdfqrfs(pewp.getRdfqrfs());


        //* 年小风切出风速

        pewp.setNxfqcfs(pewp.getRxfqcfs());


        //* 年大风切出风速

        pewp.setNdfqcfs(pewp.getRdfqcfs());


        //* 年额定风速

        pewp.setNedfs(pewp.getRedfs());


        //* 年功率一致性系数

        pewp.setNglyzxxs(pewp.getRglyzxxs());


        //* 年拟合优度

        pewp.setNnhyd(pewp.getRnhyd());


        //* 年曲线偏差率最优保证

        pewp.setNqxpcbzybz(pewp.getRqxpcbzybz());


        //* 年曲线偏差率最优实际

        pewp.setNqxpcbzysj(pewp.getRqxpcbzysj());


        //* 年曲线偏差率保证实际

        pewp.setNqxpcbbzsj(pewp.getRqxpcbbzsj());


        //* 年曲线偏差率同比

        pewp.setNqxpcbtb(pewp.getRqxpcbtb());


        //* 年曲线偏差率环比

        pewp.setNqxpcbhb(pewp.getRqxpcbhb());


        //* 年曲线偏差率标杆

        pewp.setNqxpcbbg(pewp.getRqxpcbbg());


        //* 年3-5米曲线偏差率

        pewp.setN35mqxpcl(pewp.getR35mqxpcl());


        //* 年5-11米曲线偏差率

        pewp.setN511mqxpcl(pewp.getR511mqxpcl());


        //* 年11米以上曲线偏差率

        pewp.setN11mycqxpcl(pewp.getR11mycqxpcl());


        //* 年对风偏差率（-50 +50之间）

        pewp.setNdfpcl(pewp.getRdfpcl());


        //* 年MTBF

        pewp.setNmtbf(pewp.getRmtbf());


        //* 年MTTR

        pewp.setNmttr(pewp.getRmttr());


        //* 年MTTF

        pewp.setNmttf(pewp.getRmttf());


        //* 年复位及时率

        pewp.setNfwjsl(pewp.getRfwjsl());


        //* 年状态转换及时率

        pewp.setNztzhjsl(pewp.getRztzhjsl());


        //* 年故障消缺及时率

        pewp.setNgzxqjsl(pewp.getRgzxqjsl());
    }

    private static void setEquipmentInfoDay4Month(ProEconEquipmentInfoDay4 pewp) {

        //* 月静风时长

        pewp.setYjfsc(pewp.getRjfsc());


        //* 月有效风时数

        pewp.setYyxfss(pewp.getRyxfss());


        //* 月小风切入风速

        pewp.setYxfqrfs(pewp.getRxfqrfs());


        //* 月大风切入风速

        pewp.setYdfqrfs(pewp.getRdfqrfs());


        //* 月小风切出风速

        pewp.setYxfqcfs(pewp.getRxfqcfs());


        //* 月大风切出风速

        pewp.setYdfqcfs(pewp.getRdfqcfs());


        //* 月额定风速

        pewp.setYedfs(pewp.getRedfs());


        //* 月功率一致性系数

        pewp.setYglyzxxs(pewp.getRglyzxxs());


        //* 月拟合优度

        pewp.setYnhyd(pewp.getRnhyd());


        //* 月曲线偏差率最优保证

        pewp.setYqxpcbzybz(pewp.getRqxpcbzybz());


        //* 月曲线偏差率最优实际

        pewp.setYqxpcbzysj(pewp.getRqxpcbzysj());


        //* 月曲线偏差率保证实际

        pewp.setYqxpcbbzsj(pewp.getRqxpcbbzsj());


        //* 月曲线偏差率同比

        pewp.setYqxpcbtb(pewp.getRqxpcbtb());


        //* 月曲线偏差率环比

        pewp.setYqxpcbhb(pewp.getRqxpcbhb());


        //* 月曲线偏差率标杆

        pewp.setYqxpcbbg(pewp.getRqxpcbbg());


        //* 月3-5米曲线偏差率

        pewp.setY35mqxpcl(pewp.getR35mqxpcl());


        //* 月5-11米曲线偏差率

        pewp.setY511mqxpcl(pewp.getR511mqxpcl());


        //* 月11米以上曲线偏差率

        pewp.setY11mycqxpcl(pewp.getR11mycqxpcl());


        //* 月对风偏差率（-50 +50之间）

        pewp.setYdfpcl(pewp.getRdfpcl());


        //* 月MTBF

        pewp.setYmtbf(pewp.getRmtbf());


        //* 月MTTR

        pewp.setYmttr(pewp.getRmttr());


        //* 月MTTF

        pewp.setYmttf(pewp.getRmttf());


        //* 月复位及时率

        pewp.setYfwjsl(pewp.getRfwjsl());


        //* 月状态转换及时率

        pewp.setYztzhjsl(pewp.getRztzhjsl());


        // //* 月故障消缺及时率

        pewp.setYgzxqjsl(pewp.getRgzxqjsl());
    }


}







