diff --git a/dags/poi/business/district_bank.py b/dags/poi/business/district_bank.py index 11e4883..406d995 100644 --- a/dags/poi/business/district_bank.py +++ b/dags/poi/business/district_bank.py @@ -39,7 +39,16 @@ def find_around_by_location(city, location): "_source": ["name"], "query": { "bool": { - "must": [ + "must_not": [ + { + "term": { + "status": { + "value": 1 + } + } + } + ], + "filter": [ {"terms": { "typecode": bank_typecode }}, @@ -50,15 +59,6 @@ def find_around_by_location(city, location): } } }, - { - "term": { - "status": { - "value": 0 - } - } - } - ], - "filter": [ { "geo_distance": { "distance": 1000, @@ -75,19 +75,15 @@ def find_around_by_location(city, location): def deal(city, lng, lat): - if lng != None: - location = [lng, lat] - bank_df = find_around_by_location(city, location) - return bank_df - return [] - + location = [lng, lat] + bank_df = find_around_by_location(city, location) + return bank_df for city_item in city_dict: city = city_item['display'] log.info('开始查找' + city + '周边银行') - seaweed_df = pd.DataFrame(list(seaweed_conn.find({'city': city, 'cat': 'district', 'status': 0}, - {'city': 1, 'region': 1, 'name': 1, 'lng': 1, 'lat': 1}).batch_size( - 10000))) + 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 seaweed_df['lat'] = seaweed_df['lat'] / 10 ** 10 seaweed_df['bank'] = seaweed_df.apply(lambda x: deal(x['city'], x['lng'], x['lat']), axis=1) diff --git a/dags/poi/business/district_bus.py b/dags/poi/business/district_bus.py index aae1ec7..50f4cda 100644 --- a/dags/poi/business/district_bus.py +++ b/dags/poi/business/district_bus.py @@ -31,7 +31,16 @@ def find_around_by_location(city, location): "_source": ["name"], "query": { "bool": { - "must": [ + "must_not": [ + { + "term": { + "status": { + "value": 1 + } + } + } + ], + "filter": [ {"terms": { "typecode": bus_typecode }}, @@ -42,15 +51,6 @@ def find_around_by_location(city, location): } } }, - { - "term": { - "status": { - "value": 0 - } - } - } - ], - "filter": [ { "geo_distance": { "distance": 1000, @@ -67,17 +67,15 @@ def find_around_by_location(city, location): def deal(city, lng, lat): - if lng != None: - location = [lng, lat] - bus_df = find_around_by_location(city, location) - return bus_df - return [] + location = [lng, lat] + bus_df = find_around_by_location(city, location) + return bus_df for city_item in city_dict: city = city_item['display'] log.info('开始查找' + city + '周边交通') - seaweed_df = pd.DataFrame(list(seaweed_conn.find({'city': city, 'cat': 'district', 'status': 0}, + 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