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.WindturbinethewindinfoMapper;
import com.gyee.frame.model.auto.Windturbinethewindinfo;
import com.gyee.frame.model.auto.WindturbinethewindinfoExample;
import com.gyee.frame.model.custom.SingleAnalysisVo;
import com.gyee.frame.util.DateUtils;
import com.gyee.frame.util.StringUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

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


@Service
public class WindturbinethewindinfoService implements BaseService<Windturbinethewindinfo, WindturbinethewindinfoExample> {
	@Resource
	private WindturbinethewindinfoMapper windturbinethewindinfoMapper;
	

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

	
	@Override
	public int updateByPrimaryKeySelective(Windturbinethewindinfo record) {
		return windturbinethewindinfoMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(Windturbinethewindinfo record) {
				

			
				
		return windturbinethewindinfoMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(Windturbinethewindinfo record, WindturbinethewindinfoExample example) {
		
		return windturbinethewindinfoMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(Windturbinethewindinfo record, WindturbinethewindinfoExample example) {
		
		return windturbinethewindinfoMapper.updateByExample(record, example);
	}

	@Override
	public List<Windturbinethewindinfo> selectByExample(WindturbinethewindinfoExample example) {
		
		return windturbinethewindinfoMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindturbinethewindinfoExample example) {
		
		return windturbinethewindinfoMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WindturbinethewindinfoExample example) {
		
		return windturbinethewindinfoMapper.deleteByExample(example);
	}

	public List<Windturbinethewindinfo> fzy(String windturbineid, Date date)  {


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

		WindturbinethewindinfoExample example=new WindturbinethewindinfoExample();
		example.setOrderByClause("windturbineid ASC");

		WindturbinethewindinfoExample.Criteria criteria =example.createCriteria();

		criteria.andWindturbineidEqualTo(windturbineid);

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

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

	}


	public List<Windturbinethewindinfo> getWindturbinethewindinfo(String wtId, Date beginDate, Date endDate) {


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

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

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

			WindturbinethewindinfoExample.Criteria criteria =example.createCriteria();


			if(StringUtils.notEmp(wtId))
			{
				criteria.andWindturbineidEqualTo(wtId);
			}

			criteria.andRecorddateGreaterThanOrEqualTo(beginDate).andRecorddateLessThan(endDate);
			list = windturbinethewindinfoMapper.selectByExample(example);


		}
		return list;

	}



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

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


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


			list = windturbinethewindinfoMapper.getWindturbinethewindinfoByWtId(wtId,beginDate,endDate);


		}
		return list;

	}

}
