/**
   * 등록된 휴가관리의 상세정보를 조회한다.
   *
   * @param vcatnManageVO - 휴가관리 VO
   * @return String - 리턴 Url
   */
  @RequestMapping(value = "/uss/ion/vct/EgovVcatnManageDetail.do")
  public String selectVcatnManage(
      @ModelAttribute("vcatnManageVO") VcatnManageVO vcatnManageVO,
      @ModelAttribute("vcatnManage") VcatnManage vcatnManage,
      @RequestParam Map<?, ?> commandMap,
      ModelMap model)
      throws Exception {
    List<?> vcatnSeCodeList = null;
    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd"); // 상세정보 구분
    vcatnManageVO.setBgnde(EgovStringUtil.removeMinusChar(vcatnManageVO.getBgnde()));
    vcatnManageVO.setEndde(EgovStringUtil.removeMinusChar(vcatnManageVO.getEndde()));

    // 등록 상세정보
    VcatnManageVO vcatnManageVOTemp = egovVcatnManageService.selectVcatnManage(vcatnManageVO);

    model.addAttribute("vcatnManageVO", vcatnManageVOTemp);
    model.addAttribute("message", egovMessageSource.getMessage("success.common.select"));

    if (sCmd.equals("updt")) {

      ComDefaultCodeVO vo = new ComDefaultCodeVO();
      vo.setCodeId("COM056");
      vcatnSeCodeList = cmmUseService.selectCmmCodeDetail(vo);

      model.addAttribute("vcatnSeCode", vcatnSeCodeList);
      model.addAttribute("vcatnManage", vcatnManageVOTemp);
      return "egovframework/com/uss/ion/vct/EgovVcatnUpdt";
    } else {
      return "egovframework/com/uss/ion/vct/EgovVcatnDetail";
    }
  }
  /**
   * 휴가승인관리 상세정보를 조회한다.
   *
   * @param vcatnManageVO - 휴가관리 VO
   * @return String - 리턴 Url
   */
  @RequestMapping(value = "/uss/ion/vct/EgovVcatnConfm.do")
  public String selectVcatnConfm(
      @ModelAttribute("vcatnManageVO") VcatnManageVO vcatnManageVO,
      @ModelAttribute("vcatnManage") VcatnManage vcatnManage,
      ModelMap model)
      throws Exception {
    vcatnManageVO.setBgnde(EgovStringUtil.removeMinusChar(vcatnManageVO.getBgnde()));
    vcatnManageVO.setEndde(EgovStringUtil.removeMinusChar(vcatnManageVO.getEndde()));

    // 등록 상세정보
    VcatnManageVO vcatnManageVOTemp = egovVcatnManageService.selectVcatnManage(vcatnManageVO);

    model.addAttribute("vcatnManageVO", vcatnManageVOTemp);
    model.addAttribute("vcatnManage", vcatnManageVOTemp);
    model.addAttribute("message", egovMessageSource.getMessage("success.common.select"));

    return "egovframework/com/uss/ion/vct/EgovVcatnConfm";
  }
  /**
   * 휴가관리 등록 화면으로 이동한다.
   *
   * @return String - 리턴 Url
   */
  @RequestMapping(value = "/uss/ion/vct/EgovVcatnRegist.do")
  public String insertViewVcatnManage(
      @ModelAttribute("vcatnManage") VcatnManage vcatnManage,
      @ModelAttribute("vcatnManageVO") VcatnManageVO vcatnManageVO,
      ModelMap model)
      throws Exception {
    List<?> vcatnSeCodeList = null;
    LoginVO user = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();

    VcatnManageVO vcatnManageVO1 = egovVcatnManageService.selectIndvdlYrycManage(user.getUniqId());
    vcatnManageVO1.setApplcntId(user.getUniqId());
    vcatnManageVO1.setApplcntNm(user.getName());
    vcatnManageVO1.setOrgnztNm(user.getOrgnztNm());

    ComDefaultCodeVO vo = new ComDefaultCodeVO();
    vo.setCodeId("COM056");
    vcatnSeCodeList = cmmUseService.selectCmmCodeDetail(vo);

    model.addAttribute("vcatnSeCode", vcatnSeCodeList);
    model.addAttribute("vcatnManageVO", vcatnManageVO1);

    return "egovframework/com/uss/ion/vct/EgovVcatnRegist";
  }
  /**
   * 휴가관리정보를 관리하기 위해 등록된 휴가관리 목록을 조회한다.
   *
   * @param vcatnManageVO - 휴가관리 VO
   * @return String - 리턴 Url
   */
  @IncludedInfo(name = "휴가관리", order = 900, gid = 50)
  @RequestMapping(value = "/uss/ion/vct/EgovVcatnManageList.do")
  public String selectVcatnManageList(
      @ModelAttribute("vcatnManageVO") VcatnManageVO vcatnManageVO, ModelMap model)
      throws Exception {

    java.util.Calendar cal = java.util.Calendar.getInstance();
    String[] yearList = new String[5];
    for (int x = 0; x < 5; x++) {
      yearList[x] = Integer.toString(cal.get(java.util.Calendar.YEAR) - x);
    }

    /** paging */
    PaginationInfo paginationInfo = new PaginationInfo();
    paginationInfo.setCurrentPageNo(vcatnManageVO.getPageIndex());
    paginationInfo.setRecordCountPerPage(vcatnManageVO.getPageUnit());
    paginationInfo.setPageSize(vcatnManageVO.getPageSize());

    vcatnManageVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
    vcatnManageVO.setLastIndex(paginationInfo.getLastRecordIndex());
    vcatnManageVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());

    LoginVO user = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
    vcatnManageVO.setApplcntId(user.getUniqId());
    vcatnManageVO.setVcatnManageList(egovVcatnManageService.selectVcatnManageList(vcatnManageVO));

    model.addAttribute("vcatnManageList", vcatnManageVO.getVcatnManageList());
    int totCnt = egovVcatnManageService.selectVcatnManageListTotCnt(vcatnManageVO);
    paginationInfo.setTotalRecordCount(totCnt);
    model.addAttribute("yearList", yearList);
    model.addAttribute("paginationInfo", paginationInfo);

    model.addAttribute("message", egovMessageSource.getMessage("success.common.select"));

    return "egovframework/com/uss/ion/vct/EgovVcatnManageList";
  }
  /**
   * 기 등록된 휴가관리정보를 수정한다.
   *
   * @param vcatnManage - 휴가관리 model
   * @return String - 리턴 Url
   */
  @RequestMapping(value = "/uss/ion/vct/updtVcatnManage.do")
  public String updtVcatnManage(
      @ModelAttribute("vcatnManage") VcatnManage vcatnManage,
      @ModelAttribute("vcatnManageVO") VcatnManageVO vcatnManageVO,
      BindingResult bindingResult,
      SessionStatus status,
      ModelMap model)
      throws Exception {
    String sTemp = null;
    String sTempMessage = null;
    int iTemp = 0;
    /*
    		beanValidator.validate(vcatnManage, bindingResult); //validation 수행

        	if (bindingResult.hasErrors()) {
        		model.addAttribute("vcatnManageVO", vcatnManageVO);
    			return "egovframework/com/uss/ion/vct/EgovVcatnUpdt";
    		} else {

    	    	vcatnManage.setBgnde(EgovStringUtil.removeMinusChar(vcatnManage.getBgnde()));
    	    	vcatnManage.setEndde(EgovStringUtil.removeMinusChar(vcatnManage.getEndde()));
    	    	sTempMessage = egovVcatnManageService.updtVcatnManage(vcatnManage, vcatnManageVO);
    	    	return "forward:/uss/ion/vct/EgovVcatnManageList.do";
    		}
    */
    LoginVO user = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
    vcatnManage.setFrstRegisterId(user.getUniqId());
    sTemp = egovVcatnManageService.updtVcatnManage(vcatnManage, vcatnManageVO);
    if (iTemp != 10) {
      status.setComplete();
      // sTemp = egovVcatnManageService.insertVcatnManage(vcatnManage, vcatnManageVO);

      if (sTemp.equals("01")) {
        sTempMessage = "입력성공";
        model.addAttribute("message", sTempMessage);
        return "forward:/uss/ion/vct/EgovVcatnManageList.do";
      } else {
        if (sTemp.equals("99")) sTempMessage = "휴가일자 지정 오류 - 휴가시작일자/종료일자를 확인하세요.";
        if (sTemp.equals("09")) sTempMessage = "연차사용시 휴가는 당해연도만 가능합니다.";
        if (sTemp.equals("02")) sTempMessage = "연차휴가 등록실패(잔여연차 부족)";
        if (sTemp.equals("03")) sTempMessage = "반차휴가 등록실패(잔여연차 부족)";
        model.addAttribute("errorMessage", sTempMessage);

        VcatnManageVO vcatnManageVO1 =
            egovVcatnManageService.selectIndvdlYrycManage(user.getUniqId());
        vcatnManageVO1.setApplcntId(user.getUniqId());
        vcatnManageVO1.setApplcntNm(user.getName());
        vcatnManageVO1.setOrgnztNm(user.getOrgnztNm());
        vcatnManageVO1.setTempBgnde(EgovDateUtil.formatDate(vcatnManage.getBgnde(), "-"));
        vcatnManageVO1.setTempEndde(EgovDateUtil.formatDate(vcatnManage.getEndde(), "-"));

        model.addAttribute("vcatnManageVO", vcatnManageVO1);
        ComDefaultCodeVO vo = new ComDefaultCodeVO();
        vo.setCodeId("COM056");
        List<?> vcatnSeCodeList = cmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("vcatnSeCode", vcatnSeCodeList);

        return "egovframework/com/uss/ion/vct/EgovVcatnUpdt";
      }
    } else {

      sTempMessage = "휴가일자가 중복되었습니다. 휴가일자를 확인해 주세요.";
      model.addAttribute("errorMessage", sTempMessage);

      VcatnManageVO vcatnManageVO1 =
          egovVcatnManageService.selectIndvdlYrycManage(user.getUniqId());
      vcatnManageVO1.setApplcntId(user.getUniqId());
      vcatnManageVO1.setApplcntNm(user.getName());
      vcatnManageVO1.setOrgnztNm(user.getOrgnztNm());
      model.addAttribute("vcatnManageVO", vcatnManageVO1);

      ComDefaultCodeVO vo = new ComDefaultCodeVO();
      vo.setCodeId("COM056");
      List<?> vcatnSeCodeList = cmmUseService.selectCmmCodeDetail(vo);
      model.addAttribute("vcatnSeCode", vcatnSeCodeList);

      return "egovframework/com/uss/ion/vct/EgovVcatnUpdt";
    }
  }
  /**
   * 휴가관리정보를 신규로 등록한다.
   *
   * @param vcatnManage - 휴가관리 model
   * @return String - 리턴 Url
   */
  @RequestMapping(value = "/uss/ion/vct/insertVcatnManage.do")
  public String insertVcatnManage(
      @ModelAttribute("vcatnManage") VcatnManage vcatnManage,
      @ModelAttribute("vcatnManageVO") VcatnManageVO vcatnManageVO,
      BindingResult bindingResult,
      SessionStatus status,
      @RequestParam Map<?, ?> commandMap,
      ModelMap model)
      throws Exception {
    // 승인권자 소속명, 성명   유지
    model.addAttribute(
        "infSanctnDtNm",
        commandMap.get("sanctnDtNm") == null ? "" : (String) commandMap.get("sanctnDtNm"));
    model.addAttribute(
        "infOrgnztNm",
        commandMap.get("orgnztNm") == null ? "" : (String) commandMap.get("orgnztNm"));

    String sEnddeView =
        commandMap.get("enddeView") == null ? "" : (String) commandMap.get("enddeView"); // 종료일자 구분
    if (!sEnddeView.equals("")) vcatnManage.setEndde(sEnddeView);

    String sTemp = null;
    String sTempMessage = null;
    int iTemp = 0;

    beanValidator.validate(vcatnManage, bindingResult); // validation 수행

    if (bindingResult.hasErrors()) {
      model.addAttribute("vcatnManageVO", vcatnManageVO);
      return "egovframework/com/uss/ion/vct/EgovVcatnRegist";
    } else {
      LoginVO user = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
      if (vcatnManage.getSanctnerId() != null) vcatnManage.setConfmAt("A");
      vcatnManage.setApplcntId(user.getUniqId());
      vcatnManage.setFrstRegisterId(user.getUniqId());

      vcatnManageVO.setApplcntId(user.getUniqId());
      vcatnManageVO.setSearchKeyword(EgovStringUtil.removeMinusChar(vcatnManage.getBgnde()));
      // 시작일자  포함여부
      iTemp = egovVcatnManageService.selectVcatnManageDplctAt(vcatnManageVO);
      vcatnManageVO.setSearchKeyword(EgovStringUtil.removeMinusChar(vcatnManage.getEndde()));
      // 종료일자  포함여부
      iTemp += egovVcatnManageService.selectVcatnManageDplctAt(vcatnManageVO);

      if (iTemp == 0) {
        status.setComplete();
        sTemp = egovVcatnManageService.insertVcatnManage(vcatnManage, vcatnManageVO);

        if (sTemp.equals("01")) {
          sTempMessage = "입력성공";
          model.addAttribute("message", sTempMessage);
          return "forward:/uss/ion/vct/EgovVcatnManageList.do";
        } else {
          if (sTemp.equals("99")) sTempMessage = "휴가일자 지정 오류 - 휴가시작일자/종료일자를 확인하세요.";
          if (sTemp.equals("09")) sTempMessage = "연차사용시 휴가는 당해연도만 가능합니다.";
          if (sTemp.equals("02")) sTempMessage = "연차휴가 등록실패(잔여연차 부족)";
          if (sTemp.equals("03")) sTempMessage = "반차휴가 등록실패(잔여연차 부족)";
          model.addAttribute("errorMessage", sTempMessage);

          VcatnManageVO vcatnManageVO1 =
              egovVcatnManageService.selectIndvdlYrycManage(user.getUniqId());
          vcatnManageVO1.setApplcntId(user.getUniqId());
          vcatnManageVO1.setApplcntNm(user.getName());
          vcatnManageVO1.setOrgnztNm(user.getOrgnztNm());
          vcatnManageVO1.setTempBgnde(EgovDateUtil.formatDate(vcatnManage.getBgnde(), "-"));
          vcatnManageVO1.setTempEndde(EgovDateUtil.formatDate(vcatnManage.getEndde(), "-"));

          model.addAttribute("vcatnManageVO", vcatnManageVO1);
          ComDefaultCodeVO vo = new ComDefaultCodeVO();
          vo.setCodeId("COM056");
          List<?> vcatnSeCodeList = cmmUseService.selectCmmCodeDetail(vo);
          model.addAttribute("vcatnSeCode", vcatnSeCodeList);

          return "egovframework/com/uss/ion/vct/EgovVcatnRegist";
        }
      } else {

        sTempMessage = "휴가일자가 중복되었습니다. 휴가일자를 확인해 주세요.";
        model.addAttribute("errorMessage", sTempMessage);

        VcatnManageVO vcatnManageVO1 =
            egovVcatnManageService.selectIndvdlYrycManage(user.getUniqId());
        vcatnManageVO1.setApplcntId(user.getUniqId());
        vcatnManageVO1.setApplcntNm(user.getName());
        vcatnManageVO1.setOrgnztNm(user.getOrgnztNm());
        model.addAttribute("vcatnManageVO", vcatnManageVO1);

        ComDefaultCodeVO vo = new ComDefaultCodeVO();
        vo.setCodeId("COM056");
        List<?> vcatnSeCodeList = cmmUseService.selectCmmCodeDetail(vo);
        model.addAttribute("vcatnSeCode", vcatnSeCodeList);

        return "egovframework/com/uss/ion/vct/EgovVcatnRegist";
      }
    }
  }