| 
					
				 | 
			
			
				@@ -216,7 +216,7 @@ class Mvp: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             获取答题数据中的城市。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         :return: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        citys = ['宁波市', '上海市', '苏州市', '无锡市', '宁波市'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        citys = ['上海市', '上海周边'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # citys_info = self.marketing_db.select(self.sql_1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # citys.extend([x[0] for x in citys_info if x[0] is not None]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return citys 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -327,12 +327,11 @@ class Mvp: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             定时更新分值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         :return: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        citys = ['上海市', '杭州市', '苏州市', '无锡市', '宁波市'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for city in citys: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            result = self.city_age_crowd(city) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            self.insert_score_to_db(result) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            print('{}数据更新完成...'.format(citys)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for city in self.city_list: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for age in self.age_list: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for crowd in self.crowd: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    result = self.city_age_crowd(city, age, crowd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    self.insert_score_to_db(result) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         print('{}数据关系完成...'.format(time.time())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def insert_score_to_db(self, scores): 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -497,9 +496,10 @@ class Mvp: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            获取答题数据中的年龄 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        age_info = self.marketing_db.select(self.sql_4) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # print([x[0] for x in age_info]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return [x[0] for x in age_info if x[0] is not None] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return ['95后', '85后'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # age_info = self.marketing_db.select(self.sql_4) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # # print([x[0] for x in age_info]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # return [x[0] for x in age_info if x[0] is not None] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def city_age_crowd(self, city=None, age=None, crowd=None): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         data_start = [] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -520,29 +520,6 @@ class Mvp: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 behavior_data = behavior_data_1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if behavior_data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 module_scores.extend(self.module_score(crowd, city, age, behavior_data)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            print('获取所有case的数据...') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            # for city in self.citys: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for cy in self.city_list: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                for age_1 in self.age_list: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    for crowd_type in self.crowd: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if age_1 == '85-89年生' and cy == '上海市': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            print('上海市85后数据导入人工值,无需计算...') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            pass 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            # print(' {}{}'.format(city, age)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            # people_uuids = self.get_people_uuid_by_type(crowd_type) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            people_uuids = self.people_filter(cy, age_1, crowd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            behavior_data = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            if len(people_uuids) > 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                print('{}-{}-{}'.format(cy, age_1, crowd_type)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                datas = self.behavior_tag_init(cy, age_1, people_uuids) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                data_start.append(datas) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                all_data, behavior_data_1 = self.calculation_standard_score(datas, cy, age_1, crowd_type) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                result.append(all_data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                behavior_data = behavior_data_1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            if behavior_data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                module_scores.extend(self.module_score(crowd_type, cy, age_1, behavior_data)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # data_list = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # for e in data_start: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         #     for key in e.keys(): 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -555,6 +532,17 @@ class Mvp: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return {'behavior_score': result, 'module_score': module_scores} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # return {'score': result, 'data': data_list} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    def scores(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        behavior_score = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        module_scores = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for city in self.city_list: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for age in self.age_list: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for crowd in self.crowd: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    data = self.city_age_crowd(city, age, crowd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    behavior_score.extend(data['behavior_score']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    module_scores.extend(data['module_score']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return {'behavior_score': behavior_score, 'module_score': module_scores} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def behavior_tag_init(self, city, age, people_uuids): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         result = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.group_type_count = self.marketing_db.select(self.sql_5, [people_uuids]) 
			 |