package cn.yw.repairmanage.service;

import cn.base.bean.BaseService;
import cn.base.util.CommUtils;
import cn.yw.repairmanage.dao.YwrepairjobinfoDao;
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 java.sql.SQLException;
import java.util.List;
import java.util.Map;

@Service("ywrepairjobinfoService")
public class YwrepairjobinfoService extends BaseService {
	
	private static Log log = LogFactory.getLog(YwrepairjobinfoService.class);
	
	@Autowired
	private YwrepairjobinfoDao ywrepairjobinfoDao;
	
	/**
	 * 保存记录
	 */
	public void insert_Ywrepairjobinfo(Map map) throws SQLException{
		CommUtils.addParams(map, false);
		ywrepairjobinfoDao.insert_Ywrepairjobinfo(map);
	}

	
	/**
	 * 修改记录
	 */
	public Integer update_Ywrepairjobinfo(Map map) throws SQLException{
		CommUtils.validateUpdateParams(map);
		CommUtils.addParams(map, true);
		return ywrepairjobinfoDao.update_Ywrepairjobinfo(map);
	}
	
	/**
	 * 删除记录
	 */
	public Integer delete_Ywrepairjobinfo(Map map) throws SQLException{
		CommUtils.validateDeleteParams(map);
		return ywrepairjobinfoDao.delete_Ywrepairjobinfo(map);

	}
	
	/**
	 * 批处理删除记录
	 */
	public Integer batch_delete_Ywrepairjobinfo(Map map) throws SQLException{
		return ywrepairjobinfoDao.batch_delete_Ywrepairjobinfo(map);
	}
	
	/**
	 * 查询总数
	 */
	public Integer count_Ywrepairjobinfo(Map map) throws SQLException{
		return ywrepairjobinfoDao.count_Ywrepairjobinfo(map);
	}
	
	/**
	 * 查询列表记录SELECT
	 */
	public List<Map> query_Ywrepairjobinfo(Map map) throws SQLException{
		return ywrepairjobinfoDao.query_Ywrepairjobinfo(map);
	}
	
	/**
	 * 查询一条
	 */
	 
	public Map get_Ywrepairjobinfo(Map map) throws SQLException{
		return ywrepairjobinfoDao.get_Ywrepairjobinfo(map);
	}
	
	/**
	 * 导出EXCEL
	 */
	 
	/*
	public Map exportYwrepairjobinfo(Map map) throws SQLException{
		return this.listYwrepairjobinfoByPage(map);
	}
	*/
	
	/**
	 * Ywrepairjobinfo 分页
	 */
	public Map listYwrepairjobinfoByPage(Map map) throws SQLException {
		List<Map> list = ywrepairjobinfoDao.query_Ywrepairjobinfo(map);
		Integer totalCount = ywrepairjobinfoDao.count_Ywrepairjobinfo(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	
	//获取用户信息
	public Map getUserInfo(Map map) throws SQLException{
		return ywrepairjobinfoDao.getUserInfo(map);
	}
	// 有权限审批工单的人所在的部门
	public List getReportBm(Map map) throws SQLException{
		return ywrepairjobinfoDao.getReportBm(map);
	}
	// 有权限审批工单的人
	public List getReportUser(Map map) throws SQLException{
		return ywrepairjobinfoDao.getReportUser(map);
	}

	//查看所有处理清单
	public Map listYwrepairDevicejobinfoByPage(Map map) throws SQLException {
		List<Map> list = ywrepairjobinfoDao.query_YwrepairDevicejobinfo(map);
		Integer totalCount =ywrepairjobinfoDao.count_YwrepairDevicejobinfo(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}

	public  Map countYwrepairjobinstent(Map map)throws SQLException{
		List<Map> list = ywrepairjobinfoDao.query_Ywrepairjobinstent(map);
		Integer totalCount= ywrepairjobinfoDao.count_Ywrepairjobinstent(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}

	public  List<Map> query_Ywrepairjobinstent(Map map)throws SQLException{
		List<Map> list = ywrepairjobinfoDao.query_Ywrepairjobinstent(map);
		return list;
	}


	public  void 	batch_insert_KSHPicture(List list)throws SQLException{
		 ywrepairjobinfoDao.batch_insert_KSHPicture(list);

	}


	public Map  query_kshPictureByObjectId(Map map)throws SQLException{
		List<Map> list = ywrepairjobinfoDao.query_kshPictureByObjectId(map);
		Integer totalCount= ywrepairjobinfoDao.count_kshPictureByObjectId(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	public void  delete_kshPictureByID(Map map)throws SQLException{
		CommUtils.validateDeleteParams(map);
		ywrepairjobinfoDao.delete_kshPictureByID(map);

	}

	public  Map originStatistic(Map map)throws SQLException{
		List<Map> list = ywrepairjobinfoDao.query_originStatistic(map);
		Integer totalCount= ywrepairjobinfoDao.count_originStatistic(map);
		map.clear();
		map.put("total", totalCount);
		map.put("rows", list);
		return map;
	}
	public  List<Map> query_maxDevicetypeorigin(Map map)throws SQLException{
		return  ywrepairjobinfoDao.query_maxDevicetypeorigin(map);
	}
	public  List<Map> query_YwrepairjobinfoReceiver(Map map)throws SQLException{
		return  ywrepairjobinfoDao.query_YwrepairjobinfoReceiver(map);
	}
	public  List<Map> listjobprocessstate()throws SQLException{
		return  ywrepairjobinfoDao.listjobprocessstate();
	}



}
