综合查询接口速度优化,每个小区取五个

This commit is contained in:
mjt
2024-01-02 16:26:35 +08:00
parent 8dd7ad650a
commit d9a0aaf52e
5 changed files with 35 additions and 33 deletions
@@ -228,6 +228,7 @@ public class ComprehensiveQueryController {
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) {
}
@@ -9,7 +9,7 @@ String excelFilePath = "F:\\
ExcelUtils.removeEmptyRow(excelFilePath)
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 valueUrl = "http://open.fangjia.com/property/addressEvaluate";
String caseUrl = "http://open.fangjia.com/house/case";
@@ -35,27 +35,27 @@ ExcelUtils.singleThreadingModify(excelFilePath, { List items ->
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();
// 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")
@@ -13,7 +13,7 @@ import com.fangjia.script.util.MongoUtils
import com.mongodb.BasicDBObject
import com.mongodb.DBCollection
@BatchOwner(Watcher.MaJinTao)
//@BatchOwner(Watcher.MaJinTao)
class CommunityHouseSampleBatch extends BaseBatch {
DBCollection SEAWEED = MongoUtils.getCollectionByName("fangjia", "seaweed", "192.168.0.43", 28017)
@@ -85,8 +85,8 @@ class CommunityHouseSampleBatch extends BaseBatch {
try {
def cityList = CommonUtils.findAllCity()
// cityList = cityList.subList(0,150)
// 测试
cityList = cityList.subList(0, 5)
cityList.each { city ->
executorService.submit({
def count = 0
@@ -95,8 +95,8 @@ class CommunityHouseSampleBatch extends BaseBatch {
def districtPriceMap = CommonDatautils.queryAllDistrictPrice(city, weekend)
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 ->
Map<String, List> houseMap = [:]
@@ -105,7 +105,7 @@ class CommunityHouseSampleBatch extends BaseBatch {
if (district_stat != null) {
findHouseCase(district_stat, houseMap)
}
if (houseMap.size() == 0) {
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 ->
@@ -456,7 +456,7 @@ public class ExcelUtils{
def body = data.subList(1, data.size())
def nThread = Runtime.getRuntime().availableProcessors() * 3
println nThread
ExecutorService executorService = Executors.newFixedThreadPool(1)
ExecutorService executorService = Executors.newFixedThreadPool(3)
final AtomicInteger counter = new AtomicInteger(0)
final double total = body.size()
for(int i = 0 ; i < body.size(); i++){
@@ -466,11 +466,12 @@ public class CzbankSampleServiceImpl implements CzbankSampleService {
}
//将数据放入样本仓库
for (Map.Entry<String, List<SampleWrapper>> entry : map.entrySet()) {
//超过两个,只取两个
if (entry.getValue().size()>=2){
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());
}
}