diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedSchoolLatLng.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedSchoolLatLng.groovy index d511bb745..93bf399b6 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedSchoolLatLng.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedSchoolLatLng.groovy @@ -7,7 +7,6 @@ import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.mongodb.DBObject -import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.atomic.AtomicLong @@ -19,7 +18,7 @@ class SeaweedSchoolLatLng { static DBCollection collection = MongoUtils.getCollectionByName("fangjia_craw", "seaweed_school", "192.168.0.235", 27018) - static ExecutorService executorService = Executors.newFixedThreadPool(20) + static ExecutorService executorService = Executors.newFixedThreadPool(1) static void main(String[] args) { AtomicLong atomicLong = new AtomicLong(0); @@ -29,45 +28,40 @@ class SeaweedSchoolLatLng { @Override void run() { try { - BasicDBList primarySchools = obj.primarySchool - BasicDBList middleSchools = obj.middleSchool - if (primarySchools != null) { - for (BasicDBObject dbObject : primarySchools) { - def name = dbObject.name - if (dbObject.lng == null) { - def location = GaoDeUtils.parserByGaode("上海", "上海市浦东新区" + name) - if (location && location.lng) { - def lng = Double.valueOf(location.lng) - def lat = Double.valueOf(location.lat) - dbObject.lng = lng - dbObject.lat = lat + def address = obj.address + if (address.contains("浦东")) { + BasicDBList primarySchools = obj.primarySchool + BasicDBList middleSchools = obj.middleSchool + if (primarySchools != null) { + for (BasicDBObject dbObject : primarySchools) { + def schoolAddress = dbObject.address + if (dbObject.lng == null) { + def location = GaoDeUtils.parserByGaode("上海", "上海市浦东新区" + schoolAddress) + if (location && location.lng) { + def lng = Double.valueOf(location.lng) + def lat = Double.valueOf(location.lat) + dbObject.lng = lng + dbObject.lat = lat + } } } - if (dbObject.lng != null) { - String address = GaoDeUtils.getGaoDeAddress(dbObject.lng + "," + dbObject.lat) - dbObject.address = address - } } - } - if (middleSchools != null) { - for (BasicDBObject dbObject : middleSchools) { - def name = dbObject.name - if (dbObject.lng == null) { - def location = GaoDeUtils.parserByGaode("上海", "上海市浦东新区" + name) - if (location && location.lng) { - def lng = Double.valueOf(location.lng) - def lat = Double.valueOf(location.lat) - dbObject.lng = lng - dbObject.lat = lat + if (middleSchools != null) { + for (BasicDBObject dbObject : middleSchools) { + def schoolAddress = dbObject.address + if (dbObject.lng == null) { + def location = GaoDeUtils.parserByGaode("上海", "上海市浦东新区" + schoolAddress) + if (location && location.lng) { + def lng = Double.valueOf(location.lng) + def lat = Double.valueOf(location.lat) + dbObject.lng = lng + dbObject.lat = lat + } } } - if (dbObject.lng != null) { - String address = GaoDeUtils.getGaoDeAddress(dbObject.lng + "," + dbObject.lat) - dbObject.address = address - } } + collection.update(new BasicDBObject('url', obj.url), new BasicDBObject('$set', obj), false, true) } - collection.update(new BasicDBObject('url', obj.url), new BasicDBObject('$set', obj), false, true) } catch(Exception ex) { ex.printStackTrace() } finally { diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/seaweed/SeaweedSchool.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/seaweed/SeaweedSchool.groovy index b988b6a9d..b3ab13fef 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/seaweed/SeaweedSchool.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/seaweed/SeaweedSchool.groovy @@ -48,7 +48,6 @@ class SeaweedSchool { final int perPage = 10 final int total = 4733; for (int page = 1; page < total / perPage; page++) { - Thread.sleep(1000) print("当前页:" + page) try { Map params = new HashMap(); @@ -71,7 +70,6 @@ class SeaweedSchool { List listDTOS = houseList.getContent().getList(); if (CollectionUtils.isNotEmpty(listDTOS)) { for (HouseList.ContentDTO.ListDTO listDTO : listDTOS) { - Thread.sleep(500) Integer id = listDTO.getId(); //# 房屋详情 HouseDetail houseDetail = getHouseDetail(re, id, headers) @@ -146,6 +144,7 @@ class SeaweedSchool { schoolObject.put("town", contentDTO.getTown()) schoolObject.put("distance", contentDTO.getDistance()) schoolObject.put("address", contentDTO.getAddress()) + schoolObject.put("name", contentDTO.getName()) schools.add(schoolObject) } return schools