package com.madeu.service.web.webreserve.impl;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;

import com.madeu.dao.web.webdevice.WebDeviceSqlMapDAO;
import com.madeu.dao.web.webkakaotemplate.WebKakaoTemplateSqlMapDAO;
import com.madeu.dao.web.webpayment.WebPaymentSqlMapDAO;
import com.madeu.dao.web.webkakao.WebKakaoSqlMapDAO;
import com.madeu.dao.web.webpush.WebPushSqlMapDAO;
import com.madeu.service.common.autokakao.AutoKakaoService;
import com.madeu.service.common.autopush.AutoPushService;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import com.madeu.constants.Constants;
import com.madeu.dao.web.webauthmenurelation.WebAuthMenuRelationSqlMapDAO;
import com.madeu.dao.web.webcategory.WebCategorySqlMapDAO;
import com.madeu.dao.web.webhospital.WebHospitalSqlMapDAO;
import com.madeu.dao.web.webmember.WebMemberSqlMapDAO;
import com.madeu.dao.web.webreserve.WebReserveSqlMapDAO;
import com.madeu.dao.web.webtreatmentprocedure.WebTreatmentProcedureSqlMapDAO;
import com.madeu.dao.web.webtreatmentproceduredoctor.WebTreatmentProcedureDoctorSqlMapDAO;
import com.madeu.dao.web.webuser.WebUserSqlMapDAO;
import com.madeu.dao.web.webuserconsultingchart.WebUserConsultingChartSqlMapDAO;
import com.madeu.dao.web.webusermedicalchart.WebUserMedicalChartSqlMapDAO;
import com.madeu.service.web.webreserve.WebReserveService;
import com.madeu.util.ExcelUtil;
import com.madeu.util.FileStoreUtil;
import com.madeu.util.ValidationCheckUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service("WebReserveService")
public class WebReserveServiceImpl implements WebReserveService {
	
	@Autowired
	private WebReserveSqlMapDAO webReserveSqlMapDAO;
	
	@Autowired
	private WebMemberSqlMapDAO webMemberSqlMapDAO;
	
	@Autowired
	private WebAuthMenuRelationSqlMapDAO webAuthMenuRelationSqlMapDAO;
	
	@Autowired
	private WebHospitalSqlMapDAO webHospitalSqlMapDAO;
	
	@Autowired
	private WebTreatmentProcedureSqlMapDAO webTreatmentProcedureSqlMapDAO;
	
	@Autowired
	private WebUserConsultingChartSqlMapDAO webUserConsultingChartSqlMapDAO;
	
	@Autowired
	private WebUserMedicalChartSqlMapDAO webUserMedicalChartSqlMapDAO;
	
	@Autowired
	private WebUserSqlMapDAO webUserSqlMapDAO;
	
	@Autowired
	private WebCategorySqlMapDAO webCategorySqlMapDAO;
	
	@Autowired
	private WebTreatmentProcedureDoctorSqlMapDAO webTreatmentProcedureDoctorSqlMapDAO;

	@Autowired
	private WebPaymentSqlMapDAO	webPaymentSqlMapDAO;

	@Autowired
	private WebKakaoSqlMapDAO webKakaoSqlMapDAO;

	@Autowired
	private WebKakaoTemplateSqlMapDAO webKakaoTemplateSqlMapDAO;

	@Autowired
	private WebDeviceSqlMapDAO webDeviceSqlMapDAO;

	@Autowired
	private WebPushSqlMapDAO webPushSqlMapDAO;

	@Autowired
	private AutoPushService autoPushService;

	@Autowired
	private AutoKakaoService autoKakaoService;

	@Value("${popbill.sender-phone-num}")
	String senderPhoneNumber;

	
	
