package cn.com.countrygarden.bi.main.service.performance.impl;

import cn.com.countrygarden.bi.main.dao.performance.PerformanceTargetMapper;
import cn.com.countrygarden.bi.main.model.performance.PerformanceTarget;
import cn.com.countrygarden.bi.main.service.performance.PerformanceTargetService;
import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Condition;

import java.util.List;
import java.util.Map;

/**
 * 目标值
 * 
 * @author leo 严明斌
 * @version 2018-4-3 16:58:33
 * 
 */
 
@Service
public class PerformanceTargetServiceImpl implements PerformanceTargetService {

	@Autowired
	private PerformanceTargetMapper performanceTargetMapper;
	@Override
	public List<PerformanceTarget> getNewTargetList(PerformanceTarget target) {
		return this.performanceTargetMapper.getNewTargetList(target);
	}
	@Override
	public List<PerformanceTarget> getTargetList(PerformanceTarget target) {
		return this.performanceTargetMapper.getTargetList(target);
	}

	@Override
	public List<PerformanceTarget> selectList(PerformanceTarget target) {
		return this.performanceTargetMapper.selectTargetList(target);
	}

	@Override
	public int insertTargetList(List<PerformanceTarget> targetList) {
		return this.performanceTargetMapper.insertTargetList(targetList);
	}

	@Override
	@Transactional
	public void updateTargetList(List<PerformanceTarget> targetList) {
		for(PerformanceTarget target : targetList){
			this.performanceTargetMapper.updateByPrimaryKeySelective(target);
		}
	}

	@Override
	public PerformanceTarget getTotalPage(PerformanceTarget target) {
		return  this.performanceTargetMapper.getTotalPage(target);
	}

	@Override
	public PerformanceTarget getNewByHierarchyId(PerformanceTarget target) {
		return  this.performanceTargetMapper.getByHierarchyId(target);
	}

	@Override
	public void save(PerformanceTarget model) {
		performanceTargetMapper.insertSelective(model);
	}

	@Override
	public void save(List<PerformanceTarget> models) {

	}

	@Override
	public void deleteById(Integer id) {

	}

	@Override
	public void deleteByIds(String ids) {

	}

	@Override
	public void update(PerformanceTarget model) {
		performanceTargetMapper.updateByPrimaryKeySelective(model);
	}

	@Override
	public PerformanceTarget findById(Integer id) {
		return null;
	}

	@Override
	public PerformanceTarget findBy(String fieldName, Object value) throws TooManyResultsException {
		return null;
	}

	@Override
	public List<PerformanceTarget> findByIds(String ids) {
		return null;
	}

	@Override
	public List<PerformanceTarget> findByCondition(Condition condition) {
		return null;
	}

	@Override
	public List<PerformanceTarget> findAll() {
		return null;
	}

	@Override
	public PerformanceTarget getByHierarchyId(PerformanceTarget target) {
		// TODO Auto-generated method stub		
		return this.performanceTargetMapper.getByHierarchyId(target);
	}

	@Override
	public void UpdateNewtarget(PerformanceTarget scores) {
		// TODO Auto-generated method stub
		performanceTargetMapper.UpdateNewtarget(scores);
	}

	@Override
	public void updateTargetByTargetId(PerformanceTarget target) {
		this.performanceTargetMapper.updateTargetByTargetId(target);
	}

	@Override
	public void insertTargetSelective(PerformanceTarget target) {
		this.performanceTargetMapper.insertTargetSelective(target);
	}

	@Override
	public void updateTargetSelective(PerformanceTarget target){
		this.performanceTargetMapper.updateTargetSelective(target);
	}

	/**
	 * 得到数据库记录中最新的年,季度
	 * @return Map<String, Object>
	 */
	@Override
	public Map<String, Object> getNewYearQuarter() {
		return performanceTargetMapper.getNewYearQuarter();
	}

	@Override
	public List<PerformanceTarget> getNewYearQuarterOrgan() {
		List<PerformanceTarget>list=performanceTargetMapper.getNewYearQuarterOrgan();
		return list;
	}

	@Override
	public Map<String, Object> getNewYearQuarterCompany() {
		return performanceTargetMapper.getNewYearQuarterCompany();
	}
}
