/**
   * 공통분류코드 목록을 조회한다.
   *
   * @param loginVO
   * @param searchVO
   * @param model
   * @return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeList"
   * @throws Exception
   */
  @IncludedInfo(
      name = "공통분류코드",
      listUrl = "/sym/ccm/ccc/EgovCcmCmmnClCodeList.do",
      order = 960,
      gid = 60)
  @RequestMapping(value = "/sym/ccm/ccc/EgovCcmCmmnClCodeList.do")
  public String selectCmmnClCodeList(
      @ModelAttribute("loginVO") LoginVO loginVO,
      @ModelAttribute("searchVO") CmmnClCodeVO searchVO,
      ModelMap model)
      throws Exception {
    /** 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<?> CmmnCodeList = cmmnClCodeManageService.selectCmmnClCodeList(searchVO);
    model.addAttribute("resultList", CmmnCodeList);

    int totCnt = cmmnClCodeManageService.selectCmmnClCodeListTotCnt(searchVO);
    paginationInfo.setTotalRecordCount(totCnt);
    model.addAttribute("paginationInfo", paginationInfo);

    return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeList";
  }
  /**
   * 공통상세코드를 등록한다.
   *
   * @param loginVO
   * @param cmmnDetailCode
   * @param cmmnCode
   * @param bindingResult
   * @param model
   * @return "egovframework/com/sym/ccm/cde/EgovCcmCmmnDetailCodeRegist"
   * @throws Exception
   */
  @RequestMapping(value = "/sym/ccm/cde/EgovCcmCmmnDetailCodeRegist.do")
  public String insertCmmnDetailCode(
      @ModelAttribute("loginVO") LoginVO loginVO,
      @ModelAttribute("cmmnDetailCode") CmmnDetailCode cmmnDetailCode,
      @ModelAttribute("cmmnCode") CmmnCode cmmnCode,
      BindingResult bindingResult,
      @RequestParam Map<?, ?> commandMap,
      ModelMap model)
      throws Exception {

    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");
    if (cmmnDetailCode.getCodeId() == null
        || cmmnDetailCode.getCodeId().equals("")
        || cmmnDetailCode.getCode() == null
        || cmmnDetailCode.getCode().equals("")
        || sCmd.equals("")) {

      CmmnClCodeVO searchClCodeVO;
      searchClCodeVO = new CmmnClCodeVO();
      searchClCodeVO.setRecordCountPerPage(999999);
      searchClCodeVO.setFirstIndex(0);
      searchClCodeVO.setSearchCondition("CodeList");
      List<?> CmmnClCodeList = cmmnClCodeManageService.selectCmmnClCodeList(searchClCodeVO);
      model.addAttribute("cmmnClCodeList", CmmnClCodeList);

      CmmnCodeVO searchCodeVO;
      searchCodeVO = new CmmnCodeVO();
      searchCodeVO.setRecordCountPerPage(999999);
      searchCodeVO.setFirstIndex(0);
      searchCodeVO.setSearchCondition("clCode");
      if (cmmnCode.getClCode().equals("")) {
        EgovMap emp = (EgovMap) CmmnClCodeList.get(0);
        cmmnCode.setClCode(emp.get("clCode").toString());
      }
      searchCodeVO.setSearchKeyword(cmmnCode.getClCode());

      List<?> CmmnCodeList = cmmnCodeManageService.selectCmmnCodeList(searchCodeVO);
      model.addAttribute("cmmnCodeList", CmmnCodeList);

      return "egovframework/com/sym/ccm/cde/EgovCcmCmmnDetailCodeRegist";
    } else if (sCmd.equals("Regist")) {

      beanValidator.validate(cmmnDetailCode, bindingResult);
      if (bindingResult.hasErrors()) {
        CmmnClCodeVO searchClCodeVO;
        searchClCodeVO = new CmmnClCodeVO();
        searchClCodeVO.setRecordCountPerPage(999999);
        searchClCodeVO.setFirstIndex(0);
        List<?> CmmnClCodeList = cmmnClCodeManageService.selectCmmnClCodeList(searchClCodeVO);
        model.addAttribute("cmmnClCodeList", CmmnClCodeList);

        CmmnCodeVO searchCodeVO;
        searchCodeVO = new CmmnCodeVO();
        searchCodeVO.setRecordCountPerPage(999999);
        searchCodeVO.setFirstIndex(0);
        searchCodeVO.setSearchCondition("clCode");
        if (cmmnCode.getClCode().equals("")) {
          EgovMap emp = (EgovMap) CmmnClCodeList.get(0);
          cmmnCode.setClCode(emp.get("clCode").toString());
        }
        searchCodeVO.setSearchKeyword(cmmnCode.getClCode());

        List<?> CmmnCodeList = cmmnCodeManageService.selectCmmnCodeList(searchCodeVO);
        model.addAttribute("cmmnCodeList", CmmnCodeList);

        return "egovframework/com/sym/ccm/cde/EgovCcmCmmnDetailCodeRegist";
      }

      CmmnDetailCode vo = cmmnDetailCodeManageService.selectCmmnDetailCodeDetail(cmmnDetailCode);
      if (vo != null) {
        model.addAttribute("message", "이미 등록된 코드가 존재합니다.");

        CmmnClCodeVO searchClCodeVO;
        searchClCodeVO = new CmmnClCodeVO();
        searchClCodeVO.setRecordCountPerPage(999999);
        searchClCodeVO.setFirstIndex(0);
        List<?> CmmnClCodeList = cmmnClCodeManageService.selectCmmnClCodeList(searchClCodeVO);
        model.addAttribute("cmmnClCodeList", CmmnClCodeList);

        CmmnCodeVO searchCodeVO;
        searchCodeVO = new CmmnCodeVO();
        searchCodeVO.setRecordCountPerPage(999999);
        searchCodeVO.setFirstIndex(0);
        searchCodeVO.setSearchCondition("clCode");
        if (cmmnCode.getClCode().equals("")) {
          EgovMap emp = (EgovMap) CmmnClCodeList.get(0);
          cmmnCode.setClCode(emp.get("clCode").toString());
        }
        searchCodeVO.setSearchKeyword(cmmnCode.getClCode());

        List<?> CmmnCodeList = cmmnCodeManageService.selectCmmnCodeList(searchCodeVO);
        model.addAttribute("cmmnCodeList", CmmnCodeList);

        return "egovframework/com/sym/ccm/cde/EgovCcmCmmnDetailCodeRegist";
      }
      cmmnDetailCode.setFrstRegisterId(loginVO.getUniqId());
      cmmnDetailCodeManageService.insertCmmnDetailCode(cmmnDetailCode);
      return "forward:/sym/ccm/cde/EgovCcmCmmnDetailCodeList.do";
    } else {
      return "forward:/sym/ccm/cde/EgovCcmCmmnDetailCodeList.do";
    }
  }