Exemplo n.º 1
0
  public Map<String, Object> getRoomVoById(String roomid) {
    if (jdbcTemplate == null) {
      jdbcTemplate = (JdbcTemplate) SpringManage.getInstance().getObject("jdbcTemplate");
    }
    Map<String, Object> result = new HashMap<String, Object>();
    List<RoomVo> roomVos = new ArrayList<RoomVo>();
    StringBuilder sql = new StringBuilder();
    StringBuilder count = new StringBuilder();
    sql.append("select * from ").append(RoomVo.VIEWNAME).append(" where id =" + roomid);
    System.out.println("根据房源ID 获取房源明细 :" + sql.toString());
    List list = jdbcTemplate.queryForList(sql.toString());
    if (list != null && list.size() > 0) {
      Map<String, Object> map = (Map<String, Object>) list.get(0);
      RoomVo roomVo = new RoomVo();
      LTBeanUtils.getInstance().Map2Bean(map, roomVo);
      if (StringUtils.isNotBlank(roomVo.getPicture())) {
        String[] filenames = roomVo.getPicture().split(",");

        List<String> urls = new ArrayList<String>();

        for (int k = 0; k < filenames.length; k++) {
          String url = FileUtils.downloadUrl2(filenames[k]);
          System.out.println(" url :" + url);
          urls.add(url);
        }
        roomVo.setPicture(StringUtils.join(urls.toArray(new String[] {}), ","));
      }
      roomVos.add(roomVo);
    }

    result.put("data", roomVos);
    result.put("code", "0");
    result.put("msg", "查询成功");
    return result;
  }
Exemplo n.º 2
0
  public RoomVo getRoomDetailByRoomSeq(String roomSeq) {
    Map<String, Object> result = new HashMap<String, Object>();
    RoomVo roomVo = new RoomVo();
    StringBuilder sql = new StringBuilder();

    sql.append("select * from ")
        .append(RoomVo.VIEWNAME)
        .append(" where roomSeq = '" + roomSeq + "'");
    List list = jdbcTemplate.queryForList(sql.toString());

    if (list != null && list.size() > 0) {
      Map<String, Object> map = (Map<String, Object>) list.get(0);
      LTBeanUtils.getInstance().Map2Bean(map, roomVo);
      if (StringUtils.isNotBlank(roomVo.getPicture())) {
        String[] filenames = roomVo.getPicture().split(",");

        List<String> urls = new ArrayList<String>();

        for (int k = 0; k < filenames.length; k++) {
          String url = FileUtils.downloadUrl2(filenames[k]);
          System.out.println(" url :" + url);
          urls.add(url);
        }
        roomVo.setPicture(StringUtils.join(urls.toArray(new String[] {}), ","));
      }
    }
    return roomVo;
  }
Exemplo n.º 3
0
  public Map<String, Object> getRoomDetailById(String roomid) {
    if (jdbcTemplate == null) {
      jdbcTemplate = (JdbcTemplate) SpringManage.getInstance().getObject("jdbcTemplate");
    }
    Map<String, Object> result = new HashMap<String, Object>();
    List<RoomVo> roomVos = new ArrayList<RoomVo>();
    StringBuilder sql = new StringBuilder();
    StringBuilder count = new StringBuilder();

    // String[] fields = new String[]{"id", "price", "comm_name", "kind",
    // "address", "picture", "recommend", "recommendTarget"};
    // String condition = " where concat(comm_name, comm_pinyin) like '%" +
    // comm_name + "%' and cityid like '%" + cityid + "%' and status = '0'";
    // Integer total = jdbcTemplate.queryForInt( "select count(id) from " +
    // RoomVo.VIEWNAME + condition );
    // sql.append( "select " + StringUtils.join(fields, ",") + " from " +
    // RoomVo.VIEWNAME + condition)
    // .append(" limit " + curPage * 5 + ", 5");

    // String[] fields = new String[]{"id", "price", "comm_name", "kind",
    // "address", "picture", "recommend", "recommendTarget"};
    System.out.println("根据房源ID 获取房源明细 :" + sql.toString());
    sql.append("select * from ")
        .append(RoomVo.VIEWNAME)
        .append(" where id =" + roomid + " and picture like '%.thumb.%'");
    //		sql.append("select * from ").append(RoomVo.VIEWNAME)
    //		.append(" where id =" + roomid);
    List list = jdbcTemplate.queryForList(sql.toString());

    if (list != null && list.size() > 0) {
      Map<String, Object> map = (Map<String, Object>) list.get(0);
      RoomVo roomVo = new RoomVo();
      LTBeanUtils.getInstance().Map2Bean(map, roomVo);
      if (StringUtils.isNotBlank(roomVo.getPicture())) {
        String[] filenames = roomVo.getPicture().split(",");

        List<String> urls = new ArrayList<String>();

        for (int k = 0; k < filenames.length; k++) {
          if (filenames[k].contains(".thumb.")) {
            String url = FileUtils.downloadUrl2(filenames[k]);
            System.out.println(" url :" + url);
            urls.add(url);
          }
        }
        roomVo.setPicture(StringUtils.join(urls.toArray(new String[] {}), ","));
      }
      roomVos.add(roomVo);
    }

    result.put("data", roomVos);
    result.put("code", "0");
    result.put("msg", "查询成功");
    return result;
  }
