/**
   * 설문문항 목록을 상세조회 조회한다.
   *
   * @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/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 QustnrQestnManage - 회정정보가 담김 VO
  * @return List
  * @throws Exception
  */
 public List selectQustnrQestnManageDetail(QustnrQestnManageVO qustnrQestnManageVO)
     throws Exception {
   return egovQustnrQestnManageService.selectQustnrQestnManageDetail(qustnrQestnManageVO);
 }
  /**
   * 설문문항를 수정한다.
   *
   * @param searchVO
   * @param commandMap
   * @param qustnrQestnManageVO
   * @param bindingResult
   * @param model
   * @return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageModify"
   * @throws Exception
   */
  @RequestMapping(value = "/uss/olp/qqm/EgovQustnrQestnManageModify.do")
  public String qustnrQestnManageModify(
      @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/EgovQustnrQestnManageModify";

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

    // 공통코드 질문유형 조회
    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));
        }

        List resultList =
            egovQustnrQestnManageService.selectQustnrQestnManageDetail(qustnrQestnManageVO);
        model.addAttribute("resultList", resultList);
        return "egovframework/com/uss/olp/qqm/EgovQustnrQestnManageModify";
      }

      // 아이디 설정
      qustnrQestnManageVO.setFrstRegisterId((String) loginVO.getUniqId());
      qustnrQestnManageVO.setLastUpdusrId((String) loginVO.getUniqId());

      egovQustnrQestnManageService.updateQustnrQestnManage(qustnrQestnManageVO);
      /** 목록으로갈때 검색조건 유지 */
      sLocationUrl = "redirect:/uss/olp/qqm/EgovQustnrQestnManageList.do?";
      sLocationUrl = sLocationUrl + "searchMode=" + qustnrQestnManageVO.getSearchMode();
      sLocationUrl = sLocationUrl + "&qestnrId=" + qustnrQestnManageVO.getQestnrId();
      sLocationUrl = sLocationUrl + "&qestnrTmplatId=" + qustnrQestnManageVO.getQestnrTmplatId();
    } else {
      List resultList =
          egovQustnrQestnManageService.selectQustnrQestnManageDetail(qustnrQestnManageVO);
      model.addAttribute("resultList", resultList);
    }

    return sLocationUrl;
  }