package com.gyee.runeconomy.service.bmk;
/*
@author   谢生杰
@date   2022/11/23-11:06
*/

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.common.model.StringUtils;
import com.gyee.common.util.BigDecimalUtils;
import com.gyee.common.util.DateUtils;
import com.gyee.common.util.DoubleUtils;
import com.gyee.common.util.SortUtils;
import com.gyee.common.vo.benchmark.FjjxbVo;
import com.gyee.common.vo.benchmark.FjjxbmxVo;
import com.gyee.common.vo.benchmark.WxsslVo;
import com.gyee.runeconomy.init.CacheContext;
import com.gyee.runeconomy.mapper.auto.ProEconEquipmentInfoDay1Mapper;
import com.gyee.runeconomy.model.auto.*;
import com.gyee.runeconomy.service.TokenService;
import com.gyee.runeconomy.service.auto.IProEconEquipmentInfoDay1Service;
import com.gyee.runeconomy.service.auto.ITurbineInfoDayService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;

@Service
public class BenchmarkingService {


    private final String TYPE_DATE = "date";
    private final String TYPE_WIND = "wind";
    private final String TYPE_PROJECT = "project";
    private final String TYPE_LINE = "line";
    private final String TYPE_WINDTURBINE = "windturbine";

    @Resource
    private TokenService tokenService;
    @Resource
    private IProEconEquipmentInfoDay1Service proEconEquipmentInfoDay1Service;

    @Resource
    private ProEconEquipmentInfoDay1Mapper proEconEquipmentInfoDay1Mapper;

    @Resource
    private ITurbineInfoDayService iTurbineInfoDayService;


    public List<ProBasicCompany> companys() {
        List<ProBasicCompany> cpls = CacheContext.cpls;
        Map<String, ProBasicRegion> rgmap = CacheContext.rgmap;
        List<ProBasicCompany> result = new ArrayList<>();
        cpls.stream().forEach(cp -> {
            result.add(cp);
        });
        //单区域部署打开
        //        ProBasicCompany company = new ProBasicCompany();
        //        Optional<ProBasicCompany> first = result.stream().findFirst();
        //        if (first.isPresent()){
        //            String regionId = first.get().getRegionId();
        //            company.setId(regionId);
        //            company.setAname(rgmap.get(regionId).getAname());
        //            company.setOrderNum(0);
        //        }
        //        result.add(company);

        SortUtils.sort(result, "orderNum", SortUtils.ASC);


        return result;
    }

    public List<ProBasicSubStation> subByCplist(String companyids, String type) {

        //        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
        //        List<ProBasicSubStation> list = tokenService.getSubwpls(request);
        List<ProBasicSubStation> list = CacheContext.subwpls;


        if (StringUtils.isNotEmpty(type) && !type.equals("0")) {
            String finalType = type.equals("-1") ? "_FDC" : "_GDC";
            list = list.stream().filter(wp -> wp.getWindpowerstationId().indexOf(finalType) >= 0).collect(Collectors.toList());
        }

        SortUtils.sort(list, "orderNum", SortUtils.ASC);
        return list;

    }

    public List<ProBasicPowerstation> wpByCplist(String companyids, String type) {

        //        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
        //        List<ProBasicPowerstation> list = tokenService.getWpls(request);
        List<ProBasicPowerstation> list = CacheContext.wpls;

        if (StringUtils.isNotEmpty(type) && !type.equals("0")) {
            String finalType = type.equals("-1") ? "_FDC" : "_GDC";
            list = list.stream().filter(wp -> wp.getId().indexOf(finalType) >= 0).collect(Collectors.toList());
        }

        if (companyids.endsWith("RGN")) {
            list = list.stream().filter(wp -> companyids.contains(wp.getRegionId())).collect(Collectors.toList());
        }
        if (companyids.endsWith("FGS")) {
            list = list.stream().filter(wp -> companyids.contains(wp.getGroupId())).collect(Collectors.toList());
        }
        if (companyids.endsWith("ZGS")) {
            list = list.stream().filter(wp -> companyids.contains(wp.getCompanyId())).collect(Collectors.toList());
        }
        SortUtils.sort(list, "orderNum", SortUtils.ASC);
        return list;

    }

    public List<ProBasicEquipment> wtByWplist(String wpid) {

        List<ProBasicEquipment> wtls = new ArrayList<>();
        if (StringUtils.notEmp(wpid) && CacheContext.wpwtmap.containsKey(wpid)) {
            wtls = CacheContext.wpwtmap.get(wpid);
        }
        return wtls;
    }

    public List<ProBasicProject> pjByWplist(String wpids) {
        return CacheContext.pjls.stream().filter(pj -> wpids.contains(pj.getWindpowerstationId())).collect(Collectors.toList());
    }

    public List<ProBasicLine> lnByPjlist(String pjids) {
        return CacheContext.lnls.stream().filter(ln -> pjids.contains(ln.getProjectId())).collect(Collectors.toList());
    }