	/**
	 * 고객 - 1년간 진료내역 조회 (수납완료건) (List, option)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListReserveUserOption(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectListReserveUserOption START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muUserId            :"+paramMap.get("muUserId"));
		
		List<Map<String, Object>> listMap = new ArrayList<Map<String,Object>>();

		try{
			boolean check  = true;
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				
				// 리스트 조회
				listMap = webReserveSqlMapDAO.selectListReserveUserOption(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}

		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}

		log.debug("WebReserveServiceImpl selectListReserveUserOption END");
		return map;
	}
	
	/**
	 * 예약현황 상태별 건수 조회 (count)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectTotalReserveStatusCount(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectTotalReserveStatusCount START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("searchDate          :"+paramMap.get("searchDate"));
		
		try{
			boolean check  = true;
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				List<Map<String, Object>> listMap = webReserveSqlMapDAO.selectTotalReserveStatusCount(paramMap);
				
				List<Map<String, Object>> treatmentCountListMap = webReserveSqlMapDAO.selectTotalReserveStatusTTreatmentCount(paramMap);
				List<Map<String, Object>> treatmentCountListMap2 = webReserveSqlMapDAO.selectTotalReserveStatusRTreatmentCount(paramMap);
				List<Map<String, Object>> treatmentCountListMap3 = webReserveSqlMapDAO.selectTotalReserveStatusYTreatmentCount(paramMap);

				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
				map.put("treatmentCountRows",treatmentCountListMap);
				map.put("treatmentCountRows2",treatmentCountListMap2);
				map.put("treatmentCountRows3",treatmentCountListMap3);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectTotalReserveStatusCount END");
		return map;
	}
	
	/**
	 * 예약현황 리스트 조회
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListReserve(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectListReserve START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("searchDate               : "+paramMap.get("searchDate"));
		log.debug("muTreatmentId            : "+paramMap.get("muTreatmentId"));
		log.debug("muTreatmentProcedureId   : "+paramMap.get("muTreatmentProcedureId"));
		log.debug("muMemberId               : "+paramMap.get("muMemberId"));
		log.debug("reserveReserveVisit      : "+paramMap.get("reserveReserveVisit"));

		List<Map<String, Object>> listMap = new ArrayList<Map<String,Object>>();
		List<Map<String, Object>> listMap2 = new ArrayList<Map<String,Object>>();

		try{
			boolean check  = true;
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

				if(1==authMenuRelationlistMapSize){

					if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "조회 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "조회 정보가 없습니다.");
				}
			}

			// 진료 선택
			String muTreatmentId = String.valueOf(paramMap.get("muTreatmentId"));
			String muTreatmentIdList = "";

			if(true != ValidationCheckUtil.emptyCheck(muTreatmentId)){

			}else{
				String [] muTreatmentIdArr = muTreatmentId.split(",");
				for(int i=0; i<muTreatmentIdArr.length; i++){
					muTreatmentIdList = muTreatmentIdList.concat("'").concat(muTreatmentIdArr[i]).concat("',");
				}

				muTreatmentIdList = muTreatmentIdList.substring(0, muTreatmentIdList.lastIndexOf(","));
				paramMap.put("muTreatmentIdList", muTreatmentIdList);
			}

			// 시술 선택
			String muTreatmentProcedureId = String.valueOf(paramMap.get("muTreatmentProcedureId"));
			String muTreatmentProcedureIdList = "";

			if(true != ValidationCheckUtil.emptyCheck(muTreatmentProcedureId)){

			}else{
				String [] muTreatmentProcedureIdArr = muTreatmentProcedureId.split(",");
				for(int i=0; i<muTreatmentProcedureIdArr.length; i++){
					muTreatmentProcedureIdList = muTreatmentProcedureIdList.concat("'").concat(muTreatmentProcedureIdArr[i]).concat("',");
				}

				muTreatmentProcedureIdList = muTreatmentProcedureIdList.substring(0, muTreatmentProcedureIdList.lastIndexOf(","));
				paramMap.put("muTreatmentProcedureIdList", muTreatmentProcedureIdList);
			}

			// 닥터/상담 선택
			String muMemberId2 = String.valueOf(paramMap.get("muMemberId"));
			String muMemberIdList = "";

			if(true != ValidationCheckUtil.emptyCheck(muMemberId2)){

			}else{
				String [] muMemberIdArr = muMemberId2.split(",");
				for(int i=0; i<muMemberIdArr.length; i++){
					muMemberIdList = muMemberIdList.concat("'").concat(muMemberIdArr[i]).concat("',");
				}

				muMemberIdList = muMemberIdList.substring(0, muMemberIdList.lastIndexOf(","));
				paramMap.put("muMemberIdList", muMemberIdList);
			}

			String openYn         = "";
			String holidayYn         = "";
			String openStartTime  = "";
			String openEndTime    = "";
			String breakStartTime = "";
			String breakEndTime   = "";
			if(true == check){
				// 병원 운영 시간 조회
				List<Map<String, Object>> hospitalListMap = webHospitalSqlMapDAO.selectHospitalWeek(paramMap);
				if(1 == hospitalListMap.size()) {
					openYn         = String.valueOf(hospitalListMap.get(0).get("openYn"));
					holidayYn         = String.valueOf(hospitalListMap.get(0).get("holidayYn"));
					openStartTime  = String.valueOf(hospitalListMap.get(0).get("openStartTime"));
					openEndTime    = String.valueOf(hospitalListMap.get(0).get("openEndTime"));
					breakStartTime = String.valueOf(hospitalListMap.get(0).get("breakStartTime"));
					breakEndTime   = String.valueOf(hospitalListMap.get(0).get("breakEndTime"));
					
					paramMap.put("openStartTime", openStartTime);
					paramMap.put("openEndTime", openEndTime);
					paramMap.put("breakStartTime", openEndTime);
					paramMap.put("breakEndTime", openEndTime);
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "병원 정보가 없습니다.");
				}
			}
			
			if(true == check){
				List<Map<String, Object>> timeListMap = new ArrayList<Map<String,Object>>();
				List<Map<String, Object>> memberListMap = new ArrayList<Map<String,Object>>();
				List<Map<String, Object>> appReserveListMap = new ArrayList<Map<String,Object>>();

				// 시간 조회
				timeListMap = webReserveSqlMapDAO.selectListReserveTime(paramMap);
				
				// 닥터, 상담자 조회
				memberListMap = webReserveSqlMapDAO.selectListReserveMember(paramMap);

				if(("Y").equals(openYn)) {
					// 바꾼 쿼리
					HashMap<String, Object> appParamMap = new HashMap<String, Object>();
					appParamMap.put("openStartTime", paramMap.get("openStartTime"));
					appParamMap.put("openEndTime", paramMap.get("openEndTime"));
					appParamMap.put("searchDate", paramMap.get("searchDate"));
					appParamMap.put("muTreatmentId", paramMap.get("muTreatmentId"));
					appParamMap.put("muTreatmentProcedureId", paramMap.get("muTreatmentProcedureId"));
					appParamMap.put("reserveReserveVisit", paramMap.get("reserveReserveVisit"));
					// 앱 예약 조회
					appReserveListMap = webReserveSqlMapDAO.selectListReserveApp(appParamMap);
					listMap2.addAll(appReserveListMap);

					for (int i = 0; i < memberListMap.size(); i++) {
						String muMemberId = String.valueOf(memberListMap.get(i).get("muMemberId"));

						// 예약현황 조회
						HashMap<String, Object> reserveParamMap = new HashMap<String, Object>();
						reserveParamMap.put("openStartTime", paramMap.get("openStartTime"));
						reserveParamMap.put("openEndTime", paramMap.get("openEndTime"));
						reserveParamMap.put("searchMemberId", muMemberId);
						reserveParamMap.put("searchDate", paramMap.get("searchDate"));
//						reserveParamMap.put("searchTime", resultTime);
						reserveParamMap.put("muTreatmentIdList", paramMap.get("muTreatmentIdList"));
						reserveParamMap.put("muTreatmentProcedureIdList", paramMap.get("muTreatmentProcedureIdList"));
						reserveParamMap.put("muMemberIdList", paramMap.get("muMemberIdList"));
						reserveParamMap.put("reserveReserveVisit", paramMap.get("reserveReserveVisit"));
						List<Map<String, Object>> reserveListMap = webReserveSqlMapDAO.selectListReserve(reserveParamMap);

						Map<String, Object> addResultMap = new HashMap<String, Object>();
						addResultMap.put("muMemberId", muMemberId);
//						addResultMap.put("searchDate", resultDate);
//						addResultMap.put("searchTime", resultTime);
						addResultMap.put("reserveListMap", reserveListMap);
						addResultMap.put("breakStartTime", paramMap.get("breakStartTime"));
						addResultMap.put("breakEndTime", paramMap.get("breakEndTime"));
						listMap.add(addResultMap);
					}









					/*for (int j = 0; j < timeListMap.size(); j++) {
						String resultDate = String.valueOf(timeListMap.get(j).get("resultDate"));
						String resultTime = String.valueOf(timeListMap.get(j).get("resultTime"));
						HashMap<String, Object> appParamMap = new HashMap<String, Object>();
						appParamMap.put("searchDate",resultDate);
						appParamMap.put("searchTime",resultTime);
						appParamMap.put("muTreatmentId", paramMap.get("muTreatmentId"));
						appParamMap.put("muTreatmentProcedureId", paramMap.get("muTreatmentProcedureId"));
						appParamMap.put("reserveReserveVisit", paramMap.get("reserveReserveVisit"));
//						앱 예약 조회
						appReserveListMap = webReserveSqlMapDAO.selectListReserveApp(appParamMap);
						listMap2.add(appReserveListMap);
						for (int i = 0; i < memberListMap.size(); i++) {
							String muMemberId = String.valueOf(memberListMap.get(i).get("muMemberId"));

							// 예약현황 조회
							HashMap<String, Object> reserveParamMap = new HashMap<String, Object>();
							reserveParamMap.put("searchMemberId", muMemberId);
							reserveParamMap.put("searchDate", resultDate);
							reserveParamMap.put("searchTime", resultTime);
							reserveParamMap.put("muTreatmentIdList", paramMap.get("muTreatmentIdList"));
							reserveParamMap.put("muTreatmentProcedureIdList", paramMap.get("muTreatmentProcedureIdList"));
							reserveParamMap.put("muMemberIdList", paramMap.get("muMemberIdList"));
							reserveParamMap.put("reserveReserveVisit", paramMap.get("reserveReserveVisit"));
							List<Map<String, Object>> reserveListMap = webReserveSqlMapDAO.selectListReserve(reserveParamMap);
							
							Map<String, Object> addResultMap = new HashMap<String, Object>();
							addResultMap.put("muMemberId", muMemberId);
							addResultMap.put("searchDate", resultDate);
							addResultMap.put("searchTime", resultTime);
							addResultMap.put("reserveListMap", reserveListMap);
							addResultMap.put("breakStartTime", paramMap.get("breakStartTime"));
							addResultMap.put("breakEndTime", paramMap.get("breakEndTime"));
							listMap.add(addResultMap);
						}
					}*/
				}
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("openYn",openYn);
				map.put("holidayYn",holidayYn);
				map.put("breakStartTime",breakStartTime);
				map.put("breakEndTime",breakEndTime);
				map.put("memberRows",memberListMap);
				map.put("appReserveRows",listMap2);
				map.put("timeRows",timeListMap);
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectListReserve END");
		return map;
	}
	/**
	 * 병원휴일 정보 리스트 조회
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectHospitalHoliday(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectHospitalHoliday START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("menuClass           :"+paramMap.get("menuClass"));

		List<Map<String, Object>> listMap = new ArrayList<Map<String,Object>>();

		try{
			boolean check  = true;

			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();

				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

				if(1==authMenuRelationlistMapSize){

					if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "조회 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "조회 정보가 없습니다.");
				}
			}

			if(true == check){
				listMap = webHospitalSqlMapDAO.selectHospitalHoliday(paramMap);

				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectHospitalHoliday END");
		return map;
	}
	

	/**
	 * 상태별 예약현황 리스트 조회 - (List)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListReserveStatus(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectListReserveStatus START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("status              :"+paramMap.get("status"));
		log.debug("searchDate          :"+paramMap.get("searchDate"));
		log.debug("searchKeywordParam  :"+paramMap.get("searchKeywordParam"));
		log.debug("muTreatmentId       :"+paramMap.get("muTreatmentId"));
		
		try{
			boolean check  = true;
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

				if(1==authMenuRelationlistMapSize){

					if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "조회 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "조회 정보가 없습니다.");
				}
			}
			
			if(true == check){
				
				// 고객 조회
				List<Map<String, Object>> listMap = webReserveSqlMapDAO.selectListReserveUser(paramMap);
				
				for (int i= 0; i < listMap.size(); i++) {
					String userName    = String.valueOf(listMap.get(i).get("userName"));
					String phoneNumber = String.valueOf(listMap.get(i).get("phoneNumber"));
					paramMap.put("userName", userName);
					paramMap.put("phoneNumber", phoneNumber);
					
					// 고객 현황 리스트 조회
					List<Map<String, Object>> historyListMap = webReserveSqlMapDAO.selectListReserveUserHistory(paramMap);
					
					listMap.get(i).put("historyListMap", historyListMap);
				}
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectListReserveStatus END");
		return map;
	}
	
	/**
	 * 예약현황 정보 상세 조회 (one)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectReserve(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectReserve START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muReserveId         :"+paramMap.get("muReserveId"));
		log.debug("searchDate          :"+paramMap.get("searchDate"));

		try{
			boolean check  = true;
			String muReserveId  = String.valueOf(paramMap.get("muReserveId"));
			String searchDate   = String.valueOf(paramMap.get("searchDate"));
			
			if(true != ValidationCheckUtil.emptyCheck(muReserveId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(searchDate)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","날짜 정보가 없습니다.");
			}
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
				
				if(1==authMenuRelationlistMapSize){
					
					if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {
						
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "조회 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "조회 정보가 없습니다.");
				}
			}
			
			if(true == check){
				List<Map<String, Object>> listMap = webReserveSqlMapDAO.selectReserve(paramMap);
				
				if(1==listMap.size()) {
					String muUserId = String.valueOf(listMap.get(0).get("muUserId"));
					
					paramMap.put("muUserId", muUserId);
					List<Map<String, Object>> historyListMap = webReserveSqlMapDAO.selectListReserveUserHistoryTop5(paramMap);
					
					listMap.get(0).put("historyList", historyListMap);
				}
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectReserve END");
		return map;
	}
	
	/**
	 * 고객 해당 일자 예약현황 정보 상세 조회 (one)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectReserveUser(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectReserveUser START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muUserId            :"+paramMap.get("muUserId"));
		log.debug("reserveDate         :"+paramMap.get("reserveDate"));

		try{
			boolean check  = true;
			String muUserId       = String.valueOf(paramMap.get("muUserId"));
			String reserveDate    = String.valueOf(paramMap.get("reserveDate"));
			
			if(true != ValidationCheckUtil.emptyCheck(muUserId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(reserveDate)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","일자 정보가 없습니다.");
			}
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
				
				if(1==authMenuRelationlistMapSize){
					
					if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {
						
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "조회 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "조회 정보가 없습니다.");
				}
			}
			
			if(true == check){
				List<Map<String, Object>> listMap = webReserveSqlMapDAO.selectReserveUser(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectReserveUser END");
		return map;
	}
	
	/**
	 * 고객 해당 일자 미수납건 조회(List)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListReserveUserNoPayment(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectListReserveUserNoPayment START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muUserId            :"+paramMap.get("muUserId"));
		log.debug("reserveDate         :"+paramMap.get("reserveDate"));
		
		// 검색
		log.debug("muTreatmentId           :"+paramMap.get("muTreatmentId"));
		log.debug("muTreatmentProcedureId  :"+paramMap.get("muTreatmentProcedureId"));

		try{
			boolean check  = true;
			String muUserId       = String.valueOf(paramMap.get("muUserId"));
			String reserveDate    = String.valueOf(paramMap.get("reserveDate"));
			
			if(true != ValidationCheckUtil.emptyCheck(muUserId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객 정보가 없습니다.");
			}
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
				
				if(1==authMenuRelationlistMapSize){
					
					if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {
						
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "조회 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "조회 정보가 없습니다.");
				}
			}
			
			if(true == check){
				// 예약자 정보 조회
				List<Map<String, Object>> listMap = webUserSqlMapDAO.selectUser(paramMap);
				
				// 미수납 정보 조회
				List<Map<String, Object>> paymentListMap = webReserveSqlMapDAO.selectListReserveUserNoPayment(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("userRows",listMap);
				map.put("rows",paymentListMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectListReserveUserNoPayment END");
		return map;
	}
	
	/**
	 * 고객 상세 - 고객 예약내역 리스트 화면으로 이동.
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListReserveUserHistoryIntro(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectListReserveUserHistoryIntro START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		try{
			boolean check  = true;
			
			String menuClass    = String.valueOf(paramMap.get("menuClass"));
			
			if(true != ValidationCheckUtil.emptyCheck(menuClass)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","메뉴 정보가 없습니다.");
			}
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				
				if(1==authMenuRelationlistMap.size()){
					map.put("msgCode", Constants.OK);
					map.put("success","true");
					
					map.put("selectUseYn", authMenuRelationlistMap.get(0).get("selectUseYn"));
					map.put("insertUseYn", authMenuRelationlistMap.get(0).get("insertUseYn"));
					map.put("updateUseYn", authMenuRelationlistMap.get(0).get("updateUseYn"));
					map.put("deleteUseYn", authMenuRelationlistMap.get(0).get("deleteUseYn"));
					map.put("downloadUseYn", authMenuRelationlistMap.get(0).get("downloadUseYn"));
				}
				else {
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "권한 정보가 없습니다.");
				}
			}
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		
		log.debug("WebReserveServiceImpl selectListReserveUserHistoryIntro END");
		return map;
	}
	
	/**
	 * 고객 상세 - 고객 예약내역 리스트 조회 (List)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListReserveUserHistory(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectListReserveUserHistory START");

		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("searchKeywordParam  :"+paramMap.get("searchKeywordParam"));
		log.debug("sort                :"+paramMap.get("sort"));
		log.debug("start               :"+paramMap.get("start"));
		log.debug("limit               :"+paramMap.get("limit"));
		log.debug("sort                :"+paramMap.get("sort"));
		log.debug("dir                 :"+paramMap.get("dir"));
		log.debug("currentPage         :"+paramMap.get("currentPage"));
		
		log.debug("searchStartDate     :"+paramMap.get("searchStartDate"));
		log.debug("searchEndDate       :"+paramMap.get("searchEndDate"));
		
		log.debug("muTreatmentId          :"+paramMap.get("muTreatmentId"));
		log.debug("muTreatmentProcedureId :"+paramMap.get("muTreatmentProcedureId"));
		log.debug("reserveMemberId        :"+paramMap.get("reserveMemberId"));
		
		List<Map<String, Object>> listMap = new ArrayList<Map<String,Object>>();

		try{
			boolean check  = true;
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

				if(1==authMenuRelationlistMapSize){

					if(("Y").equals(authMenuRelationlistMap.get(0).get("selectUseYn"))) {

					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "조회 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "조회 정보가 없습니다.");
				}
			}
			if(true == check){
				// 정렬 
				if(null==paramMap.get("dir")||("").equals(paramMap.get("dir"))){
					
				}
				else{
					String dir = String.valueOf(paramMap.get("dir"));
					if(("A").equals(dir)){
						paramMap.put("dir", "DESC");
					}
					else if(("B").equals(dir)){
						paramMap.put("dir", "ASC");
					}
					else {
						paramMap.put("dir", "DESC");
					}
				}
				
				paramMap.put("useYn", "Y");
				
				List<Map<String, Object>> totalCountListMap = webReserveSqlMapDAO.selectTotalReserveUserHistory2Count(paramMap);
				int totalCount = Integer.parseInt(String.valueOf(totalCountListMap.get(0).get("totalCount")));
				
				if(0 < totalCount) {
					// 리스트 조회
					listMap = webReserveSqlMapDAO.selectListReserveUserHistory2(paramMap);
				}
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("totalCount", totalCount);
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectListReserveUserHistory END");
		return map;
	}
	
	/**
	 * 고객 상세 - 고객 예약내역 리스트 조회 (List, Excel)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Map<String, Object>> selectListReserveUserHistoryExcel(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectListReserveUserHistoryExcel START");

		HashMap<String, Object> map = new HashMap<String, Object>();
		List<Map<String, Object>> listMap = null;

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));

		log.debug("searchKeywordParam  :"+paramMap.get("searchKeywordParam"));
		log.debug("sort                :"+paramMap.get("sort"));
		log.debug("start               :"+paramMap.get("start"));
		log.debug("limit               :"+paramMap.get("limit"));
		log.debug("sort                :"+paramMap.get("sort"));
		log.debug("dir                 :"+paramMap.get("dir"));
		log.debug("currentPage         :"+paramMap.get("currentPage"));
		
		log.debug("searchStartDate     :"+paramMap.get("searchStartDate"));
		log.debug("searchEndDate       :"+paramMap.get("searchEndDate"));
		
		log.debug("muTreatmentId          :"+paramMap.get("muTreatmentId"));
		log.debug("muTreatmentProcedureId :"+paramMap.get("muTreatmentProcedureId"));
		log.debug("reserveMemberId        :"+paramMap.get("reserveMemberId"));
		
		try{
			boolean check  = true;
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

				if(1==authMenuRelationlistMapSize){

					if(("Y").equals(authMenuRelationlistMap.get(0).get("downloadUseYn"))) {

					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "내려받기 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "권한 정보가 없습니다.");
				}
			}
			if(true == check){
				// 정렬 
				if(null==paramMap.get("dir")||("").equals(paramMap.get("dir"))){
					
				}
				else{
					String dir = String.valueOf(paramMap.get("dir"));
					if(("A").equals(dir)){
						paramMap.put("dir", "DESC");
					}
					else if(("B").equals(dir)){
						paramMap.put("dir", "ASC");
					}
					else {
						paramMap.put("dir", "DESC");
					}
				}
				
				paramMap.put("useYn", "Y");
				
				listMap = webReserveSqlMapDAO.selectListReserveUserHistory2Excel(paramMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectListReserveUserHistoryExcel END");
		return listMap;
	}
	
	/**
	 * 예약현황 정보 등록 (예약등록)
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> insertReserve(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl insertReserve START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muUserId            :"+paramMap.get("muUserId"));
		log.debug("userName            :"+paramMap.get("userName"));
		log.debug("muMemberId          :"+paramMap.get("muMemberId"));
		log.debug("reserveRows         :"+paramMap.get("reserveRows"));

		try{
			boolean check  = true;
			String tId = String.valueOf(System.currentTimeMillis());
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Calendar c1 = Calendar.getInstance();
			String tDate = sdf.format(c1.getTime());

			String muUserId               = String.valueOf(paramMap.get("muUserId"));
			String userName               = String.valueOf(paramMap.get("userName"));
			String muMemberId             = String.valueOf(paramMap.get("muMemberId"));
			
			if(true != ValidationCheckUtil.emptyCheck(muUserId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(userName)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객명 정보가 없습니다.");
			}
			else{
				if(true != ValidationCheckUtil.lengthCheck(userName,255)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","고객명 정보는 255자를 넘을 수 없습니다.");
				}
			}
			
			if(true != ValidationCheckUtil.emptyCheck(muMemberId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","담당자 정보가 없습니다.");
			}
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}

			if(true == check){
				// 고객정보 확인
				List<Map<String, Object>> userList = webUserSqlMapDAO.selectUser(paramMap);
				
				if(1==userList.size()) {
					paramMap.put("phoneNumber", userList.get(0).get("phoneNumber"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "고객 정보가 없습니다.");
				}
			}
			
			
			// 예약정보 확인
			JSONParser jsonParserTemp = new JSONParser();
			JSONObject jsonObjectTemp = (JSONObject) jsonParserTemp.parse(String.valueOf(paramMap.get("reserveRows")));
			
			if(true == check){
				if(true == jsonObjectTemp.isEmpty()) {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","예약 정보가 없습니다.");
				}
				else {
					JSONArray detailArray = (JSONArray) jsonObjectTemp.get("data");
					Set<String> uniqueCombinations = new HashSet<>();

					for(int j=0; j<detailArray.size(); j++){
						JSONObject detailObject = (JSONObject) detailArray.get(j);

						String reserveDate            = String.valueOf(detailObject.get("reserveDate"));
						String reserveTime            = String.valueOf(detailObject.get("reserveTime"));
						String reserveCategoryItemCode  = String.valueOf(detailObject.get("reserveCategoryItemCode"));
						String reserveCategoryItemName  = String.valueOf(detailObject.get("reserveCategoryItemName"));
						String muTreatmentProcedureId = String.valueOf(detailObject.get("muTreatmentProcedureId"));
						String reserveMemberId        = String.valueOf(detailObject.get("reserveMemberId"));
						String etc                    = String.valueOf(detailObject.get("etc"));
						String combination 			  = reserveDate + "_" +reserveTime + "_" +muTreatmentProcedureId;

						if(true != ValidationCheckUtil.emptyCheck(reserveDate)){
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc","예약일자 정보가 없습니다.");
						}
						else {
							if(true != ValidationCheckUtil.dateCheck(reserveDate)){
								check = false;
								map.put("msgCode", Constants.FAIL);
								map.put("msgDesc","예약일자 정보가 YYYY-MM-DD 형식에 맞지 않습니다.");
							}
						}
						
						if(true != ValidationCheckUtil.emptyCheck(reserveTime)){
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc","예약시간 정보가 없습니다.");
						}
						else {
							if(true != ValidationCheckUtil.timeCheck(reserveTime)){
								check = false;
								map.put("msgCode", Constants.FAIL);
								map.put("msgDesc","예약시간 정보가 HH:mm 형식에 맞지 않습니다.");
							}
						}
						
						if(true != ValidationCheckUtil.emptyCheck(reserveCategoryItemCode)){
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc","예약경로 정보가 없습니다.");
						}
						
						if(true != ValidationCheckUtil.emptyCheck(muTreatmentProcedureId)){
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc","진료시술 정보가 없습니다.");
						}
						
						if(true != ValidationCheckUtil.emptyCheck(reserveMemberId)){
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc","닥터/상담자 정보가 없습니다.");
						}

						if (!uniqueCombinations.add(combination)) {
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc","중복된 예약이 존재합니다.");
						}
	
						if(true == check){
							// 예약 중복 확인
							HashMap<String, Object> selectParamMap = new HashMap<String, Object>();
							selectParamMap.put("reserveDate", reserveDate);
							selectParamMap.put("reserveTime", reserveTime);
							selectParamMap.put("userName", userName);
							selectParamMap.put("phoneNumber", paramMap.get("phoneNumber"));
							selectParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
							selectParamMap.put("reserveMemberId", reserveMemberId);
							List<Map<String, Object>> reserveYnList = webReserveSqlMapDAO.selectListReserveYn(selectParamMap);
							
							if(0 == reserveYnList.size()) {
								
							}
							else {
								check = false;
								map.put("msgCode", Constants.FAIL);
								map.put("msgDesc", "해당시간에 진료예약건이 있습니다.");
							}
						}
						if(true == check){
							// 타임당 예약 건수 확인
							HashMap<String, Object> selectReserveCountMap = new HashMap<String, Object>();
							selectReserveCountMap.put("reserveDate", reserveDate);
							selectReserveCountMap.put("reserveTime", reserveTime);
							int reserveCount = webReserveSqlMapDAO.selectReserveCount(selectReserveCountMap);

							if(30 > reserveCount) {

							}
							else {
								check = false;
								map.put("msgCode", Constants.FAIL);
								map.put("msgDesc", "예약 가능 건수를 초과하였습니다.");
							}
						}
						if(true == check){
							// 휴일 확인
							HashMap<String, Object> selectHolidayMap = new HashMap<String, Object>();
							selectHolidayMap.put("searchDate", reserveDate);
							List<Map<String, Object>> hospitalListMap = webHospitalSqlMapDAO.selectHospitalWeek(selectHolidayMap);

							if(1 == hospitalListMap.size()) {
								String openYn = String.valueOf(hospitalListMap.get(0).get("openYn"));
								String holidayYn = String.valueOf(hospitalListMap.get(0).get("holidayYn"));

								if(("N").equals(openYn)||("Y").equals(holidayYn)){
									check = false;
									map.put("msgCode", Constants.FAIL);
									map.put("msgDesc", "운영시간이 아닙니다.");
								}
							}
						}
					}
				}
			}
			
			if(true == check){
				paramMap.put("tDate", tDate);
				paramMap.put("tId", tId);

				// 자동발송 (알림톡 + 푸시)
				// 템플릿 조회
				HashMap<String, Object> insertKakaoMap = new HashMap<String, Object>();
				insertKakaoMap.put("templateCode", "024110000457");
				List<Map<String, Object>> templateListMap = webKakaoTemplateSqlMapDAO.selectKakaoTemplate(insertKakaoMap);

				// 디바이스 리스트 조회
				List<Map<String, Object>> deviceListMap = webDeviceSqlMapDAO.selectListDevice2(paramMap);
				int deviceListMapSize = deviceListMap.size();

				// 고객명, 예약날짜, 예약시간, 시술명
				String KakaoTemplateTitle = String.valueOf(templateListMap.get(0).get("title"));
				String KakaoTemplateContent = String.valueOf(templateListMap.get(0).get("content"));

				JSONArray detailArray = (JSONArray) jsonObjectTemp.get("data");
				
				for(int i=0; i<detailArray.size(); i++){
					JSONObject detailObject = (JSONObject) detailArray.get(i);
					
					String reserveDate            = String.valueOf(detailObject.get("reserveDate"));
					String reserveTime            = String.valueOf(detailObject.get("reserveTime"));
					String reserveCategoryItemCode  = String.valueOf(detailObject.get("reserveCategoryItemCode"));
					String reserveCategoryItemName  = String.valueOf(detailObject.get("reserveCategoryItemName"));
					String muTreatmentProcedureId = String.valueOf(detailObject.get("muTreatmentProcedureId"));
					String reserveMemberId        = String.valueOf(detailObject.get("reserveMemberId"));
					String etc                    = String.valueOf(detailObject.get("etc"));
					
					// 시술 정보 조회
					HashMap<String, Object> treatmentProcedureParamMap = new HashMap<String, Object>();
					treatmentProcedureParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
					List<Map<String, Object>> treatmentProcedureList = webTreatmentProcedureSqlMapDAO.selectTreatmentProcedure2(treatmentProcedureParamMap);
					
					if(1==treatmentProcedureList.size()) {
						String treatmentProcedureId   = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentProcedureId"));
						String treatmentProcedureName = String.valueOf(treatmentProcedureList.get(0).get("treatmentProcedureName"));
						String treatmentId            = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentId"));
						String treatmentName          = String.valueOf(treatmentProcedureList.get(0).get("treatmentName"));
						
						String muReserveId = ("R").concat(String.valueOf(System.currentTimeMillis()));
						paramMap.put("muReserveId",muReserveId);
						paramMap.put("reserveDate", reserveDate);
						paramMap.put("reserveTime", reserveTime);
						paramMap.put("reserveCategoryItemCode", reserveCategoryItemCode);
						paramMap.put("reserveCategoryItemName", reserveCategoryItemName);
						paramMap.put("muTreatmentProcedureId", treatmentProcedureId);
						paramMap.put("treatmentProcedureName", treatmentProcedureName);
						paramMap.put("muTreatmentId", treatmentId);
						paramMap.put("treatmentName", treatmentName);
						paramMap.put("reserveMemberId", reserveMemberId);
						paramMap.put("etc", etc);
						paramMap.put("status", "T");
						paramMap.put("status2", "N");
						webReserveSqlMapDAO.insertReserve(paramMap);
						paramMap.put("muReserveId",paramMap.get("id"));
						
						// 상담차트 등록
						List<Map<String, Object>> userConsultingChartNumberList = webUserConsultingChartSqlMapDAO.selectUserConsultingChartNumber(paramMap);
						String chartNumber1 = String.valueOf(userConsultingChartNumberList.get(0).get("chartNumber"));
						
						String muUserConsultingChartId = ("UCC").concat(String.valueOf(System.currentTimeMillis()));
						paramMap.put("muUserConsultingChartId",muUserConsultingChartId);
						paramMap.put("chartNumber",chartNumber1);
						webUserConsultingChartSqlMapDAO.insertUserConsultingChart(paramMap); 
						
						// 시술차트 등록
						List<Map<String, Object>> userMedicalChartNumberList = webUserMedicalChartSqlMapDAO.selectUserMedicalChartNumber(paramMap);
						String chartNumber2 = String.valueOf(userMedicalChartNumberList.get(0).get("chartNumber"));
						
						String muUserMedicalChartId = ("UMC").concat(String.valueOf(System.currentTimeMillis()));
						paramMap.put("muUserMedicalChartId",muUserMedicalChartId);
						paramMap.put("chartNumber",chartNumber2);
						webUserMedicalChartSqlMapDAO.insertUserMedicalChart(paramMap);



						// 자동발송 (알림톡 + 푸시)
						// 고객명, 예약날짜, 예약시간, 시술명
						String kakaoContent = KakaoTemplateContent;
						kakaoContent = kakaoContent.replace("#{고객명}", userName);
						kakaoContent = kakaoContent.replace("#{예약날짜}", reserveDate);
						kakaoContent = kakaoContent.replace("#{예약시간}", reserveTime);
						kakaoContent = kakaoContent.replace("#{시술명}", treatmentName.concat("-").concat(treatmentProcedureName));


						insertKakaoMap.put("muKakaoId", ("K").concat(String.valueOf(System.currentTimeMillis())));
						insertKakaoMap.put("muUserId", paramMap.get("muUserId"));
						insertKakaoMap.put("userName", paramMap.get("userName"));
						insertKakaoMap.put("phoneNumber", paramMap.get("phoneNumber"));
						insertKakaoMap.put("content", kakaoContent);
						insertKakaoMap.put("state", "R");
						insertKakaoMap.put("popbillState", "0");
						insertKakaoMap.put("sender", senderPhoneNumber);
						insertKakaoMap.put("regId", "SYSTEM");
						insertKakaoMap.put("modId", "SYSTEM");
						insertKakaoMap.put("tId", paramMap.get("tId"));
						insertKakaoMap.put("tDate", paramMap.get("tDate"));

						webKakaoSqlMapDAO.insertKakao(insertKakaoMap);
//						autoKakaoService.send("reserve", insertKakaoMap);

						// 푸시
						if(0<deviceListMapSize){
							HashMap<String, Object> insertPushMap = new HashMap<String, Object>();
							for(int j=0; j<deviceListMapSize; j++){
								insertPushMap.put("muPushId", ("P").concat(String.valueOf(System.currentTimeMillis())));
								insertPushMap.put("muUserId", paramMap.get("muUserId"));
								insertPushMap.put("userName", paramMap.get("userName"));
								insertPushMap.put("muDeviceId", deviceListMap.get(j).get("muDeviceId"));
								insertPushMap.put("deviceUuid", deviceListMap.get(j).get("deviceUuid"));
								insertPushMap.put("pushKey", deviceListMap.get(j).get("pushKey"));
								insertPushMap.put("pushType", "A");
								insertPushMap.put("phoneType", deviceListMap.get(j).get("phoneType"));
								insertPushMap.put("title", KakaoTemplateTitle);
								insertPushMap.put("content", kakaoContent);
								insertPushMap.put("state", "R");
								insertPushMap.put("regId", "SYSTEM");
								insertPushMap.put("modId", "SYSTEM");
								insertPushMap.put("tId", paramMap.get("tId"));
								insertPushMap.put("tDate", paramMap.get("tDate"));

								webPushSqlMapDAO.insertPush(insertPushMap);
//								autoPushService.send("reserve", insertPushMap);
							}
						}
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "시술 정보가 없습니다.");
						
						throw new Exception("시술 정보가 없습니다.");
					}
				}
				
				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "등록되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl insertReserve END");
		return map;
	}
	
	/**
	 * 예약현황 정보 등록 (간편예약, 고객 등록(임시))
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> insertReserveSimple(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebReserveServiceImpl insertReserveSimple START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("userName                :"+paramMap.get("userName"));
		log.debug("phoneNumber             :"+paramMap.get("phoneNumber"));
		log.debug("birthday                :"+paramMap.get("birthday"));
		log.debug("reserveDate             :"+paramMap.get("reserveDate"));
		log.debug("reserveTime             :"+paramMap.get("reserveTime"));
		log.debug("reserveCategoryItemCode :"+paramMap.get("reserveCategoryItemCode"));
		log.debug("reserveCategoryItemName :"+paramMap.get("reserveCategoryItemName"));
		log.debug("muTreatmentProcedureId  :"+paramMap.get("muTreatmentProcedureId"));
		log.debug("reserveMemberId         :"+paramMap.get("etc"));
		log.debug("muMemberId              :"+paramMap.get("muMemberId"));

		try{
			boolean check  = true;
			String tId = String.valueOf(System.currentTimeMillis());
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Calendar c1 = Calendar.getInstance();
			String tDate = sdf.format(c1.getTime());

			String userName                = String.valueOf(paramMap.get("userName"));
			String phoneNumber             = String.valueOf(paramMap.get("phoneNumber"));
			String birthday                = String.valueOf(paramMap.get("birthday"));
			String reserveDate             = String.valueOf(paramMap.get("reserveDate"));
			String reserveTime             = String.valueOf(paramMap.get("reserveTime"));
			String reserveCategoryItemCode = String.valueOf(paramMap.get("reserveCategoryItemCode"));
			String reserveCategoryItemName = String.valueOf(paramMap.get("reserveCategoryItemName"));
			String muTreatmentProcedureId  = String.valueOf(paramMap.get("muTreatmentProcedureId"));
			String etc                     = String.valueOf(paramMap.get("etc"));
			String muMemberId              = String.valueOf(paramMap.get("muMemberId"));
			String reserveMemberId         = String.valueOf(paramMap.get("reserveMemberId"));

			if(true != ValidationCheckUtil.emptyCheck(userName)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객명 정보가 없습니다.");
			}
			else{
				if(true != ValidationCheckUtil.lengthCheck(userName,255)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","고객명 정보는 255자를 넘을 수 없습니다.");
				}
			}
			
			if(true != ValidationCheckUtil.emptyCheck(phoneNumber)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","연락처 정보가 없습니다.");
			}
			else{
				if(true != ValidationCheckUtil.phoneNumberCheck(phoneNumber)) {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","연락처 정보가 올바르지 않습니다.");
				}
				else if(true != ValidationCheckUtil.lengthCheck(phoneNumber,255)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","연락처 정보는 255자를 넘을 수 없습니다.");
				}
			}

			if(true != ValidationCheckUtil.emptyCheck(birthday)){
				birthday = null;
			}

			if(true != ValidationCheckUtil.emptyCheck(reserveDate)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약일자 정보가 없습니다.");
			}
			else {
				if(true != ValidationCheckUtil.dateCheck(reserveDate)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","예약일자 정보가 YYYY-MM-DD 형식에 맞지 않습니다.");
				}
			}
			
			if(true != ValidationCheckUtil.emptyCheck(reserveTime)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약시간 정보가 없습니다.");
			}
			else {
				if(true != ValidationCheckUtil.timeCheck(reserveTime)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","예약시간 정보가 HH:mm 형식에 맞지 않습니다.");
				}
			}
			
			if(true != ValidationCheckUtil.emptyCheck(reserveCategoryItemCode)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약경로 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(muTreatmentProcedureId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","진료시술 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(muMemberId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","담당자 정보가 없습니다.");
			}
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}

			if(true == check){
				// 예약 중복 확인
				HashMap<String, Object> selectParamMap = new HashMap<String, Object>();
				selectParamMap.put("reserveDate", reserveDate);
				selectParamMap.put("reserveTime", reserveTime);
				selectParamMap.put("userName", userName);
				selectParamMap.put("phoneNumber", phoneNumber);
				selectParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
				selectParamMap.put("reserveMemberId", reserveMemberId);
				List<Map<String, Object>> reserveYnList = webReserveSqlMapDAO.selectListReserveYn(selectParamMap);
				
				if(0 == reserveYnList.size()) {
					
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "해당시간에 진료예약건이 있습니다.");
				}
			}
			if(true == check){
				// 타임당 예약 건수 확인
				HashMap<String, Object> selectReserveCountMap = new HashMap<String, Object>();
				selectReserveCountMap.put("reserveDate", reserveDate);
				selectReserveCountMap.put("reserveTime", reserveTime);
				int reserveCount = webReserveSqlMapDAO.selectReserveCount(selectReserveCountMap);

				if(30 > reserveCount) {

				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "예약 가능 건수를 초과하였습니다.");
				}
			}
			
			if(true == check){
				// 고객 정보 조회 (등록 여부 확인, 고객명/전화번호로 확인)
				List<Map<String, Object>> userList = webUserSqlMapDAO.selectUserId(paramMap);
				
				if(1==userList.size()) {
					// 기존 고객으로 예약경로리
					paramMap.put("muUserId", userList.get(0).get("muUserId"));
				}
				else {
					// 간편예약 고객 등록
					String muUserId = ("U").concat(String.valueOf(System.currentTimeMillis()));
					paramMap.put("muUserId", muUserId);
					paramMap.put("birthday", birthday);
					paramMap.put("tDate", tDate);
					paramMap.put("tId", tId);
					webUserSqlMapDAO.insertUserTemp(paramMap);
					paramMap.put("muUserId", paramMap.get("id"));
				}
			}
			
			if(true == check){
				paramMap.put("tDate", tDate);
				paramMap.put("tId", tId);

				// 자동발송 (알림톡 + 푸시)
				// 템플릿 조회
				HashMap<String, Object> insertKakaoMap = new HashMap<String, Object>();
				insertKakaoMap.put("templateCode", "024110000457");
				List<Map<String, Object>> templateListMap = webKakaoTemplateSqlMapDAO.selectKakaoTemplate(insertKakaoMap);

				// 디바이스 리스트 조회
				List<Map<String, Object>> deviceListMap = webDeviceSqlMapDAO.selectListDevice2(paramMap);
				int deviceListMapSize = deviceListMap.size();

				// 고객명, 예약날짜, 예약시간, 시술명
				String KakaoTemplateTitle = String.valueOf(templateListMap.get(0).get("title"));
				String KakaoTemplateContent = String.valueOf(templateListMap.get(0).get("content"));

				// 시술 정보 조회
				HashMap<String, Object> treatmentProcedureParamMap = new HashMap<String, Object>();
				treatmentProcedureParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
				List<Map<String, Object>> treatmentProcedureList = webTreatmentProcedureSqlMapDAO.selectTreatmentProcedure2(treatmentProcedureParamMap);
				
				if(1==treatmentProcedureList.size()) {
					String treatmentProcedureId   = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentProcedureId"));
					String treatmentProcedureName = String.valueOf(treatmentProcedureList.get(0).get("treatmentProcedureName"));
					String treatmentId            = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentId"));
					String treatmentName          = String.valueOf(treatmentProcedureList.get(0).get("treatmentName"));
					
					String muReserveId = ("R").concat(String.valueOf(System.currentTimeMillis()));
					paramMap.put("muReserveId",muReserveId);
					paramMap.put("muTreatmentProcedureId", treatmentProcedureId);
					paramMap.put("treatmentProcedureName", treatmentProcedureName);
					paramMap.put("muTreatmentId", treatmentId);
					paramMap.put("treatmentName", treatmentName);
					paramMap.put("muMemberId", paramMap.get("loginMemberId"));
					paramMap.put("status", "T");
					paramMap.put("status2", "N");
					webReserveSqlMapDAO.insertReserve(paramMap);
					log.debug("muReserveId :"+paramMap.get("id"));
					paramMap.put("muReserveId", paramMap.get("id"));
					map.put("muReserveId", paramMap.get("muReserveId"));
					
					// 상담차트 등록
					List<Map<String, Object>> userConsultingChartNumberList = webUserConsultingChartSqlMapDAO.selectUserConsultingChartNumber(paramMap);
					String chartNumber1 = String.valueOf(userConsultingChartNumberList.get(0).get("chartNumber"));
					
					String muUserConsultingChartId = ("UCC").concat(String.valueOf(System.currentTimeMillis()));
					paramMap.put("muUserConsultingChartId",muUserConsultingChartId);
					paramMap.put("chartNumber",chartNumber1);
					webUserConsultingChartSqlMapDAO.insertUserConsultingChart(paramMap); 
					
					// 시술차트 등록
					List<Map<String, Object>> userMedicalChartNumberList = webUserMedicalChartSqlMapDAO.selectUserMedicalChartNumber(paramMap);
					String chartNumber2 = String.valueOf(userMedicalChartNumberList.get(0).get("chartNumber"));
					
					String muUserMedicalChartId = ("UMC").concat(String.valueOf(System.currentTimeMillis()));
					paramMap.put("muUserMedicalChartId",muUserMedicalChartId);
					paramMap.put("chartNumber",chartNumber2);
					webUserMedicalChartSqlMapDAO.insertUserMedicalChart(paramMap);



					// 자동발송 (알림톡 + 푸시)
					// 고객명, 예약날짜, 예약시간, 시술명
					String kakaoContent = KakaoTemplateContent;
					kakaoContent = kakaoContent.replace("#{고객명}", userName);
					kakaoContent = kakaoContent.replace("#{예약날짜}", reserveDate);
					kakaoContent = kakaoContent.replace("#{예약시간}", reserveTime);
					kakaoContent = kakaoContent.replace("#{시술명}", treatmentName.concat("-").concat(treatmentProcedureName));


					insertKakaoMap.put("muKakaoId", ("K").concat(String.valueOf(System.currentTimeMillis())));
					insertKakaoMap.put("muUserId", paramMap.get("muUserId"));
					insertKakaoMap.put("userName", paramMap.get("userName"));
					insertKakaoMap.put("phoneNumber", paramMap.get("phoneNumber"));
					insertKakaoMap.put("content", kakaoContent);
					insertKakaoMap.put("state", "R");
					insertKakaoMap.put("popbillState", "0");
					insertKakaoMap.put("sender", senderPhoneNumber);
					insertKakaoMap.put("regId", "SYSTEM");
					insertKakaoMap.put("modId", "SYSTEM");
					insertKakaoMap.put("tId", paramMap.get("tId"));
					insertKakaoMap.put("tDate", paramMap.get("tDate"));

					webKakaoSqlMapDAO.insertKakao(insertKakaoMap);
//					autoKakaoService.send("reserve", insertKakaoMap);

					// 푸시
					if(0<deviceListMapSize){
						HashMap<String, Object> insertPushMap = new HashMap<String, Object>();
						for(int j=0; j<deviceListMapSize; j++){
							insertPushMap.put("muPushId", ("P").concat(String.valueOf(System.currentTimeMillis())));
							insertPushMap.put("muUserId", paramMap.get("muUserId"));
							insertPushMap.put("userName", paramMap.get("userName"));
							insertPushMap.put("muDeviceId", deviceListMap.get(j).get("muDeviceId"));
							insertPushMap.put("deviceUuid", deviceListMap.get(j).get("deviceUuid"));
							insertPushMap.put("pushKey", deviceListMap.get(j).get("pushKey"));
							insertPushMap.put("pushType", "A");
							insertPushMap.put("phoneType", deviceListMap.get(j).get("phoneType"));
							insertPushMap.put("title", KakaoTemplateTitle);
							insertPushMap.put("content", kakaoContent);
							insertPushMap.put("state", "R");
							insertPushMap.put("regId", "SYSTEM");
							insertPushMap.put("modId", "SYSTEM");
							insertPushMap.put("tId", paramMap.get("tId"));
							insertPushMap.put("tDate", paramMap.get("tDate"));

							webPushSqlMapDAO.insertPush(insertPushMap);
//							autoPushService.send("reserve", insertPushMap);
						}
					}
					
					map.put("msgCode", Constants.OK);
					map.put("msgDesc", "등록되었습니다.");
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "시술 정보가 없습니다.");
					
					throw new Exception("시술 정보가 없습니다.");
				}
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl insertReserveSimple END");
		return map;
	}
	
	/**
	 * 예약현황 정보 등록 (바로접수)
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> insertReserveReady(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebReserveServiceImpl insertReserveReady START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muUserId                :"+paramMap.get("muUserId"));
		log.debug("userName                :"+paramMap.get("userName"));
		log.debug("reserveDate             :"+paramMap.get("reserveDate"));
		log.debug("reserveTime             :"+paramMap.get("reserveTime"));
		log.debug("reserveCategoryItemId   :"+paramMap.get("reserveCategoryItemId"));
		log.debug("muTreatmentProcedureId  :"+paramMap.get("muTreatmentProcedureId"));
		log.debug("reserveMemberId         :"+paramMap.get("etc"));
		log.debug("muMemberId              :"+paramMap.get("muMemberId"));

		try{
			boolean check  = true;
			String tId = String.valueOf(System.currentTimeMillis());
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Calendar c1 = Calendar.getInstance();
			String tDate = sdf.format(c1.getTime());

			String muUserId               = String.valueOf(paramMap.get("muUserId"));
			String userName               = String.valueOf(paramMap.get("userName"));
			String reserveDate            = String.valueOf(paramMap.get("reserveDate"));
			String reserveTime            = String.valueOf(paramMap.get("reserveTime"));
			String reserveCategoryItemCode  = String.valueOf(paramMap.get("reserveCategoryItemCode"));
			String reserveCategoryItemName  = String.valueOf(paramMap.get("reserveCategoryItemName"));
			String muTreatmentProcedureId = String.valueOf(paramMap.get("muTreatmentProcedureId"));
			String etc                    = String.valueOf(paramMap.get("etc"));
			String muMemberId             = String.valueOf(paramMap.get("muMemberId"));
			
			if(true != ValidationCheckUtil.emptyCheck(muUserId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객 식별자 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(userName)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객명 정보가 없습니다.");
			}
			else{
				if(true != ValidationCheckUtil.lengthCheck(userName,255)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","고객명 정보는 255자를 넘을 수 없습니다.");
				}
			}
			
			if(true != ValidationCheckUtil.emptyCheck(reserveDate)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약일자 정보가 없습니다.");
			}
			else {
				if(true != ValidationCheckUtil.dateCheck(reserveDate)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","예약일자 정보가 YYYY-MM-DD 형식에 맞지 않습니다.");
				}
			}
			
			if(true != ValidationCheckUtil.emptyCheck(reserveTime)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약시간 정보가 없습니다.");
			}
			else {
				if(true != ValidationCheckUtil.timeCheck(reserveTime)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","예약시간 정보가 HH:mm 형식에 맞지 않습니다.");
				}
			}
			
			if(true != ValidationCheckUtil.emptyCheck(reserveCategoryItemCode)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약경로 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(muTreatmentProcedureId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","진료시술 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(muMemberId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","담당자 정보가 없습니다.");
			}
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}

			if(true == check){
				// 고객정보 확인
				List<Map<String, Object>> userList = webUserSqlMapDAO.selectUser(paramMap);
				
				if(1==userList.size()) {
					paramMap.put("phoneNumber", userList.get(0).get("phoneNumber"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "고객 정보가 없습니다.");
				}
			}
			
			if(true == check){
				paramMap.put("tDate", tDate);
				paramMap.put("tId", tId);
				
				// 시술 정보 조회
				HashMap<String, Object> treatmentProcedureParamMap = new HashMap<String, Object>();
				treatmentProcedureParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
				List<Map<String, Object>> treatmentProcedureList = webTreatmentProcedureSqlMapDAO.selectTreatmentProcedure2(treatmentProcedureParamMap);
				
				if(1==treatmentProcedureList.size()) {
					String treatmentProcedureId   = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentProcedureId"));
					String treatmentProcedureName = String.valueOf(treatmentProcedureList.get(0).get("treatmentProcedureName"));
					String treatmentId            = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentId"));
					String treatmentName          = String.valueOf(treatmentProcedureList.get(0).get("treatmentName"));
					
					String muReserveId = ("R").concat(String.valueOf(System.currentTimeMillis()));
					paramMap.put("muReserveId",muReserveId);
					paramMap.put("muTreatmentProcedureId", treatmentProcedureId);
					paramMap.put("treatmentProcedureName", treatmentProcedureName);
					paramMap.put("muTreatmentId", treatmentId);
					paramMap.put("treatmentName", treatmentName);
					paramMap.put("muMemberId", paramMap.get("loginMemberId"));
					paramMap.put("status", "R");
					paramMap.put("status2", "N");
					webReserveSqlMapDAO.insertReserve(paramMap);
					log.debug("muReserveId :"+paramMap.get("id"));
					paramMap.put("muReserveId", paramMap.get("id"));
					map.put("muReserveId", paramMap.get("muReserveId"));
					
					// 상담차트 등록
					List<Map<String, Object>> userConsultingChartNumberList = webUserConsultingChartSqlMapDAO.selectUserConsultingChartNumber(paramMap);
					String chartNumber1 = String.valueOf(userConsultingChartNumberList.get(0).get("chartNumber"));
					
					String muUserConsultingChartId = ("UCC").concat(String.valueOf(System.currentTimeMillis()));
					paramMap.put("muUserConsultingChartId",muUserConsultingChartId);
					paramMap.put("chartNumber",chartNumber1);
					webUserConsultingChartSqlMapDAO.insertUserConsultingChart(paramMap); 
					
					// 시술차트 등록
					List<Map<String, Object>> userMedicalChartNumberList = webUserMedicalChartSqlMapDAO.selectUserMedicalChartNumber(paramMap);
					String chartNumber2 = String.valueOf(userMedicalChartNumberList.get(0).get("chartNumber"));
					
					String muUserMedicalChartId = ("UMC").concat(String.valueOf(System.currentTimeMillis()));
					paramMap.put("muUserMedicalChartId",muUserMedicalChartId);
					paramMap.put("chartNumber",chartNumber2);
					webUserMedicalChartSqlMapDAO.insertUserMedicalChart(paramMap);
										
					map.put("msgCode", Constants.OK);
					map.put("msgDesc", "등록되었습니다.");
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "시술 정보가 없습니다.");
					
					throw new Exception("시술 정보가 없습니다.");
				}
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl insertReserveReady END");
		return map;
	}
	
	/**
	 * 예약현황 정보 수정
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("finally")
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> updateReserve(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebReserveServiceImpl updateReserve START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));

		log.debug("userName            :"+paramMap.get("userName"));
		log.debug("muUserId            :"+paramMap.get("muUserId"));
		log.debug("phoneNumber         :"+paramMap.get("phoneNumber"));
		log.debug("muMemberId          :"+paramMap.get("muMemberId"));
		log.debug("reserveRows         :"+paramMap.get("reserveRows"));

		try{
			boolean check  = true;
			String tId = String.valueOf(System.currentTimeMillis());
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Calendar c1 = Calendar.getInstance();
			String tDate = sdf.format(c1.getTime());

			String userName               = String.valueOf(paramMap.get("userName"));
			String phoneNumber            = String.valueOf(paramMap.get("phoneNumber"));
			String muUserId               = String.valueOf(paramMap.get("muUserId"));
			String muMemberId             = String.valueOf(paramMap.get("muMemberId"));
			
			if(true != ValidationCheckUtil.emptyCheck(muUserId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객 식별자 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(userName)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","고객명 정보가 없습니다.");
			}
			else{
				if(true != ValidationCheckUtil.lengthCheck(userName,255)){
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc","고객명 정보는 255자를 넘을 수 없습니다.");
				}
			}
			
			if(true != ValidationCheckUtil.emptyCheck(muMemberId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","담당자 정보가 없습니다.");
			}

			// 예약정보 확인
			JSONParser jsonParserTemp = new JSONParser();
			JSONObject jsonObjectTemp = (JSONObject) jsonParserTemp.parse(String.valueOf(paramMap.get("reserveRows")));
			if(true == jsonObjectTemp.isEmpty()) {
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약 정보가 없습니다.");
			}
			else {
				JSONArray detailArray = (JSONArray) jsonObjectTemp.get("data");
				Set<String> uniqueCombinations = new HashSet<>();

				for(int j=0; j<detailArray.size(); j++){
					JSONObject detailObject = (JSONObject) detailArray.get(j);

					String reserveDate            = String.valueOf(detailObject.get("reserveDate"));
					String reserveTime            = String.valueOf(detailObject.get("reserveTime"));
					String reserveCategoryItemCode  = String.valueOf(detailObject.get("reserveCategoryItemCode"));
					String muTreatmentProcedureId = String.valueOf(detailObject.get("muTreatmentProcedureId"));
					String reserveMemberId        = String.valueOf(detailObject.get("reserveMemberId"));
					String etc                    = String.valueOf(detailObject.get("etc"));
					String combination 			  = reserveDate + "_" +reserveTime + "_" +muTreatmentProcedureId;
					String muReserveId 			  = String.valueOf(detailObject.get("muReserveId"));

					if(true != ValidationCheckUtil.emptyCheck(reserveDate)){
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc","예약일자 정보가 없습니다.");
					}
					else {
						if(true != ValidationCheckUtil.dateCheck(reserveDate)){
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc","예약일자 정보가 YYYY-MM-DD 형식에 맞지 않습니다.");
						}
					}
					
					if(true != ValidationCheckUtil.emptyCheck(reserveTime)){
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc","예약시간 정보가 없습니다.");
					}
					else {
						if(true != ValidationCheckUtil.timeCheck(reserveTime)){
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc","예약시간 정보가 HH:mm 형식에 맞지 않습니다.");
						}
					}
					
					if(true != ValidationCheckUtil.emptyCheck(reserveCategoryItemCode)){
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc","예약경로 정보가 없습니다.");
					}
					
					if(true != ValidationCheckUtil.emptyCheck(muTreatmentProcedureId)){
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc","진료시술 정보가 없습니다.");
					}
					
					if(true != ValidationCheckUtil.emptyCheck(reserveMemberId)){
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc","닥터/상담자 정보가 없습니다.");
					}

					if (!uniqueCombinations.add(combination)) {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc","중복된 예약이 존재합니다.");
					}

					if(true == check){
						// 예약 중복 확인
						HashMap<String, Object> selectParamMap = new HashMap<String, Object>();
						selectParamMap.put("reserveDate", reserveDate);
						selectParamMap.put("reserveTime", reserveTime);
						selectParamMap.put("userName", userName);
						selectParamMap.put("phoneNumber", phoneNumber);
						selectParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
						selectParamMap.put("reserveMemberId", reserveMemberId);
						selectParamMap.put("muReserveId", muReserveId);
						List<Map<String, Object>> reserveYnList = webReserveSqlMapDAO.selectListReserveYn(selectParamMap);

						if(0 == reserveYnList.size()) {

						}
						else {
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc", "해당시간에 진료예약건이 있습니다.");
						}
					}

					if(true == check){
						// 타임당 예약 건수 확인
						HashMap<String, Object> selectReserveCountMap = new HashMap<String, Object>();
						selectReserveCountMap.put("reserveDate", reserveDate);
						selectReserveCountMap.put("reserveTime", reserveTime);
						int reserveCount = webReserveSqlMapDAO.selectReserveCount(selectReserveCountMap);

						if(30 > reserveCount) {

						}
						else {
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc", "예약 가능 건수를 초과하였습니다.");
						}
					}

					if(true == check){
						// 예약 조회
						HashMap<String, Object> selectParamMap = new HashMap<String, Object>();
						selectParamMap.put("reserveDate", reserveDate);
						selectParamMap.put("reserveTime", reserveTime);
						selectParamMap.put("userName", userName);
						selectParamMap.put("phoneNumber", phoneNumber);
						selectParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
						selectParamMap.put("reserveMemberId", reserveMemberId);
						selectParamMap.put("muReserveId", muReserveId);
						List<Map<String, Object>> listMap = webReserveSqlMapDAO.selectReserve(selectParamMap);

						if(1==listMap.size()) {
							// 예약취소인지 체크
							String reserveStatus = String.valueOf(listMap.get(0).get("status"));
							if(("TN").equals(reserveStatus)){
								check = false;
								map.put("msgCode", Constants.FAIL);
								map.put("msgDesc", "예약취소된 예약건입니다.");
							}
						}else{
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc", "예약 정보가 없습니다.");
						}
					}
				}
			}
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
				
				if(1==authMenuRelationlistMapSize){
					
					if(("Y").equals(authMenuRelationlistMap.get(0).get("updateUseYn"))) {

					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "수정 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "권한 정보가 없습니다.");
				}
			}
			
			if(true == check){
				paramMap.put("tDate", tDate);
				paramMap.put("tId", tId);

				// 자동발송 (알림톡 + 푸시)
				// 템플릿 조회
				HashMap<String, Object> insertKakaoMap = new HashMap<String, Object>();
				insertKakaoMap.put("templateCode", "024110000457");
				List<Map<String, Object>> templateListMap = webKakaoTemplateSqlMapDAO.selectKakaoTemplate(insertKakaoMap);

				// 디바이스 리스트 조회
				List<Map<String, Object>> deviceListMap = webDeviceSqlMapDAO.selectListDevice2(paramMap);
				int deviceListMapSize = deviceListMap.size();

				// 고객명, 예약날짜, 예약시간, 시술명
				String KakaoTemplateTitle = String.valueOf(templateListMap.get(0).get("title"));
				String KakaoTemplateContent = String.valueOf(templateListMap.get(0).get("content"));

				JSONArray detailArray = (JSONArray) jsonObjectTemp.get("data");
				
				for(int i=0; i<detailArray.size(); i++){
					JSONObject detailObject = (JSONObject) detailArray.get(i);

					String reserveId              = String.valueOf(detailObject.get("muReserveId"));
					String reserveDate            = String.valueOf(detailObject.get("reserveDate"));
					String reserveTime            = String.valueOf(detailObject.get("reserveTime"));
					String reserveCategoryItemName  = String.valueOf(detailObject.get("reserveCategoryItemName"));
					String reserveCategoryItemCode  = String.valueOf(detailObject.get("reserveCategoryItemCode"));
					String muTreatmentProcedureId = String.valueOf(detailObject.get("muTreatmentProcedureId"));
					String reserveMemberId        = String.valueOf(detailObject.get("reserveMemberId"));
					String etc                    = String.valueOf(detailObject.get("etc"));
					
					// 시술 정보 조회
					HashMap<String, Object> treatmentProcedureParamMap = new HashMap<String, Object>();
					treatmentProcedureParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
					List<Map<String, Object>> treatmentProcedureList = webTreatmentProcedureSqlMapDAO.selectTreatmentProcedure2(treatmentProcedureParamMap);
					
					if(1==treatmentProcedureList.size()) {
						String treatmentProcedureId   = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentProcedureId"));
						String treatmentProcedureName = String.valueOf(treatmentProcedureList.get(0).get("treatmentProcedureName"));
						String treatmentId            = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentId"));
						String treatmentName          = String.valueOf(treatmentProcedureList.get(0).get("treatmentName"));
						
						if(true != ValidationCheckUtil.emptyCheck(reserveId)){
							// 등록
							HashMap<String, Object> reserveInsertParamMap = new HashMap<String, Object>();
							reserveId = ("R").concat(String.valueOf(System.currentTimeMillis()));
							reserveInsertParamMap.put("muReserveId",reserveId);
							reserveInsertParamMap.put("muUserId",muUserId);
							reserveInsertParamMap.put("userName",userName);
							reserveInsertParamMap.put("reserveDate", reserveDate);
							reserveInsertParamMap.put("reserveTime", reserveTime);
							reserveInsertParamMap.put("reserveCategoryItemCode", reserveCategoryItemCode);
							reserveInsertParamMap.put("reserveCategoryItemName", reserveCategoryItemName);
							reserveInsertParamMap.put("muTreatmentProcedureId", treatmentProcedureId);
							reserveInsertParamMap.put("treatmentProcedureName", treatmentProcedureName);
							reserveInsertParamMap.put("muTreatmentId", treatmentId);
							reserveInsertParamMap.put("treatmentName", treatmentName);
							reserveInsertParamMap.put("reserveMemberId", reserveMemberId);
							reserveInsertParamMap.put("muMemberId", muMemberId);
							reserveInsertParamMap.put("etc", etc);
							reserveInsertParamMap.put("status", "T");
							reserveInsertParamMap.put("status2", "N");
							reserveInsertParamMap.put("regId", paramMap.get("regId"));
							reserveInsertParamMap.put("modId", paramMap.get("modId"));
							webReserveSqlMapDAO.insertReserve(reserveInsertParamMap);
							reserveInsertParamMap.put("muReserveId", reserveInsertParamMap.get("id"));
							
							// 상담차트 등록
							List<Map<String, Object>> userConsultingChartNumberList = webUserConsultingChartSqlMapDAO.selectUserConsultingChartNumber(paramMap);
							String chartNumber1 = String.valueOf(userConsultingChartNumberList.get(0).get("chartNumber"));
							
							String muUserConsultingChartId = ("UCC").concat(String.valueOf(System.currentTimeMillis()));
							reserveInsertParamMap.put("muUserConsultingChartId",muUserConsultingChartId);
							reserveInsertParamMap.put("chartNumber",chartNumber1);
							webUserConsultingChartSqlMapDAO.insertUserConsultingChart(reserveInsertParamMap); 
							
							// 시술차트 등록
							List<Map<String, Object>> userMedicalChartNumberList = webUserMedicalChartSqlMapDAO.selectUserMedicalChartNumber(paramMap);
							String chartNumber2 = String.valueOf(userMedicalChartNumberList.get(0).get("chartNumber"));
							
							String muUserMedicalChartId = ("UMC").concat(String.valueOf(System.currentTimeMillis()));
							reserveInsertParamMap.put("muUserMedicalChartId",muUserMedicalChartId);
							reserveInsertParamMap.put("chartNumber",chartNumber2);
							webUserMedicalChartSqlMapDAO.insertUserMedicalChart(reserveInsertParamMap);

						}
						else {
							// 수정
							HashMap<String, Object> reserveUpdateParamMap = new HashMap<String, Object>();
							reserveUpdateParamMap.put("muReserveId",reserveId);
							reserveUpdateParamMap.put("reserveDate", reserveDate);
							reserveUpdateParamMap.put("reserveTime", reserveTime);
							reserveUpdateParamMap.put("reserveCategoryItemCode", reserveCategoryItemCode);
							reserveUpdateParamMap.put("reserveCategoryItemName", reserveCategoryItemName);
							reserveUpdateParamMap.put("muTreatmentProcedureId", treatmentProcedureId);
							reserveUpdateParamMap.put("treatmentProcedureName", treatmentProcedureName);
							reserveUpdateParamMap.put("muTreatmentId", treatmentId);
							reserveUpdateParamMap.put("treatmentName", treatmentName);
							reserveUpdateParamMap.put("reserveMemberId", reserveMemberId);
							reserveUpdateParamMap.put("muMemberId", muMemberId);
							reserveUpdateParamMap.put("etc", etc);
							reserveUpdateParamMap.put("modId", paramMap.get("modId"));
							webReserveSqlMapDAO.updateReserve(reserveUpdateParamMap);
						}



						// 자동발송 (알림톡 + 푸시)
						// 고객명, 예약날짜, 예약시간, 시술명
						String kakaoContent = KakaoTemplateContent;
						kakaoContent = kakaoContent.replace("#{고객명}", userName);
						kakaoContent = kakaoContent.replace("#{예약날짜}", reserveDate);
						kakaoContent = kakaoContent.replace("#{예약시간}", reserveTime);
						kakaoContent = kakaoContent.replace("#{시술명}", treatmentName.concat("-").concat(treatmentProcedureName));


						insertKakaoMap.put("muKakaoId", ("K").concat(String.valueOf(System.currentTimeMillis())));
						insertKakaoMap.put("muUserId", paramMap.get("muUserId"));
						insertKakaoMap.put("userName", paramMap.get("userName"));
						insertKakaoMap.put("phoneNumber", paramMap.get("phoneNumber"));
						insertKakaoMap.put("content", kakaoContent);
						insertKakaoMap.put("state", "R");
						insertKakaoMap.put("popbillState", "0");
						insertKakaoMap.put("sender", senderPhoneNumber);
						insertKakaoMap.put("regId", "SYSTEM");
						insertKakaoMap.put("modId", "SYSTEM");
						insertKakaoMap.put("tId", paramMap.get("tId"));
						insertKakaoMap.put("tDate", paramMap.get("tDate"));

						webKakaoSqlMapDAO.insertKakao(insertKakaoMap);
//						autoKakaoService.send("reserve", insertKakaoMap);

						// 푸시
						if(0<deviceListMapSize){
							HashMap<String, Object> insertPushMap = new HashMap<String, Object>();
							for(int j=0; j<deviceListMapSize; j++){
								insertPushMap.put("muPushId", ("P").concat(String.valueOf(System.currentTimeMillis())));
								insertPushMap.put("muUserId", paramMap.get("muUserId"));
								insertPushMap.put("userName", paramMap.get("userName"));
								insertPushMap.put("muDeviceId", deviceListMap.get(j).get("muDeviceId"));
								insertPushMap.put("deviceUuid", deviceListMap.get(j).get("deviceUuid"));
								insertPushMap.put("pushKey", deviceListMap.get(j).get("pushKey"));
								insertPushMap.put("pushType", "A");
								insertPushMap.put("phoneType", deviceListMap.get(j).get("phoneType"));
								insertPushMap.put("title", KakaoTemplateTitle);
								insertPushMap.put("content", kakaoContent);
								insertPushMap.put("state", "R");
								insertPushMap.put("regId", "SYSTEM");
								insertPushMap.put("modId", "SYSTEM");
								insertPushMap.put("tId", paramMap.get("tId"));
								insertPushMap.put("tDate", paramMap.get("tDate"));

								webPushSqlMapDAO.insertPush(insertPushMap);
//								autoPushService.send("reserve", insertPushMap);
							}
						}
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "시술 정보가 없습니다.");
						
						throw new Exception("시술 정보가 없습니다.");
					}
				}
				
				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "수정되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		finally {
			log.debug("WebReserveServiceImpl updateReserve END");
			return map;
		}
	}

	/**
	 * 예약현황 정보 상태 수정 (진료상태)
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> updateReserveStatus(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebReserveServiceImpl updateReserveStatus START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muReserveId         :"+paramMap.get("muReserveId"));
		
		log.debug("status              :"+paramMap.get("status"));

		try{
			boolean check  = true;
			String tId = String.valueOf(System.currentTimeMillis());
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Calendar c1 = Calendar.getInstance();
			String tDate = sdf.format(c1.getTime());
			paramMap.put("tId", tId);
			paramMap.put("tDate", tDate);

			String muReserveId       = String.valueOf(paramMap.get("muReserveId"));
			String status            = String.valueOf(paramMap.get("status"));
			String userName = "";
			String phoneNumber = "";
			String reserveDate = "";
			String reserveTime = "";
			String treatmentName = "";
			String treatmentProcedureName = "";

			if(true != ValidationCheckUtil.emptyCheck(muReserveId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약 식별자 정보가 없습니다.");
			}

			if(true != ValidationCheckUtil.emptyCheck(status)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","상태 정보가 없습니다.");
			}

			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
				
				if(1==authMenuRelationlistMapSize){
					
					if(("Y").equals(authMenuRelationlistMap.get(0).get("updateUseYn"))) {
						
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "수정 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "권한 정보가 없습니다.");
				}
			}
			
			if(true == check){
				// 예약 조회
				List<Map<String, Object>> listMap = webReserveSqlMapDAO.selectReserve(paramMap);

				if(1==listMap.size()) {
					paramMap.put("muUserId", listMap.get(0).get("muUserId"));
					paramMap.put("userName", listMap.get(0).get("userName"));
					paramMap.put("phoneNumber", listMap.get(0).get("phoneNumber"));
					paramMap.put("reserveDate", listMap.get(0).get("reserveDate"));
					paramMap.put("reserveTime", listMap.get(0).get("reserveTime"));
					paramMap.put("treatmentName", listMap.get(0).get("treatmentName"));
					paramMap.put("treatmentProcedureName", listMap.get(0).get("treatmentProcedureName"));
					userName = String.valueOf(listMap.get(0).get("userName"));
					phoneNumber = String.valueOf(listMap.get(0).get("phoneNumber"));
					reserveDate = String.valueOf(listMap.get(0).get("reserveDate"));
					reserveTime = String.valueOf(listMap.get(0).get("reserveTime"));
					treatmentName = String.valueOf(listMap.get(0).get("treatmentName"));
					treatmentProcedureName = String.valueOf(listMap.get(0).get("treatmentProcedureName"));

					// 예약취소인지 체크
					String reserveStatus = String.valueOf(listMap.get(0).get("status"));
					if(("TN").equals(reserveStatus)){
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "예약취소된 예약건입니다.");
					}
				}else{
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "예약 정보가 없습니다.");
				}
			}

			if(true == check){
				String msgCode = "";
				String msgDesc = "";

				// 수납완료시 수정 불가능
				List<Map<String, Object>> listMap = webPaymentSqlMapDAO.selectPaymentStatusCheck(paramMap);
				String checkStatus = "";
				int listMapSize = listMap.size();
				if(0<listMapSize){
					checkStatus = String.valueOf(listMap.get(0).get("status"));
				}

				if(("R").equals(status)) {
					webReserveSqlMapDAO.updateReserveReadyStatus(paramMap);

					webReserveSqlMapDAO.updateReserveStatus(paramMap);

					msgCode = Constants.OK;
					msgDesc = "처리되었습니다.";
				}else if(("Y").equals(status)){
					// 진료끝 상태일때 사용자 최근 내원일자 변경
					webUserSqlMapDAO.updateUserLastVisitDate(paramMap);

					webReserveSqlMapDAO.updateReserveStatus(paramMap);

					msgCode = Constants.OK;
					msgDesc = "처리되었습니다.";
				}else if(("TN").equals(status)){
					// 예약취소 시 시술차트 및 상담차트 삭제
					// 수납되면 변경 불가
					// 수납상태 결제취소, 환불, "" 일 때 수정 가능
					if(("C").equals(checkStatus) || ("R").equals(checkStatus) || ("").equals(checkStatus)){
						webUserMedicalChartSqlMapDAO.deleteUserMedicalChart(paramMap);
						webUserConsultingChartSqlMapDAO.deleteUserConsultingChart(paramMap);

						webReserveSqlMapDAO.updateReserveStatus(paramMap);


						// 자동발송 (알림톡 + 푸시)
						// 템플릿 조회
						HashMap<String, Object> insertKakaoMap = new HashMap<String, Object>();
						insertKakaoMap.put("templateCode", "024110000456");
						List<Map<String, Object>> templateListMap = webKakaoTemplateSqlMapDAO.selectKakaoTemplate(insertKakaoMap);

						// 디바이스 리스트 조회
						List<Map<String, Object>> deviceListMap = webDeviceSqlMapDAO.selectListDevice2(paramMap);
						int deviceListMapSize = deviceListMap.size();

						// 고객명, 예약날짜, 예약시간, 시술명
						String KakaoTemplateTitle = String.valueOf(templateListMap.get(0).get("title"));
						String KakaoTemplateContent = String.valueOf(templateListMap.get(0).get("content"));



						// 자동발송 (알림톡 + 푸시)
						// 고객명, 예약날짜, 예약시간, 시술명
						String kakaoContent = KakaoTemplateContent;
						kakaoContent = kakaoContent.replace("#{고객명}", userName);
						kakaoContent = kakaoContent.replace("#{예약날짜}", reserveDate);
						kakaoContent = kakaoContent.replace("#{예약시간}", reserveTime);
						kakaoContent = kakaoContent.replace("#{시술명}", treatmentName.concat("-").concat(treatmentProcedureName));


						insertKakaoMap.put("muKakaoId", ("K").concat(String.valueOf(System.currentTimeMillis())));
						insertKakaoMap.put("muUserId", paramMap.get("muUserId"));
						insertKakaoMap.put("userName", paramMap.get("userName"));
						insertKakaoMap.put("phoneNumber", paramMap.get("phoneNumber"));
						insertKakaoMap.put("content", kakaoContent);
						insertKakaoMap.put("state", "R");
						insertKakaoMap.put("popbillState", "0");
						insertKakaoMap.put("sender", senderPhoneNumber);
						insertKakaoMap.put("regId", "SYSTEM");
						insertKakaoMap.put("modId", "SYSTEM");
						insertKakaoMap.put("tId", paramMap.get("tId"));
						insertKakaoMap.put("tDate", paramMap.get("tDate"));

						webKakaoSqlMapDAO.insertKakao(insertKakaoMap);
//						autoKakaoService.send("reserve", insertKakaoMap);

						// 푸시
						if(0<deviceListMapSize){
							HashMap<String, Object> insertPushMap = new HashMap<String, Object>();
							for(int j=0; j<deviceListMapSize; j++){
								insertPushMap.put("muPushId", ("P").concat(String.valueOf(System.currentTimeMillis())));
								insertPushMap.put("muUserId", paramMap.get("muUserId"));
								insertPushMap.put("userName", paramMap.get("userName"));
								insertPushMap.put("muDeviceId", deviceListMap.get(j).get("muDeviceId"));
								insertPushMap.put("deviceUuid", deviceListMap.get(j).get("deviceUuid"));
								insertPushMap.put("pushKey", deviceListMap.get(j).get("pushKey"));
								insertPushMap.put("pushType", "A");
								insertPushMap.put("phoneType", deviceListMap.get(j).get("phoneType"));
								insertPushMap.put("title", KakaoTemplateTitle);
								insertPushMap.put("content", kakaoContent);
								insertPushMap.put("state", "R");
								insertPushMap.put("regId", "SYSTEM");
								insertPushMap.put("modId", "SYSTEM");
								insertPushMap.put("tId", paramMap.get("tId"));
								insertPushMap.put("tDate", paramMap.get("tDate"));

								webPushSqlMapDAO.insertPush(insertPushMap);
//								autoPushService.send("reserve", insertPushMap);
							}
						}



						msgCode = Constants.OK;
						msgDesc = "처리되었습니다.";
					}else{
						msgCode = Constants.FAIL;
						msgDesc = "수납이 되어 처리할 수 없습니다.";
					}

				}else if(("T").equals(status)){
					// 접수취소 -> 예약 상태로 변경
					// 수납되면 변경 불가
					// 수납상태 결제취소, 환불, "" 일 때 수정 가능
					if(("C").equals(checkStatus) || ("R").equals(checkStatus) || ("").equals(checkStatus)){
						webReserveSqlMapDAO.updateReserveStatus(paramMap);

						msgCode = Constants.OK;
						msgDesc = "처리되었습니다.";
					}else{
						msgCode = Constants.FAIL;
						msgDesc = "수납이 되어 처리할 수 없습니다.";
					}

				}else{
					webReserveSqlMapDAO.updateReserveStatus(paramMap);

					msgCode = Constants.OK;
					msgDesc = "처리되었습니다.";
				}
				map.put("muReserveId", paramMap.get("muReserveId"));

				map.put("msgCode", msgCode);
				map.put("msgDesc", msgDesc);
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl updateReserveStatus END");
		return map;
	}

	/**
	 * 예약현황 정보 상태 수정 (수납상태)
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> updateReserveStatus2(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebReserveServiceImpl updateReserveStatus2 START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muReserveId         :"+paramMap.get("muReserveId"));
		
		log.debug("status              :"+paramMap.get("status"));

		try{
			boolean check  = true;

			String muReserveId       = String.valueOf(paramMap.get("muReserveId"));
			String status            = String.valueOf(paramMap.get("status"));

			if(true != ValidationCheckUtil.emptyCheck(muReserveId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","예약 식별자 정보가 없습니다.");
			}

			if(true != ValidationCheckUtil.emptyCheck(status)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","상태 정보가 없습니다.");
			}

			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
				
				if(1==authMenuRelationlistMapSize){
					
					if(("Y").equals(authMenuRelationlistMap.get(0).get("updateUseYn"))) {
						
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "수정 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "권한 정보가 없습니다.");
				}
			}
			
			if(true == check){
				webReserveSqlMapDAO.updateReserveStatus2(paramMap);
				map.put("muReserveId", paramMap.get("muReserveId"));
				
				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "수정되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl updateReserveStatus2 END");
		return map;
	}

	/**
	 * 예약현황 정보 삭제
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> deleteReserve(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebReserveServiceImpl deleteReserve START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		// ,로 구분
		log.debug("selectId            :"+paramMap.get("selectId"));
		
		try{
			boolean check  = true;
			
			if(null== paramMap.get("selectId") || ("").equals(paramMap.get("selectId"))){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc", "삭제 대상이 없습니다.");
			}

			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 권한 조회
				HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
				authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
				authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
				List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
				
				if(1==authMenuRelationlistMapSize){
					
					if(("Y").equals(authMenuRelationlistMap.get(0).get("deleteUseYn"))) {
						
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "삭제 권한 정보가 없습니다.");
					}
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "권한 정보가 없습니다.");
				}
			}
			
			if(true == check){
				String selectId = String.valueOf(paramMap.get("selectId"));
				StringTokenizer selectData = new StringTokenizer(selectId, ",");
				while(selectData.hasMoreTokens()){//토큰이 계속 있을때 까지
					String muReserveId = selectData.nextToken();
					
					HashMap<String, Object> deleteParamMap = new HashMap<String, Object>();
					deleteParamMap.put("muReserveId", muReserveId);
					deleteParamMap.put("modId", paramMap.get("loginMemberId"));
					webReserveSqlMapDAO.deleteReserve(deleteParamMap);
				}
				
				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "삭제 되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		
		log.debug("WebReserveServiceImpl deleteReserve END");
		return map;
	}


	/**
	 * 예약 일괄 등록 (업로드 엑셀) 
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> uploadReserveExcel(
			HashMap<String, Object> paramMap, MultipartFile file) throws Exception {
		log.debug("WebReserveServiceImpl uploadReserveExcel START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		try{
			boolean check  = true;
			
			HashMap<String, Object> fileMap = new HashMap<String, Object>();
			fileMap = FileStoreUtil.checkFileExcel(file, true);
			
			boolean fileCheck = (Boolean) fileMap.get("check");
			if(check == true && fileCheck == true){
				// 결과값
				List<Map<String, Object>> listMap = new ArrayList<Map<String,Object>>();
				
				String tId = String.valueOf(System.currentTimeMillis());
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Calendar c1 = Calendar.getInstance();
				String tDate = sdf.format(c1.getTime());

				if(true == check){
					// 사용자 확인
					List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
					int userListMapSize = userListMap.size();

					if(1==userListMapSize){
						paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
					}
				}

				if(true == check){
					// 권한 조회
					HashMap<String, Object> authCheckParamMap = new HashMap<String, Object>();
					authCheckParamMap.put("menuClass",paramMap.get("menuClass"));
					authCheckParamMap.put("muAuthId",paramMap.get("menuClassAuthId"));
					List<Map<String, Object>> authMenuRelationlistMap = webAuthMenuRelationSqlMapDAO.selectAuthMenuRelation(authCheckParamMap);
					int authMenuRelationlistMapSize = authMenuRelationlistMap.size();

					if(1==authMenuRelationlistMapSize){

						if(("Y").equals(authMenuRelationlistMap.get(0).get("insertUseYn"))) {

						}
						else {
							check = false;
							map.put("msgCode", Constants.FAIL);
							map.put("msgDesc", "조회 권한 정보가 없습니다.");
						}
					}
					else {
						check = false;
						map.put("msgCode", Constants.FAIL);
						map.put("msgDesc", "권한 정보가 없습니다.");
					}
				}

				try {
					int cells = 11;
					List<String[]> list = new ArrayList<String[]>();
					Set<String> uniqueCombinations = new HashSet<>();

					String ext = (String) fileMap.get("ext");
					if(("xls").equals(ext)){
						list = ExcelUtil.readXls(file, 2, cells);
					}else if(("xlsx").equals(ext)){
						list = ExcelUtil.readXlsx(file, 2, cells);
					}
					
					int cnt = 0;
					for(String rows[]:list){
						log.debug("rows[]                      :"+rows.length);
						
						// 번호
						String number                          = rows[0];
						log.debug("number                      :"+number);
						
						// 예약일자
						String reserveDate                     = rows[1];
						log.debug("reserveDate                 :"+reserveDate);
						
						// 예약시간
						String reserveTime                     = rows[2];
						log.debug("reserveTime                 :"+reserveTime);
						
						// 예약경로 코드
						String reserveCategoryItemCode         = rows[3];
						String reserveCategoryItemName          = "";
						log.debug("reserveCategoryItemCode     :"+reserveCategoryItemCode);
						
						// 고객명
						String userName                        = rows[4];
						log.debug("userName                    :"+userName);
						
						// 연락처
						String phoneNumber                     = rows[5];
						log.debug("phoneNumber                 :"+phoneNumber);
						
						// 생년월일
//						String birthday                        = rows[6];
//						log.debug("birthday                    :"+birthday);
//
//						// 국적 코드
//						String nationalityCategoryItemCode     = rows[7];
//						String nationalityCategoryItemId       = "";
//						log.debug("nationalityCategoryItemCode :"+nationalityCategoryItemCode);
						
						// 진료유형(시술) 식별자
						String muTreatmentProcedureId          = rows[6];
						String treatmentProcedureName          = "";
						String muTreatmentId                   = "";
						String treatmentName                   = "";
						log.debug("muTreatmentProcedureId      :"+muTreatmentProcedureId);
						
						// 닥터/상담 사번 코드
						String reserveMemberCode               = rows[7];
						String reserveMemberId                 = "";
						log.debug("reserveMemberCode           :"+reserveMemberCode);
						
						// 예약메모
						String etc                             = (null==rows[8])?"":rows[8];
						log.debug("etc                         :"+etc);

						String combination 			  = reserveDate + "_" +reserveTime + "_" +phoneNumber+ "_" +userName+ "_" +muTreatmentProcedureId;
						
						// 형식 체크
						String rowCheck  = Constants.OK_ONE;
						String rowMsgDesc = "";

						if (!uniqueCombinations.add(combination)) {
							String msg = "중복된 예약이 존재합니다.";
							rowCheck     = Constants.FAIL;
							rowMsgDesc  += "- "+msg+"<br>";

							check = false;
							map.put("msgDesc", msg);
						}

						// 예약일자
						if(true != ValidationCheckUtil.emptyCheck(reserveDate)){
							String msg = "예약일자 정보가 누락되었습니다.";
							
							rowCheck     = Constants.FAIL;
							rowMsgDesc  += "- "+msg+"<br>";

							check = false;
							map.put("msgDesc", msg);
						}
						
						// 예약시간
						if(true != ValidationCheckUtil.emptyCheck(reserveTime)){
							String msg = "예약시간 정보가 누락되었습니다.";
							
							rowCheck     = Constants.FAIL;
							rowMsgDesc  += "- "+msg+"<br>";

							check = false;
							map.put("msgDesc", msg);
						}
						
						// 예약경로
						if(true != ValidationCheckUtil.emptyCheck(reserveCategoryItemCode)){
							String msg = "예약경로 정보가 누락되었습니다.";
							
							rowCheck     = Constants.FAIL;
							rowMsgDesc  += "- "+msg+"<br>";

							check = false;
							map.put("msgDesc", msg);
						}
						else {
							// 예약경로 정보 조회
							HashMap<String, Object> categoryItemParamMap = new HashMap<String, Object>();
							categoryItemParamMap.put("categoryItemCode", reserveCategoryItemCode);
							List<Map<String, Object>> categoryItemList = webCategorySqlMapDAO.selectCategoryItemId(categoryItemParamMap);
							
							if(1==categoryItemList.size()) {
								reserveCategoryItemName = String.valueOf(categoryItemList.get(0).get("categoryItemName"));
							}
							else {
								String msg = "등록된 예약경로 정보가 없습니다.";
								
								rowCheck     = Constants.FAIL;
								rowMsgDesc  += "- "+msg+"<br>";

								check = false;
								map.put("msgDesc", msg);
							}
						}
						
						// 고객명
						if(true != ValidationCheckUtil.emptyCheck(userName)){
							String msg = "고객명 정보가 누락되었습니다.";
							
							rowCheck     = Constants.FAIL;
							rowMsgDesc  += "- "+msg+"<br>";

							check = false;
							map.put("msgDesc", msg);
						}
						
						// 연락처
						if(true != ValidationCheckUtil.emptyCheck(phoneNumber)) {
							String msg = "연락처 정보가 누락되었습니다.";

							rowCheck = Constants.FAIL;
							rowMsgDesc += "- " + msg + "<br>";

							check = false;
							map.put("msgDesc", msg);
						}else{
							if(true != ValidationCheckUtil.phoneNumberCheck(phoneNumber)) {
								check = false;
								map.put("msgCode", Constants.FAIL);
								map.put("msgDesc","연락처 정보가 올바르지 않습니다.");
							}
							else if(true != ValidationCheckUtil.lengthCheck(phoneNumber,255)){
								check = false;
								map.put("msgCode", Constants.FAIL);
								map.put("msgDesc","연락처 정보는 255자를 넘을 수 없습니다.");
							}
						}
						
//						// 생년월일
//						if(true != ValidationCheckUtil.emptyCheck(birthday)){
//							String msg = "생년월일 정보가 누락되었습니다.";
//
//							rowCheck     = Constants.FAIL;
//							rowMsgDesc  += "- "+msg+"<br>";
//
//							check = false;
//							map.put("msgDesc", msg);
//						}
//
//						// 국적
//						if(true != ValidationCheckUtil.emptyCheck(nationalityCategoryItemCode)){
//							String msg = "국적 정보가 누락되었습니다.";
//
//							rowCheck     = Constants.FAIL;
//							rowMsgDesc  += "- "+msg+"<br>";
//
//							check = false;
//							map.put("msgDesc", msg);
//						}
//						else {
//							// 국적 정보 조회
//							HashMap<String, Object> categoryItemParamMap = new HashMap<String, Object>();
//							categoryItemParamMap.put("categoryItemCode", nationalityCategoryItemCode);
//							List<Map<String, Object>> categoryItemList = webCategorySqlMapDAO.selectCategoryItemId(categoryItemParamMap);
//
//							if(1==categoryItemList.size()) {
//								nationalityCategoryItemId = String.valueOf(categoryItemList.get(0).get("muCategoryItemId"));
//							}
//							else {
//								String msg = "등록된 국적 정보가 없습니다.";
//
//								rowCheck     = Constants.FAIL;
//								rowMsgDesc  += "- "+msg+"<br>";
//
//								check = false;
//								map.put("msgDesc", msg);
//							}
//						}
						
						// 진료유형
						if(true != ValidationCheckUtil.emptyCheck(muTreatmentProcedureId)){
							String msg = "진료유형 정보가 누락되었습니다.";
							
							rowCheck     = Constants.FAIL;
							rowMsgDesc  += "- "+msg+"<br>";

							check = false;
							map.put("msgDesc", msg);
						}
						else {
							// 시술 정보 조회
							HashMap<String, Object> treatmentProcedureParamMap = new HashMap<String, Object>();
							treatmentProcedureParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
							List<Map<String, Object>> treatmentProcedureList = webTreatmentProcedureSqlMapDAO.selectTreatmentProcedure2(treatmentProcedureParamMap);
							
							if(1==treatmentProcedureList.size()) {
								muTreatmentProcedureId = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentProcedureId"));
								treatmentProcedureName = String.valueOf(treatmentProcedureList.get(0).get("treatmentProcedureName"));
								muTreatmentId          = String.valueOf(treatmentProcedureList.get(0).get("muTreatmentId"));
								treatmentName          = String.valueOf(treatmentProcedureList.get(0).get("treatmentName"));
							}
							else {
								String msg = "등록된 진료유형 정보가 없습니다.";
								
								rowCheck     = Constants.FAIL;
								rowMsgDesc  += "- "+msg+"<br>";

								check = false;
								map.put("msgDesc", msg);
							}
						}
						
						// 닥터/상담
						if(true != ValidationCheckUtil.emptyCheck(reserveMemberCode)){
							String msg = "닥터/상담 정보가 누락되었습니다.";
							
							rowCheck     = Constants.FAIL;
							rowMsgDesc  += "- "+msg+"<br>";

							check = false;
							map.put("msgDesc", msg);
						}
						else {
							// 닥터/상담
							HashMap<String, Object> memberParamMap = new HashMap<String, Object>();
							memberParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
							memberParamMap.put("memberCode", reserveMemberCode);
							memberParamMap.put("searchDate", reserveDate);
							List<Map<String, Object>> memberList = webMemberSqlMapDAO.selectMemberAvailableYn(memberParamMap);
							
							if(1==memberList.size()) {
								reserveMemberId = String.valueOf(memberList.get(0).get("muMemberId"));
							}
							else {
								String msg = "예약 가능한 닥터/상담 정보가 아닙니다.";
								
								rowCheck     = Constants.FAIL;
								rowMsgDesc  += "- "+msg+"<br>";

								check = false;
								map.put("msgDesc", msg);
							}
						}
						
						// 결과에 값 넣기
						HashMap<String, Object> resultMap = new HashMap<String, Object>();
						resultMap.put("muReserveId", "");
						resultMap.put("number", number);
						resultMap.put("reserveDate", reserveDate);
						resultMap.put("reserveTime", reserveTime);
						resultMap.put("reserveCategoryItemCode", reserveCategoryItemCode);
						resultMap.put("reserveCategoryItemName", reserveCategoryItemName);
						resultMap.put("userName", userName);
						resultMap.put("phoneNumber", phoneNumber);
//						resultMap.put("birthday", birthday);
//						resultMap.put("nationalityCategoryItemCode", nationalityCategoryItemCode);
//						resultMap.put("nationalityCategoryItemId", nationalityCategoryItemId);
						resultMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
						resultMap.put("treatmentProcedureName", treatmentProcedureName);
						resultMap.put("muTreatmentId", muTreatmentId);
						resultMap.put("treatmentName", treatmentName);
						resultMap.put("reserveMemberCode", reserveMemberCode);
						resultMap.put("reserveMemberId", reserveMemberId);
						resultMap.put("etc", etc);
						resultMap.put("rowCheck", rowCheck);
						resultMap.put("rowMsgDesc", rowMsgDesc);
						listMap.add(cnt, resultMap);
						cnt++;
					}
					
					if(check == true){
						int listMapSize = listMap.size();

						// 자동발송 (알림톡 + 푸시)
						// 템플릿 조회
						HashMap<String, Object> insertKakaoMap = new HashMap<String, Object>();
						insertKakaoMap.put("templateCode", "024110000457");
						List<Map<String, Object>> templateListMap = webKakaoTemplateSqlMapDAO.selectKakaoTemplate(insertKakaoMap);


						// 고객명, 예약날짜, 예약시간, 시술명
						String KakaoTemplateTitle = String.valueOf(templateListMap.get(0).get("title"));
						String KakaoTemplateContent = String.valueOf(templateListMap.get(0).get("content"));

						
						for (int i = 0; i < listMapSize; i++) {
							// 번호
							String number                      = String.valueOf(listMap.get(i).get("number"));
							// 예약일자
							String reserveDate                 = String.valueOf(listMap.get(i).get("reserveDate"));
							// 예약시간
							String reserveTime                 = String.valueOf(listMap.get(i).get("reserveTime"));
							// 예약경로
							String reserveCategoryItemCode     = String.valueOf(listMap.get(i).get("reserveCategoryItemCode"));
							String reserveCategoryItemName     = String.valueOf(listMap.get(i).get("reserveCategoryItemName"));
							String reserveCategoryItemId       = String.valueOf(listMap.get(i).get("reserveCategoryItemId"));
							// 고객명
							String userName                    = String.valueOf(listMap.get(i).get("userName"));
							// 연락처
							String phoneNumber                 = String.valueOf(listMap.get(i).get("phoneNumber"));
							// 생년월일
//							String birthday                    = String.valueOf(listMap.get(i).get("birthday"));
							// 국적
//							String nationalityCategoryItemCode = String.valueOf(listMap.get(i).get("nationalityCategoryItemCode"));
//							String nationalityCategoryItemId   = String.valueOf(listMap.get(i).get("nationalityCategoryItemId"));
							// 진료유형
							String muTreatmentProcedureId      = String.valueOf(listMap.get(i).get("muTreatmentProcedureId"));
							String treatmentProcedureName      = String.valueOf(listMap.get(i).get("treatmentProcedureName"));
							String muTreatmentId               = String.valueOf(listMap.get(i).get("muTreatmentId"));
							String treatmentName               = String.valueOf(listMap.get(i).get("treatmentName"));
							// 닥터/상담
							String reserveMemberCode           = String.valueOf(listMap.get(i).get("reserveMemberCode"));
							String reserveMemberId             = String.valueOf(listMap.get(i).get("reserveMemberId"));
							// 예약메모
							String etc                         = String.valueOf(listMap.get(i).get("etc"));
							
							
							// 예약 중복 확인
							HashMap<String, Object> selectParamMap = new HashMap<String, Object>();
							selectParamMap.put("reserveDate", reserveDate);
							selectParamMap.put("reserveTime", reserveTime);
							selectParamMap.put("userName", userName);
							selectParamMap.put("phoneNumber", phoneNumber);
							selectParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
							selectParamMap.put("reserveMemberId", reserveMemberId);
							List<Map<String, Object>> reserveYnList = webReserveSqlMapDAO.selectListReserveYn(selectParamMap);
							int reserveCount = webReserveSqlMapDAO.selectReserveCount(selectParamMap);

							if(0 == reserveYnList.size()&&30>reserveCount) {
								// 고객 정보 조회 (등록 여부 확인, 고객명/전화번호로 확인)
								List<Map<String, Object>> userList = webUserSqlMapDAO.selectUserId(selectParamMap);
								
								HashMap<String, Object> insertParamMap = new HashMap<String, Object>();
								if(1==userList.size()) {
									// 기존 고객으로 예약경로리
									insertParamMap.put("muUserId", userList.get(0).get("muUserId"));
									insertParamMap.put("userName", userName);
									insertParamMap.put("phoneNumber", phoneNumber);
								}
								else {
									// 간편예약 고객 등록
									String muUserId = ("U").concat(String.valueOf(System.currentTimeMillis()));
									insertParamMap.put("muUserId", muUserId);
									insertParamMap.put("userName", userName);
									insertParamMap.put("phoneNumber", phoneNumber);
									insertParamMap.put("reserveCategoryItemId", reserveCategoryItemId);
									insertParamMap.put("regId",paramMap.get("regId"));
									insertParamMap.put("modId",paramMap.get("modId"));
									insertParamMap.put("tId", tId);
									insertParamMap.put("tDate", tDate);
									webUserSqlMapDAO.insertUserTemp(insertParamMap);
									log.debug("muUserId :"+insertParamMap.get("id"));
									insertParamMap.put("muUserId", insertParamMap.get("id"));
								}
								
								// 예약 등록
								String muReserveId = ("R").concat(String.valueOf(System.currentTimeMillis()));
								insertParamMap.put("muReserveId",muReserveId);
								insertParamMap.put("reserveDate", reserveDate);
								insertParamMap.put("reserveTime", reserveTime);
								insertParamMap.put("reserveCategoryItemCode", reserveCategoryItemCode);
								insertParamMap.put("reserveCategoryItemName", reserveCategoryItemName);
								insertParamMap.put("muTreatmentId", muTreatmentId);
								insertParamMap.put("treatmentName", treatmentName);
								insertParamMap.put("muTreatmentProcedureId", muTreatmentProcedureId);
								insertParamMap.put("treatmentProcedureName", treatmentProcedureName);
								insertParamMap.put("reserveMemberId", reserveMemberId);
								insertParamMap.put("muMemberId", paramMap.get("regId"));
								insertParamMap.put("etc", etc);
								insertParamMap.put("status", "T");
								insertParamMap.put("status2", "N");
								insertParamMap.put("regId",paramMap.get("regId"));
								insertParamMap.put("modId",paramMap.get("modId"));
								insertParamMap.put("tId", tId);
								insertParamMap.put("tDate", tDate);
								webReserveSqlMapDAO.insertReserve(insertParamMap);
								log.debug("muReserveId :"+insertParamMap.get("id"));
								insertParamMap.put("muReserveId", insertParamMap.get("id"));
								
								// 상담차트 등록
								List<Map<String, Object>> userConsultingChartNumberList = webUserConsultingChartSqlMapDAO.selectUserConsultingChartNumber(paramMap);
								String chartNumber1 = String.valueOf(userConsultingChartNumberList.get(0).get("chartNumber"));
								
								String muUserConsultingChartId = ("UCC").concat(String.valueOf(System.currentTimeMillis()));
								insertParamMap.put("muUserConsultingChartId",muUserConsultingChartId);
								insertParamMap.put("chartNumber",chartNumber1);
								webUserConsultingChartSqlMapDAO.insertUserConsultingChart(insertParamMap); 
								
								// 시술차트 등록
								List<Map<String, Object>> userMedicalChartNumberList = webUserMedicalChartSqlMapDAO.selectUserMedicalChartNumber(paramMap);
								String chartNumber2 = String.valueOf(userMedicalChartNumberList.get(0).get("chartNumber"));
								
								String muUserMedicalChartId = ("UMC").concat(String.valueOf(System.currentTimeMillis()));
								insertParamMap.put("muUserMedicalChartId",muUserMedicalChartId);
								insertParamMap.put("chartNumber",chartNumber2);
								webUserMedicalChartSqlMapDAO.insertUserMedicalChart(insertParamMap);


								// 디바이스 리스트 조회
								List<Map<String, Object>> deviceListMap = webDeviceSqlMapDAO.selectListDevice2(insertParamMap);
								int deviceListMapSize = deviceListMap.size();

								// 자동발송 (알림톡 + 푸시)
								// 고객명, 예약날짜, 예약시간, 시술명
								String kakaoContent = KakaoTemplateContent;
								kakaoContent = kakaoContent.replace("#{고객명}", userName);
								kakaoContent = kakaoContent.replace("#{예약날짜}", reserveDate);
								kakaoContent = kakaoContent.replace("#{예약시간}", reserveTime);
								kakaoContent = kakaoContent.replace("#{시술명}", treatmentName.concat("-").concat(treatmentProcedureName));


								insertKakaoMap.put("muKakaoId", ("K").concat(String.valueOf(System.currentTimeMillis())));
								insertKakaoMap.put("muUserId", insertParamMap.get("muUserId"));
								insertKakaoMap.put("userName", insertParamMap.get("userName"));
								insertKakaoMap.put("phoneNumber", insertParamMap.get("phoneNumber"));
								insertKakaoMap.put("content", kakaoContent);
								insertKakaoMap.put("state", "R");
								insertKakaoMap.put("popbillState", "0");
								insertKakaoMap.put("sender", senderPhoneNumber);
								insertKakaoMap.put("regId", "SYSTEM");
								insertKakaoMap.put("modId", "SYSTEM");
								insertKakaoMap.put("tId", tId);
								insertKakaoMap.put("tDate", tDate);

								webKakaoSqlMapDAO.insertKakao(insertKakaoMap);
//								autoKakaoService.send("reserve", insertKakaoMap);

								// 푸시
								if(0<deviceListMapSize){
									HashMap<String, Object> insertPushMap = new HashMap<String, Object>();
									for(int j=0; j<deviceListMapSize; j++){
										insertPushMap.put("muPushId", ("P").concat(String.valueOf(System.currentTimeMillis())));
										insertPushMap.put("muUserId", insertParamMap.get("muUserId"));
										insertPushMap.put("userName", insertParamMap.get("userName"));
										insertPushMap.put("muDeviceId", deviceListMap.get(j).get("muDeviceId"));
										insertPushMap.put("deviceUuid", deviceListMap.get(j).get("deviceUuid"));
										insertPushMap.put("pushKey", deviceListMap.get(j).get("pushKey"));
										insertPushMap.put("pushType", "A");
										insertPushMap.put("phoneType", deviceListMap.get(j).get("phoneType"));
										insertPushMap.put("title", KakaoTemplateTitle);
										insertPushMap.put("content", kakaoContent);
										insertPushMap.put("state", "R");
										insertPushMap.put("regId", "SYSTEM");
										insertPushMap.put("modId", "SYSTEM");
										insertPushMap.put("tId", tId);
										insertPushMap.put("tDate", tDate);

										webPushSqlMapDAO.insertPush(insertPushMap);
//										autoPushService.send("reserve", insertPushMap);
									}
								}
								
								map.put("msgCode", Constants.OK);
								map.put("msgDesc", "등록되었습니다.");
								
								
								// 결과 반영
								listMap.get(i).put("muReserveId", insertParamMap.get("muReserveId"));
								listMap.get(i).put("rowCheck", Constants.OK);
								listMap.get(i).put("rowMsgDesc", "");
							}
							else {
								// 결과 반영
								listMap.get(i).put("rowCheck", Constants.FAIL);
								if(29<reserveCount){
									listMap.get(i).put("rowMsgDesc", "예약 가능 건수를 초과하였습니다.");
								}else{
									listMap.get(i).put("rowMsgDesc", "중복된 예약입니다.");
								}
							}
						}
						map = new HashMap<String, Object>();
						map.put("msgCode", Constants.OK);
						map.put("msgDesc", "등록 되었습니다.");
						map.put("success",check);
						map.put("rows",listMap);
					}else{
						map.put("msgCode", Constants.OK);
						map.put("msgDesc", "일괄 등록 실패건이 있습니다. 확인 후 다시 시도해 주시기 바랍니다.");
						map.put("success",check);
						map.put("rows",listMap);
					}
					
				} catch (IOException e) {
					map.put("msgCode", Constants.FAIL);
					map.put("success", false);
					map.put("msgDesc", "파일 업로드 중 오류가 발생하였습니다.");
					System.err.println(e.getMessage());
					//throw new Exception(CodeDefines.FAIL, e.getMessage());
				}
			}else{
				map.put("msgCode", Constants.FAIL);
				map.put("success", false);
				map.put("msgDesc", fileMap.get("msgDesc"));
			}
		}catch(Exception e){
			map.put("msgCode", Constants.FAIL);
			map.put("success", false);
			map.put("msgDesc", "파일을 읽는 중 오류가 발생하였습니다.");
			
			e.printStackTrace();
			throw e;
		}
		
		log.debug("WebReserveServiceImpl uploadReserveExcel END");
		return map;
	}
	
	/**
	 * 예약 컬럼 참고 양식 다운로드 (List, Excel)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListReserveColumnExcel(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebReserveServiceImpl selectListReserveColumnExcel START");

		HashMap<String, Object> map = new HashMap<String, Object>();
		List<Map<String, Object>> listMap = null;

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		try{
			boolean check  = true;
			
			if(true == check){
				// 사용자 확인
				List<Map<String, Object>> userListMap = webMemberSqlMapDAO.checkMember(paramMap);
				int userListMapSize = userListMap.size();
				
				if(1==userListMapSize){
					paramMap.put("menuClassAuthId", userListMap.get(0).get("muAuthId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "사용자 정보가 올바르지 않습니다.");
				}
			}
			
			if(true == check){
				// 예약경로 조회
				paramMap.put("categoryCode", "C202404110004");
				List<Map<String, Object>> channelListMap = webCategorySqlMapDAO.selectCategoryItem(paramMap);
				
				// 국가 조회
				paramMap.put("categoryCode", "C202404110001");
				List<Map<String, Object>> nationalityListMap = webCategorySqlMapDAO.selectCategoryItem(paramMap);

				// 진료 유형(시술) 조회
				List<Map<String, Object>> treatmentProcedureList = webTreatmentProcedureSqlMapDAO.selectListTreatmentProcedureOption3(paramMap);

				// 직원 조회
				List<Map<String, Object>> memberList = webMemberSqlMapDAO.selectListMemberDoctorConsultingOption2(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("channelRows",channelListMap);
				map.put("nationalityRows",nationalityListMap);
				map.put("treatmentProcedureRows",treatmentProcedureList);
				map.put("memberRows",memberList);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebReserveServiceImpl selectListReserveColumnExcel END");
		return map;
	}
}
