租金挂牌样本接口
This commit is contained in:
@@ -1147,6 +1147,97 @@ public class HouseController {
|
||||
mav.setViewType("rest");
|
||||
return mav;
|
||||
}
|
||||
public Object rentAction(final HouseSearchModel model) {
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
mav.setViewType("rest");
|
||||
if (model.getSize()<0) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数(size)有误"));
|
||||
return mav;
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getCity()) || StringUtils.isBlank(model.getDistrict()) || StringUtils.isBlank(model.getName())) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("城市(city),区域(district),小区名(name)为必填参数"));
|
||||
return mav;
|
||||
}
|
||||
District property = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(), "district");
|
||||
|
||||
// 获取当前日期
|
||||
Calendar today = Calendar.getInstance();
|
||||
|
||||
// 复制一份当前日期,用于计算半年前的日期
|
||||
Calendar sixMonthsAgo = (Calendar) today.clone();
|
||||
|
||||
// 减去 6 个月
|
||||
sixMonthsAgo.add(Calendar.MONTH, -6);
|
||||
|
||||
// 格式化日期为 yyyyMMdd
|
||||
int todayInt = formatDate(today);
|
||||
int sixMonthsAgoInt = formatDate(sixMonthsAgo);
|
||||
model.setStartTime(sixMonthsAgoInt);
|
||||
model.setEndTime(todayInt);
|
||||
|
||||
List<Seawater> houses = null;
|
||||
List<Seawater> houseList = new ArrayList<Seawater>();
|
||||
// if (cat.contains("_")) {
|
||||
// 商铺,写字楼有经纬度,直接查
|
||||
SeawaterQuery query = new SeawaterQuery();
|
||||
query.setCat("rent");
|
||||
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());
|
||||
query.setRegion(model.getDistrict());
|
||||
query.setDistrictName(model.getName());
|
||||
query.setDistrictAlias(property.getAlias());
|
||||
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());
|
||||
String name = house.getName();
|
||||
if (!"暂无数据".equals(name) && StringUtils.isNotBlank(name)) {
|
||||
seawater.setTitle(name);
|
||||
}
|
||||
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());
|
||||
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);
|
||||
}
|
||||
houseList.add(seawater);
|
||||
}
|
||||
}
|
||||
BasicModel basicModel = new BasicModel(200, "ok");
|
||||
// 组装数据
|
||||
basicModel.setResult(houseList);
|
||||
mav.setModel(basicModel);
|
||||
mav.setViewType("rest");
|
||||
return mav;
|
||||
}
|
||||
|
||||
Double sub6(Double a) {
|
||||
BigDecimal bd = new BigDecimal(a);
|
||||
|
||||
@@ -23,6 +23,8 @@ public class HouseSearchModel extends SearchModel {
|
||||
private String propertyType;
|
||||
|
||||
private String houseType;
|
||||
|
||||
private String district;
|
||||
@Override
|
||||
public QueryBean getQueryBean() {
|
||||
HouseQueryBean queryBean = new HouseQueryBean();
|
||||
@@ -177,4 +179,12 @@ public class HouseSearchModel extends SearchModel {
|
||||
public void setHouseType(String houseType) {
|
||||
this.houseType = houseType;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user