| 
															
																@@ -32,6 +32,12 @@ class ExcelUtil: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         # print('max_row:{}, max_col:{}'.format(work_sheet.max_row, work_sheet.max_column)) 
															 | 
															
															 | 
															
																         # print('max_row:{}, max_col:{}'.format(work_sheet.max_row, work_sheet.max_column)) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         return work_sheet 
															 | 
															
															 | 
															
																         return work_sheet 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    def read_excel_by_ox_name(self, sheet_name): 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        work_book = ox.load_workbook(self.path, data_only=True) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        work_sheet = work_book.get_sheet_by_name(sheet_name) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        # print('max_row:{}, max_col:{}'.format(work_sheet.max_row, work_sheet.max_column)) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        return work_sheet 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     def init_crowd_info(self): 
															 | 
															
															 | 
															
																     def init_crowd_info(self): 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         """ 
															 | 
															
															 | 
															
																         """ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             整理不同人群包含的父选序号 
															 | 
															
															 | 
															
																             整理不同人群包含的父选序号 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -147,8 +153,39 @@ class ExcelUtil: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             results[name] = sub_results 
															 | 
															
															 | 
															
																             results[name] = sub_results 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         return results 
															 | 
															
															 | 
															
																         return results 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    def module_behavior_info(self): 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        """ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            构建模块和行为的关联信息 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        :return: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        """ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        work_sheet = self.read_excel_by_ox_name('行为-模块映射表') 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        max_column = work_sheet.max_column 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        rows = [row for row in work_sheet.rows][1:] 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        infos = [] 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        for row in rows: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            behavior_name = row[1].value 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            for i in range(2, max_column - 1): 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                module_name = row[i].value 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                if module_name: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    if i == 2: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        weight = 1 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    else: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        weight = 0.5 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    infos.append([row[i].value, behavior_name, weight]) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        infos.sort(key=lambda obj: obj[0]) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        result = {} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        for key, data in groupby(infos, key=lambda obj: obj[0]): 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            behavior_data = [] 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            for dt in data: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                dt_list = [x for x in dt] 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                if len(behavior_data) <= 14: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    behavior_data.append([dt_list[1], dt_list[2]]) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            result[key] = behavior_data 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        return result 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 if __name__ == '__main__': 
															 | 
															
															 | 
															
																 if __name__ == '__main__': 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     import json 
															 | 
															
															 | 
															
																     import json 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    eu = ExcelUtil().init_mvp_data() 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    print(json.dumps(eu, ensure_ascii=False)) 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    eu = ExcelUtil(file_name=r'D:\elab\elab_mvp\resources\module.xlsx') 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    data = eu.module_behavior_info() 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    print(json.dumps(data, ensure_ascii=False)) 
															 |