package com.xintong.visualinspection.visuallnspection_qzd.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xintong.visualinspection.bean.CheckApply_F;
import com.xintong.visualinspection.bean.Constant;
import com.xintong.visualinspection.service.CheckApplyService_F;
import com.xintong.visualinspection.service.CommonService;
import com.xintong.visualinspection.visuallnspection_qzd.dao.CheckApplyDao;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * 文件名：UserServiceImpl
 * 版本信息：日期：2017/3/30 Copyright 江苏省交通规划设计院 Corporation 2017 版权所有.
 */
@Service
@com.alibaba.dubbo.config.annotation.Service(
        version = "1.0.0",
        application = "${dubbo.application.id}",
        protocol = "${dubbo.protocol.id}",
        registry = "${dubbo.registry.id}"
)
public class CheckApplyServiceImpl  implements CheckApplyService_F {

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

    @Reference(version = "1.0.0",
            application = "${dubbo.application.id}",
            registry = "${dubbo.registry.address}")
    private CommonService commonService;
    @Autowired
    private CheckApplyDao checkApplyDao;

	@Override
	public List<CheckApply_F> getList(CheckApply_F param) {
		// TODO Auto-generated method stub
        Map<String,Constant> codeMap =commonService.getCodeMap();

        List<CheckApply_F> checkApply_fs = checkApplyDao.getList(param);
        if(checkApply_fs!=null && checkApply_fs.size()>0){
            for (CheckApply_F f:checkApply_fs
                 ) {
               Constant c =  (codeMap.get("task_status_"+f.getCheck_status()));
               if(c!=null){
                   f.setCode_name(c.getCode_name());
               }

            }
        }

		return checkApply_fs;
	}
	@Override
	public CheckApply_F getById(Long id) {
		// TODO Auto-generated method stub
		return checkApplyDao.getOne(id);
	}
	@Override
	public void insert(CheckApply_F checkApply) {
		// TODO Auto-generated method stub
		checkApplyDao.insert(checkApply);
	}
	@Override
	public void update(CheckApply_F checkApply) {
		// TODO Auto-generated method stub
		checkApplyDao.update(checkApply);
	}
	@Override
	public void delete(Long id) {
		// TODO Auto-generated method stub
		checkApplyDao.delete(id);
	}
	@Override
	public CheckApply_F getByTaskId(Long id) {
		// TODO Auto-generated method stub
		return checkApplyDao.getOneByTaskId(id);
	}
	@Override
	public List<CheckApply_F> getTopReasonList(Map<String, Object> param) {
		// TODO Auto-generated method stub
		return checkApplyDao.getTopReasonList(param);
	}
}
