/**
   * 연계기관 상세내역을 조회한다.
   *
   * @param loginVO
   * @param cntcInstt
   * @param model
   * @return "egovframework/com/ssi/syi/iis/EgovCcmCntcInsttDetail"
   * @throws Exception
   */
  @RequestMapping(value = "/ssi/syi/iis/getCntcInsttDetail.do")
  public String selectCntcInsttDetail(
      @ModelAttribute("cntcInstt") CntcInstt cntcInstt,
      @ModelAttribute("cntcSystemVO") CntcSystemVO cntcSystemVO,
      @ModelAttribute("cntcServiceVO") CntcServiceVO cntcServiceVO,
      ModelMap model)
      throws Exception {
    // 연계메시지 리스트박스 데이터
    CntcMessageVO searchCntcMessageVO;
    searchCntcMessageVO = new CntcMessageVO();
    searchCntcMessageVO.setRecordCountPerPage(999999);
    searchCntcMessageVO.setFirstIndex(0);
    searchCntcMessageVO.setSearchCondition("CodeList");
    List<?> cntcMessageList = cntcMessageService.selectCntcMessageList(searchCntcMessageVO);
    model.addAttribute("cntcMessageList", cntcMessageList);

    /* 연계기관 상세 */
    CntcInstt vo = cntcInsttService.selectCntcInsttDetail(cntcInstt);
    model.addAttribute("result", vo);

    /* 연계시스템 리스트 */
    cntcSystemVO.setRecordCountPerPage(999999);
    cntcSystemVO.setFirstIndex(0);
    cntcSystemVO.setSearchCondition("CodeList");
    List<?> cntcSystemList = cntcInsttService.selectCntcSystemList(cntcSystemVO);
    model.addAttribute("cntcSystemList", cntcSystemList);

    /* 연계서비스 리스트 */
    cntcServiceVO.setRecordCountPerPage(999999);
    cntcServiceVO.setFirstIndex(0);
    cntcServiceVO.setSearchCondition("CodeList_InsttId");
    List<?> cntcServiceList = cntcInsttService.selectCntcServiceList(cntcServiceVO);
    model.addAttribute("cntcServiceList", cntcServiceList);

    return "egovframework/com/ssi/syi/iis/EgovCntcInsttDetail";
  }
  /**
   * 연계서비스를 수정한다.
   *
   * @param loginVO
   * @param cntcService
   * @param bindingResult
   * @param commandMap
   * @param model
   * @return "egovframework/com/ssi/syi/iis/EgovCntcServiceModify"
   * @throws Exception
   */
  @RequestMapping(value = "/ssi/syi/iis/updateCntcService.do")
  public String updateCntcService(
      @ModelAttribute("cntcService") CntcService cntcService,
      BindingResult bindingResult,
      @RequestParam Map<?, ?> commandMap,
      ModelMap model)
      throws Exception {
    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");
    if (sCmd.equals("")) {
      // 연계기관 리스트박스 데이터
      CntcInsttVO searchCntcInsttVO;
      searchCntcInsttVO = new CntcInsttVO();
      searchCntcInsttVO.setRecordCountPerPage(999999);
      searchCntcInsttVO.setFirstIndex(0);
      searchCntcInsttVO.setSearchCondition("CodeList");
      List<?> cntcInsttList = cntcInsttService.selectCntcInsttList(searchCntcInsttVO);
      model.addAttribute("cntcInsttList", cntcInsttList);

      // 연계시스템 리스트박스 데이터
      CntcSystemVO searchCntcSystemVO;
      searchCntcSystemVO = new CntcSystemVO();
      searchCntcSystemVO.setRecordCountPerPage(999999);
      searchCntcSystemVO.setFirstIndex(0);
      searchCntcSystemVO.setSearchCondition("CodeList");
      if (cntcService.getInsttId().equals("")) {
        if (cntcInsttList.size() > 0) {
          EgovMap emp = (EgovMap) cntcInsttList.get(0);
          cntcService.setInsttId(emp.get("insttId").toString());
        }
      }
      searchCntcSystemVO.setInsttId(cntcService.getInsttId());
      List<?> cntcSystemList = cntcInsttService.selectCntcSystemList(searchCntcSystemVO);
      model.addAttribute("cntcSystemList", cntcSystemList);

      // 연계메시지 리스트박스 데이터
      CntcMessageVO searchCntcMessageVO;
      searchCntcMessageVO = new CntcMessageVO();
      searchCntcMessageVO.setRecordCountPerPage(999999);
      searchCntcMessageVO.setFirstIndex(0);
      searchCntcMessageVO.setSearchCondition("CodeList");
      List<?> cntcMessageList = cntcMessageService.selectCntcMessageList(searchCntcMessageVO);
      model.addAttribute("cntcMessageList", cntcMessageList);

      CntcService vo = cntcInsttService.selectCntcServiceDetail(cntcService);
      model.addAttribute("cntcService", vo);

      return "egovframework/com/ssi/syi/iis/EgovCntcServiceUpdt";
    } else if (sCmd.equals("Modify")) {
      beanValidator.validate(cntcService, bindingResult);
      if (bindingResult.hasErrors()) {
        // 연계기관 리스트박스 데이터
        CntcInsttVO searchCntcInsttVO;
        searchCntcInsttVO = new CntcInsttVO();
        searchCntcInsttVO.setRecordCountPerPage(999999);
        searchCntcInsttVO.setFirstIndex(0);
        searchCntcInsttVO.setSearchCondition("CodeList");
        List<?> cntcInsttList = cntcInsttService.selectCntcInsttList(searchCntcInsttVO);
        model.addAttribute("cntcInsttList", cntcInsttList);

        // 연계시스템 리스트박스 데이터
        CntcSystemVO searchCntcSystemVO;
        searchCntcSystemVO = new CntcSystemVO();
        searchCntcSystemVO.setRecordCountPerPage(999999);
        searchCntcSystemVO.setFirstIndex(0);
        searchCntcSystemVO.setSearchCondition("CodeList");
        if (cntcService.getInsttId().equals("")) {
          if (cntcInsttList.size() > 0) {
            EgovMap emp = (EgovMap) cntcInsttList.get(0);
            cntcService.setInsttId(emp.get("insttId").toString());
          }
        }
        searchCntcSystemVO.setInsttId(cntcService.getInsttId());
        List<?> cntcSystemList = cntcInsttService.selectCntcSystemList(searchCntcSystemVO);
        model.addAttribute("cntcSystemList", cntcSystemList);

        // 연계메시지 리스트박스 데이터
        CntcMessageVO searchCntcMessageVO;
        searchCntcMessageVO = new CntcMessageVO();
        searchCntcMessageVO.setRecordCountPerPage(999999);
        searchCntcMessageVO.setFirstIndex(0);
        searchCntcMessageVO.setSearchCondition("CodeList");
        List<?> cntcMessageList = cntcMessageService.selectCntcMessageList(searchCntcMessageVO);
        model.addAttribute("cntcMessageList", cntcMessageList);

        CntcService vo = cntcInsttService.selectCntcServiceDetail(cntcService);
        model.addAttribute("cntcService", vo);

        return "egovframework/com/ssi/syi/iis/EgovCntcServiceUpdt";
      }

      // 로그인VO에서  사용자 정보 가져오기
      LoginVO loginVO = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
      String uniqId = loginVO.getUniqId();

      cntcService.setLastUpdusrId(uniqId);
      cntcInsttService.updateCntcService(cntcService);
      return "forward:/ssi/syi/iis/getCntcInsttList.do";
    } else {
      return "forward:/ssi/syi/iis/getCntcInsttList.do";
    }
  }