修复物业费评级bug
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
物业费等级计算
|
物业费等级计算
|
||||||
"""
|
"""
|
||||||
from goojia_utils import ElasticSearchClient, nextcloudutils, dingutils
|
from goojia_utils import ElasticSearchClient, nextcloudutils, dingutils, areautils
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@@ -42,6 +42,21 @@ def gmm_train(total_rate, consumption_df, source, target):
|
|||||||
return consumption_df
|
return consumption_df
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def filter_min_max(city, community_summary_df):
|
||||||
|
"""
|
||||||
|
过滤极值
|
||||||
|
"""
|
||||||
|
if city in factor_dict:
|
||||||
|
community_summary_df.loc[
|
||||||
|
community_summary_df['estate_charge'] < factor_dict[city]['min_estate_charge'], 'estate_charge'] = \
|
||||||
|
factor_dict[city]['min_estate_charge']
|
||||||
|
community_summary_df.loc[
|
||||||
|
community_summary_df['estate_charge'] > factor_dict[city]['max_estate_charge'], 'estate_charge'] = \
|
||||||
|
factor_dict[city]['max_estate_charge']
|
||||||
|
return community_summary_df
|
||||||
|
|
||||||
|
|
||||||
def calc_estate_charge_rating(community_summary_df):
|
def calc_estate_charge_rating(community_summary_df):
|
||||||
"""
|
"""
|
||||||
计算物业费等级
|
计算物业费等级
|
||||||
@@ -84,30 +99,31 @@ def calc_estate_charge_rating(community_summary_df):
|
|||||||
log.info("评级完成,共更新: {}".format(count))
|
log.info("评级完成,共更新: {}".format(count))
|
||||||
|
|
||||||
|
|
||||||
def sync(city=None):
|
def sync_by_city(city_now):
|
||||||
sql = "select id, city, region, name, estate_charge from community_summary"
|
log.info(f"{city_now}开始评级....")
|
||||||
if pd.notna(city):
|
sql = "select id, city, region, name, estate_charge from community_summary where city='" + city_now + "'"
|
||||||
sql += " where city='" + city + "'"
|
|
||||||
### 极值设置
|
|
||||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||||
if city in factor_dict:
|
community_summary_df = filter_min_max(city_now, community_summary_df).copy()
|
||||||
community_summary_df.loc[community_summary_df['estate_charge'] < factor_dict[city]['min_estate_charge'], 'estate_charge'] = factor_dict[city]['min_estate_charge']
|
|
||||||
community_summary_df.loc[community_summary_df['estate_charge'] > factor_dict[city]['max_estate_charge'], 'estate_charge'] = factor_dict[city]['max_estate_charge']
|
|
||||||
calc_estate_charge_rating(community_summary_df)
|
calc_estate_charge_rating(community_summary_df)
|
||||||
|
save_png(city_now)
|
||||||
|
nextcloudutils.up_to_nextcloud(save_png_path, nextcloud_aim_file_path)
|
||||||
|
|
||||||
|
def sync(city=None):
|
||||||
|
if pd.isna(city):
|
||||||
|
for city_now in areautils.get_all_cities():
|
||||||
|
sync_by_city(city_now)
|
||||||
|
else:
|
||||||
|
sync_by_city(city)
|
||||||
|
|
||||||
|
|
||||||
def save_png(city=None):
|
def save_png(city=None):
|
||||||
"""
|
"""
|
||||||
生成财力评级图表
|
生成财力评级图表
|
||||||
"""
|
"""
|
||||||
sql = "select id, city, region, name, consumption_rating from community_summary"
|
sql = "select id, city, region, name, consumption_rating from community_summary where city='" + city + "'"
|
||||||
if pd.notna(city):
|
|
||||||
sql += " where city='" + city + "'"
|
|
||||||
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
community_summary_df = es206_client.scan_by_sql_to_data_frame(sql)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sync()
|
sync()
|
||||||
save_png()
|
|
||||||
nextcloudutils.up_to_nextcloud(save_png_path, nextcloud_aim_file_path)
|
|
||||||
dingutils.send_text("【分布图生成完毕】物业费评级已完成, 请点击 https://nextcloud.fangjia.com/s/HbifLoEDc5wi8HR 查看分布图", "c7ac6c86bfbe49a95e30a68616c4d784ae7781c715430dc9c5f6b46d3e6ebd78")
|
dingutils.send_text("【分布图生成完毕】物业费评级已完成, 请点击 https://nextcloud.fangjia.com/s/HbifLoEDc5wi8HR 查看分布图", "c7ac6c86bfbe49a95e30a68616c4d784ae7781c715430dc9c5f6b46d3e6ebd78")
|
||||||
Reference in New Issue
Block a user