多线程降低
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ class TownStandardBatch extends BaseBatch{
|
|||||||
def fullCityMap = CommonDatautils.queryFullNameCity()
|
def fullCityMap = CommonDatautils.queryFullNameCity()
|
||||||
def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity()
|
def regionMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionNameByCity()
|
||||||
def regionFullNameMap = com.fangjia.script.commData.CommonDatautils.queryAllRegionFullNameByCity()
|
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 updateList = []
|
||||||
def addAliasList = []
|
def addAliasList = []
|
||||||
|
|||||||
+22
-8
@@ -12,6 +12,7 @@ import org.jsoup.Jsoup
|
|||||||
import java.util.zip.GZIPInputStream
|
import java.util.zip.GZIPInputStream
|
||||||
|
|
||||||
class GaoDeApiUtils {
|
class GaoDeApiUtils {
|
||||||
|
//94c74c60e102972a8d17b7b75d7403be
|
||||||
def static GAO_DE_AK = "94c74c60e102972a8d17b7b75d7403be" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390
|
def static GAO_DE_AK = "94c74c60e102972a8d17b7b75d7403be" //宝剑:c6fcd4bfbc40d73ee762b8115dca3390
|
||||||
//15021384995:dfc2245bac8a7b2d5b62e060e59d4eca
|
//15021384995:dfc2245bac8a7b2d5b62e060e59d4eca
|
||||||
|
|
||||||
@@ -29,15 +30,28 @@ class GaoDeApiUtils {
|
|||||||
params.put("location", location)
|
params.put("location", location)
|
||||||
params.put("extensions","all")
|
params.put("extensions","all")
|
||||||
String content
|
String content
|
||||||
try {
|
def stop = true
|
||||||
content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8")
|
JSONObject jsonObj = null
|
||||||
} catch (Exception e) {
|
def errorCount = 1
|
||||||
content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8")
|
while (stop){
|
||||||
}
|
try {
|
||||||
JSONObject jsonObj = JSONObject.fromObject(content)
|
content = new HttpRequest().get("http://restapi.amap.com/v3/geocode/regeo", params, "utf-8")
|
||||||
if(jsonObj.status!="1"){
|
} catch (Exception e) {
|
||||||
println jsonObj
|
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
|
return jsonObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user