修复名字丢失
This commit is contained in:
+28
-34
@@ -7,7 +7,6 @@ import com.mongodb.BasicDBObject
|
|||||||
import com.mongodb.DBCollection
|
import com.mongodb.DBCollection
|
||||||
import com.mongodb.DBObject
|
import com.mongodb.DBObject
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch
|
|
||||||
import java.util.concurrent.ExecutorService
|
import java.util.concurrent.ExecutorService
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
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 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) {
|
static void main(String[] args) {
|
||||||
AtomicLong atomicLong = new AtomicLong(0);
|
AtomicLong atomicLong = new AtomicLong(0);
|
||||||
@@ -29,45 +28,40 @@ class SeaweedSchoolLatLng {
|
|||||||
@Override
|
@Override
|
||||||
void run() {
|
void run() {
|
||||||
try {
|
try {
|
||||||
BasicDBList primarySchools = obj.primarySchool
|
def address = obj.address
|
||||||
BasicDBList middleSchools = obj.middleSchool
|
if (address.contains("浦东")) {
|
||||||
if (primarySchools != null) {
|
BasicDBList primarySchools = obj.primarySchool
|
||||||
for (BasicDBObject dbObject : primarySchools) {
|
BasicDBList middleSchools = obj.middleSchool
|
||||||
def name = dbObject.name
|
if (primarySchools != null) {
|
||||||
if (dbObject.lng == null) {
|
for (BasicDBObject dbObject : primarySchools) {
|
||||||
def location = GaoDeUtils.parserByGaode("上海", "上海市浦东新区" + name)
|
def schoolAddress = dbObject.address
|
||||||
if (location && location.lng) {
|
if (dbObject.lng == null) {
|
||||||
def lng = Double.valueOf(location.lng)
|
def location = GaoDeUtils.parserByGaode("上海", "上海市浦东新区" + schoolAddress)
|
||||||
def lat = Double.valueOf(location.lat)
|
if (location && location.lng) {
|
||||||
dbObject.lng = lng
|
def lng = Double.valueOf(location.lng)
|
||||||
dbObject.lat = lat
|
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) {
|
||||||
if (middleSchools != null) {
|
for (BasicDBObject dbObject : middleSchools) {
|
||||||
for (BasicDBObject dbObject : middleSchools) {
|
def schoolAddress = dbObject.address
|
||||||
def name = dbObject.name
|
if (dbObject.lng == null) {
|
||||||
if (dbObject.lng == null) {
|
def location = GaoDeUtils.parserByGaode("上海", "上海市浦东新区" + schoolAddress)
|
||||||
def location = GaoDeUtils.parserByGaode("上海", "上海市浦东新区" + name)
|
if (location && location.lng) {
|
||||||
if (location && location.lng) {
|
def lng = Double.valueOf(location.lng)
|
||||||
def lng = Double.valueOf(location.lng)
|
def lat = Double.valueOf(location.lat)
|
||||||
def lat = Double.valueOf(location.lat)
|
dbObject.lng = lng
|
||||||
dbObject.lng = lng
|
dbObject.lat = lat
|
||||||
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) {
|
} catch(Exception ex) {
|
||||||
ex.printStackTrace()
|
ex.printStackTrace()
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+1
-2
@@ -48,7 +48,6 @@ class SeaweedSchool {
|
|||||||
final int perPage = 10
|
final int perPage = 10
|
||||||
final int total = 4733;
|
final int total = 4733;
|
||||||
for (int page = 1; page < total / perPage; page++) {
|
for (int page = 1; page < total / perPage; page++) {
|
||||||
Thread.sleep(1000)
|
|
||||||
print("当前页:" + page)
|
print("当前页:" + page)
|
||||||
try {
|
try {
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
@@ -71,7 +70,6 @@ class SeaweedSchool {
|
|||||||
List<HouseList.ContentDTO.ListDTO> listDTOS = houseList.getContent().getList();
|
List<HouseList.ContentDTO.ListDTO> listDTOS = houseList.getContent().getList();
|
||||||
if (CollectionUtils.isNotEmpty(listDTOS)) {
|
if (CollectionUtils.isNotEmpty(listDTOS)) {
|
||||||
for (HouseList.ContentDTO.ListDTO listDTO : listDTOS) {
|
for (HouseList.ContentDTO.ListDTO listDTO : listDTOS) {
|
||||||
Thread.sleep(500)
|
|
||||||
Integer id = listDTO.getId();
|
Integer id = listDTO.getId();
|
||||||
//# 房屋详情
|
//# 房屋详情
|
||||||
HouseDetail houseDetail = getHouseDetail(re, id, headers)
|
HouseDetail houseDetail = getHouseDetail(re, id, headers)
|
||||||
@@ -146,6 +144,7 @@ class SeaweedSchool {
|
|||||||
schoolObject.put("town", contentDTO.getTown())
|
schoolObject.put("town", contentDTO.getTown())
|
||||||
schoolObject.put("distance", contentDTO.getDistance())
|
schoolObject.put("distance", contentDTO.getDistance())
|
||||||
schoolObject.put("address", contentDTO.getAddress())
|
schoolObject.put("address", contentDTO.getAddress())
|
||||||
|
schoolObject.put("name", contentDTO.getName())
|
||||||
schools.add(schoolObject)
|
schools.add(schoolObject)
|
||||||
}
|
}
|
||||||
return schools
|
return schools
|
||||||
|
|||||||
Reference in New Issue
Block a user