/house/around 完善
This commit is contained in:
+49
-20
@@ -897,8 +897,22 @@ public class HouseController {
|
||||
|
||||
@Authority(role = Role.USER)
|
||||
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();
|
||||
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();
|
||||
|
||||
@@ -925,8 +939,17 @@ public class HouseController {
|
||||
return mav;
|
||||
}
|
||||
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 lat = Double.valueOf(locationStr[1]);
|
||||
|
||||
// if (model.getSize())
|
||||
if ("2".equals(model.getLocationType())) {
|
||||
Map<String, Double> gcj02Location = GeoUtils.bd09ToGcj02(lat, lng);
|
||||
lng = gcj02Location.get("lng");
|
||||
@@ -985,19 +1008,20 @@ public class HouseController {
|
||||
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());
|
||||
seawater.setUnitPrice(house.getAvgPrice());
|
||||
seawater.setTotalPrice(house.getTotalPrice());
|
||||
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());
|
||||
seawater.setMaxFloor(house.getHeight());
|
||||
seawater.setRoom(house.getRoom());
|
||||
seawater.setHall(house.getHall());
|
||||
seawater.setToilet(house.getToilet());
|
||||
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());
|
||||
@@ -1008,6 +1032,8 @@ public class HouseController {
|
||||
String formattedDate = year + "-" + month + "-" + day;
|
||||
seawater.setPublishDate(formattedDate);
|
||||
}
|
||||
seawater.setDistance(house.getDistance());
|
||||
seawater.setLocation(house.getLocation());
|
||||
houseList.add(seawater);
|
||||
}
|
||||
}
|
||||
@@ -1016,25 +1042,28 @@ public class HouseController {
|
||||
if (nearestHasHouseByLocation != null && !nearestHasHouseByLocation.isEmpty()) {
|
||||
for (House house : nearestHasHouseByLocation) {
|
||||
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());
|
||||
if (house.getAvgPrice() != null) {
|
||||
seawater.setSize(house.getArea() == 0 ? null : house.getArea());
|
||||
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());
|
||||
}else {
|
||||
if (house.getTotalPrice() != null &&house.getTotalPrice()>0 && house.getArea()!=null && house.getArea()>0){
|
||||
seawater.setUnitPrice((int) (house.getTotalPrice() / house.getArea()));
|
||||
} 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.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());
|
||||
if (house.getPublishDate() != null) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
Reference in New Issue
Block a user