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.WindpowerinfodayMapper;
import com.gyee.frame.model.auto.Windpowerinfoday;
import com.gyee.frame.model.auto.WindpowerinfodayExample;
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 WindpowerinfodayService implements BaseService<Windpowerinfoday, WindpowerinfodayExample> {
	@Autowired
	private WindpowerinfodayMapper windpowerinfodayMapper;
	

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

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

	
	@Override
	public int updateByExample(Windpowerinfoday record, WindpowerinfodayExample example) {
		
		return windpowerinfodayMapper.updateByExample(record, example);
	}

	@Override
	public List<Windpowerinfoday> selectByExample(WindpowerinfodayExample example) {
		
		return windpowerinfodayMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WindpowerinfodayExample example) {
		
		return windpowerinfodayMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WindpowerinfodayExample example) {
		
		return windpowerinfodayMapper.deleteByExample(example);
	}

	public List<Windpowerinfoday> getWindpowerinfodayList(String wpId, Date beginDate,Date endDate) {


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

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

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

			WindpowerinfodayExample.Criteria criteria =example.createCriteria();


			criteria.andLocationEqualTo("windpower");
			criteria.andRecorddateGreaterThanOrEqualTo(beginDate).andRecorddateLessThan(endDate);
			criteria.andWindpowerstationidEqualTo(wpId);

			list= windpowerinfodayMapper.selectByExample(example);

		}
		return list;

	}


}
