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.WindpowerstationthewindinfoMapper;
import com.gyee.frame.model.auto.Windpowerstationthewindinfo;
import com.gyee.frame.model.auto.WindpowerstationthewindinfoExample;
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 WindpowerstationthewindinfoService implements BaseService<Windpowerstationthewindinfo, WindpowerstationthewindinfoExample> {
	@Autowired
	private WindpowerstationthewindinfoMapper windpowerstationthewindinfoMapper;
	

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<Integer> lista=Convert.toIntArrayList(ids);
			WindpowerstationthewindinfoExample example=new WindpowerstationthewindinfoExample();
			example.createCriteria().andIdIn(lista);
			return windpowerstationthewindinfoMapper.deleteByExample(example);
			
				
	}
	

	@Override
	public Windpowerstationthewindinfo selectByPrimaryKey(String id) {

			return windpowerstationthewindinfoMapper.selectByPrimaryKey(Integer.valueOf(id));

	}


	@Override
	public int updateByPrimaryKeySelective(Windpowerstationthewindinfo record) {
		return windpowerstationthewindinfoMapper.updateByPrimaryKeySelective(record);
	}

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

				
		return windpowerstationthewindinfoMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(Windpowerstationthewindinfo record, WindpowerstationthewindinfoExample example) {
		
		return windpowerstationthewindinfoMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(Windpowerstationthewindinfo record, WindpowerstationthewindinfoExample example) {
		
		return windpowerstationthewindinfoMapper.updateByExample(record, example);
	}

	@Override
	public List<Windpowerstationthewindinfo> selectByExample(WindpowerstationthewindinfoExample example) {
		
		return windpowerstationthewindinfoMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindpowerstationthewindinfoExample example) {
		
		return windpowerstationthewindinfoMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WindpowerstationthewindinfoExample example) {
		
		return windpowerstationthewindinfoMapper.deleteByExample(example);
	}

	public List<Windpowerstationthewindinfo> getWindpowerstationthewindinfo(String wpId,Date recorddate) {


		List<Windpowerstationthewindinfo> list = null;

		if (StringUtils.notEmp(wpId) && StringUtils.notEmp(recorddate)) {

			WindpowerstationthewindinfoExample example = new WindpowerstationthewindinfoExample();
			example.setOrderByClause("windpowerstationid asc");

			if (StringUtils.notEmp(wpId) && StringUtils.notEmp(recorddate)) {

				WindpowerstationthewindinfoExample.Criteria criteria =example.createCriteria();
				criteria.andWindpowerstationidEqualTo(wpId);


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

				list = windpowerstationthewindinfoMapper.selectByExample(example);
			} else {
				list = new ArrayList<>();
			}

		}
		return list;

	}

}
