接口修改
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
package com.fangjia.dal.mongo.dao;
|
||||
|
||||
import com.fangjia.dal.MongoDao;
|
||||
import com.fangjia.dal.mongo.model.DistrictRoomSqmetreRent;
|
||||
|
||||
|
||||
public interface DistrictRoomSqmetreRentDao extends MongoDao<DistrictRoomSqmetreRent> {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.fangjia.dal.mongo.dao;
|
||||
|
||||
import com.fangjia.dal.MongoDaoImpl;
|
||||
import com.fangjia.dal.mongo.model.DistrictRoomSqmetreRent;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DistrictRentCoverage;
|
||||
|
||||
public class DistrictRoomSqmetreRentDaoImpl extends MongoDaoImpl<DistrictRoomSqmetreRent> implements DistrictRoomSqmetreRentDao{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.fangjia.dal.mongo.dao;
|
||||
|
||||
import com.fangjia.dal.MongoDao;
|
||||
import com.fangjia.dal.MongoDaoImpl;
|
||||
import com.fangjia.dal.mongo.model.RentDealPrice;
|
||||
|
||||
public interface RentDealPriceDao extends MongoDao<RentDealPrice> {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.fangjia.dal.mongo.dao;
|
||||
|
||||
import com.fangjia.dal.MongoDaoImpl;
|
||||
import com.fangjia.dal.mongo.model.RentDealPrice;
|
||||
|
||||
public class RentDealPriceDaoImpl extends MongoDaoImpl<RentDealPrice> implements RentDealPriceDao{
|
||||
}
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
package com.fangjia.dal.mongo.model;
|
||||
|
||||
import com.fangjia.dal.MongoEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "fangjia.district_room_sqmetre_rent")
|
||||
public class DistrictRoomSqmetreRent implements MongoEntity {
|
||||
|
||||
private String id;
|
||||
private String city;
|
||||
private String region;
|
||||
private String block;
|
||||
private String districtName;
|
||||
private int avgPrice;
|
||||
private String estateType;
|
||||
private Integer houseType;
|
||||
private int markup;
|
||||
private Date creationDate;
|
||||
private int sDate;
|
||||
|
||||
@Override
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "_id", unique = true, nullable = false)
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "city")
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
@Column(name = "region")
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
@Column(name = "block")
|
||||
public String getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(String block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Column(name = "district_name")
|
||||
public String getDistrictName() {
|
||||
return districtName;
|
||||
}
|
||||
|
||||
public void setDistrictName(String districtName) {
|
||||
this.districtName = districtName;
|
||||
}
|
||||
|
||||
@Column(name = "avg_price")
|
||||
public int getAvgPrice() {
|
||||
return avgPrice;
|
||||
}
|
||||
|
||||
public void setAvgPrice(int avgPrice) {
|
||||
this.avgPrice = avgPrice;
|
||||
}
|
||||
|
||||
@Column(name = "estate_type")
|
||||
public String getEstateType() {
|
||||
return estateType;
|
||||
}
|
||||
|
||||
public void setEstateType(String estateType) {
|
||||
this.estateType = estateType;
|
||||
}
|
||||
|
||||
@Column(name = "house_type")
|
||||
public Integer getHouseType() {
|
||||
return houseType;
|
||||
}
|
||||
|
||||
public void setHouseType(Integer houseType) {
|
||||
this.houseType = houseType;
|
||||
}
|
||||
|
||||
@Column(name = "markup")
|
||||
public int getMarkup() {
|
||||
return markup;
|
||||
}
|
||||
|
||||
public void setMarkup(int markup) {
|
||||
this.markup = markup;
|
||||
}
|
||||
|
||||
@Column(name = "c_date")
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
public void setCreationDate(Date creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
@Column(name = "s_date")
|
||||
public int getsDate() {
|
||||
return sDate;
|
||||
}
|
||||
|
||||
public void setsDate(int sDate) {
|
||||
this.sDate = sDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.fangjia.dal.mongo.model;
|
||||
|
||||
import com.fangjia.dal.MongoEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "fangjia.rent_deal_price")
|
||||
public class RentDealPrice implements MongoEntity {
|
||||
|
||||
private String id;
|
||||
private String city;
|
||||
private String region;
|
||||
private String districtName;
|
||||
private Double area;
|
||||
private Integer totalPrice;
|
||||
private Integer avgPrice;
|
||||
private String source;
|
||||
private Integer room;
|
||||
private Integer hall;
|
||||
private Integer toilet;
|
||||
private String fitment;
|
||||
private String url;
|
||||
private String direction;
|
||||
private Integer height;
|
||||
private Date modificationDate;
|
||||
private Date tradeDate;
|
||||
private Date createDate;
|
||||
|
||||
|
||||
@Override
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column(name = "_id", unique = true, nullable = false)
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "city")
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
@Column(name = "region")
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
@Column(name = "district_name")
|
||||
public String getDistrictName() {
|
||||
return districtName;
|
||||
}
|
||||
|
||||
public void setDistrictName(String districtName) {
|
||||
this.districtName = districtName;
|
||||
}
|
||||
|
||||
@Column(name = "area")
|
||||
public Double getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public void setArea(Double area) {
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
@Column(name = "total_price")
|
||||
public Integer getTotalPrice() {
|
||||
return totalPrice;
|
||||
}
|
||||
|
||||
public void setTotalPrice(Integer totalPrice) {
|
||||
this.totalPrice = totalPrice;
|
||||
}
|
||||
|
||||
@Column(name = "avg_price")
|
||||
public Integer getAvgPrice() {
|
||||
return avgPrice;
|
||||
}
|
||||
|
||||
public void setAvgPrice(Integer avgPrice) {
|
||||
this.avgPrice = avgPrice;
|
||||
}
|
||||
|
||||
@Column(name = "source")
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Column(name = "room")
|
||||
public Integer getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void setRoom(Integer room) {
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
@Column(name = "hall")
|
||||
public Integer getHall() {
|
||||
return hall;
|
||||
}
|
||||
|
||||
public void setHall(Integer hall) {
|
||||
this.hall = hall;
|
||||
}
|
||||
|
||||
@Column(name = "toilet")
|
||||
public Integer getToilet() {
|
||||
return toilet;
|
||||
}
|
||||
|
||||
public void setToilet(Integer toilet) {
|
||||
this.toilet = toilet;
|
||||
}
|
||||
|
||||
@Column(name = "fitment")
|
||||
public String getFitment() {
|
||||
return fitment;
|
||||
}
|
||||
|
||||
public void setFitment(String fitment) {
|
||||
this.fitment = fitment;
|
||||
}
|
||||
|
||||
@Column(name = "url")
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Column(name = "direction")
|
||||
public String getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
|
||||
public void setDirection(String direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Column(name = "height")
|
||||
public Integer getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(Integer height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "trade_date")
|
||||
public Date getTradeDate() {
|
||||
return tradeDate;
|
||||
}
|
||||
|
||||
public void setTradeDate(Date tradeDate) {
|
||||
this.tradeDate = tradeDate;
|
||||
}
|
||||
|
||||
@Column(name = "create_date")
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@Column(name = "m_date")
|
||||
public Date getModificationDate() {
|
||||
return modificationDate;
|
||||
}
|
||||
|
||||
public void setModificationDate(Date modificationDate) {
|
||||
this.modificationDate = modificationDate;
|
||||
}
|
||||
}
|
||||
+76
-26
@@ -33,9 +33,10 @@ import com.fangjia.dal.mongo.model.*;
|
||||
import com.fangjia.dal.seawater.dao.SeawaterDao;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
import com.fangjia.open.dto.*;
|
||||
import com.fangjia.service.district.SqmetreRentService;
|
||||
import com.fangjia.service.district.*;
|
||||
import com.fangjia.service.mongo.fangjia.*;
|
||||
import com.fangjia.service.open.*;
|
||||
import com.fangjia.service.util.DistrictScoreUtil;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
@@ -125,8 +126,6 @@ import com.fangjia.service.datastore.FieldFilterService;
|
||||
import com.fangjia.service.datastore.HouseService;
|
||||
import com.fangjia.service.datastore.NoHouseDistrictService;
|
||||
import com.fangjia.service.datastore.OpenApiLogService;
|
||||
import com.fangjia.service.district.DistrictStatRentService;
|
||||
import com.fangjia.service.district.DistrictStatService;
|
||||
import com.fangjia.service.mongo.bkoff.HouseAuctionService;
|
||||
import com.fangjia.service.mongo.bkoff.HouseLoudongService;
|
||||
import com.fangjia.service.mongo.bkoff.LoudongService;
|
||||
@@ -194,6 +193,10 @@ public class PropertyController {
|
||||
|
||||
private AutoCompleteService autoCompleteService;
|
||||
|
||||
|
||||
private DistrictRoomSqmetreRentService districtRoomSqmetreRentService;
|
||||
private RentDealPriceService rentDealPriceService;
|
||||
|
||||
private static final int EVALUATE_SHOW_DETAIL = 1;
|
||||
private static final Map<String, String> PROPERTY_TYPES = new HashMap<String, String>() {
|
||||
{
|
||||
@@ -5045,6 +5048,7 @@ public class PropertyController {
|
||||
|
||||
|
||||
if (evaluation.getTotalPrice() != null && evaluation.getTotalPrice() != 0) {
|
||||
evaluation.setAvgPrice((int)(evaluation.getTotalPrice()/evaluation.getArea()));
|
||||
Map<String, Object> districtPriceMap = new HashMap<String, Object>();
|
||||
districtPriceMap.put("city", district.getCity());
|
||||
districtPriceMap.put("district", district.getRegion());
|
||||
@@ -5057,46 +5061,79 @@ public class PropertyController {
|
||||
Integer startPrice = (int)(evaluation.getTotalPrice() - evaluation.getTotalPrice()*0.2);
|
||||
Integer endPrice = (int)(evaluation.getTotalPrice() + evaluation.getTotalPrice()*0.2);
|
||||
|
||||
//周边相似小区
|
||||
if (null == model.getRadius()) {// 设置默认值
|
||||
model.setRadius(1000);
|
||||
}
|
||||
String[] fields = { "city", "region", "name", "estateType2", "id","finishBuildingDate"};
|
||||
List<District> allDistricts = districtService.findNearestDistrict(district, model.getRadius(), fields, Integer.MAX_VALUE);
|
||||
//按条件过滤相似小区
|
||||
Integer buildYear = null;
|
||||
List<District> districts = null;
|
||||
if(StringUtils.isNotBlank(district.getFinishBuildingDate())){
|
||||
buildYear = DistrictScoreUtil.parseStringToDate(district.getFinishBuildingDate());
|
||||
if(buildYear!=null){
|
||||
districts = new ArrayList<District>();
|
||||
int startYear = buildYear -7;
|
||||
int endYear = buildYear + 7;
|
||||
for(District dist : allDistricts){
|
||||
if(StringUtils.isNotBlank(dist.getFinishBuildingDate())){
|
||||
int simlarDistYear = DistrictScoreUtil.parseStringToDate(district.getFinishBuildingDate());
|
||||
if(simlarDistYear>=startYear && simlarDistYear<=endYear && StringUtils.isNotBlank(district.getEstateType2()) && StringUtils.isNotBlank(dist.getEstateType2()) && district.getEstateType2().equals(dist.getEstateType2())){
|
||||
districts.add(dist);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//相似房源
|
||||
Double startArea = model.getSize() - model.getSize()*0.1;
|
||||
Double endArea = model.getSize() + model.getSize()*0.1;
|
||||
Integer startDate = Integer.parseInt(org.apache.tools.ant.util.DateUtils.format(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"));
|
||||
List<Seawater> houses = seawaterService.findSeawatersFromEs2("rent", district.getCity(), district.getRegion(), district.getName(), null, null, startDate, null,
|
||||
startArea, endArea, startPrice, endPrice, null, null, "p_date", false, 1, 5 , null,"seawater-20*/_doc");
|
||||
//无评估小区房源用周边相似小区的房源
|
||||
if(null == houses || houses.size()==0){
|
||||
for (District dist : districts) {
|
||||
houses = seawaterService.findSeawatersFromEs2("rent", dist.getCity(), dist.getRegion(), dist.getName(), null, null, startDate, null,
|
||||
startArea, endArea, startPrice, endPrice, null, null, "p_date", false, 1, 5 , null,"seawater-20*/_doc");
|
||||
if(houses!=null && houses.size()>0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
districtPriceMap.put("houses", houses);
|
||||
|
||||
//周边同类小区租金
|
||||
if (null == model.getRadius()) {// 设置默认值
|
||||
model.setRadius(2000);
|
||||
//周边相似小区租金
|
||||
Integer room = null;
|
||||
if(model.getHouseType()!=null){
|
||||
room = model.getHouseType();
|
||||
}else{
|
||||
room = houseService.getDistrictRoomType((float)model.getSize());
|
||||
}
|
||||
List<District> districts = districtService.findNearestDistrict(district, model.getRadius(), 50);
|
||||
if (null != districts) {
|
||||
Integer room = null;
|
||||
if(model.getHouseType()!=null){
|
||||
room = model.getHouseType();
|
||||
}else{
|
||||
room = houseService.getDistrictRoomType((float)model.getSize());
|
||||
}
|
||||
|
||||
if (null != room) {
|
||||
List<DistrictHouseDtao> dtos = new ArrayList<DistrictHouseDtao>();
|
||||
Date weekend = DateUtil.getFirstDayOfWeek(new Date());
|
||||
for (District dist : districts) {
|
||||
if(StringUtils.isNotBlank(district.getEstateType2()) && StringUtils.isNotBlank(dist.getEstateType2()) && !district.getEstateType2().equals(dist.getEstateType2())){
|
||||
continue;
|
||||
}
|
||||
List<DistrictStatRent> districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, room);
|
||||
if (null != districtStatRents && districtStatRents.size() > 0) {
|
||||
DistrictStatRent districtStatRent = districtStatRents.get(0);
|
||||
if (districtStatRent.getAvgPrice() > 0) {
|
||||
SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(dist.getCity(), dist.getRegion(), dist.getName(), DateUtil.formatToYYYYMMDD(weekend), "district");
|
||||
if(sqmetreRent != null){
|
||||
|
||||
List<DistrictRoomSqmetreRent> districtRoomSqmetreRents = districtRoomSqmetreRentService.findDistrictRoomSqmetreRents(dist, 1, room);
|
||||
|
||||
///List<DistrictStatRent> districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, room);
|
||||
if (null != districtRoomSqmetreRents && districtRoomSqmetreRents.size() > 0) {
|
||||
DistrictRoomSqmetreRent districtRoomSqmetreRent = districtRoomSqmetreRents.get(0);
|
||||
if (districtRoomSqmetreRent.getAvgPrice() > 0) {
|
||||
|
||||
int startSqPrice = (int)(evaluation.getAvgPrice() - evaluation.getAvgPrice()*0.1);
|
||||
int endSqPrice = (int)(evaluation.getAvgPrice() + evaluation.getAvgPrice()*0.1);
|
||||
// SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(dist.getCity(), dist.getRegion(), dist.getName(), DateUtil.formatToYYYYMMDD(weekend), "district");
|
||||
if(districtRoomSqmetreRent.getAvgPrice()>=startSqPrice && districtRoomSqmetreRent.getAvgPrice()<=endSqPrice){
|
||||
DistrictHouseDtao dto = new DistrictHouseDtao();
|
||||
dto.setCity(dist.getCity());
|
||||
dto.setRegion(dist.getRegion());
|
||||
dto.setDistrictName(dist.getName());
|
||||
dto.setRoomPrice(districtStatRent.getAvgPrice());
|
||||
dto.setSqAvgPrice(sqmetreRent.getAvgPrice());
|
||||
dto.setSqAvgPrice(districtRoomSqmetreRent.getAvgPrice());
|
||||
dto.setRoom(room);
|
||||
dtos.add(dto);
|
||||
if(dtos.size()>=5){
|
||||
@@ -5112,10 +5149,15 @@ public class PropertyController {
|
||||
|
||||
|
||||
//近一年户型租金走势
|
||||
Map<String, Object> trendsMap = districtStatRentService.getRentTrend(model.getCity(), model.getDistrict(), model.getName(), -12);
|
||||
Map<String, Object> trendsMap = districtRoomSqmetreRentService.getRentTrends(district.getCity(), district.getRegion(), district.getName(), room, -12);
|
||||
// Map<String, Object> trendsMap = districtStatRentService.getRentTrend(district.getCity(), district.getRegion(), district.getDistrictName(), -12);
|
||||
districtPriceMap.put("trends", trendsMap);
|
||||
|
||||
|
||||
//成交的租房房源
|
||||
List<RentDealPrice> rentTrades = rentDealPriceService.getRentDealPrices(district.getCity(), district.getRegion(), district.getName(), 5);
|
||||
districtPriceMap.put("trades", rentTrades);
|
||||
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(districtPriceMap));
|
||||
return mav;
|
||||
} else {
|
||||
@@ -5404,4 +5446,12 @@ public class PropertyController {
|
||||
public void setSqmetreRentService(SqmetreRentService sqmetreRentService) {
|
||||
this.sqmetreRentService = sqmetreRentService;
|
||||
}
|
||||
|
||||
public void setDistrictRoomSqmetreRentService(DistrictRoomSqmetreRentService districtRoomSqmetreRentService) {
|
||||
this.districtRoomSqmetreRentService = districtRoomSqmetreRentService;
|
||||
}
|
||||
|
||||
public void setRentDealPriceService(RentDealPriceService rentDealPriceService) {
|
||||
this.rentDealPriceService = rentDealPriceService;
|
||||
}
|
||||
}
|
||||
|
||||
+75
-76
@@ -316,82 +316,81 @@ public class RentController {
|
||||
return mav;
|
||||
}
|
||||
|
||||
public Object evaluateRentAction(RentModel model, HttpServletRequest request){
|
||||
RestfulModelAndView mav = new RestfulModelAndView();
|
||||
|
||||
if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName())
|
||||
|| StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),"district");
|
||||
if (null == district) {
|
||||
mav.setModel(BasicModel.buildBadRequestModel("小区不存在"));
|
||||
return mav;
|
||||
}
|
||||
|
||||
Double startArea = model.getSize() - model.getSize()*0.1;
|
||||
Double endArea = model.getSize() + model.getSize()*0.1;
|
||||
|
||||
Integer startDate = Integer.parseInt(DateUtils.format(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"));
|
||||
|
||||
//相似房源
|
||||
List<Seawater> houses = seawaterService.findSeawatersFromEs2("rent", district.getCity(), district.getRegion(), district.getName(), null, null, startDate, null,
|
||||
startArea, endArea, null, null, null, null, "p_date", false, 1, 5 , null,"seawater-20*/_doc");
|
||||
Map<String, Object> retMap = new HashMap<String, Object>();
|
||||
retMap.put("houses", houses);
|
||||
|
||||
if (null == model.getRadius()) {// 设置默认值
|
||||
model.setRadius(2000);
|
||||
}
|
||||
|
||||
//相近小区
|
||||
List<District> districts = districtService.findNearestDistrict(district, model.getRadius(), 50);
|
||||
if (null != districts) {
|
||||
Integer room = null;
|
||||
if(model.getHouseType()!=null){
|
||||
room = model.getHouseType();
|
||||
}else{
|
||||
room = houseService.getDistrictRoomType(model.getSize());
|
||||
}
|
||||
|
||||
if (null != room) {
|
||||
List<DistrictHouseDtao> dtos = new ArrayList<DistrictHouseDtao>();
|
||||
List<Integer> prices = new ArrayList<Integer>();
|
||||
Date weekend = DateUtil.getFirstDayOfWeek(new Date());
|
||||
for (District dist : districts) {
|
||||
List<DistrictStatRent> districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, room);
|
||||
if (null != districtStatRents && districtStatRents.size() > 0) {
|
||||
DistrictStatRent districtStatRent = districtStatRents.get(0);
|
||||
if (districtStatRent.getAvgPrice() > 0) {
|
||||
SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(dist.getCity(), dist.getRegion(), dist.getName(), DateUtil.formatToYYYYMMDD(weekend), "district");
|
||||
if(sqmetreRent != null){
|
||||
DistrictHouseDtao dto = new DistrictHouseDtao();
|
||||
dto.setCity(dist.getCity());
|
||||
dto.setRegion(dist.getRegion());
|
||||
dto.setDistrictName(dist.getName());
|
||||
dto.setRoomPrice(districtStatRent.getAvgPrice());
|
||||
dto.setSqAvgPrice(sqmetreRent.getAvgPrice());
|
||||
dto.setRoom(room);
|
||||
dtos.add(dto);
|
||||
if(dtos.size()>=5){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
retMap.put("districts", dtos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Map<String, Object> trendsMap = districtStatRentService.getRentTrend(model.getCity(), model.getDistrict(), model.getName(), -12);
|
||||
retMap.put("trends", trendsMap);
|
||||
mav.setModel(BasicModel.buildOKModel().setResult(retMap));
|
||||
return mav;
|
||||
}
|
||||
// public Object evaluateRentAction(RentModel model, HttpServletRequest request){
|
||||
// RestfulModelAndView mav = new RestfulModelAndView();
|
||||
//
|
||||
// if (StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(model.getName())
|
||||
// || StringUtils.isBlank(model.getDistrict()) || model.getSize() <= 0) {
|
||||
// mav.setModel(BasicModel.buildBadRequestModel("参数非法:城市,区域,小区名,面积(size)为必填项"));
|
||||
// return mav;
|
||||
// }
|
||||
//
|
||||
// District district = districtService.findByNameAndAlias(model.getCity(), model.getDistrict(), model.getName(),"district");
|
||||
// if (null == district) {
|
||||
// mav.setModel(BasicModel.buildBadRequestModel("小区不存在"));
|
||||
// return mav;
|
||||
// }
|
||||
//
|
||||
// Double startArea = model.getSize() - model.getSize()*0.1;
|
||||
// Double endArea = model.getSize() + model.getSize()*0.1;
|
||||
//
|
||||
// Integer startDate = Integer.parseInt(DateUtils.format(DateUtil.addMonthToDate(new Date(), -12), "yyyyMMdd"));
|
||||
//
|
||||
// //相似房源
|
||||
// List<Seawater> houses = seawaterService.findSeawatersFromEs2("rent", district.getCity(), district.getRegion(), district.getName(), null, null, startDate, null,
|
||||
// startArea, endArea, null, null, null, null, "p_date", false, 1, 5 , null,"seawater-20*/_doc");
|
||||
// Map<String, Object> retMap = new HashMap<String, Object>();
|
||||
// retMap.put("houses", houses);
|
||||
//
|
||||
// if (null == model.getRadius()) {// 设置默认值
|
||||
// model.setRadius(2000);
|
||||
// }
|
||||
//
|
||||
// //相近小区
|
||||
// List<District> districts = districtService.findNearestDistrict(district, model.getRadius(), 50);
|
||||
// if (null != districts) {
|
||||
// Integer room = null;
|
||||
// if(model.getHouseType()!=null){
|
||||
// room = model.getHouseType();
|
||||
// }else{
|
||||
// room = houseService.getDistrictRoomType(model.getSize());
|
||||
// }
|
||||
//
|
||||
// if (null != room) {
|
||||
// List<DistrictHouseDtao> dtos = new ArrayList<DistrictHouseDtao>();
|
||||
// List<Integer> prices = new ArrayList<Integer>();
|
||||
// Date weekend = DateUtil.getFirstDayOfWeek(new Date());
|
||||
// for (District dist : districts) {
|
||||
// List<DistrictStatRent> districtStatRents = districtStatRentService.findLatestDistrictStatRent(dist, 1, room);
|
||||
// if (null != districtStatRents && districtStatRents.size() > 0) {
|
||||
// DistrictStatRent districtStatRent = districtStatRents.get(0);
|
||||
// if (districtStatRent.getAvgPrice() > 0) {
|
||||
// SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(dist.getCity(), dist.getRegion(), dist.getName(), DateUtil.formatToYYYYMMDD(weekend), "district");
|
||||
// if(sqmetreRent != null){
|
||||
// DistrictHouseDtao dto = new DistrictHouseDtao();
|
||||
// dto.setCity(dist.getCity());
|
||||
// dto.setRegion(dist.getRegion());
|
||||
// dto.setDistrictName(dist.getName());
|
||||
// dto.setSqAvgPrice(sqmetreRent.getAvgPrice());
|
||||
// dto.setRoom(room);
|
||||
// dtos.add(dto);
|
||||
// if(dtos.size()>=5){
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// retMap.put("districts", dtos);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// Map<String, Object> trendsMap = districtStatRentService.getRentTrend(model.getCity(), model.getDistrict(), model.getName(), -12);
|
||||
// retMap.put("trends", trendsMap);
|
||||
// mav.setModel(BasicModel.buildOKModel().setResult(retMap));
|
||||
// return mav;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ public class DistrictHouseDtao implements Serializable {
|
||||
private String region;
|
||||
private String districtName;
|
||||
private Integer roomPrice;
|
||||
private Double sqAvgPrice;
|
||||
private Integer sqAvgPrice;
|
||||
private Integer room;
|
||||
private Integer hall;
|
||||
private Integer toilet;
|
||||
@@ -45,11 +45,11 @@ public class DistrictHouseDtao implements Serializable {
|
||||
this.roomPrice = roomPrice;
|
||||
}
|
||||
|
||||
public Double getSqAvgPrice() {
|
||||
public Integer getSqAvgPrice() {
|
||||
return sqAvgPrice;
|
||||
}
|
||||
|
||||
public void setSqAvgPrice(Double sqAvgPrice) {
|
||||
public void setSqAvgPrice(Integer sqAvgPrice) {
|
||||
this.sqAvgPrice = sqAvgPrice;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -523,6 +523,8 @@ public interface DistrictService extends ModeService<DistrictKey, DistrictBo> {
|
||||
|
||||
List<District> findNearestDistrict(District district, int radiusMeters, int limit);
|
||||
|
||||
List<District> findNearestDistrict(District district, int radiusMeters, String[] fields, int limit);
|
||||
|
||||
List<District> findNearestDistrict(String city, Double lng, Double lat, int radiusMeters, int limit);
|
||||
|
||||
int findPeopleDensity(District district);
|
||||
|
||||
+57
@@ -2292,6 +2292,22 @@ public class DistrictServiceImpl implements DistrictService {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List<District> findNearestDistrict(District district, int radiusMeters, String[] fields, int limit) {
|
||||
String cacheKey = district.getCity() + "#" + district.getRegion() + "#" + district.getName() + "#" + radiusMeters + "#" + limit;
|
||||
Object obj = CacheUtils.getValue(this.getClass(), cacheKey);
|
||||
if (obj != null) {
|
||||
return (List<District>) obj;
|
||||
}
|
||||
ArrayList<District> list = new ArrayList<District>();
|
||||
List<District> nlist = doFindNearestDistrict(district, radiusMeters, fields, limit);
|
||||
if (nlist.size() > 0) {
|
||||
list = (ArrayList<District>) nlist;
|
||||
}
|
||||
CacheUtils.putValue(CachePolicyEnum.LONG, this.getClass(), cacheKey, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<District> findNearestDistrict(String city, Double lng, Double lat, int radiusMeters, int limit) {
|
||||
|
||||
@@ -2416,6 +2432,47 @@ public class DistrictServiceImpl implements DistrictService {
|
||||
return new ArrayList<District>(ret);
|
||||
}
|
||||
|
||||
|
||||
public List<District> doFindNearestDistrict(District district, int radiusMeters, String[] fields, int limit) {
|
||||
if (district == null || district.getLat() == null || district.getLng() == null || district.getLat() <= 0
|
||||
|| district.getLng() <= 0) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("category", "district"));
|
||||
params.add(new QueryParam("city", district.getCity()));
|
||||
params.add(new QueryParam("visible", 0));
|
||||
SdQuery sdQuery = new SdQuery();
|
||||
sdQuery.setPoint((double) district.getLat() / 10000000000.0 + "," + (double) district.getLng() / 10000000000.0);
|
||||
sdQuery.setField("lat_lng");
|
||||
sdQuery.setDistance(String.valueOf((double) radiusMeters / 1000.0));
|
||||
params.add(new QueryParam(QueryParam.SD_PARAM_NAME, sdQuery));
|
||||
List<District> list = districtDao.findAllByParams(params, null, 0, limit * 2, fields);
|
||||
if (list.size() == 0) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
List<District> ret = new ArrayList<District>();
|
||||
for (District d : list) {
|
||||
if (district.getName().equals(d.getName()) && district.getRegion().equals(d.getRegion())
|
||||
&& district.getCity().equals(d.getCity())) {
|
||||
continue;
|
||||
}
|
||||
if (d.getEstateType2() != null) {
|
||||
if (d.getEstateType2().indexOf(district.getEstateType2()) > -1) {
|
||||
ret.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret.size() > limit) {
|
||||
ret = ret.subList(0, limit);
|
||||
}
|
||||
|
||||
return new ArrayList<District>(ret);
|
||||
}
|
||||
|
||||
Pattern PATT = Pattern.compile(".*(\\d{4})[Äê\\-].*");
|
||||
|
||||
private Integer parseStringToYear(String s) {
|
||||
|
||||
+9
@@ -15,6 +15,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.fangjia.dal.mongo.model.*;
|
||||
import com.fangjia.service.district.DistrictRoomSqmetreRentService;
|
||||
import com.fangjia.service.district.SqmetreRentService;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
@@ -89,6 +90,8 @@ public class EvaluationServiceImpl implements EvaluationService {
|
||||
private ApiUserCfgService apiUserCfgService;
|
||||
private SqmetreRentService sqmetreRentService;
|
||||
|
||||
private DistrictRoomSqmetreRentService districtRoomSqmetreRentService;
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(EvaluationServiceImpl.class);
|
||||
|
||||
public static final Map<String, List<Double>> CREDIT_RATE_MAP = new HashMap<String, List<Double>>();
|
||||
@@ -1031,6 +1034,8 @@ public class EvaluationServiceImpl implements EvaluationService {
|
||||
evaluation.setFloor(null);
|
||||
evaluation.setHeight(null);
|
||||
}
|
||||
|
||||
|
||||
SqmetreRent sqmetreRent = sqmetreRentService.findNearestSqmetreRent(district.getCity(), district.getRegion(), district.getName(), DateUtil.formatToYYYYMMDD(weekend), "district");
|
||||
if(sqmetreRent!=null){
|
||||
long totalPrice = evaluationRateService.evaluationRent(sqmetreRent.getAvgPrice(), evaluation);
|
||||
@@ -2014,4 +2019,8 @@ public class EvaluationServiceImpl implements EvaluationService {
|
||||
}
|
||||
return evaluationDao.findCountByParams(params);
|
||||
}
|
||||
|
||||
public void setDistrictRoomSqmetreRentService(DistrictRoomSqmetreRentService districtRoomSqmetreRentService) {
|
||||
this.districtRoomSqmetreRentService = districtRoomSqmetreRentService;
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.fangjia.service.district;
|
||||
|
||||
import com.fangjia.dal.mongo.model.DistrictRoomSqmetreRent;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DistrictRoomSqmetreRentService {
|
||||
|
||||
List<DistrictRoomSqmetreRent> findDistrictRoomSqmetreRents(District district, int periodCount, int houseType);
|
||||
|
||||
Map<String, Object> getRentTrends(String city, String region, String name, int room, int count);
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package com.fangjia.service.district;
|
||||
|
||||
import com.fangjia.core.util.CacheUtils;
|
||||
import com.fangjia.core.util.DateUtil;
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.mongo.dao.DistrictRoomSqmetreRentDao;
|
||||
import com.fangjia.dal.mongo.model.DistrictRoomSqmetreRent;
|
||||
import com.fangjia.dal.mongo.model.DistrictStatRent;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.service.bo.DistrictStatRentBo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class DistrictRoomSqmetreRentServiceImpl implements DistrictRoomSqmetreRentService{
|
||||
|
||||
private DistrictRoomSqmetreRentDao districtRoomSqmetreRentDao;
|
||||
|
||||
@Override
|
||||
public List<DistrictRoomSqmetreRent> findDistrictRoomSqmetreRents(District district, int periodCount, int houseType) {
|
||||
String cacheKey = district.getCity() + "_" + district.getRegion() + "_" + district.getName() + "_" + periodCount + "_" + houseType+"_room_rent";
|
||||
// Object obj = CacheUtils.getValue(this.getClass(), cacheKey);
|
||||
// if (obj != null) {
|
||||
// return (List<DistrictRoomSqmetreRent>) obj;
|
||||
// }
|
||||
List<DistrictRoomSqmetreRent> values = doFindLatestDistrictStatRent(district, periodCount, houseType);
|
||||
CacheUtils.putValue(CacheUtils.CachePolicyEnum.LONG, this.getClass(), cacheKey, new ArrayList<DistrictRoomSqmetreRent>(values));
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getRentTrends(String city, String region, String name, int room, int count) {
|
||||
List<Date> dates = DateUtil.getLastDayBetweenDates(DateUtil.addMonthToDate(new Date(),count), new Date());
|
||||
|
||||
List<String> times = new ArrayList<String>();
|
||||
for(Date date : dates){
|
||||
times.add(org.apache.tools.ant.util.DateUtils.format(date, "yyyyMM"));
|
||||
}
|
||||
|
||||
// List<DistrictStatRentBo> districtRents = findDistrictStatRentsByParams(city, region, name, null, dates.get(0), dates.get(dates.size()-1), null, null, null, null, true);
|
||||
List<DistrictRoomSqmetreRent> districtRents = findRentTrends(city, region, name, room, count);
|
||||
Map<String, Map<String, Integer>> distMap = null;
|
||||
List<Integer> rooms = null;
|
||||
|
||||
if(null != districtRents){
|
||||
distMap = new HashMap<String, Map<String, Integer>>();
|
||||
rooms = new ArrayList<Integer>();
|
||||
for(DistrictRoomSqmetreRent rent : districtRents){
|
||||
|
||||
Map<String, Integer> priceMap = distMap.get(room);
|
||||
if(null == priceMap){
|
||||
priceMap = new HashMap<String, Integer>();
|
||||
distMap.put(String.valueOf(room), priceMap);
|
||||
}
|
||||
|
||||
priceMap.put(String.valueOf(rent.getsDate()), rent.getAvgPrice());
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> retMap = new HashMap<String, Object>();
|
||||
if(rooms != null){
|
||||
retMap.put("times", times);
|
||||
retMap.put("distMap", distMap);
|
||||
retMap.put("room", room);
|
||||
}
|
||||
return retMap;
|
||||
}
|
||||
|
||||
|
||||
private List<DistrictRoomSqmetreRent> findRentTrends(String city, String region, String name, int room, int count){
|
||||
String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), count), "yyyyMM");
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("city", city));
|
||||
params.add(new QueryParam("region", region));
|
||||
params.add(new QueryParam("districtName", name));
|
||||
params.add(new QueryParam("houseType",room));
|
||||
params.add(new QueryParam("sDate", QueryParam.GREATER_THAN_EQUAL_OPERATOR, Integer.parseInt(date)));
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("sDate", false));
|
||||
return districtRoomSqmetreRentDao.findAllByParams(params, sortParams, 0, count);
|
||||
}
|
||||
|
||||
|
||||
private List<DistrictRoomSqmetreRent> doFindLatestDistrictStatRent(District district, int periodCount, int houseType){
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("city", district.getCity()));
|
||||
params.add(new QueryParam("region", district.getRegion()));
|
||||
params.add(new QueryParam("districtName", district.getName()));
|
||||
params.add(new QueryParam("houseType",houseType));
|
||||
// params.add(new QueryParam("sDate", QueryParam.GREATER_THAN_EQUAL_OPERATOR, calendar.getTime()));
|
||||
List<SortParam> sortParams = new ArrayList<SortParam>();
|
||||
sortParams.add(new SortParam("sDate", false));
|
||||
return districtRoomSqmetreRentDao.findAllByParams(params, sortParams, 0, periodCount);
|
||||
}
|
||||
|
||||
public void setDistrictRoomSqmetreRentDao(DistrictRoomSqmetreRentDao districtRoomSqmetreRentDao) {
|
||||
this.districtRoomSqmetreRentDao = districtRoomSqmetreRentDao;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.fangjia.service.district;
|
||||
|
||||
import com.fangjia.dal.mongo.model.RentDealPrice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RentDealPriceService {
|
||||
|
||||
List<RentDealPrice> getRentDealPrices(String city, String region, String districtName, int limit);
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.fangjia.service.district;
|
||||
|
||||
import com.fangjia.dal.MongoDaoImpl;
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.mongo.dao.DistrictRoomSqmetreRentDao;
|
||||
import com.fangjia.dal.mongo.dao.RentDealPriceDao;
|
||||
import com.fangjia.dal.mongo.model.RegionStat;
|
||||
import com.fangjia.dal.mongo.model.RentDealPrice;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RentDealPriceServiceImpl extends MongoDaoImpl<RentDealPrice> implements RentDealPriceService{
|
||||
|
||||
private RentDealPriceDao dentDealPriceDao;
|
||||
|
||||
public void setDentDealPriceDao(RentDealPriceDao dentDealPriceDao) {
|
||||
this.dentDealPriceDao = dentDealPriceDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RentDealPrice> getRentDealPrices(String city, String region, String districtName, int limit) {
|
||||
|
||||
List<QueryParam> params = new ArrayList<QueryParam>();
|
||||
params.add(new QueryParam("city", city));
|
||||
if (StringUtils.isNotBlank(region)) {
|
||||
params.add(new QueryParam("region", region));
|
||||
} else {
|
||||
params.add(new QueryParam("region", null));
|
||||
}
|
||||
if (StringUtils.isNotBlank(districtName)) {
|
||||
params.add(new QueryParam("districtName", districtName));
|
||||
} else {
|
||||
params.add(new QueryParam("districtName", null));
|
||||
}
|
||||
|
||||
List<SortParam> sortParms = new ArrayList<SortParam>(1);
|
||||
sortParms.add(new SortParam("tradeDate", true));
|
||||
List<RentDealPrice> list = findAllByParams(params, sortParms, limit);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user