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.WtMttrAndMtbfMonthMapper;
import com.gyee.frame.model.auto.WtMttrAndMtbfMonth;
import com.gyee.frame.model.auto.WtMttrAndMtbfMonthExample;
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;

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

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

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

	
	@Override
	public int updateByExample(WtMttrAndMtbfMonth record, WtMttrAndMtbfMonthExample example) {
		
		return wtMttrAndMtbfMonthMapper.updateByExample(record, example);
	}

	@Override
	public List<WtMttrAndMtbfMonth> selectByExample(WtMttrAndMtbfMonthExample example) {
		
		return wtMttrAndMtbfMonthMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(WtMttrAndMtbfMonthExample example) {
		
		return wtMttrAndMtbfMonthMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(WtMttrAndMtbfMonthExample example) {
		
		return wtMttrAndMtbfMonthMapper.deleteByExample(example);
	}


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

		WtMttrAndMtbfMonthExample example=new WtMttrAndMtbfMonthExample();
		example.setOrderByClause("wtid ASC");

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


			example.createCriteria().andWtidEqualTo(wtId).andYearEqualTo(year).andMonthEqualTo(month);
			list= wtMttrAndMtbfMonthMapper.selectByExample(example);
		}else
		{
			list=new ArrayList<>();
		}

		return list;
	}

}
