package cn.im.trafficplan.service;

 import cn.im.trafficplan.dao.TrafficplanlinkagedeviceDao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.base.bean.BaseService;
import cn.base.util.CommUtils;

@Service("trafficplanlinkagedeviceService")
public class TrafficplanlinkagedeviceService extends BaseService {
	
	private static Log log = LogFactory.getLog(TrafficplanlinkagedeviceService.class);
	
	@Autowired
	private TrafficplanlinkagedeviceDao trafficplanlinkagedeviceDao;
	
	/**
	 * 保存记录
	 */
	public void insert_Trafficplanlinkagedevice(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		trafficplanlinkagedeviceDao.insert_Trafficplanlinkagedevice(map);
	}

	
	/**
	 * 修改记录
	 */
	public Integer update_Trafficplanlinkagedevice(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		return trafficplanlinkagedeviceDao.update_Trafficplanlinkagedevice(map);
	}
	
	/**
	 * 删除记录
	 */
	public Integer delete_Trafficplanlinkagedevice(Map map) throws SQLException{
		CommUtils.validateDeleteParams(map);
		return trafficplanlinkagedeviceDao.delete_Trafficplanlinkagedevice(map);
	}

	/**
	 * 根据planID删除记录
	 */
	public Integer delete_TrafficplanlinkagedeviceByPlanID(String str) throws SQLException{
		if(str==null || str ==""){
			throw new SQLException("删除条件无！");
		}
		return trafficplanlinkagedeviceDao.delete_TrafficplanlinkagedeviceByPlanID(str);
	}
	
	
	/**
	 * Trafficplanlinkagedevice 分页
	 */
	public Map listTrafficplanlinkagedeviceByPage(Map map) throws SQLException {
		List<Map> list = trafficplanlinkagedeviceDao.query_Trafficplanlinkagedevice(map);
		Integer totalCount = trafficplanlinkagedeviceDao.count_Trafficplanlinkagedevice(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	
	/**
	 * Trafficplanlinkagedevice 
	 */
	public List<Map>  query_Trafficplanlinkagedevice(Map map) throws SQLException {
		return trafficplanlinkagedeviceDao.query_Trafficplanlinkagedevice(map);
	}
	
	public List<Map>  getlinkageDeviceOrigin(Map map) throws SQLException {
		return trafficplanlinkagedeviceDao.getlinkageDeviceOrigin(map);
	}
	
}
