Exemplo n.º 1
0
  @Override
  public MatchResultWrap findOneProjectByQueryVo(MyRentQueryVo queryVo) {
    List<MatchResultVo> list = myRentalDao.selectOneProjectByQueryVo(queryVo);
    // 我的位置
    // String workPlace = queryVo.getWorkPlace();
    // 获取我的位置的经纬度
    // MapPoint currPoint =
    // baiduMapService.getPoint(workPlace,queryVo.getCityName());

    // 获取坐标
    //		MapPoint mapPoint = (MapPoint) LocationEventMessageHandler.lrumap
    //				.get(queryVo.getWeixinId());
    //
    //		double wpLon = mapPoint.getLng().doubleValue();
    //		double wpLat = mapPoint.getLat().doubleValue();
    //		log.info("lon:[{}],lat[{}]", new Object[] { wpLon, wpLat });

    // 交通路线查询
    // if(list.size()>0){
    // MatchResultVo item=list.get(0);
    // BigDecimal lat = item.getLatitude();
    // BigDecimal lon = item.getLongitude();
    // RequestParam reqParam = new RequestParam();
    // reqParam.setDestination(lat.toString().concat(",")
    // .concat(lon.toString()));
    // reqParam.setOrigin(String.valueOf(wpLat).concat(",")
    // .concat(String.valueOf(wpLon)));
    // // queryVo.setTrafficType("1");
    // reqParam.setMode(queryVo.getTrafficType());
    // queryVo.setCityName("北京");
    // switch (ETranfficType.getSelfByCode(queryVo.getTrafficType())) {
    // case DRIVING:
    // reqParam.setOrigin_region(queryVo.getCityName());
    // reqParam.setDestination_region(queryVo.getCityName());
    // break;
    // case TRANSIT:
    // case WALKING:
    // reqParam.setRegion(queryVo.getCityName());
    // break;
    // }
    //
    // String duration = baiduMapService
    // .doLeastTimeBetweenTwoPoint(reqParam);
    // if (!StringUtils.isBlank(duration)) {
    // log.debug(String.valueOf(Math.ceil(Double.valueOf(duration) / 60)));
    // String d=String.valueOf(Math.ceil(Double.valueOf(duration) / 60));
    // for(MatchResultVo mrv:list){
    // mrv.setDuration(d);
    // }

    // }
    // }

    MatchResultWrap map = new MatchResultWrap();
    map.setLstResult(list);
    return map;
  }
Exemplo n.º 2
0
  @Override
  public MatchResultWrap findAllHouseByQueryVo(MyRentQueryVo queryVo) {
    long start = System.currentTimeMillis();
    List<MatchResultVo> listDis = myRentalDao.findHouseByQueryVo(queryVo); // 所有符合条件的房源
    // 获取我的位置的经纬度
    String workPlace = queryVo.getWorkPlace();
    MapPoint currPoint = baiduMapService.getPoint(workPlace, queryVo.getCityName());
    double wpLon = currPoint.getLng().doubleValue();
    double wpLat = currPoint.getLat().doubleValue();
    log.info("lon:[{}],lat[{}]", new Object[] {wpLon, wpLat});

    Map<String, Double> mrMap = new HashMap<String, Double>();
    // 计算房源到我的位置的直线距离
    for (MatchResultVo mr : listDis) {
      double mrDis =
          StringUtil.distanceSimplify(
              wpLat, wpLon, mr.getLatitude().doubleValue(), mr.getLongitude().doubleValue());
      mrMap.put(mr.getHouseId(), mrDis);
    }
    // 按距离远近进行排序
    ArrayList<Map.Entry<String, Double>> listEntries = StringUtil.sortMap(mrMap);

    int stackIndex = queryVo.getStackIndex();
    int MAX = 10;
    MatchResultWrap map = new MatchResultWrap();
    if (stackIndex < listEntries.size()) {
      // 本次请求显示房屋的房屋ID列表
      List<String> housIdList = new ArrayList<String>();
      int endIndex =
          (stackIndex < (listEntries.size() - (listEntries.size() % MAX)))
              ? stackIndex + MAX
              : listEntries.size();
      for (int i = stackIndex; i < endIndex; i++) {
        housIdList.add(listEntries.get(i).getKey());
      }

      // 取得房屋具体信息
      List<MatchResultVo> list = myRentalDao.findHousesByHouseIds(housIdList);
      // 计算通勤时间
      try {
        new AsyncClientHttpExchangeFutureCallback(list, queryVo, wpLon, wpLat).httpAsync();
      } catch (Exception e) {
        e.printStackTrace();
      }
      // 按通勤时间排序
      sortListByTime(list);

      map.setLstResult(list);
      log.info(System.currentTimeMillis() - start + "----------主線程時間-------ms----");
    }
    return map;
  }