    public List<FjjxbVo> performance2(String companyid, String getype, String sttype, String beginDate, String endDate, String wpids, String projectids, String lineids, String target, String sort) {
        List<FjjxbVo> resultList = new ArrayList<>();
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        StringBuilder sb = new StringBuilder();
        if (sttype.equals("1")) {
            sb.append("windpowerstation_id,");
        } else if (sttype.equals("2")) {
            sb.append("project_id,");
        } else if (sttype.equals("3")) {
            sb.append("line_id,");
        } else {
            sb.append("windturbine_id,");
        }

        if (getype.equals("-1")) {
            sb.append("sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");

        } else {
            sb.append("sum(rfdl) rfdl,sum(rllfdl) rllfdl,sum(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");

        }
        qw.select(String.valueOf(sb));
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(companyid) && companyid.endsWith("ZGS")) {
            qw.eq("company_id", companyid);
        }
        if (getype.equals("-1")) {
            qw.like("windturbine_id", "_F_WT_");
        } else if (getype.equals("-2")) {
            qw.like("windturbine_id", "_G_IN_");
        }
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("windpowerstation_id", wpList);
        }

        if (StringUtils.isNotEmpty(projectids)) {
            List<String> proList = Arrays.asList(projectids.split(","));
            qw.in("project_id", proList);
        }
        if (StringUtils.isNotEmpty(lineids)) {
            List<String> lineList = Arrays.asList(lineids.split(","));
            qw.in("line_id", lineList);
        }
        if (sttype.equals("1")) {
            qw.groupBy("windpowerstation_id");
        } else if (sttype.equals("2")) {
            qw.groupBy("project_id");
        } else if (sttype.equals("3")) {
            qw.groupBy("line_id");
        } else {
            qw.groupBy("windturbine_id");
        }
        List<ProEconEquipmentInfoDay1> list = proEconEquipmentInfoDay1Service.list(qw);
        AtomicReference<Double> llfdl = new AtomicReference<>((double) 0);
        AtomicReference<Double> sjfdl = new AtomicReference<>((double) 0);
        AtomicReference<Double> pjfs = new AtomicReference<>((double) 0);
        AtomicReference<Double> wh = new AtomicReference<>((double) 0);
        AtomicReference<Double> gz = new AtomicReference<>((double) 0);
        AtomicReference<Double> xd = new AtomicReference<>((double) 0);
        AtomicReference<Double> xn = new AtomicReference<>((double) 0);
        AtomicReference<Double> sl = new AtomicReference<>((double) 0);


        list.stream().forEach(i -> {
            FjjxbVo vo = new FjjxbVo();
            if (sttype.equals("1")) {
                vo.setId(i.getWindpowerstationId());
                vo.setName(CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getAname());
                vo.setOrdernum(CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getOrderNum());
                double quantity = CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getJrwindQuantityLd()
                        + CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getJrquantityZc()
                        + CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getJrquantityJz();

                if (getype.equals("-2")) {
                    BigDecimal rpjfs = new BigDecimal(i.getRpjfs());
                    BigDecimal speed = rpjfs.divide(new BigDecimal(quantity), 2, RoundingMode.HALF_UP);
                    vo.setSpeed(speed.doubleValue());
                } else {
                    vo.setSpeed(BigDecimalUtils.divide(new BigDecimal(i.getRpjfs()), new BigDecimal(1), 2).doubleValue());
                }

            } else if (sttype.equals("2")) {
                vo.setId(i.getProjectId());
                vo.setName(CacheContext.pjmap.get(i.getProjectId().trim()).getAname());
                vo.setOrdernum(CacheContext.pjmap.get(i.getProjectId().trim()).getOrderNum());

                double quantity = CacheContext.pjmap.get(i.getProjectId().trim()).getQuantity();
                if (getype.equals("-2")) {
                    BigDecimal rpjfs = new BigDecimal(i.getRpjfs());
                    BigDecimal speed = rpjfs.divide(new BigDecimal(quantity), 2, RoundingMode.HALF_UP);
                    vo.setSpeed(speed.doubleValue());
                } else {
                    vo.setSpeed(BigDecimalUtils.divide(new BigDecimal(i.getRpjfs()), new BigDecimal(1), 2).doubleValue());
                }
            } else if (sttype.equals("3")) {
                vo.setId(i.getLineId());
                vo.setName(CacheContext.lnmap.get(i.getLineId().trim()).getAname());
                vo.setOrdernum(CacheContext.lnmap.get(i.getLineId().trim()).getOrderNum());

                double quantity = CacheContext.lnmap.get(i.getLineId().trim()).getQuantity();
                if (getype.equals("-2")) {
                    BigDecimal rpjfs = new BigDecimal(i.getRpjfs());
                    BigDecimal speed = rpjfs.divide(new BigDecimal(quantity), 2, RoundingMode.HALF_UP);
                    vo.setSpeed(speed.doubleValue());
                } else {
                    vo.setSpeed(BigDecimalUtils.divide(new BigDecimal(i.getRpjfs()), new BigDecimal(1), 2).doubleValue());
                }
            } else {
                vo.setId(i.getWindturbineId());
                vo.setName(CacheContext.wtmap.get(i.getWindturbineId().trim()).getAname());
                vo.setOrdernum(CacheContext.wtmap.get(i.getWindturbineId().trim()).getOrderNum());
            }
            vo.setSjfdl(BigDecimalUtils.divide(new BigDecimal(i.getRfdl()), new BigDecimal(10000), 2).doubleValue());
            vo.setLlfdl(BigDecimalUtils.divide(new BigDecimal(i.getRllfdl()), new BigDecimal(10000), 2).doubleValue());

            if (sttype.isEmpty()) {
                vo.setSpeed(BigDecimalUtils.divide(new BigDecimal(i.getRpjfs()), new BigDecimal(1), 2).doubleValue());
            }
            vo.setFjhjx(BigDecimalUtils.divide(new BigDecimal(i.getRgzssdl() + i.getRcnslgzssdl()), new BigDecimal(10000), 2).doubleValue());
            vo.setJhjx(BigDecimalUtils.divide(new BigDecimal(i.getRjxssdl() + i.getRcnsljxssdl()), new BigDecimal(10000), 2).doubleValue());
            vo.setXd(BigDecimalUtils.divide(new BigDecimal(i.getRxdtjssdl() + i.getRxdjclssdl()), new BigDecimal(10000), 2).doubleValue());
            vo.setSl(BigDecimalUtils.divide(new BigDecimal(i.getRcwsldwssdl() + i.getRcwsltqssdl()), new BigDecimal(10000), 2).doubleValue());
            vo.setXn(BigDecimalUtils.divide(new BigDecimal(i.getRdjssdl() + i.getRqxjclssdl() + i.getRsdtjssdl() + i.getRxnssdl()), new BigDecimal(10000), 2).doubleValue());
            //            vo.setLlfdl(DoubleUtils.getRoundingNum(vo.getSjfdl()+vo.getFjhjx()+vo.getJhjx()+vo.getXd()+vo.getXn(),2));
            vo.setFnlly(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSjfdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setPoint(DoubleUtils.keepPrecision(vo.getLlfdl() * 1.1, 2));

            llfdl.updateAndGet(v -> new Double((double) (v + vo.getLlfdl())));
            sjfdl.updateAndGet(v -> new Double((double) (v + vo.getSjfdl())));
            pjfs.updateAndGet(v -> new Double((double) (v + vo.getSpeed())));
            wh.updateAndGet(v -> new Double((double) (v + vo.getJhjx())));
            gz.updateAndGet(v -> new Double((double) (v + vo.getFjhjx())));
            xd.updateAndGet(v -> new Double((double) (v + vo.getXd())));
            xn.updateAndGet(v -> new Double((double) (v + vo.getXn())));
            sl.updateAndGet(v -> new Double((double) (v + vo.getSl())));
            resultList.add(vo);
        });
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            //SortUtils.sort(resultList,"fdl",SortUtils.DESC);
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        FjjxbVo vo = new FjjxbVo();
        vo.setId("hj");
        vo.setName("合计");
        vo.setSjfdl(DoubleUtils.keepPrecision(sjfdl.get().doubleValue(), 2));
        vo.setLlfdl(DoubleUtils.keepPrecision(llfdl.get().doubleValue(), 2));
        vo.setSpeed(list.size() != 0 ? DoubleUtils.keepPrecision(pjfs.get().doubleValue() / list.size(), 2) : 0.0);
        vo.setJhjx(DoubleUtils.keepPrecision(wh.get().doubleValue(), 2));
        vo.setFjhjx(DoubleUtils.keepPrecision(gz.get().doubleValue(), 2));
        vo.setXd(DoubleUtils.keepPrecision(xd.get().doubleValue(), 2));
        vo.setXn(DoubleUtils.keepPrecision(xn.get().doubleValue(), 2));
        vo.setSl(DoubleUtils.keepPrecision(sl.get().doubleValue(), 2));
        vo.setFnlly(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSjfdl() / vo.getLlfdl() * 100, 2) : 0.0);
        vo.setPoint(DoubleUtils.keepPrecision(vo.getLlfdl() * 1.1, 2));
        resultList.add(vo);
        return resultList;
    }


    public List<FjjxbVo> performance(String companyid, String getype, String sttype, String beginDate, String endDate, String wpids, String projectids, String lineids, String target, String sort) {
        List<FjjxbVo> resultList = new ArrayList<>();
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        StringBuilder sb = new StringBuilder();
        if (sttype.equals("1")) {
            sb.append("station_id,");
        } else if (sttype.equals("2")) {
            sb.append("project_id,");
        } else if (sttype.equals("3")) {
            sb.append("line_id,");
        } else {
            sb.append("turbine_id,");
        }

        if (getype.equals("-1")) {
            sb.append("sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");

        } else {
            sb.append("sum(rfdl) rfdl,sum(llfdl) llfdl,sum(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");

        }
        qw.select(String.valueOf(sb));
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(companyid) && companyid.endsWith("ZGS")) {
            qw.eq("company_id", companyid);
        }
        if (getype.equals("-1")) {
            qw.like("turbine_id", "_F_WT_");
        } else if (getype.equals("-2")) {
            qw.like("turbine_id", "_G_IN_");
        }
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("station_id", wpList);
        }

        if (StringUtils.isNotEmpty(projectids)) {
            List<String> proList = Arrays.asList(projectids.split(","));
            qw.in("project_id", proList);
        }
        if (StringUtils.isNotEmpty(lineids)) {
            List<String> lineList = Arrays.asList(lineids.split(","));
            qw.in("line_id", lineList);
        }
        if (sttype.equals("1")) {
            qw.groupBy("station_id");
        } else if (sttype.equals("2")) {
            qw.groupBy("project_id");
        } else if (sttype.equals("3")) {
            qw.groupBy("line_id");
        } else {
            qw.groupBy("turbine_id");
        }
        List<TurbineInfoDay> list = iTurbineInfoDayService.list(qw);
        AtomicReference<Double> llfdl = new AtomicReference<>((double) 0);
        AtomicReference<Double> sjfdl = new AtomicReference<>((double) 0);
        AtomicReference<Double> pjfs = new AtomicReference<>((double) 0);
        AtomicReference<Double> wh = new AtomicReference<>((double) 0);
        AtomicReference<Double> gz = new AtomicReference<>((double) 0);
        AtomicReference<Double> xd = new AtomicReference<>((double) 0);
        AtomicReference<Double> xn = new AtomicReference<>((double) 0);
        AtomicReference<Double> sl = new AtomicReference<>((double) 0);


        list.stream().forEach(i -> {
            FjjxbVo vo = new FjjxbVo();
            FjjxbVo vo2 = new FjjxbVo();
            if (sttype.equals("1")) {
                vo.setId(i.getStationId());
                vo.setName(CacheContext.wpmap.get(i.getStationId().trim()).getAname());
                vo.setOrdernum(CacheContext.wpmap.get(i.getStationId().trim()).getOrderNum());
                double quantity = CacheContext.wpmap.get(i.getStationId().trim()).getJrwindQuantityLd()
                        + CacheContext.wpmap.get(i.getStationId().trim()).getJrquantityZc()
                        + CacheContext.wpmap.get(i.getStationId().trim()).getJrquantityJz();

                if (getype.equals("-2")) {
                    BigDecimal rpjfs = new BigDecimal(String.valueOf(i.getPjfs()));
                    BigDecimal speed = rpjfs.divide(new BigDecimal(quantity), 2, RoundingMode.HALF_UP);
                    vo.setSpeed(speed.doubleValue());
                } else {
                    vo.setSpeed(BigDecimalUtils.divide(new BigDecimal(String.valueOf(i.getPjfs())), new BigDecimal(1), 2).doubleValue());
                }

            } else if (sttype.equals("2")) {
                vo.setId(i.getProjectId());
                vo.setName(CacheContext.pjmap.get(i.getProjectId().trim()).getAname());
                vo.setOrdernum(CacheContext.pjmap.get(i.getProjectId().trim()).getOrderNum());

                double quantity = CacheContext.pjmap.get(i.getProjectId().trim()).getQuantity();
                if (getype.equals("-2")) {
                    BigDecimal rpjfs = new BigDecimal(String.valueOf(i.getPjfs()));
                    BigDecimal speed = rpjfs.divide(new BigDecimal(quantity), 2, RoundingMode.HALF_UP);
                    vo.setSpeed(speed.doubleValue());
                } else {
                    vo.setSpeed(BigDecimalUtils.divide(new BigDecimal(String.valueOf(i.getPjfs())), new BigDecimal(1), 2).doubleValue());
                }
            } else if (sttype.equals("3")) {
                vo.setId(i.getLineId());
                vo.setName(CacheContext.lnmap.get(i.getLineId().trim()).getAname());
                vo.setOrdernum(CacheContext.lnmap.get(i.getLineId().trim()).getOrderNum());

                double quantity = CacheContext.lnmap.get(i.getLineId().trim()).getQuantity();
                if (getype.equals("-2")) {
                    BigDecimal rpjfs = BigDecimal.valueOf(i.getPjfs());
                    BigDecimal speed = rpjfs.divide(new BigDecimal(quantity), 2, RoundingMode.HALF_UP);
                    vo.setSpeed(speed.doubleValue());
                } else {
                    vo.setSpeed(BigDecimalUtils.divide(BigDecimal.valueOf(i.getPjfs()), new BigDecimal(1), 2).doubleValue());
                }
            } else {
                vo.setId(i.getTurbineId());
                vo.setName(CacheContext.wtmap.get(i.getTurbineId().trim()).getAname());
                vo.setOrdernum(CacheContext.wtmap.get(i.getTurbineId().trim()).getOrderNum());
                vo2.setId(i.getTurbineId());
                vo2.setName(CacheContext.wtmap.get(i.getTurbineId().trim()).getAname());
                vo2.setOrdernum(CacheContext.wtmap.get(i.getTurbineId().trim()).getOrderNum());
            }
            vo.setSjfdl(BigDecimalUtils.divide(BigDecimal.valueOf(i.getRfdl()), new BigDecimal(1), 2).doubleValue());
            vo.setLlfdl(BigDecimalUtils.divide(BigDecimal.valueOf(i.getLlfdl()), new BigDecimal(1), 2).doubleValue());
            vo2.setSjfdl(BigDecimalUtils.divide(BigDecimal.valueOf(i.getRfdl() / 1000), new BigDecimal(1), 2).doubleValue());
            vo2.setLlfdl(BigDecimalUtils.divide(BigDecimal.valueOf(i.getLlfdl() / 1000), new BigDecimal(1), 2).doubleValue());

            if (sttype.isEmpty()) {
                vo.setSpeed(BigDecimalUtils.divide(BigDecimal.valueOf(i.getPjfs()), new BigDecimal(1), 2).doubleValue());
                vo2.setSpeed(BigDecimalUtils.divide(BigDecimal.valueOf(i.getPjfs()), new BigDecimal(1), 2).doubleValue());
            }
//            vo.setFjhjx(BigDecimalUtils.divide(BigDecimal.valueOf(i.getFjhjxss()), new BigDecimal(1), 2).doubleValue());
            vo.setFjhjx(BigDecimalUtils.divide(BigDecimal.valueOf(i.getGzss()), new BigDecimal(1), 2).doubleValue());
            vo.setJhjx(BigDecimalUtils.divide(BigDecimal.valueOf(i.getJhjxss()), new BigDecimal(1), 2).doubleValue());
            vo.setXd(BigDecimalUtils.divide(BigDecimal.valueOf(i.getXdss()), new BigDecimal(1), 2).doubleValue());
            vo.setSl(BigDecimalUtils.divide(BigDecimal.valueOf(i.getSlss()), new BigDecimal(1), 2).doubleValue());
            vo.setXn(BigDecimalUtils.divide(BigDecimal.valueOf(i.getXnss()), new BigDecimal(1), 2).doubleValue());
            //            vo.setLlfdl(DoubleUtils.getRoundingNum(vo.getSjfdl()+vo.getFjhjx()+vo.getJhjx()+vo.getXd()+vo.getXn(),2));
            vo.setFnlly(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSjfdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setPoint(DoubleUtils.keepPrecision(vo.getLlfdl() * 1.1, 2));

//            vo2.setFjhjx(BigDecimalUtils.divide(BigDecimal.valueOf(i.getFjhjxss() / 1000), new BigDecimal(1), 2).doubleValue());
            vo2.setFjhjx(BigDecimalUtils.divide(BigDecimal.valueOf(i.getGzss() / 1000), new BigDecimal(1), 2).doubleValue());
            vo2.setJhjx(BigDecimalUtils.divide(BigDecimal.valueOf(i.getJhjxss() / 1000), new BigDecimal(1), 2).doubleValue());
            vo2.setXd(BigDecimalUtils.divide(BigDecimal.valueOf(i.getXdss() / 1000), new BigDecimal(1), 2).doubleValue());
            vo2.setSl(BigDecimalUtils.divide(BigDecimal.valueOf(i.getSlss() / 1000), new BigDecimal(1), 2).doubleValue());
            vo2.setXn(BigDecimalUtils.divide(BigDecimal.valueOf(i.getXnss() / 1000), new BigDecimal(1), 2).doubleValue());
            vo2.setFnlly(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSjfdl() / vo.getLlfdl() * 100, 2) : 0);
            vo2.setPoint(DoubleUtils.keepPrecision(vo.getLlfdl() * 1.1, 2));

            llfdl.updateAndGet(v -> (double) (v + vo.getLlfdl()));
            sjfdl.updateAndGet(v -> (double) (v + vo.getSjfdl()));
            pjfs.updateAndGet(v -> (double) (v + vo.getSpeed()));
            wh.updateAndGet(v -> (double) (v + vo.getJhjx()));
            gz.updateAndGet(v -> (double) (v + vo.getFjhjx()));
            xd.updateAndGet(v -> (double) (v + vo.getXd()));
            xn.updateAndGet(v -> (double) (v + vo.getXn()));
            sl.updateAndGet(v -> (double) (v + vo.getSl()));
            resultList.add(vo2);
        });
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            //SortUtils.sort(resultList,"fdl",SortUtils.DESC);
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        FjjxbVo vo = new FjjxbVo();
        vo.setId("hj");
        vo.setName("合计");
        vo.setSjfdl(DoubleUtils.keepPrecision(sjfdl.get() / 1000, 2));
        vo.setLlfdl(DoubleUtils.keepPrecision(llfdl.get() / 1000, 2));
        vo.setSpeed(list.size() != 0 ? DoubleUtils.keepPrecision(pjfs.get() / list.size(), 2) : 0.0);
        vo.setJhjx(DoubleUtils.keepPrecision(wh.get() / 1000, 2));
        vo.setFjhjx(DoubleUtils.keepPrecision(gz.get() / 1000, 2));
        vo.setXd(DoubleUtils.keepPrecision(xd.get() / 1000, 2));
        vo.setXn(DoubleUtils.keepPrecision(xn.get() / 1000, 2));
        vo.setSl(DoubleUtils.keepPrecision(sl.get() / 1000, 2));
        vo.setFnlly(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSjfdl() / vo.getLlfdl() * 100, 2) : 0.0);
        vo.setPoint(DoubleUtils.keepPrecision(vo.getLlfdl() * 1.1, 2));
        resultList.add(vo);
        return resultList;
    }


    public List<FjjxbmxVo> performanceMX(String companyid, String getype, String sttype, String beginDate, String endDate, String wpids, String projectids, String lineids, String target, String sort) {
        List<FjjxbmxVo> resultList = new ArrayList<>();
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        StringBuilder sb = new StringBuilder();
        if (sttype.equals("1")) {
            sb.append("windpowerstation_id,");
        } else if (sttype.equals("2")) {
            sb.append("project_id,");
        } else if (sttype.equals("3")) {
            sb.append("line_id,");
        } else {
            sb.append("windturbine_id,");
        }

        if (getype.equals("-1")) {
            sb.append("sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");

        } else {
            sb.append("sum(rfdl) rfdl,sum(rllfdl) rllfdl,sum(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");

        }
        qw.select(String.valueOf(sb));
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (companyid.endsWith("ZGS")) {
            qw.eq("company_id", companyid);
        }
        if (getype.equals("-1")) {
            qw.like("windturbine_id", "_F_WT_");
        } else if (getype.equals("-2")) {
            qw.like("windturbine_id", "_G_IN_");
        }
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("windpowerstation_id", wpList);
        }

        if (StringUtils.isNotEmpty(projectids)) {
            List<String> proList = Arrays.asList(projectids.split(","));
            qw.in("project_id", proList);
        }
        if (StringUtils.isNotEmpty(lineids)) {
            List<String> lineList = Arrays.asList(lineids.split(","));
            qw.in("line_id", lineList);
        }
        if (sttype.equals("1")) {
            qw.groupBy("windpowerstation_id");
        } else if (sttype.equals("2")) {
            qw.groupBy("project_id");
        } else if (sttype.equals("3")) {
            qw.groupBy("line_id");
        } else {
            qw.groupBy("windturbine_id");
        }
        List<ProEconEquipmentInfoDay1> list = proEconEquipmentInfoDay1Service.list(qw);
        AtomicReference<Double> llfdl = new AtomicReference<>((double) 0);
        AtomicReference<Double> sjfdl = new AtomicReference<>((double) 0);
        AtomicReference<Double> pjfs = new AtomicReference<>((double) 0);
        AtomicReference<Double> wh1 = new AtomicReference<>((double) 0);
        AtomicReference<Double> wh2 = new AtomicReference<>((double) 0);
        AtomicReference<Double> gz1 = new AtomicReference<>((double) 0);
        AtomicReference<Double> gz2 = new AtomicReference<>((double) 0);
        AtomicReference<Double> xd1 = new AtomicReference<>((double) 0);
        AtomicReference<Double> xd2 = new AtomicReference<>((double) 0);
        AtomicReference<Double> xn1 = new AtomicReference<>((double) 0);
        AtomicReference<Double> xn2 = new AtomicReference<>((double) 0);
        AtomicReference<Double> xn3 = new AtomicReference<>((double) 0);
        AtomicReference<Double> xn4 = new AtomicReference<>((double) 0);
        AtomicReference<Double> sl1 = new AtomicReference<>((double) 0);
        AtomicReference<Double> sl2 = new AtomicReference<>((double) 0);


        list.stream().forEach(i -> {
            FjjxbmxVo vo = new FjjxbmxVo();
            if (sttype.equals("1")) {
                vo.setId(i.getWindpowerstationId());
                vo.setName(CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getAname());
                vo.setOrdernum(CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getOrderNum());

                double quantity = CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getJrwindQuantityLd()
                        + CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getJrquantityZc()
                        + CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getJrquantityJz();

                if (getype.equals("-2")) {
                    vo.setSpeed(DoubleUtils.keepPrecision(i.getRpjfs() / quantity, 2));
                } else {
                    vo.setSpeed(DoubleUtils.keepPrecision(i.getRpjfs(), 2));
                }
            } else if (sttype.equals("2")) {
                vo.setId(i.getProjectId());
                vo.setName(CacheContext.pjmap.get(i.getProjectId().trim()).getAname());
                vo.setOrdernum(CacheContext.pjmap.get(i.getProjectId().trim()).getOrderNum());

                double quantity = CacheContext.pjmap.get(i.getProjectId().trim()).getQuantity();
                if (getype.equals("-2")) {
                    vo.setSpeed(DoubleUtils.keepPrecision(i.getRpjfs() / quantity, 2));
                } else {
                    vo.setSpeed(DoubleUtils.keepPrecision(i.getRpjfs(), 2));
                }
            } else if (sttype.equals("3")) {
                vo.setId(i.getLineId());
                vo.setName(CacheContext.lnmap.get(i.getLineId().trim()).getAname());
                vo.setOrdernum(CacheContext.lnmap.get(i.getLineId().trim()).getOrderNum());

                double quantity = CacheContext.lnmap.get(i.getLineId().trim()).getQuantity();
                if (getype.equals("-2")) {
                    vo.setSpeed(DoubleUtils.keepPrecision(i.getRpjfs() / quantity, 2));
                } else {
                    vo.setSpeed(DoubleUtils.keepPrecision(i.getRpjfs(), 2));
                }
            } else {
                vo.setId(i.getWindturbineId());
                vo.setName(CacheContext.wtmap.get(i.getWindturbineId().trim()).getAname());
                vo.setOrdernum(CacheContext.wtmap.get(i.getWindturbineId().trim()).getOrderNum());
            }
            vo.setSjfdl(DoubleUtils.keepPrecision(i.getRfdl() / 10000, 2));
            vo.setLlfdl(DoubleUtils.keepPrecision(i.getRllfdl() / 10000, 2));
            if (sttype.isEmpty()) {
                vo.setSpeed(DoubleUtils.keepPrecision(i.getRpjfs(), 2));
            }
            vo.setFjhjx1(DoubleUtils.keepPrecision(i.getRgzssdl() / 10000, 2));
            vo.setFjhjx2(DoubleUtils.keepPrecision(i.getRcnslgzssdl() / 10000, 2));
            vo.setJhjx1(DoubleUtils.keepPrecision(i.getRjxssdl() / 10000, 2));
            vo.setJhjx2(DoubleUtils.keepPrecision(i.getRcnsljxssdl() / 10000, 2));
            vo.setXd1(DoubleUtils.keepPrecision(i.getRxdjclssdl() / 10000, 2));
            vo.setXd2(DoubleUtils.keepPrecision(i.getRxdtjssdl() / 10000, 2));
            vo.setSl1(DoubleUtils.keepPrecision(i.getRcwsldwssdl() / 10000, 2));
            vo.setSl2(DoubleUtils.keepPrecision(i.getRcwsltqssdl() / 10000, 2));
            vo.setXn1(DoubleUtils.keepPrecision(i.getRdjssdl() / 10000, 2));
            vo.setXn2(DoubleUtils.keepPrecision(i.getRsdtjssdl() / 10000, 2));
            vo.setXn3(DoubleUtils.keepPrecision(i.getRxnssdl() / 10000, 2));
            vo.setXn4(DoubleUtils.keepPrecision(i.getRqxjclssdl() / 10000, 2));
            vo.setFnlly(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSjfdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setPoint(DoubleUtils.keepPrecision(vo.getLlfdl() + 10, 2));
            llfdl.updateAndGet(v -> new Double((double) (v + vo.getLlfdl())));
            sjfdl.updateAndGet(v -> new Double((double) (v + vo.getSjfdl())));
            pjfs.updateAndGet(v -> new Double((double) (v + vo.getSpeed())));
            wh1.updateAndGet(v -> new Double((double) (v + vo.getJhjx1())));
            wh2.updateAndGet(v -> new Double((double) (v + vo.getJhjx2())));
            gz1.updateAndGet(v -> new Double((double) (v + vo.getFjhjx1())));
            gz2.updateAndGet(v -> new Double((double) (v + vo.getFjhjx2())));
            xd1.updateAndGet(v -> new Double((double) (v + vo.getXd1())));
            xd2.updateAndGet(v -> new Double((double) (v + vo.getXd2())));
            xn1.updateAndGet(v -> new Double((double) (v + vo.getXn1())));
            xn2.updateAndGet(v -> new Double((double) (v + vo.getXn2())));
            xn3.updateAndGet(v -> new Double((double) (v + vo.getXn3())));
            xn4.updateAndGet(v -> new Double((double) (v + vo.getXn4())));
            sl1.updateAndGet(v -> new Double((double) (v + vo.getSl1())));
            sl2.updateAndGet(v -> new Double((double) (v + vo.getSl2())));
            resultList.add(vo);
        });
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            //SortUtils.sort(resultList,"fdl",SortUtils.DESC);
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        //        SortUtils.sort(resultList,"ordernum",SortUtils.ASC);
        FjjxbmxVo vo = new FjjxbmxVo();
        vo.setId("hj");
        vo.setName("合计");
        vo.setSjfdl(DoubleUtils.keepPrecision(sjfdl.get().doubleValue(), 2));
        vo.setLlfdl(DoubleUtils.keepPrecision(llfdl.get().doubleValue(), 2));
        vo.setSpeed(list.size() != 0 ? DoubleUtils.keepPrecision(pjfs.get().doubleValue() / list.size(), 2) : 0.0);
        vo.setJhjx1(DoubleUtils.keepPrecision(wh1.get().doubleValue(), 2));
        vo.setJhjx2(DoubleUtils.keepPrecision(wh2.get().doubleValue(), 2));
        vo.setFjhjx1(DoubleUtils.keepPrecision(gz1.get().doubleValue(), 2));
        vo.setFjhjx2(DoubleUtils.keepPrecision(gz2.get().doubleValue(), 2));
        vo.setXd1(DoubleUtils.keepPrecision(xd1.get().doubleValue(), 2));
        vo.setXd2(DoubleUtils.keepPrecision(xd2.get().doubleValue(), 2));
        vo.setXn1(DoubleUtils.keepPrecision(xn1.get().doubleValue(), 2));
        vo.setXn2(DoubleUtils.keepPrecision(xn2.get().doubleValue(), 2));
        vo.setXn3(DoubleUtils.keepPrecision(xn3.get().doubleValue(), 2));
        vo.setXn4(DoubleUtils.keepPrecision(xn4.get().doubleValue(), 2));
        vo.setSl1(DoubleUtils.keepPrecision(sl1.get().doubleValue(), 2));
        vo.setSl2(DoubleUtils.keepPrecision(sl2.get().doubleValue(), 2));
        vo.setFnlly(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSjfdl() / vo.getLlfdl() * 100, 2) : 0.0);
        vo.setPoint(DoubleUtils.keepPrecision(vo.getLlfdl() + 10, 2));
        resultList.add(vo);
        return resultList;
    }

    public List<WxsslVo> wxssl2(String companys, String type, String wpids, String projectids, String lineids, String beginDate, String endDate, String target, String sort) {
        List<WxsslVo> resultList = new ArrayList<>();
        //        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
        //        List<ProBasicPowerstation> wpls = tokenService.getWpls(request);
        List<ProBasicPowerstation> wpls = CacheContext.wpls;
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        StringBuilder sb = new StringBuilder();

        if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)) {
            sb.append("windpowerstation_id,");
        } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)) {
            sb.append("project_id,");
        } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)) {
            sb.append("line_id,");
        } else {
            sb.append("windpowerstation_id,");
        }
        sb.append("sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");
        qw.select(String.valueOf(sb));
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));

        if (companys.endsWith("RGN")) {
            qw.eq("region_id", companys);
        } else {
            qw.eq("company_id", companys);
        }
        if (type.equals("-1")) {
            qw.like("windturbine_id", "_WT_");
        } else {
            qw.like("windturbine_id", "_IN_");
        }
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("windpowerstation_id", wpList);
        }

        if (StringUtils.isNotEmpty(projectids)) {
            List<String> proList = Arrays.asList(projectids.split(","));
            qw.in("project_id", proList);
        }
        if (StringUtils.isNotEmpty(lineids)) {
            List<String> lineList = Arrays.asList(lineids.split(","));
            qw.in("line_id", lineList);
        }
        if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)) {
            qw.groupBy("windpowerstation_id");
        } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)) {
            qw.groupBy("project_id");
        } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)) {
            qw.groupBy("line_id");
        } else {
            qw.groupBy("windpowerstation_id");
        }
        List<ProEconEquipmentInfoDay1> list = proEconEquipmentInfoDay1Service.list(qw);

        Map<String, Integer> station = wpls
                .stream().collect(Collectors.toMap(ProBasicPowerstation::getId, ProBasicPowerstation::getOrderNum));

        list.stream().forEach(i -> {
            WxsslVo vo = new WxsslVo();
            station.get(i.getWindpowerstationId());
            if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)) {
                vo.setId(i.getWindpowerstationId());
                vo.setName(CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getAname());
                vo.setOrdernum(station.get(i.getWindpowerstationId()).doubleValue());
            } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)) {
                vo.setId(i.getProjectId());
                vo.setName(CacheContext.pjmap.get(i.getProjectId().trim()).getAname());
                vo.setOrdernum(CacheContext.pjmap.get(i.getProjectId().trim()).getOrderNum().doubleValue());
            } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)) {
                vo.setId(i.getLineId());
                vo.setName(CacheContext.lnmap.get(i.getLineId().trim()).getAname());
                vo.setOrdernum(CacheContext.lnmap.get(i.getLineId().trim()).getOrderNum().doubleValue());
            } else {
                vo.setId(i.getWindpowerstationId());
                vo.setName(CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getName());
                vo.setOrdernum(station.get(i.getWindpowerstationId()).doubleValue());
            }

            vo.setFdl(DoubleUtils.keepPrecision(i.getRfdl() / 10000, 2));
            vo.setLlfdl(DoubleUtils.keepPrecision(i.getRllfdl() / 10000, 2));
            vo.setJxssdl(DoubleUtils.keepPrecision((i.getRjxssdl() + i.getRcnsljxssdl()) / 10000, 2));
            vo.setGzssdl(DoubleUtils.keepPrecision((i.getRgzssdl() + i.getRcnslgzssdl()) / 10000, 2));
            vo.setXdssdl(DoubleUtils.keepPrecision((i.getRxdtjssdl() + i.getRxdjclssdl()) / 10000, 2));
            vo.setSlssdl(DoubleUtils.keepPrecision((i.getRcwsltqssdl() + i.getRcwsldwssdl()) / 10000, 2));
            vo.setXnssdl(DoubleUtils.keepPrecision((i.getRdjssdl() + i.getRsdtjssdl() + i.getRqxjclssdl() + i.getRxnssdl()) / 10000, 2));
            vo.setZssdl(DoubleUtils.keepPrecision(vo.getGzssdl() + vo.getJxssdl() + vo.getXdssdl() + vo.getXnssdl() + vo.getSlssdl(), 2));
            vo.setFnlyl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getFdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setGzssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getGzssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setJxssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getJxssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setQfl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getXdssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setXnssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getXnssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setSlssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSlssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            resultList.add(vo);
        });
        SortUtils.sort(resultList, "fdl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setFdlpm(i + 1);
        }

        SortUtils.sort(resultList, "fnlyl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setFnlylpm(i + 1);
        }
        SortUtils.sort(resultList, "zssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setZhpm(i + 1);
        }
        SortUtils.sort(resultList, "gzssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setGzssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "gzssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setGzsslpm(i + 1);
        }
        SortUtils.sort(resultList, "jxssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setJxssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "jxssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setJxsslpm(i + 1);
        }
        SortUtils.sort(resultList, "xdssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXdssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "qfl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setQflpm(i + 1);
        }
        SortUtils.sort(resultList, "xnssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXnssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "xnssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXnsslpm(i + 1);
        }
        SortUtils.sort(resultList, "slssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setSlssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "slssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setSlsslpm(i + 1);
        }
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            //SortUtils.sort(resultList,"fdl",SortUtils.DESC);
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return resultList;
    }


    public List<WxsslVo> wxssl(String companys, String type, String wpids, String projectids, String lineids, String beginDate, String endDate, String target, String sort) {
        List<WxsslVo> resultList = new ArrayList<>();
        List<ProBasicPowerstation> wpls = CacheContext.wpls;
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        StringBuilder sb = new StringBuilder();

        if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)) {
            sb.append("station_id,");
        } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)) {
            sb.append("project_id,");
        } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)) {
            sb.append("line_id,");
        } else {
            sb.append("station_id,");
        }
        sb.append("sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
        qw.select(String.valueOf(sb));
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
//
//        if (companys.endsWith("RGN")) {
//            qw.eq("region_id", companys);
//        } else {
//            qw.eq("company_id", companys);
//        }
        if (type.equals("-1")) {
            qw.like("turbine_id", "_WT_");
        } else {
            qw.like("turbine_id", "_IN_");
        }
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("station_id", wpList);
        }

        if (StringUtils.isNotEmpty(projectids)) {
            List<String> proList = Arrays.asList(projectids.split(","));
            qw.in("project_id", proList);
        }
        if (StringUtils.isNotEmpty(lineids)) {
            List<String> lineList = Arrays.asList(lineids.split(","));
            qw.in("line_id", lineList);
        }
        if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)) {
            qw.groupBy("station_id");
        } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)) {
            qw.groupBy("project_id");
        } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)) {
            qw.groupBy("line_id");
        } else {
            qw.groupBy("station_id");
        }
        List<TurbineInfoDay> list = iTurbineInfoDayService.list(qw);

        Map<String, Integer> station = wpls
                .stream().collect(Collectors.toMap(ProBasicPowerstation::getId, ProBasicPowerstation::getOrderNum));

        list.stream().forEach(i -> {
            WxsslVo vo = new WxsslVo();
            station.get(i.getStationId());
            if (StringUtils.isNotEmpty(wpids) && StringUtils.isEmpty(projectids) && StringUtils.isEmpty(lineids)) {
                vo.setId(i.getStationId());
                vo.setName(CacheContext.wpmap.get(i.getStationId().trim()).getAname());
                vo.setOrdernum(station.get(i.getStationId()).doubleValue());
            } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isEmpty(lineids)) {
                vo.setId(i.getProjectId());
                vo.setName(CacheContext.pjmap.get(i.getProjectId().trim()).getAname());
                vo.setOrdernum(CacheContext.pjmap.get(i.getProjectId().trim()).getOrderNum().doubleValue());
            } else if (StringUtils.isNotEmpty(wpids) && StringUtils.isNotEmpty(projectids) && StringUtils.isNotEmpty(lineids)) {
                vo.setId(i.getLineId());
                vo.setName(CacheContext.lnmap.get(i.getLineId().trim()).getAname());
                vo.setOrdernum(CacheContext.lnmap.get(i.getLineId().trim()).getOrderNum().doubleValue());
            } else {
                vo.setId(i.getStationId());
                vo.setName(CacheContext.wpmap.get(i.getStationId().trim()).getName());
                vo.setOrdernum(station.get(i.getStationId()).doubleValue());
            }

            vo.setFdl(DoubleUtils.keepPrecision(Double.valueOf(String.valueOf(i.getRfdl())) / 1000, 2));
            vo.setLlfdl(DoubleUtils.keepPrecision(Double.valueOf(String.valueOf(i.getLlfdl())) / 1000, 2));
            vo.setJxssdl(DoubleUtils.keepPrecision(Double.valueOf(String.valueOf(i.getJhjxss() + i.getFjhjxss())) / 1000, 2));
            vo.setGzssdl(DoubleUtils.keepPrecision(Double.valueOf(String.valueOf(i.getGzss())) / 1000, 2));
            vo.setXdssdl(DoubleUtils.keepPrecision(Double.valueOf(String.valueOf(i.getXdss())) / 1000, 2));
            vo.setSlssdl(DoubleUtils.keepPrecision(Double.valueOf(String.valueOf(i.getSlss())) / 1000, 2));
            vo.setXnssdl(DoubleUtils.keepPrecision(Double.valueOf(String.valueOf(i.getXnss())) / 1000, 2));
            vo.setZssdl(DoubleUtils.keepPrecision(vo.getGzssdl() + vo.getJxssdl() + vo.getXdssdl() + vo.getXnssdl() + vo.getSlssdl(), 2));
            vo.setFnlyl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getFdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setGzssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getGzssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setJxssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getJxssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setQfl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getXdssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setXnssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getXnssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            vo.setSlssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSlssdl() / vo.getLlfdl() * 100, 2) : 0.0);
            resultList.add(vo);
        });
        SortUtils.sort(resultList, "fdl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setFdlpm(i + 1);
        }

        SortUtils.sort(resultList, "fnlyl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setFnlylpm(i + 1);
        }
        SortUtils.sort(resultList, "zssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setZhpm(i + 1);
        }
        SortUtils.sort(resultList, "gzssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setGzssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "gzssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setGzsslpm(i + 1);
        }
        SortUtils.sort(resultList, "jxssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setJxssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "jxssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setJxsslpm(i + 1);
        }
        SortUtils.sort(resultList, "xdssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXdssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "qfl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setQflpm(i + 1);
        }
        SortUtils.sort(resultList, "xnssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXnssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "xnssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXnsslpm(i + 1);
        }
        SortUtils.sort(resultList, "slssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setSlssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "slssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setSlsslpm(i + 1);
        }
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            //SortUtils.sort(resultList,"fdl",SortUtils.DESC);
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return resultList;
    }


    public Map<String, Object> cndb2(String companys, String type, String wpid, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        Integer total = 0;

        List<WxsslVo> resultList = new ArrayList<>();
        qw.select("record_date,sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(wpid)) {
            qw.eq("windpowerstation_id", wpid);
        }
        if (companys.endsWith("RGN")) {
            qw.eq("region_id", companys);
        } else {
            qw.eq("company_id", companys);
        }
        if (type.equals("-1")) {
            qw.like("windturbine_id", "_WT_");
        } else {
            qw.like("windturbine_id", "_IN_");
        }
        qw.groupBy("record_date");

        //        total = proEconEquipmentInfoDay1Mapper.selectCount(qw);

        //        qw1.ge("record_date",DateUtils.parseDate(beginDate)).le("record_date",DateUtils.parseDate(endDate));
        //        if (StringUtils.isNotEmpty(wpid)){
        //            qw1.eq("windpowerstation_id",wpid);
        //        }
        //        if (companys.endsWith("RGN")){
        //            qw1.eq("region_id",companys);
        //        }else {
        //            qw1.eq("company_id",companys);
        //        }
        //        if (type.equals("-1")){
        //            qw1.like("windturbine_id","_WT_");
        //        }else {
        //            qw1.like("windturbine_id","_IN_");
        //        }

        Map<String, Object> wxsslVoList = getWxsslSortVos2(qw, total, resultList, TYPE_DATE, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "date", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    public Map<String, Object> cndb(String companys, String type, String wpid, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        Integer total = 0;

        List<WxsslVo> resultList = new ArrayList<>();
        qw.select("record_date,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(wpid)) {
            qw.eq("station_id", wpid);
        }
//        if (companys.endsWith("RGN")) {
//            qw.eq("region_id", companys);
//        } else {
//            qw.eq("company_id", companys);
//        }
        if (type.equals("-1")) {
            qw.like("turbine_id", "_WT_");
        } else {
            qw.like("turbine_id", "_IN_");
        }
        qw.groupBy("record_date");

        Map<String, Object> wxsslVoList = getWxsslSortVos(qw, total, resultList, TYPE_DATE, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "date", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    public Map<String, Object> cndbthb2(String companys, String type, String wpid, String beginDate, String endDate, int pageNum, int pageSize) {
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        Integer total = 0;
        List<WxsslVo> resultList = new ArrayList<>();
        qw.select("sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(wpid)) {
            qw.eq("windpowerstation_id", wpid);
        }
        if (companys.endsWith("RGN")) {
            qw.eq("region_id", companys);
        } else {
            qw.eq("company_id", companys);
        }
        if (type.equals("-1")) {
            qw.like("windturbine_id", "_WT_");
        } else {
            qw.like("windturbine_id", "_IN_");
        }
        qw.groupBy("windpowerstation_id");

        //        total = proEconEquipmentInfoDay1Mapper.selectCount(qw);

        Map<String, Object> wxsslVoList = getWxsslSortVos2(qw, total, resultList, TYPE_DATE, pageNum, pageSize);
        return wxsslVoList;
    }


    public Map<String, Object> cndbthb(String companys, String type, String wpid, String beginDate, String endDate, int pageNum, int pageSize) {
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        Integer total = 0;
        List<WxsslVo> resultList = new ArrayList<>();
        qw.select("sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(wpid)) {
            qw.eq("station_id", wpid);
        }
//        if (companys.endsWith("RGN")) {
//            qw.eq("region_id", companys);
//        } else {
//            qw.eq("company_id", companys);
//        }
        if (type.equals("-1")) {
            qw.like("turbine_id", "_WT_");
        } else {
            qw.like("turbine_id", "_IN_");
        }
        qw.groupBy("station_id");

        //        total = proEconEquipmentInfoDay1Mapper.selectCount(qw);

        Map<String, Object> wxsslVoList = getWxsslSortVos(qw, total, resultList, TYPE_DATE, pageNum, pageSize);
        return wxsslVoList;
    }

    public Map<String, Object> cjdb2(String companys, String type, String wpids, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        List<WxsslVo> resultList = new ArrayList<>();
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        Integer total = 0;
        qw.select("windpowerstation_id,sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");

        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("windpowerstation_id", wpList);
        }
        if (companys.endsWith("RGN")) {
            qw.eq("region_id", companys);
        } else {
            qw.eq("company_id", companys);
        }
        if (type.equals("-1")) {
            qw.like("windturbine_id", "_WT_");
        } else {
            qw.like("windturbine_id", "_IN_");
        }
        qw.groupBy("windpowerstation_id");

        //        total = proEconEquipmentInfoDay1Mapper.selectCount(qw);

        Map<String, Object> wxsslVoList = getWxsslSortVos2(qw, total, resultList, TYPE_WIND, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    public Map<String, Object> cjdb(String companys, String type, String wpids, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        List<WxsslVo> resultList = new ArrayList<>();
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        Integer total = 0;
        qw.select("station_id,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");

        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("station_id", wpList);
        }
//        if (companys.endsWith("RGN")) {
//            qw.eq("region_id", companys);
//        } else {
//            qw.eq("company_id", companys);
//        }
        if (type.equals("-1")) {
            qw.like("turbine_id", "_WT_");
        } else {
            qw.like("turbine_id", "_IN_");
        }
        qw.groupBy("station_id");

        Map<String, Object> wxsslVoList = getWxsslSortVos(qw, total, resultList, TYPE_WIND, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    public Map<String, Object> xmdb2(String companys, String type, String wpids, String projectids, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        List<WxsslVo> resultList = new ArrayList<>();
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        Integer total = 0;
        qw.select("project_id,sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("windpowerstation_id", wpList);
        }
        if (StringUtils.isNotEmpty(projectids)) {
            List<String> projectList = Arrays.asList(projectids.split(","));
            qw.in("project_id", projectList);
        }
        if (companys.endsWith("RGN")) {
            qw.eq("region_id", companys);
        } else {
            qw.eq("company_id", companys);
        }
        if (type.equals("-1")) {
            qw.like("windturbine_id", "_WT_");
        } else {
            qw.like("windturbine_id", "_IN_");
        }
        qw.groupBy("project_id");

        //        total = proEconEquipmentInfoDay1Mapper.selectCount(qw);

        Map<String, Object> wxsslVoList = getWxsslSortVos2(qw, total, resultList, TYPE_PROJECT, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    public Map<String, Object> xmdb(String companys, String type, String wpids, String projectids, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        List<WxsslVo> resultList = new ArrayList<>();
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        Integer total = 0;
        qw.select("project_id,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");
        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("station_id", wpList);
        }
        if (StringUtils.isNotEmpty(projectids)) {
            List<String> projectList = Arrays.asList(projectids.split(","));
            qw.in("project_id", projectList);
        }
//        if (companys.endsWith("RGN")) {
//            qw.eq("region_id", companys);
//        } else {
//            qw.eq("company_id", companys);
//        }
        if (type.equals("-1")) {
            qw.like("turbine_id", "_WT_");
        } else {
            qw.like("turbine_id", "_IN_");
        }
        qw.groupBy("project_id");

        Map<String, Object> wxsslVoList = getWxsslSortVos(qw, total, resultList, TYPE_PROJECT, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    public Map<String, Object> xldb2(String companys, String type, String wpids, String projectids, String lineids, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        List<WxsslVo> resultList = new ArrayList<>();
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        Integer total = 0;
        qw.select("line_id,sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");

        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));

        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("windpowerstation_id", wpList);
        }
        if (StringUtils.isNotEmpty(projectids)) {
            List<String> projectList = Arrays.asList(projectids.split(","));
            qw.in("project_id", projectList);
        }
        if (StringUtils.isNotEmpty(lineids)) {
            List<String> lineList = Arrays.asList(lineids.split(","));
            qw.in("line_id", lineList);

        }
        if (companys.endsWith("RGN")) {
            qw.eq("region_id", companys);
        } else {
            qw.eq("company_id", companys);
        }
        if (type.equals("-1")) {
            qw.like("windturbine_id", "_WT_");
        } else {
            qw.like("windturbine_id", "_IN_");
        }
        qw.groupBy("line_id");

        //        total = proEconEquipmentInfoDay1Mapper.selectCount(qw);

        Map<String, Object> wxsslVoList = getWxsslSortVos2(qw, total, resultList, TYPE_LINE, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    public Map<String, Object> xldb(String companys, String type, String wpids, String projectids, String lineids, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        List<WxsslVo> resultList = new ArrayList<>();
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        Integer total = 0;
        qw.select("line_id,sum(rfdl) rfdl,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");

        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));

        if (StringUtils.isNotEmpty(wpids)) {
            List<String> wpList = Arrays.asList(wpids.split(","));
            qw.in("station_id", wpList);
        }
        if (StringUtils.isNotEmpty(projectids)) {
            List<String> projectList = Arrays.asList(projectids.split(","));
            qw.in("project_id", projectList);
        }
        if (StringUtils.isNotEmpty(lineids)) {
            List<String> lineList = Arrays.asList(lineids.split(","));
            qw.in("line_id", lineList);

        }
//        if (companys.endsWith("RGN")) {
//            qw.eq("region_id", companys);
//        } else {
//            qw.eq("company_id", companys);
//        }
        if (type.equals("-1")) {
            qw.like("turbine_id", "_WT_");
        } else {
            qw.like("turbine_id", "_IN_");
        }
        qw.groupBy("line_id");

        Map<String, Object> wxsslVoList = getWxsslSortVos(qw, total, resultList, TYPE_LINE, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    /**
     * 根据查询条件和类型，查询处五项损失并封装到结果list
     *
     * @param qw
     * @param resultList
     * @param type
     * @return
     */
    private Map<String, Object> getWxsslSortVos2(QueryWrapper<ProEconEquipmentInfoDay1> qw, Integer total, List<WxsslVo> resultList, String type, int pageNum, int pageSize) {
        Map<String, Object> resultMap = new HashMap<>();
        List<ProBasicPowerstation> wpls = CacheContext.wpls;
        Map<String, Integer> station = wpls
                .stream().collect(Collectors.toMap(ProBasicPowerstation::getId, ProBasicPowerstation::getOrderNum));

        List<ProEconEquipmentInfoDay1> list1 = proEconEquipmentInfoDay1Service.list(qw);
        int offset = (pageNum - 1) * pageSize;
        int limit = pageSize;
        qw.last("OFFSET " + offset + " ROWS FETCH NEXT " + limit + " ROWS ONLY");


        List<ProEconEquipmentInfoDay1> list = proEconEquipmentInfoDay1Service.list(qw);
        list.stream().forEach(i -> {
            WxsslVo vo = new WxsslVo();

            if (type.equals(TYPE_WIND)) {
                vo.setId(i.getWindpowerstationId());
                vo.setName(CacheContext.wpmap.get(i.getWindpowerstationId().trim()).getAname());
                vo.setOrdernum(station.get(i.getWindpowerstationId()).doubleValue());
            } else if (type.equals(TYPE_PROJECT)) {
                vo.setId(i.getProjectId());

                vo.setName(CacheContext.pjmap.get(i.getProjectId().trim()).getAname());
                vo.setOrdernum(CacheContext.pjmap.get(i.getProjectId().trim()).getOrderNum().doubleValue());
            } else if (type.equals(TYPE_LINE)) {
                vo.setId(i.getLineId());
                vo.setName(CacheContext.lnmap.get(i.getLineId().trim()).getAname());
                vo.setOrdernum(CacheContext.lnmap.get(i.getLineId().trim()).getOrderNum().doubleValue());
            } else if (type.equals(TYPE_WINDTURBINE)) {
                vo.setId(i.getWindturbineId());
                vo.setName(CacheContext.wtmap.get(i.getWindturbineId().trim()).getAname());
                vo.setOrdernum(CacheContext.wtmap.get(i.getWindturbineId().trim()).getOrderNum().doubleValue());
            }
            vo.setDate(i.getRecordDate());
            vo.setFdl(DoubleUtils.keepPrecision(i.getRfdl() / 10000, 2));
            vo.setLlfdl(DoubleUtils.keepPrecision(i.getRllfdl() / 10000, 2));
            vo.setJxssdl(DoubleUtils.keepPrecision((i.getRjxssdl() + i.getRcnsljxssdl()) / 10000, 2));
            vo.setGzssdl(DoubleUtils.keepPrecision((i.getRgzssdl() + i.getRcnslgzssdl()) / 10000, 2));
            vo.setXdssdl(DoubleUtils.keepPrecision((i.getRxdtjssdl() + i.getRxdjclssdl()) / 10000, 2));
            vo.setSlssdl(DoubleUtils.keepPrecision((i.getRcwsltqssdl() + i.getRcwsldwssdl()) / 10000, 2));
            vo.setXnssdl(DoubleUtils.keepPrecision((i.getRdjssdl() + i.getRsdtjssdl() + i.getRqxjclssdl() + i.getRxnssdl()) / 10000, 2));
            vo.setZssdl(DoubleUtils.keepPrecision(vo.getGzssdl() + vo.getJxssdl() + vo.getXdssdl() + vo.getXnssdl() + vo.getSlssdl(), 2));
            vo.setFnlyl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getFdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setGzssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getGzssdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setJxssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getJxssdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setQfl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getXdssdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setXnssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getXnssdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setSlssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSlssdl() / vo.getLlfdl() * 100, 2) : 0);
            resultList.add(vo);
        });
        SortUtils.sort(resultList, "llfdl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setZhpm(i + 1);
        }
        SortUtils.sort(resultList, "fdl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setFdlpm(i + 1);
        }
        SortUtils.sort(resultList, "fnlyl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setFnlylpm(i + 1);
        }
        SortUtils.sort(resultList, "gzssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setGzssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "gzssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setGzsslpm(i + 1);
        }
        SortUtils.sort(resultList, "jxssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setJxssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "jxssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setJxsslpm(i + 1);
        }
        SortUtils.sort(resultList, "xdssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXdssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "qfl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setQflpm(i + 1);
        }
        SortUtils.sort(resultList, "xnssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXnssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "xnssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXnsslpm(i + 1);
        }
        SortUtils.sort(resultList, "slssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setSlssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "slssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setSlsslpm(i + 1);
        }
        //        SortUtils.sort(resultList,"ordernum",SortUtils.ASC);
        // 计算总记录数
        //        long total = proEconEquipmentInfoDay1Service.count(qw);
        // 计算总记录数
        Integer ls = list1.size();

        resultMap.put("resultList", resultList);
        resultMap.put("total", ls);
        resultMap.put("pageNum", pageNum);
        resultMap.put("pageSize", pageSize);
        return resultMap;
    }


    private Map<String, Object> getWxsslSortVos(QueryWrapper<TurbineInfoDay> qw, Integer total, List<WxsslVo> resultList, String type, int pageNum, int pageSize) {
        Map<String, Object> resultMap = new HashMap<>();
        List<ProBasicPowerstation> wpls = CacheContext.wpls;
        Map<String, Integer> station = wpls
                .stream().collect(Collectors.toMap(ProBasicPowerstation::getId, ProBasicPowerstation::getOrderNum));

        List<TurbineInfoDay> list1 = iTurbineInfoDayService.list(qw);
        int offset = (pageNum - 1) * pageSize;
        int limit = pageSize;
        qw.last("OFFSET " + offset + " ROWS FETCH NEXT " + limit + " ROWS ONLY");


        List<TurbineInfoDay> list = iTurbineInfoDayService.list(qw);
        list.stream().forEach(i -> {
            WxsslVo vo = new WxsslVo();

            if (type.equals(TYPE_WIND)) {
                vo.setId(i.getStationId());
                vo.setName(CacheContext.wpmap.get(i.getStationId().trim()).getAname());
                vo.setOrdernum(station.get(i.getStationId()).doubleValue());
            } else if (type.equals(TYPE_PROJECT)) {
                vo.setId(i.getProjectId());

                vo.setName(CacheContext.pjmap.get(i.getProjectId().trim()).getAname());
                vo.setOrdernum(CacheContext.pjmap.get(i.getProjectId().trim()).getOrderNum().doubleValue());
            } else if (type.equals(TYPE_LINE)) {
                vo.setId(i.getLineId());
                vo.setName(CacheContext.lnmap.get(i.getLineId().trim()).getAname());
                vo.setOrdernum(CacheContext.lnmap.get(i.getLineId().trim()).getOrderNum().doubleValue());
            } else if (type.equals(TYPE_WINDTURBINE)) {
                vo.setId(i.getTurbineId());
                vo.setName(CacheContext.wtmap.get(i.getTurbineId().trim()).getAname());
                vo.setOrdernum(CacheContext.wtmap.get(i.getTurbineId().trim()).getOrderNum().doubleValue());
            }
            if (null == i.getRecordDate()) {
                vo.setDate(null);
            } else {
                Date date = i.getRecordDate();
                vo.setDate(date);
            }
            vo.setFdl(DoubleUtils.keepPrecision(i.getRfdl() / 1000, 2));
            vo.setLlfdl(DoubleUtils.keepPrecision(i.getLlfdl() / 1000, 2));
            vo.setJxssdl(DoubleUtils.keepPrecision((i.getJhjxss() + i.getFjhjxss()) / 1000, 2));
            vo.setGzssdl(DoubleUtils.keepPrecision(i.getGzss() / 1000, 2));
            vo.setXdssdl(DoubleUtils.keepPrecision((i.getXdss() + i.getDjss()) / 1000, 2));
            vo.setSlssdl(DoubleUtils.keepPrecision(i.getSlss() / 1000, 2));
            vo.setXnssdl(DoubleUtils.keepPrecision(i.getXnss() / 1000, 2));
            vo.setZssdl(DoubleUtils.keepPrecision((vo.getGzssdl() + vo.getJxssdl() + vo.getXdssdl() + vo.getXnssdl() + vo.getSlssdl()) / 1000, 2));
            vo.setFnlyl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getFdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setGzssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getGzssdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setJxssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getJxssdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setQfl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getXdssdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setXnssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getXnssdl() / vo.getLlfdl() * 100, 2) : 0);
            vo.setSlssl(vo.getLlfdl() != 0 ? DoubleUtils.keepPrecision(vo.getSlssdl() / vo.getLlfdl() * 100, 2) : 0);
            resultList.add(vo);
        });
        SortUtils.sort(resultList, "llfdl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setZhpm(i + 1);
        }
        SortUtils.sort(resultList, "fdl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setFdlpm(i + 1);
        }
        SortUtils.sort(resultList, "fnlyl", SortUtils.DESC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setFnlylpm(i + 1);
        }
        SortUtils.sort(resultList, "gzssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setGzssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "gzssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setGzsslpm(i + 1);
        }
        SortUtils.sort(resultList, "jxssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setJxssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "jxssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setJxsslpm(i + 1);
        }
        SortUtils.sort(resultList, "xdssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXdssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "qfl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setQflpm(i + 1);
        }
        SortUtils.sort(resultList, "xnssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXnssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "xnssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setXnsslpm(i + 1);
        }
        SortUtils.sort(resultList, "slssdl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setSlssdlpm(i + 1);
        }
        SortUtils.sort(resultList, "slssl", SortUtils.ASC);
        for (int i = 0; i < resultList.size(); i++) {
            resultList.get(i).setSlsslpm(i + 1);
        }
        Integer ls = list1.size();

        resultMap.put("resultList", resultList);
        resultMap.put("total", ls);
        resultMap.put("pageNum", pageNum);
        resultMap.put("pageSize", pageSize);
        return resultMap;
    }


    public Map<String, Object> details2(String id, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        List<WxsslVo> resultList = new ArrayList<>();
        QueryWrapper<ProEconEquipmentInfoDay1> qw = new QueryWrapper<>();
        Integer total = 0;
        qw.select("windturbine_id,sum(rfdl) rfdl,sum(rllfdl) rllfdl,avg(rpjfs) rpjfs,sum(rjxssdl) rjxssdl,sum(rcnsljxssdl) rcnsljxssdl,sum(rgzssdl) rgzssdl,sum(rcnslgzssdl) rcnslgzssdl,sum(rxdtjssdl) rxdtjssdl,sum(rxdjclssdl) rxdjclssdl,sum(rdjssdl) rdjssdl,sum(rqxjclssdl) rqxjclssdl,sum(rsdtjssdl) rsdtjssdl,sum(rxnssdl) rxnssdl,sum(rcwsldwssdl) rcwsldwssdl,sum(rcwsltqssdl) rcwsltqssdl");

        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (id.endsWith("STA")) {
            qw.eq("windpowerstation_id", id);
        } else if (id.endsWith("EG")) {
            qw.eq("project_id", id);
        } else if (id.endsWith("LN")) {
            qw.eq("line_id", id);
        }
        qw.groupBy("windturbine_id");
        //        total = proEconEquipmentInfoDay1Service.count(qw);
        Map<String, Object> wxsslVoList = getWxsslSortVos2(qw, total, resultList, TYPE_WINDTURBINE, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return wxsslVoList;
    }


    public Map<String, Object> details(String id, String beginDate, String endDate, String target, String sort, int pageNum, int pageSize) {
        List<WxsslVo> resultList = new ArrayList<>();
        QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
        Integer total = 0;
        qw.select("turbine_id,sum(rfdl) rfdl,sum(llfdl) llfdl,avg(pjfs) pjfs,sum(jhjxss) jhjxss,sum(fjhjxss) fjhjxss,sum(slss) slss,sum(gzss) gzss,sum(xdss) xdss,sum(xnss) xnss,sum(djss) djss");

        qw.ge("record_date", DateUtils.parseDate(beginDate)).le("record_date", DateUtils.parseDate(endDate));
        if (id.endsWith("STA")) {
            qw.eq("station_id", id);
        } else if (id.endsWith("EG")) {
            qw.eq("project_id", id);
        } else if (id.endsWith("LN")) {
            qw.eq("line_id", id);
        }
        qw.groupBy("turbine_id");
        //        total = proEconEquipmentInfoDay1Service.count(qw);
        Map<String, Object> wxsslVoList = getWxsslSortVos(qw, total, resultList, TYPE_WINDTURBINE, pageNum, pageSize);
        if (StringUtils.isNotEmpty(target) && StringUtils.isNotEmpty(sort)) {
            if (sort.equals("1")) {
                SortUtils.sort(resultList, target, SortUtils.ASC);
            } else {
                SortUtils.sort(resultList, target, SortUtils.DESC);
            }
        } else {
            SortUtils.sort(resultList, "ordernum", SortUtils.ASC);
        }
        return wxsslVoList;
    }


}
