package com.gyee.frame.service;

import com.gyee.frame.common.base.BaseService;
import com.gyee.frame.common.support.Convert;
import com.gyee.frame.mapper.auto.WindTurbineInfoDay2Mapper;
import com.gyee.frame.model.auto.WindTurbineInfoDay2;
import com.gyee.frame.model.auto.WindTurbineInfoDay2Example;
import com.gyee.frame.model.custom.SingleAnalysisVo;
import com.gyee.frame.util.DateUtils;
import com.gyee.frame.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Service
public class WindTurbineInfoDay2Service implements BaseService<WindTurbineInfoDay2, WindTurbineInfoDay2Example> {
	@Autowired
	private WindTurbineInfoDay2Mapper windTurbineInfoDay2Mapper;
	

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<Integer> lista=Convert.toIntArrayList(ids);
			WindTurbineInfoDay2Example example=new WindTurbineInfoDay2Example();
			example.createCriteria().andIdIn(lista);
			return windTurbineInfoDay2Mapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public WindTurbineInfoDay2 selectByPrimaryKey(String id) {
				
			return windTurbineInfoDay2Mapper.selectByPrimaryKey(Integer.valueOf(id));
				
	}

	
	@Override
	public int updateByPrimaryKeySelective(WindTurbineInfoDay2 record) {
		return windTurbineInfoDay2Mapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(WindTurbineInfoDay2 record) {
				
//		//添加雪花主键id
//		record.setId(SnowflakeIdWorker.getUUID());
			
				
		return windTurbineInfoDay2Mapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(WindTurbineInfoDay2 record, WindTurbineInfoDay2Example example) {
		
		return windTurbineInfoDay2Mapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(WindTurbineInfoDay2 record, WindTurbineInfoDay2Example example) {
		
		return windTurbineInfoDay2Mapper.updateByExample(record, example);
	}

	@Override
	public List<WindTurbineInfoDay2> selectByExample(WindTurbineInfoDay2Example example) {
		
		return windTurbineInfoDay2Mapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindTurbineInfoDay2Example example) {
		
		return windTurbineInfoDay2Mapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WindTurbineInfoDay2Example example) {
		
		return windTurbineInfoDay2Mapper.deleteByExample(example);
	}

	public List<WindTurbineInfoDay2> getWindturbineinfo(String wtId, Date recorddate) {


		List<com.gyee.frame.model.auto.WindTurbineInfoDay2> list=null;

		if (StringUtils.notEmp(wtId) ) {

			WindTurbineInfoDay2Example example=new WindTurbineInfoDay2Example();
			example.setOrderByClause("recorddate DESC");

			if(StringUtils.notEmp(recorddate)){

				WindTurbineInfoDay2Example.Criteria criteria =example.createCriteria();

				Date endDate= DateUtils.addDays(recorddate,1);
				criteria.andRecorddateGreaterThanOrEqualTo(recorddate).andRecorddateLessThan(endDate);

				criteria.andWindturbineidEqualTo(wtId);
				list= windTurbineInfoDay2Mapper.selectByExample(example);
			}else
			{
				list=new ArrayList<>();
			}

		}
		return list;

	}


	public List<WindTurbineInfoDay2> getWindturbineinfoday2List(String wpId, Date beginDate, Date endDate) {


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

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

			WindTurbineInfoDay2Example example=new WindTurbineInfoDay2Example();
			example.setOrderByClause("recorddate asc");

			WindTurbineInfoDay2Example.Criteria criteria =example.createCriteria();

			criteria.andRecorddateGreaterThanOrEqualTo(beginDate).andRecorddateLessThan(endDate);

			criteria.andWindpowerstationidEqualTo(wpId);
			list= windTurbineInfoDay2Mapper.selectByExample(example);

		}
		return list;

	}

	public List<WindTurbineInfoDay2> getWindturbineinfoday2ListBywtId(String wtId, Date beginDate, Date endDate) {


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

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

			WindTurbineInfoDay2Example example=new WindTurbineInfoDay2Example();
			example.setOrderByClause("recorddate DESC");

			WindTurbineInfoDay2Example.Criteria criteria =example.createCriteria();

			criteria.andRecorddateGreaterThanOrEqualTo(beginDate).andRecorddateLessThan(endDate);

			criteria.andWindturbineidEqualTo(wtId);
			list= windTurbineInfoDay2Mapper.selectByExample(example);

		}
		return list;

	}


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

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


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


			list = windTurbineInfoDay2Mapper.getWindTurbineInfoDay2(wpId,beginDate,endDate);


		}
		return list;

	}


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

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


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


			list = windTurbineInfoDay2Mapper.getWindTurbineInfoDay2ByWtId(wtId,beginDate,endDate);


		}
		return list;

	}
}
