升级Es驱动版本

This commit is contained in:
2021-04-12 11:49:21 +08:00
parent 1626ab944d
commit a8cba2def2
3 changed files with 54 additions and 57 deletions
@@ -140,13 +140,12 @@ class ElasticUtils {
* @return * @return
*/ */
static closeBulkProcessor(BulkProcessor bulkProcessor) { static closeBulkProcessor(BulkProcessor bulkProcessor) {
bulkProcessor.awaitClose(10, TimeUnit.DAYS) bulkProcessor.awaitClose(10, TimeUnit.DAYS)
bulkProcessor.flush() bulkProcessor.flush()
bulkProcessor.close() bulkProcessor.close()
} }
static executeQuery(String host, String indexName, QueryBuilder qb, Closure closure){ static executeQuery(String host, String indexName, QueryBuilder qb, Closure closure){
RestHighLevelClient client = getClient(host) RestHighLevelClient client = getClient(host)
@@ -1,19 +1,17 @@
package com.fangjia.script.util package com.fangjia.script.util
import com.mongodb.DBCursor
import org.apache.commons.lang.StringUtils
import org.apache.lucene.index.Term
import org.apache.lucene.search.BooleanClause
import org.apache.lucene.search.BooleanQuery
import org.apache.lucene.search.TermQuery
import org.apache.solr.client.solrj.util.ClientUtils
import com.fangjia.datastore.driver.DSCursor import com.fangjia.datastore.driver.DSCursor
import com.fangjia.datastore.driver.FacetResult import com.fangjia.datastore.driver.FacetResult
import com.fangjia.script.util.DateUtils import com.fangjia.script.util.DateUtils
import com.fangjia.script.util.DbUtils import com.fangjia.script.util.DbUtils
import com.mongodb.BasicDBObject import com.mongodb.BasicDBObject
import com.mongodb.DBObject import com.mongodb.DBObject
import org.apache.commons.lang.StringUtils
import org.apache.lucene.index.Term
import org.apache.lucene.search.BooleanClause
import org.apache.lucene.search.BooleanQuery
import org.apache.lucene.search.TermQuery
import org.apache.solr.client.solrj.util.ClientUtils
class HouseUtils{ class HouseUtils{
static main(args){ static main(args){
@@ -153,55 +153,55 @@ import org.apache.commons.lang3.StringUtils
//} //}
DBCollection BAIDUMAP_BORDER_COLL = MongoUtils.getCollectionByName("addrepo", "baidumap_border", "192.168.0.206", 27020) DBCollection BAIDUMAP_BORDER_COLL = MongoUtils.getCollectionByName("addrepo", "baidumap_border", "192.168.0.206", 27020)
BAIDUMAP_BORDER_COLL.find(new BasicDBObject("baidu_border", null)).each {BasicDBObject dbo-> //BAIDUMAP_BORDER_COLL.find(new BasicDBObject("baidu_border", null)).each {BasicDBObject dbo->
def border = dbo.getString("border").replace("1-", "").replace(";", "").split(",") as List // def border = dbo.getString("border").replace("1-", "").replace(";", "").split(",") as List
def coords = [] // def coords = []
def baidu_points = [] // def baidu_points = []
def gaode_points = [] // def gaode_points = []
for(int i=0; i < border.size() - 1; i=i+2){ // for(int i=0; i < border.size() - 1; i=i+2){
coords << "${border[i]},${border[i+1]}" // coords << "${border[i]},${border[i+1]}"
if(coords.size() > 50){ // if(coords.size() > 50){
def json=BaiDuApiUtils.geoconv(coords.join(";"), 6, 5) // def json=BaiDuApiUtils.geoconv(coords.join(";"), 6, 5)
for(JSONObject it : json.result){ // for(JSONObject it : json.result){
baidu_points << "${it.x},${it.y}" // baidu_points << "${it.x},${it.y}"
def geo = GeocodeUtils.geoconvBaiduToGoogle(it.x, it.y) // def geo = GeocodeUtils.geoconvBaiduToGoogle(it.x, it.y)
gaode_points << "${DataUtil.roundDouble(geo.lng, 6)},${DataUtil.roundDouble(geo.lat,6)}" // gaode_points << "${DataUtil.roundDouble(geo.lng, 6)},${DataUtil.roundDouble(geo.lat,6)}"
} // }
coords.clear() // coords.clear()
}
}
if(coords.size() > 0){
def json=BaiDuApiUtils.geoconv(coords.join(";"), 6, 5)
for(JSONObject it : json.result){
baidu_points << "${it.x},${it.y}"
def geo = GeocodeUtils.geoconvBaiduToGoogle(it.x, it.y)
gaode_points << "${DataUtil.roundDouble(geo.lng, 6)},${DataUtil.roundDouble(geo.lat,6)}"
}
}
dbo.format_city = RegionData.formatCity(dbo.city)
dbo.baidu_border = baidu_points.join(";")
dbo.gaode_border = gaode_points.join(";")
BAIDUMAP_BORDER_COLL.save(dbo)
println(dbo)
}
//ExcelUtils.multiThreadingModify("D:\\Users\\wenyan\\Desktop\\人口测试数据.xlsx",{List item->
// def seaweed = DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(item["B"], item["C"], item["D"]), new BasicDBObject("alias", 1).append("lng",1).append("lat", 1))
// if(seaweed){
// item["A"] = seaweed._id.toString()
// def names = [item['D']]
// if(seaweed.alias){
// names.addAll(seaweed.alias)
// } // }
// names.unique() // }
// if(coords.size() > 0){
// def json=BaiDuApiUtils.geoconv(coords.join(";"), 6, 5)
// for(JSONObject it : json.result){
// baidu_points << "${it.x},${it.y}"
// def geo = GeocodeUtils.geoconvBaiduToGoogle(it.x, it.y)
// gaode_points << "${DataUtil.roundDouble(geo.lng, 6)},${DataUtil.roundDouble(geo.lat,6)}"
// }
// }
// dbo.format_city = RegionData.formatCity(dbo.city)
// dbo.baidu_border = baidu_points.join(";")
// dbo.gaode_border = gaode_points.join(";")
// BAIDUMAP_BORDER_COLL.save(dbo)
// println(dbo)
//}
ExcelUtils.multiThreadingModify("D:\\Users\\wenyan\\Desktop\\小区群像测试数据.xlsx",{List item->
def seaweed = DbUtils.seaweed.findOne(DbUtils.buildSeaweedQuery(item["B"], item["C"], item["D"]), new BasicDBObject("alias", 1).append("lng",1).append("lat", 1))
if(seaweed){
// item["A"] = seaweed._id.toString()
def names = [item['D']]
if(seaweed.alias){
names.addAll(seaweed.alias)
}
names.unique()
// if(seaweed.lng){ // if(seaweed.lng){
// item["G"] = DataUtil.roundDouble(seaweed.lng/10000000000d, 6) // item["G"] = DataUtil.roundDouble(seaweed.lng/10000000000d, 6)
// item["H"] = DataUtil.roundDouble(seaweed.lat/10000000000d, 6) // item["H"] = DataUtil.roundDouble(seaweed.lat/10000000000d, 6)
// } // }
// def one = BAIDUMAP_BORDER_COLL.findOne(new BasicDBObject("format_city", item["B"]).append("format_region", item["C"]).append("name", new BasicDBObject('$in', names))) def one = BAIDUMAP_BORDER_COLL.findOne(new BasicDBObject("format_city", item["B"]).append("format_region", item["C"]).append("name", new BasicDBObject('$in', names)))
// if(one){ if(one){
// item["I"] = one.baidu_border item["I"] = one.gaode_border
// } }
// println(item) println(item)
// } }
//}) })