From e644aa58abcd70279b1dac15010023a2244e730f Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Mon, 5 Sep 2022 16:57:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A5=BC=E7=9B=98=E8=AF=84?= =?UTF-8?q?=E7=BA=A7POI=E9=87=8D=E6=8A=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../temp/shenjian/poi/SeaweedAroundPoi.groovy | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy index 23b734e2e..5737fa3dd 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy @@ -10,6 +10,7 @@ import com.fangjia.script.temp.shenjian.util.HttpUtils import com.fangjia.script.temp.shenjian.util.SeaweedUtils import com.fangjia.script.util.DbUtils import com.fangjia.script.util.MongoUtils +import com.mongodb.BasicDBList import com.mongodb.BasicDBObject import com.mongodb.DBCollection import com.mongodb.DBObject @@ -27,7 +28,7 @@ import java.util.concurrent.Executors @BatchOwner(Watcher.ShenJian) class SeaweedAroundPoi extends BaseBatch { - static DBCollection conn136 = MongoUtils.getCollectionByName("fangjia", "seaweed_poi_sync", "192.168.0.136", 27017) + static DBCollection conn136 = MongoUtils.getCollectionByName("fangjia", "seaweed_poi_sync", "192.168.0.235", 27018) static final def URL = "http://192.168.0.100:38080/FangJiaDataService/saveAmapPoi" //static ExecutorService executorService = Executors.newFixedThreadPool(2) @@ -71,18 +72,20 @@ class SeaweedAroundPoi extends BaseBatch { // @Override // void run() { def city = obj.city - def lng = obj.lng - def lat = obj.lat - List pois = GaoDeUtils.searchNearDtoByPoi(city, types, lng, lat, 1000, "") - if (CollectionUtils.isNotEmpty(pois)) { - String jsonStr = JSONObject.toJSONString(pois) - HttpUtils.postForJson(URL, jsonStr) - conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status", 0).append("flag", "已获取周边POI"))) - } else { - conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status", 2).append("flag", "周边POI为空"))) + if (obj.lng) { + def lng = SeaweedUtils.formatLatLng(obj.lng) + def lat = SeaweedUtils.formatLatLng(obj.lat) + List pois = GaoDeUtils.searchNearDtoByPoi(city, types, lng, lat, 1000, "") + if (CollectionUtils.isNotEmpty(pois)) { + String jsonStr = JSONObject.toJSONString(pois) + HttpUtils.postForJson(URL, jsonStr) + conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status", 0).append("flag", "已获取周边POI"))) + } else { + conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status", 2).append("flag", "周边POI为空"))) + } + Thread.sleep(500) + println("已处理小区:" + obj) } - Thread.sleep(500) - println("已处理小区:" + obj) } // }) // } @@ -92,6 +95,8 @@ class SeaweedAroundPoi extends BaseBatch { DBObject query = new BasicDBObject() query.put("cat", "district") query.put("visible", 0) + //query.put("city", new BasicDBObject('$in', ["连云港", "南通", "苏州", "无锡", "盐城", "扬州"])) + //query.put("city", "连云港") //query.put("_id", new ObjectId("50c96f82e4b0e15299cb018a")) DBObject filter = new BasicDBObject() @@ -164,15 +169,15 @@ class SeaweedAroundPoi extends BaseBatch { public static final Map KEYWORDS_MAP = new HashMap() { { - //put("餐饮", "05"); -// put("地铁", "150500"); -// put("公交", "1507"); -// put("医院", "090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211"); + put("餐饮", "05"); + put("地铁", "150500"); + put("公交", "1507"); + put("医院", "090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211"); // put("写字楼", "120201"); -// put("学校", "141200|141201|141202|141203|141204"); + put("学校", "141200|141201|141202|141203|141204"); // put("银行", "1601|1603"); -// put("大型超市", "0604"); -// put("商场", "0601"); + put("大型超市", "0604"); + put("商场", "0601"); // put("餐饮", "0501|0502|0503|0504"); // put("旅游景点", "110000"); put("公园广场", "110100|110101|110102|110103|110104|110105")