/house/around接口

This commit is contained in:
majintao
2024-11-27 18:12:50 +08:00
parent 592e2671f1
commit 1c35420bf7
7 changed files with 1811 additions and 1453 deletions
@@ -6,6 +6,7 @@ import javax.persistence.*;
import com.fangjia.dal.DatastoreCategory;
import com.fangjia.dal.SeawaterEntity;
import com.fasterxml.jackson.annotation.JsonInclude;
@Entity
@Table(name = "fangjia.seawater")
@@ -35,9 +36,11 @@ public class Seawater implements SeawaterEntity {
private String id;
private String category;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private int status;
private String city;
private String region;
private String district;
private String districtName;
private String address;
private Date modificationDate;
@@ -46,8 +49,10 @@ public class Seawater implements SeawaterEntity {
private String block;
private Integer totalPrice;
private Double area;
private Double size;
private Integer height;
private Integer floor;
private Integer maxFloor;
private String floorInfo;
private String fitment;
private Integer room;
@@ -55,10 +60,13 @@ public class Seawater implements SeawaterEntity {
private Integer toilet;
private String mobile;
private Integer pDate;
private String publishDate;
private Integer userId;
private String url;
private String root;
private Integer avgPrice;
private Integer unitPrice;
private String purpose;
private String estateType;
private String buildType;
@@ -70,6 +78,8 @@ public class Seawater implements SeawaterEntity {
private String housingAge; //房屋年限 满二年
private String elevator; //配备电梯 有/无
private String decoration;
@Id
@Column(name = "_id")
public String getId() {
@@ -395,4 +405,52 @@ public class Seawater implements SeawaterEntity {
public void setElevator(String elevator) {
this.elevator = elevator;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public Double getSize() {
return size;
}
public void setSize(Double size) {
this.size = size;
}
public Integer getMaxFloor() {
return maxFloor;
}
public void setMaxFloor(Integer maxFloor) {
this.maxFloor = maxFloor;
}
public Integer getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(Integer unitPrice) {
this.unitPrice = unitPrice;
}
public String getPublishDate() {
return publishDate;
}
public void setPublishDate(String publishDate) {
this.publishDate = publishDate;
}
public String getDecoration() {
return decoration;
}
public void setDecoration(String decoration) {
this.decoration = decoration;
}
}
@@ -24,6 +24,8 @@ public class Seaweed implements SeaweedEntity {
private List<String> alias;
private List<String> addrAlias;
private double score;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "_id")
@@ -134,4 +136,13 @@ public class Seaweed implements SeaweedEntity {
public void setEstateType2(String estateType2) {
this.estateType2 = estateType2;
}
@Transient
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
}
File diff suppressed because it is too large Load Diff
@@ -13,6 +13,16 @@ public class HouseSearchModel extends SearchModel {
private String unitNo;
private Double size;
private Boolean showDetail;
private String city;
private String location;
private String locationType;
private String propertyType;
private String houseType;
@Override
public QueryBean getQueryBean() {
HouseQueryBean queryBean = new HouseQueryBean();
@@ -125,4 +135,46 @@ public class HouseSearchModel extends SearchModel {
public void setId(String id) {
this.id = id;
}
@Override
public String getCity() {
return city;
}
@Override
public void setCity(String city) {
this.city = city;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getLocationType() {
return locationType;
}
public void setLocationType(String locationType) {
this.locationType = locationType;
}
public String getPropertyType() {
return propertyType;
}
public void setPropertyType(String propertyType) {
this.propertyType = propertyType;
}
public String getHouseType() {
return houseType;
}
public void setHouseType(String houseType) {
this.houseType = houseType;
}
}
@@ -1535,15 +1535,23 @@ public class DistrictServiceImpl implements DistrictService {
List<District> ret = new ArrayList<District>();
for (District d : districts) {
if (null == d.getLat2() || null == d.getLng2()) {
if (d.getLat2() == null || d.getLng2() == null) {
continue;
}
double dis = GeoUtils.calculateDistance(lng, lat, d.getLng() / 10000000000.0, d.getLat() / 10000000000.0);
if (dis <= radius) {
d.setScore(dis); // Assuming District has a `distance` field to store the calculated distance.
ret.add(d);
}
}
Collections.sort(ret, new Comparator<District>() {
@Override
public int compare(District d1, District d2) {
return Double.compare(d1.getScore(), d2.getScore());
}
});
return ret;
}
@@ -0,0 +1,13 @@
package com.fangjia.service.datastore;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.seaweed.model.Seaweed;
import com.fangjia.dal.seaweed.model.Shop;
import java.util.List;
public interface SeaweedService {
List<Seaweed> findSeaweedByLocation(double lat, double lng, double radius,String cat,int limit);
List<Seaweed> findSeaweedByLocation(double lat, double lng, double radius,String cat);
}
@@ -0,0 +1,102 @@
package com.fangjia.service.datastore;
import com.fangjia.core.util.CacheUtils;
import com.fangjia.core.util.CacheUtils.CachePolicyEnum;
import com.fangjia.core.util.GeoUtils;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.seaweed.dao.SeaweedDao;
import com.fangjia.dal.seaweed.dao.ShopDao;
import com.fangjia.dal.seaweed.model.District;
import com.fangjia.dal.seaweed.model.Seaweed;
import com.fangjia.dal.seaweed.model.Shop;
import com.fangjia.service.index.BoostQueryPolicy;
import org.apache.commons.lang.StringUtils;
import org.sothis.core.util.Closure;
import org.sothis.core.util.CollectionUtils;
import java.util.*;
public class SeaweedServiceImpl implements SeaweedService {
private SeaweedDao seaweedDao;
@Override
public List<Seaweed> findSeaweedByLocation(double lat, double lng, double radius,String cat,int limit) {
double[] latlngs = GeoUtils.getAround(lat, lng, radius);
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("category", cat));
params.add(new QueryParam("status", 0));
params.add(new QueryParam("lat", QueryParam.GREATER_THAN_EQUAL_OPERATOR, latlngs[0] * 10000000000d));
params.add(new QueryParam("lat", QueryParam.LESS_THAN_EQUAL_OPERATOR, latlngs[1] * 10000000000d));
params.add(new QueryParam("lng", QueryParam.GREATER_THAN_EQUAL_OPERATOR, latlngs[2] * 10000000000d));
params.add(new QueryParam("lng", QueryParam.LESS_THAN_EQUAL_OPERATOR, latlngs[3] * 10000000000d));
List<Seaweed> seaweeds = seaweedDao.findAllByParams(params,limit);
if (CollectionUtils.isEmpty(seaweeds)) {
return Collections.emptyList();
}
List<Seaweed> ret = new ArrayList<Seaweed>();
for (Seaweed d : seaweeds) {
if (d.getLat() == null || d.getLng() == null) {
continue;
}
double dis = GeoUtils.calculateDistance(lng, lat, d.getLng() / 10000000000.0, d.getLat() / 10000000000.0);
if (dis <= radius) {
d.setScore(dis); // Assuming District has a `distance` field to store the calculated distance.
ret.add(d);
}
}
Collections.sort(ret, new Comparator<Seaweed>() {
@Override
public int compare(Seaweed d1, Seaweed d2) {
return Double.compare(d1.getScore(), d2.getScore());
}
});
return ret;
}
@Override
public List<Seaweed> findSeaweedByLocation(double lat, double lng, double radius, String cat) {
double[] latlngs = GeoUtils.getAround(lat, lng, radius);
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("category", cat));
params.add(new QueryParam("status", 0));
params.add(new QueryParam("lat", QueryParam.GREATER_THAN_EQUAL_OPERATOR, latlngs[0] * 10000000000d));
params.add(new QueryParam("lat", QueryParam.LESS_THAN_EQUAL_OPERATOR, latlngs[1] * 10000000000d));
params.add(new QueryParam("lng", QueryParam.GREATER_THAN_EQUAL_OPERATOR, latlngs[2] * 10000000000d));
params.add(new QueryParam("lng", QueryParam.LESS_THAN_EQUAL_OPERATOR, latlngs[3] * 10000000000d));
List<Seaweed> seaweeds = seaweedDao.findAllByParams(params);
if (CollectionUtils.isEmpty(seaweeds)) {
return Collections.emptyList();
}
List<Seaweed> ret = new ArrayList<Seaweed>();
for (Seaweed d : seaweeds) {
if (d.getLat() == null || d.getLng() == null) {
continue;
}
double dis = GeoUtils.calculateDistance(lng, lat, d.getLng() / 10000000000.0, d.getLat() / 10000000000.0);
if (dis <= radius) {
d.setScore(dis); // Assuming District has a `distance` field to store the calculated distance.
ret.add(d);
}
}
Collections.sort(ret, new Comparator<Seaweed>() {
@Override
public int compare(Seaweed d1, Seaweed d2) {
return Double.compare(d1.getScore(), d2.getScore());
}
});
return ret;
}
public void setSeaweedDao(SeaweedDao seaweedDao) {
this.seaweedDao = seaweedDao;
}
}