物业费添加分数

This commit is contained in:
shenjian@fangjia.com
2023-03-29 11:34:57 +08:00
parent b41c78fef4
commit e0e18e5d36
@@ -34,7 +34,7 @@ def save_fix(community_summary_df):
if 'estate_charge_fix' not in community_summary_df.columns: if 'estate_charge_fix' not in community_summary_df.columns:
log.info("该城市无调整物业费") log.info("该城市无调整物业费")
return return
df = community_summary_df[['_id', 'city', 'estate_charge_fix']] df = community_summary_df[['_id', 'city', 'estate_charge_fix', 'estate_charge_score']]
df = df.dropna(subset=['estate_charge_fix']) df = df.dropna(subset=['estate_charge_fix'])
actions = list() actions = list()
count = 0 count = 0
@@ -45,6 +45,7 @@ def save_fix(community_summary_df):
row = dict() row = dict()
_id = str(item["_id"]) _id = str(item["_id"])
row['estate_charge_fix'] = item['estate_charge_fix'] row['estate_charge_fix'] = item['estate_charge_fix']
row['credit_detail'] = {'estate_charge_score': int(item['estate_charge_score'])}
row['m_date'] = m_date row['m_date'] = m_date
action = {'_op_type': 'update', action = {'_op_type': 'update',
@@ -72,7 +73,7 @@ def save_fill(community_summary_df):
if 'estate_charge' not in community_summary_df.columns: if 'estate_charge' not in community_summary_df.columns:
log.info("该城市无补充物业费") log.info("该城市无补充物业费")
return return
df = community_summary_df[['_id', 'city', 'estate_charge']] df = community_summary_df[['_id', 'city', 'estate_charge', 'estate_charge_score']]
df = df.dropna(subset=['estate_charge']) df = df.dropna(subset=['estate_charge'])
actions = list() actions = list()
count = 0 count = 0
@@ -83,6 +84,7 @@ def save_fill(community_summary_df):
row = dict() row = dict()
_id = str(item["_id"]) _id = str(item["_id"])
row['estate_charge'] = item['estate_charge'] row['estate_charge'] = item['estate_charge']
row['credit_detail'] = {'estate_charge_score': int(item['estate_charge_score'])}
# 1 表示为物业费补充的,在实际应用中不输出 # 1 表示为物业费补充的,在实际应用中不输出
row['estate_charge_flag'] = 1 row['estate_charge_flag'] = 1
row['m_date'] = m_date row['m_date'] = m_date
@@ -188,10 +190,11 @@ def deal_adjust(community):
max_now = estate_charge_city_region_dict[city_short]['max'] max_now = estate_charge_city_region_dict[city_short]['max']
if community['estate_charge'] > max_now: if community['estate_charge'] > max_now:
estate_charge = find_estate_charge_for_adjust(community, max_now) estate_charge, score = find_estate_charge_for_adjust(community, max_now)
if pd.notna(estate_charge): if pd.notna(estate_charge):
mutex.acquire(timeout=60) mutex.acquire(timeout=60)
community['estate_charge_fix'] = estate_charge community['estate_charge_fix'] = estate_charge
community['estate_charge_score'] = score
mutex.release() mutex.release()
def adjust_estate_charge(city_now): def adjust_estate_charge(city_now):
@@ -223,16 +226,21 @@ def find_estate_charge_for_adjust(community, max_now):
docs = find_nearest_by_location(community['city'], location) docs = find_nearest_by_location(community['city'], location)
if len(docs) <= 0 or 'estate_charge' not in docs.columns: if len(docs) <= 0 or 'estate_charge' not in docs.columns:
return estate_charge return estate_charge
# 记录打分
score = None
if pd.notna(community['finish_building_date']) and 'finish_building_date' in docs.columns: if pd.notna(community['finish_building_date']) and 'finish_building_date' in docs.columns:
# 根据相近建筑年代赋值 # 根据相近建筑年代赋值
estate_charge = get_estate_charge_for_adjust(community['finish_building_date'], docs) estate_charge = get_estate_charge_for_adjust(community['finish_building_date'], docs)
score = 9
if pd.isna(estate_charge) or estate_charge > max_now: if pd.isna(estate_charge) or estate_charge > max_now:
# 取周边均值 # 取周边均值
estate_charge = docs['estate_charge'].mean() estate_charge = docs['estate_charge'].mean()
score = 8
# 如果查找的还大于分位值,不调整 # 如果查找的还大于分位值,不调整
if estate_charge > max_now: if estate_charge > max_now:
estate_charge = None estate_charge = None
return estate_charge score = None
return estate_charge, score
def find_estate_charge(community, max_now): def find_estate_charge(community, max_now):
""" """
@@ -249,15 +257,19 @@ def find_estate_charge(community, max_now):
docs['estate_charge_fix'] = None docs['estate_charge_fix'] = None
# 用修正后的物业费补充 # 用修正后的物业费补充
docs['estate_charge_fix'].fillna(docs['estate_charge'], inplace=True) docs['estate_charge_fix'].fillna(docs['estate_charge'], inplace=True)
score = None
if pd.notna(community['finish_building_date']) and 'finish_building_date' in docs.columns: if pd.notna(community['finish_building_date']) and 'finish_building_date' in docs.columns:
# 根据相近建筑年代赋值 # 根据相近建筑年代赋值
estate_charge = get_estate_charge(community['finish_building_date'], docs) estate_charge = get_estate_charge(community['finish_building_date'], docs)
score = 7
if pd.isna(estate_charge) or estate_charge > max_now: if pd.isna(estate_charge) or estate_charge > max_now:
# 取周边均值 # 取周边均值
estate_charge = docs['estate_charge_fix'].mean() estate_charge = docs['estate_charge_fix'].mean()
score = 6
if estate_charge > max_now: if estate_charge > max_now:
estate_charge = None estate_charge = None
return estate_charge score = None
return estate_charge, score
find_count = 0 find_count = 0
def deal_fill(community): def deal_fill(community):
@@ -276,10 +288,11 @@ def deal_fill(community):
if community['estate_type'] == '别墅': if community['estate_type'] == '别墅':
# 别墅不限制物业费最大值 # 别墅不限制物业费最大值
max_now = 99 max_now = 99
estate_charge = find_estate_charge(community, max_now) estate_charge, score = find_estate_charge(community, max_now)
if pd.notna(estate_charge): if pd.notna(estate_charge):
mutex.acquire(timeout=60) mutex.acquire(timeout=60)
community["estate_charge"] = estate_charge community["estate_charge"] = estate_charge
community["estate_charge_score"] = score
mutex.release() mutex.release()
def fill_estate_charge(city_now): def fill_estate_charge(city_now):