From 771ee6af5de0aacc22138731492078ba48de9750 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Thu, 13 Jun 2024 10:54:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=94=B9=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../script/commData/CommonDatautils.groovy | 75 ++++++++++++++++++- .../script/gj/data_handle/DevProcess.groovy | 41 +++++++++- 2 files changed, 114 insertions(+), 2 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy index ea417b329..634bf7b80 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/commData/CommonDatautils.groovy @@ -18,6 +18,7 @@ import groovy.json.JsonSlurper import net.sf.json.JSONArray import net.sf.json.JSONObject import org.apache.commons.lang.StringUtils +import org.apache.poi.ss.util.RegionUtil import org.bson.Document import org.bson.types.ObjectId @@ -117,6 +118,7 @@ class CommonDatautils { } public static final DBCollection COMMUNITY_CONN = MongoUtils.getCollectionByName2("fangjia", "community", "mongodb://admin:G00MONGOADMIN@192.168.0.100:30009") + public static final DBCollection ADMINISTRATIVE_MAPPING_COLL = MongoUtils.getCollectionByName("business", "administrative_mapping", "mongo.db.fangjia.com") public static DSCollection getHouseDataStoreConnection(){ if(house_dataStoreConnection != null) { @@ -274,7 +276,7 @@ class CommonDatautils { q.put("status", 0); q.put("cat", cat); q.put("city", city); -// q.put("name","泰瑞家园") + q.put("name","上唐山水") DBObject keys = new BasicDBObject(); if(fields){ @@ -4605,6 +4607,77 @@ class CommonDatautils { } + static def queryFullNameByCity(){ + def q = new BasicDBObject() + q.put("type","城市") + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q) + def cityMap = [:] + for(def d : dbcursor){ + def city = RegionData.formatCity(d.city) + if(city){ + cityMap.put(city, d) + }else{ + //println d.city +" 格式化不出" + } + + } + return cityMap + } + + static def queryDistNameByCity(){ + + def q = new BasicDBObject() + q.put("type","区域") + def keys = new BasicDBObject() + keys.put("province",1) + keys.put("city",1) + keys.put("district",1) + keys.put("street",1) + keys.put("mzb_district_name", 1) + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(2000) + def regionMap = [:] + for(def d : dbcursor){ + if(d.mzb_district_name){ + def regions = regionMap.get(d.city) + if(!regions){ + regions = [] + } + regions << d + regionMap.put(d.city, regions) + }else{ + println d.province+" "+d.district +" 格式化不出民政部区域" + } + } + return regionMap + } + + static def queryCommunityByCity(){ + + def q = new BasicDBObject() + q.put("type","乡镇街道") + + def keys = new BasicDBObject() + keys.put("province",1) + keys.put("city",1) + keys.put("district",1) + keys.put("street",1) + keys.put("shape",1) + def dbcursor = ADMINISTRATIVE_MAPPING_COLL.find(q, keys).batchSize(5000) + def townMap = [:] + for(def d : dbcursor){ + def key = d.city+"#"+d.district + def list = townMap.get(key) + if(!list){ + list = [] + } + list << d + townMap.put(key, list) + } + return townMap + + } + + static def queryDistNameCity(){ def q = new BasicDBObject() diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy index 13d1b5009..c722603c3 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/DevProcess.groovy @@ -52,6 +52,7 @@ class DevProcess { // task.addAlias() // task.addDevShape()//添加开发区围栏 +// task.matchDevTownship()//添加乡镇街道 } @@ -172,7 +173,7 @@ class DevProcess { def devSplitRoad(){ def i = 0; while(i<1){ - def fileName = "/home/goojia/gj/hebei-${i}.xlsx" + def fileName = "/home/goojia/gj/qzd-${i}.xlsx" if(CommonDatautils.isWindow()){ fileName = "D:\\数据\\数据建设\\开发区\\江苏-无锡.xlsx" } @@ -660,6 +661,44 @@ class DevProcess { },0); } + + + def matchDevTownship(){ + ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\区域匹配开发区.xlsx",{d-> + if(d['C']){ + def q = new BasicDBObject() + q.put("name", d['C']) + def obj = development_zone_CONN.findOne(q) + if(obj){ + d['E'] = obj._id.toString() + def street = d['D'] + q.put("township", street) + def sameObj = DEV_MAPPING_CONN.findOne(q) + if(!sameObj){ + def udata = new BasicDBObject() + udata.put("province", obj.province) + if(obj.city){ + udata.put("city", obj.city) + } + if(obj.district){ + udata.put("district", obj.district) + } + + udata.put("name",obj.name) +// udata.put("type", "乡镇街道") +// udata.put("township", street) + + udata.put("type", "区域") + udata.put("dev_district", street) + udata.put("c_date",new Date()) + DEV_MAPPING_CONN.save(udata) + println obj.name +" "+street + } + } + } + },1); + } + def addAlias(){ ExcelUtils.modify("D:\\数据\\数据建设\\开发区\\开发区别名.xlsx",{d-> def q = new BasicDBObject() From 2c9fa258a2d321d0c144aa0e8744241b993cd31c Mon Sep 17 00:00:00 2001 From: gaojuan Date: Thu, 13 Jun 2024 10:58:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?19-=E3=80=8B93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/gj/district/FangjiaClientUtils.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy index 71132614c..0bdd0555f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/district/FangjiaClientUtils.groovy @@ -354,7 +354,7 @@ class FangjiaClientUtils { def content = null try { address = address.replace("{","") - def url = "http://192.168.0.19:31080/FangJiaNlpService/formatNinelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=false&addressAssessment=true" + def url = "http://192.168.0.93:8080/FangJiaNlpService/formatNinelevel?address="+URLEncoder.encode(address,"UTF-8")+"&complete=false&useMap=false&addressAssessment=true" if(city){ url = url +"&city="+URLEncoder.encode(city,"UTF-8") }