/house/around 完善
This commit is contained in:
@@ -267,6 +267,10 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
|||||||
seawater.setCity(source.getString("city"));
|
seawater.setCity(source.getString("city"));
|
||||||
seawater.setRegion(source.getString("region"));
|
seawater.setRegion(source.getString("region"));
|
||||||
seawater.setDistrictName(source.getString("district_name"));
|
seawater.setDistrictName(source.getString("district_name"));
|
||||||
|
if (source.containsKey("location")){
|
||||||
|
String location = source.getJSONObject("location").getString("lon") + "," + source.getJSONObject("location").getString("lat");
|
||||||
|
seawater.setLocation(location);
|
||||||
|
}
|
||||||
if(source.containsKey("address")){
|
if(source.containsKey("address")){
|
||||||
seawater.setAddress(source.getString("address"));
|
seawater.setAddress(source.getString("address"));
|
||||||
}
|
}
|
||||||
@@ -372,6 +376,11 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
|||||||
if(source.containsKey("elevator")){
|
if(source.containsKey("elevator")){
|
||||||
seawater.setElevator(source.getString("elevator"));
|
seawater.setElevator(source.getString("elevator"));
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
seawater.setDistance((int)jsonList.get(i).getJSONArray("sort").getDouble(0));
|
||||||
|
}catch (Exception e){
|
||||||
|
seawater.setDistance(null);
|
||||||
|
}
|
||||||
seawaterList.add(seawater);
|
seawaterList.add(seawater);
|
||||||
}
|
}
|
||||||
return seawaterList;
|
return seawaterList;
|
||||||
@@ -557,6 +566,7 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
|||||||
Double lat = query.getLat();
|
Double lat = query.getLat();
|
||||||
Double lng = query.getLng();
|
Double lng = query.getLng();
|
||||||
Integer radius = query.getRadius();
|
Integer radius = query.getRadius();
|
||||||
|
// 添加地理位置过滤器和排序
|
||||||
if (lat != null && lng != null && radius != null) {
|
if (lat != null && lng != null && radius != null) {
|
||||||
// 1. 设置地理位置参数
|
// 1. 设置地理位置参数
|
||||||
JSONObject geoDistanceParam = new JSONObject();
|
JSONObject geoDistanceParam = new JSONObject();
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ public class Seawater implements SeawaterEntity {
|
|||||||
|
|
||||||
private String decoration;
|
private String decoration;
|
||||||
|
|
||||||
|
private Integer distance;
|
||||||
|
|
||||||
|
private String location;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "_id")
|
@Column(name = "_id")
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -453,4 +457,20 @@ public class Seawater implements SeawaterEntity {
|
|||||||
public void setDecoration(String decoration) {
|
public void setDecoration(String decoration) {
|
||||||
this.decoration = decoration;
|
this.decoration = decoration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getDistance() {
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistance(Integer distance) {
|
||||||
|
this.distance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(String location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-20
@@ -897,8 +897,22 @@ public class HouseController {
|
|||||||
|
|
||||||
@Authority(role = Role.USER)
|
@Authority(role = Role.USER)
|
||||||
public Object aroundAction(final HouseSearchModel model) {
|
public Object aroundAction(final HouseSearchModel model) {
|
||||||
|
List<String> type3 = Arrays.asList("1", "2", "0");
|
||||||
|
List<String> type2 = Arrays.asList("1", "0");
|
||||||
RestfulModelAndView mav = new RestfulModelAndView();
|
RestfulModelAndView mav = new RestfulModelAndView();
|
||||||
mav.setViewType("rest");
|
mav.setViewType("rest");
|
||||||
|
if (StringUtils.isNotBlank(model.getLocationType()) && !type3.contains(model.getLocationType())){
|
||||||
|
mav.setModel(BasicModel.buildBadRequestModel("参数(locationType)有误"));
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(model.getPropertyType()) && !type3.contains(model.getPropertyType())){
|
||||||
|
mav.setModel(BasicModel.buildBadRequestModel("参数(propertyType)有误"));
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(model.getHouseType()) && !type2.contains(model.getHouseType())){
|
||||||
|
mav.setModel(BasicModel.buildBadRequestModel("参数(houseType)有误"));
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
// 获取当前日期
|
// 获取当前日期
|
||||||
Calendar today = Calendar.getInstance();
|
Calendar today = Calendar.getInstance();
|
||||||
|
|
||||||
@@ -925,8 +939,17 @@ public class HouseController {
|
|||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
String[] locationStr = model.getLocation().split(",");
|
String[] locationStr = model.getLocation().split(",");
|
||||||
|
String numberPattern = "-?\\d+(\\.\\d+)?"; // 匹配整数或浮点数
|
||||||
|
for (String loc : locationStr) {
|
||||||
|
if (!loc.trim().matches(numberPattern)) {
|
||||||
|
mav.setModel(BasicModel.buildBadRequestModel("location(经纬度)格式错误"));
|
||||||
|
return mav;
|
||||||
|
}
|
||||||
|
}
|
||||||
Double lng = Double.valueOf(locationStr[0]);
|
Double lng = Double.valueOf(locationStr[0]);
|
||||||
Double lat = Double.valueOf(locationStr[1]);
|
Double lat = Double.valueOf(locationStr[1]);
|
||||||
|
|
||||||
|
// if (model.getSize())
|
||||||
if ("2".equals(model.getLocationType())) {
|
if ("2".equals(model.getLocationType())) {
|
||||||
Map<String, Double> gcj02Location = GeoUtils.bd09ToGcj02(lat, lng);
|
Map<String, Double> gcj02Location = GeoUtils.bd09ToGcj02(lat, lng);
|
||||||
lng = gcj02Location.get("lng");
|
lng = gcj02Location.get("lng");
|
||||||
@@ -985,19 +1008,20 @@ public class HouseController {
|
|||||||
if (houses != null && !houses.isEmpty()) {
|
if (houses != null && !houses.isEmpty()) {
|
||||||
for (Seawater house : houses) {
|
for (Seawater house : houses) {
|
||||||
Seawater seawater = new Seawater();
|
Seawater seawater = new Seawater();
|
||||||
|
seawater.setId(house.getId());
|
||||||
seawater.setCity(house.getCity());
|
seawater.setCity(house.getCity());
|
||||||
seawater.setDistrict(house.getRegion());
|
seawater.setDistrict(house.getRegion());
|
||||||
seawater.setAddress(house.getAddress());
|
seawater.setAddress(house.getAddress());
|
||||||
seawater.setName(house.getDistrictName());
|
seawater.setName(house.getDistrictName());
|
||||||
seawater.setSize(house.getArea());
|
seawater.setSize(house.getArea() == 0 ? null : house.getArea());
|
||||||
seawater.setUnitPrice(house.getAvgPrice());
|
seawater.setUnitPrice(house.getAvgPrice() == 0 ? null : house.getAvgPrice());
|
||||||
seawater.setTotalPrice(house.getTotalPrice());
|
seawater.setTotalPrice(house.getTotalPrice() == 0 ? null : house.getTotalPrice());
|
||||||
seawater.setDirection(house.getDirection());
|
seawater.setDirection(house.getDirection());
|
||||||
seawater.setFloor(house.getFloor());
|
seawater.setFloor(house.getFloor() == 0 ? null : house.getFloor());
|
||||||
seawater.setMaxFloor(house.getHeight());
|
seawater.setMaxFloor(house.getHeight() == 0 ? null : house.getMaxFloor());
|
||||||
seawater.setRoom(house.getRoom());
|
seawater.setRoom(house.getRoom() == 0 ? null : house.getRoom());
|
||||||
seawater.setHall(house.getHall());
|
seawater.setHall(house.getHall() == 0 ? null : house.getHall());
|
||||||
seawater.setToilet(house.getToilet());
|
seawater.setToilet(house.getToilet() == 0 ? null : house.getToilet());
|
||||||
seawater.setDecoration(house.getFitment());
|
seawater.setDecoration(house.getFitment());
|
||||||
if (house.getpDate() != null && house.getpDate() > 10000000) {
|
if (house.getpDate() != null && house.getpDate() > 10000000) {
|
||||||
String numberStr = String.valueOf(house.getpDate());
|
String numberStr = String.valueOf(house.getpDate());
|
||||||
@@ -1008,6 +1032,8 @@ public class HouseController {
|
|||||||
String formattedDate = year + "-" + month + "-" + day;
|
String formattedDate = year + "-" + month + "-" + day;
|
||||||
seawater.setPublishDate(formattedDate);
|
seawater.setPublishDate(formattedDate);
|
||||||
}
|
}
|
||||||
|
seawater.setDistance(house.getDistance());
|
||||||
|
seawater.setLocation(house.getLocation());
|
||||||
houseList.add(seawater);
|
houseList.add(seawater);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1016,25 +1042,28 @@ public class HouseController {
|
|||||||
if (nearestHasHouseByLocation != null && !nearestHasHouseByLocation.isEmpty()) {
|
if (nearestHasHouseByLocation != null && !nearestHasHouseByLocation.isEmpty()) {
|
||||||
for (House house : nearestHasHouseByLocation) {
|
for (House house : nearestHasHouseByLocation) {
|
||||||
Seawater seawater = new Seawater();
|
Seawater seawater = new Seawater();
|
||||||
|
seawater.setId(house.getId());
|
||||||
seawater.setCity(house.getCity());
|
seawater.setCity(house.getCity());
|
||||||
seawater.setDistrict(house.getRegion());
|
seawater.setDistrict(house.getRegion());
|
||||||
seawater.setAddress(house.getAddress());
|
seawater.setAddress(house.getAddress());
|
||||||
seawater.setName(house.getDistrictName());
|
seawater.setName(house.getDistrictName());
|
||||||
seawater.setSize(house.getArea());
|
seawater.setSize(house.getArea() == 0 ? null : house.getArea());
|
||||||
if (house.getAvgPrice() != null) {
|
seawater.setUnitPrice(house.getAvgPrice() == 0 || house.getAvgPrice() == null ? null : house.getAvgPrice());
|
||||||
|
seawater.setTotalPrice(house.getTotalPrice() == 0 ? null : house.getTotalPrice());
|
||||||
|
seawater.setDirection(house.getDirection());
|
||||||
|
seawater.setFloor(house.getFloor() == 0 ? null : house.getFloor());
|
||||||
|
seawater.setMaxFloor(house.getHeight() == 0 ? null : house.getHeight());
|
||||||
|
seawater.setRoom(house.getRoom() == 0 ? null : house.getRoom());
|
||||||
|
seawater.setHall(house.getHall() == 0 ? null : house.getHall());
|
||||||
|
seawater.setToilet(house.getToilet() == 0 ? null : house.getToilet());
|
||||||
|
if (house.getAvgPrice() != null && house.getAvgPrice() != 0) {
|
||||||
seawater.setUnitPrice(house.getAvgPrice());
|
seawater.setUnitPrice(house.getAvgPrice());
|
||||||
}else {
|
} else {
|
||||||
if (house.getTotalPrice() != null &&house.getTotalPrice()>0 && house.getArea()!=null && house.getArea()>0){
|
if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) {
|
||||||
seawater.setUnitPrice((int) (house.getTotalPrice() / house.getArea()));
|
int price = (int) (house.getTotalPrice() / house.getArea());
|
||||||
|
seawater.setUnitPrice(price == 0 ? null : price);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
seawater.setTotalPrice(house.getTotalPrice());
|
|
||||||
seawater.setDirection(house.getDirection());
|
|
||||||
seawater.setFloor(house.getFloor());
|
|
||||||
seawater.setMaxFloor(house.getHeight());
|
|
||||||
seawater.setRoom(house.getRoom());
|
|
||||||
seawater.setHall(house.getHall());
|
|
||||||
seawater.setToilet(house.getToilet());
|
|
||||||
seawater.setDecoration(house.getFitment());
|
seawater.setDecoration(house.getFitment());
|
||||||
if (house.getPublishDate() != null) {
|
if (house.getPublishDate() != null) {
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|||||||
+1
-1
@@ -841,7 +841,7 @@ public class RentHouseServiceImpl implements RentHouseService {
|
|||||||
// sdQuery.setDistance(String.valueOf(radiusMeters));
|
// sdQuery.setDistance(String.valueOf(radiusMeters));
|
||||||
params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery));
|
params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery));
|
||||||
List<SortParam> sortParams = Arrays.asList(new SortParam("latLng", true));
|
List<SortParam> sortParams = Arrays.asList(new SortParam("latLng", true));
|
||||||
List<House> list = houseDao.findAllByParams(params, null, 0, limit);
|
List<House> list = houseDao.findAllByParams(params, sortParams, 0, limit);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user