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.WeatherfhMapper;
import com.gyee.frame.model.auto.Weatherfh;
import com.gyee.frame.model.auto.WeatherfhExample;
import com.gyee.frame.util.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


@Service
public class WeatherfhService implements BaseService<Weatherfh, WeatherfhExample> {
	@Resource
	private WeatherfhMapper weatherfhMapper;
	

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

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

			
				
		return weatherfhMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(Weatherfh record, WeatherfhExample example) {
		
		return weatherfhMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(Weatherfh record, WeatherfhExample example) {
		
		return weatherfhMapper.updateByExample(record, example);
	}

	@Override
	public List<Weatherfh> selectByExample(WeatherfhExample example) {
		
		return weatherfhMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WeatherfhExample example) {
		
		return weatherfhMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WeatherfhExample example) {
		
		return weatherfhMapper.deleteByExample(example);
	}


	public List<Weatherfh> findWeatherfh(Date beginDate,Date endDate,String wpId) {

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

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

			WeatherfhExample example=new WeatherfhExample();
			example.setOrderByClause("recodedata DESC");

			WeatherfhExample.Criteria criteria =example.createCriteria();

			criteria.andRecodedataGreaterThanOrEqualTo(beginDate).andRecodedataLessThan(endDate);

			criteria.andWindpowerstationidEqualTo(wpId);
			criteria.andWindpowerstationidLike("%FDC");
			list= weatherfhMapper.selectByExample(example);

		}
		return list;

	}

}
