修复名字丢失

This commit is contained in:
沈健
2021-09-05 13:52:50 +08:00
parent f267f393fe
commit d961902f86
2 changed files with 29 additions and 36 deletions
@@ -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 {
@@ -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<String, String> params = new HashMap<String, String>();
@@ -71,7 +70,6 @@ class SeaweedSchool {
List<HouseList.ContentDTO.ListDTO> 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