Exemplo n.º 4
0
  public Map<String, Object> getRoomList(
      AppRoomPage page, String lonAndLat, String comm_name, String cityid) {
    if (jdbcTemplate == null) {
      jdbcTemplate = (JdbcTemplate) SpringManage.getInstance().getObject("jdbcTemplate");
    }
    Map<String, Object> result = new HashMap<String, Object>();
    List<RoomVo> roomVos = new ArrayList<RoomVo>();
    StringBuilder sql = new StringBuilder();
    StringBuilder count = new StringBuilder();

    String[] fields =
        new String[] {
          "id",
          "price",
          "comm_name",
          "kind",
          "address",
          "picture",
          "recommend",
          "recommendTarget",
          "size",
          "rent_type",
          "hm_number",
          "busiCircle",
          "longitude",
          "latitude",
          "roomSeq",
          "smartlock",
          "isRecommend"
        };
    String condition =
        " where concat(comm_name, comm_pinyin) like '%"
            + comm_name
            + "%' and cityid like '%"
            + cityid
            + "%' "
            + getRoomListFilter(); // and status = '0'

    Integer total =
        jdbcTemplate.queryForInt("select count(id) from " + RoomVo.VIEWNAME + condition);
    sql.append("select " + StringUtils.join(fields, ",") + " from " + RoomVo.VIEWNAME + condition)
        .append(AppRoomPageUtil.getInstance().getPageSql(page, lonAndLat, true));
    // .append(" limit " + curPage * 5 + ", 5");
    System.out.println(
        "总数:"
            + "select count(id) from "
            + RoomVo.VIEWNAME
            + condition
            + AppRoomPageUtil.getInstance().getPageSql(page, lonAndLat, false));
    System.out.println("接口根据小区名进行查找房源:" + sql.toString());
    List list = jdbcTemplate.queryForList(sql.toString());

    for (int i = 0; list != null && i < list.size(); i++) {
      Map<String, Object> map = (Map<String, Object>) list.get(i);

      RoomVo roomVo = new RoomVo();
      LTBeanUtils.getInstance().Map2Bean(map, roomVo);

      if (StringUtils.isNotBlank(roomVo.getPicture())) {
        String[] filenames = roomVo.getPicture().split(",");

        List<String> urls = new ArrayList<String>();

        for (int k = 0; k < filenames.length; k++) {
          String url = FileUtils.downloadUrl2(filenames[k]);
          System.out.println(" url :" + url);
          urls.add(url);
        }
        roomVo.setPicture(StringUtils.join(urls.toArray(new String[] {}), ","));
      }

      roomVos.add(roomVo);
    }

    if ((page.getCurPage() + 1) * page.getRows() <= total) {
      result.put("curPage", page.getCurPage() + 1);
    } else {
      result.put("curPage", page.getCurPage());
    }
    result.put("data", roomVos);
    result.put("code", "0");
    result.put("msg", "查询成功");
    result.put("total", total);
    return result;
  }
Exemplo n.º 5
0
  /** ******************************** app 专用接口 **************************************** */
  public Map<String, Object> getFeaturedList(String cityid) {
    Map<String, Object> result = new HashMap<String, Object>();
    List<RoomVo> roomVos = new ArrayList<RoomVo>();
    if (jdbcTemplate == null) {
      jdbcTemplate = (JdbcTemplate) SpringManage.getInstance().getObject("jdbcTemplate");
    }

    StringBuilder sql = new StringBuilder();

    String[] fields =
        new String[] {
          "id",
          "price",
          "comm_name",
          "kind",
          "address",
          "picture",
          "recommend",
          "recommendTarget",
          "size",
          "rent_type",
          "hm_number",
          "busiCircle",
          "longitude",
          "latitude",
          "roomSeq",
          "smartlock",
          "isRecommend"
        };
    String condition =
        " where cityid like '%"
            + cityid
            + "%' "
            + " AND ( isRecommend = 1 )"; // 是否是推荐房源的字段";//getRoomListFilter() ;//and status = '0'
    sql.append("select " + StringUtils.join(fields, ",") + " from " + RoomVo.VIEWNAME + condition);
    List list = jdbcTemplate.queryForList(sql.toString());

    for (int i = 0; list != null && i < list.size(); i++) {
      Map<String, Object> map = (Map<String, Object>) list.get(i);
      RoomVo roomVo = new RoomVo();
      LTBeanUtils.getInstance().Map2Bean(map, roomVo);
      if (StringUtils.isNotBlank(roomVo.getPicture())) {
        String[] filenames = roomVo.getPicture().split(",");

        List<String> urls = new ArrayList<String>();

        for (int k = 0; k < filenames.length; k++) {
          String url = FileUtils.downloadUrl2(filenames[k]);
          System.out.println(" url :" + url);
          urls.add(url);
        }
        roomVo.setPicture(StringUtils.join(urls.toArray(new String[] {}), ","));
      }
      /*
       * if( map.get("URL") != null ){ String url = (String)
       * map.get("URL"); if( StringUtils.isNotBlank( url.trim() ) ){ url =
       * FileUtils.downloadUrl(url); roomVo.setPicture(url); } } if(
       * roomVos.contains( roomVo ) ){//已经包含了 int pos = roomVos.indexOf(
       * roomVo ); String picture = roomVos.get( pos ).getPicture(); if(
       * picture == null ){ picture = roomVo.getPicture(); } else {
       * picture += "," + roomVo.getPicture(); } roomVos.get( pos
       * ).setPicture(picture); } else { roomVos.add( roomVo ); }
       */
      roomVos.add(roomVo);
    }
    result.put("data", roomVos);
    result.put("code", "0");
    result.put("msg", "查询成功");
    return result;
  }