jxing 5 years ago
parent
commit
23c6d22db0
2 changed files with 16 additions and 26 deletions
  1. 7 16
      src/level/check_level.py
  2. 9 10
      src/level/test.py

+ 7 - 16
src/level/check_level.py

@@ -5,8 +5,8 @@ import sys
 def floor_sort_cmp(x, y):
     positive = 1
     negative = -1
-    x_name = x.get('name')[0:len(x.get('name'))-5]
-    y_name = y.get('name')[0:len(y.get('name'))-5]
+    x_name = x.get('floor_name')[0:len(x.get('floor_name'))-5]
+    y_name = y.get('floor_name')[0:len(y.get('floor_name'))-5]
     # x 夹层号
     x_m_num = 1
     # y 夹层号
@@ -78,14 +78,9 @@ def floor_sort_cmp(x, y):
     return 1
 
 
-def check_level_reasonable(model_list, level_data):
-    levels = []
-    for model_id, level_rows in level_data.items():
-        if level_rows is not None and len(level_rows) == 1:
-            levels.append(level_rows[0])
+def check_level_reasonable(model_list):
 
-
-    sorted_arr = sorted(levels, key=functools.cmp_to_key(floor_sort_cmp))
+    sorted_arr = sorted(model_list, key=functools.cmp_to_key(floor_sort_cmp))
 
     last_height = -999999999
     last_model_id = ''
@@ -93,10 +88,10 @@ def check_level_reasonable(model_list, level_data):
     group = 0
     elevations = {}
     for row in sorted_arr:
-        current_height = row.get('elevation')
-        current_model_id = row.get('model_id')
+        current_height = row.get('level')
+        current_model_id = row.get('fid')
         elevations[current_model_id] = current_height
-        if current_height > last_height:
+        if current_height is not None and current_height > last_height:
             last_height = current_height
             last_model_id = current_model_id
             continue
@@ -117,10 +112,6 @@ def check_level_reasonable(model_list, level_data):
         else:
             floor_row['has_error'] = False
             floor_row['error'] = None
-        if model_id in elevations:
-            floor_row['elevation'] = elevations[model_id]
-        else:
-            floor_row['elevation'] = None
     if len(error) == 0:
         return True
     return False

+ 9 - 10
src/level/test.py

@@ -5,7 +5,8 @@ import sys
 
 import psycopg2
 
-from src.level.check_level import check_level_reasonable
+# from src.level.check_level import check_level_reasonable
+import check_level
 
 involved_model_keys = [
     'id',
@@ -21,7 +22,9 @@ involved_model_keys = [
     'log',
     'url',
     'md5',
-    'status'
+    'status',
+    'plan_name',
+    'level'
 ]
 
 level_keys = [
@@ -71,19 +74,15 @@ def loads_curve(x):
 
 
 if __name__ == '__main__':
-    involved_model_sql = "select * from revit.model_floor_file_func('Pj1101010015') where folder_id = " \
-                         "'bbe510dbe26011e999b69b669ea08505' and status in (3, 31, 4) "
-    level_sql = "select * from revit.level where name like '%-saga' and model_id = "
+    involved_model_sql = "select * from revit.model_floor_file_func('Pj1101080004') where folder_id = " \
+                         "'651741331a5011eaa2ec5bb247ac1cd5' and status in (31, 4) "
     columns_data = get_data(involved_model_sql)
     if len(columns_data) == 0:
         sys.exit()
     model_list = [dict(zip(involved_model_keys, item)) for item in columns_data]
     level_data = dict()
     for item in model_list:
-        current_level_sql = level_sql + '\'{model_id}\''.format(model_id=item.get('fid'))
-        single_model_level = get_data(current_level_sql)
-        single_model_level = [dict(zip(level_keys, item)) for item in single_model_level]
-        level_data[item.get('fid')] = single_model_level
+        level_data[item.get('fid')] = item.get('level')
 
-    print(check_level_reasonable(model_list, level_data))
+    print(check_level.check_level_reasonable(model_list))
     print(model_list)