package cn.im.operation;

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

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository("operationDao")
public class OperationDao extends SqlMapClientDaoSupport{
	
	@Autowired 
    private SqlMapClient sqlMapClient;  
      
	@PostConstruct          
    public void initSqlMapClient(){  
    	super.setSqlMapClient(sqlMapClient);      
    }
	
	
	// 查询异常的服务
	public List<Map> getAbnormalServers(Map obj) throws SQLException{
		return this.getSqlMapClientTemplate().queryForList("getAbnormalServers", obj);
	}
	
	// 查询异常的相机数
	public Integer getAbnormalCameraCount(Map obj) throws SQLException{
		return (Integer) this.getSqlMapClientTemplate().queryForObject("getAbnormalCameraCount", obj);
	}
	
	// 查询正常的服务
	public List<Map> getNormalServers(Map obj) throws SQLException{
		return this.getSqlMapClientTemplate().queryForList("getNormalServers", obj);
	}
	
	// 查询正常的相机数
	public Integer getNormalCameraCount(Map obj) throws SQLException{
		return (Integer) this.getSqlMapClientTemplate().queryForObject("getNormalCameraCount", obj);
	}
	
	// 查询异常的相机信息
	public List<Map> getAbnormalCamera(Map obj) throws SQLException{
		return this.getSqlMapClientTemplate().queryForList("getAbnormalCamera", obj);
	}
	
	// 查询正常的相机信息
	public List<Map> getNormalCamera(Map obj) throws SQLException{
		return this.getSqlMapClientTemplate().queryForList("getNormalCamera", obj);
	}

	// 根据 id 查询某一服务详细信息
	public Map getServerInfoById(Map obj) throws SQLException{
		return (Map) this.getSqlMapClientTemplate().queryForObject("getServerInfoById", obj);
	}
	
	// 根据 id 查询一条记录
	public Map getCaVideoSourceById(Map obj) throws SQLException{
		return (Map) this.getSqlMapClientTemplate().queryForObject("getCaVideoSourceById", obj);
	}

	// 查询视频 
	public List<Map> query_CaVideoSource(Map map) throws SQLException{
		return this.getSqlMapClientTemplate().queryForList("query_CaVideoSource", map);
	}
	// 查询视频 总数
	public Integer query_CaVideoSourceCount(Map map) throws SQLException{
		return (Integer) this.getSqlMapClientTemplate().queryForObject("query_CaVideoSourceCount", map);
	}
	
	// 查询 节点下服务状态
	public List<Map> getNodeServerStatus(Map obj) throws SQLException{
		return this.getSqlMapClientTemplate().queryForList("getNodeServerStatus", obj);
	}
	
	// 查询 节点下服务状态 总数
	public Integer getNodeServerStatusCount(Map obj) throws SQLException{
		return (Integer) this.getSqlMapClientTemplate().queryForObject("getNodeServerStatusCount", obj);
	}
	
}
