北交所接口合并

This commit is contained in:
mjt
2023-12-19 10:51:18 +08:00
parent 316297aeb6
commit c4eebbfe36
24 changed files with 4581 additions and 458 deletions
+1 -1
View File
@@ -18,6 +18,6 @@
<finalName>goojia-auto</finalName>
</build>
<modules>
<module>../../projects/goojia-auto</module>
<!-- <module>../../projects/goojia-auto</module>-->
</modules>
</project>
@@ -22,16 +22,16 @@ public class AaController {
private AddressModeParserChain addressModeParserChain;
public Object pickAction() throws Exception {
File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730.txt");
File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730_picker.txt");
File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730.txt");
File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730_picker.txt");
if (file2.exists()) {
file2.delete();
}
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 指定编码格式,以免读取时中文字符异常
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 指定编码格式,以免读取时中文字符异常
// 全部写入缓存中的内容
// 全部写入缓存中的内容
InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 考虑到编码格式
InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
@@ -42,7 +42,7 @@ public class AaController {
List<Token> tokens = CnAddressTokenizer.tokenizer(lineTxt);
addressPickerChain.doPick(tokens, ret);
// parserChain.doParse("上海", lineTxt, ret);
// parserChain.doParse("上海", lineTxt, ret);
ret.remove(AddressAnalyseResultKeyEnum.orgAddress.name());
// ret.remove(AddressAnalyseResultKeyEnum.shortAddress.name());
@@ -64,16 +64,16 @@ public class AaController {
}
public Object parseAction() throws Exception {
File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730.txt");
File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730_parser.txt");
File file = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730.txt");
File file2 = new File("C:\\Users\\yk\\Desktop\\yongjia\\test\\上海-0730_parser.txt");
if (file2.exists()) {
file2.delete();
}
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 指定编码格式,以免读取时中文字符异常
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file2, true), "GBK")); // 指定编码格式,以免读取时中文字符异常
// 全部写入缓存中的内容
// 全部写入缓存中的内容
InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 考虑到编码格式
InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8");// 考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
@@ -81,7 +81,7 @@ public class AaController {
ret.put(AddressAnalyseResultKeyEnum.orgAddress.name(), lineTxt);
System.out.println(lineTxt);
addressModeParserChain.doParse("上海", lineTxt, ret);
addressModeParserChain.doParse("上海", lineTxt, ret);
ret.remove(AddressAnalyseResultKeyEnum.orgAddress.name());
ret.remove(AddressAnalyseResultKeyEnum.shortAddress.name());
@@ -903,7 +903,10 @@ public class HouseController {
if(null == sampleQuery.getMax()){
sampleQuery.setMax(10);
}
long start = System.currentTimeMillis();
List<Collateral> collaterals = czbankSampleService.findSample2(querys, sampleQuery.getMax());
long end = System.currentTimeMillis();
System.out.println("用时:"+(end-start));
Collateral collateral = collaterals.get(0);
List<Sample> samples = collateral.getSample();
UniversalDto dto = UniversalDto.newDto();
@@ -913,7 +916,8 @@ public class HouseController {
if(null != collateral.getMinPrice()){
dto.append("minUnitPrice", collateral.getMinPrice());
}
dto.append("datas", samples);
dto.append("datas", samples);
// if(samples!= null && samples.size()>=2){
// Sample minSample = samples.get(samples.size()-2);
// Sample maxSample = samples.get(samples.size()-1);
@@ -7,7 +7,8 @@ import com.fangjia.dal.mongo.model.CityNewPrice;
import com.fangjia.dal.mongo.model.RegionSellStat;
@SuppressWarnings("serial")
public class CityNewPriceDto implements Serializable{
public class
CityNewPriceDto implements Serializable{
/**
*
@@ -0,0 +1,57 @@
package com.fangjia.open.dto;
import com.fangjia.dal.mongo.model.DistrictFacilitys;
import com.fangjia.open.dto.addressGovernance.MatchedBuildingDto;
import com.fangjia.open.model.RestfulModelAndView;
import java.util.Map;
/**
* @author 13607
* @since 2023/12/12 10:47
*/
public class HouseValueInformationDto {
// 原小区均价返回值
private MatchedBuildingDto communityAvgPrice;
// 原房屋价值评估返回值
private Map<String, Object> addressValue;
//原房源样本返回值
private UniversalDto houseCase;
//原周边POI返回值
private DistrictFacilitys surroundingPoi;
public MatchedBuildingDto getCommunityAvgPrice() {
return communityAvgPrice;
}
public void setCommunityAvgPrice(MatchedBuildingDto communityAvgPrice) {
this.communityAvgPrice = communityAvgPrice;
}
public Map<String, Object> getAddressValue() {
return addressValue;
}
public void setAddressValue(Map<String, Object> addressValue) {
this.addressValue = addressValue;
}
public UniversalDto getHouseCase() {
return houseCase;
}
public void setHouseCase(UniversalDto houseCase) {
this.houseCase = houseCase;
}
public DistrictFacilitys getSurroundingPoi() {
return surroundingPoi;
}
public void setSurroundingPoi(DistrictFacilitys surroundingPoi) {
this.surroundingPoi = surroundingPoi;
}
}
@@ -0,0 +1,941 @@
package com.fangjia.open.model;
import java.util.Date;
/**
* @author 13607
* @since 2023/12/12 14:27
*/
public class HouseInfomationModel extends FangjiaApiModel {
private String city;
private String address;
private String category;
private boolean useMap;
/**
* 判断是不是有房估价
*/
private boolean isYouFang;
/**
* 判断是不是友达
*/
private boolean isYouDa;
/**
* 区域
*/
private String region;
/**
* 区域(新版本估价)
**/
private String district;
/**
* 小区名
*/
private String districtName;
/**
* 小区名(新版本)
*/
private String name;
/**
* 楼号
*/
private String unitNumber;
/**
* 新楼号
*/
private String houseNumber;
private String id;
/**
* 室号
*/
private String roomNumber;
/**
* 面积
*/
private double size;
/**
* 所在楼层
*/
private Integer floor;
/**
* 总楼层
*/
private Integer height;
/**
* 室数
*/
private Integer room;
/**
* 厅数
*/
private int hall;
/**
* 卫数
*/
private int toilet;
/**
* 估价时间
*/
private Date calDate;
private String propertyType;
/**
* 建筑类型
*/
private String buildType;
/**
* 朝向
*/
private String direction;
/**
* 装修情况
*/
private String fitment;
/**
* 装修价格
*/
private int fitmentCharge;
/**
* 景观情况
*/
private String view;
/**
* 噪音情况
*/
private String noise;
/**
* 花园面积
*/
private Double gardenArea;
/**
* 地下室面积
*/
private Double basementArea;
/**
* 厌恶因素
*/
private String[] worryFactor;
/**
* 房龄
*/
private int age;
/**
* 自有车位
*/
private String carport;
/**
* 小区配套
*/
private String facilities;
/**
* 小区位置
*/
private String insidepos;
/**
* 装修年限
*/
private int fitmentAge;
/**
* 采光通风
*/
private String lightingVentilation;
/**
* 边套装置
*/
private String sideset;
/**
* 建筑质量
*/
private String[] buildQuality;
/**
* 厌恶设施
*/
private String worryFacility;
/**
* 产权属性
*/
private String houseProperty;
/**
* 其他因素
*/
private String otherFactor;
/**
* 门面开间
*/
private String facade;
/**
* 公共交通
*/
private String traffice;
/**
* 形状
*/
private String shape;
/**
* 障碍物
*/
private String obstacle;
/**
* 经营性质
*/
private String industry;
/**
* 配套设备
*/
private String supportDevice;
/**
* 距离扶梯位置
*/
private String leftPosition;
/**
* 商铺类型
*/
private String shopType;
/**
* 商铺唯一性
*/
private String shopUnique;
/**
* 商铺位置
*/
private String location;
private String kind;
private boolean isNewDistrict;
private Integer carportPrice;
private String keyword;
private String buildingNumber;
private Integer maxFloor;
private String decoration;
private Integer decorationCost;
private Double gardenSize;
private Double basementSize;
private Double outerSize;
private Double atticSize;
private String negativeFactor;
private String insidePosition;
private int decorationAge;
private boolean convert;
private String estateType;
private String periodType;
private Integer periodCount;
private Integer houseType;
private String clientNo;
private int scope;
private Integer maxPrice;
private Integer minPrice;
private Integer radius;
private Integer limit;
private String app;
private String user;
private Integer avgPrice;
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public boolean isUseMap() {
return useMap;
}
public void setUseMap(boolean useMap) {
this.useMap = useMap;
}
public boolean isYouFang() {
return isYouFang;
}
public void setYouFang(boolean youFang) {
isYouFang = youFang;
}
public boolean isYouDa() {
return isYouDa;
}
public void setYouDa(boolean youDa) {
isYouDa = youDa;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getDistrictName() {
return districtName;
}
public void setDistrictName(String districtName) {
this.districtName = districtName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUnitNumber() {
return unitNumber;
}
public void setUnitNumber(String unitNumber) {
this.unitNumber = unitNumber;
}
public String getHouseNumber() {
return houseNumber;
}
public void setHouseNumber(String houseNumber) {
this.houseNumber = houseNumber;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRoomNumber() {
return roomNumber;
}
public void setRoomNumber(String roomNumber) {
this.roomNumber = roomNumber;
}
public double getSize() {
return size;
}
public void setSize(double size) {
this.size = size;
}
public Integer getFloor() {
return floor;
}
public void setFloor(Integer floor) {
this.floor = floor;
}
public Integer getHeight() {
return height;
}
public void setHeight(Integer height) {
this.height = height;
}
public Integer getRoom() {
return room;
}
public void setRoom(Integer room) {
this.room = room;
}
public int getHall() {
return hall;
}
public void setHall(int hall) {
this.hall = hall;
}
public int getToilet() {
return toilet;
}
public void setToilet(int toilet) {
this.toilet = toilet;
}
public Date getCalDate() {
return calDate;
}
public void setCalDate(Date calDate) {
this.calDate = calDate;
}
public String getPropertyType() {
return propertyType;
}
public void setPropertyType(String propertyType) {
this.propertyType = propertyType;
}
public String getBuildType() {
return buildType;
}
public void setBuildType(String buildType) {
this.buildType = buildType;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public String getFitment() {
return fitment;
}
public void setFitment(String fitment) {
this.fitment = fitment;
}
public int getFitmentCharge() {
return fitmentCharge;
}
public void setFitmentCharge(int fitmentCharge) {
this.fitmentCharge = fitmentCharge;
}
public String getView() {
return view;
}
public void setView(String view) {
this.view = view;
}
public String getNoise() {
return noise;
}
public void setNoise(String noise) {
this.noise = noise;
}
public Double getGardenArea() {
return gardenArea;
}
public void setGardenArea(Double gardenArea) {
this.gardenArea = gardenArea;
}
public Double getBasementArea() {
return basementArea;
}
public void setBasementArea(Double basementArea) {
this.basementArea = basementArea;
}
public String[] getWorryFactor() {
return worryFactor;
}
public void setWorryFactor(String[] worryFactor) {
this.worryFactor = worryFactor;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getCarport() {
return carport;
}
public void setCarport(String carport) {
this.carport = carport;
}
public String getFacilities() {
return facilities;
}
public void setFacilities(String facilities) {
this.facilities = facilities;
}
public String getInsidepos() {
return insidepos;
}
public void setInsidepos(String insidepos) {
this.insidepos = insidepos;
}
public int getFitmentAge() {
return fitmentAge;
}
public void setFitmentAge(int fitmentAge) {
this.fitmentAge = fitmentAge;
}
public String getLightingVentilation() {
return lightingVentilation;
}
public void setLightingVentilation(String lightingVentilation) {
this.lightingVentilation = lightingVentilation;
}
public String getSideset() {
return sideset;
}
public void setSideset(String sideset) {
this.sideset = sideset;
}
public String[] getBuildQuality() {
return buildQuality;
}
public void setBuildQuality(String[] buildQuality) {
this.buildQuality = buildQuality;
}
public String getWorryFacility() {
return worryFacility;
}
public void setWorryFacility(String worryFacility) {
this.worryFacility = worryFacility;
}
public String getHouseProperty() {
return houseProperty;
}
public void setHouseProperty(String houseProperty) {
this.houseProperty = houseProperty;
}
public String getOtherFactor() {
return otherFactor;
}
public void setOtherFactor(String otherFactor) {
this.otherFactor = otherFactor;
}
public String getFacade() {
return facade;
}
public void setFacade(String facade) {
this.facade = facade;
}
public String getTraffice() {
return traffice;
}
public void setTraffice(String traffice) {
this.traffice = traffice;
}
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getObstacle() {
return obstacle;
}
public void setObstacle(String obstacle) {
this.obstacle = obstacle;
}
public String getIndustry() {
return industry;
}
public void setIndustry(String industry) {
this.industry = industry;
}
public String getSupportDevice() {
return supportDevice;
}
public void setSupportDevice(String supportDevice) {
this.supportDevice = supportDevice;
}
public String getLeftPosition() {
return leftPosition;
}
public void setLeftPosition(String leftPosition) {
this.leftPosition = leftPosition;
}
public String getShopType() {
return shopType;
}
public void setShopType(String shopType) {
this.shopType = shopType;
}
public String getShopUnique() {
return shopUnique;
}
public void setShopUnique(String shopUnique) {
this.shopUnique = shopUnique;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public boolean isNewDistrict() {
return isNewDistrict;
}
public void setNewDistrict(boolean newDistrict) {
isNewDistrict = newDistrict;
}
public Integer getCarportPrice() {
return carportPrice;
}
public void setCarportPrice(Integer carportPrice) {
this.carportPrice = carportPrice;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getBuildingNumber() {
return buildingNumber;
}
public void setBuildingNumber(String buildingNumber) {
this.buildingNumber = buildingNumber;
}
public Integer getMaxFloor() {
return maxFloor;
}
public void setMaxFloor(Integer maxFloor) {
this.maxFloor = maxFloor;
}
public String getDecoration() {
return decoration;
}
public void setDecoration(String decoration) {
this.decoration = decoration;
}
public Integer getDecorationCost() {
return decorationCost;
}
public void setDecorationCost(Integer decorationCost) {
this.decorationCost = decorationCost;
}
public Double getGardenSize() {
return gardenSize;
}
public void setGardenSize(Double gardenSize) {
this.gardenSize = gardenSize;
}
public Double getBasementSize() {
return basementSize;
}
public void setBasementSize(Double basementSize) {
this.basementSize = basementSize;
}
public Double getOuterSize() {
return outerSize;
}
public void setOuterSize(Double outerSize) {
this.outerSize = outerSize;
}
public Double getAtticSize() {
return atticSize;
}
public void setAtticSize(Double atticSize) {
this.atticSize = atticSize;
}
public String getNegativeFactor() {
return negativeFactor;
}
public void setNegativeFactor(String negativeFactor) {
this.negativeFactor = negativeFactor;
}
public String getInsidePosition() {
return insidePosition;
}
public void setInsidePosition(String insidePosition) {
this.insidePosition = insidePosition;
}
public int getDecorationAge() {
return decorationAge;
}
public void setDecorationAge(int decorationAge) {
this.decorationAge = decorationAge;
}
public boolean isConvert() {
return convert;
}
public void setConvert(boolean convert) {
this.convert = convert;
}
public String getEstateType() {
return estateType;
}
public void setEstateType(String estateType) {
this.estateType = estateType;
}
public String getPeriodType() {
return periodType;
}
public void setPeriodType(String periodType) {
this.periodType = periodType;
}
public Integer getPeriodCount() {
return periodCount;
}
public void setPeriodCount(Integer periodCount) {
this.periodCount = periodCount;
}
public Integer getHouseType() {
return houseType;
}
public void setHouseType(Integer houseType) {
this.houseType = houseType;
}
public String getClientNo() {
return clientNo;
}
public void setClientNo(String clientNo) {
this.clientNo = clientNo;
}
public int getScope() {
return scope;
}
public void setScope(int scope) {
this.scope = scope;
}
public Integer getMaxPrice() {
return maxPrice;
}
public void setMaxPrice(Integer maxPrice) {
this.maxPrice = maxPrice;
}
public Integer getMinPrice() {
return minPrice;
}
public void setMinPrice(Integer minPrice) {
this.minPrice = minPrice;
}
public Integer getRadius() {
return radius;
}
public void setRadius(Integer radius) {
this.radius = radius;
}
public Integer getLimit() {
return limit;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public String getApp() {
return app;
}
public void setApp(String app) {
this.app = app;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public Integer getAvgPrice() {
return avgPrice;
}
public void setAvgPrice(Integer avgPrice) {
this.avgPrice = avgPrice;
}
}
@@ -0,0 +1,71 @@
package com.fangjia.script.majintao
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
import net.sf.json.JSONObject
ExcelUtils.removeEmptyRow("F:\\估家\\文件\\北交所\\testcopy.xlsx")
ExcelUtils.singleThreadingModify("F:\\估家\\文件\\北交所\\testcopy.xlsx", { List items ->
String excelFilePath = "F:\\估家\\文件\\北交所\\testcopy.xlsx";
String comprehensiveUrl = "http://192.168.10.15:9180/comprehensiveQuery/houseValueInformation";
String communityUrl = "http://192.168.10.15:9180/addrSvc/avgPrice";
String valueUrl = "http://192.168.10.15:9180/property/addressEvaluate";
String caseUrl = "http://192.168.10.15:9180/house/case";
String poiUrl = "http://192.168.10.15:9180/district/addrFacilitys";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
String city = items['A']
String address = items['B']
double size = items['C']
System.out.println(city + "---" + address + "----" + size);
map.put("city", city)
map.put("address", address)
map.put("size", size.toString())
map.put("strctureArea", size.toString())
map.put("token", "F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB")
if (!address.contains("%")) {
// 发送HTTP请求
long start
long end
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(communityUrl, map, "UTF-8")
//
//
// end = System.currentTimeMillis();
// items['D'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(valueUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['E'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(caseUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['F'] = String.valueOf(end - start);
//
// start = System.currentTimeMillis();
// httpRequest.getJsonContent(poiUrl, map, "UTF-8")
// end = System.currentTimeMillis();
// items['G'] = String.valueOf(end - start);
start = System.currentTimeMillis();
def content = httpRequest.getJsonContent(comprehensiveUrl, map, "UTF-8")
end = System.currentTimeMillis();
items['H'] = String.valueOf(end - start);
println content.get("msg")
if(content.get("msg").contains("该地址不支持估价!")) {
items['I'] = "该地址不支持估价!"
}
}
})
@@ -443,6 +443,45 @@ public class ExcelUtils{
}
public static singleThreadingModify(String fileName, Closure closure, Integer srcSheetIndex = 0, String destSheetName = null){
if(!destSheetName){
def inp = new FileInputStream(fileName);
Workbook workbook = WorkbookFactory.create(inp)
workbook.setForceFormulaRecalculation(true)
Sheet sheet = workbook.getSheetAt(srcSheetIndex);
destSheetName = sheet.getSheetName();
}
def data = ExcelUtils.read(fileName, srcSheetIndex, 0)
def body = data.subList(1, data.size())
def nThread = Runtime.getRuntime().availableProcessors() * 3
println nThread
ExecutorService executorService = Executors.newFixedThreadPool(3)
final AtomicInteger counter = new AtomicInteger(0)
final double total = body.size()
for(int i = 0 ; i < body.size(); i++){
final row = body[i]
executorService.submit(new Runnable() {
@Override
void run() {
try{
closure.call(row)
int count = counter.incrementAndGet()
if(count % 1000 == 0){
println(DateUtils.formatDateByPattern(new Date(), "yyyy-MM-dd HH:mm:ss")+"执行进度:${com.fangjia.core.util.DataUtil.roundDouble((count * 100)/total, 2)}%")
}
}catch (Exception e){
println(row)
e.printStackTrace()
}
}
})
}
executorService.shutdown()
executorService.awaitTermination(30, TimeUnit.DAYS)
ExcelUtils.write(fileName, data, destSheetName)
}
public static Object getCellValue(Cell cell){
@@ -522,6 +522,7 @@ public interface DistrictService extends ModeService<DistrictKey, DistrictBo> {
public District findOneByKey(DistrictKey districtKey, String cat);
List<District> findNearestDistrict(District district, int radiusMeters, int limit);
List<District> doFindNearestHasHouseDistrict(District district, int radiusMeters, int limit) ;
List<District> findNearestDistrict(District district, int radiusMeters, String[] fields, int limit);
@@ -2297,6 +2297,22 @@ public class DistrictServiceImpl implements DistrictService {
return list;
}
@SuppressWarnings("unchecked")
public List<District> findNearestHasHouseDistrict(District district, int radiusMeters, int limit) {
String cacheKey = district.getCity() + "#" + district.getRegion() + "#" + district.getName() + "#" + radiusMeters + "#_if_sell_1" + limit;
Object obj = CacheUtils.getValue(this.getClass(), cacheKey);
if (obj != null) {
return (List<District>) obj;
}
ArrayList<District> list = new ArrayList<District>();
List<District> nlist = doFindNearestHasHouseDistrict(district, radiusMeters, limit);
if (nlist.size() > 0) {
list = (ArrayList<District>) nlist;
}
CacheUtils.putValue(CachePolicyEnum.LONG, this.getClass(), cacheKey, list);
return list;
}
public List<District> findNearestDistrict(District district, int radiusMeters, String[] fields, int limit) {
String cacheKey = district.getCity() + "#" + district.getRegion() + "#" + district.getName() + "#" + radiusMeters + "#" + limit;
@@ -2437,6 +2453,48 @@ public class DistrictServiceImpl implements DistrictService {
return new ArrayList<District>(ret);
}
public List<District> doFindNearestHasHouseDistrict(District district, int radiusMeters, int limit) {
if (district == null || district.getLat() == null || district.getLng() == null || district.getLat() <= 0
|| district.getLng() <= 0) {
return Collections.EMPTY_LIST;
}
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("category", "district"));
params.add(new QueryParam("city", district.getCity()));
params.add(new QueryParam("visible", 0));
params.add(new QueryParam("ifSell", 1));
SdQuery sdQuery = new SdQuery();
sdQuery.setPoint((double) district.getLat() / 10000000000.0 + "," + (double) district.getLng() / 10000000000.0);
sdQuery.setField("lat_lng");
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" });
if (list.isEmpty()) {
return list;
}
List<District> ret = new ArrayList<District>();
for (District d : list) {
if (district.getName().equals(d.getName()) && district.getRegion().equals(d.getRegion())
&& district.getCity().equals(d.getCity())) {
continue;
}
if (d.getEstateType2() != null) {
if (d.getEstateType2().indexOf(district.getEstateType2()) > -1) {
ret.add(d);
}
}
}
if (ret.size() > limit) {
ret = ret.subList(0, limit);
}
return new ArrayList<District>(ret);
}
public List<District> doFindNearestDistrict(District district, int radiusMeters, String[] fields, int limit) {
if (district == null || district.getLat() == null || district.getLng() == null || district.getLat() <= 0