package com.xintong.visualinspection.service.impl;

import java.util.HashMap;
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.CheckAppeal;
import com.xintong.visualinspection.dao.master.CheckAppealDao;
import com.xintong.visualinspection.service.BaseService;
import com.xintong.visualinspection.service.CheckAppealService;
import com.xintong.visualinspection.service.UserService;
import com.xintong.visualinspection.util.CacheUtil;

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

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


    @Autowired
    private CheckAppealDao checkAppealDao;
    @Autowired
    private UserService userService;

	@Override
	public List<CheckAppeal> getList(CheckAppeal param) {
		List<CheckAppeal> list = checkAppealDao.getList(param);
		return getList(list) ;
	}
	public List<CheckAppeal> getList(List<CheckAppeal> checkAppeallist){
		for (CheckAppeal checkAppeal : checkAppeallist) {
			if(checkAppeal.getAppeal_man()==null||CacheUtil.userMap.get(checkAppeal.getAppeal_man().longValue())==null){
				checkAppeal.setAppeal_man_name("-");
			}else{
				checkAppeal.setAppeal_man_name(CacheUtil.userMap.get(checkAppeal.getAppeal_man().longValue()).getTruename());
			}
			if(checkAppeal.getVerify_person() == null || CacheUtil.userMap.get(checkAppeal.getVerify_person().longValue())==null){
				checkAppeal.setVerify_person_name("-");
			}else{
				checkAppeal.setVerify_person_name(CacheUtil.userMap.get(checkAppeal.getVerify_person().longValue()).getTruename());
			}
			if(checkAppeal.getAppeal_dept()==null || CacheUtil.deptMap.get(checkAppeal.getAppeal_dept().longValue())==null){
				checkAppeal.setAppeal_dept_name("-");
			}else{
				checkAppeal.setAppeal_dept_name(CacheUtil.deptMap.get(checkAppeal.getAppeal_dept().longValue()).getOrganname());
			}
		}
		return checkAppeallist;
	}

	@Override
	public CheckAppeal getById(Long id) {
		return checkAppealDao.getOne(id);
	}


	@Override
	public void insert(CheckAppeal checkAppeal) {
		checkAppealDao.insert(checkAppeal);
	}


	@Override
	public void update(CheckAppeal checkAppeal) {
		checkAppealDao.update(checkAppeal);
	}


	@Override
	public void delete(Long id) {
		checkAppealDao.delete(id);
	}


}
