/**
   * 받은쪽지함관리 목록을 상세조회 조회한다.
   *
   * @param searchVO -검색정보가 담긴 Model
   * @param commandMap -Request Variable
   * @param noteRecptn -받은쪽지함관리 Model
   * @param model -Spring 제공하는 ModelMap
   * @return String -리턴 URL
   * @throws Exception
   */
  @RequestMapping(value = "/uss/ion/ntr/detailNoteRecptn.do")
  public String EgovNoteRecptnDetail(
      @ModelAttribute("searchVO") NoteRecptn searchVO,
      Map commandMap,
      @ModelAttribute("noteRecptn") NoteRecptn noteRecptn,
      ModelMap model)
      throws Exception {

    String sLocationUrl = "egovframework/com/uss/ion/nts/EgovNoteTrnsmitDetail";

    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");

    if (sCmd.equals("del")) {
      egovNoteRecptnService.deleteNoteRecptn(searchVO);
      return "redirect:/uss/ion/ntr/listNoteRecptn.do";
    } else {
      // 로그인 객체 선언/아이디설정
      LoginVO loginVO = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
      searchVO.setFrstRegisterId((String) loginVO.getUniqId());
      searchVO.setLastUpdusrId((String) loginVO.getUniqId());

      Map noteRecptnMap = egovNoteRecptnService.selectNoteRecptnDetail(searchVO);
      model.addAttribute("noteRecptn", noteRecptnMap);

      egovframework.com.uss.ion.nts.service.NoteTrnsmit noteTrnsmit =
          new egovframework.com.uss.ion.nts.service.NoteTrnsmit();
      noteTrnsmit.setNoteId((String) commandMap.get("noteId"));

      List resultRecptnEmp = egovNoteTrnsmitService.selectNoteTrnsmitCnfirm(noteTrnsmit);
      model.addAttribute("resultRecptnEmp", resultRecptnEmp);
    }

    return "egovframework/com/uss/ion/ntr/EgovNoteRecptnDetail";
  }
  /**
   * 받은쪽지함관리 목록을 조회한다.
   *
   * @param request -HttpServletRequest 객체
   * @param response -HttpServletResponse 객체
   * @param searchVO -검색정보가 담긴 Model
   * @param commandMap -Request Variable
   * @param noteRecptn -받은쪽지함관리 Model
   * @param model -Spring 제공하는 ModelMap
   * @return String -리턴 URL
   * @throws Exception
   */
  @IncludedInfo(name = "받은쪽지함관리", order = 850, gid = 50)
  @RequestMapping(value = "/uss/ion/ntr/listNoteRecptn.do")
  public String EgovNoteRecptnList(
      HttpServletRequest request,
      HttpServletResponse response,
      @ModelAttribute("searchVO") NoteRecptn searchVO,
      Map commandMap,
      @ModelAttribute("noteRecptn") NoteRecptn noteRecptn,
      ModelMap model)
      throws Exception {

    // 변수 설정
    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");

    // Spring Security 사용자권한 처리
    Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
    if (!isAuthenticated) {
      model.addAttribute("message", egovMessageSource.getMessage("fail.common.login"));
      return "egovframework/com/uat/uia/EgovLoginUsr";
    }

    // 로그인 객체 선언
    LoginVO loginVO = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();

    // 삭제 모드로 실행시
    if (sCmd.equals("del")) {
      // 한개의 값으로 삭제가 넘어올때 처리
      if (commandMap.get("checkList") instanceof String) {
        String sCheckList = (String) commandMap.get("checkList");

        String[] sArrCheckListValue = sCheckList.split(",");

        log.debug("==================================EgovNoteRecptnList");
        log.debug("checkList" + sCheckList);
        log.debug("sArrCheckListValue[0]>" + sArrCheckListValue[0]);
        log.debug("sArrCheckListValue[1]>" + sArrCheckListValue[1]);

        noteRecptn.setFrstRegisterId((String) loginVO.getUniqId());
        noteRecptn.setLastUpdusrId((String) loginVO.getUniqId());
        noteRecptn.setNoteId(sArrCheckListValue[0]);
        noteRecptn.setNoteTrnsmitId(sArrCheckListValue[1]);
        noteRecptn.setNoteRecptnId(sArrCheckListValue[2]);

        egovNoteRecptnService.deleteNoteRecptn(noteRecptn);
      }

      // 여러개의 값으로 삭제가 넘어올때 처리
      if (commandMap.get("checkList") instanceof String[]) {
        String[] sArrCheckList = (String[]) commandMap.get("checkList");
        // log.debug("sArrCheckList" + sArrCheckList);

        for (int i = 0; i < sArrCheckList.length; i++) {
          String[] sArrCheckListValue = sArrCheckList[i].split(",");

          noteRecptn.setFrstRegisterId((String) loginVO.getUniqId());
          noteRecptn.setLastUpdusrId((String) loginVO.getUniqId());
          noteRecptn.setNoteId(sArrCheckListValue[0]);
          noteRecptn.setNoteTrnsmitId(sArrCheckListValue[1]);
          noteRecptn.setNoteRecptnId(sArrCheckListValue[2]);

          egovNoteRecptnService.deleteNoteRecptn(noteRecptn);
        }
      }
      // 삭제후 페이지 인덱스 설정
      searchVO.setPageIndex(1);
    }

    /** EgovPropertyService.sample */
    searchVO.setPageUnit(propertiesService.getInt("pageUnit"));
    searchVO.setPageSize(propertiesService.getInt("pageSize"));

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

    searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
    searchVO.setLastIndex(paginationInfo.getLastRecordIndex());
    searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
    // 수신자설정
    searchVO.setRcverId((String) loginVO.getUniqId());

    List reusltList = egovNoteRecptnService.selectNoteRecptnList(searchVO);
    model.addAttribute("resultList", reusltList);

    model.addAttribute(
        "searchKeyword",
        commandMap.get("searchKeyword") == null ? "" : (String) commandMap.get("searchKeyword"));
    model.addAttribute(
        "searchCondition",
        commandMap.get("searchCondition") == null
            ? ""
            : (String) commandMap.get("searchCondition"));

    int totCnt = (Integer) egovNoteRecptnService.selectNoteRecptnListCnt(searchVO);
    paginationInfo.setTotalRecordCount(totCnt);
    model.addAttribute("paginationInfo", paginationInfo);

    return "egovframework/com/uss/ion/ntr/EgovNoteRecptnList";
  }