From 118e23a078932a344cbceccf3cedad3ec192b1c8 Mon Sep 17 00:00:00 2001 From: Jian Shen Date: Sat, 18 Jun 2022 21:00:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8=E6=8D=95?= =?UTF-8?q?=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dags/poi/business/district_bank.py | 76 ++++++++++++---------- dags/poi/business/district_bus.py | 74 ++++++++++++---------- dags/poi/business/district_supermarket.py | 77 +++++++++++++---------- 3 files changed, 129 insertions(+), 98 deletions(-) diff --git a/dags/poi/business/district_bank.py b/dags/poi/business/district_bank.py index 406d995..179c8f7 100644 --- a/dags/poi/business/district_bank.py +++ b/dags/poi/business/district_bank.py @@ -35,53 +35,63 @@ def find_around_by_location(city, location): :param location: :return: """ - bank_df = elastic_client.scan_to_data_frame('amap_poi', { - "_source": ["name"], - "query": { - "bool": { - "must_not": [ - { - "term": { - "status": { - "value": 1 + try: + bank_df = elastic_client.scan_to_data_frame('amap_poi', { + "_source": ["name"], + "query": { + "bool": { + "must_not": [ + { + "term": { + "status": { + "value": 1 + } } } - } - ], - "filter": [ - {"terms": { - "typecode": bank_typecode - }}, - { - "term": { - "cityname": { - "value": city + ], + "filter": [ + {"terms": { + "typecode": bank_typecode + }}, + { + "term": { + "cityname": { + "value": city + } + } + }, + { + "geo_distance": { + "distance": 1000, + "location": location } } - }, - { - "geo_distance": { - "distance": 1000, - "location": location - } - } - ] + ] + } } - } - }); - if len(bank_df) > 0: - return bank_df['name'].tolist() - return [] - + }); + if len(bank_df) > 0: + return bank_df['name'].tolist() + return [] + except Exception as e: + print(e) + return [] def deal(city, lng, lat): location = [lng, lat] bank_df = find_around_by_location(city, location) return bank_df +### 临时后续注释 +after_dongguan = False + for city_item in city_dict: city = city_item['display'] log.info('开始查找' + city + '周边银行') + if city == '东莞': + after_dongguan = True + if not after_dongguan: + continue seaweed_df = pd.DataFrame(list(seaweed_conn.find({'city': city, 'cat': 'district', 'status': 0, 'lng': {'$ne': None}}, {'city': 1, 'region': 1, 'name': 1, 'lng': 1, 'lat': 1}).batch_size(10000))) seaweed_df['lng'] = seaweed_df['lng'] / 10 ** 10 diff --git a/dags/poi/business/district_bus.py b/dags/poi/business/district_bus.py index 50f4cda..9065266 100644 --- a/dags/poi/business/district_bus.py +++ b/dags/poi/business/district_bus.py @@ -27,43 +27,47 @@ def find_around_by_location(city, location): :param location: :return: """ - bus_df = elastic_client.scan_to_data_frame('amap_poi', { - "_source": ["name"], - "query": { - "bool": { - "must_not": [ - { - "term": { - "status": { - "value": 1 + try: + bus_df = elastic_client.scan_to_data_frame('amap_poi', { + "_source": ["name"], + "query": { + "bool": { + "must_not": [ + { + "term": { + "status": { + "value": 1 + } } } - } - ], - "filter": [ - {"terms": { - "typecode": bus_typecode - }}, - { - "term": { - "cityname": { - "value": city + ], + "filter": [ + {"terms": { + "typecode": bus_typecode + }}, + { + "term": { + "cityname": { + "value": city + } + } + }, + { + "geo_distance": { + "distance": 1000, + "location": location } } - }, - { - "geo_distance": { - "distance": 1000, - "location": location - } - } - ] + ] + } } - } - }); - if len(bus_df) > 0: - return bus_df['name'].tolist() - return [] + }); + if len(bus_df) > 0: + return bus_df['name'].tolist() + return [] + except Exception as e: + print(e) + return [] def deal(city, lng, lat): @@ -71,10 +75,16 @@ def deal(city, lng, lat): bus_df = find_around_by_location(city, location) return bus_df +### 临时后续注释 +after_dongguan = False for city_item in city_dict: city = city_item['display'] log.info('开始查找' + city + '周边交通') + if city == '东莞': + after_dongguan = True + if not after_dongguan: + continue seaweed_df = pd.DataFrame(list(seaweed_conn.find({'city': city, 'cat': 'district', 'status': 0, 'lng': {'$ne': None}}, {'city': 1, 'region': 1, 'name': 1, 'lng': 1, 'lat': 1}).batch_size( 10000))) diff --git a/dags/poi/business/district_supermarket.py b/dags/poi/business/district_supermarket.py index 665e99f..55d4871 100644 --- a/dags/poi/business/district_supermarket.py +++ b/dags/poi/business/district_supermarket.py @@ -27,44 +27,48 @@ def find_around_by_location(city, location): :param location: :return: """ - supermarket_df = elastic_client.scan_to_data_frame('amap_poi', { - "_source": ["name"], - "query": { - "bool": { - "must_not": [ - { - "term": { - "status": { - "value": 1 + try: + supermarket_df = elastic_client.scan_to_data_frame('amap_poi', { + "_source": ["name"], + "query": { + "bool": { + "must_not": [ + { + "term": { + "status": { + "value": 1 + } } } - } - ], - "filter": [ - {"terms": { - "typecode": supermarket_typecode - }}, - { - "term": { - "cityname": { - "value": city + ], + "filter": [ + {"terms": { + "typecode": supermarket_typecode + }}, + { + "term": { + "cityname": { + "value": city + } + } + }, + { + "geo_distance": { + "distance": 1000, + "location": location } } - }, - { - "geo_distance": { - "distance": 1000, - "location": location - } - } - ] + ] + } } - } - }); - if len(supermarket_df) > 0: - return supermarket_df['name'].tolist() - return [] - + }); + if len(supermarket_df) > 0: + return supermarket_df['name'].tolist() + return [] + except Exception as e: + print(e) + print(location) + return [] def deal(city, lng, lat): location = [lng, lat] @@ -72,9 +76,16 @@ def deal(city, lng, lat): return supermarket_df +### 临时后续注释 +after_dongguan = False + for city_item in city_dict: city = city_item['display'] log.info('开始查找' + city + '周边商场') + if city == '东莞': + after_dongguan = True + if not after_dongguan: + continue seaweed_df = pd.DataFrame(list(seaweed_conn.find({'city': city, 'cat': 'district', 'status': 0, 'lng': {'$ne': None}}, {'city': 1, 'region': 1, 'name': 1, 'lng': 1, 'lat': 1}).batch_size( 10000)))