/**
   * 기 등록된 휴가관리정보를 수정한다.
   *
   * @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";
      }
    }
  }