|
@@ -5,11 +5,29 @@ from PySide6.QtGui import QStandardItemModel, QStandardItem
|
5
|
5
|
from PySide6.QtCore import QItemSelectionModel
|
6
|
6
|
|
7
|
7
|
|
8
|
|
-def main_function(ui, db_path, utf_en):
|
|
8
|
+def process_utf_en(utf_en):
|
9
|
9
|
# 确保 utf_en 是字节字符串
|
10
|
10
|
if not isinstance(utf_en, bytes):
|
11
|
11
|
utf_en = utf_en.encode('utf-8')
|
12
|
12
|
|
|
13
|
+ # 将字节字符串解码为普通字符串
|
|
14
|
+ file_name = utf_en.decode('utf-8')
|
|
15
|
+
|
|
16
|
+ # 检查文件后缀名并进行相应处理
|
|
17
|
+ if file_name.endswith('.xls'):
|
|
18
|
+ # 去掉 .xls 后缀并添加 .xlsx 后缀
|
|
19
|
+ file_name = file_name[:-4] + '.xlsx'
|
|
20
|
+
|
|
21
|
+ # 将处理后的字符串重新编码为字节字符串
|
|
22
|
+ utf_en = file_name.encode('utf-8')
|
|
23
|
+
|
|
24
|
+ return utf_en
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+def main_function(ui, db_path, utf_en):
|
|
28
|
+ # 处理 utf_en
|
|
29
|
+ utf_en = process_utf_en(utf_en)
|
|
30
|
+
|
13
|
31
|
# 设置 QTabWidget 的可见性和标签文本
|
14
|
32
|
tabs_to_show = [(0, '水准测段高差计算成果表')]
|
15
|
33
|
for index in range(ui.tabWidget.count()):
|
|
@@ -23,46 +41,67 @@ def main_function(ui, db_path, utf_en):
|
23
|
41
|
db1.text_factory = lambda x: str(x, 'utf-8')
|
24
|
42
|
cursor1 = db1.cursor()
|
25
|
43
|
|
26
|
|
- # 查询 GC_Output_Point 表中的 TableName 字段
|
27
|
|
- query_table_names = "SELECT DISTINCT TableName FROM GC_Output_Point"
|
28
|
|
- cursor1.execute(query_table_names)
|
29
|
|
-
|
|
44
|
+ # 查询 GC_Output_Point 表中的数据
|
30
|
45
|
query = """
|
31
|
46
|
SELECT New_ID, New_ResultName, New_SPName, New_EPName, New_HDiff, New_RLen, Correct_Factor, Period_Diff, Dis_Ass
|
32
|
47
|
FROM GC_Output_Point
|
33
|
48
|
WHERE TableName = ?
|
34
|
49
|
"""
|
35
|
50
|
cursor1.execute(query, (utf_en,))
|
36
|
|
- result = cursor1.fetchall()
|
|
51
|
+ output_result = cursor1.fetchall()
|
|
52
|
+
|
|
53
|
+ # 查询 GC_Input_Param 表中的 Correct_Factor 字段
|
|
54
|
+ param_query_correct_factor = """
|
|
55
|
+ SELECT Correct_Factor
|
|
56
|
+ FROM GC_Input_Param
|
|
57
|
+ WHERE TableName = ?
|
|
58
|
+ """
|
|
59
|
+ cursor1.execute(param_query_correct_factor, (utf_en,))
|
|
60
|
+ correct_factor_result = cursor1.fetchall()
|
|
61
|
+
|
37
|
62
|
cursor1.close()
|
38
|
63
|
db1.close()
|
39
|
64
|
|
40
|
65
|
# 创建 QStandardItemModel 实例
|
41
|
66
|
model = QStandardItemModel()
|
42
|
|
- model.setColumnCount(len(result[0]))
|
|
67
|
+ model.setColumnCount(len(output_result[0]) + 1) # 增加一列
|
43
|
68
|
|
44
|
69
|
# 设置表头
|
45
|
|
- headers = ['序号', '结果期数', '起点', '终点', '高差', '路线长', '修正数', '期间差异', '变形判定']
|
|
70
|
+ headers = ['序号', '结果期数', '起点', '终点', '高差', '路线长', '修正数', '期间差异', '变形判定', '修正系数']
|
46
|
71
|
model.setHorizontalHeaderLabels(headers)
|
47
|
72
|
|
48
|
|
- for row_data in result:
|
|
73
|
+ # 使用 itertools.zip_longest 处理长度不一致的情况
|
|
74
|
+ for row_data, correct_factor_data in itertools.zip_longest(output_result, correct_factor_result,
|
|
75
|
+ fillvalue=(None, None)):
|
49
|
76
|
items = []
|
50
|
77
|
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,显示空字符串
|
|
78
|
+ if item is None:
|
|
79
|
+ item = "" # 如果是 None,显示空字符串
|
|
80
|
+ else:
|
|
81
|
+ if i == 4 or i == 5: # 索引4(高差)和索引5(路线长)
|
|
82
|
+ item = f"{item:.6f}" # 格式化为6位小数
|
|
83
|
+ elif i == 6: # 索引 6(修正数)
|
|
84
|
+ item = f"{item:.2f}"
|
|
85
|
+ elif i == 7: # 假设 Period_Diff 在索引 7
|
|
86
|
+ if item is not None and isinstance(item, (int, float)):
|
|
87
|
+ item = f"{item:.2f}" # 格式化为2位小数
|
|
88
|
+ else:
|
|
89
|
+ item = "" # 如果是 None 或非数字类型,显示空字符串
|
|
90
|
+ elif i == 8: # 假设 Dis_Ass 在索引 8
|
|
91
|
+ if item is not None and isinstance(item, str):
|
|
92
|
+ item = item # 显示字符串内容
|
|
93
|
+ else:
|
|
94
|
+ item = "" # 如果是 None,显示空字符串
|
65
|
95
|
items.append(QStandardItem(str(item)))
|
|
96
|
+
|
|
97
|
+ # 添加修正系数列数据
|
|
98
|
+ if correct_factor_data is not None and correct_factor_data[0] is not None:
|
|
99
|
+ correct_factor = f"{correct_factor_data[0]:.10f}" # 格式化为10位小数
|
|
100
|
+ else:
|
|
101
|
+ correct_factor = ""
|
|
102
|
+
|
|
103
|
+ items.append(QStandardItem(str(correct_factor)))
|
|
104
|
+
|
66
|
105
|
model.appendRow(items)
|
67
|
106
|
|
68
|
107
|
# 设置并展示表格
|
|
@@ -101,7 +140,7 @@ def search_show_function(ui, db_path, utf_en):
|
101
|
140
|
|
102
|
141
|
# 查询 GC_Input_Param 表中的数据
|
103
|
142
|
param_query = """
|
104
|
|
- SELECT ObservationLevel, Ms_Station, Last_StationCount, Last_SumHDiff, Last_SumRLen, New_StationCount, New_SumHDiff, New_SumRLen
|
|
143
|
+ SELECT ObservationLevel, Ms_Station, Last_StationCount, Last_SumHDiff, Last_SumRLen, New_StationCount, New_SumHDiff, New_SumRLen, Correct_Factor
|
105
|
144
|
FROM GC_Input_Param
|
106
|
145
|
WHERE TableName = ?
|
107
|
146
|
"""
|
|
@@ -122,7 +161,8 @@ def search_show_function(ui, db_path, utf_en):
|
122
|
161
|
input_model.setHorizontalHeaderLabels(input_headers)
|
123
|
162
|
|
124
|
163
|
# 使用 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)):
|
|
164
|
+ for row_data, param_data in itertools.zip_longest(input_result, param_result,
|
|
165
|
+ fillvalue=(None, None, None, None, None, None, None, None, None)):
|
126
|
166
|
items = []
|
127
|
167
|
for i, item in enumerate(row_data):
|
128
|
168
|
if item is None:
|
|
@@ -134,9 +174,9 @@ def search_show_function(ui, db_path, utf_en):
|
134
|
174
|
|
135
|
175
|
# 添加新的列数据
|
136
|
176
|
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
|
|
177
|
+ 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
|
178
|
else:
|
139
|
|
- observation_level, ms_station, last_station_count, last_sum_hdiff, last_sum_rlen, new_station_count, new_sum_hdiff, new_sum_rlen = "", "", "", "", "", "", "", ""
|
|
179
|
+ 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
|
180
|
|
141
|
181
|
# 确保 observation_level 和 ms_station 是字符串
|
142
|
182
|
if observation_level is None:
|
|
@@ -165,6 +205,8 @@ def search_show_function(ui, db_path, utf_en):
|
165
|
205
|
new_sum_rlen = ""
|
166
|
206
|
else:
|
167
|
207
|
new_sum_rlen = f"{new_sum_rlen:.6f}"
|
|
208
|
+ if correct_factor is None:
|
|
209
|
+ correct_factor = ""
|
168
|
210
|
|
169
|
211
|
items.append(QStandardItem(str(observation_level)))
|
170
|
212
|
items.append(QStandardItem(f"{ms_station:.2f}" if isinstance(ms_station, (int, float)) else ""))
|
|
@@ -193,32 +235,57 @@ def search_show_function(ui, db_path, utf_en):
|
193
|
235
|
cursor1.execute(output_query, (utf_en,))
|
194
|
236
|
output_result = cursor1.fetchall()
|
195
|
237
|
|
|
238
|
+ # 查询 GC_Input_Param 表中的 Correct_Factor 字段
|
|
239
|
+ param_query_correct_factor = """
|
|
240
|
+ SELECT Correct_Factor
|
|
241
|
+ FROM GC_Input_Param
|
|
242
|
+ WHERE TableName = ?
|
|
243
|
+ """
|
|
244
|
+ cursor1.execute(param_query_correct_factor, (utf_en,))
|
|
245
|
+ correct_factor_result = cursor1.fetchall()
|
|
246
|
+
|
196
|
247
|
# 创建 QStandardItemModel 实例
|
197
|
248
|
output_model = QStandardItemModel()
|
198
|
|
- output_model.setColumnCount(len(output_result[0]))
|
|
249
|
+ output_model.setColumnCount(len(output_result[0]) + 1) # 增加一列
|
199
|
250
|
|
200
|
251
|
# 设置表头
|
201
|
|
- output_headers = ['序号', '结果期数', '起点', '终点', '高差', '路线长', '修正数', '期间差异', '变形判定']
|
|
252
|
+ output_headers = [
|
|
253
|
+ '序号', '结果期数', '起点', '终点', '高差', '路线长', '修正数', '期间差异', '变形判定', '修正系数'
|
|
254
|
+ ]
|
202
|
255
|
output_model.setHorizontalHeaderLabels(output_headers)
|
203
|
256
|
|
204
|
|
- for row_data in output_result:
|
|
257
|
+ # 使用 itertools.zip_longest 处理长度不一致的情况
|
|
258
|
+ for row_data, correct_factor_data in itertools.zip_longest(output_result, correct_factor_result,
|
|
259
|
+ fillvalue=(None, None)):
|
205
|
260
|
items = []
|
206
|
261
|
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,显示空字符串
|
|
262
|
+ if item is None:
|
|
263
|
+ item = "" # 如果是 None,显示空字符串
|
|
264
|
+ else:
|
|
265
|
+ if i == 4 or i == 5: # 索引4(高差)和索引5(路线长)
|
|
266
|
+ item = f"{item:.6f}" # 格式化为6位小数
|
|
267
|
+ elif i == 6: # 索引 6(修正数)
|
|
268
|
+ item = f"{item:.2f}"
|
|
269
|
+ elif i == 7: # 假设 Period_Diff 在索引 7
|
|
270
|
+ if item is not None and isinstance(item, (int, float)):
|
|
271
|
+ item = f"{item:.2f}" # 格式化为2位小数
|
|
272
|
+ else:
|
|
273
|
+ item = "" # 如果是 None 或非数字类型,显示空字符串
|
|
274
|
+ elif i == 8: # 假设 Dis_Ass 在索引 8
|
|
275
|
+ if item is not None and isinstance(item, str):
|
|
276
|
+ item = item # 显示字符串内容
|
|
277
|
+ else:
|
|
278
|
+ item = "" # 如果是 None,显示空字符串
|
221
|
279
|
items.append(QStandardItem(str(item)))
|
|
280
|
+
|
|
281
|
+ # 添加修正系数列数据
|
|
282
|
+ if correct_factor_data is not None and correct_factor_data[0] is not None:
|
|
283
|
+ correct_factor = f"{correct_factor_data[0]:.10f}" # 格式化为6位小数
|
|
284
|
+ else:
|
|
285
|
+ correct_factor = ""
|
|
286
|
+
|
|
287
|
+ items.append(QStandardItem(str(correct_factor)))
|
|
288
|
+
|
222
|
289
|
output_model.appendRow(items)
|
223
|
290
|
|
224
|
291
|
# 设置并展示输出数据表格
|
|
@@ -237,4 +304,3 @@ def search_show_function(ui, db_path, utf_en):
|
237
|
304
|
|
238
|
305
|
# 隐藏 QLabel
|
239
|
306
|
ui.default_remind1.hide()
|
240
|
|
-
|