Prechádzať zdrojové kódy

mxg:add building_id constraint to the sys_direction calc

mengxiangge 5 rokov pred
rodič
commit
c94f1e08e1

+ 20 - 11
src/system_relation/systemdatautils.py

@@ -16,7 +16,7 @@ def get_dicdata(sql,dic):
 	data=test.get_data(sql)
 	dic_data=[dict(zip(dic,item)) for item in data]
 	return list(dic_data)
-def get_project_models(project_id,build_id):
+def get_project_models(project_id,building_id):
 	'''
 	Get all the models in the project.
 	project-->folder-->model.
@@ -28,9 +28,9 @@ def get_project_models(project_id,build_id):
 		"id,name,local_id,local_name,sequence_id,model_id,building_id,project_id " \
 		"from floor " \
 		"where project_id='%s' " \
-		"and (building_id is null or building_id='%s') " \
+		"and ('%s' is null or building_id='%s') " \
 		"order by sequence_id desc"\
-		%(project_id,build_id)
+		%(project_id,building_id,building_id)
 	COMPONENT_KEYS = [
 		'id',
 		'name',
@@ -222,7 +222,7 @@ def save_edge_data(edge,block_id,build_id):
 		data = test.save_data(sql)
 	except Exception as e:
 		print(e)
-def del_project_data(project_id,system_name,domain,build_id):
+def del_project_data(project_id,system_name,domain,building_id):
 	"""
 	Before save.delete old data.
 	:param project_id:
@@ -232,10 +232,10 @@ def del_project_data(project_id,system_name,domain,build_id):
 		  "where project_id='%s'"\
 		  "and mep_system_type='%s'" \
 		  "and domain='%s'" \
-		  "and (building_id is null or building_id='%s')" \
-		  % (project_id,system_name,domain,build_id)
+		  "and ('%s' is null or building_id='%s')" \
+		  % (project_id,system_name,domain,building_id,building_id)
 	test.save_data(sql)
-def get_connected_block_data(project_id,block_id,system_name,domain):
+def get_connected_block_data(project_id,block_id,system_name,domain,building_id):
 	'''
 	Get all the connected_block .
 	:param project_id:
@@ -248,8 +248,9 @@ def get_connected_block_data(project_id,block_id,system_name,domain):
 		  "and block_id='%s'" \
 		  "and mep_system_type='%s'" \
 		  "and domain='%s'" \
+		  "and ('%s' is null or building_id='%s')" \
 		  "order by cast(depth as int) asc"\
-		  % (project_id,block_id,system_name,domain)
+		  % (project_id,block_id,system_name,domain,building_id,building_id)
 	KEYS = [
 		'id',
 		'id1',
@@ -262,11 +263,14 @@ def get_connected_block_data(project_id,block_id,system_name,domain):
 		'block_id',
 		'project_id',
 		'depth',
+		'mep_system_type',
+		'domain',
+		'building_id',
 	]
 	element_data.extend(get_dicdata(sql, KEYS))
 	element_data = list(map(systemutils.dic2obj, element_data))
 	return element_data
-def get_connected_block_source_data(project_id,block_id,system_name,domain):
+def get_connected_block_source_data(project_id,block_id,system_name,domain,building_id):
 	'''
 	Get all the connected_block source .
 	:param project_id:
@@ -279,12 +283,17 @@ def get_connected_block_source_data(project_id,block_id,system_name,domain):
 		  "and block_id='%s'" \
 		  "and mep_system_type='%s'" \
 		  "and domain='%s'" \
-		  % (project_id,block_id,system_name,domain)
+		  "and ('%s' is null or building_id='%s')" \
+		  % (project_id,block_id,system_name,domain,building_id,building_id)
 	KEYS = [
 		'id',
 		'project_id',
 		'block_id',
 		'source_id',
+		'source_type',
+		'mep_system_type',
+		'domain',
+		'building_id',
 	]
 	element_data.extend(get_dicdata(sql, KEYS))
 	element_data = list(map(systemutils.dic2obj, element_data))
@@ -296,7 +305,7 @@ def update_connected_block_data(block_datas):
 	:return:
 	'''
 	for block_data in block_datas:
-		sql="update revit_calc.connected_block set direction='%s',depth='%s' where id='%s'"\
+		sql="update revit_calc.connected_block set direction='%s',depth='%s' where id='%s'" \
 			%(block_data.direction,block_data.depth,block_data.id)
 		data = test.save_data(sql)
 

+ 1 - 2
src/system_relation/systemgraph_display.py

@@ -51,14 +51,13 @@ def show_groupedsystem(grouped_system_graph):
 from src.system_relation import systemdatautils
 
 
-def show_connected_block(project_id: object, block_id: object) -> object:
+def show_connected_block(block_datas):
 	'''
 	show connected block.
 	:param project_id:
 	:param block_id:
 	:return:
 	'''
-	block_datas= systemdatautils.get_connected_block_data(project_id, block_id)
 	g=nx.DiGraph()
 	model_dic = {}
 	floor_data_dic = {}

+ 5 - 4
src/system_relation/test_flowdirection.py

@@ -1,13 +1,14 @@
 import sys
 sys.path.append("../../..")
-from relations.src.system_relation import calc_flowdirection, systemdatautils
+from relations.src.system_relation import calc_flowdirection, systemdatautils,systemgraph_display
 if __name__=="__main__":
 	project_id="Pj1101010015"
 	block_id="0"
 	system_name = "冷冻水供水管"
 	domain = "DomainPiping"
-	block_datas= systemdatautils.get_connected_block_data(project_id, block_id,system_name,domain)
-	source_datas= systemdatautils.get_connected_block_source_data(project_id, block_id,system_name,domain)
+	building_id = 'Bd11010100153c05821ed8fd11e9b8f2d79d0a5b4bf6'
+	block_datas= systemdatautils.get_connected_block_data(project_id, block_id,system_name,domain,building_id)
+	source_datas= systemdatautils.get_connected_block_source_data(project_id, block_id,system_name,domain,building_id)
 	block_datas= calc_flowdirection.calc(block_datas, source_datas)
 	systemdatautils.update_connected_block_data(block_datas)
-	#systemgraph_display.show_connected_block(project_id,block_id)
+	systemgraph_display.show_connected_block(block_datas)

+ 3 - 3
src/system_relation/test_systemblock.py

@@ -7,8 +7,8 @@ if '__main__'==__name__:
 	project_id="Pj1101010015"
 	system_name="冷冻水供水管"
 	domain="DomainPiping"
-	build_id = 'Bd11010100153c05821ed8fd11e9b8f2d79d0a5b4bf6'
-	models= systemdatautils.get_project_models(project_id,build_id)
+	building_id = 'Bd11010100153c05821ed8fd11e9b8f2d79d0a5b4bf6'
+	models= systemdatautils.get_project_models(project_id,building_id)
 	floorgraphs=[]
 	for model in models:
 		floor_connectors = systemdatautils.get_connectors_data(model.model_id, system_name, domain)
@@ -17,5 +17,5 @@ if '__main__'==__name__:
 		g.get_floor_graphs()
 		floorgraphs.append(g)
 	projectgraph= graph_model.combine_systemgraph(project_id,floorgraphs)
-	systemdatautils.save_project_data(projectgraph,system_name,domain,build_id)
+	systemdatautils.save_project_data(projectgraph,system_name,domain,building_id)
 	systemgraph_display.show_project(projectgraph)