|
@@ -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):
|
|
|
+def get_project_models(project_id,build_id):
|
|
|
'''
|
|
|
Get all the models in the project.
|
|
|
project-->folder-->model.
|
|
@@ -24,34 +24,21 @@ def get_project_models(project_id):
|
|
|
:return:
|
|
|
'''
|
|
|
element_data = []
|
|
|
- sql ="select " \
|
|
|
- "file.id as file_id" \
|
|
|
- ",file.original_name as file_name" \
|
|
|
- ",file.status as file_status" \
|
|
|
- ",floor.id as floor_id" \
|
|
|
- ",floor.floor_name as floor_name" \
|
|
|
- ",folder.id as folder_id" \
|
|
|
- ",folder.name as folder_name" \
|
|
|
- ",folder.project_id as project_id " \
|
|
|
- "from revit.model_file as file " \
|
|
|
- "inner join " \
|
|
|
- "revit.model_floor as floor " \
|
|
|
- "on ( file.id=floor.current_model_id) " \
|
|
|
- "inner join " \
|
|
|
- "revit.model_folder as folder " \
|
|
|
- "on (floor.folder_id=folder.id )" \
|
|
|
- "where folder.project_id='%s'" \
|
|
|
- "and folder.id='bbe510dbe26011e999b69b669ea08505'"\
|
|
|
- % (project_id)
|
|
|
- #"and file.status=4 "\
|
|
|
+ sql="select " \
|
|
|
+ "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') " \
|
|
|
+ "order by sequence_id desc"\
|
|
|
+ %(project_id,build_id)
|
|
|
COMPONENT_KEYS = [
|
|
|
- 'file_id',
|
|
|
- 'file_name',
|
|
|
- 'file_status',
|
|
|
- 'floor_id',
|
|
|
- 'floor_name',
|
|
|
- 'folder_id',
|
|
|
- 'folder_name',
|
|
|
+ 'id',
|
|
|
+ 'name',
|
|
|
+ 'local_id',
|
|
|
+ 'local_name',
|
|
|
+ 'sequence_id',
|
|
|
+ 'model_id',
|
|
|
+ 'building_id',
|
|
|
'project_id'
|
|
|
]
|
|
|
element_data.extend(get_dicdata(sql, COMPONENT_KEYS))
|
|
@@ -196,23 +183,23 @@ def get_connectors_data(model_id, system_name, domain):
|
|
|
connector_data=list(map(systemutils.dic2obj, connector_data))
|
|
|
return connector_data
|
|
|
|
|
|
-def save_project_data(project_graph,project_id,system_name,domain):
|
|
|
+def save_project_data(project_graph,system_name,domain,build_id):
|
|
|
"""
|
|
|
Sava project graph data.
|
|
|
:param floor_graph:
|
|
|
:return:
|
|
|
"""
|
|
|
- del_project_data(project_id,system_name,domain)
|
|
|
+ del_project_data(project_graph.project_id,system_name,domain,build_id)
|
|
|
# Create
|
|
|
block_id=0
|
|
|
for g in project_graph.groupedsystemgraphs:
|
|
|
for s in g.systemgraphs:
|
|
|
for e in s.system_edges:
|
|
|
- save_edge_data(e, block_id,system_name,domain)
|
|
|
+ save_edge_data(e, block_id,build_id)
|
|
|
for e in g.connectedges:
|
|
|
- save_edge_data(e,block_id,system_name,domain)
|
|
|
+ save_edge_data(e,block_id,build_id)
|
|
|
block_id+=1
|
|
|
-def save_edge_data(edge,block_id,system_name,domain):
|
|
|
+def save_edge_data(edge,block_id,build_id):
|
|
|
"""
|
|
|
Save edge info using sql
|
|
|
:param edge:
|
|
@@ -224,16 +211,18 @@ def save_edge_data(edge,block_id,system_name,domain):
|
|
|
vertex2=edge.end_vertex
|
|
|
c1=vertex1.system_data
|
|
|
c2=vertex2.system_data
|
|
|
- model1= vertex1.get_parent_floor()
|
|
|
- model2 = vertex2.get_parent_floor()
|
|
|
+ floor1 = vertex1.get_parent_floor()
|
|
|
+ floor2 = vertex2.get_parent_floor()
|
|
|
+ model1= floor1.model
|
|
|
+ model2 = floor2.model
|
|
|
sql="insert into revit_calc.connected_block" \
|
|
|
- "(id1,type1,model_id1,id2,type2,model_id2,block_id,project_id,mep_system_type,domain) values " \
|
|
|
- "('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')"\
|
|
|
- %(c1.id,c1.type,model1.file_id,c2.id,c2.type,model2.file_id,block_id,model1.project_id,system_name,domain)
|
|
|
+ "(id1,type1,model_id1,id2,type2,model_id2,block_id,project_id,mep_system_type,domain,building_id) values " \
|
|
|
+ "('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')"\
|
|
|
+ %(c1.id,c1.type,model1.model_id,c2.id,c2.type,model2.model_id,block_id,model1.project_id,floor1.system_name,floor1.domain,build_id)
|
|
|
data = test.save_data(sql)
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
-def del_project_data(project_id,system_name,domain):
|
|
|
+def del_project_data(project_id,system_name,domain,build_id):
|
|
|
"""
|
|
|
Before save.delete old data.
|
|
|
:param project_id:
|
|
@@ -243,7 +232,8 @@ def del_project_data(project_id,system_name,domain):
|
|
|
"where project_id='%s'"\
|
|
|
"and mep_system_type='%s'" \
|
|
|
"and domain='%s'" \
|
|
|
- % (project_id,system_name,domain)
|
|
|
+ "and (building_id is null or building_id='%s')" \
|
|
|
+ % (project_id,system_name,domain,build_id)
|
|
|
test.save_data(sql)
|
|
|
def get_connected_block_data(project_id,block_id,system_name,domain):
|
|
|
'''
|