/**
   * 설문문항 목록을 상세조회 조회한다.
   *
   * @param searchVO
   * @param qustnrQestnManageVO
   * @param commandMap
   * @param model
   * @return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageDetail"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qqm/EgovQustnrQestnManageDetail.do")
  public String egovQustnrQestnManageDetail(
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      @ModelAttribute("qustnrQestnManageVO") QustnrQestnManageVO qustnrQestnManageVO,
      Map commandMap,
      ModelMap model)
      throws Exception {

    String sLocationUrl = "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageDetail";

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

    if (sCmd.equals("del")) {
      egovQustnrQestnManageService.deleteQustnrQestnManage(qustnrQestnManageVO);
      /** 목록으로갈때 검색조건 유지 */
      sLocationUrl = "redirect:/uss/olp/qqm/EgovQustnrQestnManageList.do?";
      sLocationUrl = sLocationUrl + "searchMode=" + qustnrQestnManageVO.getSearchMode();
      sLocationUrl = sLocationUrl + "&qestnrId=" + qustnrQestnManageVO.getQestnrId();
      sLocationUrl = sLocationUrl + "&qestnrTmplatId=" + qustnrQestnManageVO.getQestnrTmplatId();
    } else {
      // 공통코드 질문유형 조회
      ComDefaultCodeVO voComCode = new ComDefaultCodeVO();
      voComCode.setCodeId("COM018");
      List listComCode = cmmUseService.selectCmmCodeDetail(voComCode);
      model.addAttribute("cmmCode018", listComCode);

      List sampleList =
          egovQustnrQestnManageService.selectQustnrQestnManageDetail(qustnrQestnManageVO);
      model.addAttribute("resultList", sampleList);
    }

    return sLocationUrl;
  }
  /**
   * 설문문항 목록을 조회한다.
   *
   * @param searchVO
   * @param qustnrQestnManageVO
   * @param commandMap
   * @param model
   * @return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageList"
   * @throws Exception
   */
  @IncludedInfo(name = "질문관리", order = 630, gid = 50)
  @RequestMapping(value = "/uss/olp/qqm/EgovQustnrQestnManageList.do")
  public String egovQustnrQestnManageList(
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      @ModelAttribute("qustnrQestnManageVO") QustnrQestnManageVO qustnrQestnManageVO,
      Map commandMap,
      ModelMap model)
      throws Exception {
    // 0. 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();

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

    if (sCmd.equals("del")) {
      egovQustnrQestnManageService.deleteQustnrQestnManage(qustnrQestnManageVO);
    }

    // 설문지정보에서 넘어오면 자동검색 설정
    if (sSearchMode.equals("Y")) {
      searchVO.setSearchCondition("QESTNR_ID");
      searchVO.setSearchKeyword(qustnrQestnManageVO.getQestnrId());
    }

    /** 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());

    List sampleList = egovQustnrQestnManageService.selectQustnrQestnManageList(searchVO);
    model.addAttribute("resultList", sampleList);

    int totCnt = (Integer) egovQustnrQestnManageService.selectQustnrQestnManageListCnt(searchVO);
    paginationInfo.setTotalRecordCount(totCnt);
    model.addAttribute("paginationInfo", paginationInfo);

    return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageList";
  }
  /**
   * 설문문항 팝업 록을 조회한다.
   *
   * @param searchVO
   * @param qustnrQestnManageVO
   * @param commandMap
   * @param model
   * @return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageListPopup"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qqm/EgovQustnrQestnManageListPopup.do")
  public String egovQustnrQestnManageListPopup(
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      @ModelAttribute("qustnrQestnManageVO") QustnrQestnManageVO qustnrQestnManageVO,
      Map commandMap,
      ModelMap model)
      throws Exception {

    String sSearchMode =
        commandMap.get("searchMode") == null ? "" : (String) commandMap.get("searchMode");

    // 설문지정보에서 넘어오면 자동검색 설정
    if (sSearchMode.equals("Y")) {
      searchVO.setSearchCondition("QESTNR_ID");
      searchVO.setSearchKeyword(qustnrQestnManageVO.getQestnrId());
    }

    /** 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());

    List resultList = egovQustnrQestnManageService.selectQustnrQestnManageList(searchVO);
    model.addAttribute("resultList", resultList);

    int totCnt = (Integer) egovQustnrQestnManageService.selectQustnrQestnManageListCnt(searchVO);
    paginationInfo.setTotalRecordCount(totCnt);
    model.addAttribute("paginationInfo", paginationInfo);

    return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageListPopup";
  }
  /**
   * 설문항목 통계를 조회한다.
   *
   * @param searchVO
   * @param qustnrQestnManageVO
   * @param commandMap
   * @param model
   * @return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageStatistics"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qqm/EgovQustnrQestnManageStatistics.do")
  public String egovQustnrQestnManageStatistics(
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      QustnrQestnManageVO qustnrQestnManageVO,
      Map commandMap,
      ModelMap model)
      throws Exception {

    String sLocationUrl = "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageStatistics";

    List sampleList =
        egovQustnrQestnManageService.selectQustnrQestnManageDetail(qustnrQestnManageVO);
    model.addAttribute("resultList", sampleList);
    // 객관식설문통계
    HashMap mapParam = new HashMap();
    mapParam.put("qestnrQesitmId", (String) qustnrQestnManageVO.getQestnrQesitmId());
    List statisticsList = egovQustnrQestnManageService.selectQustnrManageStatistics(mapParam);
    model.addAttribute("statisticsList", statisticsList);
    // 주관식설문통계
    List statisticsList2 = egovQustnrQestnManageService.selectQustnrManageStatistics2(mapParam);
    model.addAttribute("statisticsList2", statisticsList2);
    return sLocationUrl;
  }
 /**
  * 설문조사 응답자답변내용결과/기타답변내용결과 통계를 조회한다.
  *
  * @param Map - 설문지 정보가 담김 Parameter
  * @return Map
  * @throws Exception
  */
 public List selectQustnrManageStatistics2(Map map) throws Exception {
   return egovQustnrQestnManageService.selectQustnrManageStatistics2(map);
 }
 /**
  * 설문문항를(을) 수정한다.
  *
  * @param searchVO - 조회할 정보가 담긴 VO
  * @throws Exception
  */
 public void updateQustnrQestnManage(QustnrQestnManageVO qustnrQestnManageVO) throws Exception {
   egovQustnrQestnManageService.updateQustnrQestnManage(qustnrQestnManageVO);
 }
 /**
  * 설문문항를(을) 상세조회 한다.
  *
  * @param QustnrQestnManage - 회정정보가 담김 VO
  * @return List
  * @throws Exception
  */
 public List selectQustnrQestnManageDetail(QustnrQestnManageVO qustnrQestnManageVO)
     throws Exception {
   return egovQustnrQestnManageService.selectQustnrQestnManageDetail(qustnrQestnManageVO);
 }
 /**
  * 설문문항를(을) 등록한다.
  *
  * @param searchVO - 조회할 정보가 담긴 VO
  * @throws Exception
  */
 public void insertQustnrQestnManage(QustnrQestnManageVO qustnrQestnManageVO) throws Exception {
   egovQustnrQestnManageService.insertQustnrQestnManage(qustnrQestnManageVO);
 }
 /**
  * 설문문항 목록을 조회한다.
  *
  * @param searchVO - 조회할 정보가 담긴 VO
  * @return List
  * @throws Exception
  */
 public List selectQustnrQestnManageList(ComDefaultVO searchVO) throws Exception {
   return egovQustnrQestnManageService.selectQustnrQestnManageList(searchVO);
 }
  /**
   * 설문문항를 등록한다.
   *
   * @param searchVO
   * @param commandMap
   * @param qustnrQestnManageVO
   * @param bindingResult
   * @param model
   * @return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageRegist"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qqm/EgovQustnrQestnManageRegist.do")
  public String qustnrQestnManageRegist(
      @ModelAttribute("searchVO") ComDefaultVO searchVO,
      Map commandMap,
      @ModelAttribute("qustnrQestnManageVO") QustnrQestnManageVO qustnrQestnManageVO,
      BindingResult bindingResult,
      ModelMap model)
      throws Exception {
    // 0. 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();

    String sLocationUrl = "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageRegist";

    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");
    log.info("cmd =>" + sCmd);

    // 공통코드 질문유형 조회
    ComDefaultCodeVO voComCode = new ComDefaultCodeVO();
    voComCode.setCodeId("COM018");
    List listComCode = cmmUseService.selectCmmCodeDetail(voComCode);
    model.addAttribute("cmmCode018", listComCode);

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

      // 서버  validate 체크
      beanValidator.validate(qustnrQestnManageVO, bindingResult);
      if (bindingResult.hasErrors()) {
        // 설문제목가져오기
        String sQestnrId =
            commandMap.get("qestnrId") == null ? "" : (String) commandMap.get("qestnrId");
        String sQestnrTmplatId =
            commandMap.get("qestnrTmplatId") == null
                ? ""
                : (String) commandMap.get("qestnrTmplatId");

        log.info("sQestnrId =>" + sQestnrId);
        log.info("sQestnrTmplatId =>" + sQestnrTmplatId);
        if (!sQestnrId.equals("") && !sQestnrTmplatId.equals("")) {

          Map mapQustnrManage = new HashMap();
          mapQustnrManage.put("qestnrId", sQestnrId);
          mapQustnrManage.put("qestnrTmplatId", sQestnrTmplatId);

          model.addAttribute(
              "qestnrInfo",
              (Map) egovQustnrQestnManageService.selectQustnrManageQestnrSj(mapQustnrManage));
        }

        return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageRegist";
      }

      // 아이디 설정
      qustnrQestnManageVO.setFrstRegisterId((String) loginVO.getUniqId());
      qustnrQestnManageVO.setLastUpdusrId((String) loginVO.getUniqId());
      /** 목록으로갈때 검색조건 유지 */
      egovQustnrQestnManageService.insertQustnrQestnManage(qustnrQestnManageVO);
      sLocationUrl = "redirect:/uss/olp/qqm/EgovQustnrQestnManageList.do?";
      sLocationUrl = sLocationUrl + "searchMode=" + qustnrQestnManageVO.getSearchMode();
      sLocationUrl = sLocationUrl + "&qestnrId=" + qustnrQestnManageVO.getQestnrId();
      sLocationUrl = sLocationUrl + "&qestnrTmplatId=" + qustnrQestnManageVO.getQestnrTmplatId();

    } else {

      // 설문제목가져오기
      String sQestnrId =
          commandMap.get("qestnrId") == null ? "" : (String) commandMap.get("qestnrId");
      String sQestnrTmplatId =
          commandMap.get("qestnrTmplatId") == null ? "" : (String) commandMap.get("qestnrTmplatId");

      log.info("sQestnrId =>" + sQestnrId);
      log.info("sQestnrTmplatId =>" + sQestnrTmplatId);
      if (!sQestnrId.equals("") && !sQestnrTmplatId.equals("")) {

        Map mapQustnrManage = new HashMap();
        mapQustnrManage.put("qestnrId", sQestnrId);
        mapQustnrManage.put("qestnrTmplatId", sQestnrTmplatId);

        model.addAttribute(
            "qestnrInfo",
            (Map) egovQustnrQestnManageService.selectQustnrManageQestnrSj(mapQustnrManage));
      }
    }

    return sLocationUrl;
  }