添加街道字段
This commit is contained in:
@@ -6,34 +6,50 @@ import com.fangjia.script.util.DataUtil
|
||||
import com.fangjia.script.util.DbUtils
|
||||
import com.fangjia.script.util.ExcelUtils
|
||||
import com.fangjia.script.util.MongoUtils
|
||||
import com.fangjia.script.yinjihaun.amap.GaoDeApiUtils
|
||||
import com.mongodb.BasicDBObject
|
||||
import com.mongodb.DBCollection
|
||||
import net.sf.json.JSONObject
|
||||
import org.apache.commons.lang.StringUtils
|
||||
DBCollection SEAWEED_TOWNSHIP = MongoUtils.getCollectionByName("fangjia_base", "seaweed_township", "192.168.0.235", 27018)
|
||||
def count = 0
|
||||
List<List<String>> data = Collections.synchronizedList([])
|
||||
data << ["ID","城市","区域","小区名","经度","纬度","街道"]
|
||||
|
||||
|
||||
//ExcelUtils.multiThreadingModify("D:\\Users\\wenyan\\Desktop\\Êý¾Ý.xlsx",{List item->
|
||||
// if(DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(item["A"], item["B"], item["C"]))){
|
||||
// item["D"] = "´æÔÚ"
|
||||
// }else{
|
||||
// item["D"] = "²»´æÔÚ"
|
||||
// }
|
||||
//})
|
||||
|
||||
|
||||
DBCollection DISTRICT_STAT = MongoUtils.getCollectionByName("fangjia_stat", "district_stat","mongo.db.fangjia.com")
|
||||
ProvinceData.getAllCity("¸£½¨").each {def city->
|
||||
int count = 0
|
||||
def s = new TreeMap()
|
||||
DISTRICT_STAT.find(new BasicDBObject("weekend", Date.parse("yyyy-MM-dd", "2020-04-19")).append("city", city)).each {BasicDBObject stat->
|
||||
count ++
|
||||
int credit = (stat.credit * 100)/10
|
||||
s[credit] = s.get(credit, 0) + 1
|
||||
}
|
||||
|
||||
def data = []
|
||||
data << city
|
||||
data << count
|
||||
for(int i=0; i <=10; i++){
|
||||
data << s.get(i, 0)
|
||||
}
|
||||
println(data.join(","))
|
||||
CommonUtils.findAllCity().each {def city->
|
||||
DbUtils.multiThreadingExecuteQueryOnSeaweed(DbUtils.buildSeaweedQuery(city),{BasicDBObject item->
|
||||
if(StringUtils.isBlank(item.township) && item.lng){
|
||||
count++
|
||||
def lng = item.lng/10000000000d
|
||||
def lat = item.lat/10000000000d
|
||||
def location = "${lng},${lat}"
|
||||
JSONObject resp = GaoDeApiUtils.geocode(location)
|
||||
def row = []
|
||||
row << item._id.toString()
|
||||
row << item.city
|
||||
row << item.region
|
||||
row << item.name
|
||||
row << lng
|
||||
row << lat
|
||||
BasicDBObject dbo = new BasicDBObject()
|
||||
dbo.id = item._id.toString()
|
||||
dbo.city = item.city
|
||||
dbo.region = item.region
|
||||
dbo.name = item.name
|
||||
dbo.lng = lng
|
||||
dbo.lat = lat
|
||||
if(resp.regeocode && resp.regeocode.addressComponent && resp.regeocode.addressComponent.township){
|
||||
row << resp.regeocode.addressComponent.township
|
||||
dbo.township = resp.regeocode.addressComponent.township
|
||||
}
|
||||
println(row)
|
||||
data << row
|
||||
SEAWEED_TOWNSHIP.insert(dbo)
|
||||
}
|
||||
})
|
||||
}
|
||||
ExcelUtils.write("D:\\街道补充数据.xlsx", data, "补充数据")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user