package com.gyee.frame.service.singleanalysis;

import com.gyee.frame.common.spring.InitialRunner;
import com.gyee.frame.model.auto.*;
import com.gyee.frame.model.custom.SingleAnalysisVo;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.service.*;
import com.gyee.frame.util.StringUtils;
import org.springframework.stereotype.Service;

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


@Service
public class SingleAnalysisService {

    @Resource
    private InputoroutputspeedtotalService inputoroutputspeedtotalService;
    @Resource
    private WindturbineinfodayService windturbineinfodayService;
    @Resource
    private WindTurbineInfoDay2Service WindTurbineInfoDay2Service;
    @Resource
    private Windturbineinfoday3Service windturbineinfoday3Service;
    @Resource
    private WindpowerinfodayService windpowerinfodayService;
    @Resource
    private WindturbinethewindinfoService windturbinethewindinfoService;


    public List<SingleAnalysisVo> SingleAnalysisList(Tablepar tablepar, String wpId, Date beginDate, Date endDate) {

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

        if (StringUtils.notEmp(wpId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {

            Map<String, SingleAnalysisVo> iomap = getInputoroutputspeedtotalMap(wpId, beginDate, endDate);
            Map<String, SingleAnalysisVo> wtdaymap = getWindturbineinfodayMap(wpId, beginDate, endDate);
            Map<String, SingleAnalysisVo> wtday2map = getWindturbineinfoday2Map(wpId, beginDate, endDate);
            Map<String, SingleAnalysisVo> wtday3map = getWindturbineinfoday3Map(wpId, beginDate, endDate);


            if (InitialRunner.wp_wtmap.containsKey(wpId)) {
                List<Windturbine> wtls = InitialRunner.wp_wtmap.get(wpId);

                for (Windturbine wt : wtls) {
                    SingleAnalysisVo vo = new SingleAnalysisVo();
                    vo.setWindPowerStationId(wt.getWindpowerstationid());
                    vo.setWindturbineName(wt.getName());
                    if (InitialRunner.wpmap.containsKey(wt.getWindpowerstationid())) {
                        Windpowerstation wp = InitialRunner.wpmap.get(wt.getWindpowerstationid());
                        vo.setWindPowerStationName(wp.getName());
                    }

                    if (InitialRunner.mlmap.containsKey(wt.getModelid())) {
                        Equipmentmodel model = InitialRunner.mlmap.get(wt.getModelid());
                        vo.setFjrl(model.getPowerproduction());
                    }


                    vo.setWindturbineid(wt.getId());

//                        double swdl=wpls.stream().mapToDouble(Windpowerinfoday::getGridelectricity).sum();//风场上网电量合计
//                        double gwdl=wpls.stream().mapToDouble(Windpowerinfoday::getBuyelectricity).sum();//风场购网电量合计
//
//                        vo.setSwdl(swdl);
//                        vo.setGwdl(gwdl);
                    double fdl = 0;
                    if (wtdaymap.containsKey(wt.getId())) {
                        SingleAnalysisVo wtd = wtdaymap.get(wt.getId());

                        fdl = null != wtd.getFdl() ? wtd.getFdl() : 0.0;//风机发电量合计
                        fdl = new BigDecimal(fdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).doubleValue();

                        double yxxs = null != wtd.getYxxs() ? wtd.getYxxs() : 0.0;//风机运行小时合计
                        double gzxs = null != wtd.getGzxs() ? wtd.getGzxs() : 0.0;//风机故障小时合计
                        double jxxs = null != wtd.getJxxs() ? wtd.getJxxs() : 0.0;//风机检修小时合计
                        double tjxs = null != wtd.getTjxs() ? wtd.getTjxs() : 0.0;//风机停机小时合计
                        double zdxs = null != wtd.getZdxs() ? wtd.getZdxs() : 0.0;//风机中断小时合计
                        double rlxs = null != wtd.getRlxs() ? wtd.getRlxs() : 0.0;//风机日历小时合计
                        double fs = null != wtd.getFs() ? wtd.getFs() : 0.0;//风机平均风速
                        double sbklyl = null != wtd.getSbklyl() ? wtd.getSbklyl() : 0.0;//风机平均设备可利用率
                        double dxklyxs = null != wtd.getDxklyxs() ? wtd.getDxklyxs() : 0.0;//风机平均等效可利用系数
                        double lyxs = null != wtd.getLyxs() ? wtd.getLyxs() : 0.0;//风机平均利用小时
                        double yxfss = null != wtd.getYxfss() ? wtd.getYxfss() : 0.0;//风机平均有效风时速


                        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));

                    }

                    if (wtday2map.containsKey(wt.getId())) {
                        SingleAnalysisVo wtd = wtday2map.get(wt.getId());

                        double glyzxxs = null != wtd.getGlyzxxs() ? wtd.getGlyzxxs() : 0.0;//风机平均功率一致性系数
                        vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));
                    }

                    if (wtday3map.containsKey(wt.getId())) {
                        SingleAnalysisVo wtd = wtday3map.get(wt.getId());

                        double gzss = null != wtd.getGzss() ? wtd.getGzss() : 0.0;//风机故障损失合计
                        double jxss = null != wtd.getJxss() ? wtd.getJxss() : 0.0;//风机检修损失合计
                        double xdss = null != wtd.getXdss() ? wtd.getXdss() : 0.0;//风机限电损失合计
                        double xnss = null != wtd.getXnss() ? wtd.getXnss() : 0.0;//风机性能损失时合计
                        double slss = null != wtd.getSlss() ? wtd.getSlss() : 0.0;//风机受累损失合计


                        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));
                    }

