Browse Source

完成了GC中的修正系数的展示

wzp 5 months ago
parent
commit
2bb929e165
1 changed files with 89 additions and 43 deletions
  1. 89
    43
      Back/GC/GCshow.py

+ 89
- 43
Back/GC/GCshow.py View File

23
     db1.text_factory = lambda x: str(x, 'utf-8')
23
     db1.text_factory = lambda x: str(x, 'utf-8')
24
     cursor1 = db1.cursor()
24
     cursor1 = db1.cursor()
25
 
25
 
26
-    # 查询 GC_Output_Point 表中的 TableName 字段
27
-    query_table_names = "SELECT DISTINCT TableName FROM GC_Output_Point"
28
-    cursor1.execute(query_table_names)
29
-
26
+    # 查询 GC_Output_Point 表中的数据
30
     query = """
27
     query = """
31
     SELECT New_ID, New_ResultName, New_SPName, New_EPName, New_HDiff, New_RLen, Correct_Factor, Period_Diff, Dis_Ass
28
     SELECT New_ID, New_ResultName, New_SPName, New_EPName, New_HDiff, New_RLen, Correct_Factor, Period_Diff, Dis_Ass
32
     FROM GC_Output_Point
29
     FROM GC_Output_Point
33
     WHERE TableName = ?
30
     WHERE TableName = ?
34
     """
31
     """
35
     cursor1.execute(query, (utf_en,))
32
     cursor1.execute(query, (utf_en,))
36
-    result = cursor1.fetchall()
33
+    output_result = cursor1.fetchall()
34
+
35
+    # 查询 GC_Input_Param 表中的 Correct_Factor 字段
36
+    param_query_correct_factor = """
37
+    SELECT Correct_Factor
38
+    FROM GC_Input_Param
39
+    WHERE TableName = ?
40
+    """
41
+    cursor1.execute(param_query_correct_factor, (utf_en,))
42
+    correct_factor_result = cursor1.fetchall()
43
+
37
     cursor1.close()
44
     cursor1.close()
38
     db1.close()
45
     db1.close()
39
 
46
 
40
     # 创建 QStandardItemModel 实例
47
     # 创建 QStandardItemModel 实例
41
     model = QStandardItemModel()
48
     model = QStandardItemModel()
42
-    model.setColumnCount(len(result[0]))
49
+    model.setColumnCount(len(output_result[0]) + 1)  # 增加一列
43
 
50
 
44
     # 设置表头
51
     # 设置表头
45
-    headers = ['序号', '结果期数', '起点', '终点', '高差', '路线长', '修正数', '期间差异', '变形判定']
52
+    headers = ['序号', '结果期数', '起点', '终点', '高差', '路线长', '修正数', '期间差异', '变形判定', '修正系数']
46
     model.setHorizontalHeaderLabels(headers)
53
     model.setHorizontalHeaderLabels(headers)
47
 
54
 
48
-    for row_data in result:
55
+    # 使用 itertools.zip_longest 处理长度不一致的情况
56
+    for row_data, correct_factor_data in itertools.zip_longest(output_result, correct_factor_result, fillvalue=(None, None)):
49
         items = []
57
         items = []
50
         for i, item in enumerate(row_data):
58
         for i, item in enumerate(row_data):
51
-            if i == 4 or i == 5:  # 索引4(高差)
52
-                item = f"{item:.6f}"  # 格式化为6位小数
53
-            elif i == 6:  # 索引 6(修正数)
54
-                item = f"{item:.2f}"
55
-            elif i == 7:  # 假设 Period_Diff 在索引 7
56
-                if item is not None and isinstance(item, (int, float)):
57
-                    item = f"{item:.2f}"  # 格式化为2位小数
58
-                else:
59
-                    item = ""  # 如果是 None 或非数字类型,显示空字符串
60
-            elif i == 8:  # 假设 Dis_Ass 在索引 8
61
-                if item is not None and isinstance(item, str):
62
-                    item = item  # 显示字符串内容
63
-                else:
64
-                    item = ""  # 如果是 None,显示空字符串
59
+            if item is None:
60
+                item = ""  # 如果是 None,显示空字符串
61
+            else:
62
+                if i == 4 or i == 5:  # 索引4(高差)和索引5(路线长)
63
+                    item = f"{item:.6f}"  # 格式化为6位小数
64
+                elif i == 6:  # 索引 6(修正数)
65
+                    item = f"{item:.2f}"
66
+                elif i == 7:  # 假设 Period_Diff 在索引 7
67
+                    if item is not None and isinstance(item, (int, float)):
68
+                        item = f"{item:.2f}"  # 格式化为2位小数
69
+                    else:
70
+                        item = ""  # 如果是 None 或非数字类型,显示空字符串
71
+                elif i == 8:  # 假设 Dis_Ass 在索引 8
72
+                    if item is not None and isinstance(item, str):
73
+                        item = item  # 显示字符串内容
74
+                    else:
75
+                        item = ""  # 如果是 None,显示空字符串
65
             items.append(QStandardItem(str(item)))
