综合查询接口速度优化,每个小区取五个
This commit is contained in:
+1
@@ -228,6 +228,7 @@ public class ComprehensiveQueryController {
|
|||||||
JSONObject matchResponse = null;
|
JSONObject matchResponse = null;
|
||||||
try {
|
try {
|
||||||
matchResponse = httpRequest.getJsonContent("http://192.168.0.100:32080/FangJiaAddressService/v2/match", communityAvgPriceParams, "UTF-8");
|
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) {
|
} catch (HttpRequestException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ String excelFilePath = "F:\\
|
|||||||
ExcelUtils.removeEmptyRow(excelFilePath)
|
ExcelUtils.removeEmptyRow(excelFilePath)
|
||||||
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
||||||
|
|
||||||
String comprehensiveUrl = "http://open.fangjia.com/comprehensiveQuery/houseValueInformation";
|
String comprehensiveUrl = "http://localhost:9180/comprehensiveQuery/houseValueInformation";
|
||||||
String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
|
String communityUrl = "http://open.fangjia.com/addrSvc/avgPrice";
|
||||||
String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
|
String valueUrl = "http://open.fangjia.com/property/addressEvaluate";
|
||||||
String caseUrl = "http://open.fangjia.com/house/case";
|
String caseUrl = "http://open.fangjia.com/house/case";
|
||||||
@@ -35,27 +35,27 @@ ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
|
|||||||
long start
|
long start
|
||||||
long end
|
long end
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
// start = System.currentTimeMillis();
|
||||||
httpRequest.getJsonContent(communityUrl, map, "UTF-8")
|
// httpRequest.getJsonContent(communityUrl, map, "UTF-8")
|
||||||
|
//
|
||||||
|
//
|
||||||
end = System.currentTimeMillis();
|
// end = System.currentTimeMillis();
|
||||||
items['D'] = String.valueOf(end - start);
|
// items['D'] = String.valueOf(end - start);
|
||||||
|
//
|
||||||
start = System.currentTimeMillis();
|
// start = System.currentTimeMillis();
|
||||||
httpRequest.getJsonContent(valueUrl, map, "UTF-8")
|
// httpRequest.getJsonContent(valueUrl, map, "UTF-8")
|
||||||
end = System.currentTimeMillis();
|
// end = System.currentTimeMillis();
|
||||||
items['E'] = String.valueOf(end - start);
|
// items['E'] = String.valueOf(end - start);
|
||||||
|
//
|
||||||
start = System.currentTimeMillis();
|
// start = System.currentTimeMillis();
|
||||||
httpRequest.getJsonContent(caseUrl, map, "UTF-8")
|
// httpRequest.getJsonContent(caseUrl, map, "UTF-8")
|
||||||
end = System.currentTimeMillis();
|
// end = System.currentTimeMillis();
|
||||||
items['F'] = String.valueOf(end - start);
|
// items['F'] = String.valueOf(end - start);
|
||||||
|
//
|
||||||
start = System.currentTimeMillis();
|
// start = System.currentTimeMillis();
|
||||||
httpRequest.getJsonContent(poiUrl, map, "UTF-8")
|
// httpRequest.getJsonContent(poiUrl, map, "UTF-8")
|
||||||
end = System.currentTimeMillis();
|
// end = System.currentTimeMillis();
|
||||||
items['G'] = String.valueOf(end - start);
|
// items['G'] = String.valueOf(end - start);
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
def content = httpRequest.getJsonContent(comprehensiveUrl, map, "UTF-8")
|
def content = httpRequest.getJsonContent(comprehensiveUrl, map, "UTF-8")
|
||||||
|
|||||||
+6
-6
@@ -13,7 +13,7 @@ import com.fangjia.script.util.MongoUtils
|
|||||||
import com.mongodb.BasicDBObject
|
import com.mongodb.BasicDBObject
|
||||||
import com.mongodb.DBCollection
|
import com.mongodb.DBCollection
|
||||||
|
|
||||||
@BatchOwner(Watcher.MaJinTao)
|
//@BatchOwner(Watcher.MaJinTao)
|
||||||
class CommunityHouseSampleBatch extends BaseBatch {
|
class CommunityHouseSampleBatch extends BaseBatch {
|
||||||
|
|
||||||
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
|
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
|
||||||
@@ -85,8 +85,8 @@ class CommunityHouseSampleBatch extends BaseBatch {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
def cityList = CommonUtils.findAllCity()
|
def cityList = CommonUtils.findAllCity()
|
||||||
|
// 测试
|
||||||
// cityList = cityList.subList(0,150)
|
cityList = cityList.subList(0, 5)
|
||||||
cityList.each { city ->
|
cityList.each { city ->
|
||||||
executorService.submit({
|
executorService.submit({
|
||||||
def count = 0
|
def count = 0
|
||||||
@@ -95,8 +95,8 @@ class CommunityHouseSampleBatch extends BaseBatch {
|
|||||||
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
|
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
|
||||||
List<BasicDBObject> districts = CommonDatautils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lat", "lng"])
|
List<BasicDBObject> districts = CommonDatautils.findAllDistrictByCity(city, "district", ["city", "region", "name", "lat", "lng"])
|
||||||
|
|
||||||
// 测试,只选一个
|
// 测试
|
||||||
// districts = districts.subList(0, 1)
|
districts = districts.subList(0, 10)
|
||||||
|
|
||||||
districts.each { district ->
|
districts.each { district ->
|
||||||
Map<String, List> houseMap = [:]
|
Map<String, List> houseMap = [:]
|
||||||
@@ -105,7 +105,7 @@ class CommunityHouseSampleBatch extends BaseBatch {
|
|||||||
if (district_stat != null) {
|
if (district_stat != null) {
|
||||||
findHouseCase(district_stat, houseMap)
|
findHouseCase(district_stat, houseMap)
|
||||||
}
|
}
|
||||||
if (houseMap.size() == 0) {
|
if (houseMap == null || houseMap.size() == 0) {
|
||||||
def aroundDistrictList = DbUtils.findAroundDistrictByRadius(district, 3000)
|
def aroundDistrictList = DbUtils.findAroundDistrictByRadius(district, 3000)
|
||||||
// def aroundDistrictList = (aroundDistrictListAll.size() >= 50) ? aroundDistrictListAll.subList(0, 50) : aroundDistrictListAll
|
// def aroundDistrictList = (aroundDistrictListAll.size() >= 50) ? aroundDistrictListAll.subList(0, 50) : aroundDistrictListAll
|
||||||
aroundDistrictList.each { aroundDistrict ->
|
aroundDistrictList.each { aroundDistrict ->
|
||||||
|
|||||||
@@ -456,7 +456,7 @@ public class ExcelUtils{
|
|||||||
def body = data.subList(1, data.size())
|
def body = data.subList(1, data.size())
|
||||||
def nThread = Runtime.getRuntime().availableProcessors() * 3
|
def nThread = Runtime.getRuntime().availableProcessors() * 3
|
||||||
println nThread
|
println nThread
|
||||||
ExecutorService executorService = Executors.newFixedThreadPool(1)
|
ExecutorService executorService = Executors.newFixedThreadPool(3)
|
||||||
final AtomicInteger counter = new AtomicInteger(0)
|
final AtomicInteger counter = new AtomicInteger(0)
|
||||||
final double total = body.size()
|
final double total = body.size()
|
||||||
for(int i = 0 ; i < body.size(); i++){
|
for(int i = 0 ; i < body.size(); i++){
|
||||||
|
|||||||
+5
-4
@@ -466,11 +466,12 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
|
|||||||
}
|
}
|
||||||
//将数据放入样本仓库
|
//将数据放入样本仓库
|
||||||
for (Map.Entry<String, List<SampleWrapper>> entry : map.entrySet()) {
|
for (Map.Entry<String, List<SampleWrapper>> entry : map.entrySet()) {
|
||||||
//超过两个,只取两个
|
//每个小区取5个样本
|
||||||
if (entry.getValue().size()>=2){
|
|
||||||
querySamples.addAll(entry.getValue().subList(0,2));
|
if (entry.getValue().size()>=5){
|
||||||
|
querySamples.addAll(entry.getValue().subList(0,5));
|
||||||
}else {
|
}else {
|
||||||
// 不超过两个,全部放入
|
// 不超过五个,全部放入
|
||||||
querySamples.addAll(entry.getValue());
|
querySamples.addAll(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user