修改楼盘评级bug
This commit is contained in:
@@ -28,6 +28,7 @@ city_sell_stat_client = MAIN_MONGO_CLIENT.get_collection("fangjia_stat", "city_s
|
||||
sqmetre_rent_client = MAIN_MONGO_CLIENT.get_collection("fangjia", "sqmetre_rent")
|
||||
community_rate_client = MAIN_MONGO_CLIENT.get_collection("fangjia_stat", "community_rate")
|
||||
elastic_client = ElasticSearchClient(host="192.168.0.89", username='elastic', password='elasticsearch')
|
||||
administrative_mapping_client = MAIN_MONGO_CLIENT.get_collection("business", "administrative_mapping")
|
||||
# 定义楼盘评级级别数量
|
||||
COMM_RATING_LEVEL_COUNT = 5
|
||||
COMM_RATING_LEVEL_NAMES = {1: "S", 2: "A", 3: "B", 4: "C", 5: "D"}
|
||||
@@ -451,7 +452,9 @@ def comms_rating(data):
|
||||
data[f'{score_factor}'] = data[f'{score_factor}'].apply(lambda x: round(x * 100, 6))
|
||||
return data
|
||||
|
||||
city_code_map = {"深圳": '440300', "临沂" : "371300"}
|
||||
city_code_map = {}
|
||||
for doc in administrative_mapping_client.find({"type":"城市"}, {"city_short" :1, "mzb_city_code":1}):
|
||||
city_code_map[doc['city_short']] = doc['mzb_city_code']
|
||||
|
||||
def load_house_stat(city, calc_year_month):
|
||||
end_year_month = int(dateutils.format_date(dateutils.add_months(dateutils.parse_date(str(calc_year_month), "%Y%m"), months=1), "%Y%m"))
|
||||
@@ -566,6 +569,8 @@ def process_city(args):
|
||||
updater.bulk_insert_or_update_by_id(df_simple, id_fields=['comm_id', 'date'], dtype=dtype)
|
||||
logger.info(f"楼盘评级计算结束:{city}")
|
||||
except Exception as e:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
logging.error(f"{city}楼盘评级计算失败;{e}")
|
||||
|
||||
|
||||
@@ -582,7 +587,10 @@ if __name__ == '__main__':
|
||||
calc_year_months = [int(dateutils.format_date(dateutils.add_months(datetime.now(), months=-1), "%Y%m"))]
|
||||
else:
|
||||
calc_year_months = [int(calc_year_month.strip()) for calc_year_month in args.month.split(',') if calc_year_month.strip()]
|
||||
|
||||
# for city in cities:
|
||||
# args_list = [{"city": city, "calc_year_month": calc_year_month} for calc_year_month in calc_year_months]
|
||||
# for args in args_list:
|
||||
# process_city(args)
|
||||
with multiprocessing.Pool(processes=min(8, len(calc_year_months))) as pool:
|
||||
# for calc_year_month in calc_year_months:
|
||||
# args_list = [{"calc_year_month": calc_year_month, "city": city} for city in cities]
|
||||
|
||||
Reference in New Issue
Block a user