package cn.nhyw.xxpzgl.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.nhyw.xxpzgl.dao.NhywxmglwdxxDao;
import cn.nhyw.xxpzgl.dao.NhywxmxxDao;

@Service("nhywxmxxService")
public class NhywxmxxService extends BaseService {
	
	private static Log log = LogFactory.getLog(NhywxmxxService.class);
	
	@Autowired
	private NhywxmxxDao nhywxmxxDao;

	@Autowired
	private NhywxmglwdxxDao nhywxmglwdxxDao;
	
	/**
	 * 保存记录
	 */
	public void insert_Nhywxmxx(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		nhywxmxxDao.insert_Nhywxmxx(map);
	}
	

	
	/**
	 * 修改记录
	 */
	public Integer update_Nhywxmxx(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		// 修改项目信息时修改文档信息中关联字段
		Map xmglwdxxMap = new HashMap();
		xmglwdxxMap.put("XGTJxmbh", map.get("XGTJxh"));
		xmglwdxxMap.put("xmmc", map.get("xmmc"));
		CommUtils.addParams(xmglwdxxMap, true);
		nhywxmglwdxxDao.update_Nhywxmglwdxx(xmglwdxxMap);
		return nhywxmxxDao.update_Nhywxmxx(map);
	}
	
	
	/**
	 * 删除记录
	 */
	public Integer delete_Nhywxmxx(Map map) throws SQLException{
		CommUtils.validateDeleteParams(map);
		Map xmglwdxxMap = new HashMap();
		xmglwdxxMap.put("xmbh", map.get("xh"));
		nhywxmglwdxxDao.delete_Nhywxmglwdxx(xmglwdxxMap);
		return nhywxmxxDao.delete_Nhywxmxx(map);
	}
	
	
	/**
	 * 批处理删除记录
	 */
	/*
	public Integer batch_delete_Nhywxmxx(Map map) throws SQLException{
		return nhywxmxxDao.batch_delete_Nhywxmxx(map);
	}
	*/
	
	/**
	 * 查询总数
	 */
	public Integer count_Nhywxmxx(Map map) throws SQLException{
		return nhywxmxxDao.count_Nhywxmxx(map);
	}
	
	
	/**
	 * 查询列表记录SELECT
	 */
	public List<Map> query_Nhywxmxx(Map map) throws SQLException{
		return nhywxmxxDao.query_Nhywxmxx(map);
	}
	
	
	/**
	 * 查询一条
	 */
	public Map get_Nhywxmxx(Map map) throws SQLException{
		return nhywxmxxDao.get_Nhywxmxx(map);
	}
	
	
	/**
	 * 导出EXCEL
	 */
	 
	/*
	public Map exportNhywxmxx(Map map) throws SQLException{
		return this.listNhywxmxxByPage(map);
	}
	*/
	
	/**
	 * Nhywxmxx 分页
	 */
	public Map listNhywxmxxByPage(Map map) throws SQLException {
		List<Map> list = nhywxmxxDao.query_Nhywxmxx(map);
		Integer totalCount = nhywxmxxDao.count_Nhywxmxx(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	
}
