systemdatautils.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. """PipeNetwork Data .
  2. """
  3. import test
  4. from systemrelation import systemutils
  5. def get_dicdata(sql,dic):
  6. data=test.get_data(sql)
  7. dic_data=[dict(zip(dic,item)) for item in data]
  8. return list(dic_data)
  9. def get_element_data(model_id):
  10. """
  11. Cache all Element from Db
  12. :return:
  13. """
  14. element_data=[]
  15. component_sql="select * from revit.component where model_id='%s'"%(model_id)
  16. COMPONENT_KEYS = [
  17. 'id',
  18. 'model_id',
  19. 'local_id',
  20. 'local_name',
  21. 'family',
  22. 'location',
  23. 'outline',
  24. 'source_id',
  25. 'name',
  26. 'revit_id',
  27. 'parameters',
  28. 'type',
  29. 'tag',
  30. 'owner',
  31. 'last_update',
  32. 'create_time',
  33. 'owner_id',
  34. 'family_name',
  35. 'owner_source_id'
  36. ]
  37. element_data.extend(get_dicdata(component_sql,COMPONENT_KEYS))
  38. equipment_sql="select * from revit.equipment where model_id='%s'"%(model_id)
  39. EQUIPMENT_KEYS = [
  40. 'id',
  41. 'model_id',
  42. 'local_id',
  43. 'local_name',
  44. 'family',
  45. 'location',
  46. 'outline',
  47. 'last_update',
  48. 'create_time',
  49. 'source_id',
  50. 'name',
  51. 'parameters',
  52. 'revit_id',
  53. 'type',
  54. 'tag',
  55. 'family_name',
  56. ]
  57. element_data.extend(get_dicdata(equipment_sql,EQUIPMENT_KEYS))
  58. other_sql="select * from revit.other where model_id='%s'"%(model_id)
  59. OTHER_KEYS = [
  60. 'id',
  61. 'model_id',
  62. 'connected_ids',
  63. 'source_id',
  64. 'name',
  65. 'revit_id',
  66. 'type',
  67. 'create_time',
  68. 'last_update',
  69. 'location',
  70. 'outline'
  71. ]
  72. element_data.extend(get_dicdata(other_sql,OTHER_KEYS))
  73. pipe_sql = "select * from revit.pipe where model_id='%s'" % (model_id)
  74. PIPE_KEYS = [
  75. 'id',
  76. 'model_id',
  77. 'location',
  78. 'outline',
  79. 'connected_ids',
  80. 'mep_system_type',
  81. 'diameter',
  82. 'source_id',
  83. 'name',
  84. 'revit_id',
  85. 'type',
  86. 'last_update',
  87. 'create_time',
  88. 'parameters'
  89. ]
  90. element_data.extend(get_dicdata(pipe_sql, PIPE_KEYS))
  91. duct_sql="select * from revit.duct where model_id='%s'"%(model_id)
  92. DUCT_KEYS = [
  93. 'id',
  94. 'model_id',
  95. 'location',
  96. 'outline',
  97. 'connected_ids',
  98. 'mep_system_type',
  99. 'shape',
  100. 'diameter',
  101. 'width',
  102. 'height',
  103. 'source_id',
  104. 'revit_id',
  105. 'name',
  106. 'type',
  107. 'last_update',
  108. 'create_time',
  109. 'parameters'
  110. ]
  111. element_data.extend(get_dicdata(duct_sql,DUCT_KEYS))
  112. element_data=list(map(systemutils.dic2obj, element_data))
  113. return element_data
  114. def get_connectors_data(model_id, system_name, domain):
  115. """Cache all connector from Db。"""
  116. connector_data=[]
  117. connector_sql = "SELECT * FROM revit.connector where model_id='%s' and mep_system_type='%s' and domain='%s'" % (model_id,system_name,domain)
  118. print(connector_sql)
  119. CONNECTOR_KEYS = [
  120. 'id',
  121. 'model_id',
  122. 'belong',
  123. 'belong_type',
  124. 'origin',
  125. 'domain',
  126. 'description',
  127. 'connected',
  128. 'owner',
  129. 'connected_ids',
  130. 'mep_system_type',
  131. 'source_id',
  132. 'revit_id',
  133. 'type',
  134. 'create_time',
  135. 'last_update',
  136. 'connect_id_json'
  137. ]
  138. connector_data.extend(get_dicdata(connector_sql, CONNECTOR_KEYS))
  139. connector_data=list(map(systemutils.dic2obj,connector_data))
  140. return connector_data
  141. if '__main__'==__name__:
  142. model_id="cf4e11a0e25811e999b6dbc4c75fa946"
  143. system_name="喷淋管"
  144. domain="DomainPiping"
  145. g=get_connectors_data(model_id,system_name,domain)
  146. print (g)