package cn.yw.video.videotask.service;

 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;
import cn.yw.video.videotask.dao.YwvideotaskDao;

@Service("ywvideotaskService")
public class YwvideotaskService extends BaseService {

	private static Log log = LogFactory.getLog(YwvideotaskService.class);

	@Autowired
	private YwvideotaskDao ywvideotaskDao;

	/**
	 * 保存记录
	 */
	public void insert_Ywvideotask(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		ywvideotaskDao.insert_Ywvideotask(map);
	}


	/**
	 * 修改记录
	 */
	public Integer update_Ywvideotask(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		return ywvideotaskDao.update_Ywvideotask(map);
	}
	public Integer delete_channelset_Ywvideotask(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		return ywvideotaskDao.delete_channelset_Ywvideotask(map);
	}

	/**
	 * 删除记录
	 */
	public Integer delete_Ywvideotask(Map map) throws SQLException{
		CommUtils.validateDeleteParams(map);
		return ywvideotaskDao.delete_Ywvideotask(map);
	}

	/**
	 * 批处理删除记录
	 */
	public Integer batch_delete_Ywvideotask(List l) throws SQLException{
		return ywvideotaskDao.batch_delete_Ywvideotask(l);
	}
	public Integer batch_update_Ywvideotask(Map m) throws SQLException{
		return ywvideotaskDao.batch_update_Ywvideotask(m);
	}

	/**
	 * 查询总数
	 */
	public Integer count_Ywvideotask(Map map) throws SQLException{
		return ywvideotaskDao.count_Ywvideotask(map);
	}

	/**
	 * 查询列表记录SELECT
	 */
	public List<Map> query_Ywvideotask(Map map) throws SQLException{
		return ywvideotaskDao.query_Ywvideotask(map);
	}
	public List<Map> query_Ywvideotask_children(Map map) throws SQLException{
		return ywvideotaskDao.query_Ywvideotask_children(map);
	}

	/**
	 * 查询一条
	 */

	public Map get_Ywvideotask(Map map) throws SQLException{
		return ywvideotaskDao.get_Ywvideotask(map);
	}

	/**
	 * 导出EXCEL
	 */
	 
	/*
	public Map exportYwvideotask(Map map) throws SQLException{
		return this.listYwvideotaskByPage(map);
	}
	*/

	public List<Map> getApproveUser(Map map) throws SQLException{
		return ywvideotaskDao.getApproveUser(map);
	}

	/**
	 * Ywvideotask 分页
	 */
	public Map listYwvideotaskByPage(Map map) throws SQLException {
		List<Map> list = ywvideotaskDao.query_Ywvideotask(map);
		Integer totalCount = ywvideotaskDao.count_Ywvideotask(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}

	public List<Map>  listYwjtqueryTimeParam(Map map) throws SQLException {
	 return  ywvideotaskDao.listYwjtqueryTimeParam(map);
	}
	public List<Map>  listYwjtxjtask(Map map) throws SQLException {
		return  ywvideotaskDao.listYwjtxjtask(map);
	}

	public Map listYwDevicetaskNoTaskByPage(Map map) throws SQLException {
		List<Map> list = ywvideotaskDao.query_YwDevicetaskNoTask(map);
		Integer totalCount = ywvideotaskDao.count_YwDevicetaskNoTask(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}

	public Map listYwtaskrunresulthistoryByPage(Map map) throws SQLException {
		List<Map> list = ywvideotaskDao.query_Ywtaskrunresulthistory(map);
		Integer totalCount = ywvideotaskDao.count_Ywtaskrunresulthistory(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
}
