江南行房源价格改为差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"));
|
||||
}
|
||||
|
||||
+40
-7
@@ -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
|
||||
@@ -1132,12 +1136,16 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
||||
*/
|
||||
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,10 +1157,14 @@ 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));
|
||||
@@ -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