76
             items.append(QStandardItem(str(item)))
77
+
78
+        # 添加修正系数列数据
79
+        if correct_factor_data is not None and correct_factor_data[0] is not None:
80
+            correct_factor = f"{correct_factor_data[0]:.10f}"  # 格式化为10位小数
81
+        else:
82
+            correct_factor = ""
83
+
84
+        items.append(QStandardItem(str(correct_factor)))
85
+
66
         model.appendRow(items)
86
         model.appendRow(items)
67
 
87
 
68
     # 设置并展示表格
88
     # 设置并展示表格
101
 
121
 
102
     # 查询 GC_Input_Param 表中的数据
122
     # 查询 GC_Input_Param 表中的数据
103
     param_query = """
123
     param_query = """
104
-    SELECT ObservationLevel, Ms_Station, Last_StationCount, Last_SumHDiff, Last_SumRLen, New_StationCount, New_SumHDiff, New_SumRLen
124
+    SELECT ObservationLevel, Ms_Station, Last_StationCount, Last_SumHDiff, Last_SumRLen, New_StationCount, New_SumHDiff, New_SumRLen, Correct_Factor
105
     FROM GC_Input_Param
125
     FROM GC_Input_Param
106
     WHERE TableName = ?
126
     WHERE TableName = ?
107
     """
127
     """
122
     input_model.setHorizontalHeaderLabels(input_headers)
142
     input_model.setHorizontalHeaderLabels(input_headers)
123
 
143
 
124
     # 使用 itertools.zip_longest 处理长度不一致的情况
144
     # 使用 itertools.zip_longest 处理长度不一致的情况
125
-    for row_data, param_data in itertools.zip_longest(input_result, param_result, fillvalue=(None, None, None, None, None, None, None, None)):
145
+    for row_data, param_data in itertools.zip_longest(input_result, param_result, fillvalue=(None, None, None, None, None, None, None, None, None)):
126
         items = []
146
         items = []
127
         for i, item in enumerate(row_data):
147
         for i, item in enumerate(row_data):
128
             if item is None:
148
             if item is None:
134
 
154
 
135
         # 添加新的列数据
155
         # 添加新的列数据
136
         if param_data is not None:
156
         if param_data is not None:
137
-            observation_level, ms_station, last_station_count, last_sum_hdiff, last_sum_rlen, new_station_count, new_sum_hdiff, new_sum_rlen = param_data
157
+            observation_level, ms_station, last_station_count, last_sum_hdiff, last_sum_rlen, new_station_count, new_sum_hdiff, new_sum_rlen, correct_factor = param_data
138
         else:
158
         else:
139
-            observation_level, ms_station, last_station_count, last_sum_hdiff, last_sum_rlen, new_station_count, new_sum_hdiff, new_sum_rlen = "", "", "", "", "", "", "", ""
159
+            observation_level, ms_station, last_station_count, last_sum_hdiff, last_sum_rlen, new_station_count, new_sum_hdiff, new_sum_rlen, correct_factor = "", "", "", "", "", "", "", "", ""
140
 
160
 
141
         # 确保 observation_level 和 ms_station 是字符串
161
         # 确保 observation_level 和 ms_station 是字符串
142
         if observation_level is None:
162
         if observation_level is None:
165
             new_sum_rlen = ""
185
             new_sum_rlen = ""
166
         else:
186
         else:
167
             new_sum_rlen = f"{new_sum_rlen:.6f}"
187
             new_sum_rlen = f"{new_sum_rlen:.6f}"
188
+        if correct_factor is None:
189
+            correct_factor = ""
168
 
190
 
169
         items.append(QStandardItem(str(observation_level)))
191
         items.append(QStandardItem(str(observation_level)))
170
         items.append(QStandardItem(f"{ms_station:.2f}" if isinstance(ms_station, (int, float)) else ""))
