|
@@ -11,7 +11,7 @@ class Mvp:
|
|
|
"""
|
|
|
|
|
|
age_dict = {
|
|
|
- '00-04年生': '00后',
|
|
|
+ '00-04年生': '95后',
|
|
|
'05-09年生': '05后',
|
|
|
'50-59年生': '50后',
|
|
|
'60-69年生': '60后',
|
|
@@ -19,7 +19,7 @@ class Mvp:
|
|
|
'75-79年生': '75后',
|
|
|
'80-84年生': '80后',
|
|
|
'85-89年生': '85后',
|
|
|
- '90-94年生': '90后',
|
|
|
+ '90-94年生': '85后',
|
|
|
'95-99年生': '95后'
|
|
|
}
|
|
|
|
|
@@ -30,23 +30,16 @@ class Mvp:
|
|
|
tag_table = {
|
|
|
'用户画像-审美偏好': ['mvp_crowd_info_aesthetic_preference', 'aesthetic_preference'],
|
|
|
'用户画像-行为兴趣': ['mvp_crowd_info_behavior', 'behavioral_interest'],
|
|
|
- '用户画像-观念': ['mvp_crowd_info_consumer_concept', ''],
|
|
|
- '用户画像-消费特征': ['mvp_crowd_info_consumer_structure', ''],
|
|
|
- '空间需求图谱-功能关联': ['mvp_crowd_info_functional_module', ''],
|
|
|
- '性别比例': ['mvp_crowd_info_gender_rate', ''],
|
|
|
- '用户画像-生活方式': ['mvp_crowd_info_life_style', ''],
|
|
|
- '人群占比': ['mvp_crowd_info_rate', ''],
|
|
|
- '用户画像-社交模式': ['mvp_crowd_info_social_mode', ''],
|
|
|
- '用户画像-行业': ['mvp_crowd_info_trade', ''],
|
|
|
- '用户画像-出行方式': ['mvp_crowd_info_trip_mode', ''],
|
|
|
- '空间需求图谱-基础模块分值': ['mvp_innovate_space_base_module', ''],
|
|
|
+ '用户画像-观念': ['mvp_crowd_info_consumer_concept', 'consumer_concept'],
|
|
|
+ '用户画像-社交模式': ['mvp_crowd_info_social_mode', 'social_module'],
|
|
|
+ '用户画像-行业': ['mvp_crowd_info_trade', 'trade'],
|
|
|
+ '用户画像-出行方式': ['mvp_crowd_info_trip_mode', 'trip_mode'],
|
|
|
'空间需求图谱-色相': ['mvp_innovate_space_color_prefer', 'color'],
|
|
|
'空间需求图谱-精装关注点': ['mvp_innovate_space_hardcover_focus', 'hardcover_focus'],
|
|
|
'空间需求图谱-色调': ['mvp_innovate_space_hue_prefer', 'hue'],
|
|
|
'空间需求图谱-单品偏好': ['mvp_innovate_space_item_preference', 'item_preference'],
|
|
|
'空间需求图谱-材质': ['mvp_innovate_space_material_prefer', 'material'],
|
|
|
'空间需求图谱-空间特性偏好': ['mvp_innovate_space_space_prefer', 'space_preference'],
|
|
|
- '空间需求图谱-空间拓普图': ['mvp_innovate_space_space_top', ''],
|
|
|
'模块分数': ['mvp_crowd_info_module', 'module_name']
|
|
|
}
|
|
|
crowd_info_1 = {
|
|
@@ -416,6 +409,7 @@ class Mvp:
|
|
|
定时更新分值
|
|
|
:return:
|
|
|
"""
|
|
|
+ self.insert_table = []
|
|
|
self.linshi_db = MysqlDB('linshi', db_type=1)
|
|
|
for city in self.city_list:
|
|
|
for age in self.age_list:
|
|
@@ -446,14 +440,16 @@ class Mvp:
|
|
|
age_1 = id[1]
|
|
|
crowd_1 = id[3]
|
|
|
id_1 = id[0]
|
|
|
- if city_2 == city_1 and self.age_dict[age_2] == age_1 and crowd_2 == crowd_1:
|
|
|
+ if city_2 == city_1 and age_2 == age_1 and crowd_2 == crowd_1:
|
|
|
module_insert_data.append([id_1, module_name_2, module_score_2])
|
|
|
# 先清空之前的数据
|
|
|
- table_name = self.get_table_name('模块分数')
|
|
|
- if table_name and len(module_insert_data) > 0:
|
|
|
- self.linshi_db.truncate(table_name)
|
|
|
- self.linshi_db.add_some(module_insert_sql, module_insert_data)
|
|
|
- print('模块分数更新完成...')
|
|
|
+ if len(module_insert_data) > 0:
|
|
|
+ table_name = self.get_table_name('模块分数')
|
|
|
+ if table_name is not None and table_name not in self.insert_table:
|
|
|
+ self.linshi_db.truncate(table_name)
|
|
|
+ self.linshi_db.add_some(module_insert_sql, module_insert_data)
|
|
|
+ self.insert_table.append(table_name)
|
|
|
+ print('模块分数更新完成...')
|
|
|
|
|
|
for b_score in behavior_score:
|
|
|
for key in b_score.keys():
|
|
@@ -467,21 +463,25 @@ class Mvp:
|
|
|
tag_name = data[2]
|
|
|
crowd = data[3]
|
|
|
tag_score = data[4]
|
|
|
- for id in ids:
|
|
|
- city_1 = id[2]
|
|
|
- age_1 = id[1]
|
|
|
- crowd_1 = id[3]
|
|
|
- id_1 = id[0]
|
|
|
- if city == city_1 and self.age_dict[age] == age_1 and crowd == crowd_1:
|
|
|
- insert_data.append([id_1, tag_name, tag_score])
|
|
|
+ if key == '用户画像-行为兴趣' and city == '上海市' and age == '85后':
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ for id in ids:
|
|
|
+ city_1 = id[2]
|
|
|
+ age_1 = id[1]
|
|
|
+ crowd_1 = id[3]
|
|
|
+ id_1 = id[0]
|
|
|
+ if city == city_1 and age == age_1 and crowd == crowd_1:
|
|
|
+ insert_data.append([id_1, tag_name, tag_score])
|
|
|
if len(insert_data) > 0:
|
|
|
table_name = self.get_table_name(key)
|
|
|
- if table_name:
|
|
|
+ if table_name and table_name not in self.insert_table:
|
|
|
if table_name == 'mvp_crowd_info_behavior':
|
|
|
self.linshi_db.delete(self.sql_18)
|
|
|
else:
|
|
|
self.linshi_db.truncate(table_name)
|
|
|
self.linshi_db.add_some(insert_sql, insert_data)
|
|
|
+ self.insert_table.append(table_name)
|
|
|
else:
|
|
|
print('未找到对应的表,数据无法插入...')
|
|
|
print('行为分数更新完成...')
|
|
@@ -816,5 +816,4 @@ class Mvp:
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
- mvp = Mvp()
|
|
|
- print(mvp.get_insert_sql('模块分数'))
|
|
|
+ pass
|