| 
					
				 | 
			
			
				@@ -8,8 +8,11 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 - 动态标签识别等功能 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import logging 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from app.core.graph.graph_operations import connect_graph 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# 配置logger 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+logger = logging.getLogger(__name__) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # 数据标准列表展示 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def standard_list(skip_count, page_size, en_name_filter=None, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -54,31 +57,40 @@ def standard_list(skip_count, page_size, en_name_filter=None, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     cql = f""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     MATCH (n:data_standard) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     WHERE {where_str} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    RETURN properties(n) as properties,n.time as time,id(n) as nodeid,size((n)--()) as relationship_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    RETURN properties(n) as properties,n.time as time,id(n) as nodeid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           COUNT{{()-[]->(n)}} + COUNT{{(n)-[]->()}} as relationship_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ORDER BY time desc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     SKIP $skip_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     LIMIT $page_size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     params['skip_count'] = skip_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     params['page_size'] = page_size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    result = connect_graph.run(cql, **params) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for record in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        properties = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            key: value for key, value in record['properties'].items() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if key not in ['input', 'code', 'output'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        properties.setdefault("describe", None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        new_attr = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            'id': record['nodeid'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            'number': record['relationship_count'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        properties.update(new_attr) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        data.append(properties) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    # 获取总量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    total_query = f"MATCH (n:data_standard) WHERE {where_str} RETURN COUNT(n) AS total" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    total_result = connect_graph.run(total_query, **params).evaluate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return [], 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(cql, **params) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for record in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            properties = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                key: value for key, value in record['properties'].items() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if key not in ['input', 'code', 'output'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            properties.setdefault("describe", None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            new_attr = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'id': record['nodeid'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'number': record['relationship_count'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            properties.update(new_attr) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            data.append(properties) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # 获取总量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        total_query = f"MATCH (n:data_standard) WHERE {where_str} RETURN COUNT(n) AS total" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        total_result = session.run(total_query, **params).single()["total"] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return data, total_result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -111,15 +123,22 @@ def standard_kinship_graph(nodeid): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         apoc.coll.toSet(nodes) as nodes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     RETURN nodes,lines,rootId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data = connect_graph.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for item in data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "rootId": item['rootId'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for item in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "rootId": item['rootId'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # 数据标准图谱展示(影响关系)下游 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -151,15 +170,22 @@ def standard_impact_graph(nodeid): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             apoc.coll.toSet(nodes) as nodes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         RETURN nodes,lines,rootId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data = connect_graph.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for item in data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "rootId": item['rootId'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for item in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "rootId": item['rootId'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # 数据标准图谱展示(所有关系) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -197,15 +223,21 @@ def standard_all_graph(nodeid): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         apoc.coll.toSet(nodes) as nodes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     RETURN nodes,lines,rootId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data = connect_graph.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for item in data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "rootId": item['rootId'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for item in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "rootId": item['rootId'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # 数据标签列表展示 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -252,30 +284,39 @@ def label_list(skip_count, page_size, en_name_filter=None, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     MATCH (n:data_label) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     WHERE {where_str} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     RETURN properties(n) as properties,n.time as time,id(n) as nodeid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-           size((n)--()) as relationship_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+           COUNT{{()-[]->(n)}} + COUNT{{(n)-[]->()}} as relationship_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ORDER BY time desc 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     SKIP $skip_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     LIMIT $page_size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     params['skip_count'] = skip_count 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     params['page_size'] = page_size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    result = connect_graph.run(cql, **params) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for record in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        properties = record['properties'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        new_attr = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            'id': record['nodeid'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            'number': record['relationship_count'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if "describe" not in properties: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            properties["describe"] = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if "scope" not in properties: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            properties["scope"] = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        properties.update(new_attr) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        data.append(properties) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    # 获取总量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    total_query = f"MATCH (n:data_label) WHERE {where_str} RETURN COUNT(n) AS total" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    total_result = connect_graph.run(total_query, **params).evaluate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        logger.error("无法连接到数据库") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return [], 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(cql, **params) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for record in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            properties = record['properties'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            new_attr = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'id': record['nodeid'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                'number': record['relationship_count'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if "describe" not in properties: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                properties["describe"] = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if "scope" not in properties: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                properties["scope"] = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            properties.update(new_attr) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            data.append(properties) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # 获取总量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        total_query = f"MATCH (n:data_label) WHERE {where_str} RETURN COUNT(n) AS total" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        total_result = session.run(total_query, **params).single()["total"] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return data, total_result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -303,16 +344,21 @@ def id_label_graph(id): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                  toString(id(n)) AS res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     RETURN lines, nodes, res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data = connect_graph.run(query, nodeId=id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for item in data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "rootId": item['res'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(query, nodeId=id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for item in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "rootId": item['res'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # 数据标签图谱展示(血缘关系)父节点/(所有关系) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -353,15 +399,21 @@ def label_kinship_graph(nodeid): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         apoc.coll.toSet(nodes) as nodes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     RETURN nodes,lines,rootId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data = connect_graph.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for item in data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "rootId": item['rootId'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for item in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "nodes": [record for record in item['nodes'] if record['id']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "lines": [record for record in item['lines'] if record['from'] and record['to']], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "rootId": item['rootId'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # 数据标签图谱展示(影响关系)下游 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -382,15 +434,21 @@ def label_impact_graph(nodeid): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         RETURN {id:toString(id(n)),text:(n.name),type:"label"} AS nodes, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                toString(id(n)) as rootId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data = connect_graph.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for item in data: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "nodes": item['nodes'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "rootId": item['rootId'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "lines": [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(cql, nodeId=nodeid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        res = {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for item in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            res = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "nodes": item['nodes'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "rootId": item['rootId'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "lines": [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 # 数据标签按照提交内容查询相似分组,并且返回 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -412,12 +470,18 @@ def dynamic_label_list(name_filter=None): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     RETURN DISTINCT n.group as name,id(n) as nodeid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    result = connect_graph.run(cql).data() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    data = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    for record in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        data.append({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "name": record['name'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            "id": record['nodeid'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return data  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    # 修复:使用正确的session方式执行查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    driver = connect_graph() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if not driver: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    with driver.session() as session: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        result = session.run(cql) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        data = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for record in result: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            data.append({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "name": record['name'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "id": record['nodeid'] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return data  
			 |