192
         items.append(QStandardItem(f"{ms_station:.2f}" if isinstance(ms_station, (int, float)) else ""))
193
     cursor1.execute(output_query, (utf_en,))
215
     cursor1.execute(output_query, (utf_en,))
194
     output_result = cursor1.fetchall()
216
     output_result = cursor1.fetchall()
195
 
217
 
218
+    # 查询 GC_Input_Param 表中的 Correct_Factor 字段
219
+    param_query_correct_factor = """
220
+    SELECT Correct_Factor
221
+    FROM GC_Input_Param
222
+    WHERE TableName = ?
223
+    """
224
+    cursor1.execute(param_query_correct_factor, (utf_en,))
225
+    correct_factor_result = cursor1.fetchall()
226
+
196
     # 创建 QStandardItemModel 实例
227
     # 创建 QStandardItemModel 实例
197
     output_model = QStandardItemModel()
228
     output_model = QStandardItemModel()
198
-    output_model.setColumnCount(len(output_result[0]))
229
+    output_model.setColumnCount(len(output_result[0]) + 1)  # 增加一列
199
 
230
 
200
     # 设置表头
231
     # 设置表头
201
-    output_headers = ['序号', '结果期数', '起点', '终点', '高差', '路线长', '修正数', '期间差异', '变形判定']
232
+    output_headers = [
233
+        '序号', '结果期数', '起点', '终点', '高差', '路线长', '修正数', '期间差异', '变形判定', '修正系数'
234
+    ]
202
     output_model.setHorizontalHeaderLabels(output_headers)
235
     output_model.setHorizontalHeaderLabels(output_headers)
203
 
236
 
204
-    for row_data in output_result:
237
+    # 使用 itertools.zip_longest 处理长度不一致的情况
238
+    for row_data, correct_factor_data in itertools.zip_longest(output_result, correct_factor_result, fillvalue=(None, None)):
205
         items = []
239
         items = []
206
         for i, item in enumerate(row_data):
240
         for i, item in enumerate(row_data):
207
-            if i == 4 or i == 5:  # 索引4(高差)和索引5(路线长)
208
-                item = f"{item:.6f}"  # 格式化为6位小数
209
-            elif i == 6:  # 索引 6(修正数)
210
-                item = f"{item:.2f}"
211
-            elif i == 7:  # 假设 Period_Diff 在索引 7
212
-                if item is not None and isinstance(item, (int, float)):
213
-                    item = f"{item:.2f}"  # 格式化为2位小数
214
-                else:
215
-                    item = ""  # 如果是 None 或非数字类型,显示空字符串
216
-            elif i == 8:  # 假设 Dis_Ass 在索引 8
217
-                if item is not None and isinstance(item, str):
218
-                    item = item  # 显示字符串内容
219
-                else:
220
-                    item = ""  # 如果是 None,显示空字符串
241
+            if item is None:
242
+                item = ""  # 如果是 None,显示空字符串
243
+            else:
244
+                if i == 4 or i == 5:  # 索引4(高差)和索引5(路线长)
245
+                    item = f"{item:.6f}"  # 格式化为6位小数
246
+                elif i == 6:  # 索引 6(修正数)
247
+                    item = f"{item:.2f}"
248
+                elif i == 7:  # 假设 Period_Diff 在索引 7
249
+                    if item is not None and isinstance(item, (int, float)):
250
+                        item = f"{item:.2f}"  # 格式化为2位小数
251
+                    else:
252
+                        item = ""  # 如果是 None 或非数字类型,显示空字符串
253
+                elif i == 8:  # 假设 Dis_Ass 在索引 8
254
+                    if item is not None and isinstance(item, str):
255
+                        item = item  # 显示字符串内容
256
+                    else:
257
+                        item = ""  # 如果是 None,显示空字符串
221
             items.append(QStandardItem(str(item)))
258
             items.append(QStandardItem(str(item)))
259
+
260
+        # 添加修正系数列数据
261
+        if correct_factor_data is not None and correct_factor_data[0] is not None:
262
+            correct_factor = f"{correct_factor_data[0]:.10f}"  # 格式化为6位小数
263
+        else:
264
+            correct_factor = ""
265
+
266
+        items.append(QStandardItem(str(correct_factor)))
267
+
222
         output_model.appendRow(items)
268
         output_model.appendRow(items)
223
 
269
 
224
     # 设置并展示输出数据表格
270
     # 设置并展示输出数据表格

Loading…
Cancel
Save