/house/around 改成同一查询ES

This commit is contained in:
majintao
2024-12-04 15:28:00 +08:00
parent 9f930e2e36
commit 576ce5ab2b
@@ -986,7 +986,7 @@ public class HouseController {
} }
List<Seawater> houses = null; List<Seawater> houses = null;
List<Seawater> houseList = new ArrayList<Seawater>(); List<Seawater> houseList = new ArrayList<Seawater>();
if (cat.contains("_")) { // if (cat.contains("_")) {
// 商铺,写字楼有经纬度,直接查 // 商铺,写字楼有经纬度,直接查
SeawaterQuery query = new SeawaterQuery(); SeawaterQuery query = new SeawaterQuery();
query.setLat(lat); query.setLat(lat);
@@ -1049,75 +1049,75 @@ public class HouseController {
houseList.add(seawater); houseList.add(seawater);
} }
} }
} else { // } else {
if ("sell".equals(cat)) { // if ("sell".equals(cat)) {
List<House> houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); // List<House> houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5);
for (House house : houseByLocation) { // for (House house : houseByLocation) {
Seawater seawater = new Seawater(); // Seawater seawater = new Seawater();
seawater.setId(house.getId()); // 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() == null || house.getArea() == 0 ? null : house.getArea()); // seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea());
seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); // seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice());
seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); // seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
seawater.setDirection(house.getDirection()); // seawater.setDirection(house.getDirection());
seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); // seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor());
seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); // seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight());
seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); // seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom());
seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); // seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall());
seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); // seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet());
if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { // 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) {
int price = (int) (house.getTotalPrice() / house.getArea()); // int price = (int) (house.getTotalPrice() / house.getArea());
seawater.setUnitPrice(price == 0 ? null : price); // seawater.setUnitPrice(price == 0 ? null : price);
} // }
} // }
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");
seawater.setPublishDate(sdf.format(house.getPublishDate())); // seawater.setPublishDate(sdf.format(house.getPublishDate()));
} // }
houseList.add(seawater); // houseList.add(seawater);
} // }
} else if ("rent".equals(cat)) { // } else if ("rent".equals(cat)) {
List<RentHouse> rentHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5); // List<RentHouse> rentHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5);
for (RentHouse house : rentHouseByLocation) { // for (RentHouse house : rentHouseByLocation) {
Seawater seawater = new Seawater(); // Seawater seawater = new Seawater();
seawater.setId(house.getId()); // 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() == null || house.getArea() == 0 ? null : house.getArea()); // seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea());
seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice()); // seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice());
seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice()); // seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
seawater.setDirection(house.getDirection()); // seawater.setDirection(house.getDirection());
seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor()); // seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor());
seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight()); // seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight());
seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom()); // seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom());
seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall()); // seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall());
seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet()); // seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet());
if (house.getAvgPrice() != null && house.getAvgPrice() != 0) { // 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) {
int price = (int) (house.getTotalPrice() / house.getArea()); // int price = (int) (house.getTotalPrice() / house.getArea());
seawater.setUnitPrice(price == 0 ? null : price); // seawater.setUnitPrice(price == 0 ? null : price);
} // }
} // }
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");
seawater.setPublishDate(sdf.format(house.getPublishDate())); // seawater.setPublishDate(sdf.format(house.getPublishDate()));
} // }
houseList.add(seawater); // houseList.add(seawater);
} // }
} // }
} // }
} }