新增接口及接口bug修改

This commit is contained in:
2025-12-18 12:10:54 +08:00
parent 889f575116
commit 476fe6471f
17 changed files with 1187 additions and 41 deletions
@@ -1469,6 +1469,7 @@ public class AddressParserImpl implements AddressParser {
.replaceAll("【】()\\(\\)\\[\\]", "").replaceAll("\\*+", "").replaceAll("[\\s ]+", "");
}
public void setDistrictService(DistrictService districtService) {
this.districtService = districtService;
}
@@ -88,5 +88,16 @@ public interface AddressMatchProxyService {
JSONObject addressStructure(String city, String address);
/**
* 最新的匹配算法(穆)
* @param city
* @param address
* @param category
* @param useMap
* @return
*/
JSONObject newMatch(String city, String address, String category, boolean useMap );
}
@@ -866,6 +866,35 @@ public class AddressMatchProxyServiceImpl extends AbstractHttpApiService impleme
}
}
@Override
public JSONObject newMatch(String city, String address, String category, boolean useMap ){
HttpRequest request = new HttpRequest();
JSONObject json = null;
Map<String, String> params = new HashMap<String, String>();
params.put("city", city);
params.put("address", address);
if(StringUtils.isNotBlank(category)){
params.put("category", category);
}
params.put("useMap", String.valueOf(useMap));
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
} catch (Exception e) {
try {
json = request.getJsonContent("http://192.168.0.100:32080/FangJiaNlpService/match", params, "UTF-8");
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (json != null && json.size()>0) {
return (JSONObject)json;
}
return null;
}
public void setHouseLoudongService(HouseLoudongService houseLoudongService) {
this.houseLoudongService = houseLoudongService;
}
@@ -99,6 +99,15 @@ public interface DistrictSellStatService {
* @return
*/
Long findCityMarkDownDistrictCount(String city);
/**
* 查找最新一期的月度增价
* @param city
* @param region
* @param name
* @return
*/
DistrictSellStat findFirstByParams(String city, String region,String name);
}
@@ -219,4 +219,17 @@ public class DistrictSellStatServiceImpl implements DistrictSellStatService {
params.add(new QueryParam("mom", QueryParam.LESS_THAN_OPERATOR, 0));
return districtSellStatDao.findCountByParams(params);
}
@Override
public DistrictSellStat findFirstByParams(String city, String region,String name) {
List<QueryParam> queryParams = ImmutableList.of(
new QueryParam("city", city),
new QueryParam("region", region),
new QueryParam("districtName", name)
);
List<SortParam> sortParams = ImmutableList.of(
new SortParam("date", false)
);
return districtSellStatDao.findFirstByParams(queryParams, sortParams);
}
}
@@ -2014,6 +2014,13 @@ public class DistrictServiceImpl implements DistrictService {
if (city == null){
return null;
}
if(RegionData.isRegion(city, region)){
region = RegionData.formatRegion(city, region);
}
if(region == null){
return null;
}
District districtInfo = findDistrict(new DistrictKey(city, region, name), target);
// 先精确查询,查不到再根据别名匹配
if (districtInfo != null) {
@@ -2449,6 +2456,7 @@ public class DistrictServiceImpl implements DistrictService {
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("category", "district"));
params.add(new QueryParam("city", district.getCity()));
params.add(new QueryParam("estateType2", district.getEstateType2()));
params.add(new QueryParam("visible", 0));
SdQuery sdQuery = new SdQuery();
sdQuery.setPoint((double) district.getLat() / 10000000000.0 + "," + (double) district.getLng() / 10000000000.0);
@@ -2456,7 +2464,7 @@ public class DistrictServiceImpl implements DistrictService {
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,
new String[] { "city", "region", "name", "estateType2", "id" });
new String[] { "city", "region", "name", "estateType2", "id","lat","lng" });
if (list.isEmpty()) {
return Collections.emptyList();
}
@@ -8,6 +8,7 @@ import java.util.Map;
import com.fangjia.dal.FacetQuery;
import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.datastore.model.RentHouse;
import com.fangjia.dal.seawater.model.Seawater;
import com.fangjia.datastore.driver.FacetResult;
import com.fangjia.service.bo.HousePDSBo;
import com.fangjia.service.bo.HouseScorer;
@@ -473,5 +474,32 @@ public interface HouseService extends ModeService<String, HouseBo> {
List<House> findNearestHasHouseByLocation(String city, Double lat, Double lng, String cat, int radiusMeters, int limit);
/**
* 查询自身房源
* @param district
* @param cat
* @param startTime
* @param endTime
* @param startPrie
* @param endPrice
* @param pager
* @return
*/
List<Seawater> findSelfHouseByParams(District district, String cat, Integer startTime, Integer endTime, Integer startPrie, Integer endPrice, String estateType, Pager pager);
/**
* 根据经纬度查周边样本
* @param lng
* @param lat
* @param startTime
* @param endTime
* @param startPrie
* @param endPrice
* @param pager
* @param radius
* @return
*/
List<Seawater> findArroundHouseByParams(String cat, Double lng, Double lat, Integer startTime, Integer endTime, Integer startPrie, Integer endPrice, String estateType, Pager pager, Integer radius);
}
@@ -11,16 +11,18 @@ import com.fangjia.dal.datastore.model.House;
import com.fangjia.dal.datastore.model.RentHouse;
import com.fangjia.dal.mongo.dao.UserHouseDao;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.DistrictStat;
import com.fangjia.dal.mongo.model.FangjiaOfficialAreaMap;
import com.fangjia.dal.mongo.model.UserHouse;
import com.fangjia.dal.mongo.model.bkoff.DealPrice;
import com.fangjia.dal.seawater.dao.SeawaterDao;
import com.fangjia.dal.seawater.model.Seawater;
import com.fangjia.dal.seaweed.model.District;
import com.fangjia.datastore.driver.DSCollection;
import com.fangjia.datastore.driver.DataStore;
import com.fangjia.datastore.driver.FacetResult;
import com.fangjia.service.api.KnowbaseService;
import com.fangjia.service.bo.HouseBo;
import com.fangjia.service.bo.HousePDSBo;
import com.fangjia.service.bo.HouseScorer;
import com.fangjia.service.bo.KnowbaseBo;
import com.fangjia.service.bo.*;
import com.fangjia.service.common.SellSimilar;
import com.fangjia.service.datastore.bean.HouseQueryBean;
import com.fangjia.service.district.DistrictStatService;
@@ -31,6 +33,7 @@ import com.fangjia.service.menu.Menu;
import com.fangjia.service.mode.ModeEnum;
import com.fangjia.service.mongo.fangjia.MetroService;
import com.fangjia.service.query.QueryBean;
import com.fangjia.service.util.CommonUtils;
import com.fangjia.service.util.ServiceUtil;
import com.fangjia.service.util.SitenameUtil;
import com.fangjia.service.web.MenuService;
@@ -38,6 +41,7 @@ import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import org.apache.commons.lang.StringUtils;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
@@ -83,7 +87,9 @@ public class HouseServiceImpl implements HouseService {
* 房源样本估价简洁模式检索属性
*/
private static final String[] SAMPLE_COMPACT = {"id", "city", "region", "districtName", "name", "area", "hall", "room", "toilet", "floor", "height", "direction", "fitment", "totalPrice", "url", "publishDate" };
public static String[] TAGS = new String[]{"独栋", "联排", "叠加", "双拼", "花园面积", "泳池", "别墅", "带花园", "洋房", "叠拼", "独院", "联体", "微墅", "大平墅"};
private HouseDao houseDao;
private PicService picService;
private DistrictService districtService;
@@ -94,6 +100,7 @@ public class HouseServiceImpl implements HouseService {
private BoostQueryPolicy boostQueryInformationPolicy;
private UserHouseDao userHouseDao;
private DistrictStatService districtStatService;
private SeawaterDao seawaterDao;
public FacetQueryResult<HouseBo> randomGainHouse(HouseQueryBean queryBean, int count) {
long totalCount = this.findHouseCount(queryBean);
@@ -2635,4 +2642,239 @@ public class HouseServiceImpl implements HouseService {
return list;
}
@Override
public List<Seawater> findSelfHouseByParams(District district, String cat, Integer startTime, Integer endTime, Integer startPrie, Integer endPrice, String estateType, Pager pager) {
SeawaterQuery query = new SeawaterQuery();
// 先用名字查自身的样本
query.setCityDisplay(district.getCity());
query.setRegion(district.getRegion());
query.setDistrictName(district.getName());
query.setCat(cat);
query.setStartDate(startTime);
query.setEndDate(endTime);
if(StringUtils.isNotBlank(estateType)){
query.setEstateType(estateType);
}
if (startPrie != null) {
query.setStartPrice(startPrie);
}
if(endPrice != null){
query.setEndPrice(endPrice);
}
query.setPager(pager);
query.setSortField("p_date");
query.setOrder(false);
query.setTable("latest_seawater");
// if(StringUtils.isNotBlank(estateType)){
List<Seawater> seawaters = seawaterDao.findSeawatersByQuery(query);
List<Seawater> houses = new ArrayList<Seawater>();
for(Seawater s : seawaters){
if(StringUtils.isNotBlank(district.getEstateType2())){
if (district.getEstateType2().equals("普通住宅")) {//01:普通住宅 02:别墅
if (StringUtils.isNotBlank(s.getEstateType()) && s.getEstateType().contains("别墅")) {
continue;
}
if (isVilla(s.getArea(), s.getName(), s.getHeight(), s.getRoom())) {
continue;
}
houses.add(s);
} else if (district.getEstateType2().equals("别墅")) {
if (s.getHeight() != null && s.getHeight() >= 10) {
continue;
}
if (s.getFloor() != null && s.getFloor() >= 10) {
continue;
}
if (s.getArea()<=150) {
continue;
}
houses.add(s);
}
}
}
return houses;
// }
// return seawaterDao.findSeawatersByQuery(query);
}
@Override
public List<Seawater> findArroundHouseByParams(String cat, Double lng, Double lat, Integer startTime, Integer endTime, Integer startPrie, Integer endPrice, String estateType, Pager pager, Integer radius) {
SeawaterQuery query = new SeawaterQuery();
query.setLat(lat);
query.setLng(lng);
query.setRadius(radius);
query.setCat(cat);
query.setStartDate(startTime);
query.setEndDate(endTime);
if (startPrie != null) {
query.setStartPrice(startPrie);
}
if(endPrice != null){
query.setEndPrice(endPrice);
}
if(StringUtils.isNotBlank(estateType)){
query.setEstateType(estateType);
}
query.setPager(pager);
query.setSortField("p_date");
query.setOrder(false);
query.setTable("latest_seawater");
return seawaterDao.findSeawatersByQuery(query);
}
/**
*
* @param estateType 用户查询物业类型
* @param startDate
* @return
*/
private List<SampleWrapper> findByDistrict(District district, List<String> keys, List<String> names, Date startDate, Integer startPrice, Integer endPrice) {
//改为从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);
}
}
List<SampleWrapper> samples = new ArrayList<SampleWrapper>();
List<SampleWrapper> nolianjiaSamples = new ArrayList<SampleWrapper>();
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 (startPrice!=null && startPrice>0) {
houseQuery.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startPrice));
}
if(endPrice!=null && endPrice>0){
houseQuery.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, endPrice));
}
if (nameQuery.clauses().isEmpty()) {
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));
seawaterQuery.setCityDisplay(district.getCity());
seawaterQuery.setDistrictAlias(names);
seawaterQuery.setRegion(district.getRegion());
seawaterQuery.setDistrictName(district.getName());
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);
int height = 0;
int maxFloor = 0;
boolean allSampleHasHeight = true;
for (House house : houses) {
if (StringUtils.isNotBlank(district.getEstateType2()) && district.getEstateType2().equals("普通住宅")) {//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(district.getEstateType2()) && district.getEstateType2().equals("别墅")) {
if (house.getHeight() != null && house.getHeight() >= 10) {
continue;
}
if (house.getFloor() != null && house.getFloor() >= 10) {
continue;
}
}
SampleWrapper sample = null;//convertHouse2Sample(house);
if (isAvailableSample(sample)) {
if (house.getUrl().contains("lianjia.com") || house.getUrl().contains("ke.com")) {
samples.add(sample);
} else {
nolianjiaSamples.add(sample);
}
}
}
return samples;
}
/**
* 判断样本是否可用
*
* @param sample
* @return
*/
private boolean isAvailableSample(SampleWrapper sample) {
if (sample.getStrctureArea() > 500 || sample.getStrctureArea() < 10) {
return false;
}
return true;
}
/**
* 是否是别墅
*
* @return
*/
public boolean isVilla(Double area, String name, Integer height, Integer room) {
if (area == null) {
return false;
}
if (area >= 150 && StringUtils.indexOfAny(name, TAGS) > -1) {
return true;
}
boolean ret = false;
if (height != null && room != null) {
if (height <= 3) {
if (area > 200 && room >= 5) {
ret = true;
}
}
} else if (height == null && room != null) {
if (area > 360 && room >= 6) {
ret = true;
}
} else if (height == null && room == null) {
if (area > 500) {
ret = true;
}
}
return ret;
}
public void setSeawaterDao(SeawaterDao seawaterDao) {
this.seawaterDao = seawaterDao;
}
}
@@ -197,9 +197,6 @@ public class OfficeServiceImpl implements OfficeService {
params.add(new QueryParam("city", evaluation.getCity()));
params.add(new QueryParam("district", evaluation.getRegion()));
params.add(new QueryParam("name", evaluation.getDistrictName()));
// 获取上个月yyyyMM日期
String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -2), "yyyyMM");
params.add(new QueryParam("date", Integer.parseInt(date)));
// 按日期降序排序,取最新的数据,可能上月还未更新,则取上上个月的数据
List<SortParam> sortParams = new ArrayList<SortParam>();
@@ -207,7 +204,15 @@ public class OfficeServiceImpl implements OfficeService {
// 第二步:基准价*楼层系数*装修系数*朝向系数
OfficeRentStat officeRentStat = officeRentStatDao.findFirstByParams(params);
Double avgPrice = officeRentStat.getAvgPrice();
// if(officeRentStat == null){
// // 获取上个月yyyyMM日期
// String date = DateUtil.formatByPattern(DateUtil.addMonthToDate(new Date(), -1), "yyyyMM");
// params.add(new QueryParam("date", Integer.parseInt(date)));
// }
Double avgPrice = null;
if(officeRentStat != null){
avgPrice = officeRentStat.getAvgPrice();
}
if (avgPrice != null) {
Double factor = 1.0;
if (evaluation.getFitment() != null) {
@@ -69,6 +69,8 @@ public interface DealPriceService {
*/
public List<DealPrice> findDealPrices(List<QueryParam> params, int max);
public List<DealPrice> findDealPrices(String id, int max, Integer startPrice, Integer endPrice, Date startDate, Date endDate);
public Integer findDealPrices(String city, String region, String districtName, Date startDate, Date endDate);
public List<DealPrice> findDealPriceList(String city, String region, String districtName, Date startDate,
@@ -180,6 +180,33 @@ public class DealPriceServiceImpl implements DealPriceService {
"tradeDate", "source", "room", "hall", "toilet", "height", "floor","direction" });
}
@Override
public List<DealPrice> findDealPrices(String id, int max, Integer startPrice, Integer endPrice, Date startDate, Date endDate) {
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("tradeDate", QueryParam.GREATER_THAN_EQUAL_OPERATOR, DateUtil.add(new Date(), -6)));
params.add(new QueryParam("matchId", id));
if(startPrice!=null && startPrice>0){
params.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startPrice));
}
if(startPrice!=null && startPrice>0){
params.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_EQUAL_OPERATOR, endPrice));
}
if(startDate!=null){
params.add(new QueryParam("tradeDate", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate));
}
if(endDate!=null){
params.add(new QueryParam("tradeDate", QueryParam.LESS_THAN_EQUAL_OPERATOR, endDate));
}
List<SortParam> sortParams = new ArrayList<SortParam>();
sortParams.add(new SortParam("tradeDate", false));
return dealPriceDao.findAllByParams(params, sortParams, 0, max,
new String[] { "city", "region", "districtName", "avgPrice", "fitment", "area", "totalPrice",
"tradeDate", "source", "room", "hall", "toilet", "height", "floor","direction" });
}
@Override
public Integer findDealPrices(String city, String region, String districtName, Date startDate, Date endDate) {
List<QueryParam> params = new ArrayList<QueryParam>();