package com.xintong.visualinspection.service.impl;

import java.util.Date;
import java.util.List;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xintong.visualinspection.bean.Score;
import com.xintong.visualinspection.dao.master.ScoreDao;
import com.xintong.visualinspection.service.BaseService;
import com.xintong.visualinspection.service.ScoreService;
import com.xintong.visualinspection.util.CacheUtil;

/**
 * 文件名：ScoreServiceImpl
 * 版本信息：日期：2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
 */
@Service
public class ScoreServiceImpl extends BaseService implements ScoreService {

    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ScoreServiceImpl.class);


    @Autowired
    private ScoreDao scoreDao;

	@Override
	public List<Score> getAll() {
		// TODO Auto-generated method stub
		return scoreDao.getAll();
	}

	@Override
	public Score getOne(Long id) {
		// TODO Auto-generated method stub
		return scoreDao.getOne(id);
	}

	@Override
	public List<Score> getScoreList(Score score) {
		// TODO Auto-generated method stub
		List<Score> scoreList = scoreDao.getScoreList(score);
		for(Score s:scoreList) {
			s.setChecked_person_name(CacheUtil.getUserTurenameFromMap(s.getChecked_person()));
		}
		return scoreList;
	}

	@Override
	public List<Score> getScoreListByTaskId(Long task_id) {
		// TODO Auto-generated method stub
		return scoreDao.getScoreListByTaskId(task_id);
	}

	@Override
	public void insert(Score score) {
		// TODO Auto-generated method stub
		score.setUpdate_time(new Date());
		scoreDao.insert(score);
	}

	@Override
	public void update(Score score) {
		// TODO Auto-generated method stub
		scoreDao.update(score);
	}

	@Override
	public void delete(Long id) {
		// TODO Auto-generated method stub
		scoreDao.delete(id);
	}
}
