package com.gyee.runeconomy.service.singleanalysis;

import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.common.model.StringUtils;
import com.gyee.runeconomy.init.CacheContext;
import com.gyee.runeconomy.model.auto.*;
import com.gyee.runeconomy.model.vo.SingleAnalysisVo;
import com.gyee.runeconomy.service.auto.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;


@Service
public class SingleAnalysisService {

    @Resource
    private IProEconInOrOutSpeedTotalService proEconInOrOutSpeedTotalService;
    @Resource
    private IProEconEquipmentInfoDay1Service proEconEquipmentInfoDay1Service;
    @Resource
    private IProEconEquipmentInfoDay2Service proEconEquipmentInfoDay2Service;

    @Resource
    private IProEconEquipmentInfoDay4Service proEconEquipmentInfoDay4Service;
    @Resource
    private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;

    @Resource
    private ITurbineInfoDayService turbineInfoDayService;

    private Map<String, ProEconInOrOutSpeedTotal> queryInOrOutSpeedTotal(String cmId, String type, String wpId, Date recordDate) {

        List<ProEconInOrOutSpeedTotal> iostls = null;
        if (StringUtils.notEmp(wpId)) {
            QueryWrapper<ProEconInOrOutSpeedTotal> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("windpowerstation_id", wpId);
            if (StringUtils.notEmp(type) && !type.equals("0")) {
                queryWrapper.eq("types", type);
            }
            iostls = proEconInOrOutSpeedTotalService.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getTypes().equals(type)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.cpmap.containsKey(cmId)) {
            QueryWrapper<ProEconInOrOutSpeedTotal> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("company_id", cmId);
            if (StringUtils.notEmp(type) && !type.equals("0")) {
                queryWrapper.eq("types", type);
            }
            iostls = proEconInOrOutSpeedTotalService.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getTypes().equals(type)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.rgmap.containsKey(cmId)) {
            QueryWrapper<ProEconInOrOutSpeedTotal> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("region_Id", cmId);
            if (StringUtils.notEmp(type) && !type.equals("0")) {
                queryWrapper.eq("types", type);
            }
            iostls = proEconInOrOutSpeedTotalService.list(queryWrapper);
            //                    .stream().filter(i-> i.getCompanyId().equals(cmId)
            //                            && i.getTypes().equals(type)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        }

        //List转map
        Map<String, ProEconInOrOutSpeedTotal> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconInOrOutSpeedTotal::getWindturbineId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }

    private Map<String, ProEconEquipmentInfoDay1> queryEquipmentInfoDay1(String cmId, String type, String wpId, Date recordDate) {


        List<ProEconEquipmentInfoDay1> iostls = null;
        if (StringUtils.notEmp(wpId)) {
            QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("windpowerstation_id", wpId);

            iostls = proEconEquipmentInfoDay1Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.cpmap.containsKey(cmId)) {
            QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("company_id", cmId);

            iostls = proEconEquipmentInfoDay1Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.rgmap.containsKey(cmId)) {
            QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("region_Id", cmId);

            iostls = proEconEquipmentInfoDay1Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        }


        //List转map
        Map<String, ProEconEquipmentInfoDay1> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconEquipmentInfoDay1::getWindturbineId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }

    private Map<String, ProEconEquipmentInfoDay2> queryEquipmentInfoDay2(String cmId, String type, String wpId, Date recordDate) {

        List<ProEconEquipmentInfoDay2> iostls = null;

        if (StringUtils.notEmp(wpId)) {
            QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("windpowerstation_id", wpId);

            iostls = proEconEquipmentInfoDay2Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.cpmap.containsKey(cmId)) {
            QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("company_id", cmId);

            iostls = proEconEquipmentInfoDay2Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.rgmap.containsKey(cmId)) {
            QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("region_Id", cmId);

            iostls = proEconEquipmentInfoDay2Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        }
        //List转map
        Map<String, ProEconEquipmentInfoDay2> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconEquipmentInfoDay2::getWindturbineId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }

    private Map<String, ProEconPowerstationInfoDay5> queryPowerstationInfoDay5(String cmId, String type, String wpId, Date recordDate) {


        List<ProEconPowerstationInfoDay5> iostls = null;
        if (StringUtils.notEmp(wpId)) {
            QueryWrapper<ProEconPowerstationInfoDay5> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("windpowerstation_id", wpId);
            if (StringUtils.notEmp(type)) {
                queryWrapper.eq("foreign_key_id", wpId + type);
            }
            iostls = proEconPowerstationInfoDay5Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.cpmap.containsKey(cmId)) {
            QueryWrapper<ProEconPowerstationInfoDay5> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("company_id", cmId);
            if (StringUtils.notEmp(type)) {
                queryWrapper.eq("foreign_key_id", cmId + type);
            }
            iostls = proEconPowerstationInfoDay5Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.rgmap.containsKey(cmId)) {
            QueryWrapper<ProEconPowerstationInfoDay5> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("region_Id", cmId);
            if (StringUtils.notEmp(type)) {
                queryWrapper.eq("foreign_key_id", cmId + type);
            }
            iostls = proEconPowerstationInfoDay5Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        }

        //                .stream().filter(i->
        //                        i.getCompanyId() !=null
        //                                && i.getCompanyId().equals(cmId)
        //                                && i.getRecordDate().compareTo(recordDate) == 0
        //                )
        //                .collect(Collectors.toList());
        //List转map
        Map<String, ProEconPowerstationInfoDay5> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconPowerstationInfoDay5::getWindpowerstationId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }

    private Map<String, ProEconPowerstationInfoDay5> queryPowerstationInfoDay5(String wpId, Date recordDate) {


        List<ProEconPowerstationInfoDay5> iostls = new ArrayList<>();
        if (StringUtils.notEmp(wpId)) {
            QueryWrapper<ProEconPowerstationInfoDay5> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("windpowerstation_id", wpId);

            iostls = proEconPowerstationInfoDay5Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        }

        //                .stream().filter(i->
        //                        i.getCompanyId() !=null
        //                                && i.getCompanyId().equals(cmId)
        //                                && i.getRecordDate().compareTo(recordDate) == 0
        //                )
        //                .collect(Collectors.toList());
        //List转map
        Map<String, ProEconPowerstationInfoDay5> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconPowerstationInfoDay5::getWindpowerstationId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }

    private Map<String, ProEconEquipmentInfoDay4> queryEquipmentInfoDay4(String cmId, String type, String wpId, Date recordDate) {


        List<ProEconEquipmentInfoDay4> iostls = null;
        if (StringUtils.notEmp(wpId)) {
            QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("windpowerstation_id", wpId);

            iostls = proEconEquipmentInfoDay4Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.cpmap.containsKey(cmId)) {
            QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("company_id", cmId);

            iostls = proEconEquipmentInfoDay4Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        } else if (StringUtils.notEmp(cmId) && CacheContext.rgmap.containsKey(cmId)) {
            QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("record_date", recordDate)
                    .eq("region_Id", cmId);

            iostls = proEconEquipmentInfoDay4Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindpowerstationId().equals(wpId)
            //                            && i.getCompanyId().equals(cmId)
            //                            && i.getRecordDate().compareTo(recordDate) == 0
            //                    )
            //                    .collect(Collectors.toList());
        }
        //List转map
        Map<String, ProEconEquipmentInfoDay4> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconEquipmentInfoDay4::getWindturbineId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }

    //*************************************************************************************************************************************************************/
    private Map<String, ProEconInOrOutSpeedTotal> queryInOrOutSpeedTotalByWt(String wtId, Date recordDate) {


        QueryWrapper<ProEconInOrOutSpeedTotal> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("record_date", recordDate)
                .eq("windturbine_id", wtId);
        List<ProEconInOrOutSpeedTotal> iostls = proEconInOrOutSpeedTotalService.list(queryWrapper);
        //                .stream().filter(i->i.getWindturbineId().equals(wtId)
        //                        && i.getRecordDate().compareTo(recordDate) == 0
        //                )
        //                .collect(Collectors.toList());
        //List转map
        Map<String, ProEconInOrOutSpeedTotal> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconInOrOutSpeedTotal::getWindturbineId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }

    private Map<String, ProEconEquipmentInfoDay1> queryEquipmentInfoDay1ByWt(String wtId, Date recordDate) {

        QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("record_date", recordDate)
                .eq("windturbine_id", wtId);
        List<ProEconEquipmentInfoDay1> iostls = proEconEquipmentInfoDay1Service.list(queryWrapper);
        //                .stream().filter(i->i.getWindturbineId().equals(wtId)
        //                        && i.getRecordDate().compareTo(recordDate) == 0
        //                )
        //                .collect(Collectors.toList());
        //List转map
        Map<String, ProEconEquipmentInfoDay1> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconEquipmentInfoDay1::getWindturbineId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }

    private Map<String, ProEconEquipmentInfoDay2> queryEquipmentInfoDay2ByWt(String wtId, Date recordDate) {

        QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("record_date", recordDate)
                .eq("windturbine_id", wtId);
        List<ProEconEquipmentInfoDay2> iostls = proEconEquipmentInfoDay2Service.list(queryWrapper);
        //                .stream().filter(i->i.getWindturbineId().equals(wtId)
        //                        && i.getRecordDate().compareTo(recordDate) == 0
        //                )
        //                .collect(Collectors.toList());
        //List转map
        Map<String, ProEconEquipmentInfoDay2> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconEquipmentInfoDay2::getWindturbineId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }


    private Map<String, ProEconEquipmentInfoDay4> queryEquipmentInfoDay4ByWt(String wtId, Date recordDate) {

        QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("record_date", recordDate)
                .eq("windturbine_id", wtId);
        List<ProEconEquipmentInfoDay4> iostls = proEconEquipmentInfoDay4Service.list(queryWrapper);
        //                .stream().filter(i->i.getWindturbineId().equals(wtId)
        //                        && i.getRecordDate().compareTo(recordDate) == 0
        //                )
        //                .collect(Collectors.toList());
        //List转map
        Map<String, ProEconEquipmentInfoDay4> iostmap = iostls.stream().
                collect(Collectors.toMap(ProEconEquipmentInfoDay4::getWindturbineId, Function.identity(), (key1, key2) -> key2));
        return iostmap;
    }


    public Map<String, Object> SingleAnalysisList(Integer pageNum, Integer pageSize, String cmId, String type, String wpId, Date recordDate) {

        List<SingleAnalysisVo> vos = new ArrayList<>();

        if (StringUtils.notEmp(cmId) && StringUtils.notEmp(recordDate)) {

            Map<String, ProEconInOrOutSpeedTotal> iostmap = queryInOrOutSpeedTotal(cmId, type, wpId, recordDate);
            Map<String, ProEconEquipmentInfoDay1> eqday1map = queryEquipmentInfoDay1(cmId, type, wpId, recordDate);
            Map<String, ProEconEquipmentInfoDay2> eqday2map = queryEquipmentInfoDay2(cmId, type, wpId, recordDate);
            Map<String, ProEconPowerstationInfoDay5> pwday5map = queryPowerstationInfoDay5(cmId, type, wpId, recordDate);
            Map<String, ProEconEquipmentInfoDay4> eqday4map = queryEquipmentInfoDay4(cmId, type, wpId, recordDate);

            List<ProBasicEquipment> wtls = new ArrayList<>();
            if (StringUtils.isNotEmpty(wpId)) {
                if (CacheContext.wpwtmap.containsKey(wpId)) {
                    wtls = CacheContext.wpwtmap.get(wpId);
                }

            } else if (StringUtils.isNotEmpty(cmId) && CacheContext.cpmap.containsKey(cmId)) {
                if (CacheContext.cmwtlsmap.containsKey(cmId)) {
                    wtls = CacheContext.cmwtlsmap.get(cmId);
                }

            } else if (StringUtils.isNotEmpty(cmId) && CacheContext.rgmap.containsKey(cmId)) {
                if (CacheContext.rgwtlsmap.containsKey(cmId)) {
                    wtls = CacheContext.rgwtlsmap.get(cmId);
                }
            }

            //if (CacheContext.cmwtlsmap.containsKey(wpId)) {
            //                List<ProBasicEquipment> wtls = CacheContext.cmwtlsmap.get(wpId);

            for (ProBasicEquipment wt : wtls) {
                SingleAnalysisVo vo = new SingleAnalysisVo();
                vo.setWindPowerStationId(wt.getWindpowerstationId());
                vo.setWindturbineName(wt.getAname());
                vo.setWtcode(wt.getAname());
                if (CacheContext.wpmap.containsKey(wt.getWindpowerstationId())) {
                    ProBasicPowerstation wp = CacheContext.wpmap.get(wt.getWindpowerstationId());
                    vo.setWindPowerStationName(wp.getName());
                }

                if (CacheContext.modelMap.containsKey(wt.getModelId())) {
                    ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId());
                    vo.setFjrl(model.getPowerProduction());
                }

                vo.setRecorddate(recordDate);
                vo.setWindturbineid(wt.getId());

                Calendar c = Calendar.getInstance();

                c.setTime(recordDate);
                int dayTimes = c.get(Calendar.DAY_OF_MONTH) * 24;//风机日历小时合计
                double fdl = 0;
                if (eqday1map.containsKey(wt.getId())) {

                    ProEconEquipmentInfoDay1 wtd = eqday1map.get(wt.getId());

                    fdl = null != wtd.getYfdl() ? wtd.getYfdl() : 0.0;//风机发电量合计
                    // fdl = new BigDecimal(fdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                    double fs = null != wtd.getYpjfs() ? wtd.getYpjfs() : 0.0;//风机平均风速

                    double gzss = null != wtd.getYgzssdl() ? wtd.getYgzssdl() : 0.0;//风机故障损失合计
                    double jxss = null != wtd.getYjxssdl() ? wtd.getYjxssdl() : 0.0;//风机检修损失合计
                    double xdss = null != wtd.getYxdtjssdl() ? wtd.getYxdtjssdl() : 0.0;//风机限电损失合计
                    double xnss = null != wtd.getYxnssdl() ? wtd.getYxnssdl() : 0.0;//风机性能损失时合计
                    double ycwsldwssdl = null != wtd.getYcwsldwssdl() ? wtd.getYcwsldwssdl() : 0.0;//场外受累电网损失电量
                    double ycwsltqssdl = null != wtd.getYcwsltqssdl() ? wtd.getYcwsldwssdl() : 0.0;//场外受累天气损失电量
                    double slss = StringUtils.round(ycwsldwssdl + ycwsltqssdl, 2);

                    double llfdl = fdl + gzss + jxss + xdss + xnss + slss; //理论发电量

                    vo.setGzss(StringUtils.round(gzss / 10000, 2));
                    vo.setJxss(StringUtils.round(jxss / 10000, 2));
                    vo.setXdss(StringUtils.round(xdss / 10000, 2));
                    vo.setXnss(StringUtils.round(xnss / 10000, 2));
                    vo.setSlss(StringUtils.round(xnss / 10000, 2));
                    vo.setLlfdl(StringUtils.round(llfdl / 10000, 2));

                    double powerProduction = 0;
                    if (CacheContext.modelMap.containsKey(wt.getModelId())) {
                        ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId());
                        powerProduction = model.getPowerProduction();
                    }
                    double lyxs = 0.0;
                    if (powerProduction != 0) {
                        lyxs = new BigDecimal(fdl).divide(new BigDecimal(powerProduction), 2, RoundingMode.HALF_EVEN).doubleValue();//风机平均利用小时
                    }


                    vo.setFdl(StringUtils.round(fdl / 10000, 2));
                    vo.setRlxs(StringUtils.round(dayTimes, 2));
                    vo.setFs(StringUtils.round(fs, 2));


                    vo.setLyxs(StringUtils.round(lyxs, 2));


                }

                if (eqday2map.containsKey(wt.getId())) {

                    ProEconEquipmentInfoDay2 wtd = eqday2map.get(wt.getId());

                    double yxxs = null != wtd.getYyxxs() ? wtd.getYyxxs() : 0.0;//风机运行小时合计
                    double gzxs = null != wtd.getYgztjxs() ? wtd.getYgztjxs() : 0.0;//风机故障小时合计
                    double jxxs = null != wtd.getYjxtjxs() ? wtd.getYjxtjxs() : 0.0;//风机检修小时合计
                    double tjxs = null != wtd.getYxdxs() ? wtd.getYxdxs() : 0.0;//风限电小时合计
                    double zdxs = null != wtd.getYtxzdxs() ? wtd.getYtxzdxs() : 0.0;//风机中断小时合计
                    double sbklyl = new BigDecimal(dayTimes - gzxs).divide(new BigDecimal(dayTimes), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();//风机平均设备可利用率
                    double dxklyxs = new BigDecimal(dayTimes - gzxs - jxxs).divide(new BigDecimal(dayTimes), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();//风机平均等效可利用系数


                    double yxfss = dayTimes - gzxs - jxxs;//风机平均有效风
                    vo.setYxfss(StringUtils.round(yxfss, 2));
                    vo.setDxklyxs(StringUtils.round(dxklyxs, 2));
                    vo.setSbklyl(StringUtils.round(sbklyl, 2));
                    vo.setYxxs(StringUtils.round(yxxs, 2));
                    vo.setGzxs(StringUtils.round(gzxs, 2));
                    vo.setJxxs(StringUtils.round(jxxs, 2));
                    vo.setTjxs(StringUtils.round(tjxs, 2));
                    vo.setZdxs(StringUtils.round(zdxs, 2));


                }

                if (eqday4map.containsKey(wt.getId())) {

                    ProEconEquipmentInfoDay4 wtd = eqday4map.get(wt.getId());

                    double glyzxxs = null != wtd.getYglyzxxs() ? wtd.getYglyzxxs() : 0.0;//风机平均功率一致性系数
                    vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));
                    double jfsc = null != wtd.getYjfsc() ? wtd.getYjfsc() : 0.0;//静风时长
                    double jfpl = new BigDecimal(jfsc).divide(new BigDecimal(dayTimes), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();//静风频率

                    vo.setJfpl(jfpl);

                }

                if (iostmap.containsKey(wt.getId())) {

                    ProEconInOrOutSpeedTotal wtd = iostmap.get(wt.getId());


                    double xfqr = null != wtd.getMonthInputSmall() ? wtd.getMonthInputSmall() : 0.0;//风机小风切入
                    double xfqrhgl = null != wtd.getMonthInputSmallRatio() ? wtd.getMonthInputSmallRatio() : 0.0;//风机小风切入合格率
                    vo.setXfqr(StringUtils.round(xfqr, 2));
                    vo.setXfqrhgl(StringUtils.round(xfqrhgl, 2));

                }

                vos.add(vo);
            }

            //}


            if (null != vos && !vos.isEmpty()) {

                //统计所有风机指标数据
                SingleAnalysisVo vo = new SingleAnalysisVo();
                vo.setWindturbineName("合计");

                if (pwday5map.containsKey(wpId)) {
                    ProEconPowerstationInfoDay5 day5 = pwday5map.get(wpId);
                    double swdl = day5.getYswdldb().doubleValue();//风场上网电量合计
                    double gwdl = day5.getYgwgwdldb().doubleValue() + day5.getYnwgwdldb().doubleValue();//风场购网电量合计
                    vo.setSwdl(StringUtils.round(swdl, 2));
                    vo.setGwdl(StringUtils.round(gwdl, 2));
                }


                double fdl = 0.0;//风机发电量合计
                double yxxs = 0.0;//风机运行小时合计
                double gzxs = 0.0;//风机故障小时合计
                double jxxs = 0.0;//风机检修小时合计
                double tjxs = 0.0;//风机停机小时合计
                double zdxs = 0.0;//风机中断小时合计
                double rlxs = 0.0;//风机日历小时合计

                double fs = 0.0;//风机平均风速
                double sbklyl = 0.0;//风机平均设备可利用率
                double dxklyxs = 0.0;//风机平均等效可利用系数
                double lyxs = 0.0;//风机平均利用小时
                double yxfss = 0.0;//风机平均有效风时速
                double glyzxxs = 0.0;//风机平均功率一致性系数

                double xfqr = 0.0;//风机小风切入
                double xfqrhgl = 0.0;//风机小风切入合格率

                int xfqrnum = 0;
                int xfqrhglnum = 0;

                int fsnum = 0;
                int sbklylnum = 0;
                int dxklyxsnum = 0;
                int lyxsnum = 0;
                int yxfssnum = 0;
                int glyzxxsnum = 0;

                for (SingleAnalysisVo wtd : vos) {
                    double temp = null != wtd.getFdl() ? wtd.getFdl() : 0.0;//风机发电量合计
                    fdl = fdl + temp;
                    temp = null != wtd.getYxxs() ? wtd.getYxxs() : 0.0;//风机运行小时合计
                    yxxs = yxxs + temp;
                    temp = null != wtd.getGzxs() ? wtd.getGzxs() : 0.0;//风机故障小时合计
                    gzxs = gzxs + temp;
                    temp = null != wtd.getJxxs() ? wtd.getJxxs() : 0.0;//风机检修小时合计
                    jxxs = jxxs + temp;
                    temp = null != wtd.getTjxs() ? wtd.getTjxs() : 0.0;//风机停机小时合计
                    tjxs = tjxs + temp;
                    temp = null != wtd.getZdxs() ? wtd.getZdxs() : 0.0;//风机中断小时合计
                    zdxs = zdxs + temp;
                    temp = null != wtd.getRlxs() ? wtd.getRlxs() : 0.0;//风机日历小时合计
                    rlxs = rlxs + temp;

                    temp = null != wtd.getFs() ? wtd.getFs() : 0.0;//风机平均风速
                    fs = fs + temp;
                    if (StringUtils.notEmp(wtd.getFs())) {
                        fsnum++;
                    }
                    temp = null != wtd.getSbklyl() ? wtd.getSbklyl() : 0.0;//风机平均设备可利用率
                    sbklyl = sbklyl + temp;
                    if (StringUtils.notEmp(wtd.getSbklyl())) {
                        sbklylnum++;
                    }
                    temp = null != wtd.getDxklyxs() ? wtd.getDxklyxs() : 0.0;//风机平均等效可利用系数
                    dxklyxs = dxklyxs + temp;
                    if (StringUtils.notEmp(wtd.getDxklyxs())) {
                        dxklyxsnum++;
                    }
                    temp = null != wtd.getLyxs() ? wtd.getLyxs() : 0.0;//风机平均利用小时
                    lyxs = lyxs + temp;
                    if (StringUtils.notEmp(wtd.getLyxs())) {
                        lyxsnum++;
                    }
                    temp = null != wtd.getYxfss() ? wtd.getYxfss() : 0.0;//风机平均有效风时速
                    yxfss = yxfss + temp;
                    if (StringUtils.notEmp(wtd.getYxfss())) {
                        yxfssnum++;
                    }
                    temp = null != wtd.getGlyzxxs() ? wtd.getGlyzxxs() : 0.0;//风机平均功率一致性系数
                    glyzxxs = glyzxxs + temp;
                    if (StringUtils.notEmp(wtd.getGlyzxxs())) {
                        glyzxxsnum++;
                    }

                    temp = null != wtd.getXfqr() ? wtd.getXfqr() : 0.0;//风机小风切入
                    xfqr = xfqr + temp;
                    if (StringUtils.notEmp(wtd.getXfqr())) {
                        xfqrnum++;
                    }
                    temp = null != wtd.getXfqrhgl() ? wtd.getXfqrhgl() : 0.0;//风机小风切入合格率
                    xfqrhgl = xfqrhgl + temp;
                    if (StringUtils.notEmp(wtd.getXfqrhgl())) {
                        xfqrhglnum++;
                    }
                }

                if (fsnum != 0) {
                    double temp = new BigDecimal(fs).divide(new BigDecimal(fsnum), 2, RoundingMode.HALF_UP).doubleValue();
                    vo.setFs(temp);
                }
                if (sbklylnum != 0) {
                    double temp = new BigDecimal(sbklyl).divide(new BigDecimal(sbklylnum), 2, RoundingMode.HALF_UP).doubleValue();
                    vo.setSbklyl(temp);
                }

                if (dxklyxsnum != 0) {
                    double temp = new BigDecimal(dxklyxs).divide(new BigDecimal(dxklyxsnum), 2, RoundingMode.HALF_UP).doubleValue();
                    vo.setDxklyxs(temp);
                }

                if (lyxsnum != 0) {
                    double temp = new BigDecimal(lyxs).divide(new BigDecimal(lyxsnum), 2, RoundingMode.HALF_UP).doubleValue();
                    vo.setLyxs(temp);
                }

                if (yxfssnum != 0) {
                    double temp = new BigDecimal(yxfss).divide(new BigDecimal(yxfssnum), 2, RoundingMode.HALF_UP).doubleValue();
                    vo.setYxfss(temp);
                }

                if (glyzxxsnum != 0) {
                    double temp = new BigDecimal(glyzxxs).divide(new BigDecimal(glyzxxsnum), 2, RoundingMode.HALF_UP).doubleValue();
                    vo.setGlyzxxs(temp);
                }


                vo.setFdl(StringUtils.round(fdl, 2));
                vo.setYxxs(StringUtils.round(yxxs, 2));
                vo.setGzxs(StringUtils.round(gzxs, 2));
                vo.setJxxs(StringUtils.round(jxxs, 2));
                vo.setTjxs(StringUtils.round(tjxs, 2));
                vo.setZdxs(StringUtils.round(zdxs, 2));
                vo.setRlxs(StringUtils.round(rlxs, 2));
                vo.setFs(StringUtils.round(fs, 2));
                vo.setSbklyl(StringUtils.round(sbklyl, 2));
                vo.setDxklyxs(StringUtils.round(dxklyxs, 2));
                vo.setLyxs(StringUtils.round(lyxs, 2));
                vo.setYxxs(StringUtils.round(yxfss, 2));
                vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));

                double gzss = vos.stream().filter(i -> i.getGzss() != null).mapToDouble(SingleAnalysisVo::getGzss).sum();//风机故障损失合计
                double jxss = vos.stream().filter(i -> i.getJxss() != null).mapToDouble(SingleAnalysisVo::getJxss).sum();//风机检修损失合计
                double xdss = vos.stream().filter(i -> i.getXdss() != null).mapToDouble(SingleAnalysisVo::getXdss).sum();//风机限电损失合计
                double xnss = vos.stream().filter(i -> i.getXnss() != null).mapToDouble(SingleAnalysisVo::getXnss).sum();//风机性能损失时合计
                double slss = vos.stream().filter(i -> i.getSlss() != null).mapToDouble(SingleAnalysisVo::getSlss).sum();//风机受累损失合计
                double llfdl = fdl + gzss + jxss + xdss + xnss + slss;

                vo.setGzss(StringUtils.round(gzss, 2));
                vo.setJxss(StringUtils.round(jxss, 2));
                vo.setXdss(StringUtils.round(xdss, 2));
                vo.setXnss(StringUtils.round(xnss, 2));
                vo.setSlss(StringUtils.round(slss, 2));
                vo.setLlfdl(StringUtils.round(llfdl, 2));


                if (xfqrnum != 0) {
                    double temp = new BigDecimal(xfqr).divide(new BigDecimal(xfqrnum), 2, RoundingMode.HALF_UP).doubleValue();
                    vo.setXfqr(temp);
                }

                if (xfqrhglnum != 0) {
                    double temp = new BigDecimal(xfqrhgl).divide(new BigDecimal(xfqrhglnum), 2, RoundingMode.HALF_UP).doubleValue();
                    vo.setXfqrhgl(temp);
                }

                vos.add(vo);
            }
        }


        //总数
        int total = vos.size();
        //总页数
        int pageSum = total % pageSize == 0 ? total / pageSize : total / pageSize + 1;

        //分页
        List<SingleAnalysisVo> subList = vos.stream().skip((pageNum - 1) * pageSize).limit(pageSize).
                collect(Collectors.toList());


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

        map.put("total", vos.size());
        map.put("pageSum", pageSum);
        map.put("values", subList);
        //        PageHelper.startPage(pageNum, pageSize);
        //        PageInfo<SingleAnalysisVo> pageInfo = new PageInfo<SingleAnalysisVo>(vos);
        //        return pageInfo.getList();
        return map;
    }


    public SingleAnalysisVo SingleAnalysisListByWtId(String wtId, Date recordDate) {

        SingleAnalysisVo vo = new SingleAnalysisVo();

        vo.setSwdl(0.0);
        vo.setGwdl(0.0);
        vo.setGzss(0.0);
        vo.setJxss(0.0);
        vo.setXdss(0.0);
        vo.setXnss(0.0);
        vo.setSlss(0.0);
        vo.setLlfdl(0.0);
        vo.setFdl(0.0);
        vo.setRlxs(0.0);
        vo.setFs(0.0);
        vo.setYxxs(0.0);
        vo.setDxklyxs(0.0);
        vo.setSbklyl(0.0);
        vo.setGzxs(0.0);
        vo.setJxxs(0.0);
        vo.setTjxs(0.0);
        vo.setZdxs(0.0);
        vo.setJfpl(0.0);
        vo.setXfqr(0.0);
        vo.setXfqrhgl(0.0);
        vo.setLyxs(0.0);
        vo.setYxfss(0.0);
        vo.setGlyzxxs(0.0);
        if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recordDate) && CacheContext.wtmap.containsKey(wtId)) {


            ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
            vo.setWindPowerStationId(wt.getWindpowerstationId());
            ProBasicPowerstation wp = CacheContext.wpmap.get(wt.getWindpowerstationId());


            vo.setWindPowerStationName(wp.getName());
            vo.setWindturbineName(wt.getName());
            if (CacheContext.modelMap.containsKey(wt.getModelId())) {
                ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId());
                vo.setFjrl(model.getPowerProduction());
            }


            vo.setWindturbineid(wt.getId());

            Map<String, ProEconInOrOutSpeedTotal> iostmap = queryInOrOutSpeedTotalByWt(wtId, recordDate);
            Map<String, ProEconEquipmentInfoDay1> eqday1map = queryEquipmentInfoDay1ByWt(wtId, recordDate);
            Map<String, ProEconEquipmentInfoDay2> eqday2map = queryEquipmentInfoDay2ByWt(wtId, recordDate);
            Map<String, ProEconEquipmentInfoDay4> eqday4map = queryEquipmentInfoDay4ByWt(wtId, recordDate);
            Map<String, ProEconPowerstationInfoDay5> pwday5map = queryPowerstationInfoDay5(wt.getWindpowerstationId(), recordDate);
            String wpId = CacheContext.wtmap.get(wtId).getWindpowerstationId();


            if (iostmap.isEmpty() && eqday1map.isEmpty() && eqday2map.isEmpty() && pwday5map.isEmpty() && pwday5map.isEmpty()) {
                return vo;
            }


            if (pwday5map.containsKey(wpId)) {
                ProEconPowerstationInfoDay5 day5 = pwday5map.get(wpId);
                double swdl = day5.getYswdldb().doubleValue();//风场上网电量合计
                double gwdl = day5.getYgwgwdldb().doubleValue() + day5.getYnwgwdldb().doubleValue();//风场购网电量合计
                vo.setSwdl(StringUtils.round(swdl, 2));
                vo.setGwdl(StringUtils.round(gwdl, 2));
            }


            Calendar c = Calendar.getInstance();

            c.setTime(recordDate);
            int dayTimes = c.get(Calendar.DAY_OF_MONTH) * 24;//风机日历小时合计
            double fdl = 0;
            if (eqday1map.containsKey(wt.getId())) {

                ProEconEquipmentInfoDay1 wtd = eqday1map.get(wt.getId());

                fdl = null != wtd.getYfdl() ? wtd.getYfdl() : 0.0;//风机发电量合计
                fdl = new BigDecimal(fdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                double fs = null != wtd.getYpjfs() ? wtd.getYpjfs() : 0.0;//风机平均风速

                double gzss = null != wtd.getYgzssdl() ? wtd.getYgzssdl() : 0.0;//风机故障损失合计
                gzss = new BigDecimal(gzss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                double jxss = null != wtd.getYjxssdl() ? wtd.getYjxssdl() : 0.0;//风机检修损失合计
                jxss = new BigDecimal(jxss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                double xdss = null != wtd.getYxdtjssdl() ? wtd.getYxdtjssdl() : 0.0;//风机限电损失合计
                xdss = new BigDecimal(xdss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                double xnss = null != wtd.getYxnssdl() ? wtd.getYxnssdl() : 0.0;//风机性能损失时合计
                xnss = new BigDecimal(xnss).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                double ycwsldwssdl = null != wtd.getYcwsldwssdl() ? wtd.getYcwsldwssdl() : 0.0;//场外受累电网损失电量
                ycwsldwssdl = new BigDecimal(ycwsldwssdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                double ycwsltqssdl = null != wtd.getYcwsltqssdl() ? wtd.getYcwsldwssdl() : 0.0;//场外受累天气损失电量
                ycwsltqssdl = new BigDecimal(ycwsltqssdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                double slss = StringUtils.round(ycwsldwssdl + ycwsltqssdl, 2);

                double llfdl = fdl + gzss + jxss + xdss + xnss + slss; //理论发电量

                vo.setGzss(StringUtils.round(gzss, 2));
                vo.setJxss(StringUtils.round(jxss, 2));
                vo.setXdss(StringUtils.round(xdss, 2));
                vo.setXnss(StringUtils.round(xnss, 2));
                vo.setSlss(StringUtils.round(xnss, 2));
                vo.setLlfdl(StringUtils.round(llfdl, 2));

                double powerProduction = 0;
                if (CacheContext.modelMap.containsKey(wt.getModelId())) {
                    ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId());
                    powerProduction = model.getPowerProduction();
                }
                double lyxs = 0.0;
                if (powerProduction != 0) {
                    lyxs = new BigDecimal(wtd.getYfdl()).divide(new BigDecimal(powerProduction), 2, RoundingMode.HALF_EVEN).doubleValue();//风机平均利用小时
                }


                vo.setFdl(StringUtils.round(fdl, 2));
                vo.setRlxs(StringUtils.round(dayTimes, 2));
                vo.setFs(StringUtils.round(fs, 2));


                vo.setLyxs(StringUtils.round(lyxs, 2));


            }

            //            vo.setYxfss(StringUtils.round(dayTimes, 2));
            if (eqday2map.containsKey(wt.getId())) {

                ProEconEquipmentInfoDay2 wtd = eqday2map.get(wt.getId());

                double yxxs = null != wtd.getYyxxs() ? wtd.getYyxxs() : 0.0;//风机运行小时合计
                double gzxs = null != wtd.getYgztjxs() ? wtd.getYgztjxs() : 0.0;//风机故障小时合计
                double jxxs = null != wtd.getYjxtjxs() ? wtd.getYjxtjxs() : 0.0;//风机检修小时合计
                double djxs = null != wtd.getYdjxs() ? wtd.getYdjxs() : 0.0;//风机待机小时合计
                double tjxs = null != wtd.getYxdxs() ? wtd.getYxdxs() : 0.0;//风限电小时合计
                double zdxs = null != wtd.getYtxzdxs() ? wtd.getYtxzdxs() : 0.0;//风机中断小时合计
                double sbklyl = new BigDecimal(dayTimes - gzxs).divide(new BigDecimal(dayTimes), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();//风机平均设备可利用率
                double dxklyxs = new BigDecimal(dayTimes - gzxs - jxxs).divide(new BigDecimal(dayTimes), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();//风机平均等效可利用系数


                double yxfss = dayTimes - gzxs - jxxs;//风机平均有效风

                //                System.out.println(yxfss);
                vo.setYxfss(StringUtils.round(yxfss, 2));
                vo.setDxklyxs(StringUtils.round(dxklyxs, 2));
                vo.setSbklyl(StringUtils.round(sbklyl, 2));
                vo.setYxxs(StringUtils.round(yxxs, 2));
                vo.setGzxs(StringUtils.round(gzxs, 2));
                vo.setJxxs(StringUtils.round(jxxs, 2));
                vo.setTjxs(StringUtils.round(tjxs, 2));
                vo.setZdxs(StringUtils.round(zdxs, 2));
                vo.setDjxs(StringUtils.round(djxs, 2));

            }

            if (eqday4map.containsKey(wt.getId())) {

                ProEconEquipmentInfoDay4 wtd = eqday4map.get(wt.getId());

                double glyzxxs = null != wtd.getYglyzxxs() ? wtd.getYglyzxxs() : 0.0;//风机平均功率一致性系数
                vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));
                double jfsc = null != wtd.getYjfsc() ? wtd.getYjfsc() : 0.0;//静风时长
                double jfpl = new BigDecimal(jfsc).divide(new BigDecimal(dayTimes), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();//静风频率

                vo.setJfpl(jfpl);

            }

            if (iostmap.containsKey(wt.getId())) {

                ProEconInOrOutSpeedTotal wtd = iostmap.get(wt.getId());


                double xfqr = null != wtd.getMonthInputSmall() ? wtd.getMonthInputSmall() : 0.0;//风机小风切入
                double xfqrhgl = null != wtd.getMonthInputSmallRatio() ? wtd.getMonthInputSmallRatio() : 0.0;//风机小风切入合格率
                vo.setXfqr(StringUtils.round(xfqr, 2));
                vo.setXfqrhgl(StringUtils.round(xfqrhgl, 2));

            }
        }
        return vo;
    }


    public Map<String, List<SingleAnalysisVo>> SingleAnalysisListByWtIdDetiml(String wtId, Date beginDate, Date endDate) {

        Map<String, List<SingleAnalysisVo>> map = new HashMap<>();
        List<SingleAnalysisVo> fdlfsls = new ArrayList<>();
        List<SingleAnalysisVo> wsls = new ArrayList<>();
        List<SingleAnalysisVo> jfpldjsjls = new ArrayList<>();
        if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {


            Map<String, Map<Long, ProEconEquipmentInfoDay1>> day1map = new HashMap<>();
            Map<String, Map<Long, ProEconEquipmentInfoDay2>> day2map = new HashMap<>();

            QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("windturbine_id", wtId).ge("record_date", beginDate)
                    .le("record_date", endDate);
            List<ProEconEquipmentInfoDay1> wtday1ls = proEconEquipmentInfoDay1Service.list(queryWrapper);
            //                    .stream().filter(i->i.getWindturbineId() !=null && i.getWindturbineId().equals(wtId)
            //                            && ( i.getRecordDate().compareTo(beginDate)==0 || i.getRecordDate().after(beginDate))
            //                            && (i.getRecordDate().compareTo(endDate)==0 || i.getRecordDate().before(endDate))
            //                    )
            //                    .collect(Collectors.toList());
            if (!wtday1ls.isEmpty()) {
                for (ProEconEquipmentInfoDay1 wtday1 : wtday1ls) {
                    if (day1map.containsKey(wtday1.getWindturbineId())) {
                        Map<Long, ProEconEquipmentInfoDay1> tempmap = day1map.get(wtday1.getWindturbineId());
                        tempmap.put(wtday1.getRecordDate().getTime(), wtday1);
                        day1map.put(wtId, tempmap);
                    } else {
                        Map<Long, ProEconEquipmentInfoDay1> tempmap = new HashMap<>();
                        tempmap.put(wtday1.getRecordDate().getTime(), wtday1);
                        day1map.put(wtId, tempmap);
                    }
                }
            }
            QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper2 = new QueryWrapper<>();
            queryWrapper2.eq("windturbine_id", wtId).ge("record_date", beginDate)
                    .le("record_date", endDate);
            List<ProEconEquipmentInfoDay2> wtday2ls = proEconEquipmentInfoDay2Service.list(queryWrapper2);
            //                    .stream().filter(i->i.getWindturbineId().equals(wtId)
            //                            && ( i.getRecordDate().compareTo(beginDate)==0 || i.getRecordDate().after(beginDate))
            //                            && (i.getRecordDate().compareTo(endDate)==0 || i.getRecordDate().before(endDate))
            //                    )
            //                    .collect(Collectors.toList());
            if (!wtday2ls.isEmpty()) {
                for (ProEconEquipmentInfoDay2 wtday2 : wtday2ls) {
                    if (day2map.containsKey(wtday2.getWindturbineId())) {
                        Map<Long, ProEconEquipmentInfoDay2> tempmap = day2map.get(wtday2.getWindturbineId());
                        tempmap.put(wtday2.getRecordDate().getTime(), wtday2);
                        day2map.put(wtId, tempmap);
                    } else {
                        Map<Long, ProEconEquipmentInfoDay2> tempmap = new HashMap<>();
                        tempmap.put(wtday2.getRecordDate().getTime(), wtday2);
                        day2map.put(wtId, tempmap);
                    }
                }
            }
            QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper4 = new QueryWrapper<>();
            queryWrapper4.eq("windturbine_id", wtId).ge("record_date", beginDate)
                    .le("record_date", endDate);
            List<ProEconEquipmentInfoDay4> wtday4ls = proEconEquipmentInfoDay4Service.list(queryWrapper4);
            //                    .stream().filter(i->i.getWindturbineId().equals(wtId)
            //                            && ( i.getRecordDate().compareTo(beginDate)==0 || i.getRecordDate().after(beginDate))
            //                            && (i.getRecordDate().compareTo(endDate)==0 || i.getRecordDate().before(endDate))
            //                    )
            //                    .collect(Collectors.toList());
            ProBasicEquipment wt = CacheContext.wtmap.get(wtId);
            ProBasicPowerstation wp = CacheContext.wpmap.get(wt.getWindpowerstationId());

            if (StringUtils.notEmp(wtday2ls) && !wtday2ls.isEmpty()) {

                for (ProEconEquipmentInfoDay2 wtd : wtday2ls) {

                    SingleAnalysisVo vo = new SingleAnalysisVo();

                    Calendar c = Calendar.getInstance();

                    c.setTime(wtd.getRecordDate());
                    int dayTimes = 24;//风机日历小时合计


                    if (day1map.containsKey(wtd.getWindturbineId())) {
                        Map<Long, ProEconEquipmentInfoDay1> map1 = day1map.get(wtd.getWindturbineId());
                        if (map1.containsKey(wtd.getRecordDate().getTime())) {
                            ProEconEquipmentInfoDay1 daypo = map1.get(wtd.getRecordDate().getTime());
                            double fdl = null != daypo.getRfdl() ? daypo.getRfdl() : 0.0;//风机发电量合计
                            if (CacheContext.modelMap.containsKey(wt.getModelId())) {
                                ProEconEquipmentmodel model = CacheContext.modelMap.get(wt.getModelId());
                                double lyxs = new BigDecimal(fdl).divide(new BigDecimal(model.getPowerProduction()), 2, RoundingMode.HALF_UP).doubleValue();
                                vo.setLyxs(lyxs);
                            }

                            fdl = new BigDecimal(fdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();
                            double fs = null != daypo.getRpjfs() ? daypo.getRpjfs() : 0.0;//风机平均风速
                            vo.setFdl(StringUtils.round(fdl, 2));
                            vo.setFs(StringUtils.round(fs, 2));
                        }
                    }

                    double yxxs = null != wtd.getRyxxs() ? wtd.getRyxxs() : 0.0;//风机运行小时合计
                    double gzxs = null != wtd.getRgztjxs() ? wtd.getRgztjxs() : 0.0;//风机故障小时合计
                    double jxxs = null != wtd.getRjxtjxs() ? wtd.getRjxtjxs() : 0.0;//风机检修小时合计
                    double tjxs = null != wtd.getRxdxs() ? wtd.getRxdxs() : 0.0;//风限电小时合计
                    double zdxs = null != wtd.getRtxzdxs() ? wtd.getRtxzdxs() : 0.0;//风机中断小时合计

                    vo.setWindPowerStationId(wt.getWindpowerstationId());
                    vo.setWindPowerStationName(wp.getName());
                    vo.setWindturbineName(wt.getName());
                    vo.setWindturbineid(wt.getId());
                    vo.setRecorddate(wtd.getRecordDate());


                    vo.setYxxs(StringUtils.round(yxxs, 2));
                    vo.setGzxs(StringUtils.round(gzxs, 2));
                    vo.setJxxs(StringUtils.round(jxxs, 2));
                    vo.setTjxs(StringUtils.round(tjxs, 2));
                    vo.setZdxs(StringUtils.round(zdxs, 2));
                    vo.setRlxs(StringUtils.round(dayTimes, 2));

                    fdlfsls.add(vo);

                }

            }

            if (StringUtils.notEmp(wtday1ls) && !wtday1ls.isEmpty()) {
                for (ProEconEquipmentInfoDay1 wtd : wtday1ls) {
                    SingleAnalysisVo vo = new SingleAnalysisVo();
                    double gzss = null != wtd.getRgzssdl() ? wtd.getRgzssdl() : 0.0;//风机故障损失合计
                    double jxss = null != wtd.getRjxssdl() ? wtd.getRjxssdl() : 0.0;//风机检修损失合计
                    double xdss = null != wtd.getRxdtjssdl() ? wtd.getRxdtjssdl() : 0.0;//风机限电损失合计
                    double xnss = null != wtd.getRxnssdl() ? wtd.getRxnssdl() : 0.0;//风机性能损失时合计
                    double ycwsldwssdl = null != wtd.getRcwsldwssdl() ? wtd.getRcwsldwssdl() : 0.0;//场外受累电网损失电量
                    double ycwsltqssdl = null != wtd.getRcwsltqssdl() ? wtd.getRcwsldwssdl() : 0.0;//场外受累天气损失电量
                    double slss = StringUtils.round(ycwsldwssdl + ycwsltqssdl, 2);


                    vo.setWindPowerStationId(wt.getWindpowerstationId());
                    vo.setWindPowerStationName(wp.getName());
                    vo.setWindturbineName(wt.getName());
                    vo.setWindturbineid(wt.getId());
                    vo.setRecorddate(wtd.getRecordDate());

                    vo.setGzss(StringUtils.round(gzss, 2));
                    vo.setJxss(StringUtils.round(jxss, 2));
                    vo.setXdss(StringUtils.round(xdss, 2));
                    vo.setXnss(StringUtils.round(xnss, 2));
                    vo.setSlss(StringUtils.round(slss, 2));
                    wsls.add(vo);
                }

            }


            if (StringUtils.notEmp(wtday4ls) && !wtday4ls.isEmpty()) {

                for (ProEconEquipmentInfoDay4 wtd : wtday4ls) {

                    SingleAnalysisVo vo = new SingleAnalysisVo();

                    vo.setRecorddate(wtd.getRecordDate());

                    double jfsc = null != wtd.getRjfsc() ? wtd.getRjfsc() : 0.0;//静风时长
                    double jfpl = new BigDecimal(jfsc).divide(new BigDecimal(24), 2, RoundingMode.HALF_EVEN).multiply(new BigDecimal(100)).doubleValue();//静风频率

                    vo.setJfpl(StringUtils.round(jfpl, 2));
                    if (day2map.containsKey(wtd.getWindturbineId())) {
                        Map<Long, ProEconEquipmentInfoDay2> map2 = day2map.get(wtd.getWindturbineId());
                        if (map2.containsKey(wtd.getRecordDate().getTime())) {
                            ProEconEquipmentInfoDay2 daypo = map2.get(wtd.getRecordDate().getTime());
                            vo.setTjxs(daypo.getRdjxsmx());
                        }
                    }

                    vo.setWindPowerStationId(wt.getWindpowerstationId());
                    vo.setWindPowerStationName(wp.getName());
                    vo.setWindturbineName(wt.getName());
                    vo.setWindturbineid(wt.getId());


                    jfpldjsjls.add(vo);
                }

            }

            map.put("ff", fdlfsls);//发电量和风速
            map.put("ws", wsls);//五项损失，绑定五个
            map.put("jd", jfpldjsjls);//静风频率和待机时间

        }

        return map;
    }

    public SingleAnalysisVo SingleAnalysisListByWtId(SingleAnalysisVo vo1, SingleAnalysisVo vo2) {

        SingleAnalysisVo vo = new SingleAnalysisVo();

        vo.setWindturbineName(vo1.getWindturbineName());
        vo.setWindturbineid(vo1.getWindturbineid());
        vo.setWindPowerStationName(vo1.getWindPowerStationName());
        vo.setWindPowerStationId(vo1.getWindPowerStationId());

        vo.setFdl(0.0);
        vo.setYxxs(0.0);
        vo.setGzxs(0.0);
        vo.setJxxs(0.0);
        vo.setTjxs(0.0);
        vo.setZdxs(0.0);
        vo.setRlxs(0.0);
        vo.setFs(0.0);
        vo.setSbklyl(0.0);
        vo.setDxklyxs(0.0);
        vo.setLyxs(0.0);
        vo.setYxfss(0.0);

        vo.setGzss(0.0);
        vo.setJxss(0.0);
        vo.setXdss(0.0);
        vo.setXnss(0.0);
        vo.setSlss(0.0);
        vo.setXfqr(0.0);
        vo.setXfqrhgl(0.0);
        vo.setJfpl(0.0);
        vo.setLlfdl(0.0);
        vo.setGlyzxxs(0.0);
        if (StringUtils.notEmp(vo1) && StringUtils.notEmp(vo2) && vo2.getFdl() != 0 && vo2.getFs() != 0) {

            vo.setWindturbineName(vo1.getWindturbineName());
            vo.setWindturbineid(vo1.getWindturbineid());
            vo.setWindPowerStationName(vo1.getWindPowerStationName());
            vo.setWindPowerStationId(vo1.getWindPowerStationId());

            double fdl = 0.0;//风机发电量
            double yxxs = 0.0;//风机运行小时合计
            double gzxs = 0.0;//风机故障小时合计
            double jxxs = 0.0;//风机检修小时合计
            double tjxs = 0.0;//风机停机小时合计
            double zdxs = 0.0;//风机中断小时合计
            double rlxs = 0.0;//风机日历小时合计

            double fs = 0.0;//风机平均风速
            double sbklyl = 0.0;//风机平均设备可利用率
            double dxklyxs = 0.0;//风机平均等效可利用系数
            double lyxs = 0.0;//风机平均利用小时
            double yxfss = 0.0;//风机平均有效风时速
            double glyzxxs = 0.0;//风机平均功率一致性系数

            double gzss = 0.0;//风机故障损失合计
            double jxss = 0.0;//风机检修损失合计
            double xdss = 0.0;//风机限电损失合计
            double xnss = 0.0;//风机性能损失时合计
            double slss = 0.0;//风机受累损失合计
            double xfqr = 0.0;//风机小风切入
            double xfqrhgl = 0.0;//风机小风切入合格率
            double jfpl = 0.0;//风机小风切入

            if (vo2.getFdl() != 0) {
                fdl = new BigDecimal(vo1.getFdl()).divide(new BigDecimal(vo2.getFdl()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1))
                        .multiply(new BigDecimal(100)).doubleValue();//风机发电量合计

            } else {
                fdl = new BigDecimal(vo1.getFdl()).multiply(new BigDecimal(100)).doubleValue();//风机发电量合计
            }

            if (vo2.getYxxs() != 0) {
                yxxs = new BigDecimal(vo1.getYxxs()).divide(new BigDecimal(vo2.getYxxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1))
                        .multiply(new BigDecimal(100)).doubleValue();//风机运行小时合计

            } else {
                yxxs = new BigDecimal(vo1.getYxxs()).multiply(new BigDecimal(100)).doubleValue();//风机运行小时合计
            }
            if (vo2.getGzxs() != 0) {
                gzxs = new BigDecimal(vo1.getGzxs()).divide(new BigDecimal(vo2.getGzxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机故障小时合计

            } else {
                gzxs = new BigDecimal(vo1.getGzxs()).multiply(new BigDecimal(100)).doubleValue();//风机故障小时合计

            }
            if (vo2.getJxxs() != 0) {
                jxxs = new BigDecimal(vo1.getJxxs()).divide(new BigDecimal(vo2.getJxxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机检修小时合计

            } else {
                jxxs = new BigDecimal(vo1.getJxxs()).multiply(new BigDecimal(100)).doubleValue();//风机检修小时合计


            }

            if (vo2.getTjxs() != 0) {
                tjxs = new BigDecimal(vo1.getTjxs()).divide(new BigDecimal(vo2.getTjxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机停机小时合计

            } else {
                tjxs = new BigDecimal(vo1.getTjxs()).multiply(new BigDecimal(100)).doubleValue();//风机停机小时合计


            }

            if (vo2.getZdxs() != 0) {
                zdxs = new BigDecimal(vo1.getZdxs()).divide(new BigDecimal(vo2.getZdxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机中断小时合计

            } else {
                zdxs = new BigDecimal(vo1.getZdxs()).multiply(new BigDecimal(100)).doubleValue();//风机中断小时合计


            }

            if (vo2.getRlxs() != 0) {
                rlxs = new BigDecimal(vo1.getRlxs()).divide(new BigDecimal(vo2.getRlxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机日历小时合计

            } else {
                rlxs = new BigDecimal(vo1.getRlxs()).multiply(new BigDecimal(100)).doubleValue();//风机日历小时合计


            }
            if (vo2.getFs() != 0) {
                fs = new BigDecimal(vo1.getFs()).divide(new BigDecimal(vo2.getFs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机平均风速

            } else {
                fs = new BigDecimal(vo1.getFs()).multiply(new BigDecimal(100)).doubleValue();//风机平均风速

            }

            if (vo2.getSbklyl() != 0) {
                sbklyl = new BigDecimal(vo1.getSbklyl()).divide(new BigDecimal(vo2.getSbklyl()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机平均设备可利用率

            } else {
                sbklyl = new BigDecimal(vo1.getSbklyl()).multiply(new BigDecimal(100)).doubleValue();//风机平均设备可利用率

            }

            if (vo2.getDxklyxs() != 0) {
                dxklyxs = new BigDecimal(vo1.getDxklyxs()).divide(new BigDecimal(vo2.getDxklyxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机平均等效可利用系数

            } else {
                dxklyxs = new BigDecimal(vo1.getDxklyxs()).multiply(new BigDecimal(100)).doubleValue();//风机平均等效可利用系数

            }

            if (vo2.getLyxs() != 0) {
                lyxs = new BigDecimal(vo1.getLyxs()).divide(new BigDecimal(vo2.getLyxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机平均利用小时

            } else {
                lyxs = new BigDecimal(vo1.getLyxs()).multiply(new BigDecimal(100)).doubleValue();//风机平均利用小时

            }

            if (vo2.getYxfss() != 0) {
                yxfss = new BigDecimal(vo1.getYxfss()).divide(new BigDecimal(vo2.getYxfss()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机平均有效风时速

            } else {
                yxfss = new BigDecimal(vo1.getYxfss()).multiply(new BigDecimal(100)).doubleValue();//风机平均有效风时速

            }

            vo.setFdl(StringUtils.round(fdl, 2));
            vo.setYxxs(StringUtils.round(yxxs, 2));
            vo.setGzxs(StringUtils.round(gzxs, 2));
            vo.setJxxs(StringUtils.round(jxxs, 2));
            vo.setTjxs(StringUtils.round(tjxs, 2));
            vo.setZdxs(StringUtils.round(zdxs, 2));
            vo.setRlxs(StringUtils.round(rlxs, 2));
            vo.setFs(StringUtils.round(fs, 2));
            vo.setSbklyl(StringUtils.round(sbklyl, 2));
            vo.setDxklyxs(StringUtils.round(dxklyxs, 2));
            vo.setLyxs(StringUtils.round(lyxs, 2));
            vo.setYxfss(StringUtils.round(yxfss, 2));


            if (vo2.getGlyzxxs() != 0) {
                glyzxxs = new BigDecimal(vo1.getGlyzxxs()).divide(new BigDecimal(vo2.getGlyzxxs()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机平均功率一致性系数

            } else {
                glyzxxs = new BigDecimal(vo1.getGlyzxxs()).multiply(new BigDecimal(100)).doubleValue();//风机平均功率一致性系数

            }
            vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));

            if (vo2.getGzss() != 0) {
                gzss = new BigDecimal(vo1.getGzss()).divide(new BigDecimal(vo2.getGzss()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机故障损失合计

            } else {
                gzss = new BigDecimal(vo1.getGzss()).multiply(new BigDecimal(100)).doubleValue();//风机故障损失合计

            }

            if (vo2.getJxss() != 0) {
                jxss = new BigDecimal(vo1.getJxss()).divide(new BigDecimal(vo2.getJxss()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机检修损失合计

            } else {
                jxss = new BigDecimal(vo1.getJxss()).multiply(new BigDecimal(100)).doubleValue();//风机检修损失合计

            }

            if (vo2.getXdss() != 0) {
                xdss = new BigDecimal(vo1.getXdss()).divide(new BigDecimal(vo2.getXdss()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机限电损失合计

            } else {
                xdss = new BigDecimal(vo1.getXdss()).multiply(new BigDecimal(100)).doubleValue();//风机限电损失合计

            }

            if (vo2.getXnss() != 0) {
                xnss = new BigDecimal(vo1.getXnss()).divide(new BigDecimal(vo2.getXnss()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机性能损失时合计

            } else {
                xnss = new BigDecimal(vo1.getXnss()).multiply(new BigDecimal(100)).doubleValue();//风机性能损失时合计

            }
            if (vo2.getSlss() != 0) {
                slss = new BigDecimal(vo1.getSlss()).divide(new BigDecimal(vo2.getSlss()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机受累损失合计

            } else {
                slss = new BigDecimal(vo1.getSlss()).multiply(new BigDecimal(100)).doubleValue();//风机受累损失合计

            }

            double llfdl = fdl + gzss + jxss + xdss + xnss + slss;

            vo.setGzss(StringUtils.round(gzss, 2));
            vo.setJxss(StringUtils.round(jxss, 2));
            vo.setXdss(StringUtils.round(xdss, 2));
            vo.setXnss(StringUtils.round(xnss, 2));
            vo.setSlss(StringUtils.round(slss, 2));

            vo.setLlfdl(StringUtils.round(llfdl, 2));
            if (vo2.getXfqr() != 0) {
                xfqr = new BigDecimal(vo1.getXfqr()).divide(new BigDecimal(vo2.getXfqr()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机小风切入

            } else {
                xfqr = new BigDecimal(vo1.getXfqr()).multiply(new BigDecimal(100)).doubleValue();//风机小风切入

            }

            if (vo2.getXfqrhgl() != 0) {
                xfqrhgl = new BigDecimal(vo1.getXfqrhgl()).divide(new BigDecimal(vo2.getXfqrhgl()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机小风切入合格率

            } else {
                xfqrhgl = new BigDecimal(vo1.getXfqrhgl()).multiply(new BigDecimal(100)).doubleValue();//风机小风切入合格率

            }
            vo.setXfqr(StringUtils.round(xfqr, 2));
            vo.setXfqrhgl(StringUtils.round(xfqrhgl, 2));

            if (vo2.getJfpl() != 0) {
                jfpl = new BigDecimal(vo1.getJfpl()).divide(new BigDecimal(vo2.getJfpl()), 2, RoundingMode.HALF_UP).subtract(new BigDecimal(1)).multiply(new BigDecimal(100)).doubleValue();//风机小风切入

            } else {
                jfpl = new BigDecimal(vo1.getJfpl()).multiply(new BigDecimal(100)).doubleValue();//风机小风切入

            }
            vo.setJfpl(StringUtils.round(jfpl, 2));
        }
        return vo;
    }


    public SingleAnalysisVo SingleAnalysisTurbineinfoday(String wtId, String year, String month, SingleAnalysisVo byzb) {
        String date = year + "-" + month;
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        qw.lambda().eq(TurbineInfoDay::getTurbineId, wtId)
                .apply("to_char(record_date,'YYYY-MM')='" + date + "'");
        List<TurbineInfoDay> list = turbineInfoDayService.list(qw);
        double rfdl = list.stream().mapToDouble(TurbineInfoDay::getRfdl).sum();
        byzb.setFdl(NumberUtil.round(rfdl/1000,2).doubleValue());
        double pjfs = list.stream().mapToDouble(TurbineInfoDay::getPjfs).average().orElse(0.0);
        byzb.setFs(NumberUtil.round(pjfs,2).doubleValue());
        double gzss = list.stream().mapToDouble(TurbineInfoDay::getGzss).sum();
        byzb.setGzss(NumberUtil.round(gzss/1000,2).doubleValue());
        double jhjxss = list.stream().mapToDouble(TurbineInfoDay::getJhjxss).sum();
        byzb.setJxss(NumberUtil.round(jhjxss/1000,2).doubleValue());
        double xdss = list.stream().mapToDouble(TurbineInfoDay::getXdss).sum();
        byzb.setXdss(NumberUtil.round(xdss/1000,2).doubleValue());
        double xnss = list.stream().mapToDouble(TurbineInfoDay::getXnss).sum();
        byzb.setXnss(NumberUtil.round(xnss/1000,2).doubleValue());
        double slss = list.stream().mapToDouble(TurbineInfoDay::getXnss).sum();
        byzb.setSlss(NumberUtil.round(slss/1000,2).doubleValue());
        double llfdl = list.stream().mapToDouble(TurbineInfoDay::getXnss).sum();
        byzb.setLlfdl(NumberUtil.round(llfdl/1000,2).doubleValue());
        double gzmin = list.stream().mapToDouble(TurbineInfoDay::getGzMin).sum();
        byzb.setGzxs(NumberUtil.round(gzmin/60,2).doubleValue());
        double jxmin = list.stream().mapToDouble(TurbineInfoDay::getJxMin).sum();
        byzb.setJxxs(NumberUtil.round(jxmin/60,2).doubleValue());
        double lxmin = list.stream().mapToDouble(TurbineInfoDay::getLxMin).sum();
        byzb.setZdxs(NumberUtil.round(lxmin/60,2).doubleValue());
        double yxmin = list.stream().mapToDouble(TurbineInfoDay::getYxMin).sum();
        byzb.setYxxs(NumberUtil.round(yxmin/60,2).doubleValue());
        double djmin = list.stream().mapToDouble(TurbineInfoDay::getDjMin).sum();
        byzb.setDjxs(NumberUtil.round(djmin/60,2).doubleValue());
        double sblyxs = list.stream().mapToDouble(TurbineInfoDay::getLyxs).sum();
        byzb.setLyxs(NumberUtil.round(sblyxs,2).doubleValue());
        double sbklyl = list.stream().mapToDouble(TurbineInfoDay::getKlyl).average().orElse(0.0);
        byzb.setSbklyl(NumberUtil.round(sbklyl,2).doubleValue());
        return byzb;
    }
}
