diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy index d8ee85b0c..0feaa0b5e 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/gj/data_handle/TownStandardBatch.groovy @@ -36,7 +36,7 @@ class TownStandardBatch extends BaseBatch{ def fullCityMap = CommonDatautils.queryFullNameCity() def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity() def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity() - public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(100) + public static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(20) def updateList = [] def addAliasList = [] diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy index f4801828f..60dc4ddb2 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/yinjihaun/amap/GaoDeApiUtils.groovy @@ -12,6 +12,7 @@ import org.jsoup.Jsoup import java.util.zip.GZIPInputStream class GaoDeApiUtils { + //94c74c60e102972a8d17b7b75d7403be def static GAO_DE_AK = "94c74c60e102972a8d17b7b75d7403be" //±¦½£:c6fcd4bfbc40d73ee762b8115dca3390 //15021384995£ºdfc2245bac8a7b2d5b62e060e59d4eca @@ -29,15 +30,28 @@ class GaoDeApiUtils { params.put("location", location) params.put("extensions","all") String content - try { - content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") - } catch (Exception e) { - content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") - } - JSONObject jsonObj = JSONObject.fromObject(content) - if(jsonObj.status!="1"){ - println jsonObj + def stop = true + JSONObject jsonObj = null + def errorCount = 1 + while (stop){ + try { + content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + } catch (Exception e) { + content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8") + } + jsonObj = JSONObject.fromObject(content) + if(jsonObj.status!="1"){ + println jsonObj + errorCount ++ + Thread.sleep(3000) + if(errorCount>3){ + stop = false + } + }else{ + stop = false + } } + return jsonObj }