package com.madeu.dao.web.webreserve;

import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import jakarta.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class WebReserveSqlMapDAO extends SqlSessionDaoSupport{

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@PostConstruct
	void init() {
		setSqlSessionTemplate(sqlSessionTemplate);
	}
	
	/**
	 * 예약현황 상태별 총 건수 조회 (count)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalReserveStatusCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectTotalReserveStatusCount START");
		String sqlId = "WebReserve.selectTotalReserveStatusCount";
		logger.debug("WebReserveSqlMapDAO selectTotalReserveStatusCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 예약현황 진료별 총 건수 조회 (count) - 예약
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalReserveStatusTTreatmentCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectTotalReserveStatusTTreatmentCount START");
		String sqlId = "WebReserve.selectTotalReserveStatusTTreatmentCount";
		logger.debug("WebReserveSqlMapDAO selectTotalReserveStatusTTreatmentCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 예약현황 진료별 총 건수 조회 (count) - 접수
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectTotalReserveStatusRTreatmentCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectTotalReserveStatusRTreatmentCount START");
		String sqlId = "WebReserve.selectTotalReserveStatusRTreatmentCount";
		logger.debug("WebReserveSqlMapDAO selectTotalReserveStatusRTreatmentCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 예약현황 진료별 총 건수 조회 (count) - 수납
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectTotalReserveStatusYTreatmentCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectTotalReserveStatusYTreatmentCount START");
		String sqlId = "WebReserve.selectTotalReserveStatusYTreatmentCount";
		logger.debug("WebReserveSqlMapDAO selectTotalReserveStatusYTreatmentCount END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 예약현황 정보 - 조회날짜 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveTime(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveTime START");
		String sqlId = "WebReserve.selectListReserveTime";
		logger.debug("WebReserveSqlMapDAO selectListReserveTime END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 예약현황 정보 - 직원 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveMember(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveMember START");
		String sqlId = "WebReserve.selectListReserveMember";
		logger.debug("WebReserveSqlMapDAO selectListReserveMember END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 예약현황 정보 - 앱예약 조회 (List)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListReserveApp(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveApp START");
		String sqlId = "WebReserve.selectListReserveApp";
		logger.debug("WebReserveSqlMapDAO selectListReserveApp END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 예약현황 정보 - 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserve(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserve START");
		String sqlId = "WebReserve.selectListReserve";
		logger.debug("WebReserveSqlMapDAO selectListReserve END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 상태별 예약현황 정보 - 고객 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveUser(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveUser START");
		String sqlId = "WebReserve.selectListReserveUser";
		logger.debug("WebReserveSqlMapDAO selectListReserveUser END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 상태별 예약현황 정보 - 고객 현황 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveUserHistory(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveUserHistory START");
		String sqlId = "WebReserve.selectListReserveUserHistory";
		logger.debug("WebReserveSqlMapDAO selectListReserveUserHistory END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 고객 예약현황 정보 최근 5개 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveUserHistoryTop5(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveUserHistoryTop5 START");
		String sqlId = "WebReserve.selectListReserveUserHistoryTop5";
		logger.debug("WebReserveSqlMapDAO selectListReserveUserHistoryTop5 END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 고객 상세 - 고객 예약내역 리스트 총 갯수 (count)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectTotalReserveUserHistory2Count(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectTotalReserveUserHistory2Count START");
		String sqlId = "WebReserve.selectTotalReserveUserHistory2Count";
		logger.debug("WebReserveSqlMapDAO selectTotalReserveUserHistory2Count END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 고객 상세 - 고객 예약내역 리스트 조회 (List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveUserHistory2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveUserHistory2 START");
		String sqlId = "WebReserve.selectListReserveUserHistory2";
		logger.debug("WebReserveSqlMapDAO selectListReserveUserHistory2 END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 고객 상세 - 고객 예약내역 리스트 조회 (List, Excel)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveUserHistory2Excel(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveUserHistory2Excel START");
		String sqlId = "WebReserve.selectListReserveUserHistory2Excel";
		logger.debug("WebReserveSqlMapDAO selectListReserveUserHistory2Excel END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 당일 예약 리스트 조회 (배치)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListReserveTodayBatch(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveTodayBatch START");
		String sqlId = "WebReserve.selectListReserveTodayBatch";
		logger.debug("WebReserveSqlMapDAO selectListReserveTodayBatch END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 예약현황 상세 조회 (one)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectReserve(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectReserve START");
		String sqlId = "WebReserve.selectReserve";
		logger.debug("WebReserveSqlMapDAO selectReserve END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 고객 해당 일자 예약현황 정보 상세 조회 (one)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectReserveUser(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectReserveUser START");
		String sqlId = "WebReserve.selectReserveUser";
		logger.debug("WebReserveSqlMapDAO selectReserveUser END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 고객 해당 일자 미수납건 조회(List)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveUserNoPayment(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveUserNoPayment START");
		String sqlId = "WebReserve.selectListReserveUserNoPayment";
		logger.debug("WebReserveSqlMapDAO selectListReserveUserNoPayment END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 고객 - 1년간 진료내역 조회 (수납완료건) (List, option)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveUserOption(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveUserOption START");
		String sqlId = "WebReserve.selectListReserveUserOption";
		logger.debug("WebReserveSqlMapDAO selectListReserveUserOption END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	
	/**
	 * 고객 정보로 예약 중복 확인
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException 
	 */
	public List<Map<String, Object>> selectListReserveYn(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveYn START");
		String sqlId = "WebReserve.selectListReserveYn";
		logger.debug("WebReserveSqlMapDAO selectListReserveYn END");
		return getSqlSession().selectList(sqlId, paramMap);
	}

	/**
	 * 기존 db 예약 중복 확인
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public List<Map<String, Object>> selectListReserveCheck(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectListReserveCheck START");
		String sqlId = "WebReserve.selectListReserveCheck";
		logger.debug("WebReserveSqlMapDAO selectListReserveCheck END");
		return getSqlSession().selectList(sqlId, paramMap);
	}
	/**
	 * 시간 별 예약 수 조회
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public Integer selectReserveCount(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO selectReserveCount START");
		String sqlId = "WebReserve.selectReserveCount";
		logger.debug("WebReserveSqlMapDAO selectReserveCount END");
		return getSqlSession().selectOne(sqlId, paramMap);
	}
	
	/**
	 * 예약현황 정보 등록
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertReserve(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO insertReserve START");
		String sqlId = "WebReserve.insertReserve";
		logger.debug("WebReserveSqlMapDAO insertReserve END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 예약현황 정보 등록 (배치)
	 *
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int insertReserveBatch(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO insertReserveBatch START");
		String sqlId = "WebReserve.insertReserveBatch";
		logger.debug("WebReserveSqlMapDAO insertReserveBatch END");
		return getSqlSession().insert(sqlId, paramMap);
	}

	/**
	 * 예약현황 정보 수정
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateReserve(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO updateReserve START");
		String sqlId = "WebReserve.updateReserve";
		logger.debug("WebReserveSqlMapDAO updateReserve END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
	/**
	 * 예약현황 정보 상태 수정 (진료상태)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateReserveStatus(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO updateReserveStatus START");
		String sqlId = "WebReserve.updateReserveStatus";
		logger.debug("WebReserveSqlMapDAO updateReserveStatus END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
	/**
	 * 예약현황 정보 상태 수정 (접수상태로 변경)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateReserveReadyStatus(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO updateReserveReadyStatus START");
		String sqlId = "WebReserve.updateReserveReadyStatus";
		logger.debug("WebReserveSqlMapDAO updateReserveReadyStatus END");
		return getSqlSession().update(sqlId, paramMap);
	}
	
	/**
	 * 예약현황 정보 상태2 수정 (수납상태)
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int updateReserveStatus2(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO updateReserveStatus2 START");
		String sqlId = "WebReserve.updateReserveStatus2";
		logger.debug("WebReserveSqlMapDAO updateReserveStatus2 END");
		return getSqlSession().update(sqlId, paramMap);
	}

	/**
	 * 예약현황 정보 삭제
	 * 
	 * @param Map
	 * @return
	 * @throws DataAccessException
	 */
	public int deleteReserve(HashMap<String, Object> paramMap)
			throws DataAccessException {
		logger.debug("WebReserveSqlMapDAO deleteReserve START");
		String sqlId = "WebReserve.deleteReserve";
		logger.debug("WebReserveSqlMapDAO deleteReserve END");
		return getSqlSession().update(sqlId, paramMap);
	}
}