                    if (iomap.containsKey(wt.getId())) {
                        SingleAnalysisVo wtd = iomap.get(wt.getId());

                        double xfqr = null != wtd.getXfqr() ? wtd.getXfqr() : 0.0;//风机小风切入
                        double xfqrhgl = null != wtd.getXfqrhgl() ? wtd.getXfqrhgl() : 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("合计");
            List<Windpowerinfoday> wpls = windpowerinfodayService.getWindpowerinfodayList(wpId, beginDate, endDate);
            double swdl = wpls.stream().mapToDouble(Windpowerinfoday::getGridelectricity).sum();//风场上网电量合计
            double gwdl = wpls.stream().mapToDouble(Windpowerinfoday::getBuyelectricity).sum();//风场购网电量合计
            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().mapToDouble(SingleAnalysisVo::getGzss).sum();//风机故障损失合计
            double jxss = vos.stream().mapToDouble(SingleAnalysisVo::getJxss).sum();//风机检修损失合计
            double xdss = vos.stream().mapToDouble(SingleAnalysisVo::getXdss).sum();//风机限电损失合计
            double xnss = vos.stream().mapToDouble(SingleAnalysisVo::getXnss).sum();//风机性能损失时合计
            double slss = vos.stream().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);
        }

        vos = sortSingleAnalysisVoList(tablepar, vos);
        return vos;
    }


    public List<SingleAnalysisVo> SingleAnalysisList(String wpId, Date beginDate, Date endDate) {

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

        if (StringUtils.notEmp(wpId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {

            vos = inputoroutputspeedtotalService.getInputoroutputspeedtotalMapper(wpId, beginDate, endDate);
        }
        return vos;
    }

    public SingleAnalysisVo SingleAnalysisListByWtId(String wtId, Date beginDate, Date endDate) {

        SingleAnalysisVo vo = new SingleAnalysisVo();

        if (StringUtils.notEmp(wtId) && StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {

            List<SingleAnalysisVo> iols = inputoroutputspeedtotalService.getInputoroutputspeedtotalMapperByWtId(wtId, beginDate, endDate);
            List<SingleAnalysisVo> wtdayls = windturbineinfodayService.getWindTurbineInfoDayMapperByWtId(wtId, beginDate, endDate);
            List<SingleAnalysisVo> wtday2ls = WindTurbineInfoDay2Service.getWindTurbineInfoDayMapper2ByWtId(wtId, beginDate, endDate);
            List<SingleAnalysisVo> wtday3ls = windturbineinfoday3Service.getWindTurbineInfoDayMapper3ByWtId(wtId, beginDate, endDate);
            List<SingleAnalysisVo> wtdls = windturbinethewindinfoService.getWindturbinethewindinfoMapperByWtId(wtId, beginDate, endDate);

            Windturbine wt = InitialRunner.wtmap.get(wtId);
            Windpowerstation wp = InitialRunner.wpmap.get(wt.getWindpowerstationid());
            List<Windpowerinfoday> wpls = windpowerinfodayService.getWindpowerinfodayList(wp.getId(), beginDate, endDate);


            vo.setWindPowerStationId(wt.getWindpowerstationid());
            vo.setWindPowerStationName(wp.getName());
            vo.setWindturbineName(wt.getName());
            if (InitialRunner.mlmap.containsKey(wt.getModelid())) {
                Equipmentmodel model = InitialRunner.mlmap.get(wt.getModelid());
                vo.setFjrl(model.getPowerproduction());
            }


            vo.setWindturbineid(wt.getId());

            double swdl = wpls.stream().mapToDouble(Windpowerinfoday::getGridelectricity).sum();//风场上网电量合计
            double gwdl = wpls.stream().mapToDouble(Windpowerinfoday::getBuyelectricity).sum();//风场购网电量合计

            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 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;//风机小风切入
            double llfdl=0.0;//理论发电量
            if (StringUtils.notEmp(wtdayls) && !wtdayls.isEmpty() && StringUtils.notEmp(wtdayls.get(0)) ) {

                SingleAnalysisVo wtd = wtdayls.get(0);

                fdl = null != wtd.getFdl() ? wtd.getFdl() : 0.0;//风机发电量合计
                yxxs = null != wtd.getYxxs() ? wtd.getYxxs() : 0.0;//风机运行小时合计
                gzxs = null != wtd.getGzxs() ? wtd.getGzxs() : 0.0;//风机故障小时合计
                jxxs = null != wtd.getJxxs() ? wtd.getJxxs() : 0.0;//风机检修小时合计
                tjxs = null != wtd.getTjxs() ? wtd.getTjxs() : 0.0;//风机停机小时合计
                zdxs = null != wtd.getZdxs() ? wtd.getZdxs() : 0.0;//风机中断小时合计
                rlxs = null != wtd.getRlxs() ? wtd.getRlxs() : 0.0;//风机日历小时合计
                fs = null != wtd.getFs() ? wtd.getFs() : 0.0;//风机平均风速
                sbklyl = null != wtd.getSbklyl() ? wtd.getSbklyl() : 0.0;//风机平均设备可利用率
                dxklyxs = null != wtd.getDxklyxs() ? wtd.getDxklyxs() : 0.0;//风机平均等效可利用系数
                lyxs = null != wtd.getLyxs() ? wtd.getLyxs() : 0.0;//风机平均利用小时
                yxfss = null != wtd.getYxfss() ? wtd.getYxfss() : 0.0;//风机平均有效风时速
            }

            fdl = new BigDecimal(fdl).divide(new BigDecimal(10000), 2, RoundingMode.HALF_UP).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 (StringUtils.notEmp(wtday2ls) && !wtday2ls.isEmpty() && StringUtils.notEmp(wtday2ls.get(0)) ) {
                SingleAnalysisVo wtd = wtday2ls.get(0);
                 glyzxxs = null != wtd.getGlyzxxs() ? wtd.getGlyzxxs() : 0.0;//风机平均功率一致性系数
            }
            vo.setGlyzxxs(StringUtils.round(glyzxxs, 2));
            if (StringUtils.notEmp(wtday3ls) && !wtday3ls.isEmpty() && StringUtils.notEmp(wtday3ls.get(0)) ) {
                SingleAnalysisVo wtd = wtday3ls.get(0);
                 gzss = null != wtd.getGzss() ? wtd.getGzss() : 0.0;//风机故障损失合计
                 jxss = null != wtd.getJxss() ? wtd.getJxss() : 0.0;//风机检修损失合计
                 xdss = null != wtd.getXdss() ? wtd.getXdss() : 0.0;//风机限电损失合计
                 xnss = null != wtd.getXnss() ? wtd.getXnss() : 0.0;//风机性能损失时合计
                 slss = null != wtd.getSlss() ? wtd.getSlss() : 0.0;//风机受累损失合计



                 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 (StringUtils.notEmp(iols) && !iols.isEmpty() && StringUtils.notEmp(iols.get(0)) ) {
                SingleAnalysisVo wtd = iols.get(0);
                xfqr = null != wtd.getXfqr() ? wtd.getXfqr() : 0.0;//风机小风切入
                xfqrhgl = null != wtd.getXfqrhgl() ? wtd.getXfqrhgl() : 0.0;//风机小风切入合格率
            }

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

            if (StringUtils.notEmp(wtdls) && !wtdls.isEmpty() && StringUtils.notEmp(wtdls.get(0)) ) {
                SingleAnalysisVo wtd = wtdls.get(0);
                jfpl = null != wtd.getJfpl() ? wtd.getJfpl() : 0.0;//静风频率
            }
            vo.setJfpl(StringUtils.round(jfpl, 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)) {

            List<Inputoroutputspeedtotal> iols = inputoroutputspeedtotalService.getInputoroutputspeedtotalbyWtId(wtId, beginDate, endDate);
            List<WindTurbineInfoDay> wtdayls = windturbineinfodayService.getWindturbineinfodayListByWtId(wtId, beginDate, endDate);
//            List<WindTurbineInfoDay2> wtday2ls = WindTurbineInfoDay2Service.getWindturbineinfoday2List(wtId, beginDate, endDate);
            List<Windturbineinfoday3> wtday3ls = windturbineinfoday3Service.getWindturbineinfoday3ListBywtId(wtId, beginDate, endDate);
            List<Windturbinethewindinfo> wtdls = windturbinethewindinfoService.getWindturbinethewindinfo(wtId, beginDate, endDate);

            Windturbine wt = InitialRunner.wtmap.get(wtId);
            Windpowerstation wp = InitialRunner.wpmap.get(wt.getWindpowerstationid());
//            List<Windpowerinfoday> wpls = windpowerinfodayService.getWindpowerinfodayList(wp.getId(), beginDate, endDate);



            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 gzss = 0.0;//风机故障损失合计
            double jxss = 0.0;//风机检修损失合计
            double xdss = 0.0;//风机限电损失合计
            double xnss = 0.0;//风机性能损失时合计
            double slss = 0.0;//风机受累损失合计

            double jfpl = 0.0;//风机小风切入


            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            Map<String,WindTurbineInfoDay> wtdmap=new HashMap<>();
            if (StringUtils.notEmp(wtdayls) && !wtdayls.isEmpty()) {

                for(WindTurbineInfoDay wtd:wtdayls)
                {

                    SingleAnalysisVo vo = new SingleAnalysisVo();
                    fdl = null != wtd.getGeneratingcapacity2() ? wtd.getGeneratingcapacity2() : 0.0;//风机发电量合计
                    yxxs = null != wtd.getRuntime() ? wtd.getRuntime() : 0.0;//风机运行小时合计
                    gzxs = null != wtd.getFaulttime() ? wtd.getFaulttime() : 0.0;//风机故障小时合计
                    jxxs = null != wtd.getMaintaintime() ? wtd.getMaintaintime() : 0.0;//风机检修小时合计
                    tjxs = null != wtd.getStoptime() ? wtd.getStoptime() : 0.0;//风机停机小时合计
                    zdxs = null != wtd.getInterrupttime() ? wtd.getInterrupttime() : 0.0;//风机中断小时合计
                    rlxs = null != wtd.getDaycalendarhours() ? wtd.getDaycalendarhours() : 0.0;//风机日历小时合计
                    fs = null != wtd.getSpeed() ? wtd.getSpeed() : 0.0;//风机平均风速

                    vo.setWindPowerStationId(wt.getWindpowerstationid());
                    vo.setWindPowerStationName(wp.getName());
                    vo.setWindturbineName(wt.getName());
                    vo.setWindturbineid(wt.getId());
                    vo.setRecorddate(wtd.getRecorddate());

                    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));
                    fdlfsls.add(vo);
                    wtdmap.put(df.format(wtd.getRecorddate()),wtd);
                }

            }

            if (StringUtils.notEmp(wtday3ls) && !wtday3ls.isEmpty() && StringUtils.notEmp(wtday3ls.get(0)) ) {
                for(Windturbineinfoday3 wtd:wtday3ls) {

                    SingleAnalysisVo vo = new SingleAnalysisVo();
                    gzss = null != wtd.getDaynhxdssdl() ? wtd.getDaynhxdssdl() : 0.0;//风机故障损失合计
                    jxss = null != wtd.getDaynhwhssdl() ? wtd.getDaynhwhssdl() : 0.0;//风机检修损失合计
                    xdss = null != wtd.getDaynhxdssdl() ? wtd.getDaynhxdssdl() : 0.0;//风机限电损失合计
                    xnss = null != wtd.getDaynhqfdl() ? wtd.getDaynhqfdl() : 0.0;//风机性能损失时合计
                    slss = null != wtd.getDaynhcfdl() ? wtd.getDaynhcfdl() : 0.0;//风机受累损失合计

                    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(wtdls) && !wtdls.isEmpty()) {

                for(Windturbinethewindinfo wtd:wtdls) {

                    SingleAnalysisVo vo = new SingleAnalysisVo();

                    vo.setRecorddate(wtd.getRecorddate());
                    jfpl = null != wtd.getCb() ? wtd.getCb() : 0.0;//静风频率
                    vo.setWindPowerStationId(wt.getWindpowerstationid());
                    vo.setWindPowerStationName(wp.getName());
                    vo.setWindturbineName(wt.getName());
                    vo.setWindturbineid(wt.getId());
                    vo.setJfpl(StringUtils.round(jfpl, 2));
                    if(wtdmap.containsKey(df.format(wtd.getRecorddate())))
                    {
                        WindTurbineInfoDay wtday=wtdmap.get(df.format(wtd.getRecorddate()));
                        vo.setTjxs(wtday.getStoptime());
                    }
                    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();


        if (StringUtils.notEmp(vo1) && StringUtils.notEmp(vo2)) {

            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;
    }

    private Map<String, SingleAnalysisVo> getWindturbineinfoday3Map(String wpId, Date beginDate, Date endDate) {
        Map<String, SingleAnalysisVo> wtdaymap = new HashMap<>();
        List<SingleAnalysisVo> wtdayls = windturbineinfoday3Service.getWindTurbineInfoDay3Mapper(wpId, beginDate, endDate);

        if (!wtdayls.isEmpty()) {
            if (!wtdayls.isEmpty()) {
                for (SingleAnalysisVo io : wtdayls) {
                    wtdaymap.put(io.getWindturbineid(), io);
                }
            }
        }
        return wtdaymap;
    }

    private Map<String, SingleAnalysisVo> getWindturbineinfoday2Map(String wpId, Date beginDate, Date endDate) {
        Map<String, SingleAnalysisVo> wtdaymap = new HashMap<>();
        List<SingleAnalysisVo> wtdayls = WindTurbineInfoDay2Service.getWindTurbineInfoDay2Mapper(wpId, beginDate, endDate);

        if (!wtdayls.isEmpty()) {
            if (!wtdayls.isEmpty()) {
                for (SingleAnalysisVo io : wtdayls) {
                    wtdaymap.put(io.getWindturbineid(), io);
                }
            }
        }
        return wtdaymap;
    }

    private Map<String, SingleAnalysisVo> getWindturbineinfodayMap(String wpId, Date beginDate, Date endDate) {
        Map<String, SingleAnalysisVo> wtdaymap = new HashMap<>();
        List<SingleAnalysisVo> wtdayls = windturbineinfodayService.getWindTurbineInfoDayMapper(wpId, beginDate, endDate);

        if (!wtdayls.isEmpty()) {
            if (!wtdayls.isEmpty()) {
                for (SingleAnalysisVo io : wtdayls) {
                    wtdaymap.put(io.getWindturbineid(), io);
                }
            }
        }
        return wtdaymap;
    }

    private Map<String, SingleAnalysisVo> getInputoroutputspeedtotalMap(String wpId, Date beginDate, Date endDate) {
        Map<String, SingleAnalysisVo> iomap = new HashMap<>();
        List<SingleAnalysisVo> iols = inputoroutputspeedtotalService.getInputoroutputspeedtotalMapper(wpId, beginDate, endDate);

        if (!iols.isEmpty()) {
            for (SingleAnalysisVo io : iols) {
                iomap.put(io.getWindturbineid(), io);
            }
        }
        return iomap;
    }


    public List<SingleAnalysisVo> sortSingleAnalysisVoList(Tablepar tablepar, List<SingleAnalysisVo> ls) {

        if (null != tablepar && StringUtils.notEmp(tablepar.getOrderByColumn())) {

            switch (tablepar.getOrderByColumn()) {
                case "windturbineName":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getWindturbineName().compareTo(o2.getWindturbineName());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getWindturbineName().compareTo(o1.getWindturbineName());
                            }

                        });
                    }
                    break;
                case "fdl":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getFdl().compareTo(o2.getFdl());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getFdl().compareTo(o1.getFdl());
                            }

                        });
                    }
                    break;
                case "fs":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getFs().compareTo(o2.getFs());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getFs().compareTo(o1.getFs());
                            }

                        });
                    }
                    break;
                case "gzss":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getGzss().compareTo(o2.getGzss());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getGzss().compareTo(o1.getGzss());
                            }

                        });
                    }
                    break;
                case "jxss":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getJxss().compareTo(o2.getJxss());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getJxss().compareTo(o1.getJxss());
                            }

                        });
                    }
                    break;
                case "xdss":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getXdss().compareTo(o2.getXdss());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getXdss().compareTo(o1.getXdss());
                            }

                        });
                    }
                    break;
                case "xnss":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getXnss().compareTo(o2.getXnss());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getXnss().compareTo(o1.getXnss());
                            }

                        });
                    }
                    break;
                case "slss":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getSlss().compareTo(o2.getSlss());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getSlss().compareTo(o1.getSlss());
                            }

                        });
                    }
                    break;

                case "llfdl":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getLlfdl().compareTo(o2.getLlfdl());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getLlfdl().compareTo(o1.getLlfdl());
                            }

                        });
                    }
                    break;
                case "gzxs":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getGzxs().compareTo(o2.getGzxs());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getGzxs().compareTo(o1.getGzxs());
                            }

                        });
                    }
                    break;
                case "jxxs":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getJxxs().compareTo(o2.getJxxs());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getJxxs().compareTo(o1.getJxxs());
                            }

                        });
                    }
                    break;
                case "lyxs":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getLyxs().compareTo(o2.getLyxs());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getLyxs().compareTo(o1.getLyxs());
                            }

                        });
                    }
                    break;
                case "sbklyl":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getSbklyl().compareTo(o2.getSbklyl());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getSbklyl().compareTo(o1.getSbklyl());
                            }

                        });
                    }
                    break;
                case "dxklyxs":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getDxklyxs().compareTo(o2.getDxklyxs());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getDxklyxs().compareTo(o1.getDxklyxs());
                            }

                        });
                    }
                    break;
                case "rlxs":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getRlxs().compareTo(o2.getRlxs());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getRlxs().compareTo(o1.getRlxs());
                            }

                        });
                    }
                    break;
                case "xfqr":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getXfqr().compareTo(o2.getXfqr());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getXfqr().compareTo(o1.getXfqr());
                            }

                        });
                    }
                    break;
                case "glyzxxs":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getGlyzxxs().compareTo(o2.getGlyzxxs());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getGlyzxxs().compareTo(o1.getGlyzxxs());
                            }

                        });
                    }
                    break;
                case "yxfss":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getYxfss().compareTo(o2.getYxfss());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getYxfss().compareTo(o1.getYxfss());
                            }

                        });
                    }
                    break;
                case "jfpl":
                    if (tablepar.getIsAsc().equals("asc")) {

                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o1.getJfpl().compareTo(o2.getJfpl());
                            }

                        });
                    } else {
                        Collections.sort(ls, new Comparator<SingleAnalysisVo>() {
                            // 升序排序
                            public int compare(SingleAnalysisVo o1, SingleAnalysisVo o2) {
                                return o2.getJfpl().compareTo(o1.getJfpl());
                            }

                        });
                    }
                    break;
                default:

                    break;
            }

        }
        return ls;
    }
}
