/house/around 完善
This commit is contained in:
+75
-58
@@ -68,6 +68,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -987,68 +988,78 @@ public class HouseController {
|
||||
List<Seawater> houses = null;
|
||||
List<Seawater> houseList = new ArrayList<Seawater>();
|
||||
// if (cat.contains("_")) {
|
||||
// 商铺,写字楼有经纬度,直接查
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setLat(lat);
|
||||
query.setLng(lng);
|
||||
query.setCat(cat);
|
||||
query.setRadius(model.getRadius());
|
||||
query.setStartDate(model.getStartTime());
|
||||
query.setEndDate(model.getEndTime());
|
||||
if (model.getSize() != null && model.getSize() != 0) {
|
||||
query.setStartArea(model.getSize() * 0.9);
|
||||
query.setEndArea(model.getSize() * 1.1);
|
||||
}
|
||||
query.setCityDisplay(model.getCity());
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
pager.setPageSize(5);
|
||||
query.setPager(pager);
|
||||
query.setTable("latest_seawater");
|
||||
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() == 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.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());
|
||||
// 商铺,写字楼有经纬度,直接查
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setLat(lat);
|
||||
query.setLng(lng);
|
||||
query.setCat(cat);
|
||||
query.setRadius(model.getRadius());
|
||||
query.setStartDate(model.getStartTime());
|
||||
query.setEndDate(model.getEndTime());
|
||||
if (model.getSize() != null && model.getSize() != 0) {
|
||||
query.setStartArea(model.getSize() * 0.9);
|
||||
query.setEndArea(model.getSize() * 1.1);
|
||||
}
|
||||
query.setCityDisplay(model.getCity());
|
||||
Pager pager = new Pager();
|
||||
pager.setStartRow(0);
|
||||
pager.setPageSize(5);
|
||||
query.setPager(pager);
|
||||
query.setTable("latest_seawater");
|
||||
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());
|
||||
String districtName = house.getDistrictName();
|
||||
if (!"暂无数据".equals(districtName) && StringUtils.isNotBlank(districtName)) {
|
||||
seawater.setName(districtName);
|
||||
}else {
|
||||
seawater.setName(house.getName());
|
||||
}
|
||||
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.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(sub6(toBd09.get("lng")) + "," + sub6(toBd09.get("lat")));
|
||||
} else {
|
||||
String location = house.getLocation();
|
||||
String[] split = location.split(",");
|
||||
if (split.length == 2) {
|
||||
String location1 = sub6(Double.valueOf(split[0])) + "," + sub6(Double.valueOf(split[1]));
|
||||
seawater.setLocation(location1);
|
||||
}
|
||||
}
|
||||
houseList.add(seawater);
|
||||
}
|
||||
houseList.add(seawater);
|
||||
}
|
||||
}
|
||||
// } else {
|
||||
// if ("sell".equals(cat)) {
|
||||
// List<House> houseByLocation = houseService.findNearestHasHouseByLocation(model.getCity(), lat, lng, cat, model.getRadius(), 5);
|
||||
@@ -1129,6 +1140,12 @@ public class HouseController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
Double sub6(Double a) {
|
||||
BigDecimal bd = new BigDecimal(a);
|
||||
BigDecimal bigDecimal = bd.setScale(6, BigDecimal.ROUND_DOWN);
|
||||
return bigDecimal.doubleValue();
|
||||
}
|
||||
|
||||
// 格式化日期为 yyyyMMdd
|
||||
private static int formatDate(Calendar calendar) {
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
|
||||
Reference in New Issue
Block a user