package com.gyee.frame.service;

import com.gyee.frame.common.base.BaseService;
import com.gyee.frame.common.dataSources.DataSource;
import com.gyee.frame.common.dataSources.DataSourceType;
import com.gyee.frame.common.support.Convert;
import com.gyee.frame.mapper.auto.RecommenmainMsSqlMapper;
import com.gyee.frame.model.auto.RecommenmainMsSql;
import com.gyee.frame.model.auto.RecommenmainMsSqlExample;
import com.gyee.frame.model.custom.SimpleVo;
import com.gyee.frame.model.custom.WoBugEqVo;
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;

/**
 * 线路 RecommenmainMsSqlService
 * @Title: RecommenmainMsSqlService.java 
 * @Package com.gyee.frame.service 
 * @author gyee_自动生成
 * @email 1@qq.com
 * @date 2019-12-31 14:58:09  
 **/
@Service

public class RecommenmainMsSqlService implements BaseService<RecommenmainMsSql, RecommenmainMsSqlExample> {
	@Resource
	private RecommenmainMsSqlMapper recommenmainMsSqlMapper;
	


	@Override
	@DataSource(value = DataSourceType.TICKET)
	public int deleteByPrimaryKey(String ids) {
				
			List<Double> lista=Convert.toDoubleArrayList(ids);
			RecommenmainMsSqlExample example=new RecommenmainMsSqlExample();
			example.createCriteria().andIdIn(lista);
			return recommenmainMsSqlMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	@DataSource(value = DataSourceType.TICKET)
	public RecommenmainMsSql selectByPrimaryKey(String id) {
				
			return recommenmainMsSqlMapper.selectByPrimaryKey(id);
				
	}

	
	@Override
	@DataSource(value = DataSourceType.TICKET)
	public int updateByPrimaryKeySelective(RecommenmainMsSql record) {
		return recommenmainMsSqlMapper.updateByPrimaryKeySelective(record);
	}
	
	
	/**
	 * 添加
	 */
	@Override
	@DataSource(value = DataSourceType.TICKET)
	public int insertSelective(RecommenmainMsSql record) {


				
		return recommenmainMsSqlMapper.insertSelective(record);
	}
	
	
	@Override
	public int updateByExampleSelective(RecommenmainMsSql record, RecommenmainMsSqlExample example) {
		
		return recommenmainMsSqlMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(RecommenmainMsSql record, RecommenmainMsSqlExample example) {
		
		return recommenmainMsSqlMapper.updateByExample(record, example);
	}

	@Override
	public List<RecommenmainMsSql> selectByExample(RecommenmainMsSqlExample example) {
		
		return recommenmainMsSqlMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(RecommenmainMsSqlExample example) {
		
		return recommenmainMsSqlMapper.countByExample(example);
	}

	
	@Override
	@DataSource(value = DataSourceType.TICKET)
	public int deleteByExample(RecommenmainMsSqlExample example) {
		
		return recommenmainMsSqlMapper.deleteByExample(example);
	}

	@DataSource(value = DataSourceType.TICKET)
	public RecommenmainMsSql findRecommenmainById(String rId) {


		RecommenmainMsSql po=new RecommenmainMsSql();

		if (StringUtils.notEmp(rId) ) {

			RecommenmainMsSqlExample example=new RecommenmainMsSqlExample();
			example.setOrderByClause("recodedate asc");

			RecommenmainMsSqlExample.Criteria criteria =example.createCriteria();

			criteria.andRidEqualTo(rId);

			List<RecommenmainMsSql> list= recommenmainMsSqlMapper.selectByExample(example);
			if(!list.isEmpty())
			{
				po=list.get(0);
			}

		}
		return po;

	}
	@DataSource(value = DataSourceType.TICKET)
	public List<WoBugEqVo> unfinishedList(String wpId,String wtId, Date beginDate, Date endDate) {


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

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


			list= recommenmainMsSqlMapper.unfinishedList(wpId,wtId, beginDate, endDate);

		}
		return list;

	}
	@DataSource(value = DataSourceType.TICKET)
	public List<WoBugEqVo> finishedList(String wpId,String wtId, Date beginDate, Date endDate) {


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

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


			list= recommenmainMsSqlMapper.finishedList(wpId,wtId, beginDate, endDate);

		}
		return list;

	}

	@DataSource(value = DataSourceType.TICKET)
	public int totalList(String wpId,String wtId, Date beginDate, Date endDate) {

		int num=0;
		List<SimpleVo> list=new ArrayList<>();

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


			list= recommenmainMsSqlMapper.totalList(wpId,wtId, beginDate, endDate);

			if(!list.isEmpty())
			{
				num=list.get(0).getValue();
			}
		}
		return num;

	}

}
