diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/dingding/DingTalkUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/dingding/DingTalkUtils.groovy index 209ab9fe2..795b1556a 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/dingding/DingTalkUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/dingding/DingTalkUtils.groovy @@ -12,7 +12,7 @@ import com.fangjia.script.util.DateUtils class DingTalkUtils { static main(String[] args) { - Date now = DateUtils.parseFromTightByPattern("2021-07-01", "yyyy-MM-dd") ; + Date now = DateUtils.parseFromTightByPattern("2021-08-01", "yyyy-MM-dd") ; String startTime = DateUtils.addMonth(now, -1) + " 00:00:00" String monthStartTime = DateUtils.formatDateByPattern(now, "yyyy-MM-dd HH:mm:ss") diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy index 1f5f696cf..71d8c3bec 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/CommitteeLatLng.groovy @@ -1,5 +1,6 @@ package com.fangjia.script.temp.shenjian.poi +import com.fangjia.script.statistics.poi.AmapPoi import com.fangjia.script.temp.shenjian.util.GaoDeUtils import com.fangjia.script.util.MongoUtils import com.mongodb.BasicDBObject @@ -18,7 +19,7 @@ import java.util.concurrent.Executors class CommitteeLatLng { static DBCollection villagesConn = MongoUtils.getCollectionByName("fangjia", "villages", "192.168.0.43", 28017) - static ExecutorService executorService = Executors.newFixedThreadPool(30) + static ExecutorService executorService = Executors.newFixedThreadPool(1) static void main(String[] args) { dealPoi(new BasicDBObject("status_location", new BasicDBObject('$ne', 0))) @@ -37,12 +38,16 @@ class CommitteeLatLng { city = obj.province_name } def address = obj.province_name + city + obj.area_name + obj.street_name + obj.name; - def location = GaoDeUtils.parserByGaode(city, address); - if (location && location.lng) { - def lng = Double.valueOf(location.lng) - def lat = Double.valueOf(location.lat) + // 不准确 + // def location = GaoDeUtils.parserByGaode(city, address); + List amapPoi = GaoDeUtils.searchPoi(city, address, obj.area_name, "130106|130105|130104") + if (amapPoi && amapPoi.size() > 0) { + def poi = amapPoi[0] + String[] locations = poi.location.split(",") + def lng = Double.valueOf(locations[0]) + def lat = Double.valueOf(locations[1]) villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 0) - .append("location", new BasicDBObject("lat", lat).append("lon", lng)).append("flag_location", "已获取经纬度"))) + .append("location", new BasicDBObject("lat", lat).append("lon", lng)).append("flag_location", "关键字搜索获取经纬度"))) } else { villagesConn.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status_location", 2).append("flag_location", "经纬度为空"))) } diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy index 5334643d3..8496f3f01 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy @@ -128,9 +128,9 @@ class GaoDeUtils { while (result.size() < count) { params.page = "${page}".toString() page++ - JSONObject json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/around", params); + JSONObject json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v5/place/around", params); if (json == null) { - json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/around", params); + json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v5/place/around", params); } if (json && json.info && json.info == "OK") { count = json.getString("count").toInteger() @@ -169,11 +169,13 @@ class GaoDeUtils { /** * 查找关键字经纬度 */ - static List searchPoi(String city, String keywords){ + static List searchPoi(String city, String keywords, String region, String typecodes){ def params = [:] params.key = GAO_DE_AK[keyUsed.intValue()] params.keywords = keywords params.city = city + params.region = region + params.types = typecodes params.put("extensions", "all") params.put("citylimit","true") params.put("offset","20") @@ -184,9 +186,9 @@ class GaoDeUtils { while (result.size() < count) { params.page = "${page}".toString() page++ - JSONObject json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/text", params); + JSONObject json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v5/place/text", params); if (json == null) { - json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/text", params); + json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v5/place/text", params); } if (json && json.info && json.info == "OK") { count = json.getString("count").toInteger()