江南行房源价格改为差30%,从ES查
This commit is contained in:
@@ -329,6 +329,9 @@ public class SeawaterDaoImpl extends com.fangjia.dal.SeawaterDaoImpl<Seawater> i
|
||||
} catch (Exception e) {
|
||||
seawater.setpDate(0);
|
||||
}
|
||||
if (source.containsKey("publish_date")){
|
||||
seawater.setPublishDate(source.getString("publish_date"));
|
||||
}
|
||||
if (source.containsKey("url")) {
|
||||
seawater.setUrl(source.getString("url"));
|
||||
}
|
||||
|
||||
+51
-18
@@ -1,9 +1,8 @@
|
||||
package com.fangjia.service.datastore;
|
||||
|
||||
import com.fangjia.core.util.*;
|
||||
import com.fangjia.dal.QueryParam;
|
||||
import com.fangjia.dal.SortParam;
|
||||
import com.fangjia.dal.SrQuery;
|
||||
import com.fangjia.dal.*;
|
||||
import com.fangjia.dal.seawater.dao.SeawaterDao;
|
||||
import com.fangjia.dal.common.DistrictKey;
|
||||
import com.fangjia.dal.datastore.dao.HouseDao;
|
||||
import com.fangjia.dal.datastore.model.House;
|
||||
@@ -14,6 +13,7 @@ import com.fangjia.dal.mongo.model.DistrictStat;
|
||||
import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap;
|
||||
import com.fangjia.dal.mongo.model.bkoff.DealPrice;
|
||||
import com.fangjia.dal.mongo.model.bkoff.Loudong;
|
||||
import com.fangjia.dal.seawater.model.Seawater;
|
||||
import com.fangjia.dal.seaweed.model.District;
|
||||
import com.fangjia.service.address.mode.ProvinceData;
|
||||
import com.fangjia.service.bo.Collateral;
|
||||
@@ -24,12 +24,15 @@ import com.fangjia.service.datastore.bean.CollateralSampleQueryBean;
|
||||
import com.fangjia.service.datastore.bean.ShopCollateralSampleQueryBean;
|
||||
import com.fangjia.service.district.DistrictStatService;
|
||||
import com.fangjia.service.open.FangjiaOfficialAreaService;
|
||||
import com.fangjia.service.util.CommonUtil;
|
||||
import com.fangjia.service.util.CommonUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||
import org.sothis.core.util.Pager;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
@@ -59,6 +62,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
private DistrictSellStatService districtSellStatService;
|
||||
private FangjiaOfficialAreaService fangjiaOfficialAreaService;
|
||||
private LoudongDao loudongDao;
|
||||
private SeawaterDao seawaterDao;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -227,7 +231,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
List<SampleWrapper> querySamples = new ArrayList<SampleWrapper>();
|
||||
District hasHouseDist = districtService.findDistrictHasHouseFlag(district);//查询是否是有房源的小区
|
||||
|
||||
if(hasHouseDist != null){
|
||||
if (hasHouseDist != null) {
|
||||
List<String> keys = new ArrayList<String>();
|
||||
String key = district.getName() + "_" + district.getRegion() + "_" + district.getCity();
|
||||
// 修改
|
||||
@@ -269,7 +273,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
List<String> arroundKeys = new ArrayList<String>();
|
||||
for (District d : districts) {
|
||||
d = districtService.findById(d.getId());
|
||||
if(district.getName().equals(d.getName())){
|
||||
if (district.getName().equals(d.getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -531,8 +535,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
if (!map.containsKey(districtName)) {
|
||||
List<SampleWrapper> sampleWrappers = new ArrayList<SampleWrapper>();
|
||||
sampleWrappers.add(sample);
|
||||
map.put(districtName,sampleWrappers);
|
||||
}else {
|
||||
map.put(districtName, sampleWrappers);
|
||||
} else {
|
||||
map.get(districtName).add(sample);
|
||||
}
|
||||
}
|
||||
@@ -540,9 +544,9 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
for (Map.Entry<String, List<SampleWrapper>> entry : map.entrySet()) {
|
||||
//每个小区取5个样本
|
||||
|
||||
if (entry.getValue().size()>=5){
|
||||
querySamples.addAll(entry.getValue().subList(0,5));
|
||||
}else {
|
||||
if (entry.getValue().size() >= 5) {
|
||||
querySamples.addAll(entry.getValue().subList(0, 5));
|
||||
} else {
|
||||
// 不超过五个,全部放入
|
||||
querySamples.addAll(entry.getValue());
|
||||
}
|
||||
@@ -659,7 +663,7 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
|
||||
querySamples.addAll(samples);
|
||||
if (querySamples.size() < max + 10) {
|
||||
// 查询成交补充 TODO
|
||||
// 查询成交补充 TODO
|
||||
List<QueryParam> dealPriceQuery = new ArrayList<QueryParam>();
|
||||
dealPriceQuery.add(new QueryParam("city", district.getCity()));
|
||||
dealPriceQuery.add(new QueryParam("region", district.getRegion()));
|
||||
@@ -1126,18 +1130,22 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
/**
|
||||
* 江南行查找小区样本(优先使用贝壳链家)
|
||||
*
|
||||
* @param estateType 用户查询物业类型
|
||||
* @param estateType 用户查询物业类型
|
||||
* @param startDate
|
||||
* @return
|
||||
*/
|
||||
private List<SampleWrapper> findJnbankSampleByDistrict(District district, List<String> keys, List<String> names, String estateType, Date startDate, DistrictStat districtStat,double area) {
|
||||
|
||||
private List<SampleWrapper> findJnbankSampleByDistrict(District district, List<String> keys, List<String> names, String estateType, Date startDate, DistrictStat districtStat, double area) {
|
||||
|
||||
//改为从ES 查房源
|
||||
ArrayList<String> districtNames = new ArrayList<String>();
|
||||
BooleanQuery nameQuery = new BooleanQuery();
|
||||
int c = 0;
|
||||
for (String namekey : keys) {
|
||||
if (StringUtils.isNotBlank(namekey)) {
|
||||
namekey = ClientUtils.escapeQueryChars(namekey);
|
||||
if (namekey.contains("_")) {
|
||||
districtNames.add(namekey.split("_")[0]);
|
||||
}
|
||||
c++;
|
||||
nameQuery.add(new TermQuery(new Term("districtname_key", namekey)), BooleanClause.Occur.SHOULD);
|
||||
}
|
||||
@@ -1149,15 +1157,19 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
List<QueryParam> houseQuery = new ArrayList<QueryParam>();
|
||||
houseQuery.add(new QueryParam("city", district.getCity()));
|
||||
houseQuery.add(new QueryParam("region", district.getRegion()));
|
||||
SeawaterQuery seawaterQuery = new SeawaterQuery();
|
||||
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
|
||||
// 价格范围调整为上下浮动30%
|
||||
seawaterQuery.setStartPrice((int) (avgPrice * 0.7));
|
||||
seawaterQuery.setEndPrice((int) (avgPrice * 1.3));
|
||||
houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, (int) (avgPrice * 0.7)));
|
||||
houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, (int) (avgPrice * 1.3)));
|
||||
}
|
||||
houseQuery.add(new QueryParam("area", QueryParam.LESS_THAN_EQUAL_OPERATOR, area + 30));
|
||||
houseQuery.add(new QueryParam("area", QueryParam.GREATER_THAN_EQUAL_OPERATOR, area - 30));
|
||||
|
||||
if (nameQuery.clauses().isEmpty()){
|
||||
if (nameQuery.clauses().isEmpty()) {
|
||||
return samples;
|
||||
}
|
||||
BooleanQuery srQuery = new BooleanQuery();
|
||||
@@ -1169,7 +1181,24 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
|
||||
List<SortParam> houseSortParams = new ArrayList<SortParam>();
|
||||
houseSortParams.add(new SortParam("publishDate", false));
|
||||
List<House> houses = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 200, HOUSE_FIELDS);
|
||||
|
||||
seawaterQuery.setCityDisplay(district.getCity());
|
||||
seawaterQuery.setDistrictAlias(names);
|
||||
seawaterQuery.setRegion(district.getRegion());
|
||||
seawaterQuery.setDistrictName(district.getName());
|
||||
seawaterQuery.setStartArea(area - 30);
|
||||
seawaterQuery.setEndArea(area + 30);
|
||||
seawaterQuery.setSortField("p_date");
|
||||
seawaterQuery.setOrder(false);
|
||||
Pager pager = new Pager(0, 200);
|
||||
pager.setPageSize(200);
|
||||
seawaterQuery.setTable("latest_seawater");
|
||||
seawaterQuery.setPager(pager);
|
||||
seawaterQuery.setCat("sell");
|
||||
List<Seawater> seawaters = seawaterDao.findSeawatersByQuery(seawaterQuery);
|
||||
List<House> houses = CommonUtils.transformListV(House.class, seawaters);
|
||||
|
||||
// List<House> houses1 = houseDao.findAllByParams(houseQuery, houseSortParams, 0, 200, HOUSE_FIELDS);
|
||||
int height = 0;
|
||||
int maxFloor = 0;
|
||||
boolean allSampleHasHeight = true;
|
||||
@@ -1730,4 +1759,8 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
public void setFangjiaOfficialAreaService(FangjiaOfficialAreaService fangjiaOfficialAreaService) {
|
||||
this.fangjiaOfficialAreaService = fangjiaOfficialAreaService;
|
||||
}
|
||||
|
||||
public void setSeawaterDao(SeawaterDao seawaterDao) {
|
||||
this.seawaterDao = seawaterDao;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.fangjia.service.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用实体与DTO互相转换工具类
|
||||
*
|
||||
* @author shenjian
|
||||
* @date 2021/06/16
|
||||
*/
|
||||
public class CommonUtils {
|
||||
public static <T> T transformV(Class<T> targetClass, Object source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
String jsonSource = JSON.toJSONString(source);
|
||||
return JSONObject.parseObject(jsonSource, targetClass);
|
||||
} catch (Exception var3) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<T> transformListV(Class<T> targetClass, List<?> listSource) {
|
||||
if (listSource == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
String jsonSource = JSON.toJSONString(listSource);
|
||||
return JSONArray.parseArray(jsonSource, targetClass);
|
||||
} catch (Exception var3) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user