/**
   * 공통분류코드를 등록한다.
   *
   * @param loginVO
   * @param cmmnClCode
   * @param bindingResult
   * @return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeRegist"
   * @throws Exception
   */
  @RequestMapping(value = "/sym/ccm/ccc/EgovCcmCmmnClCodeRegist.do")
  public String insertCmmnClCode(
      @ModelAttribute("loginVO") LoginVO loginVO,
      @ModelAttribute("cmmnClCode") CmmnClCode cmmnClCode,
      BindingResult bindingResult,
      ModelMap model)
      throws Exception {
    if (cmmnClCode.getClCode() == null || cmmnClCode.getClCode().equals("")) {
      return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeRegist";
    }

    beanValidator.validate(cmmnClCode, bindingResult);
    if (bindingResult.hasErrors()) {
      return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeRegist";
    }

    if (cmmnClCode.getClCode() != null) {
      CmmnClCode vo = cmmnClCodeManageService.selectCmmnClCodeDetail(cmmnClCode);
      if (vo != null) {
        model.addAttribute("message", "이미 등록된 분류코드가 존재합니다.");
        return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeRegist";
      }
    }

    cmmnClCode.setFrstRegisterId(loginVO.getUniqId());
    cmmnClCodeManageService.insertCmmnClCode(cmmnClCode);
    return "forward:/sym/ccm/ccc/EgovCcmCmmnClCodeList.do";
  }
  /**
   * 공통분류코드를 수정한다.
   *
   * @param loginVO
   * @param cmmnClCode
   * @param bindingResult
   * @param commandMap
   * @param model
   * @return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeModify"
   * @throws Exception
   */
  @RequestMapping(value = "/sym/ccm/ccc/EgovCcmCmmnClCodeModify.do")
  public String updateCmmnClCode(
      @ModelAttribute("loginVO") LoginVO loginVO,
      @ModelAttribute("administCode") CmmnClCode cmmnClCode,
      BindingResult bindingResult,
      @RequestParam Map<?, ?> commandMap,
      ModelMap model)
      throws Exception {
    String sCmd = commandMap.get("cmd") == null ? "" : (String) commandMap.get("cmd");
    if (sCmd.equals("")) {
      CmmnClCode vo = cmmnClCodeManageService.selectCmmnClCodeDetail(cmmnClCode);
      model.addAttribute("cmmnClCode", vo);

      return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeModify";
    } else if (sCmd.equals("Modify")) {
      beanValidator.validate(cmmnClCode, bindingResult);
      if (bindingResult.hasErrors()) {
        CmmnClCode vo = cmmnClCodeManageService.selectCmmnClCodeDetail(cmmnClCode);
        model.addAttribute("cmmnClCode", vo);

        return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeModify";
      }
      cmmnClCode.setLastUpdusrId(loginVO.getUniqId());
      cmmnClCodeManageService.updateCmmnClCode(cmmnClCode);
      return "forward:/sym/ccm/ccc/EgovCcmCmmnClCodeList.do";
    } else {
      return "forward:/sym/ccm/ccc/EgovCcmCmmnClCodeList.do";
    }
  }
  /**
   * 공통분류코드 목록을 조회한다.
   *
   * @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 cmmnClCode
  * @param model
  * @return "forward:/sym/ccm/ccc/EgovCcmCmmnClCodeList.do"
  * @throws Exception
  */
 @RequestMapping(value = "/sym/ccm/ccc/EgovCcmCmmnClCodeRemove.do")
 public String deleteCmmnClCode(
     @ModelAttribute("loginVO") LoginVO loginVO, CmmnClCode cmmnClCode, ModelMap model)
     throws Exception {
   cmmnClCodeManageService.deleteCmmnClCode(cmmnClCode);
   return "forward:/sym/ccm/ccc/EgovCcmCmmnClCodeList.do";
 }
  /**
   * 공통분류코드 상세항목을 조회한다.
   *
   * @param loginVO
   * @param cmmnClCode
   * @param model
   * @return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeDetail"
   * @throws Exception
   */
  @RequestMapping(value = "/sym/ccm/ccc/EgovCcmCmmnClCodeDetail.do")
  public String selectCmmnClCodeDetail(
      @ModelAttribute("loginVO") LoginVO loginVO, CmmnClCode cmmnClCode, ModelMap model)
      throws Exception {
    CmmnClCode vo = cmmnClCodeManageService.selectCmmnClCodeDetail(cmmnClCode);
    model.addAttribute("result", vo);

    return "egovframework/com/sym/ccm/ccc/EgovCcmCmmnClCodeDetail";
  }
  /**
   * 공통상세코드를 등록한다.
   *
   * @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";
    }
  }