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.Inputoroutputspeedtotal2Mapper;
import com.gyee.frame.model.auto.Inputoroutputspeedtotal2;
import com.gyee.frame.model.auto.Inputoroutputspeedtotal2Example;
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 Inputoroutputspeedtotal2Service implements BaseService<Inputoroutputspeedtotal2, Inputoroutputspeedtotal2Example> {
	@Resource
	private Inputoroutputspeedtotal2Mapper inputoroutputspeedtotal2Mapper;
	

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

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

				
		return inputoroutputspeedtotal2Mapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(Inputoroutputspeedtotal2 record, Inputoroutputspeedtotal2Example example) {
		
		return inputoroutputspeedtotal2Mapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(Inputoroutputspeedtotal2 record, Inputoroutputspeedtotal2Example example) {
		
		return inputoroutputspeedtotal2Mapper.updateByExample(record, example);
	}

	@Override
	public List<Inputoroutputspeedtotal2> selectByExample(Inputoroutputspeedtotal2Example example) {
		
		return inputoroutputspeedtotal2Mapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(Inputoroutputspeedtotal2Example example) {
		
		return inputoroutputspeedtotal2Mapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(Inputoroutputspeedtotal2Example example) {
		
		return inputoroutputspeedtotal2Mapper.deleteByExample(example);
	}

	public List<Inputoroutputspeedtotal2> getInputoroutputspeedtotal2(String wtId,Date recorddate) {


		List<Inputoroutputspeedtotal2> list = null;

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

			Inputoroutputspeedtotal2Example example = new Inputoroutputspeedtotal2Example();
			example.setOrderByClause("windturbineid asc");

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

				Inputoroutputspeedtotal2Example.Criteria criteria =example.createCriteria();
				criteria.andWindturbineidEqualTo(wtId);
				Date endDate= DateUtils.addDays(recorddate,1);
				criteria.andRecorddateGreaterThanOrEqualTo(recorddate).andRecorddateLessThan(endDate);
				list = inputoroutputspeedtotal2Mapper.selectByExample(example);

			} else {
				list = new ArrayList<>();
			}

		}
		return list;

	}

}
