package cn.yw.machinemanage.service;

 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;
import cn.yw.machinemanage.dao.YwmachinecurrentstateDao;

@Service("ywmachinecurrentstateService")
public class YwmachinecurrentstateService extends BaseService {
	
	private static Log log = LogFactory.getLog(YwmachinecurrentstateService.class);
	
	@Autowired
	private YwmachinecurrentstateDao ywmachinecurrentstateDao;
	
	/**
	 * 保存记录
	 */
	/*
	public void insert_Ywmachinecurrentstate(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		ywmachinecurrentstateDao.insert_Ywmachinecurrentstate(map);
	}
	*/

	
	/**
	 * 修改记录
	 */
	public Integer update_Ywmachinecurrentstate(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		return ywmachinecurrentstateDao.update_Ywmachinecurrentstate(map);
	}
	
	
	/**
	 * 删除记录
	 */
	/*
	public Integer delete_Ywmachinecurrentstate(Map map) throws SQLException{
		CommUtils.validateDeleteParams(map);
		return ywmachinecurrentstateDao.delete_Ywmachinecurrentstate(map);
	}
	*/
	
	/**
	 * 批处理删除记录
	 */
	/*
	public Integer batch_delete_Ywmachinecurrentstate(Map map) throws SQLException{
		return ywmachinecurrentstateDao.batch_delete_Ywmachinecurrentstate(map);
	}
	*/
	
	/**
	 * 查询总数
	 */
	public Integer count_Ywmachinecurrentstate(Map map) throws SQLException{
		return ywmachinecurrentstateDao.count_Ywmachinecurrentstate(map);
	}
	
	/**
	 * 查询列表记录SELECT
	 */
	public List<Map> query_Ywmachinecurrentstate(Map map) throws SQLException{
		return ywmachinecurrentstateDao.query_Ywmachinecurrentstate(map);
	}
	
	/**
	 * 查询一条
	 */
	 
	
	public Map get_Ywmachinecurrentstate(Map map) throws SQLException{
		return ywmachinecurrentstateDao.get_Ywmachinecurrentstate(map);
	}
	/**
	 * 首页服务器统计
	 * @return
	 * @throws SQLException
	 */
	public Map statisticsMachineOnlineRate() throws SQLException{
		Map<String,Object> result = new HashMap<String,Object>();
		List<Map> list = ywmachinecurrentstateDao.statisticsMachineOnlineRate();
		if(list!=null && list.size()>0){
			for(Map m : list){
				String name = m.get("name")+"";
				result.put(name, m.get("totalcount"));
			}
		}
		return result;
	}
	public Map listStatisticsMachineIntactRate() throws SQLException{
		Map<String,Object> result = new HashMap<String,Object>();
		List<Map> list = ywmachinecurrentstateDao.listStatisticsMachineIntactRate();
		if(list!=null && list.size()>0){
			for(Map m : list){
				String name = m.get("name")+"";
				result.put(name, m.get("totalcount"));
			}
		}
		return result;
	}
	
	/**
	 * 导出EXCEL
	 */
	 
	/*
	public Map exportYwmachinecurrentstate(Map map) throws SQLException{
		return this.listYwmachinecurrentstateByPage(map);
	}
	*/
	
	/**
	 * Ywmachinecurrentstate 分页
	 */
	public Map listYwmachinecurrentstateByPage(Map map) throws SQLException {
		List<Map> list = ywmachinecurrentstateDao.query_Ywmachinecurrentstate(map);
		Integer totalCount = ywmachinecurrentstateDao.count_Ywmachinecurrentstate(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	public List<Map> listMachineInfo(Map map) throws SQLException {
		return ywmachinecurrentstateDao.listMachineInfo(map);
	}

	public Map listYwmachineUnonline(Map map) throws SQLException {
		List<Map> list = ywmachinecurrentstateDao.query_YwmachineUnonline(map);
		Integer totalCount = ywmachinecurrentstateDao.count_YwmachineUnonline(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}

	public Map listYwmachineonline(Map map) throws SQLException {
		List<Map> list = ywmachinecurrentstateDao.query_Ywmachineonline(map);
		Integer totalCount = ywmachinecurrentstateDao.count_Ywmachineonline(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
}
