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.StopAnalysismainMapper;
import com.gyee.frame.model.auto.*;
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;


@Service
public class StopAnalysismainService implements BaseService<StopAnalysismain, StopAnalysismainExample> {
	@Resource
	private StopAnalysismainMapper stopAnalysismainMapper;

	@Resource
	private StopAnalysismainVoService stopAnalysismainVoService;
	@Override
	public int deleteByPrimaryKey(String ids) {
				
			List<String> lista=Convert.toListStrArray(ids);
			StopAnalysismainExample example=new StopAnalysismainExample();
			example.createCriteria().andIdIn(lista);
			return stopAnalysismainMapper.deleteByExample(example);
			
				
	}
	
	
	@Override
	public StopAnalysismain selectByPrimaryKey(String id) {
				
			return stopAnalysismainMapper.selectByPrimaryKey(id);
				
	}

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

	
	@Override
	public int updateByExample(StopAnalysismain record, StopAnalysismainExample example) {
		
		return stopAnalysismainMapper.updateByExample(record, example);
	}

	@Override
	public List<StopAnalysismain> selectByExample(StopAnalysismainExample example) {
		
		return stopAnalysismainMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(StopAnalysismainExample example) {
		
		return stopAnalysismainMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(StopAnalysismainExample example) {
		
		return stopAnalysismainMapper.deleteByExample(example);
	}

	public void saveStopAnalysismainList(String mainId,List<StopAnalysismainVo> vos) {

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

		//List<StopAnalysismainVo> vos=stopAnalysismainVoService.findStopAnalysismainVoList();

		if(!vos.isEmpty())
		{
			for(StopAnalysismainVo vo:vos)
			{
				StopAnalysismain po=new StopAnalysismain();

//				po.setId(vo.getId());
				po.setMainid(mainId);
				po.setModelid(vo.getModelid());
				po.setWtid(vo.getWtid());
				po.setJudegvulue(vo.getJudegvulue());

				insertSelective(po);
			}
		}

	}

	public List<StopAnalysismain> findStopAnalysismainList(String mainId) {

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

		if (StringUtils.notEmp(mainId) ) {

			StopAnalysismainExample example=new StopAnalysismainExample();
			example.setOrderByClause(" wtId ");

			StopAnalysismainExample.Criteria criteria =example.createCriteria();

			criteria.andMainidEqualTo(mainId);
			list= stopAnalysismainMapper.selectByExample(example);

		}
		return list;

	}
}
