Merge remote-tracking branch 'origin/master'

This commit is contained in:
2022-06-15 18:50:01 +08:00
354 changed files with 37191 additions and 1728 deletions
@@ -1,12 +1,12 @@
package com.fangjia.service.address;
import com.fangjia.core.RegionData;
import com.fangjia.core.util.*;
import com.fangjia.core.util.DataUtil;
import com.fangjia.core.util.GeoUtils;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.common.ServerAreaData;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.AmapPoi;
import com.fangjia.dal.mongo.model.bkoff.HouseLoudong;
import com.fangjia.dal.mongo.model.bkoff.Loudong;
import com.fangjia.dal.seaweed.dao.SeaweedDao;
@@ -16,17 +16,15 @@ import com.fangjia.service.address.processor.AddressDistrictProcessors;
import com.fangjia.service.address.processor.AddressProcessors;
import com.fangjia.service.api.AliyunService;
import com.fangjia.service.bo.AliyunBo;
import com.fangjia.service.bo.MatchAddressScore;
import com.fangjia.service.datastore.DistrictService;
import com.fangjia.service.mongo.addrepo.AddressRepoService;
import com.fangjia.service.mongo.bkoff.HouseLoudongService;
import com.fangjia.service.mongo.bkoff.LoudongService;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.bson.types.ObjectId;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
@@ -759,6 +757,13 @@ public class AddressParserServiceImpl implements AddressParserService {
double simScore;
boolean onSameRoad = false;
boolean sameDistrict = isSameDistrict(address, metaData);
if(PreciseLevel.STRICT == address.getPreciseLevel() && !sameDistrict){
return 0;
}
// //当地图解析出来的区域和用户地址中的区域一致时,只匹配指定区域下面的小区
// if(address.getGeoRegion() != null && address.getGeoRegion().equals(address.getDistrict()) && !sameDistrict){
// return 0;
// }
Iterator<Map.Entry<String, MatchText>> addrEntrySet = metaData.getAddrePinYinMap().entrySet().iterator();
Map.Entry<String, MatchText> addrEntry;
while(addrEntrySet.hasNext()){
@@ -808,7 +813,6 @@ public class AddressParserServiceImpl implements AddressParserService {
}
}
}
String keywordPinYin = address.getKeywordsPinYin();
String keywords = address.getKeywords();
String fuzzyKeywordsPinYin = address.getFuzzyKeywordsPinYin();
@@ -892,7 +896,7 @@ public class AddressParserServiceImpl implements AddressParserService {
if(name.length() == 2 && (name.equals(address.getOrgAddress()) || name.equals(address.getEffectiveAddress()))){
keywordScore = Math.max(keywordScore, namePriority);
}else if(name.length() > 3 && (address.getOrgAddrePinYin().contains(namePinYin) || enhanceContains(address.getOrgAddress(), name))){
double similar = AddressParserUtil.getSimilarityRatio(name, address.getEffectiveAddress());
double similar = AddressParserUtil.getSimilarityRatio(name, address.getOrgAddress());
if(similar == 1){
keywordScore = Math.max(similar, keywordScore) * namePriority * 1.0001;
}else if(similar > 0.1){
@@ -907,20 +911,27 @@ public class AddressParserServiceImpl implements AddressParserService {
if (standardAddressScore > 0 && keywordScore > 0) {
matchLevelScore = 0.9;
similarityScore = Math.max(standardAddressScore, keywordScore) * SIMILARITY_RATE;
} else if(keywordScore > 0 && streetScore > 0){
matchLevelScore = 0.8;
similarityScore = Math.max(streetScore, keywordScore * 0.8) * SIMILARITY_RATE;
} else if (standardAddressScore > 0) {
matchLevelScore = 0.7;
matchLevelScore = 0.8;
similarityScore = standardAddressScore * SIMILARITY_RATE;
} else if(keywordScore > 0 && streetScore > 0){
matchLevelScore = 0.7;
similarityScore = Math.max(streetScore, keywordScore * 0.8) * SIMILARITY_RATE;
} else if (keywordScore > 0) {
matchLevelScore = 0.6;
similarityScore = keywordScore * SIMILARITY_RATE;
} else if (fuzzyKeywordsScore > 0) {
matchLevelScore = 0.5;
if(address.hasCoordinate() && metaData.getLng() != null && GeoUtils.calculateDistance(address.getLng(), address.getLat(),
metaData.getLng(), metaData.getLat()) < 100){
matchLevelScore = 0.7;
}else{
matchLevelScore = 0.4;
}
similarityScore = fuzzyKeywordsScore * SIMILARITY_RATE;
}else if(metaData.getId().equals(address.getPolygonSeaweedId())){
matchLevelScore = 0.4;
similarityScore = 0.05;
}
if (similarityScore > 0) {
if(metaData.getBuildingType() != null){
if ("shop".equals(metaData.getBuildingType().toString())) {
@@ -942,10 +953,6 @@ public class AddressParserServiceImpl implements AddressParserService {
* similarityScore = 相似度部分(0.07) + 类型部分(0.01) < 0.1
* */
double score = matchLevelScore + similarityScore;
if(address.hasCoordinate() && metaData.hasCoordinate()
&& GeoUtils.calculateDistance(address.getLng(), address.getLat(), metaData.getLng(), metaData.getLat()) > 3 * 1000){
score = 0d;
}
return score;
}
@@ -980,7 +987,7 @@ public class AddressParserServiceImpl implements AddressParserService {
return false;
}
if(StringUtils.isBlank(address.getDistrict()) && StringUtils.isBlank(address.getSuggestDistrict())){
return false;
return true;
}
String district = metaData.getDistrict();
return district.equals(address.getDistrict()) || district.equals(address.getSuggestDistrict());
@@ -61,6 +61,8 @@ public class Address {
private String suggestDistrict;
private String suggestName;
private String suggestNamePinYin;
private String polygonSeaweedId;
private String geoRegion;
private List<String> buildingNumbers;
private PreciseLevel preciseLevel;
private boolean pinYin;
@@ -397,6 +399,7 @@ public class Address {
}
public void setOrgAddress(String orgAddress) {
orgAddress = orgAddress.toUpperCase();
setAddress(orgAddress);
if(this.orgAddress != null){
throw new UnsupportedOperationException("原始地址不能被修改");
@@ -749,6 +752,14 @@ public class Address {
return false;
}
public String getGeoRegion() {
return geoRegion;
}
public void setGeoRegion(String geoRegion) {
this.geoRegion = geoRegion;
}
@Override
public String toString() {
return "Address{" +
@@ -808,6 +819,14 @@ public class Address {
'}';
}
public String getPolygonSeaweedId() {
return polygonSeaweedId;
}
public void setPolygonSeaweedId(String polygonSeaweedId) {
this.polygonSeaweedId = polygonSeaweedId;
}
public String toMd5Hex(){
String keyProperties = "Address{" +
"city='" + city + '\'' +
@@ -20,18 +20,16 @@ public class AddressProcessors{
static {
//修改顺序需要调整process i 的值
addressProcessors.add(new TokenProcessor());
addressProcessors.add(new ProximalCharactersProcessor());
addressProcessors.add(new PreNoiseProcessor());
addressProcessors.add(new AddressFormatProcessor());
addressProcessors.add(new TokenProcessor());
addressProcessors.add(new FloorProcessor());
addressProcessors.add(new TooltipProcessor());
addressProcessors.add(new ProvinceProcessor());
addressProcessors.add(new CityProcessor());
addressProcessors.add(new DistrictProcessor());
addressProcessors.add(new LoopLineProcessor());
addressProcessors.add(new TownshipProcessor());
addressProcessors.add(new LoopLineProcessor());
addressProcessors.add(new StageAndPartitionProcessor());
addressProcessors.add(new DirectionProcessor());
addressProcessors.add(new OffsetProcessor());
@@ -44,7 +42,7 @@ public class AddressProcessors{
addressProcessors.add(new NumericProcessor());
addressProcessors.add(new ProvinceAdjustProcessor());
addressProcessors.add(new FormatProcessor());
// addressProcessors.add(new GeoProcessor());
addressProcessors.add(new GeoProcessor());
}
@@ -52,8 +52,9 @@ public class CityProcessor extends AbstractAddressProcessor {
}
if(StringUtils.isNotBlank(city) && CityStatus.SURE != address.getCityStatus() ){
String formatCity = RegionData.formatCity(city);
String possibleCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) ? parseCityFromAddress(orgAddress, address) : null;
String confirmCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) ? null : formatCity;
address.setCity(formatCity);
String possibleCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) || address.getAddressParserGoal() == null ? parseCityFromAddress(orgAddress, address) : null;
String confirmCity = AddressParserGoal.Match.equals(address.getAddressParserGoal()) || address.getAddressParserGoal() == null? null : formatCity;
/**如果省份和城市信息相互矛盾 则用区域推断城市*/
if(StringUtils.isNotBlank(address.getProvince()) && !ProvinceData.belongTo(formatCity, address.getProvince())){
List<String> possibleCities = speculateCityNameByRegion(address, city);
@@ -191,15 +192,12 @@ public class CityProcessor extends AbstractAddressProcessor {
}else{
weight.score += 2;
}
}else if(address.contains(city)){
index = address.indexOf(city);
weight.index = index;
index += city.length();
if(province != null && (orgAddress.contains(province + city) || orgAddress.contains(ProvinceData.getDisplay(province) + city))){
weight.score += 2;
}else{
weight.score += 1;
}
}
Map<String, List<String>> regionMap = RegionData.getAllRegions(city);
@@ -208,9 +206,11 @@ public class CityProcessor extends AbstractAddressProcessor {
if(matchResult !=null){
address = address.replace(matchResult.matchContent, "");
}
if(address.indexOf(region, index) > -1){
if(address.indexOf(region + "区", index) > -1 || address.indexOf(region + "县", index) > -1){
if(province != null && (orgAddress.contains(province + region) || orgAddress.contains(ProvinceData.getDisplay(province) + region))){
weight.score += 2;
}else if(city.equals(addr.getCity())){
weight.score += 10;
}else{
weight.score += 1;
}
@@ -221,9 +221,13 @@ public class CityProcessor extends AbstractAddressProcessor {
List<String> alias = regionMap.get(region);
if(alias != null){
for(String alia : alias){
if(StringUtils.isNotBlank(alia) && !alia.equals(region) && address.indexOf(alia, index) > -1
if(StringUtils.isNotBlank(alia) && !alia.equals(region) && alia.length() > 2 && address.indexOf(alia, index) > -1
&& (alia.endsWith("市")|(alia.endsWith("县")))){
weight.score += 1;
if(city.equals(addr.getCity())){
weight.score += 10;
}else{
weight.score += 1;
}
weight.index = address.indexOf(alia, index);
break;
}
@@ -237,16 +241,6 @@ public class CityProcessor extends AbstractAddressProcessor {
}
List<FragmentWeight> weights = new ArrayList<FragmentWeight>(weightMap.values());
if(weights.size() > 0){
/*String street = getStreet(address);
if(street != null){
Iterator<FragmentWeight> iterator = weights.iterator();
while(iterator.hasNext()){
FragmentWeight fragmentWeight = iterator.next();
if(match(street, ".*" + fragmentWeight.text + "[东南西北中一二三四五六七八九十百千\\d]?(路|街|大道|支路|村)")){
iterator.remove();
}
}
}*/
Collections.sort(weights);
}
if(weights.size() > 0){
@@ -167,6 +167,9 @@ public class DistrictProcessor extends AbstractAddressProcessor {
address.setDevelopmentZone(dz);
}
}
if(address.getSuggestDistrict() != null && address.getDistrict() == null){
address.setDistrict(address.getSuggestDistrict());
}
address.setAddress(orgAddress);
address.setEffectiveAddress(address.getAddress());
return RepeatStatus.NEXT;
@@ -5,8 +5,12 @@ import com.fangjia.core.util.HttpRequest;
import com.fangjia.service.address.mode.Address;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import java.util.*;
import org.apache.log4j.Logger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 地址经纬度处理器
@@ -16,78 +20,69 @@ import java.util.*;
public class GeoProcessor extends AbstractAddressProcessor {
private static final String KEY = "4ccfe3c898a9489884bd2bcb1ef6dcde";
List<String> POI_LEVELS = Arrays.asList("村庄", "热点商圈", "兴趣点", "门牌号", "单元号", "道路交叉路口");
List<String> DISTRICT_LEVEL = Arrays.asList("区县", "开发区", "乡镇", "村庄", "热点商圈", "兴趣点", "门牌号", "单元号", "道路交叉路口");
private static final Logger logger = Logger.getLogger(GeoProcessor.class);
List<String> POI_LEVELS = Arrays.asList("村庄", "热点商圈", "兴趣点", "门牌号", "单元号", "道路交叉路口", "门牌号");
@Override
public RepeatStatus process(Address address) {
if (address.hasCoordinate()) {
return RepeatStatus.NEXT;
}
List<String> queryTypes = new ArrayList<String>();
List<String> addressList = new ArrayList<String>();
if (address.isStandardAddress()) {
addressList.add(address.getStandardAddress());
queryTypes.add("StandardAddress");
}
if (StringUtils.isNotBlank(address.getOrgKeywords())) {
addressList.add(address.getOrgKeywords());
queryTypes.add("Keywords");
String addr = address.getEffectiveAddress();
if(addr == null || addr.length() < 3){
addr = address.getOrgAddress();
}
HttpRequest request = new HttpRequest();
Map<String, String> params = new HashMap<String, String>();
params.put("address", StringUtils.join(addressList, "|"));
params.put("address", addr);
params.put("key", KEY);
params.put("city", address.getCity());
params.put("batch", "true");
params.put("output", "json");
try {
JSONObject response = request.getJsonContent("https://restapi.amap.com/v3/geocode/geo", params, "UTF-8");
logger.info("高德API:" + response.toString());
if (response.getInt("status") == 1) {
JSONArray geocodes = response.getJSONArray("geocodes");
if(queryTypes.contains("StandardAddress")){
JSONObject geocode = geocodes.getJSONObject(queryTypes.indexOf("StandardAddress"));
String level = geocode.getString("level");
if(DISTRICT_LEVEL.contains(level)){
if(StringUtils.isBlank(address.getDistrict())){
address.setDistrict(RegionData.formatRegion(address.getCity(), geocode.getString("district")));
if(geocodes.size() > 0){
JSONObject json = geocodes.getJSONObject(0);
if(json.get("district") instanceof String){
String city = address.getCity();
if(city == null){
city = RegionData.formatCity(json.getString("city"));
}
String region = RegionData.formatRegion(city, json.getString("district"));
address.setGeoRegion(region);
}
if(geocode.containsKey("street") && geocode.containsKey("number")){
String geocodeAddress = geocode.getString("street") + geocode.getString("number");
if(address.getStandardAddress().contains(geocodeAddress)){
String location = geocode.getString("location");
address.setLng(Double.parseDouble(location.split(",")[0]));
address.setLat(Double.parseDouble(location.split(",")[1]));
}
}
}
if(queryTypes.contains("Keywords")){
JSONObject geocode = geocodes.getJSONObject(queryTypes.indexOf("Keywords"));
String level = geocode.getString("level");
if(DISTRICT_LEVEL.contains(level)){
if(StringUtils.isBlank(address.getDistrict())){
address.setDistrict(RegionData.formatRegion(address.getCity(), geocode.getString("district")));
}
}
if(POI_LEVELS.contains(level)){
String formattedAddress = geocode.getString("formatted_address");
formattedAddress = formattedAddress
.replaceFirst(geocode.getString("province"), "")
.replaceFirst(geocode.getString("city"), "")
.replaceFirst(geocode.getString("district"), "");
if(formattedAddress.equals(address.getOrgKeywords())){
String location = geocode.getString("location");
address.setLng(Double.parseDouble(location.split(",")[0]));
address.setLat(Double.parseDouble(location.split(",")[1]));
if(POI_LEVELS.contains(json.getString("level"))){
//对于门牌号级别的POI,formatted_address中包含|代表是推测出来的路号,重庆市巴南区凤林路|808号,|号楼
if("门牌号".equals(json.getString("level"))){
if(!(json.get("number") instanceof JSONArray) && json.getString("formatted_address").contains("|" + json.getString("number"))){
return RepeatStatus.NEXT;
}
}
String location = json.getString("location");
address.setLng(Double.valueOf(location.split(",")[0]));
address.setLat(Double.valueOf(location.split(",")[1]));
String tmp = "{ \"_source\": [\"seaweed_id\"], \"query\": {\"geo_shape\": {\"shape\": {\"shape\": {\"type\": \"Point\",\"coordinates\":[location]},\"relation\": \"CONTAINS\"}}}}";
tmp = tmp.replace("location", location);
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization","Basic ZGV2ZWxvcGVyOjVlOGVkZDg1MWQyZmRmYmQ3NDE1MjMyYzY3MzY3Y2Mz");
JSONObject resp = JSONObject.fromObject(request.postWithBody("http://192.168.0.206:9200/seaweed_polygon/_search", JSONObject.fromObject(tmp),headers,"UTF-8"));
if(resp.containsKey("hits") && resp.getJSONObject("hits").containsKey("hits")){
JSONArray hits = resp.getJSONObject("hits").getJSONArray("hits");
if(hits.size() > 0){
String seaweedId = hits.getJSONObject(0).getJSONObject("_source").getString("seaweed_id");
address.setPolygonSeaweedId(seaweedId);
}
}
}
}
}
} catch (Exception e) {
logger.error(e);
e.printStackTrace();
}
return RepeatStatus.NEXT;
}
@@ -22,7 +22,7 @@ public class KeywordProcessor extends AbstractAddressProcessor {
static final List<Pattern> KEYWORDS_PATTERNS = Arrays.asList(Pattern.compile(".*[^一二三四五六七八九十\\d]{3,}号"));
static final List<String> KEYWORDS = Arrays.asList("居委会", "辖区", "街道办", "街道", "办事处", "村委", "管理区");
static final List<Pattern> NOISE_PATTERNS = Arrays.asList(Pattern.compile("^.*\\d+队"), Pattern.compile("^\\d+号院$"));
static final List<Pattern> INVALID_KEYWORD_PATTERN = Arrays.asList(Pattern.compile("^[一二三四五六七八九十甲乙丙丁戊己庚辛A-Z\\d]+[区期]$"), Pattern.compile("碧桂园"), Pattern.compile("住宅楼"), Pattern.compile("家属院"));
static final List<Pattern> INVALID_KEYWORD_PATTERN = Arrays.asList(Pattern.compile("^[一二三四五六七八九十甲乙丙丁戊己庚辛A-Z\\d]+[区期]$"), Pattern.compile("碧桂园"), Pattern.compile("住宅楼"), Pattern.compile("家属[区院]"), Pattern.compile("宿舍"), Pattern.compile("生活区"), Pattern.compile("公寓"));
static final Pattern INVALID_PATTERN = Pattern.compile("^([-\\\\、])+$");
@@ -23,11 +23,17 @@ public class StageAndPartitionProcessor extends AbstractAddressProcessor {
addr = addr.replaceAll(matchResult.matchContent, formatStage);
address.setAddress(addr);
}
address.setStage(matchResult.matchContent);
address.setStage(formatStage);
}
matchResult = matchFirst(AddressParserPatterns.PARTITION_PATTERN, orgAddr);
if (matchResult != null) {
address.setPartition(matchResult.matchContent);
String formatPartition = CNNMFilter.convertArabicToCnNumeric(matchResult.matchContent);
if(!formatPartition.equals(matchResult.matchContent)){
String addr = address.getAddress();
addr = addr.replaceAll(matchResult.matchContent, formatPartition);
address.setAddress(addr);
}
address.setStage(formatPartition);
}
return RepeatStatus.NEXT;
}
@@ -42,12 +42,10 @@ public class TooltipProcessor extends AbstractAddressProcessor {
if(matchFirst(AddressParserPatterns.STREET, tooltip) != null){
address.setTooltip(tooltip);
address.setStreet(getStreet(tooltip));
} else if(containsDistrictName(tooltip)){
address.setTooltip(tooltip);
} else if(RegionData.isRegion(address.getCity(), tooltip)){
}else if(RegionData.isRegion(address.getCity(), tooltip)){
address.setSuggestDistrict(tooltip);
}else{
address.addNosie(tooltip);
address.setTooltip(tooltip);
}
}
}
@@ -15,15 +15,6 @@ public class VillageNameProcessor extends AbstractAddressProcessor {
@Override
public AbstractAddressProcessor.RepeatStatus process(Address address) {
String orgAddress = address.getAddress();
if(address.getTokens()!=null){
for(Token token:address.getTokens()){
if("district".equals(token.getKeywordTypes())){
address.setKeywords(token.getName());
address.setAddress(orgAddress.replace(token.getName(),""));
return RepeatStatus.NEXT;
}
}
}
List<String> names = tokenDistrictNames(orgAddress);
List<String> kws = new ArrayList<String>();
for(String name : names){
@@ -1,24 +1,16 @@
package com.fangjia.service.cnAnalyzer;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fangjia.core.util.DataUtil;
import com.goojia.solr.ganalytics.IKSegmentation;
import com.goojia.solr.ganalytics.Lexeme;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.util.*;
/**
* 房价网分词器
@@ -0,0 +1,11 @@
package com.fangjia.service.datastore;
import com.fangjia.dal.mongo.model.BsEvaluation;
import java.util.Date;
import java.util.List;
public interface BsEvaluationService {
List<BsEvaluation> getNearlySameEvaluation(String id, Integer minPrice, Integer maxPrice, Date startDate, Date endDate, Integer limit);
}
@@ -0,0 +1,44 @@
package com.fangjia.service.datastore;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.SortParam;
import com.fangjia.dal.mongo.dao.BsEvaluationDao;
import com.fangjia.dal.mongo.dao.EvaluationDao;
import com.fangjia.dal.mongo.model.BsEvaluation;
import com.fangjia.dal.mongo.model.bkoff.DealPrice;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class BsEvaluationServiceImpl implements BsEvaluationService {
private BsEvaluationDao bsEvaluationDao;
public void setBsEvaluationDao(BsEvaluationDao bsEvaluationDao) {
this.bsEvaluationDao = bsEvaluationDao;
}
@Override
public List<BsEvaluation> getNearlySameEvaluation(String id, Integer minPrice, Integer maxPrice, Date startDate, Date endDate, Integer limit) {
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("commid", id));
if(startDate!=null){
params.add(new QueryParam("cDate", QueryParam.GREATER_THAN_EQUAL_OPERATOR, startDate));
}
if(endDate!=null){
params.add(new QueryParam("cDate", QueryParam.LESS_THAN_EQUAL_OPERATOR, startDate));
}
if (minPrice > 0) {
params.add(new QueryParam("unitPrice", QueryParam.GREATER_THAN_OPERATOR, minPrice));
}
if (maxPrice > 0) {
params.add(new QueryParam("unitPrice", QueryParam.LESS_THAN_OPERATOR, maxPrice));
}
List<SortParam> sortParams = new ArrayList<SortParam>();
sortParams.add(new SortParam("cDate", false));
List<BsEvaluation> bsEvaluations = bsEvaluationDao.findAllByParams(params, sortParams, limit);
return bsEvaluations;
}
}
@@ -2014,7 +2014,13 @@ public class DistrictServiceImpl implements DistrictService {
params.add(new QueryParam("city", ClientUtils.escapeQueryChars(city)));
}
if (StringUtils.isNotBlank(region)) {
params.add(new QueryParam("region", ClientUtils.escapeQueryChars(RegionData.formatRegion(city, region))));
city = ClientUtils.escapeQueryChars(city);
String newRegion = RegionData.formatRegion(city, region);
if(StringUtils.isNotBlank(newRegion)){
params.add(new QueryParam("region", ClientUtils.escapeQueryChars(newRegion)));
}else{
params.add(new QueryParam("region", region));
}
}
if (StringUtils.isNotBlank(target)) {
params.add(new QueryParam("category", target));
@@ -240,7 +240,7 @@ public class AddressRepoServiceImpl implements AddressRepoService {
}
private boolean isAvailablePoi(AddressMatchMetaData data){
if(data.getType() != null && data.getType().contains("·")){
if(data.getType() != null && (data.getType().contains("·") || data.getType().contains("½ÖµÀ"))){
return false;
}
return true;
@@ -94,4 +94,6 @@ public interface HouseLoudongService {
public List<HouseLoudong> findAll(List<QueryParam> queryParams, Pager pager);
List<String> findAllSources();
public List<HouseLoudong> findAll(String id, String houseNum, String unitNum, String roomNum);
}
@@ -297,6 +297,22 @@ public class HouseLoudongServiceImpl implements HouseLoudongService {
return froms;
}
@Override
public List<HouseLoudong> findAll(String id, String houseNum, String unitNum, String roomNum) {
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("districtId", id));
if (StringUtils.isNotBlank(houseNum)) {
params.add(new QueryParam("houseNum", houseNum));
}
if (StringUtils.isNotBlank(unitNum)) {
params.add(new QueryParam("houseNumUnit", unitNum));
}
if (StringUtils.isNotBlank(roomNum)) {
params.add(new QueryParam("roomNum", roomNum));
}
return houseLoudongBkoffDao.findAllByParams(params);
}
@Override
public List<HouseLoudong> queryHouseLoudongList(String city, String districtName, String roomNum, Pager pager) {
List<QueryParam> params = new ArrayList<QueryParam>();
@@ -23,6 +23,8 @@ public interface LoudongService {
List<Loudong> findAll(String city, String region, String name, String houseNumber, String unitNumber, int limit);
List<Loudong> findAll(String id, String houseNumber, String unitNumber);
Map<String, XSSFWorkbook> findAll(List<QueryParam> query, String city);
Loudong findById(String id);
@@ -41,4 +43,6 @@ public interface LoudongService {
void save(Map<String, Object> data);
List<String> findAllSources();
Loudong findForEvaluate(String idInSeaweed, String houseNumber, String unitNumber);
}
@@ -148,6 +148,23 @@ public class LoudongServiceImpl implements LoudongService {
return loudongDao.findAllByParams(params,null, 0 , limit, ADDRESS_VERIFY_FIELDS);
}
@Override
public List<Loudong> findAll(String id, String houseNumber, String unitNumber) {
List<QueryParam> params = new ArrayList<QueryParam>();
if(StringUtils.isNotBlank(id)) {
params.add(new QueryParam("idInSeaweed", id));
}
if(StringUtils.isNotBlank(houseNumber)) {
params.add(new QueryParam("houseNumber", houseNumber));
}
if(StringUtils.isNotBlank(unitNumber)) {
params.add(new QueryParam("unitNumber", unitNumber));
}
return loudongDao.findAllByParams(params);
}
@Override
public Loudong findById(String id) {
return loudongDao.findById(id);
@@ -318,4 +335,23 @@ public class LoudongServiceImpl implements LoudongService {
}
return froms;
}
@Override
public Loudong findForEvaluate(String idInSeaweed, String houseNumber, String unitNumber){
if(StringUtils.isBlank(idInSeaweed) || StringUtils.isBlank(houseNumber)){
return null;
}
List<QueryParam> params = Lists.newArrayList();
params.add(new QueryParam("idInSeaweed", idInSeaweed));
params.add(new QueryParam("houseNumber", houseNumber));
if(StringUtils.isNotBlank(unitNumber)) {
params.add(new QueryParam("unitNumber", unitNumber));
}
params.add(new QueryParam("floors", QueryParam.GREATER_THAN_OPERATOR, 0));
params.add(new QueryParam("floors", QueryParam.LESS_THAN_OPERATOR, 60));
params.add(new QueryParam("status", QueryParam.NOT_EQUAL_OPERATOR, 0));
List<SortParam> sortParams = ImmutableList.of(new SortParam("floors", false));
return loudongDao.findFirstByParams(params, sortParams);
}
}
@@ -82,6 +82,8 @@ public interface DealPriceService {
public List<DealPrice> getNearlySameDealPrice(DistrictKey key, int minPrice, int maxPrice, int radius, int limit);
public List<DealPrice> getNearlySameDealPrice(String districtId, Integer minPrice, Integer maxPrice,Date startDate, Date endDate, int limit);
public List<DealPrice> getDisSameDealPrice(DistrictKey key, int minPrice, int maxPrice, int limit);
/**
@@ -354,6 +354,29 @@ public class DealPriceServiceImpl implements DealPriceService {
return houses;
}
@Override
public List<DealPrice> getNearlySameDealPrice(String districtId, Integer minPrice, Integer maxPrice, Date startDate, Date endDate, int limit) {
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("matchId", districtId));
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, startDate));
}
if (minPrice > 0) {
params.add(new QueryParam("avgPrice", QueryParam.GREATER_THAN_OPERATOR, minPrice));
}
if (maxPrice > 0) {
params.add(new QueryParam("avgPrice", QueryParam.LESS_THAN_OPERATOR, maxPrice));
}
List<SortParam> sortParams = new ArrayList<SortParam>();
sortParams.add(new SortParam("tradeDate", false));
List<DealPrice> dealPrices = dealPriceDao.findAllByParams(params, sortParams, limit);
return dealPrices;
}
@Override
public List<DealPrice> getDisSameDealPrice(DistrictKey key, int minPrice, int maxPrice, int limit) {
List<QueryParam> params = new ArrayList<QueryParam>();
@@ -0,0 +1,9 @@
package com.fangjia.service.open;
import com.fangjia.dal.mongo.open.model.CommunityBasePrice;
import com.fangjia.dal.mongo.open.model.CommunityPoi;
public interface CommunityBasePriceService {
CommunityBasePrice getById(String id);
}
@@ -0,0 +1,8 @@
package com.fangjia.service.open;
import com.fangjia.dal.mongo.open.model.CommunityPoi;
public interface CommunityPoiService {
CommunityPoi getById(String id);
}
@@ -0,0 +1,22 @@
package com.fangjia.service.open.impl;
import com.fangjia.dal.mongo.open.dao.CommunityBasePriceDao;
import com.fangjia.dal.mongo.open.dao.CommunityPoiDao;
import com.fangjia.dal.mongo.open.model.CommunityBasePrice;
import com.fangjia.dal.mongo.open.model.CommunityPoi;
import com.fangjia.service.open.CommunityBasePriceService;
import com.fangjia.service.open.CommunityPoiService;
public class CommunityBasePriceServiceImpl implements CommunityBasePriceService {
private CommunityBasePriceDao communityBasePriceDao;
@Override
public CommunityBasePrice getById(String id) {
return communityBasePriceDao.findById(id);
}
public void setCommunityBasePriceDao(CommunityBasePriceDao communityBasePriceDao) {
this.communityBasePriceDao = communityBasePriceDao;
}
}
@@ -0,0 +1,19 @@
package com.fangjia.service.open.impl;
import com.fangjia.dal.mongo.open.dao.CommunityPoiDao;
import com.fangjia.dal.mongo.open.model.CommunityPoi;
import com.fangjia.service.open.CommunityPoiService;
public class CommunityPoiServiceImpl implements CommunityPoiService {
private CommunityPoiDao communityPoiDao;
@Override
public CommunityPoi getById(String id) {
return communityPoiDao.findById(id);
}
public void setCommunityPoiDao(CommunityPoiDao communityPoiDao) {
this.communityPoiDao = communityPoiDao;
}
}
@@ -1,5 +1,7 @@
package com.fangjia.service.util;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -29,6 +31,29 @@ public class CookieUtils {
}
public static boolean removeCookie(HttpServletRequest request, HttpServletResponse response, String name) {
if(request.getCookies() == null){
return false;
}
if (StringUtils.isBlank(name)) {
return false;
}
Cookie[] cookies = request.getCookies();
if (null != cookies) {
for (Cookie cookie : cookies) {
if (name.equals(cookie.getName())) {
cookie.setValue(null);
cookie.setMaxAge(0);
cookie.setPath("/");
response.addCookie(cookie);
return true;
}
}
}
return false;
}
public static void setCookie(String name, String value, String path,int maxAge, HttpServletResponse response){
Cookie cookie = new Cookie(name, value);
if(path != null){