package cn.im.trafficalarm.service;

 import cn.im.trafficalarm.dao.TrafficaccidentinfoDao;
import cn.im.trafficalarm.model.TrafficaccidentinfoBean;

import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
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("trafficaccidentinfoService")
public class TrafficaccidentinfoService extends BaseService {
	
	private static Log log = LogFactory.getLog(TrafficaccidentinfoService.class);
	
	@Autowired
	private TrafficaccidentinfoDao trafficaccidentinfoDao;
	
	/**
	 * 保存记录
	 */
	
	
	public void insert_Trafficaccidentinfo(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		trafficaccidentinfoDao.insert_Trafficaccidentinfo(map);
	}
	/*
	*/

	
	public void jkdClick(TrafficaccidentinfoBean tb) throws SQLException{
		trafficaccidentinfoDao.jkdClick(tb);
	}
	/**
	 * 修改记录
	 */
	public Integer update_Trafficaccidentinfo(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		return trafficaccidentinfoDao.update_Trafficaccidentinfo(map);
	}
	public Integer updateTrafficaccidentinfo_planEnd(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		return trafficaccidentinfoDao.updateTrafficaccidentinfo_planEnd(map);
	}
	
	/**
	 * 批量更新首页中pushlet后的数据的事件状态
	 */
	public Integer batch_update_TrafficHomePageinfo(String accidentId,String accidentState) throws SQLException{
		return trafficaccidentinfoDao.batch_update_TrafficHomePageinfo(accidentId,accidentState);
	}
	
	
	/**
	 * 删除记录
	 */
	 
	/*
	
	public Integer delete_Trafficaccidentinfo(Map map) throws SQLException{
		CommUtils.validateDeleteParams(map);
		return trafficaccidentinfoDao.delete_Trafficaccidentinfo(map);
	}
	
	*/
	
	/**
	 * 批处理删除记录
	 */
	 
	
	
	public Integer batch_delete_Trafficaccidentinfo(Map map) throws SQLException{
		return trafficaccidentinfoDao.batch_delete_Trafficaccidentinfo(map);
	}

	
	
	/**
	 * 查询总数
	 */
	 
	/*
	
	public Integer count_Trafficaccidentinfo(Map map) throws SQLException{
		return trafficaccidentinfoDao.count_Trafficaccidentinfo(map);
	}
	
	*/
	
	/**
	 * 查询列表记录SELECT
	 */
	public List<Map> query_Trafficaccidentinfo(Map map) throws SQLException{
		return trafficaccidentinfoDao.query_Trafficaccidentinfo(map);
	}
	
	/**
	 * 首页搜索功能
	 */
	public Map query_TrafficHomePagetinfo(Map map) throws SQLException{
		//return trafficaccidentinfoDao.query_TrafficHomePagetinfo(map);
		String pages = (String)map.get("pages");
		List<Map> list = trafficaccidentinfoDao.query_TrafficHomePagetinfo(map);
		Integer totalCount = trafficaccidentinfoDao.count_TrafficHomePagetinfo(map);
		//Integer totalCount = trafficaccidentinfoDao.count_Trafficaccidentinfo(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		map.put("page", pages);
		return map;
		
	}
	
	/**
	 * 首页工作台中处理中和未处理数据量
	 */
	public Map query_TrafficHomePagetCount(Map map) throws SQLException{
		List<Map> list = trafficaccidentinfoDao.query_TrafficHomePageCount(map);
		map.clear();
		map.put("rows", list);
		return map;
		
	}
	
	/**
	 * 查询一条
	 */
	 
	/*
	
	public Map get_Trafficaccidentinfo(Map map) throws SQLException{
		return trafficaccidentinfoDao.get_Trafficaccidentinfo(map);
	}
	
	*/
	
	/**
	 * 导出EXCEL
	 */
	 
	/*
	
	public Map exportTrafficaccidentinfo(Map map) throws SQLException{
		return this.listTrafficaccidentinfoByPage(map);
	}
	
	*/
	
	/**
	 * Trafficaccidentinfo 分页
	 */
	public Map listTrafficaccidentinfoByPage(Map map) throws SQLException {
		List<Map> list = trafficaccidentinfoDao.query_Trafficaccidentinfo(map);
		Integer totalCount = trafficaccidentinfoDao.count_Trafficaccidentinfo(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	
	
	// 查询设备信息 id + 名称   
	public List<Map> get_Cameras(Map map) throws SQLException {
		List<Map> list = trafficaccidentinfoDao.get_Cameras(map);
		Map obj = new HashMap();
		obj.put("xh", "");
		obj.put("tdmc", "请选择");		
		list.add(0,obj);
		return list;
	}
	
	//查询预案
	public Map get_bjya(Map map) throws SQLException{
		return trafficaccidentinfoDao.get_bjya(map);	
	}
	
	/**
	 * 大屏加载摄像机信息
	 */
	public List<Map> query_listBigscreenInitCamere(Map map) throws SQLException{
		return trafficaccidentinfoDao.query_listBigscreenInitCamere(map);
	}
	
	/**
	 * 大屏加载隧道信息
	 */
	public List<Map> query_listBigscreenInitTunnel(Map map) throws SQLException{
		return trafficaccidentinfoDao.query_listBigscreenInitTunnel(map);
	}
	
	/**
	 * 大屏加载情报板信息
	 */
	public List<Map> query_listBigscreenInitLedBoard(Map map) throws SQLException{
		return trafficaccidentinfoDao.query_listBigscreenInitLedBoard(map);
	}
	
	/**
	 * 大屏加载诱导灯信息
	 */
	public List<Map> query_listBigscreenInitTrafficLight(Map map) throws SQLException{
		return trafficaccidentinfoDao.query_listBigscreenInitTrafficLight(map);
	}
	
	/**
	 * 大屏加载交通事件信息信息
	 */
	public List<Map> query_listBigscreenInitAlarm(Map map) throws SQLException{
		return trafficaccidentinfoDao.query_listBigscreenInitAlarm(map);
	}
	
	/**
	 * Trafficaccidentinfo 分页
	 */
	public Map get_Trafficaccidentinfo(Map map) throws SQLException {
		return trafficaccidentinfoDao.get_Trafficaccidentinfo(map);
	}
}
