From 11cb97b03327686e4183a8b815f313fddbcbfa65 Mon Sep 17 00:00:00 2001 From: gaojuan Date: Tue, 16 Jan 2024 21:53:40 +0800 Subject: [PATCH] update --- .../com/fangjia/script/gj/OpenApiUtils.groovy | 1 + .../gj/location/GaoDeMapSearchTest.groovy | 5 ++- .../gj/village/communityLocation.groovy | 34 ++++++++++++++++++- .../gj/xiamen/SuggestionDataSynch.groovy | 21 +++++++----- 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy index 5fd8cdf21..7343a106d 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/OpenApiUtils.groovy @@ -674,6 +674,7 @@ class OpenApiUtils { static def financialRating(city, address){ def url = "http://open.fangjia.com/address/financialRating?city=${city}&address=${address}&token=F54F52381C49BB9EB4A33EB1B65604AE4B71A28AEE53518A94A2F360408B9056D57553931D15CE6DDE765562DAD286BA38E05A4CDAFC51C3D527A4959BF8E75A3B95DB7108FCEA340DDE61925616DB55118E1851E67D83EAD800460D100D6B667A4ED8EE67C8F7FB" String content = new HttpRequest().get(url, "utf-8"); + print(url) if(content){ def doc = new JsonSlurper().parseText(content) if(doc && doc.code ==0 && doc.result){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/GaoDeMapSearchTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/GaoDeMapSearchTest.groovy index adc26463e..7bfaf972f 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/GaoDeMapSearchTest.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/location/GaoDeMapSearchTest.groovy @@ -28,7 +28,10 @@ class GaoDeMapSearchTest { // task.mapSearch(path) // task.baiduMapSearch(path) // task.checkTrue(path) - task.addFinancialLevel(path) +// task.addFinancialLevel(path) + + def results = com.fangjia.script.gj.OpenApiUtils.financialRating("重庆", "凤中路193号") + println results } def addFinancialLevel(path){ diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/communityLocation.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/communityLocation.groovy index 614af517f..2fe850969 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/communityLocation.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/village/communityLocation.groovy @@ -10,24 +10,39 @@ def codeMap = [" //def region = "东城区" //def rets = OpenApiUtils.searchBaiDuMap(name, region, codeMap.get("北京").toInteger()); -filePath = "D:\\数据\\涉农\\无经纬度居委_0.xlsx" +filePath = "D:\\数据\\涉农\\无经纬度居委_5.xlsx" ExcelUtils.multiThreadingModify(filePath, {d-> if(!d['N']){ def city = d['D'] def region = d['F'] def name = d['J'] + def township = d['H'] def code = codeMap.get(city); if(!code){ code = codeMap.get(RegionData.formatCity(city)); } if(code){ def rets = OpenApiUtils.searchBaiDuMap(name, region, code.toInteger()); +// rets = sortResult(rets) + println name +" "+rets.size() for(def r : rets){ def bdname = r.name.replace("-","").replace("社区居民委员会","").replace('社区居委会','').replace('居民委员会','').replace('村民委员会','').replace('村委员会','').replace('村委会','').replace('居委会','') def newName = name.replace("-","").replace("社区居民委员会","").replace('社区居委会','').replace('居民委员会','').replace('村民委员会','').replace('村委员会','').replace('村委会','').replace('居委会','') + def stopFlag = false if(bdname == newName){ + stopFlag = true + }else if(bdname.endsWith("村")){ + if(bdname.equals(newName+"村")){ + stopFlag = true + }else{ + if(bdname.equals(township+newName+"村")){ + stopFlag = true + } + } + } + if(stopFlag){ d['N'] = DataUtil.getRound(6, r.lng) d['O'] = DataUtil.getRound(6, r.lat) d['P'] = r.estateType @@ -48,6 +63,23 @@ ExcelUtils.multiThreadingModify(filePath, {d-> }) +def sortResult(rets){ + rets.sort{a,b-> + def a1 = a.estateType + def b1 = b.estateType + def a1_score = a.score + if(a1.contains("政府机构")){ + a1_score = a1_score +1 + } + def b1_score = b.score + if(b1.contains("政府机构")){ + b1_score = b1_score +1 + } + return b1_score.compareTo(a1_score) + } + return rets +} + // //def code = codeMap.get("北京"); diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy index 883b7371b..acb7dc107 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/xiamen/SuggestionDataSynch.groovy @@ -59,14 +59,14 @@ class SuggestionDataSynch extends BaseBatch{ def run() { //"三明","宁德","泉州","厦门","福州","漳州","南平","龙岩","莆田","重庆" - def citys = CommonDatautils.findAllCity() + def citys = ["岳阳","湘潭","张家界","邵阳","南京","苏州","无锡","扬州","常州","徐州","镇江","南通","泰州","连云港","盐城","淮安","宿迁"]//CommonDatautils.findAllCity() def index = 0 fullCityMap = queryFullNameCity() mcaDistMap = queryDistNameCity() for (def c : citys) { def allRets = [] - if(["上海","北京","广州","深圳","成都","杭州","天津","西安","南京","沈阳","重庆","武汉","石家庄","福州","宁波","贵阳"].contains(c)){ + if(["上海","北京","广州","深圳","成都","杭州","天津","西安","南京","沈阳","重庆","武汉","石家庄","福州","宁波","贵阳","怀化","郴州","益阳","永州","娄底","湘西","长沙","常德","株洲","衡阳"].contains(c)){ continue; } index++ @@ -85,8 +85,8 @@ class SuggestionDataSynch extends BaseBatch{ allRets.addAll(ret3) allRets.addAll(ret4) - println index + " " + c + " 完成 "+ allRets.size() saveToMG(c, allRets) + println index + " " + c + " 完成 "+ allRets.size() } } @@ -96,7 +96,13 @@ class SuggestionDataSynch extends BaseBatch{ def data = fullCityMap.get(city) def q = new BasicDBObject("city", data.city) - def count = SUGGESTION_CONN.count(q) + def count = 0 + try{ + count = SUGGESTION_CONN.count(q) + }catch(e){ + SUGGESTION_CONN = MongoUtils.getCollectionByName2("fangjia", "suggestion", MONGO100_URL) + count = SUGGESTION_CONN.count(q) + } if(count>0){ SUGGESTION_CONN.remove(q) } @@ -227,7 +233,6 @@ class SuggestionDataSynch extends BaseBatch{ if(data){ def results = CommonDatautils.findAmapDetailBySql(data.city) def rets = createPoi(data.city, results, data, townMap) - println city +" 完成!" return rets; } return [] @@ -265,9 +270,9 @@ class SuggestionDataSynch extends BaseBatch{ map.source = "FJW" if(townshipMap && townshipMap.containsKey(dist.id)){ - def obj = townshipMap.get(dist.id) - if(obj){ - map.township = obj.township + def township = townshipMap.get(dist.id) + if(township){ + map.township = township } } if(!map.township){