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.WpMttrAndMtbMonthMapper;
import com.gyee.frame.model.auto.WpMttrAndMtbMonth;
import com.gyee.frame.model.auto.WpMttrAndMtbMonthExample;
import com.gyee.frame.util.SnowflakeIdWorker;
import com.gyee.frame.util.StringUtils;
import org.springframework.stereotype.Service;

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

/**
 * 线路 WpMttrAndMtbMonthService
 * @Title: WpMttrAndMtbMonthService.java 
 * @Package com.gyee.frame.service 
 * @author gyee_自动生成
 * @email 1@qq.com
 * @date 2019-12-31 14:58:09  
 **/
@Service
public class WpMttrAndMtbMonthService implements BaseService<WpMttrAndMtbMonth, WpMttrAndMtbMonthExample> {
	@Resource
	private WpMttrAndMtbMonthMapper wpMttrAndMtbMonthMapper;

	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=Convert.toListStrArray(ids);
			WpMttrAndMtbMonthExample example=new WpMttrAndMtbMonthExample();
			example.createCriteria().andIdIn(lista);
			return wpMttrAndMtbMonthMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public WpMttrAndMtbMonth selectByPrimaryKey(String id) {
				
			return wpMttrAndMtbMonthMapper.selectByPrimaryKey(id);
				
	}

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

	
	@Override
	public int updateByExample(WpMttrAndMtbMonth record, WpMttrAndMtbMonthExample example) {
		
		return wpMttrAndMtbMonthMapper.updateByExample(record, example);
	}

	@Override
	public List<WpMttrAndMtbMonth> selectByExample(WpMttrAndMtbMonthExample example) {
		
		return wpMttrAndMtbMonthMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WpMttrAndMtbMonthExample example) {
		
		return wpMttrAndMtbMonthMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WpMttrAndMtbMonthExample example) {
		
		return wpMttrAndMtbMonthMapper.deleteByExample(example);
	}


	public List<WpMttrAndMtbMonth> getMttrAndMtbf(String wpId, Integer year, Integer month)  {
		List<WpMttrAndMtbMonth> list=null;

		WpMttrAndMtbMonthExample example=new WpMttrAndMtbMonthExample();
		example.setOrderByClause("wpId ASC");

		if(StringUtils.notEmp(year) && StringUtils.notEmp(month) &&  StringUtils.notEmp(wpId)){


			example.createCriteria().andWpidEqualTo(wpId).andYearEqualTo(year).andMonthEqualTo(month);
			list= wpMttrAndMtbMonthMapper.selectByExample(example);
		}else
		{
			list=new ArrayList<>();
		}

		return list;
	}

}
