コード例 #1
0
ファイル: MyRentServiceImpl.java プロジェクト: szpaddy/weixin
  public HouseInfo findBaseHouseInfoBytHouseId(String tHouseId, Boolean showMap) {
    HouseInfo houseInfo = houseInfoDao.findBaseHouseInfoBytHouseId(tHouseId);
    if (showMap) {
      MapPoint currPoint = new MapPoint(houseInfo.getLongitude(), houseInfo.getLatitude());
      List<MapPoint> lstMark = new ArrayList<MapPoint>();
      lstMark.add(currPoint);
      houseInfo.setMapImg(baiduMapService.crtStaticMapUrl(lstMark, currPoint));
    }

    return houseInfo;
  }
コード例 #2
0
ファイル: MyRentServiceImpl.java プロジェクト: szpaddy/weixin
  @Override
  public MatchResultWrap findAllProjectByQueryVo(MyRentQueryVo queryVo) {
    log.info("findAllProjectByQueryVo begin.");
    // 根据查询条件搜索项目列表-前台校验必输项

    List<MatchResultVo> projectList = myRentalDao.selectProjectByQueryVo(queryVo);

    if (projectList == null || projectList.isEmpty()) {
      return new MatchResultWrap();
    }

    // 工作地点
    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});
    // 搜索五公里以内的房源信息
    List<MatchResultVo> selectedProjectList = extractMatchResult(projectList, wpLon, wpLat);

    String staticUrl = StringUtils.EMPTY;
    if (selectedProjectList == null || selectedProjectList.isEmpty()) {
      return new MatchResultWrap();
    } else {
      // 构造百度url
      List<MapPoint> lstMarks = transformPoint(selectedProjectList);
      staticUrl = baiduMapService.crtStaticMapUrl(lstMarks, currPoint);

      // 交通路线查询
      for (MatchResultVo item : selectedProjectList) {
        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)));
        reqParam.setMode(queryVo.getTrafficType());

        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)));
          item.setDuration(String.valueOf(Math.ceil(Double.valueOf(duration) / 60)));
        }
      }

      Collections.sort(selectedProjectList, new MatchResultVoCompator());
    }

    log.info("findAllProjectByQueryVo end.");
    return new MatchResultWrap(selectedProjectList, currPoint, staticUrl);
  }