/house/around 完善
This commit is contained in:
@@ -38,6 +38,8 @@ public class RentHouse extends BaseHouse implements DatastoreEntity {
|
||||
private String block;
|
||||
private Integer totalPrice;
|
||||
private Integer totalPriceRange;
|
||||
|
||||
private Integer avgPrice;
|
||||
/**
|
||||
* 出租类型
|
||||
*/
|
||||
@@ -760,4 +762,14 @@ public class RentHouse extends BaseHouse implements DatastoreEntity {
|
||||
this.houseRequire = houseRequire;
|
||||
}
|
||||
|
||||
@Transient
|
||||
@Column(name = "avg_price")
|
||||
public Integer getAvgPrice() {
|
||||
return avgPrice;
|
||||
}
|
||||
|
||||
public void setAvgPrice(Integer avgPrice) {
|
||||
this.avgPrice = avgPrice;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+90
-54
@@ -8,6 +8,7 @@ import com.fangjia.dal.SeawaterQuery;
|
||||
import com.fangjia.dal.common.DistrictKey;
|
||||
import com.fangjia.dal.common.ServerAreaData;
|
||||
import com.fangjia.dal.datastore.model.House;
|
||||
import com.fangjia.dal.datastore.model.RentHouse;
|
||||
import com.fangjia.dal.mongo.model.DistrictFacilitys;
|
||||
import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap;
|
||||
import com.fangjia.dal.mongo.model.Metro;
|
||||
@@ -1007,50 +1008,6 @@ public class HouseController {
|
||||
houses = seawaterDao.findSeawatersByQuery(query);
|
||||
if (houses != null && !houses.isEmpty()) {
|
||||
for (Seawater house : houses) {
|
||||
Seawater seawater = new Seawater();
|
||||
seawater.setId(house.getId());
|
||||
seawater.setCity(house.getCity());
|
||||
seawater.setDistrict(house.getRegion());
|
||||
seawater.setAddress(house.getAddress());
|
||||
seawater.setName(house.getDistrictName());
|
||||
seawater.setSize(house.getArea() == 0 ? null : house.getArea());
|
||||
seawater.setUnitPrice(house.getAvgPrice() == 0 ? 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.getMaxFloor());
|
||||
seawater.setRoom(house.getRoom() == 0 ? null : house.getRoom());
|
||||
seawater.setHall(house.getHall() == 0 ? null : house.getHall());
|
||||
seawater.setToilet(house.getToilet() == 0 ? null : house.getToilet());
|
||||
seawater.setDecoration(house.getFitment());
|
||||
if (house.getpDate() != null && house.getpDate() > 10000000) {
|
||||
String numberStr = String.valueOf(house.getpDate());
|
||||
// 拆分字符串并格式化
|
||||
String year = numberStr.substring(0, 4); // 前四位是年份
|
||||
String month = numberStr.substring(4, 6); // 中间两位是月份
|
||||
String day = numberStr.substring(6, 8); // 最后两位是日期
|
||||
String formattedDate = year + "-" + month + "-" + day;
|
||||
seawater.setPublishDate(formattedDate);
|
||||
}
|
||||
seawater.setDistance(house.getDistance());
|
||||
if (StringUtils.isNotBlank(house.getLocation())) {
|
||||
if ("2".equals(model.getLocationType())) {
|
||||
String[] split = house.getLocation().split(",");
|
||||
Double lon = Double.valueOf(split[0]);
|
||||
Double latt = Double.valueOf(split[1]);
|
||||
Map<String, Double> toBd09 = GeoUtils.gcj02ToBd09(latt, lon);
|
||||
seawater.setLocation(toBd09.get("lng") + "," + toBd09.get("lat"));
|
||||
} else {
|
||||
seawater.setLocation(house.getLocation());
|
||||
}
|
||||
}
|
||||
houseList.add(seawater);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<House> nearestHasHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5);
|
||||
if (nearestHasHouseByLocation != null && !nearestHasHouseByLocation.isEmpty()) {
|
||||
for (House house : nearestHasHouseByLocation) {
|
||||
Seawater seawater = new Seawater();
|
||||
seawater.setId(house.getId());
|
||||
seawater.setCity(house.getCity());
|
||||
@@ -1067,19 +1024,98 @@ public class HouseController {
|
||||
seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall());
|
||||
seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet());
|
||||
if (house.getAvgPrice() != null && house.getAvgPrice() != 0) {
|
||||
seawater.setUnitPrice(house.getAvgPrice());
|
||||
} else {
|
||||
if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) {
|
||||
int price = (int) (house.getTotalPrice() / house.getArea());
|
||||
seawater.setUnitPrice(price == 0 ? null : price);
|
||||
seawater.setDecoration(house.getFitment());
|
||||
if (house.getpDate() != null && house.getpDate() > 10000000) {
|
||||
String numberStr = String.valueOf(house.getpDate());
|
||||
// 拆分字符串并格式化
|
||||
String year = numberStr.substring(0, 4); // 前四位是年份
|
||||
String month = numberStr.substring(4, 6); // 中间两位是月份
|
||||
String day = numberStr.substring(6, 8); // 最后两位是日期
|
||||
String formattedDate = year + "-" + month + "-" + day;
|
||||
seawater.setPublishDate(formattedDate);
|
||||
}
|
||||
seawater.setDistance(house.getDistance());
|
||||
if (StringUtils.isNotBlank(house.getLocation())) {
|
||||
if ("2".equals(model.getLocationType())) {
|
||||
String[] split = house.getLocation().split(",");
|
||||
Double lon = Double.valueOf(split[0]);
|
||||
Double latt = Double.valueOf(split[1]);
|
||||
Map<String, Double> toBd09 = GeoUtils.gcj02ToBd09(latt, lon);
|
||||
seawater.setLocation(toBd09.get("lng") + "," + toBd09.get("lat"));
|
||||
} else {
|
||||
seawater.setLocation(house.getLocation());
|
||||
}
|
||||
}
|
||||
houseList.add(seawater);
|
||||
}
|
||||
seawater.setDecoration(house.getFitment());
|
||||
if (house.getPublishDate() != null) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
seawater.setPublishDate(sdf.format(house.getPublishDate()));
|
||||
}
|
||||
} else {
|
||||
if ("sell".equals(cat)) {
|
||||
List<House> houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5);
|
||||
for (House house : houseByLocation) {
|
||||
Seawater seawater = new Seawater();
|
||||
seawater.setId(house.getId());
|
||||
seawater.setCity(house.getCity());
|
||||
seawater.setDistrict(house.getRegion());
|
||||
seawater.setAddress(house.getAddress());
|
||||
seawater.setName(house.getDistrictName());
|
||||
seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea());
|
||||
seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice());
|
||||
seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
|
||||
seawater.setDirection(house.getDirection());
|
||||
seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor());
|
||||
seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight());
|
||||
seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom());
|
||||
seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall());
|
||||
seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet());
|
||||
if (house.getAvgPrice() != null && house.getAvgPrice() != 0) {
|
||||
seawater.setUnitPrice(house.getAvgPrice());
|
||||
} else {
|
||||
if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) {
|
||||
int price = (int) (house.getTotalPrice() / house.getArea());
|
||||
seawater.setUnitPrice(price == 0 ? null : price);
|
||||
}
|
||||
}
|
||||
seawater.setDecoration(house.getFitment());
|
||||
if (house.getPublishDate() != null) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
seawater.setPublishDate(sdf.format(house.getPublishDate()));
|
||||
}
|
||||
houseList.add(seawater);
|
||||
}
|
||||
} else if ("rent".equals(cat)) {
|
||||
List<RentHouse> rentHouseByLocation = rentHouseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5);
|
||||
for (RentHouse house : rentHouseByLocation) {
|
||||
Seawater seawater = new Seawater();
|
||||
seawater.setId(house.getId());
|
||||
seawater.setCity(house.getCity());
|
||||
seawater.setDistrict(house.getRegion());
|
||||
seawater.setAddress(house.getAddress());
|
||||
seawater.setName(house.getDistrictName());
|
||||
seawater.setSize(house.getArea() == null || house.getArea() == 0 ? null : house.getArea());
|
||||
seawater.setUnitPrice(house.getAvgPrice() == null || house.getAvgPrice() == 0 ? null : house.getAvgPrice());
|
||||
seawater.setTotalPrice(house.getTotalPrice() == null || house.getTotalPrice() == 0 ? null : house.getTotalPrice());
|
||||
seawater.setDirection(house.getDirection());
|
||||
seawater.setFloor(house.getFloor() == null || house.getFloor() == 0 ? null : house.getFloor());
|
||||
seawater.setMaxFloor(house.getHeight() == null || house.getHeight() == 0 ? null : house.getHeight());
|
||||
seawater.setRoom(house.getRoom() == null || house.getRoom() == 0 ? null : house.getRoom());
|
||||
seawater.setHall(house.getHall() == null || house.getHall() == 0 ? null : house.getHall());
|
||||
seawater.setToilet(house.getToilet() == null || house.getToilet() == 0 ? null : house.getToilet());
|
||||
if (house.getAvgPrice() != null && house.getAvgPrice() != 0) {
|
||||
seawater.setUnitPrice(house.getAvgPrice());
|
||||
} else {
|
||||
if (house.getTotalPrice() != null && house.getTotalPrice() > 0 && house.getArea() != null && house.getArea() > 0) {
|
||||
int price = (int) (house.getTotalPrice() / house.getArea());
|
||||
seawater.setUnitPrice(price == 0 ? null : price);
|
||||
}
|
||||
}
|
||||
seawater.setDecoration(house.getFitment());
|
||||
if (house.getPublishDate() != null) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
seawater.setPublishDate(sdf.format(house.getPublishDate()));
|
||||
}
|
||||
houseList.add(seawater);
|
||||
}
|
||||
houseList.add(seawater);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
|
||||
import com.fangjia.dal.FacetQuery;
|
||||
import com.fangjia.dal.common.DistrictKey;
|
||||
import com.fangjia.dal.datastore.model.RentHouse;
|
||||
import com.fangjia.datastore.driver.FacetResult;
|
||||
import com.fangjia.service.bo.HousePDSBo;
|
||||
import com.fangjia.service.bo.HouseScorer;
|
||||
@@ -470,4 +471,7 @@ public interface HouseService extends ModeService<String, HouseBo> {
|
||||
|
||||
HashMap<String, Object> findHouseStat(District districtKey, Integer avgPrice);
|
||||
|
||||
List<House> findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+22
@@ -8,6 +8,7 @@ import com.fangjia.dal.common.FangjiaServerAreaContextHolder;
|
||||
import com.fangjia.dal.common.ServerAreaData;
|
||||
import com.fangjia.dal.datastore.dao.HouseDao;
|
||||
import com.fangjia.dal.datastore.model.House;
|
||||
import com.fangjia.dal.datastore.model.RentHouse;
|
||||
import com.fangjia.dal.mongo.dao.UserHouseDao;
|
||||
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
|
||||
import com.fangjia.dal.mongo.model.UserHouse;
|
||||
@@ -2613,4 +2614,25 @@ public class HouseServiceImpl implements HouseService {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<House> findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit) {
|
||||
if (lat == null || lng == null || lat <= 0 ||lng <= 0) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("cat", cat));
|
||||
if (StringUtils.isNotBlank(city)){
|
||||
params.add(new QueryParam("city", city));
|
||||
}
|
||||
SdQuery sdQuery = new SdQuery();
|
||||
sdQuery.setPoint(lat + "," + lng);
|
||||
sdQuery.setField("lat_lng");
|
||||
sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0));
|
||||
// sdQuery.setDistance(String.valueOf(radiusMeters));
|
||||
params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery));
|
||||
List<SortParam> sortParams = Arrays.asList(new SortParam("latLng", true));
|
||||
List<House> list = houseDao.findAllByParams(params, null, 0, limit);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -210,5 +210,5 @@ public interface RentHouseService extends ModeService<String, RentHouseBo> {
|
||||
|
||||
// 用户中心发布房源接口 END
|
||||
|
||||
List<House> findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit);
|
||||
List<RentHouse> findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit);
|
||||
}
|
||||
|
||||
+2
-2
@@ -825,7 +825,7 @@ public class RentHouseServiceImpl implements RentHouseService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<House> findNearestHasHouseByLocation(String city,Double lat, Double lng, String cat,int radiusMeters, int limit) {
|
||||
public List<RentHouse> findNearestHasHouseByLocation(String city,Double lat, Double lng, String cat,int radiusMeters, int limit) {
|
||||
if (lat == null || lng == null || lat <= 0 ||lng <= 0) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
@@ -841,7 +841,7 @@ public class RentHouseServiceImpl implements RentHouseService {
|
||||
// sdQuery.setDistance(String.valueOf(radiusMeters));
|
||||
params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery));
|
||||
List<SortParam> sortParams = Arrays.asList(new SortParam("latLng", true));
|
||||
List<House> list = houseDao.findAllByParams(params, null, 0, limit);
|
||||
List<RentHouse> list = rentHouseDao.findAllByParams(params, null, 0, limit);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user