// 列表页中返回json数据
  @RequestMapping("/jsonList")
  public Object jsonList(HttpServletRequest request, HttpServletResponse response) {
    int currentPage =
        request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
    if (currentPage <= 0) {
      currentPage = 1;
    }

    int pageSize =
        request.getParameter("rows") == null ? 10 : Integer.parseInt(request.getParameter("rows"));

    Map filter = getFilterMap(request);

    int currentResult = (currentPage - 1) * pageSize;

    PageInfo pageInfo = new PageInfo();
    pageInfo.setShowCount(pageSize);
    pageInfo.setCurrentResult(currentResult);
    pageInfo.setFilter(filter);
    pageInfo.setSortField("id");
    pageInfo.setOrder("asc");

    List<BaseMer> baseMers = baseMerService.selectListPage(pageInfo);

    if (pageInfo.getTotalResult() > 0) {
      Json json = new Json();
      json.add("total", pageInfo.getTotalResult());

      for (BaseMer baseMer : baseMers) {
        Json json_a = new Json();
        try {
          json_a.getObjectValue(baseMer, json_a);
        } catch (Exception e) {
          e.printStackTrace();
        }
        json.add("rows", json_a);
      }

      response.setContentType("application/json;charset=UTF-8");
      response.setCharacterEncoding("UTF-8");
      PrintWriter pw = null;
      try {
        pw = response.getWriter();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      pw.write(json.toString());
      pw.flush();
    }

    return null;
  }
  // 返回生成树需要的json
  @RequestMapping("/baseMerJsonTree")
  public Object baseMerJsonTree(HttpServletRequest request, HttpServletResponse response) {

    Map filter = getFilterMap(request);
    PageInfo pageInfo = new PageInfo();
    pageInfo.setShowCount(100);
    pageInfo.setCurrentResult(0);
    pageInfo.setFilter(filter);
    pageInfo.setSortField("id");
    pageInfo.setOrder("asc");

    List<BaseMer> baseMers = baseMerService.selectListPage(pageInfo);

    if (pageInfo.getTotalResult() > 0) {

      StringBuffer sbf = new StringBuffer("[");

      Json json = new Json();
      json.add("id", 1);
      json.add("text", "基质");

      Json person = new Json();
      person.add("id", 11);
      person.add("text", "人源基质");

      Json noPerson = new Json();
      noPerson.add("id", 12);
      noPerson.add("text", "非人源基质");

      for (BaseMer baseMer : baseMers) {
        if (baseMer.getSource().equals("人源基质")) {
          Json json_a = new Json();
          json_a.add("id", String.valueOf(baseMer.getId()));
          json_a.add("text", baseMer.getType());
          person.add("children", json_a);
        } else {
          Json json_b = new Json();
          json_b.add("id", String.valueOf(baseMer.getId()));
          json_b.add("text", baseMer.getType());
          noPerson.add("children", json_b);
        }
      }

      json.add("children", person);
      json.add("children", noPerson);

      sbf.append(json.toString());
      sbf.append("]");

      response.setContentType("application/json;charset=UTF-8");
      response.setCharacterEncoding("UTF-8");
      PrintWriter pw = null;
      try {
        pw = response.getWriter();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      pw.write(sbf.toString());
      pw.flush();
    }

    return null;
  }