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

import java.io.IOException;
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 com.madeu.util.ExcelUtil;
import com.madeu.util.FileStoreUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.simple.parser.JSONParser;
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.webmember.WebMemberSqlMapDAO;
import com.madeu.dao.web.webvacationmanagement.WebVacationManagementSqlMapDAO;
import com.madeu.service.web.webvacationmanagement.WebVacationManagementService;
import com.madeu.util.ValidationCheckUtil;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@Service("WebVacationManagementService")
public class WebVacationManagementServiceImpl implements WebVacationManagementService {
	
	@Autowired
	private WebVacationManagementSqlMapDAO webVacationManagementSqlMapDAO;
	
	@Autowired
	private WebMemberSqlMapDAO webMemberSqlMapDAO;
	
	@Autowired
	private WebAuthMenuRelationSqlMapDAO webAuthMenuRelationSqlMapDAO;
	
	/**
	 * 연차관리 리스트 조회
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectListVacationManagement(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebVacationManagementServiceImpl selectListVacationManagement START");

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

		log.debug("loginMemberId       :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass           :"+paramMap.get("menuClass"));
		
		log.debug("vacationManagementSearchKeywordParam  :"+paramMap.get("vacationManagementSearchKeywordParam"));
		log.debug("vacationManagementSort                :"+paramMap.get("vacationManagementSort"));
		log.debug("vacationManagementDir                 :"+paramMap.get("vacationManagementDir"));
		log.debug("vacationManagementStart               :"+paramMap.get("vacationManagementStart"));
		log.debug("vacationManagementLimit               :"+paramMap.get("vacationManagementLimit"));
		
		log.debug("vacationManagementSearchYear          :"+paramMap.get("vacationManagementSearchYear"));
		log.debug("vacationManagementSearchGroupId       :"+paramMap.get("vacationManagementSearchGroupId"));

		List<Map<String, Object>> listMap = new ArrayList<Map<String,Object>>();
		
		try{
			boolean check  = true;

			String vacationManagementSearchYear    = String.valueOf(paramMap.get("vacationManagementSearchYear"));
			
			if(true != ValidationCheckUtil.emptyCheck(vacationManagementSearchYear)){
				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("vacationManagementDir")||("").equals(paramMap.get("vacationManagementDir"))){
					
				}
				else{
					String dir = String.valueOf(paramMap.get("vacationManagementDir"));
					if(("A").equals(dir)){
						paramMap.put("vacationManagementDir", "DESC");
					}
					else if(("B").equals(dir)){
						paramMap.put("vacationManagementDir", "ASC");
					}
					else {
						paramMap.put("vacationManagementDir", "DESC");
					}
				}
				
				paramMap.put("useYn", "Y");
				
				List<Map<String, Object>> totalCountListMap = webVacationManagementSqlMapDAO.selectTotalVacationManagementCount(paramMap);
				int totalCount = Integer.parseInt(String.valueOf(totalCountListMap.get(0).get("totalCount")));
				
				if(0 < totalCount) {
					// 리스트 조회
					listMap = webVacationManagementSqlMapDAO.selectListVacationManagement(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("WebVacationManagementServiceImpl selectListVacationManagement END");
		return map;
	}
	
	/**
	 * 연차관리 리스트 조회 (Excel)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Map<String, Object>> selectListVacationManagementExcel(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebVacationManagementServiceImpl selectListVacationManagementExcel 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("vacationManagementSearchKeywordParam  :"+paramMap.get("vacationManagementSearchKeywordParam"));
		log.debug("vacationManagementSort                :"+paramMap.get("vacationManagementSort"));
		log.debug("vacationManagementDir                 :"+paramMap.get("vacationManagementDir"));
		log.debug("vacationManagementStart               :"+paramMap.get("vacationManagementStart"));
		log.debug("vacationManagementLimit               :"+paramMap.get("vacationManagementLimit"));
		
		log.debug("vacationManagementSearchYear          :"+paramMap.get("vacationManagementSearchYear"));
		log.debug("vacationManagementSearchGroupId       :"+paramMap.get("vacationManagementSearchGroupId"));

		try{
			boolean check  = true;

			String vacationManagementSearchYear    = String.valueOf(paramMap.get("vacationManagementSearchYear"));
			
			if(true != ValidationCheckUtil.emptyCheck(vacationManagementSearchYear)){
				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("vacationManagementDir")||("").equals(paramMap.get("vacationManagementDir"))){
					
				}
				else{
					String dir = String.valueOf(paramMap.get("vacationManagementDir"));
					if(("A").equals(dir)){
						paramMap.put("vacationManagementDir", "DESC");
					}
					else if(("B").equals(dir)){
						paramMap.put("vacationManagementDir", "ASC");
					}
					else {
						paramMap.put("vacationManagementDir", "DESC");
					}
				}
				
				paramMap.put("useYn", "Y");
				
				listMap = webVacationManagementSqlMapDAO.selectListVacationManagementExcel(paramMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebVacationManagementServiceImpl selectListVacationManagementExcel END");
		return listMap;
	}
	
	/**
	 * 연차관리 수정 화면으로 이동.
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> updateVacationManagementIntro(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebVacationManagementServiceImpl updateVacationManagementIntro START");

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

		log.debug("loginMemberId          :"+paramMap.get("loginMemberId"));
		
		log.debug("menuClass              :"+paramMap.get("menuClass"));
		
		log.debug("muVacationManagementid :"+paramMap.get("muVacationManagementid"));
		
		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);
				int authMenuRelationlistMapSize = authMenuRelationlistMap.size();
				
				if(1==authMenuRelationlistMapSize){
					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("WebVacationManagementServiceImpl updateVacationManagementIntro END");
		return map;
	}
	
	/**
	 * 연차관리 정보 상세 조회 (one)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectVacationManagement(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebVacationManagementServiceImpl selectVacationManagement START");

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

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

		try{
			boolean check  = true;
			String muVacationManagementId = String.valueOf(paramMap.get("muVacationManagementId"));
			String year                   = String.valueOf(paramMap.get("year"));
			
			if(true != ValidationCheckUtil.emptyCheck(muVacationManagementId)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","연차관리 정보가 없습니다.");
			}
			
			if(true != ValidationCheckUtil.emptyCheck(year)){
				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 = webVacationManagementSqlMapDAO.selectVacationManagement(paramMap);
				
				// 연차 사용자 정보 조회
				List<Map<String, Object>> memberListMap = webVacationManagementSqlMapDAO.selectVacationManagementMember(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
				map.put("memberRows",memberListMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebVacationManagementServiceImpl selectVacationManagement END");
		return map;
	}
	
	/**
	 * 연차관리 잔여 연차 조회 (one)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectVacationManagementLeftDays(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebVacationManagementServiceImpl selectVacationManagementLeftDays 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"));

		try{
			boolean check  = true;
			String muMemberId   = String.valueOf(paramMap.get("muMemberId"));
			String muVacationId = String.valueOf(paramMap.get("muVacationId"));
			String endDate = String.valueOf(paramMap.get("endDate"));
			String startDate = String.valueOf(paramMap.get("startDate"));


			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);

				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 = webVacationManagementSqlMapDAO.selectVacationManagementLeftDays(paramMap);
				
				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebVacationManagementServiceImpl selectVacationManagementLeftDays END");
		return map;
	}
	/**
	 * 발행연차수정 잔여연차 조회 (one)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public HashMap<String, Object> selectVacationManagementDays(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebVacationManagementServiceImpl selectVacationManagementDays 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"));

		try{
			boolean check  = true;
			String muMemberId   = String.valueOf(paramMap.get("muMemberId"));
			String startDate   = String.valueOf(paramMap.get("startDate"));
			String endDate   = String.valueOf(paramMap.get("endDate"));

			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> 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 = webVacationManagementSqlMapDAO.selectVacationManagementDays(paramMap);

				map.put("msgCode", Constants.OK);
				map.put("success","true");
				map.put("rows",listMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebVacationManagementServiceImpl selectVacationManagementDays END");
		return map;
	}
	
	/**
	 * 연차관리 정보 등록
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> insertVacationManagement(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebVacationManagementServiceImpl insertVacationManagement 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("year                :"+paramMap.get("year"));
		log.debug("days                :"+paramMap.get("days"));
		log.debug("startDate           :"+paramMap.get("startDate"));
		log.debug("endDate             :"+paramMap.get("endDate"));
		log.debug("etc                 :"+paramMap.get("etc"));
		log.debug("dataList            :"+paramMap.get("dataList"));

		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 year              = String.valueOf(paramMap.get("year"));
			String days              = String.valueOf(paramMap.get("days"));
			String startDate         = String.valueOf(paramMap.get("startDate"));
			String endDate           = String.valueOf(paramMap.get("endDate"));
			String etc               = String.valueOf(paramMap.get("etc"));


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

			if (!ValidationCheckUtil.emptyCheck(year)) {
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc", "발행연도 정보가 없습니다.");
			}

			if (!ValidationCheckUtil.emptyCheck(days)) {
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc", "발행일수 정보가 없습니다.");
			}

			if (!ValidationCheckUtil.emptyCheck(startDate)) {
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc", "사용기한 시작일자 정보가 없습니다.");
			}

			if (!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){
				// 연차 유형별 기간 중복 확인
				List<Map<String, Object>> vacationManagementListMap = webVacationManagementSqlMapDAO.selectVacationManagementDate(paramMap);
				int totalCount = Integer.parseInt(String.valueOf(vacationManagementListMap.get(0).get("totalCount")));

				if (totalCount == 0) {

				} else {
					check = false;
					map.put("msgCode", Constants.FAIL);
					map.put("msgDesc", "이미 등록된 사용기한과 중복됩니다. 사용기한 확인 후 다시 등록하십시오.");
				}
			}

			if(true == check){
				paramMap.put("tDate", tDate);
				paramMap.put("tId", tId);

				String muVacationManagementId = ("VM").concat(String.valueOf(System.currentTimeMillis()));
				paramMap.put("muVacationManagementId", muVacationManagementId);
				paramMap.put("regId",paramMap.get("regId"));
				paramMap.put("modId",paramMap.get("modId"));
				webVacationManagementSqlMapDAO.insertVacationManagement(paramMap);

				log.debug("muVacationManagementId :" + paramMap.get("id"));
				paramMap.put("muVacationManagementId", paramMap.get("id"));
				map.put("muVacationManagementId", paramMap.get("muVacationManagementId"));
				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "등록되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}

		log.debug("WebVacationManagementServiceImpl insertVacationManagement END");
		return map;
	}

	/**
	 * 연차관리 정보 일괄등록
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> insertVacationManagementExcel(
			HashMap<String, Object> paramMap, MultipartFile file) throws Exception{
		log.debug("WebVacationManagementServiceImpl insertVacationManagementExcel 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 {
					if(true == check) {
						int cells = 8;
						List<String[]> list = new ArrayList<String[]>();

						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 memberName = rows[1];
							log.debug("memberName                  :" + memberName);

							// 로그인 아이디
							String loginId = rows[2];
							log.debug("loginId               	   :" + loginId);

							// 발행연도
							String year = rows[3];
							log.debug("year     				   :" + year);

							// 연차발행 수
							String days = rows[4];
							log.debug("days                    	   :" + days);

							// 사용기한 시작일자
							String startDate = rows[5];
							log.debug("startDate                   :" + startDate);

							// 사용기한 종료일자
							String endDate = rows[6];
							log.debug("endDate                     :" + endDate);

							// 연차발행 메모
							String etc = rows[7];
							log.debug("etc 						   :" + etc);

							// 형식 체크
							String rowCheck = Constants.OK_ONE;
							String rowMsgDesc = "";

							// 로그인 아이디
							if (true != ValidationCheckUtil.emptyCheck(loginId)) {
								String msg = "로그인 아이디가 누락되었습니다.";

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

								check = false;
								map.put("msgDesc", msg);
							} else {
								//id정보 조회
								if (true != ValidationCheckUtil.emptyCheck(webMemberSqlMapDAO.selectMemberId(loginId))) {
									String msg = "로그인 아이디 정보가 없습니다.";

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

									check = false;
									map.put("msgDesc", msg);
								}
							}
							// 발행연도
							if (true != ValidationCheckUtil.emptyCheck(year)) {
								String msg = "발행연도가 누락되었습니다.";

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

								check = false;
								map.put("msgDesc", msg);
							}
							// 연차발행 수
							if (true != ValidationCheckUtil.emptyCheck(days)) {
								String msg = "연차발행 수가 누락되었습니다.";

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

								check = false;
								map.put("msgDesc", msg);
							}
							// 사용기한 시작일자
							if (true != ValidationCheckUtil.emptyCheck(startDate)) {
								String msg = "사용기한 시작일자가 누락되었습니다.";

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

								check = false;
								map.put("msgDesc", msg);
							}
							// 사용기한 종료일자
							if (true != ValidationCheckUtil.emptyCheck(endDate)) {
								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("loginId", loginId);
							resultMap.put("year", year);
							resultMap.put("days", days);
							resultMap.put("startDate", startDate);
							resultMap.put("endDate", endDate);
							resultMap.put("etc", etc);
							listMap.add(cnt, resultMap);
							cnt++;
						}
					}
					if(check == true){
						int listMapSize = listMap.size();
						for (int i = 0; i < listMapSize; i++) {
							//로그인 아이디
							String loginId              = String.valueOf(listMap.get(i).get("loginId"));
							//직원 아이디
							String muMemberId			=  webMemberSqlMapDAO.selectMemberId(loginId);
							// 연차발행 연도
							String year                 = String.valueOf(listMap.get(i).get("year"));
							// 연차발행 일수
							String days                 = String.valueOf(listMap.get(i).get("days"));
							// 사용기한 시작일자
							String startDate     		= String.valueOf(listMap.get(i).get("startDate"));
							// 사용기한 종료일자
							String endDate       		= String.valueOf(listMap.get(i).get("endDate"));
							// 메모
							String etc                  = String.valueOf(listMap.get(i).get("etc"));

							HashMap<String, Object> selectParamMap = new HashMap<String, Object>();
							selectParamMap.put("loginId", loginId);
							selectParamMap.put("muMemberId", muMemberId);
							selectParamMap.put("year", year);
							selectParamMap.put("days", days);
							selectParamMap.put("startDate", startDate);
							selectParamMap.put("endDate", endDate);
							if (true == ValidationCheckUtil.emptyCheck(etc)) {
								selectParamMap.put("etc", etc);
							}

							if(true == check){
								// 직원 조회
								List<Map<String, Object>> memberListMap = webMemberSqlMapDAO.selectMember(selectParamMap);
								int memberListMapSize = memberListMap.size();

								if(1 == memberListMapSize){
									selectParamMap.put("muGroupId", memberListMap.get(0).get("muGroupId"));
									selectParamMap.put("muDutyId", memberListMap.get(0).get("muDutyId"));
								}
								else {
									check = false;
									map.put("msgCode", Constants.FAIL);
									map.put("msgDesc", "직원 정보가 올바르지 않습니다.");
								}
							}

							if(true == check){
								// 연차 유형별 기간 중복 확인
								List<Map<String, Object>> vacationManagementListMap = webVacationManagementSqlMapDAO.selectVacationManagementDate(selectParamMap);
								int totalCount = Integer.parseInt(String.valueOf(vacationManagementListMap.get(0).get("totalCount")));

								if (totalCount == 0) {

								} else {
									check = false;
									map.put("msgCode", Constants.FAIL);
									map.put("msgDesc", "이미 등록된 사용기한과 중복됩니다. 사용기한 확인 후 다시 등록하십시오.");
								}
							}
							if(true == check) {
								selectParamMap.put("tDate", tDate);
								selectParamMap.put("tId", tId);

								String muVacationManagementId = ("VM").concat(String.valueOf(System.currentTimeMillis()));
								selectParamMap.put("muVacationManagementId", muVacationManagementId);
								selectParamMap.put("regId", paramMap.get("regId"));
								selectParamMap.put("modId", paramMap.get("modId"));
								webVacationManagementSqlMapDAO.insertVacationManagement(selectParamMap);

								map.put("msgCode", Constants.OK);
								map.put("msgDesc", "등록되었습니다.");

								// 결과 반영
								listMap.get(i).put("muVacationManagementId", selectParamMap.get("muVacationManagementId"));
								listMap.get(i).put("rowCheck", Constants.OK);
								listMap.get(i).put("rowMsgDesc", "");
							}
						}
					}
					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("WebVacationManagementServiceImpl insertVacationManagementExcel END");
		return map;
	}

	/**
	 * 연차관리 정보 수정
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> updateVacationManagement(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebVacationManagementServiceImpl updateVacationManagement START");

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

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

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

		log.debug("muVacationManagementId           :"+paramMap.get("muVacationManagementId"));
		log.debug("days                				:"+paramMap.get("days"));
		log.debug("leftDays           				:"+paramMap.get("leftDays"));
		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 muVacationManagementId        = String.valueOf(paramMap.get("muVacationManagementId"));
			String muMemberId        			 = String.valueOf(paramMap.get("muMemberId"));
			String days              		     = String.valueOf(paramMap.get("days"));
			String leftDays              		 = String.valueOf(paramMap.get("leftDays"));

			if(true != ValidationCheckUtil.emptyCheck(muVacationManagementId)){
				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 != ValidationCheckUtil.emptyCheck(days)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","발행일수 정보가 없습니다.");
			}


			if(true != ValidationCheckUtil.emptyCheck(leftDays)){
				check = false;
				map.put("msgCode", Constants.FAIL);
				map.put("msgDesc","잔여일수 정보가 없습니다.");
			}

			if(true == check){
				// 연차 유형별 기간 중복 확인
				List<Map<String, Object>> vacationManagementListMap = webVacationManagementSqlMapDAO.selectVacationManagementDate(paramMap);
				int totalCount = Integer.parseInt(String.valueOf(vacationManagementListMap.get(0).get("totalCount")));

				if (totalCount == 0) {

				} 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("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){
				paramMap.put("tDate", tDate);
				paramMap.put("tId", tId);

				webVacationManagementSqlMapDAO.updateVacationManagement(paramMap);
				log.debug("muVacationManagementId :"+paramMap.get("id"));
				paramMap.put("muVacationManagementId", paramMap.get("id"));
				map.put("muVacationManagementId", paramMap.get("muVacationManagementId"));

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

		log.debug("WebVacationManagementServiceImpl insertVacationManagement END");
		return map;
	}
	/**
	 * 연차관리 정보 삭제
	 * 
	 * @param paramMap
	 * @return
	 * @throws Exception 
	 */
	@Override
	@Transactional(rollbackFor={Exception.class}, propagation = Propagation.REQUIRES_NEW)
	public HashMap<String, Object> deleteVacationManagement(
			HashMap<String, Object> paramMap) throws Exception{
		log.debug("WebVacationManagementServiceImpl deleteVacationManagement 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 muVacationManagementId = selectData.nextToken();
					
					HashMap<String, Object> deleteParamMap = new HashMap<String, Object>();
					deleteParamMap.put("muVacationManagementId", muVacationManagementId);
					deleteParamMap.put("modId", paramMap.get("loginMemberId"));
					webVacationManagementSqlMapDAO.deleteVacationManagement(deleteParamMap);
				}
				
				map.put("msgCode", Constants.OK);
				map.put("msgDesc", "삭제 되었습니다.");
			}
		}
		catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
		
		log.debug("WebVacationManagementServiceImpl deleteVacationManagement END");
		return map;
	}
	/**
	 * 연차관리 리스트 조회 (Excel)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Map<String, Object>> downloadVacationManagementDetailExcel(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebVacationManagementServiceImpl downloadVacationManagementDetailExcel 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("vacationManagementSort                :"+paramMap.get("vacationManagementSort"));
		log.debug("vacationManagementDir                 :"+paramMap.get("vacationManagementDir"));
		log.debug("vacationManagementStart               :"+paramMap.get("vacationManagementStart"));
		log.debug("vacationManagementLimit               :"+paramMap.get("vacationManagementLimit"));

		log.debug("vacationManagementSearchYear          :"+paramMap.get("vacationManagementSearchYear"));
		log.debug("vacationManagementSearchGroupId       :"+paramMap.get("vacationManagementSearchGroupId"));

		try{
			boolean check  = true;

			String vacationManagementSearchYear    = String.valueOf(paramMap.get("vacationManagementSearchYear"));

			if(true != ValidationCheckUtil.emptyCheck(vacationManagementSearchYear)){
				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("vacationManagementDir")||("").equals(paramMap.get("vacationManagementDir"))){

				}
				else{
					String dir = String.valueOf(paramMap.get("vacationManagementDir"));
					if(("A").equals(dir)){
						paramMap.put("vacationManagementDir", "DESC");
					}
					else if(("B").equals(dir)){
						paramMap.put("vacationManagementDir", "ASC");
					}
					else {
						paramMap.put("vacationManagementDir", "DESC");
					}
				}

				paramMap.put("useYn", "Y");

				listMap = webVacationManagementSqlMapDAO.downloadVacationManagementDetailExcel(paramMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebVacationManagementServiceImpl downloadVacationManagementDetailExcel END");
		return listMap;
	}

	/**
	 * 연차관리 리스트 조회 (Excel)
	 *
	 *
	 * @param paramMap
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Map<String, Object>> selectListMemberExcel(
			HashMap<String, Object> paramMap) throws Exception {
		log.debug("WebVacationManagementServiceImpl selectListMemberExcel START");

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

		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("useYn", "Y");

				listMap = webVacationManagementSqlMapDAO.selectListMemberExcel(paramMap);
			}
		}
		catch(Exception e){
			e.printStackTrace();
			throw e;
		}
		log.debug("WebVacationManagementServiceImpl selectListMemberExcel END");
		return listMap;
	}
}
