Merge branch 'dev' into 'master'

把城市(city)设置为非必须

See merge request !785
This commit is contained in:
2024-01-10 10:17:14 +08:00
20 changed files with 488 additions and 18 deletions
@@ -213,21 +213,22 @@ public class ComprehensiveQueryController {
HouseValueInformationDto houseValueInformation = new HouseValueInformationDto();
RestfulModelAndView mav = new RestfulModelAndView();
if (StringUtils.isBlank(model.getAddress()) || StringUtils.isBlank(model.getCity()) || StringUtils.isBlank(String.valueOf(model.getSize()))) {
mav.setModel(BasicModel.buildBadRequestModel("城市(city),地址(address),面积(size)为必填字段"));
if (StringUtils.isBlank(model.getAddress()) || StringUtils.isBlank(String.valueOf(model.getSize()))) {
mav.setModel(BasicModel.buildBadRequestModel("地址(address),面积(size)为必填字段"));
return mav;
}
HttpRequest httpRequest = new HttpRequest();
JSONObject json = null;
Map<String, String> communityAvgPriceParams = new HashMap<String, String>();
communityAvgPriceParams.put("city", model.getCity());
// communityAvgPriceParams.put("city", model.getCity());
communityAvgPriceParams.put("address", model.getAddress());
communityAvgPriceParams.put("category", model.getCategory());
communityAvgPriceParams.put("useMap", String.valueOf(model.isUseMap()));
JSONObject matchResponse = null;
try {
matchResponse = httpRequest.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8");
// matchResponse = httpRequest.getJsonContent("http://192.168.0.19:31080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8");
} catch (HttpRequestException e) {
}
+7 -1
View File
@@ -530,7 +530,13 @@
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.fangjia</groupId>-->
<!-- <artifactId>fangjia-open</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>
</dependencies>
</project>
@@ -32,7 +32,8 @@ public enum Watcher {
BaYi('15300424133','bayi@fangjia.com'),
WeiLei('18101751850','weilei@fangjia.com'),
JiangYaHui('13684913780','jiangyahui@fangjia.com'),
ShenJian('13764369683', 'shenjian@fangjia.com')
ShenJian('13764369683', 'shenjian@fangjia.com'),
MaJinTao('13607600062','majintao@fangjia.com')
private final String mobile;
private final String email;
@@ -0,0 +1,57 @@
import com.fangjia.core.ProvinceData
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
import com.lowagie.text.Row
import javafx.scene.control.Cell
import jxl.Sheet
import jxl.Workbook
import org.apache.poi.ss.usermodel.WorkbookFactory
String excelFilePath = "F:\\估家\\文件\\安徽省联社\\全国省级行政区房屋覆盖情况表 - 副本.xlsx"
ExcelUtils.removeEmptyRow(excelFilePath)
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
province1 = items['A']
if (!province1.equals('黑龙江省') || !province1.equals('内蒙古自治区')) {
province = province1.substring(0, 2)
} else {
province = province1.substring(0, 3)
}
println('province: ' + province)
def citys = ProvinceData.getAllCity(province)
println(citys)
if (citys.size() > 0) {
ExcelUtils.writeToExcel(excelFilePath, citys, province)
}
})
//
//import com.fangjia.core.ProvinceData
//
//import com.fangjia.script.util.ExcelUtils
//
//
//String excelFilePath = "F:\\估家\\文件\\安徽省联社\\全国省级行政区房屋覆盖情况表.xlsx"
//ExcelUtils.removeEmptyRow(excelFilePath)
//ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
//
// def province1 = items['A']
// def province
//
// if (!province1.equals('黑龙江省') && !province1.equals('内蒙古自治区')) {
// province = province1.substring(0, 2)
// } else {
// province = province1.substring(0, 3)
// }
//
// println('province: ' + province)
//
// def citys = ProvinceData.getAllCity(province)
// println(citys)
// items['D'] = citys.toString()
//
//})
@@ -5,14 +5,15 @@ 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";
String excelFilePath = "F:\\估家\\文件\\北交所\\testcopy1.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
String comprehensiveUrl = "http://localhost:9180/comprehensiveQuery/houseValueInformation";
String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
String caseUrl = "http://open.fangjia.com/house/case";
String poiUrl = "http://open.fangjia.com/district/addrFacilitys";
HttpRequest httpRequest = new HttpRequest();
map = new HashMap<String, String>()
@@ -0,0 +1,54 @@
package com.fangjia.script.majintao
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.util.ExcelUtils
import net.sf.json.JSONObject
String excelFilePath = "F:\\估家\\文件\\北交所\\暂时不能估值数据 - 副本.xlsx";
ExcelUtils.removeEmptyRow(excelFilePath)
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
String comprehensiveUrl = "http://open.fangjia.com/comprehensiveQuery/houseValueInformation";
String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
String caseUrl = "http://open.fangjia.com/house/case";
String poiUrl = "http://open.fangjia.com/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
def addressValue = httpRequest.getJsonContent(communityUrl, map, "UTF-8")
items['D'] = addressValue.get('result').toString()
def value = httpRequest.getJsonContent(valueUrl, map, "UTF-8")
items['E'] = value.get('result').toString()
def houseCase = httpRequest.getJsonContent(caseUrl, map, "UTF-8")
items['F'] = houseCase.get('result').toString()
def poi = httpRequest.getJsonContent(poiUrl, map, "UTF-8")
items['G'] = poi.get('result').toString()
}
})
@@ -0,0 +1,350 @@
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import com.fangjia.datastore.driver.DSCollection
import com.fangjia.datastore.driver.DataStore
import com.fangjia.script.BaseBatch
import com.fangjia.script.BatchOwner
import com.fangjia.script.Watcher
import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.util.CommonUtils
import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
//@BatchOwner(Watcher.MaJinTao)
class CommunityHouseSampleBatch extends BaseBatch {
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017)
DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017)
DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird")
static void main(String[] args) {
runBatch(new CommunityHouseSampleBatch(), args)
}
def findHouseCase(Object district_stat, Map<String, List> houseMap) {
// 查本小区的房源
def houseQuery = new BasicDBObject()
houseQuery.put("cat", "sell")
houseQuery.put("city", district_stat.city)
houseQuery.put("region", district_stat.region)
houseQuery.put("district_name", district_stat.district_name)
def houseListAll = SEABIRD.find(houseQuery).toList()
// 将均价符合的房源放入结果集
def houseList = houseListAll.findAll() { housecase ->
def totalPrice = housecase.total_price
def houseArea = housecase.area
def houseAvgPrice = totalPrice / houseArea
def avgPrice = district_stat.avg_price
houseAvgPrice >= avgPrice * 0.8 && houseAvgPrice <= avgPrice * 1.2
}
// 将样本数据按面积段分,200以下每10为一段,200以上每30为一段
// 分段的字段规则 area: 23.4 对应[20,30] 标记为 g20
for (def housecase : houseList) {
if (housecase.area <= 200) {
def area = housecase.area.toInteger()
def key = "g" + (area / 10).toInteger() * 10
def gList = houseMap.get(key)
if (gList == null || gList.size() == 0) {
def gHouseCaseList = []
gHouseCaseList.add(housecase)
houseMap.put(key, gHouseCaseList)
} else if (gList.size() < 10) {
gList.add(housecase)
houseMap.put(key, gList)
}
} else {
def area = housecase.area.toInteger()
def startPoint = 200
def segmentSize = 30
def rangeStart = (startPoint + (Math.floor((area - startPoint) / segmentSize) * segmentSize)).toInteger()
def key = "g" + rangeStart
def gList = houseMap.get(key)
if (gList == null || gList.size() == 0) {
def gHouseCaseList = []
gHouseCaseList.add(housecase)
houseMap.put(key, gHouseCaseList)
} else if (gList.size() < 10) {
gList.add(housecase)
houseMap.put(key, gList)
}
}
}
}
@Override
void process(Object args) {
ExecutorService executorService = Executors.newFixedThreadPool(5)
try {
def cityList = CommonUtils.findAllCity()
// 测试
cityList = cityList.subList(0, 5)
cityList.each { city ->
executorService.submit({
def count = 0
def documents = []
def weekend = DateUtils.getFirstDayOfWeek(new Date())
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
List<BasicDBObject> districts = CommonDatautils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lat", "lng"])
// 测试
districts = districts.subList(0, 10)
districts.each { district ->
Map<String, List> houseMap = [:]
def district_stat = districtPriceMap.get(district.city + "##" + district.region + "##" + district.name)
if (district_stat != null) {
findHouseCase(district_stat, houseMap)
}
if (houseMap == null || houseMap.size() == 0) {
def aroundDistrictList = DbUtils.findAroundDistrictByRadius(district, 3000)
// def aroundDistrictList = (aroundDistrictListAll.size() >= 50) ? aroundDistrictListAll.subList(0, 50) : aroundDistrictListAll
aroundDistrictList.each { aroundDistrict ->
def aroundDistrict_stat = districtPriceMap.get(aroundDistrict.city + "##" + aroundDistrict.region + "##" + aroundDistrict.name)
if (aroundDistrict_stat != null) {
findHouseCase(aroundDistrict_stat, houseMap)
}
}
}
def document = new BasicDBObject()
document.put("city", district.city)
document.put("region", district.region)
document.put("district_name", district.name)
document.put("house_case", houseMap)
documents.add(document)
count++
if (count % 10 == 0) {
println(city + "已处理小区数----------------------------------------------------" + count)
}
}
HOUSE_CASE.insert(documents)
} as Runnable)
}
} finally {
executorService.shutdown()
executorService.awaitTermination(Long.MAX_VALUE, java.util.concurrent.TimeUnit.NANOSECONDS)
}
}
}
/*
package com.fangjia.script.sync
import com.fangjia.datastore.driver.DSCollection
import com.fangjia.datastore.driver.DataStore
import com.fangjia.script.BaseBatch
import com.fangjia.script.BatchOwner
import com.fangjia.script.Watcher
import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.util.CommonUtils
import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.DbUtils
import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
@BatchOwner(Watcher.MaJinTao)
class CommunityHouseSampleBatch extends BaseBatch {
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
DBCollection STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat", "192.168.0.43", 28017)
DBCollection HOUSE_CASE = MongoUtils.getCollectionByName("business", "house_case", "192.168.0.43", 28017)
// DBCollection SEABIRD = MongoUtils.getCollectionByName("fangjia", "seabird", "192.168.0.43", 28017)
DSCollection SEABIRD = new DataStore("seabird.db.fangjia.com").getCollection("fangjia.seabird")
static void main(String[] args) {
runBatch(new CommunityHouseSampleBatch(), args)
}
def findHouseCase(Object district_stat, Map<String, List> houseMap) {
// 查本小区的房源
def houseQuery = new BasicDBObject()
//houseQuery.put("city", "深圳")
//houseQuery.put("region", "福田")
//houseQuery.put("district_name", "中泰燕南名庭")
houseQuery.put("cat", "sell")
houseQuery.put("city", district_stat.city)
houseQuery.put("region", district_stat.region)
houseQuery.put("district_name", district_stat.district_name)
def houseListAll = SEABIRD.find(houseQuery).toList()
// 将均价符合的房源放入结果集
def houseList = houseListAll.findAll() { housecase ->
def totalPrice = housecase.total_price
def houseArea = housecase.area
def houseAvgPrice = totalPrice / houseArea
def avgPrice = district_stat.avg_price
if (houseAvgPrice >= avgPrice * 0.8 && houseAvgPrice <= avgPrice * 1.2) {
return true
} else {
return false
}
}
// 将样本数据按面积段分,200以下每10为一段,200以上每30为一段
// 分段的字段规则 area: 23.4 对应[20,30] 标记为 g20
for (def housecase : houseList) {
if (housecase.area <= 200) {
def area = housecase.area.toInteger()
def key = "g" + (area / 10).toInteger() * 10
// println(key)
// 获取该面积段的房源列表
def gList = houseMap.get(key)
// 如果为空,说明该面积段没有房源,新建一个list,放入
if (gList == null || gList.size() == 0) {
def gHouseCaseList = []
gHouseCaseList.add(housecase)
houseMap.put(key, gHouseCaseList)
} else {
// 如果该面积段已经有10个房源,就不再放入
if (gList.size() < 10) {
// 如果不为空,说明该面积段已经有房源,直接放入
gList.add(housecase)
houseMap.put(key, gList)
}
}
} else {
def area = housecase.area.toInteger()
def startPoint = 200
def segmentSize = 30
def rangeStart = (startPoint + (Math.floor((area - startPoint) / segmentSize) * segmentSize)).toInteger()
def key = "g" + rangeStart
// println(key)
// 获取该面积段的房源列表
def gList = houseMap.get(key)
// 如果为空,说明该面积段没有房源,新建一个list,放入
if (gList == null || gList.size() == 0) {
def gHouseCaseList = []
gHouseCaseList.add(housecase)
houseMap.put(key, gHouseCaseList)
} else {
// 如果该面积段已经有10个房源,就不再放入
if (gList.size() < 10) {
gList.add(housecase)
houseMap.put(key, gList)
}
}
}
}
}
@Override
void process(Object args) {
def count = 0
def cityList = CommonUtils.findAllCity()
// 测试用,先只取一条
// cityList = cityList.subList(0, 1)
print(cityList.size())
print(cityList.toString())
// cityList.each { city ->
def city = cityList.get(0)
print(city)
def documents = []
//查询该城市的所有小区
List<BasicDBObject> districts = CommonDatautils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lat", "lng"])
//测试用,先只取5个小区
// districts = districts.subList(0, 2)
// 查询所有的小区均价
def weekend = DateUtils.getFirstDayOfWeek(new Date());
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
for (def district : districts) {
Map<String, List> houseMap = [:]
def district_stat = districtPriceMap.get(district.city + "##" + district.region + "##" + district.name)
// 拿到小区对应的均价之后,去查房源
if (district_stat != null) {
findHouseCase(district_stat, houseMap)
}
// 没有拿到小区对应的均价,找小区周边的三十个小区
def aroundDistrictListAll = DbUtils.findAroundDistrictByRadius(district, 3000)
def aroundDistrictList = (aroundDistrictListAll.size() >= 50) ? aroundDistrictListAll.subList(0, 50) : aroundDistrictListAll
// 遍历周边小区,找到均价符合的房源
aroundDistrictList.each { aroundDistrict ->
def aroundDistrict_stat = districtPriceMap.get(aroundDistrict.city + "##" + aroundDistrict.region + "##" + aroundDistrict.name)
// 拿到小区对应的均价之后,去查房源
if (aroundDistrict_stat != null) {
findHouseCase(aroundDistrict_stat, houseMap)
}
}
print(houseMap)
// 创建一个新的文档
def document = new BasicDBObject()
// 将 houseMap 和 communityStr 放入文档
document.put("city", district.city)
document.put("region", district.region)
document.put("district_name", district.name)
document.put("house_case", houseMap)
// 将文档插入到 MongoDB 中
// HOUSE_CASE.in(document)
documents.add(document)
count++
if (count % 10 == 0) {
print("已处理小区数----------------------------------------------------" + count)
}
}
HOUSE_CASE.insert(documents)
}
// }
}
*/
@@ -515,12 +515,12 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
}
//将数据放入样本仓库
for (Map.Entry<String, List<SampleWrapper>> entry : map.entrySet()) {
//超过两个,只取两个
// 取三个
if (entry.getValue().size()>=3){
querySamples.addAll(entry.getValue().subList(0,2));
//每个小区取5个样本
if (entry.getValue().size()>=5){
querySamples.addAll(entry.getValue().subList(0,5));
}else {
// 不超过两个,全部放入
// 不超过五个,全部放入
querySamples.addAll(entry.getValue());
}
}
View File