package com.gyee.frame.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gyee.frame.common.base.BaseService;
import com.gyee.frame.common.spring.InitialRunner;
import com.gyee.frame.common.support.Convert;
import com.gyee.frame.mapper.auto.Windpowerinfoday3Mapper;
import com.gyee.frame.model.auto.*;
import com.gyee.frame.model.custom.Tablepar;
import com.gyee.frame.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**
 * 风机信息表 Windpowerinfoday3Service
 * @Title: Windpowerinfoday3Service.java 
 * @Package com.gyee.frame.service 
 **/
@Service
public class Windpowerinfoday3Service implements BaseService<Windpowerinfoday3, Windpowerinfoday3Example> {
	@Resource
	private Windpowerinfoday3Mapper windpowerinfoday3Mapper;

	@Resource
	private Windturbineinfoday3Service windturbineinfoday3Service;
	/**
	 * 分页查询
	 * @param tablepar
	 * @param name
	 * @return
	 */
	 public PageInfo<Windpowerinfoday3> list(Tablepar tablepar, String name){
	        Windpowerinfoday3Example testExample=new Windpowerinfoday3Example();
	        testExample.setOrderByClause("id ASC");
	        if(name!=null&&!"".equals(name)){
//	        	testExample.createCriteria().and.andCodeLike("%"+name+"%");
	        }

	        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
	        List<Windpowerinfoday3> list= windpowerinfoday3Mapper.selectByExample(testExample);
	        PageInfo<Windpowerinfoday3> pageInfo = new PageInfo<Windpowerinfoday3>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {

			List<Integer> lista=Convert.toIntArrayList(ids);
			Windpowerinfoday3Example example=new Windpowerinfoday3Example();
			example.createCriteria().andIdIn(lista);
			return windpowerinfoday3Mapper.deleteByExample(example);


	}


	@Override
	public Windpowerinfoday3 selectByPrimaryKey(String id) {

	 	if(StringUtils.isNotEmpty(id))
		{
			return windpowerinfoday3Mapper.selectByPrimaryKey(Integer.valueOf(id));

		}
	 	return new Windpowerinfoday3();

	}


	@Override
	public int updateByPrimaryKeySelective(Windpowerinfoday3 record) {
		return windpowerinfoday3Mapper.updateByPrimaryKeySelective(record);
	}


	/**
	 * 添加
	 */
	@Override
	public int insertSelective(Windpowerinfoday3 record) {

//		//添加雪花主键id
//		record.setId(SnowflakeIdWorker.getUUID());


		return windpowerinfoday3Mapper.insertSelective(record);
	}


	@Override
	public int updateByExampleSelective(Windpowerinfoday3 record, Windpowerinfoday3Example example) {

		return windpowerinfoday3Mapper.updateByExampleSelective(record, example);
	}


	@Override
	public int updateByExample(Windpowerinfoday3 record, Windpowerinfoday3Example example) {

		return windpowerinfoday3Mapper.updateByExample(record, example);
	}

	@Override
	public List<Windpowerinfoday3> selectByExample(Windpowerinfoday3Example example) {

		return windpowerinfoday3Mapper.selectByExample(example);
	}


	@Override
	public long countByExample(Windpowerinfoday3Example example) {

		return windpowerinfoday3Mapper.countByExample(example);
	}


	@Override
	public int deleteByExample(Windpowerinfoday3Example example) {

		return windpowerinfoday3Mapper.deleteByExample(example);
	}

	public Map<String, List<String>> getWindturbineinfoAllJson(String id, Date beginDate, Date endDate, int type) {
		List<Windpowerinfoday3> ls = this.getWindturbineinfoAll(id, beginDate, endDate, type, "", "");

		Map<String, List<String>> resultmap = new HashMap<String, List<String>>();
		List<String> names = new ArrayList<String>();
		List<String> names2 = new ArrayList<String>();
		List<String> yfdl = new ArrayList<String>();
		List<String> sfdl = new ArrayList<String>();
		List<String> gzdl = new ArrayList<String>();
		List<String> whdl = new ArrayList<String>();
		List<String> xddl = new ArrayList<String>();
		List<String> qfdl = new ArrayList<String>();
		List<String> sldl = new ArrayList<String>();
		List<String> lyl = new ArrayList<String>();
		List<String> speedl = new ArrayList<String>();
		for (int i = 0; i < ls.size() - 1; i++) {
			names.add(ls.get(i).getWtName());
			names2.add("");
			yfdl.add(((Double) StringUtils.round(ls.get(i).getTotal(), 2)).toString());
			sfdl.add(((Double) StringUtils.round(ls.get(i).getDaydl2(), 2)).toString());
			gzdl.add(((Double) StringUtils.round(ls.get(i).getDaynhgzssdl(), 2)).toString());
			whdl.add(((Double) StringUtils.round(ls.get(i).getDaynhwhssdl(), 2)).toString());
			xddl.add(((Double) StringUtils.round(ls.get(i).getDaynhxdssdl(), 2)).toString());
			qfdl.add(((Double) StringUtils.round(ls.get(i).getDaynhqfdl(), 2)).toString());
			sldl.add(((Double) StringUtils.round(ls.get(i).getDaynhcfdl(), 2)).toString());
			lyl.add(((Double) StringUtils.round(ls.get(i).getLyl(), 2)).toString());
			speedl.add(((Double) StringUtils.round(ls.get(i).getDayspeed(), 2)).toString());

		}
		resultmap.put("names", names);
		resultmap.put("names2", names2);
		resultmap.put("yfdl", yfdl);
		resultmap.put("sfdl", sfdl);
		resultmap.put("gzdl", gzdl);
		resultmap.put("whdl", whdl);
		resultmap.put("xddl", xddl);
		resultmap.put("qfdl", qfdl);
		resultmap.put("sldl", sldl);
		resultmap.put("lyl", lyl);
		resultmap.put("speedl", speedl);

		return resultmap;

	}


	public List<Windpowerinfoday3> getWindturbineinfoAll(String id, Date beginDate, Date endDate, int type,
														 String sortName, String sortOrder) {
		List<Windpowerinfoday3> vos = new ArrayList<Windpowerinfoday3>();

		if (StringUtils.notEmp(beginDate) && StringUtils.notEmp(endDate)) {
			Map<String, Object> params = new HashMap<String, Object>();

			Map map = new HashMap();
			List<Windturbineinfoday3> list = windturbineinfoday3Service.getWindturbineinfo(null, null, null, beginDate,
					endDate, sortName, sortOrder);
			for (int i = 0; i < list.size() - 1; i++) {
				switch (type) {
					case 0:
						if (map.containsKey(list.get(i).getWindpowerstationid())) {

							Windpowerinfoday3 wdp3 = (Windpowerinfoday3) map.get(list.get(i).getWindpowerstationid());
							wdp3.setDaydl2(
									wdp3.getDaydl2() + (list.get(i).getDaydl2() == null ? 0.0 : list.get(i).getDaydl2()));
							wdp3.setDaynhdl(wdp3.getDaynhdl()
									+ (list.get(i).getDaynhdl() == null ? 0.0 : list.get(i).getDaynhdl()));
							wdp3.setDaynhgzssdl(wdp3.getDaynhgzssdl()
									+ (list.get(i).getDaynhgzssdl() == null ? 0.0 : list.get(i).getDaynhgzssdl()));
							wdp3.setDaynhwhssdl(wdp3.getDaynhwhssdl()
									+ (list.get(i).getDaynhwhssdl() == null ? 0.0 : list.get(i).getDaynhwhssdl()));
							wdp3.setDaynhxdssdl(wdp3.getDaynhxdssdl()
									+ (list.get(i).getDaynhxdssdl() == null ? 0.0 : list.get(i).getDaynhxdssdl()));
							wdp3.setDaynhqfdl(wdp3.getDaynhqfdl()
									+ (list.get(i).getDaynhqfdl() == null ? 0.0 : list.get(i).getDaynhqfdl()));
							int count = (Integer) map.get(list.get(i).getWindpowerstationid() + "count");
							wdp3.setDayspeed((wdp3.getDayspeed()
									+ (list.get(i).getDayspeed() == null ? 0.0 : list.get(i).getDayspeed())));

							wdp3.setDaynhcfdl(wdp3.getDaynhcfdl()
									+ (list.get(i).getDaynhcfdl() == null ? 0.0 : list.get(i).getDaynhcfdl()));
							wdp3.setTotal(
									wdp3.getTotal() + (list.get(i).getTotal() == null ? 0.0 : list.get(i).getTotal()));

							map.put(list.get(i).getWindpowerstationid(), wdp3);
							map.put(list.get(i).getWindpowerstationid() + "count", count + 1);
						} else {
							Windpowerinfoday3 wdp3 = new Windpowerinfoday3();
							wdp3.setDaydl2(list.get(i).getDaydl2() == null ? 0.0 : list.get(i).getDaydl2());
							wdp3.setDaynhdl(list.get(i).getDaynhdl() == null ? 0.0 : list.get(i).getDaynhdl());
							wdp3.setDaynhgzssdl(list.get(i).getDaynhgzssdl() == null ? 0.0 : list.get(i).getDaynhgzssdl());
							wdp3.setDaynhwhssdl(list.get(i).getDaynhwhssdl() == null ? 0.0 : list.get(i).getDaynhwhssdl());
							wdp3.setDaynhxdssdl(list.get(i).getDaynhxdssdl() == null ? 0.0 : list.get(i).getDaynhxdssdl());
							wdp3.setDaynhqfdl(list.get(i).getDaynhqfdl() == null ? 0.0 : list.get(i).getDaynhqfdl());
							wdp3.setDayspeed(list.get(i).getDayspeed() == null ? 0.0 : list.get(i).getDayspeed());
							wdp3.setDaynhcfdl(list.get(i).getDaynhcfdl() == null ? 0.0 : list.get(i).getDaynhcfdl());
							wdp3.setTotal(list.get(i).getTotal() == null ? 0.0 : list.get(i).getTotal());
							map.put(list.get(i).getWindpowerstationid(), wdp3);
							map.put(list.get(i).getWindpowerstationid() + "count", 1);
						}
						break;
					case 1:

						if (map.containsKey(list.get(i).getProjectid())) {
							Windpowerinfoday3 wdp3 = (Windpowerinfoday3) map.get(list.get(i).getProjectid());
							wdp3.setDaydl2(
									wdp3.getDaydl2() + (list.get(i).getDaydl2() == null ? 0.0 : list.get(i).getDaydl2()));
							wdp3.setDaynhdl(wdp3.getDaynhdl()
									+ (list.get(i).getDaynhdl() == null ? 0.0 : list.get(i).getDaynhdl()));
							wdp3.setDaynhgzssdl(wdp3.getDaynhgzssdl()
									+ (list.get(i).getDaynhgzssdl() == null ? 0.0 : list.get(i).getDaynhgzssdl()));
							wdp3.setDaynhwhssdl(wdp3.getDaynhwhssdl()
									+ (list.get(i).getDaynhwhssdl() == null ? 0.0 : list.get(i).getDaynhwhssdl()));
							wdp3.setDaynhxdssdl(wdp3.getDaynhxdssdl()
									+ (list.get(i).getDaynhxdssdl() == null ? 0.0 : list.get(i).getDaynhxdssdl()));
							wdp3.setDaynhqfdl(wdp3.getDaynhqfdl()
									+ (list.get(i).getDaynhqfdl() == null ? 0.0 : list.get(i).getDaynhqfdl()));
							int count = (Integer) map.get(list.get(i).getProjectid() + "count");
							wdp3.setDayspeed((wdp3.getDayspeed()
									+ (list.get(i).getDayspeed() == null ? 0.0 : list.get(i).getDayspeed())));

							wdp3.setDaynhcfdl(wdp3.getDaynhcfdl()
									+ (list.get(i).getDaynhcfdl() == null ? 0.0 : list.get(i).getDaynhcfdl()));
							wdp3.setTotal(
									wdp3.getTotal() + (list.get(i).getTotal() == null ? 0.0 : list.get(i).getTotal()));

							map.put(list.get(i).getProjectid(), wdp3);
							map.put(list.get(i).getProjectid() + "count", count + 1);
						} else {
							Windpowerinfoday3 wdp3 = new Windpowerinfoday3();
							wdp3.setDaydl2(list.get(i).getDaydl2() == null ? 0.0 : list.get(i).getDaydl2());
							wdp3.setDaynhdl(list.get(i).getDaynhdl() == null ? 0.0 : list.get(i).getDaynhdl());
							wdp3.setDaynhgzssdl(list.get(i).getDaynhgzssdl() == null ? 0.0 : list.get(i).getDaynhgzssdl());
							wdp3.setDaynhwhssdl(list.get(i).getDaynhwhssdl() == null ? 0.0 : list.get(i).getDaynhwhssdl());
							wdp3.setDaynhxdssdl(list.get(i).getDaynhxdssdl() == null ? 0.0 : list.get(i).getDaynhxdssdl());
							wdp3.setDaynhqfdl(list.get(i).getDaynhqfdl() == null ? 0.0 : list.get(i).getDaynhqfdl());
							wdp3.setDayspeed(list.get(i).getDayspeed() == null ? 0.0 : list.get(i).getDayspeed());
							wdp3.setDaynhcfdl(list.get(i).getDaynhcfdl() == null ? 0.0 : list.get(i).getDaynhcfdl());
							wdp3.setTotal(list.get(i).getTotal() == null ? 0.0 : list.get(i).getTotal());
							map.put(list.get(i).getProjectid(), wdp3);
							map.put(list.get(i).getProjectid() + "count", 1);
						}

						break;

					case 2:
						if (map.containsKey(list.get(i).getLineid())) {

							Windpowerinfoday3 wdp3 = (Windpowerinfoday3) map.get(list.get(i).getLineid());
							wdp3.setDaydl2(
									wdp3.getDaydl2() + (list.get(i).getDaydl2() == null ? 0.0 : list.get(i).getDaydl2()));
							wdp3.setDaynhdl(wdp3.getDaynhdl()
									+ (list.get(i).getDaynhdl() == null ? 0.0 : list.get(i).getDaynhdl()));
							wdp3.setDaynhgzssdl(wdp3.getDaynhgzssdl()
									+ (list.get(i).getDaynhgzssdl() == null ? 0.0 : list.get(i).getDaynhgzssdl()));
							wdp3.setDaynhwhssdl(wdp3.getDaynhwhssdl()
									+ (list.get(i).getDaynhwhssdl() == null ? 0.0 : list.get(i).getDaynhwhssdl()));
							wdp3.setDaynhxdssdl(wdp3.getDaynhxdssdl()
									+ (list.get(i).getDaynhxdssdl() == null ? 0.0 : list.get(i).getDaynhxdssdl()));
							wdp3.setDaynhqfdl(wdp3.getDaynhqfdl()
									+ (list.get(i).getDaynhqfdl() == null ? 0.0 : list.get(i).getDaynhqfdl()));
							int count = (Integer) map.get(list.get(i).getLineid() + "count");
							// wdp3.setDayspeed(((wdp3.getDayspeed()*(count-1)+(list.get(i).getDayspeed()==null?0.0:list.get(i).getDayspeed())))/count);

							wdp3.setDayspeed((wdp3.getDayspeed()
									+ (list.get(i).getDayspeed() == null ? 0.0 : list.get(i).getDayspeed())));
							wdp3.setDaynhcfdl(wdp3.getDaynhcfdl()
									+ (list.get(i).getDaynhcfdl() == null ? 0.0 : list.get(i).getDaynhcfdl()));
							wdp3.setTotal(
									wdp3.getTotal() + (list.get(i).getTotal() == null ? 0.0 : list.get(i).getTotal()));

							map.put(list.get(i).getLineid(), wdp3);
							map.put(list.get(i).getLineid() + "count", count + 1);
						} else {
							Windpowerinfoday3 wdp3 = new Windpowerinfoday3();
							wdp3.setDaydl2(list.get(i).getDaydl2() == null ? 0.0 : list.get(i).getDaydl2());
							wdp3.setDaynhdl(list.get(i).getDaynhdl() == null ? 0.0 : list.get(i).getDaynhdl());
							wdp3.setDaynhgzssdl(list.get(i).getDaynhgzssdl() == null ? 0.0 : list.get(i).getDaynhgzssdl());
							wdp3.setDaynhwhssdl(list.get(i).getDaynhwhssdl() == null ? 0.0 : list.get(i).getDaynhwhssdl());
							wdp3.setDaynhxdssdl(list.get(i).getDaynhxdssdl() == null ? 0.0 : list.get(i).getDaynhxdssdl());
							wdp3.setDaynhqfdl(list.get(i).getDaynhqfdl() == null ? 0.0 : list.get(i).getDaynhqfdl());
							wdp3.setDayspeed(list.get(i).getDayspeed() == null ? 0.0 : list.get(i).getDayspeed());
							wdp3.setDaynhcfdl(list.get(i).getDaynhcfdl() == null ? 0.0 : list.get(i).getDaynhcfdl());
							wdp3.setTotal(list.get(i).getTotal() == null ? 0.0 : list.get(i).getTotal());
							map.put(list.get(i).getLineid(), wdp3);
							map.put(list.get(i).getLineid() + "count", 1);
						}
						break;

					default:
						break;
				}

			}
			double fdl = 0.0;
			double gzss = 0.0;
			double whss = 0.0;
			double xnss = 0.0;
			double xdss = 0.0;
			double slss = 0.0;
			double llfdl = 0.0;
			double lylT = 0.0;
			double dayspeed = 0.0;
			double count = 0;
			if (0 == type) {
				List<Windpowerstation> pwls = InitialRunner.wpls;
				for (int i = 0; i < pwls.size(); i++) {
					if (pwls.get(i).getId().endsWith("FDC")) {
						Windpowerinfoday3 wpd = (Windpowerinfoday3) map.get(pwls.get(i).getCode());
						double lyl = 0.0;
						if (wpd.getTotal() != 0) {
							lyl = StringUtils.round(wpd.getDaydl2() / wpd.getTotal() * 100, 2);
						}
						wpd.setWtId(pwls.get(i).getCode());
						wpd.setLyl(lyl);
						wpd.setWtName(pwls.get(i).getName());
						int countSpeed = (Integer) map.get(pwls.get(i).getCode() + "count");
						wpd.setDayspeed(StringUtils.round(wpd.getDayspeed() / countSpeed, 2));
						vos.add(wpd);
						fdl += wpd.getDaydl2();
						gzss += wpd.getDaynhgzssdl();
						whss += wpd.getDaynhwhssdl();
						xnss += wpd.getDaynhqfdl();
						xdss += wpd.getDaynhxdssdl();
						slss += wpd.getDaynhcfdl();
						dayspeed += wpd.getDayspeed();
						count++;
					}

				}
			} else if (1 == type) {
				List<Project> pwls = InitialRunner.pjls;
				for (int i = 0; i < pwls.size(); i++) {
					if (pwls.get(i).getWindpowerstationid().endsWith("FDC")) {
						Windpowerinfoday3 wpd = (Windpowerinfoday3) map.get(pwls.get(i).getCode());
						double lyl = 0.0;
						if (wpd.getTotal() != 0) {
							lyl = StringUtils.round(wpd.getDaydl2() / wpd.getTotal() * 100, 2);
						}
						wpd.setWtId(pwls.get(i).getCode());
						wpd.setLyl(lyl);
						wpd.setWtName(pwls.get(i).getName());
						int countSpeed = (Integer) map.get(pwls.get(i).getCode() + "count");
						wpd.setDayspeed(StringUtils.round(wpd.getDayspeed() / countSpeed, 2));
						vos.add(wpd);

						fdl += wpd.getDaydl2();
						gzss += wpd.getDaynhgzssdl();
						whss += wpd.getDaynhwhssdl();
						xnss += wpd.getDaynhqfdl();
						xdss += wpd.getDaynhxdssdl();
						slss += wpd.getDaynhcfdl();
						dayspeed += wpd.getDayspeed();
						count++;
					}

				}
			} else if (2 == type) {
				List<Line> pwls = InitialRunner.linels;
				Map<String, Project> pjmap = InitialRunner.pjmap;
				for (int i = 0; i < pwls.size(); i++) {
					if (pjmap.containsKey(pwls.get(i).getProjectid()) && pjmap.get(pwls.get(i).getProjectid()).getWindpowerstationid().endsWith("FDC")) {
						Windpowerinfoday3 wpd = (Windpowerinfoday3) map.get(pwls.get(i).getCode());
						double lyl = 0.0;
						if (wpd.getTotal() != 0) {
							lyl = StringUtils.round(wpd.getDaydl2() / wpd.getTotal() * 100, 2);
						}
						wpd.setWtId(pwls.get(i).getCode());
						wpd.setLyl(lyl);
						wpd.setWtName(pwls.get(i).getName());
						int countSpeed = (Integer) map.get(pwls.get(i).getCode() + "count");
						wpd.setDayspeed(StringUtils.round(wpd.getDayspeed() / countSpeed, 2));
						vos.add(wpd);

						fdl += wpd.getDaydl2();
						gzss += wpd.getDaynhgzssdl();
						whss += wpd.getDaynhwhssdl();
						xnss += wpd.getDaynhqfdl();
						xdss += wpd.getDaynhxdssdl();
						slss += wpd.getDaynhcfdl();
						dayspeed += wpd.getDayspeed();
						count++;
					}

				}
			}
			if (StringUtils.notEmp(sortName)) {
				getSortData(sortName, sortOrder, vos);
			}

			llfdl = fdl + whss + gzss + xnss + xdss + slss;
			if (llfdl != 0) {
				lylT = StringUtils.round(fdl / llfdl * 100, 2);
			}

			Windpowerinfoday3 wpd = new Windpowerinfoday3();
			wpd.setWtName("合计");
			wpd.setDaydl2(StringUtils.round(fdl, 4));
			wpd.setDaynhgzssdl(StringUtils.round(gzss, 4));
			wpd.setDaynhwhssdl(StringUtils.round(whss, 4));
			wpd.setDaynhcfdl(StringUtils.round(slss, 4));
			wpd.setDaynhxdssdl(StringUtils.round(xdss, 4));
			wpd.setDaynhqfdl(StringUtils.round(xnss, 4));
			wpd.setTotal(StringUtils.round(llfdl, 4));
			wpd.setLyl(lylT > 100 ? 100.00 : lylT);
			wpd.setDayspeed(StringUtils.round(dayspeed / count, 2));
			vos.add(wpd);
		}
		return vos;

	}


	private void getSortData(String sortName, String sortOrder, List<Windpowerinfoday3> vos) {
		if (StringUtils.notEmp(sortName) && sortName.equals("daydl2")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
					// 升序排序
					public int compare(Windpowerinfoday3 o1, Windpowerinfoday3 o2) {
						return o2.getDaydl2().compareTo(o1.getDaydl2());
					}

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("daynhgzssdl")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
					// 升序排序
					public int compare(Windpowerinfoday3 o1, Windpowerinfoday3 o2) {
						return o2.getDaynhgzssdl().compareTo(o1.getDaynhgzssdl());
					}

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("daynhwhssdl")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {

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

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("dayspeed")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
					// 升序排序
					public int compare(Windpowerinfoday3 o1, Windpowerinfoday3 o2) {
						return o2.getDayspeed().compareTo(o1.getDayspeed());
					}

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("daynhxdssdl")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
					// 升序排序
					public int compare(Windpowerinfoday3 o1, Windpowerinfoday3 o2) {
						return o2.getDaynhxdssdl().compareTo(o1.getDaynhxdssdl());
					}

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("daynhqfdl")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
					// 升序排序
					public int compare(Windpowerinfoday3 o1, Windpowerinfoday3 o2) {
						return o2.getDaynhqfdl().compareTo(o1.getDaynhqfdl());
					}

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("total")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
//				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
//					public int compare(Windpowerinfoday3 arg0, Windpowerinfoday3 arg1) {
//						int result = 0;
//						if (arg0.getTotal() < arg1.getTotal())
//							result = 1;
//						else
//							result = 0;
//						return result;
//					}
//				});

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

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("lyl")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
					// 升序排序
					public int compare(Windpowerinfoday3 o1, Windpowerinfoday3 o2) {
						return o2.getLyl().compareTo(o1.getLyl());
					}

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("wtName")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
					// 升序排序
					public int compare(Windpowerinfoday3 o1, Windpowerinfoday3 o2) {
						return o2.getWtName().compareTo(o1.getWtName());
					}

				});
			}

		} else if (StringUtils.notEmp(sortName) && sortName.equals("dayspeed")) {

			if (sortOrder.equals("asc")) {

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

				});
			} else if (sortOrder.equals("desc")) {
				Collections.sort(vos, new Comparator<Windpowerinfoday3>() {
					// 升序排序
					public int compare(Windpowerinfoday3 o1, Windpowerinfoday3 o2) {
						return o2.getDayspeed().compareTo(o1.getDayspeed());
					}

				});


			}

		}
	}


	public List<Windpowerinfoday3> getWindpowerinfoday3(List<String> ids, Date beginDate, Date endDate,String location) {


		List<Windpowerinfoday3> list=new ArrayList<>();

		Windpowerinfoday3Example example=new Windpowerinfoday3Example();
		example.setOrderByClause("windpowerstationid ASC");

		Windpowerinfoday3Example.Criteria criteria =example.createCriteria();

		if(StringUtils.isNotEmpty(ids) && !ids.isEmpty())
		{
			criteria.andForeignkeyidIn(ids);
		}

		if(beginDate!=null && endDate!=null ){
			criteria.andRecorddateGreaterThanOrEqualTo(beginDate).andRecorddateLessThan(endDate);
		}
		if(StringUtils.isNotEmpty(location))
		{
			criteria.andLocationEqualTo(location);


		}

		criteria.andWindpowerstationidLike("%FDC");

		list= windpowerinfoday3Mapper.selectByExample(example);
		return list;

	}


	public List<Windpowerinfoday3> getWindpowerinfoday3(String wpid, Date beginDate, Date endDate,String location) {


		List<Windpowerinfoday3> list=new ArrayList<>();

		Windpowerinfoday3Example example=new Windpowerinfoday3Example();
		example.setOrderByClause("windpowerstationid ASC");

		Windpowerinfoday3Example.Criteria criteria =example.createCriteria();

		if(StringUtils.isNotEmpty(wpid))
		{
			criteria.andForeignkeyidEqualTo(wpid);
		}

		if(beginDate!=null && endDate!=null ){
			criteria.andRecorddateGreaterThanOrEqualTo(beginDate).andRecorddateLessThan(endDate);
		}
		if(StringUtils.isNotEmpty(location))
		{
			criteria.andLocationEqualTo(location);
		}

		criteria.andWindpowerstationidLike("%FDC");



		list= windpowerinfoday3Mapper.selectByExample(example);
		return list;

	}
}
