From 9194dfa8d9cc002102ddbeb97a4b169c2fabec0f Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Fri, 2 Sep 2022 16:58:22 +0800 Subject: [PATCH 1/8] =?UTF-8?q?poi=E6=9F=A5=E8=AF=A2=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../temp/shenjian/poi/SeaweedAroundPoi.groovy | 18 ++++++++++-------- .../temp/shenjian/util/GaoDeUtils.groovy | 2 +- .../script/statistics/poi/AmapPoiDetail.java | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 10 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 f3c36ebd8..23b734e2e 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 @@ -29,13 +29,13 @@ class SeaweedAroundPoi extends BaseBatch { static DBCollection conn136 = MongoUtils.getCollectionByName("fangjia", "seaweed_poi_sync", "192.168.0.136", 27017) static final def URL = "http://192.168.0.100:38080/FangJiaDataService/saveAmapPoi" - static ExecutorService executorService = Executors.newFixedThreadPool(30) + //static ExecutorService executorService = Executors.newFixedThreadPool(2) static void main(String[] args) { def types = listAllType() //dealSpecialSeaweedAround(types) dealPoi(new BasicDBObject(), types) - executorService.shutdown() + //executorService.shutdown() } /** @@ -67,9 +67,9 @@ class SeaweedAroundPoi extends BaseBatch { query.put("status", 1) conn136.find(query).batchSize(5000).each {objTemp -> final def obj = objTemp - executorService.submit(new Runnable() { - @Override - void run() { +// executorService.submit(new Runnable() { +// @Override +// void run() { def city = obj.city def lng = obj.lng def lat = obj.lat @@ -81,10 +81,11 @@ class SeaweedAroundPoi extends BaseBatch { } else { conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status", 2).append("flag", "周边POI为空"))) } + Thread.sleep(500) println("已处理小区:" + obj) } - }) - } +// }) +// } } static getNewSeaweed() { @@ -163,7 +164,7 @@ class SeaweedAroundPoi extends BaseBatch { public static final Map KEYWORDS_MAP = new HashMap() { { - put("餐饮", "05"); + //put("餐饮", "05"); // put("地铁", "150500"); // put("公交", "1507"); // put("医院", "090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211"); @@ -174,6 +175,7 @@ class SeaweedAroundPoi extends BaseBatch { // put("商场", "0601"); // put("餐饮", "0501|0502|0503|0504"); // put("旅游景点", "110000"); + put("公园广场", "110100|110101|110102|110103|110104|110105") // put("图书馆", "140500"); // put("政府机关", "130100|130101|130102|130103|130104|130105|130106|130107"); // put("丧葬设施", "071900|071901|071902|071903") 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 f08b96c89..1ab50a6ec 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 @@ -258,7 +258,7 @@ class GaoDeUtils { } if (json && json.info && json.info == "OK") { try { - List ret = JSONObject.parseArray(json.pois.toString(), AmapPoi.class) + List ret = JSONObject.parseArray(json.pois.toString(), AmapPoiDetail.class) return ret } catch(Exception ex) { ex.printStackTrace() diff --git a/projects/fangjia-script/src/main/java/com/fangjia/script/statistics/poi/AmapPoiDetail.java b/projects/fangjia-script/src/main/java/com/fangjia/script/statistics/poi/AmapPoiDetail.java index 8192b359c..14922257d 100644 --- a/projects/fangjia-script/src/main/java/com/fangjia/script/statistics/poi/AmapPoiDetail.java +++ b/projects/fangjia-script/src/main/java/com/fangjia/script/statistics/poi/AmapPoiDetail.java @@ -50,6 +50,21 @@ public class AmapPoiDetail { private BizExtDTO bizExt; @com.alibaba.fastjson.annotation.JSONField(name = "photos") private List photos; + @com.alibaba.fastjson.annotation.JSONField(name = "business") + private BusinessDTO business; + + @lombok.NoArgsConstructor + @lombok.Data + public static class BusinessDTO { + @com.alibaba.fastjson.annotation.JSONField(name = "business_area") + private String businessArea; + @com.alibaba.fastjson.annotation.JSONField(name = "keytag") + private String keytag; + @com.alibaba.fastjson.annotation.JSONField(name = "opentime_today") + private String opentimeToday; + @com.alibaba.fastjson.annotation.JSONField(name = "opentime_week") + private String opentimeWeek; + } @lombok.NoArgsConstructor @lombok.Data @@ -64,7 +79,7 @@ public class AmapPoiDetail { @lombok.Data public static class PhotosDTO { @com.alibaba.fastjson.annotation.JSONField(name = "title") - private List title; + private String title; @com.alibaba.fastjson.annotation.JSONField(name = "url") private String url; } From 44d482859b29a1253bd50ea8c62b02908cde386f Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Mon, 5 Sep 2022 16:57:58 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A5=BC=E7=9B=98?= =?UTF-8?q?=E8=AF=84=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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 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..b219b0a32 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", 27017) static final def URL = "http://192.168.0.100:38080/FangJiaDataService/saveAmapPoi" //static ExecutorService executorService = Executors.newFixedThreadPool(2) @@ -92,6 +93,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 +167,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") From e644aa58abcd70279b1dac15010023a2244e730f Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Mon, 5 Sep 2022 16:57:58 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A5=BC=E7=9B=98?= =?UTF-8?q?=E8=AF=84=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") From 7dd0e59f2f3d0d4cdecfed0bc905bb44827586ee Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Mon, 5 Sep 2022 17:13:01 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=94=B9=E4=B8=BAv3=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E8=BF=94=E5=9B=9Ecount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/temp/shenjian/util/GaoDeUtils.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 1ab50a6ec..28f35f1ee 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 @@ -146,11 +146,11 @@ class GaoDeUtils { while (result.size() < count) { params.page = "${page}".toString() page++ - params.key = this.getGaodeKey("v5/place/around") - JSONObject json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v5/place/around", params); + params.key = this.getGaodeKey("v3/place/around") + JSONObject json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/around", params); if (json == null) { - params.key = this.getGaodeKey("v5/place/around") - json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v5/place/around", params); + params.key = this.getGaodeKey("v3/place/around") + json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/around", params); } if (json && json.info && json.info == "OK") { count = json.getString("count").toInteger() From db64d086f14e731a5b7f05b9230759b36eadd274 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Mon, 5 Sep 2022 19:40:42 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A4=90=E9=A5=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy | 5 ++--- 1 file changed, 2 insertions(+), 3 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 5737fa3dd..7759a5da9 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 @@ -83,7 +83,6 @@ class SeaweedAroundPoi extends BaseBatch { } else { conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status", 2).append("flag", "周边POI为空"))) } - Thread.sleep(500) println("已处理小区:" + obj) } } @@ -169,7 +168,7 @@ class SeaweedAroundPoi extends BaseBatch { public static final Map KEYWORDS_MAP = new HashMap() { { - put("餐饮", "05"); + //put("餐饮", "05"); put("地铁", "150500"); put("公交", "1507"); put("医院", "090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211"); @@ -178,7 +177,7 @@ class SeaweedAroundPoi extends BaseBatch { // put("银行", "1601|1603"); put("大型超市", "0604"); put("商场", "0601"); -// put("餐饮", "0501|0502|0503|0504"); + put("餐饮", "0501|0502|0503|0504"); // put("旅游景点", "110000"); put("公园广场", "110100|110101|110102|110103|110104|110105") // put("图书馆", "140500"); From 21a0cd05bae94a11042254c54b36bce2fef07ad6 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Tue, 6 Sep 2022 11:36:47 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=A2=9E=E5=A4=A7=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fangjia/script/temp/shenjian/poi/SeaweedAroundPoi.groovy | 4 ++-- .../com/fangjia/script/temp/shenjian/util/GaoDeUtils.groovy | 2 ++ 2 files changed, 4 insertions(+), 2 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 7759a5da9..4020ce8af 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 @@ -66,7 +66,7 @@ class SeaweedAroundPoi extends BaseBatch { static dealPoi(DBObject query, def types) { query.put("status", 1) - conn136.find(query).batchSize(5000).each {objTemp -> + conn136.find(query).batchSize(5000).limit(20000).each {objTemp -> final def obj = objTemp // executorService.submit(new Runnable() { // @Override @@ -177,7 +177,7 @@ class SeaweedAroundPoi extends BaseBatch { // put("银行", "1601|1603"); put("大型超市", "0604"); put("商场", "0601"); - put("餐饮", "0501|0502|0503|0504"); + //put("餐饮", "0501|0502|0503|0504"); // put("旅游景点", "110000"); put("公园广场", "110100|110101|110102|110103|110104|110105") // put("图书馆", "140500"); 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 28f35f1ee..0aa5d9ce5 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 @@ -147,9 +147,11 @@ class GaoDeUtils { params.page = "${page}".toString() page++ params.key = this.getGaodeKey("v3/place/around") + params.offset = "100" JSONObject json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/around", params); if (json == null) { params.key = this.getGaodeKey("v3/place/around") + params.offset = "100" json = HttpRequestUtil.getJsonContent("http://restapi.amap.com/v3/place/around", params); } if (json && json.info && json.info == "OK") { From 6008bc55b08eea776da6ef837db1b148fcb7bfb9 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Thu, 8 Sep 2022 21:02:53 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=AD=A6=E6=A0=A1?= =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../temp/shenjian/poi/FillLngLat.groovy | 27 +++++++++++++++ .../temp/shenjian/poi/SeaweedAroundPoi.groovy | 33 ++++++++++--------- 2 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy new file mode 100644 index 000000000..cf23c1fec --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy @@ -0,0 +1,27 @@ +package com.fangjia.script.temp.shenjian.poi + +import com.alibaba.fastjson.JSONObject +import com.fangjia.script.temp.shenjian.util.EsUtils +import com.fangjia.script.temp.shenjian.util.GaoDeUtils +import com.fangjia.script.util.ElasticUtils + +/** + * 补充学校经纬度 + * @author shenjian + * @since 2022/9/8 + */ +class FillLngLat { + + static void main(String[] args) { + ElasticUtils.executeSqlQuery("select * from dws_poi where location is null", { data -> + println(data) + def lngLat = GaoDeUtils.parserByGaode(data.city, data.region + data.name + data.address) + if (lngLat.size() == 2 ) { + JSONObject jsonObject = new JSONObject() + jsonObject.put("lon", Double.valueOf(lngLat['lng'])) + jsonObject.put("lat", Double.valueOf(lngLat['lat'])) + EsUtils.bulkUpdateFieldByIds("dws_poi", "location", jsonObject, Arrays.asList(data.source_id)) + } + }) + } +} 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 4020ce8af..147d08336 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 @@ -65,23 +65,26 @@ class SeaweedAroundPoi extends BaseBatch { } static dealPoi(DBObject query, def types) { - query.put("status", 1) - conn136.find(query).batchSize(5000).limit(20000).each {objTemp -> + query.put("canyin_status", 0) + conn136.find(query).batchSize(5000).limit(20000).noCursorTimeout(true).each {objTemp -> final def obj = objTemp // executorService.submit(new Runnable() { // @Override // void run() { def city = obj.city if (obj.lng) { - def lng = SeaweedUtils.formatLatLng(obj.lng) - def lat = SeaweedUtils.formatLatLng(obj.lat) + //def lng = SeaweedUtils.formatLatLng(obj.lng) + //def lat = SeaweedUtils.formatLatLng(obj.lat) + // {'lon': 121.810877, 'lat': 31.737642} + def lng = 121.810877 + def lat = 31.737642 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"))) + conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("canyin_status", 0).append("flag", "已获取周边POI"))) } else { - conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("status", 2).append("flag", "周边POI为空"))) + conn136.update(new BasicDBObject("_id", obj._id), new BasicDBObject('$set', new BasicDBObject("canyin_status", 2).append("flag", "周边POI为空"))) } println("已处理小区:" + obj) } @@ -168,18 +171,18 @@ 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("餐饮", "0501|0502|0503|0504"); +// put("大型超市", "0604"); +// put("商场", "0601"); + put("餐饮", "0501|0502|0503|0504"); // put("旅游景点", "110000"); - put("公园广场", "110100|110101|110102|110103|110104|110105") +// put("公园广场", "110100|110101|110102|110103|110104|110105") // put("图书馆", "140500"); // put("政府机关", "130100|130101|130102|130103|130104|130105|130106|130107"); // put("丧葬设施", "071900|071901|071902|071903") From 7076c00dcaf093dbdab73cb9a05066f19790511b Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Thu, 8 Sep 2022 21:06:50 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=AD=A6=E6=A0=A1?= =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy index cf23c1fec..d114be591 100644 --- a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/poi/FillLngLat.groovy @@ -16,7 +16,7 @@ class FillLngLat { ElasticUtils.executeSqlQuery("select * from dws_poi where location is null", { data -> println(data) def lngLat = GaoDeUtils.parserByGaode(data.city, data.region + data.name + data.address) - if (lngLat.size() == 2 ) { + if (lngLat != null && lngLat.size() == 2 ) { JSONObject jsonObject = new JSONObject() jsonObject.put("lon", Double.valueOf(lngLat['lng'])) jsonObject.put("lat", Double.valueOf(lngLat['lat']))