Merge branch 'open_bohai' into 'master'
江南行选房源修改 See merge request !658
This commit is contained in:
+5
-1
@@ -1,10 +1,13 @@
|
||||
package com.fangjia.service.datastore;
|
||||
|
||||
import com.fangjia.dal.mongo.model.DistrictStat;
|
||||
import com.fangjia.service.bo.Collateral;
|
||||
import com.fangjia.service.bo.SampleWrapper;
|
||||
import com.fangjia.service.bo.ShopSample;
|
||||
import com.fangjia.service.datastore.bean.CollateralSampleQueryBean;
|
||||
import com.fangjia.service.datastore.bean.ShopCollateralSampleQueryBean;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -27,4 +30,5 @@ public interface CzbankSampleService {
|
||||
*/
|
||||
List<ShopSample> findShopSample(ShopCollateralSampleQueryBean queryBean, int max);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+217
-3
@@ -46,7 +46,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService{
|
||||
"totalPrice", "avgPrice", "area", "roomNumber", "fitment", "direction", "floor", "height", "tradeDate", "address"};
|
||||
|
||||
private static String[] HOUSE_FIELDS = new String[]{"city", "region", "districtName", "totalPrice", "avgPrice",
|
||||
"area", "fitment", "direction", "floor", "height", "publishDate", "address", "estateType"};
|
||||
"area", "fitment", "direction", "floor", "height", "publishDate", "address", "estateType","url"};
|
||||
|
||||
public static String[] TAGS =new String[]{"独栋", "联排", "叠加", "双拼", "花园面积", "泳池", "别墅", "带花园", "洋房", "叠拼", "独院", "联体", "微墅", "大平墅"};
|
||||
|
||||
@@ -187,7 +187,9 @@ public class CzbankSampleServiceImpl implements CzbankSampleService{
|
||||
districtStat = districtStatService.findOneDistrictStatsSort(district.getCity(), district.getRegion(), district.getName(), DateUtil.add( new Date(), -7));
|
||||
}
|
||||
List<SampleWrapper> querySamples= new ArrayList<SampleWrapper>();
|
||||
List<SampleWrapper> samples = findSampleByDistrict(district.getCity(), district.getRegion(), district.getName(), district.getAlias(), district.getMasterDistrictNname(), district.getEstateType2(),queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat);
|
||||
// List<SampleWrapper> samples = findSampleByDistrict(district.getCity(), district.getRegion(), district.getName(), district.getAlias(), district.getMasterDistrictNname(), district.getEstateType2(),queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat);
|
||||
List<SampleWrapper> samples = findJnbankSampleByDistrict(district.getCity(), district.getRegion(), district.getName(), district.getAlias(), district.getMasterDistrictNname(), district.getEstateType2(),queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat);
|
||||
|
||||
// scoreForSample(samples, target);
|
||||
sortForSample(samples, target);
|
||||
for(SampleWrapper sample : samples){
|
||||
@@ -199,7 +201,9 @@ public class CzbankSampleServiceImpl implements CzbankSampleService{
|
||||
List<District> districts = districtService.findNearestDistrict(district, 1000, 5);
|
||||
for(District d : districts){
|
||||
d = districtService.findById(d.getId());
|
||||
List<SampleWrapper> nearlySample = findSampleByDistrict(d.getCity(), d.getRegion(), d.getName(), district.getAlias(), district.getMasterDistrictNname(), district.getEstateType2(),queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat);
|
||||
//List<SampleWrapper> nearlySample = findSampleByDistrict(d.getCity(), d.getRegion(), d.getName(), district.getAlias(), district.getMasterDistrictNname(), district.getEstateType2(),queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat);
|
||||
List<SampleWrapper> nearlySample = findJnbankSampleByDistrict(d.getCity(), d.getRegion(), d.getName(), district.getAlias(), district.getMasterDistrictNname(), district.getEstateType2(),queryBean.getPropertyTypeCode(), queryBean.getUpdateDate(), districtStat);
|
||||
|
||||
for(SampleWrapper sample : nearlySample){
|
||||
sample.setProperty(d);
|
||||
}
|
||||
@@ -499,6 +503,27 @@ public class CzbankSampleServiceImpl implements CzbankSampleService{
|
||||
});
|
||||
|
||||
List<Integer> prices = new ArrayList<Integer>();
|
||||
// for(SampleWrapper sample : samples){
|
||||
// if(!prices.contains(sample.getUnitPrice())){
|
||||
// double min = targetSample.getStrctureArea() - 20;
|
||||
// double max = targetSample.getStrctureArea() + 20;
|
||||
// if(sample.getStrctureArea()>=min && sample.getStrctureArea()<=max){
|
||||
// prices.add(sample.getUnitPrice());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(prices.size()<10){
|
||||
// prices.clear();
|
||||
// for(SampleWrapper sample : samples){
|
||||
// if(!prices.contains(sample.getUnitPrice())){
|
||||
// prices.add(sample.getUnitPrice());
|
||||
// if(prices.size()>=10){
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
for(SampleWrapper sample : samples){
|
||||
if(!prices.contains(sample.getUnitPrice())){
|
||||
prices.add(sample.getUnitPrice());
|
||||
@@ -708,6 +733,195 @@ public class CzbankSampleServiceImpl implements CzbankSampleService{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 江南行查找小区样本(优先使用贝壳链家)
|
||||
* @param city
|
||||
* @param region
|
||||
* @param name
|
||||
* @param alias
|
||||
* @param estateType 用户查询物业类型
|
||||
* @param startDate
|
||||
* @param distEstateType 小区物业类型
|
||||
* @return
|
||||
*/
|
||||
private List<SampleWrapper> findJnbankSampleByDistrict(String city, String region, String name, List<String> alias, String masterName, String distEstateType, String estateType, Date startDate, DistrictStat districtStat){
|
||||
|
||||
List<String> names = new ArrayList<String>();
|
||||
names.add(ClientUtils.escapeQueryChars(name));
|
||||
if(alias != null){
|
||||
for(String alia : alias){
|
||||
if(StringUtils.isNotBlank(alia) && alia.length() >= 2 && !names.contains(alia)){
|
||||
names.add(ClientUtils.escapeQueryChars(alia));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(masterName)){
|
||||
names.add(ClientUtils.escapeQueryChars(masterName));
|
||||
}
|
||||
|
||||
List<SampleWrapper> samples = new ArrayList<SampleWrapper>();
|
||||
List<SampleWrapper> nolianjiaSamples = new ArrayList<SampleWrapper>();
|
||||
|
||||
List<QueryParam> houseQuery = new ArrayList<QueryParam>();
|
||||
houseQuery.add(new QueryParam("city", city ));
|
||||
houseQuery.add(new QueryParam("region", region ));
|
||||
if(districtStat != null && districtStat.getAvgPrice() > 0){
|
||||
int avgPrice = districtStat.getAvgPrice();
|
||||
houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int)(avgPrice * 0.5 )));//0.85
|
||||
houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int)(avgPrice * 1.5 )));//1.15
|
||||
}
|
||||
BooleanQuery nameQuery = new BooleanQuery();
|
||||
int c = 0;
|
||||
for (String n : names) {
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
if (name.indexOf("(") > -1 || name.indexOf(")") > -1 || name.indexOf("(") > -1 || name.indexOf(")") > -1
|
||||
| name.indexOf("[") > -1 || name.indexOf("]") > -1 || name.indexOf("-") > -1 || name.indexOf("{") > -1
|
||||
|| name.indexOf("}") > -1 || name.indexOf("{") > -1 || name.indexOf("}") > -1 || name.indexOf(":") > -1|| name.indexOf("\\") > -1) {
|
||||
continue;
|
||||
}
|
||||
c++;
|
||||
nameQuery.add(new TermQuery(new Term("district_name", n)), BooleanClause.Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
|
||||
if(nameQuery.clauses().size()==0){
|
||||
return samples;
|
||||
}
|
||||
BooleanQuery srQuery = new BooleanQuery();
|
||||
srQuery.add(nameQuery, BooleanClause.Occur.MUST);
|
||||
houseQuery.add(new QueryParam("$sr", new SrQuery(srQuery)));
|
||||
if(startDate != null){
|
||||
houseQuery.add(new QueryParam("publishDate", QueryParam.GREATER_THAN_OPERATOR, startDate));
|
||||
}
|
||||
|
||||
List<SortParam> houseSortParams = new ArrayList<SortParam>();
|
||||
houseSortParams.add(new SortParam("publishDate", false));
|
||||
List<House> houses = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 500, HOUSE_FIELDS);
|
||||
int height = 0;
|
||||
int maxFloor = 0;
|
||||
boolean allSampleHasHeight = true;
|
||||
for(House house : houses){
|
||||
if(StringUtils.isNotBlank(estateType) && estateType.equals("01")){//01:普通住宅 02:别墅
|
||||
if(StringUtils.isNotBlank(house.getEstateType()) && house.getEstateType().contains("别墅")){
|
||||
continue;
|
||||
}
|
||||
if(isVilla(house.getArea(), house.getName(), house.getHeight(), house.getRoom())){
|
||||
continue;
|
||||
}
|
||||
}else if(StringUtils.isNotBlank(estateType) && estateType.equals("02")){
|
||||
if(house.getHeight()!=null && house.getHeight()>=10){
|
||||
continue;
|
||||
}
|
||||
if(house.getFloor()!=null && house.getFloor()>=10){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
SampleWrapper sample = convertHouse2Sample(house);
|
||||
if(isAvailableSample(sample)){
|
||||
if(house.getUrl().contains("lianjia.com") || house.getUrl().contains("ke.com")){
|
||||
samples.add(sample);
|
||||
}else{
|
||||
nolianjiaSamples.add(sample);
|
||||
}
|
||||
}
|
||||
if(sample.getAboveFloorAmount() == null){
|
||||
allSampleHasHeight = false;
|
||||
}else if(sample.getAboveFloorAmount() > 0 && sample.getAboveFloorAmount() > height && sample.getAboveFloorAmount() < 100){
|
||||
height = sample.getAboveFloorAmount() ;
|
||||
}
|
||||
if(sample.getFloorNumber() != null && sample.getFloorNumber() > maxFloor){
|
||||
maxFloor = sample.getFloorNumber();
|
||||
}
|
||||
//浙商测试特意添加
|
||||
if(house.getDistrictName().equals("新泾三村") && house.getArea()>=35 && house.getArea()<=55){
|
||||
sample.setDoorNo("502");
|
||||
sample.setBuildingNoName("56");
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(house.getEstateType())){
|
||||
if(house.getEstateType().contains("商业") || house.getEstateType().contains("商住") || house.getEstateType().contains("办公")){
|
||||
sample.setBuildingName(house.getDistrictName() +"(商住)");
|
||||
}
|
||||
}else{
|
||||
if(StringUtils.isNotBlank(distEstateType) && (distEstateType.contains("商住") && (!name.contains("商住") || !name.contains("商业")) )){
|
||||
sample.setBuildingName(house.getDistrictName() + "(商住)");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
List<QueryParam> dealPriceQuery = new ArrayList<QueryParam>();
|
||||
dealPriceQuery.add(new QueryParam("city", city ));
|
||||
dealPriceQuery.add(new QueryParam("region", region ));
|
||||
dealPriceQuery.add(new QueryParam("districtName", QueryParam.IN_OPERATOR, names));
|
||||
if(startDate != null){
|
||||
dealPriceQuery.add(new QueryParam("tradeDate", QueryParam.GREATER_THAN_OPERATOR, startDate ));
|
||||
}else{
|
||||
dealPriceQuery.add(new QueryParam("tradeDate", QueryParam.GREATER_THAN_OPERATOR, DateUtil.add(new Date(), Calendar.MONTH, -3) ));
|
||||
}
|
||||
List<SortParam> dealPriceSortParams = new ArrayList<SortParam>();
|
||||
dealPriceSortParams.add(new SortParam("tradeDate", false));
|
||||
List<DealPrice> dealPrices = dealPriceDao.findAllByParams(dealPriceQuery, dealPriceSortParams, 0, 100, DEAL_PRICE_FIELDS);
|
||||
for(DealPrice dealPrice : dealPrices){
|
||||
SampleWrapper sample = convertDealPrice2Sample(dealPrice);
|
||||
if(isAvailableSample(sample)){
|
||||
samples.add(sample);
|
||||
}
|
||||
if(sample.getAboveFloorAmount() == null){
|
||||
allSampleHasHeight = false;
|
||||
}else if(sample.getAboveFloorAmount() > 0 && sample.getAboveFloorAmount() > height && sample.getAboveFloorAmount() < 100){
|
||||
height = sample.getAboveFloorAmount() ;
|
||||
}
|
||||
if(sample.getFloorNumber() != null && sample.getFloorNumber() > maxFloor){
|
||||
maxFloor = sample.getFloorNumber();
|
||||
}
|
||||
}
|
||||
if(!allSampleHasHeight){
|
||||
if(height == 0){//如果没有楼高到楼栋库里寻找最高的楼高
|
||||
height = findHeight(city, region, name);
|
||||
}
|
||||
if(height == 0){//如果楼栋库没有使用房源中的最大楼层
|
||||
height = maxFloor;
|
||||
}
|
||||
if(height == 0){//没有楼高信息使用默认的楼高
|
||||
if(estateType == "01"){//住宅默认6楼
|
||||
height = 6;
|
||||
}else{//别墅默认三村
|
||||
height = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FangjiaOfficialAreaMap fangjiaOfficialAreaMap = fangjiaOfficialAreaService.convertFangjiaToOfficial(city, region);
|
||||
|
||||
if(samples.size()<10){
|
||||
samples.addAll(nolianjiaSamples);
|
||||
}
|
||||
|
||||
for(SampleWrapper sample : samples){
|
||||
if(sample.getAboveFloorAmount() == null){
|
||||
sample.setAboveFloorAmount(height);
|
||||
}
|
||||
if(sample.getFloorNumber() == null){
|
||||
if("01".equals(estateType)){
|
||||
sample.setFloorNumber((sample.getAboveFloorAmount()/2));
|
||||
}else{
|
||||
sample.setFloorNumber(1);
|
||||
}
|
||||
}
|
||||
if(fangjiaOfficialAreaMap != null){
|
||||
sample.setProvince(fangjiaOfficialAreaMap.getProvinceCode());
|
||||
sample.setCity(fangjiaOfficialAreaMap.getCityCode());
|
||||
sample.setDistrict(fangjiaOfficialAreaMap.getDistrictCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据小区名在楼栋库中查询最大的楼高
|
||||
* @param city
|
||||
|
||||
Reference in New Issue
Block a user