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

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.madeu.constants.Constants;
import com.madeu.dao.web.webauthmenurelation.WebAuthMenuRelationSqlMapDAO;
import com.madeu.dao.web.webholidaymanagement.WebHolidayManagementSqlMapDAO;
import com.madeu.dao.web.webmember.WebMemberSqlMapDAO;
import com.madeu.service.web.webholidaymanagement.WebHolidayManagementService;
import com.madeu.util.ValidationCheckUtil;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service("WebHolidayManagementService")
public class WebHolidayManagementServiceImpl implements WebHolidayManagementService {
	
	@Autowired
	private WebHolidayManagementSqlMapDAO webHolidayManagementSqlMapDAO;
	
	@Autowired
	private WebMemberSqlMapDAO webMemberSqlMapDAO;
	
	@Autowired
	private WebAuthMenuRelationSqlMapDAO webAuthMenuRelationSqlMapDAO;
	
	/**
	 * 휴무관리 리스트 조회
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListHolidayManagement(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebHolidayManagementServiceImpl selectListHolidayManagement START");

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

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("holidayManagementSearchKeywordParam  :"+paramMap.get("holidayManagementSearchKeywordParam"));
		log.debug("holidayManagementSort                :"+paramMap.get("holidayManagementSort"));
		log.debug("holidayManagementDir                 :"+paramMap.get("holidayManagementDir"));
		log.debug("holidayManagementStart               :"+paramMap.get("holidayManagementStart"));
		log.debug("holidayManagementLimit               :"+paramMap.get("holidayManagementLimit"));
		
		log.debug("holidayManagementSearchGroupId       :"+paramMap.get("holidayManagementSearchGroupId"));
		log.debug("holidayManagementSearchDutyId        :"+paramMap.get("holidayManagementSearchDutyId"));
		log.debug("holidayManagementSearchDate          :"+paramMap.get("holidayManagementSearchDate"));
		
		List<Map<String, Object>> listMap = new ArrayList<Map<String,Object>>();
		
		try{
			boolean check  = true;

			String holidayManagementSearchDate    = String.valueOf(paramMap.get("holidayManagementSearchDate"));
			
			if(true != ValidationCheckUtil.emptyCheck(holidayManagementSearchDate)){
				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()){

					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("holidayManagementDir")||("").equals(paramMap.get("holidayManagementDir"))){
					
				}
				else{
					String dir = String.valueOf(paramMap.get("holidayManagementDir"));
					if(("A").equals(dir)){
						paramMap.put("holidayManagementDir", "DESC");
					}
					else if(("B").equals(dir)){
						paramMap.put("holidayManagementDir", "ASC");
					}
					else {
						paramMap.put("holidayManagementDir", "DESC");
					}
				}
				
				paramMap.put("useYn", "Y");
				
				List<Map<String, Object>> totalCountListMap = webHolidayManagementSqlMapDAO.selectTotalHolidayManagementCount(paramMap);
				int totalCount = Integer.parseInt(String.valueOf(totalCountListMap.get(0).get("totalCount")));
				
				if(0 < totalCount) {
					// 리스트 조회
					listMap = webHolidayManagementSqlMapDAO.selectListHolidayManagement(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("WebHolidayManagementServiceImpl selectListHolidayManagement END");
		return map;
	}
	
	/**
	 * 휴무관리 리스트 조회 (Excel)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Map<String, Object>> selectListHolidayManagementExcel(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebHolidayManagementServiceImpl selectListHolidayManagementExcel 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("holidayManagementSearchKeywordParam  :"+paramMap.get("holidayManagementSearchKeywordParam"));
		log.debug("holidayManagementSort                :"+paramMap.get("holidayManagementSort"));
		log.debug("holidayManagementDir                 :"+paramMap.get("holidayManagementDir"));
		log.debug("holidayManagementStart               :"+paramMap.get("holidayManagementStart"));
		log.debug("holidayManagementLimit               :"+paramMap.get("holidayManagementLimit"));
		
		log.debug("holidayManagementSearchGroupId       :"+paramMap.get("holidayManagementSearchGroupId"));
		log.debug("holidayManagementSearchDutyId        :"+paramMap.get("holidayManagementSearchDutyId"));
		log.debug("holidayManagementSearchDate          :"+paramMap.get("holidayManagementSearchDate"));

		try{
			boolean check  = true;
			
			String holidayManagementSearchDate    = String.valueOf(paramMap.get("holidayManagementSearchDate"));
			
			if(true != ValidationCheckUtil.emptyCheck(holidayManagementSearchDate)){
				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()){

					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("holidayManagementDir")||("").equals(paramMap.get("holidayManagementDir"))){
					
				}
				else{
					String dir = String.valueOf(paramMap.get("holidayManagementDir"));
					if(("A").equals(dir)){
						paramMap.put("holidayManagementDir", "DESC");
					}
					else if(("B").equals(dir)){
						paramMap.put("holidayManagementDir", "ASC");
					}
					else {
						paramMap.put("holidayManagementDir", "DESC");
					}
				}
				
				paramMap.put("useYn", "Y");
				
				listMap = webHolidayManagementSqlMapDAO.selectListHolidayManagementExcel(paramMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebHolidayManagementServiceImpl selectListHolidayManagementExcel END");
		return listMap;
	}
	
	/**
	 * 휴무관리 정보 상세 조회 (one)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectHolidayManagement(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebHolidayManagementServiceImpl selectHolidayManagement START");

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

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

		try{
			boolean check  = true;
			String muAttendanceId    = String.valueOf(paramMap.get("muAttendanceId"));
			
			// 정렬
			if(true != ValidationCheckUtil.emptyCheck(muAttendanceId)){
				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()){

					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 = webHolidayManagementSqlMapDAO.selectHolidayManagement(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebHolidayManagementServiceImpl selectHolidayManagement END");
		return map;
	}
	
	/**
	 * 휴무관리 정보 등록
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> insertHolidayManagement(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebHolidayManagementServiceImpl insertHolidayManagement START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("muMemberId          :"+paramMap.get("muMemberId"));
		log.debug("startDate           :"+paramMap.get("startDate"));
		log.debug("endDate             :"+paramMap.get("endDate"));
		log.debug("etc                 :"+paramMap.get("etc"));

		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 muMemberId        = String.valueOf(paramMap.get("muMemberId"));
			String startDate         = String.valueOf(paramMap.get("startDate"));
			String endDate           = String.valueOf(paramMap.get("endDate"));
			String etc               = String.valueOf(paramMap.get("etc"));
			
			if(true != ValidationCheckUtil.emptyCheck(muMemberId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","직원 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(startDate)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","휴무시작일자 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(endDate)){
				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("insertUseYn"))) {
						
					}
					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>> memberListMap = webMemberSqlMapDAO.selectMember(paramMap);
				int memberListMapSize = memberListMap.size();
				
				if(1 == memberListMapSize){
					paramMap.put("muGroupId", memberListMap.get(0).get("muGroupId"));
					paramMap.put("muDutyId", memberListMap.get(0).get("muDutyId"));
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "직원 정보가 올바르지 않습니다.");
				}
			}
			
			// 겹치는 일자 안들어가도록 조건 추가 필요.
			
			if(true == check){
				paramMap.put("tDate", tDate);
				paramMap.put("tId", tId);
				
				String muAttendanceId = ("A").concat(String.valueOf(System.currentTimeMillis()));
				paramMap.put("muAttendanceId",muAttendanceId);
				webHolidayManagementSqlMapDAO.insertHolidayManagement(paramMap);
				log.debug("muAttendanceId :"+paramMap.get("id"));
				paramMap.put("muAttendanceId", paramMap.get("id"));
				map.put("muAttendanceId", paramMap.get("muAttendanceId"));

				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "등록되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebHolidayManagementServiceImpl insertHolidayManagement END");
		return map;
	}

	/**
	 * 휴무관리 정보 수정
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> updateHolidayManagement(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebHolidayManagementServiceImpl updateHolidayManagement START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		log.debug("loginMemberId         :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass             :"+paramMap.get("menuClass"));
		
		log.debug("muAttendanceId        :"+paramMap.get("muAttendanceId"));

		log.debug("startDate             :"+paramMap.get("startDate"));
		log.debug("endDate               :"+paramMap.get("endDate"));
		log.debug("etc                   :"+paramMap.get("etc"));

		try{
			boolean check  = true;

			String muAttendanceId        = String.valueOf(paramMap.get("muAttendanceId"));
			String startDate             = String.valueOf(paramMap.get("startDate"));
			String endDate               = String.valueOf(paramMap.get("endDate"));
			String etc                   = String.valueOf(paramMap.get("etc"));

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

			if(true != ValidationCheckUtil.emptyCheck(startDate)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","휴무시작일자 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(endDate)){
				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){
				webHolidayManagementSqlMapDAO.updateHolidayManagement(paramMap);
				map.put("muAttendanceId", paramMap.get("muAttendanceId"));

				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "수정되었습니다.");
			}
			
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebHolidayManagementServiceImpl updateHolidayManagement END");
		return map;
	}

	/**
	 * 휴무관리 정보 휴무취소
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> updateHolidayManagementCancel(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebHolidayManagementServiceImpl updateHolidayManagementCancel START");
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		log.debug("loginMemberId         :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass             :"+paramMap.get("menuClass"));
		
		log.debug("muAttendanceId        :"+paramMap.get("muAttendanceId"));
		log.debug("cancelEtc             :"+paramMap.get("cancelEtc"));

		try{
			boolean check  = true;

			String muAttendanceId        = String.valueOf(paramMap.get("muAttendanceId"));
			String cancelEtc             = String.valueOf(paramMap.get("cancelEtc"));

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

			if(true != ValidationCheckUtil.emptyCheck(cancelEtc)){
				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>> holidayListMap = webHolidayManagementSqlMapDAO.selectHolidayManagement(paramMap);
				
				if(1 == holidayListMap.size()) {
					String status = String.valueOf(holidayListMap.get(0).get("status"));
					
					if(!("D").equals(status)) {
						// 휴무취소처리
						webHolidayManagementSqlMapDAO.updateHolidayManagementCancel(paramMap);
					}
					else {
						// 취소사유만 변경
						webHolidayManagementSqlMapDAO.updateHolidayManagementCancelEtc(paramMap);
					}
					
					map.put("muAttendanceId", paramMap.get("muAttendanceId"));
					
					map.put("msgCode", Constants.OK);
					map.put("msgDesc", "처리되었습니다.");
				}
				else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "휴무관리 정보가 없습니다.");
				}
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebHolidayManagementServiceImpl updateHolidayManagementCancel END");
		return map;
	}

	/**
	 * 휴무관리 정보 삭제
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> deleteHolidayManagement(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebHolidayManagementServiceImpl deleteHolidayManagement 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 muAttendanceId = selectData.nextToken();
					
					HashMap<String, Object> deleteParamMap = new HashMap<String, Object>();
					deleteParamMap.put("muAttendanceId", muAttendanceId);
					deleteParamMap.put("modId", paramMap.get("loginMemberId"));
					webHolidayManagementSqlMapDAO.deleteHolidayManagement(deleteParamMap);
				}
				
				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "삭제 되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		log.debug("WebHolidayManagementServiceImpl deleteHolidayManagement END");
		return map;
	}
}
