This commit is contained in:
2024-11-27 18:22:14 +08:00
parent 6b0c7c4b18
commit ce66ee4213
2 changed files with 123 additions and 101 deletions
@@ -4215,7 +4215,6 @@ class CommonDatautils {
ElasticUtils.executeSqlQuery(sql, { map-> ElasticUtils.executeSqlQuery(sql, { map->
// if(map.address && map.address.contains("五角场")){ // if(map.address && map.address.contains("五角场")){
index++ index++
println index
rets << ["map_id":map.id,"province":map.pname,"city":map.cityname, "district":map.adname, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.x, "lat":map.location.y] rets << ["map_id":map.id,"province":map.pname,"city":map.cityname, "district":map.adname, "name":map.name, "address":map.address, "cat":map.type,"lng":map.location.x, "lat":map.location.y]
// } // }
}) })
@@ -52,11 +52,13 @@ class NewGaoDePoiBatch extends BaseBatch{
def cityList = CommonDatautils.findFullNameCitys().reverse() def cityList = CommonDatautils.findFullNameCitys().reverse()
for(def cityObj : cityList){ for(def cityObj : cityList){
// if(cityObj.city == "上海市"){ // if(cityObj.city == "胡杨河市"){
def results = CommonDatautils.findAllNewPoiDatas(cityObj.city) def results = CommonDatautils.findAllNewPoiDatas(cityObj.city)
println cityObj.city+" "+results.size() println cityObj.province+" " +cityObj.city+" "+results.size()
if(results){
def rows = running(cityObj.city, results) def rows = running(cityObj.city, results)
save(rows) save(rows)
}
// } // }
} }
} }
@@ -91,7 +93,7 @@ class NewGaoDePoiBatch extends BaseBatch{
}); });
} }
latch.await() latch.await()
return rets; return rets
} }
def getStandardRegion(mzbRegionMap, district){ def getStandardRegion(mzbRegionMap, district){
@@ -130,7 +132,38 @@ class NewGaoDePoiBatch extends BaseBatch{
} }
saveObj.name = map.name saveObj.name = map.name
if(map.cat){ if(map.cat){
saveObj = catWash(saveObj, map)
}
def location = [:]
location.lon = DataHandleUtils.getDoubleRound(6, map.lng)
location.lat = DataHandleUtils.getDoubleRound(6, map.lat)
saveObj.location = location
saveObj.spell_name = com.fangjia.core.util.DataUtil.hanyuQuanpin(map.name, " ")
saveObj.version = version
saveObj.data_id = map.map_id
saveObj.data_source = "高德地图"
saveObj.data_source_year = "2024-11"
if(saveObj.cat && TAGS.contains(saveObj.cat)){
saveObj.status = 0
}else{
saveObj.status = 1
}
def towns = townMap.get(saveObj.district)
if(location){
saveObj = addTown(saveObj, towns, location)
}
if(map.address){
saveObj = addressWash(saveObj, map, mzbRegionMap, towns)
}
return saveObj
}
def catWash(saveObj, map){
def arrs = map.cat.split(";|:") def arrs = map.cat.split(";|:")
if(arrs.size()>=1){ if(arrs.size()>=1){
saveObj.type = arrs[0] saveObj.type = arrs[0]
@@ -156,26 +189,10 @@ class NewGaoDePoiBatch extends BaseBatch{
} }
saveObj.cat = saveObj.type+";"+saveObj.secondary_type+";"+saveObj.small_type saveObj.cat = saveObj.type+";"+saveObj.secondary_type+";"+saveObj.small_type
return saveObj
}
def location = [:]
location.lon = DataHandleUtils.getDoubleRound(6, map.lng)
location.lat = DataHandleUtils.getDoubleRound(6, map.lat)
saveObj.location = location
saveObj.spell_name = com.fangjia.core.util.DataUtil.hanyuQuanpin(map.name, " ")
saveObj.version = version
saveObj.data_id = map.map_id
saveObj.data_source = "高德地图"
saveObj.data_source_year = "2024-11"
if(saveObj.cat && TAGS.contains(saveObj.cat)){
saveObj.status = 0
}else{
saveObj.status = 1
} }
def towns = townMap.get(saveObj.district) def addTown(saveObj, towns, location){
if(location){
if(towns){ if(towns){
for(def town : towns){ for(def town : towns){
if(town.shape && town.shape.coordinates){ if(town.shape && town.shape.coordinates){
@@ -198,9 +215,10 @@ class NewGaoDePoiBatch extends BaseBatch{
// } // }
// } // }
} }
return saveObj
} }
if(map.address){ def addressWash(saveObj, map, mzbRegionMap, towns){
if(map.address.length()<3){ if(map.address.length()<3){
saveObj.address = "" saveObj.address = ""
}else{ }else{
@@ -217,18 +235,21 @@ class NewGaoDePoiBatch extends BaseBatch{
if(address && saveObj.district){ if(address && saveObj.district){
def tjjObj = mzbRegionMap.get(saveObj.district) def tjjObj = mzbRegionMap.get(saveObj.district)
if(tjjObj){ if(tjjObj){
def alias = tjjObj.alias def alias = null
if(!alias){ if(tjjObj.alias){
alias = [] alias = new CopyOnWriteArrayList<>(tjjObj.alias);
}else{
alias = new CopyOnWriteArrayList<>();
} }
if(!alias.contains(saveObj.district)){ if(!alias.contains(saveObj.district)){
alias << saveObj.district alias << saveObj.district
} }
// if(alias.size()>=2){ if(alias.size()>=2){
// alias.sort(){ a, b -> alias = alias.sort(){ a, b ->
// b.length().compareTo(a.length()); b.length().compareTo(a.length());
// } }
// } }
for(def regionName : alias){ for(def regionName : alias){
if(address.startsWith(regionName) && (regionName.endsWith("区") || regionName.endsWith("县"))){ if(address.startsWith(regionName) && (regionName.endsWith("区") || regionName.endsWith("县"))){
@@ -246,18 +267,21 @@ class NewGaoDePoiBatch extends BaseBatch{
if(address && towns){ if(address && towns){
for(def town : towns){ for(def town : towns){
def townAlias = town.alias def townAlias = null
if(!townAlias){ if(town.alias){
townAlias = [] townAlias = new CopyOnWriteArrayList<>(town.alias);
}else{
townAlias = new CopyOnWriteArrayList<>();
} }
if(!townAlias.contains(town.street)){ if(!townAlias.contains(town.street)){
townAlias << town.street townAlias << town.street
} }
// if(townAlias.size()>=2){ if(townAlias.size()>=2){
// townAlias = townAlias.sort(){ a, b -> townAlias = townAlias.sort(){ a, b ->
// b.length().compareTo(a.length()); b.length().compareTo(a.length());
// } }
// } }
for(def townName : townAlias){ for(def townName : townAlias){
if(address.startsWith(townName)){ if(address.startsWith(townName)){
@@ -278,13 +302,12 @@ class NewGaoDePoiBatch extends BaseBatch{
saveObj.address = address saveObj.address = address
} }
} }
}
return saveObj return saveObj
} }
def save(rows){ def save(rows){
BulkRequest request = new BulkRequest(); BulkRequest request = new BulkRequest();
int batchSize = 1000; int batchSize = 2000;
int processedCount = 0; int processedCount = 0;
def client = ElasticUtils89.getClient("192.168.0.89") def client = ElasticUtils89.getClient("192.168.0.89")