package cn.im.trafficplan.service;

 import cn.im.trafficplan.dao.TrafficplanmanageDao;

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("trafficplanmanageService")
public class TrafficplanmanageService extends BaseService {
	
	private static Log log = LogFactory.getLog(TrafficplanmanageService.class);
	
	@Autowired
	private TrafficplanmanageDao trafficplanmanageDao;
	
	public List<Map> getLinkageDeviceCommandfromHis(Map map) throws SQLException{
		return trafficplanmanageDao.getLinkageDeviceCommandfromHis(map);
	}
	public Map gethisStateLast(Map map) throws SQLException{
		return trafficplanmanageDao.gethisStateLast(map);
	}
	
	public List<Map> query_alarmDevice_Origin(Map map) throws SQLException{
		return trafficplanmanageDao.query_alarmDevice_Origin(map);
	}
	
	public List<Map> query_TrafficLedDevice() throws SQLException{
		return trafficplanmanageDao.query_TrafficLedDevice();
	}
	
	public List<Map> query_TrafficLightDevice() throws SQLException{
		return trafficplanmanageDao.query_TrafficLightDevice();
	}
	
	/*public List<Map> query_alarmDevice(Map map) throws SQLException{
		return trafficplanmanageDao.query_alarmDevice(map);
	}*/
	
	public List<Map> query_alarmDevice(Map map) throws SQLException{
		return trafficplanmanageDao.query_alarmDevice(map);
	}
	
	/**
	 * 保存记录
	 */
	public void insert_Trafficplanmanage(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		trafficplanmanageDao.insert_Trafficplanmanage(map);
	}

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

	/**
	 * 根据planID删除记录
	 */
	public Integer delete_TrafficplanmanageByplanID(String str) throws SQLException{
		if(str==null || str ==""){
			throw new SQLException("删除条件无！");
		}
		return trafficplanmanageDao.delete_TrafficplanmanageByplanID(str);
	}
	
	/**
	 * Trafficplanmanage 分页
	 */
	public Map listTrafficplanmanageByPage(Map map) throws SQLException {
		List<Map> list = trafficplanmanageDao.query_Trafficplanmanage(map);
		Integer totalCount = trafficplanmanageDao.count_Trafficplanmanage(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	

	/**
	 * Trafficplanmanage
	 */
	public List<Map> query_Trafficplanmanage_sjgl(Map map) throws SQLException {
		return trafficplanmanageDao.query_Trafficplanmanage_sjgl(map);
	}
	
	public Map query_Trafficplanmanage_choose(Map map) throws SQLException {
		List<Map> list = trafficplanmanageDao.query_Trafficplanmanage_choose(map);
		Integer totalCount = trafficplanmanageDao.count_Trafficplanmanage_choose(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
}
