Просмотр исходного кода

修改了部分UI,针对WD,GC的数据导出进行了修改,修改后导出为一个包含初始数据,成果数据的合并excel表格

wzp 1 месяц назад
Родитель
Сommit
c506be449c
5 измененных файлов: 536 добавлений и 646 удалений
  1. 149
    191
      Front/back/GC/GCExport.py
  2. 295
    328
      Front/back/WD/WDExport.py
  3. 24
    30
      Front/main.py
  4. 66
    88
      Front/main.ui
  5. 2
    9
      Front/modules/ui_functions.py

+ 149
- 191
Front/back/GC/GCExport.py Просмотреть файл

@@ -10,12 +10,120 @@ from openpyxl.utils.dataframe import dataframe_to_rows
10 10
 from openpyxl import Workbook
11 11
 
12 12
 
13
-def export_result_data(ui, utf_en, db_path, export_folder,file_name):
13
+def export_combined_data(ui, utf_en, db_path, export_folder, file_name):
14 14
     try:
15 15
         # 解码 utf_en
16 16
         decoded_utf_en = utf_en.decode('utf-8') if isinstance(utf_en, bytes) else utf_en
17
+
18
+        # 创建一个新的 Excel 工作簿
19
+        wb = Workbook()
20
+
21
+        # 导出初始数据到第一个 sheet
22
+        ws_initial = wb.active
23
+        ws_initial.title = "初始高差数据"
24
+
25
+        # 合并指定的单元格
26
+        merge_cells = ['A1:B1', 'D1:E1', 'F1:G1', 'I1:J1']
27
+        for cell_range in merge_cells:
28
+            ws_initial.merge_cells(cell_range)
29
+
30
+        # 设置合并单元格后的居中对齐
31
+        for cell_range in merge_cells:
32
+            cell = ws_initial[cell_range.split(':')[0]]
33
+            cell.alignment = Alignment(horizontal='center', vertical='center')
34
+
17 35
         # 连接数据库
18 36
         conn = sqlite3.connect(db_path)
37
+        cursor = conn.cursor()
38
+
39
+        # 查询 GC_Input_Param 表获取 ObservationLevel, Last_ResultName, New_ResultName, Ms_Station 字段
40
+        query_observation_level = "SELECT ObservationLevel, Last_ResultName, New_ResultName, Ms_Station FROM GC_Input_Param WHERE TableName=?"
41
+        cursor.execute(query_observation_level, (utf_en,))
42
+        result = cursor.fetchone()
43
+        if result:
44
+            observation_level, last_result_name, new_result_name, ms_station = result
45
+        else:
46
+            observation_level = "未找到"
47
+            last_result_name = "未找到"
48
+            new_result_name = "未找到"
49
+            ms_station = "未找到"
50
+
51
+        # 填写表头信息
52
+        ws_initial['A1'] = '观测等级'
53
+        ws_initial['C1'] = observation_level  # 将 ObservationLevel 写入 C1 单元格
54
+        ws_initial['A2'] = '序号'
55
+        ws_initial['B2'] = '起点'
56
+        ws_initial['C2'] = '终点'
57
+        ws_initial['D2'] = '高差(m)'
58
+        ws_initial['E2'] = '路线长(km)'
59
+        ws_initial['F1'] = '测站全中误差(mm)'
60
+        ws_initial['F2'] = '序号'
61
+        ws_initial['G2'] = '起点'
62
+        ws_initial['H2'] = '终点'
63
+        ws_initial['I2'] = '高差(m)'
64
+        ws_initial['J2'] = '路线长(km)'
65
+
66
+        # 写入 Last_ResultName, New_ResultName, Ms_Station 到相应的单元格
67
+        ws_initial['D1'] = last_result_name
68
+        ws_initial['I1'] = new_result_name
69
+        ws_initial['H1'] = ms_station
70
+
71
+        # 设置 H1 单元格的数值格式为保留两位小数
72
+        ws_initial['H1'].number_format = '0.00'
73
+
74
+        # 查询数据库表为DataFrame,添加 TableName 条件
75
+        query = "SELECT * FROM GC_Input_Point WHERE TableName=?"
76
+        cursor.execute(query, (utf_en,))
77
+        rows = cursor.fetchall()
78
+
79
+        # 获取列名
80
+        column_names = [description[0] for description in cursor.description]
81
+
82
+        # 定义需要的列索引
83
+        last_id_index = column_names.index('Last_ID')
84
+        last_spname_index = column_names.index('Last_SPName')
85
+        last_epname_index = column_names.index('Last_EPName')
86
+        last_hdiff_index = column_names.index('Last_HDiff')
87
+        last_rlen_index = column_names.index('Last_RLen')
88
+        new_id_index = column_names.index('New_ID')
89
+        new_spname_index = column_names.index('New_SPName')
90
+        new_epname_index = column_names.index('New_EPName')
91
+        new_hdiff_index = column_names.index('New_HDiff')
92
+        new_rlen_index = column_names.index('New_RLen')
93
+
94
+        # 填充数据到Excel
95
+        for idx, row in enumerate(rows, start=3):
96
+            ws_initial.cell(row=idx, column=1, value=row[last_id_index])
97
+            ws_initial.cell(row=idx, column=2, value=row[last_spname_index])
98
+            ws_initial.cell(row=idx, column=3, value=row[last_epname_index])
99
+            ws_initial.cell(row=idx, column=4, value=row[last_hdiff_index])
100
+            ws_initial.cell(row=idx, column=5, value=row[last_rlen_index])
101
+            ws_initial.cell(row=idx, column=6, value=row[new_id_index])
102
+            ws_initial.cell(row=idx, column=7, value=row[new_spname_index])
103
+            ws_initial.cell(row=idx, column=8, value=row[new_epname_index])
104
+            ws_initial.cell(row=idx, column=9, value=row[new_hdiff_index])
105
+            ws_initial.cell(row=idx, column=10, value=row[new_rlen_index])
106
+
107
+            # 设置 D, E, I, J 列为强制保留六位小数
108
+            ws_initial.cell(row=idx, column=4).number_format = '0.000000'
109
+            ws_initial.cell(row=idx, column=5).number_format = '0.000000'
110
+            ws_initial.cell(row=idx, column=9).number_format = '0.000000'
111
+            ws_initial.cell(row=idx, column=10).number_format = '0.000000'
112
+
113
+        # 设置B,C,G,H的列宽为9.25
114
+        ws_initial.column_dimensions['B'].width = 9.25
115
+        ws_initial.column_dimensions['C'].width = 9.25
116
+        ws_initial.column_dimensions['G'].width = 9.25
117
+        ws_initial.column_dimensions['H'].width = 9.25
118
+
119
+        # 设置 D, E, I, J 列的列宽为11.5
120
+        ws_initial.column_dimensions['D'].width = 11.5
121
+        ws_initial.column_dimensions['E'].width = 11.5
122
+        ws_initial.column_dimensions['I'].width = 11.5
123
+        ws_initial.column_dimensions['J'].width = 11.5
124
+
125
+        # 导出成果数据到第二个 sheet
126
+        ws_result = wb.create_sheet(title="成果高差数据")
19 127
 
20 128
         # 查询数据库表为DataFrame,添加 TableName 条件
21 129
         query = "SELECT * FROM GC_Output_Point WHERE TableName=?"
@@ -39,15 +147,19 @@ def export_result_data(ui, utf_en, db_path, export_folder,file_name):
39 147
         # 删除 TableName 列
40 148
         if 'TableName' in df.columns:
41 149
             df.drop(columns=['TableName'], inplace=True)
150
+
42 151
         # new HDiff 保留小数点后6位
43 152
         if 'New_HDiff' in df.columns:
44 153
             df['New_HDiff'] = df['New_HDiff'].round(6)
154
+
45 155
         # New_RLen 保留小数点后6位
46 156
         if 'New_RLen' in df.columns:
47 157
             df['New_RLen'] = df['New_RLen'].round(6)
158
+
48 159
         # Correct_Factor 保留小数点后2位
49 160
         if 'Correct_Factor' in df.columns:
50 161
             df['Correct_Factor'] = df['Correct_Factor'].round(2)
162
+
51 163
         # Period_Diff 保留小数点后2位
52 164
         if 'Period_Diff' in df.columns:
53 165
             df['Period_Diff'] = df['Period_Diff'].round(2)
@@ -65,29 +177,27 @@ def export_result_data(ui, utf_en, db_path, export_folder,file_name):
65 177
             'Dis_Ass': '变形判定'
66 178
         }
67 179
         df.rename(columns=column_mapping, inplace=True)
180
+
68 181
         # 查询 GC_Input_Param 表获取 Correct_Factor 字段
69 182
         query_param = "SELECT Correct_Factor FROM GC_Input_Param WHERE TableName=?"
70 183
         correct_factor_df = pd.read_sql_query(query_param, conn, params=(utf_en,))
71 184
 
72 185
         correct_factor = correct_factor_df.iloc[0]['Correct_Factor']
73 186
 
74
-        # 创建一个新的 Excel 工作簿
75
-        wb = Workbook()
76
-        ws = wb.active
77 187
         # 在E1单元格添加内容“修正系数”
78
-        ws.cell(row=1, column=1, value="序号")
79
-        ws.cell(row=1, column=2, value="结果期数")
80
-        ws.cell(row=1, column=3, value="起点")
81
-        ws.cell(row=1, column=4, value="终点")
82
-        ws.cell(row=1, column=5, value="修正系数")
83
-        ws.cell(row=1, column=6, value=correct_factor)
84
-        ws.cell(row=1, column=7, value="修正数")
85
-        ws.cell(row=1, column=8, value="期间差异")
86
-        ws.cell(row=1, column=9, value="变形判定")
188
+        ws_result.cell(row=1, column=1, value="序号")
189
+        ws_result.cell(row=1, column=2, value="结果期数")
190
+        ws_result.cell(row=1, column=3, value="起点")
191
+        ws_result.cell(row=1, column=4, value="终点")
192
+        ws_result.cell(row=1, column=5, value="修正系数")
193
+        ws_result.cell(row=1, column=6, value=correct_factor)
194
+        ws_result.cell(row=1, column=7, value="修正数")
195
+        ws_result.cell(row=1, column=8, value="期间差异")
196
+        ws_result.cell(row=1, column=9, value="变形判定")
87 197
 
88 198
         # 将 DataFrame 写入工作表
89 199
         for r in dataframe_to_rows(df, index=False, header=True):
90
-            ws.append(r)
200
+            ws_result.append(r)
91 201
 
92 202
         # 定义自定义样式
93 203
         style_0_000000 = NamedStyle(name="style_0_000000", number_format='0.000000')
@@ -103,178 +213,57 @@ def export_result_data(ui, utf_en, db_path, export_folder,file_name):
103 213
         correct_factor_col_index = df.columns.get_loc('修正数') + 1  # 获取“修正数”列的索引
104 214
         period_diff_col_index = df.columns.get_loc('期间差异') + 1  # 获取“期间差异”列的索引
105 215
 
106
-        for row in range(2, ws.max_row + 1):  # 从第二行开始,因为第一行为标题行
107
-            ws.cell(row=row, column=hdiff_col_index).style = style_0_000000
108
-            ws.cell(row=row, column=rlen_col_index).style = style_0_000000
109
-            ws.cell(row=row, column=correct_factor_col_index).style = style_0_00
110
-            ws.cell(row=row, column=period_diff_col_index).style = style_0_00
216
+        for row in range(2, ws_result.max_row + 1):  # 从第二行开始,因为第一行为标题行
217
+            ws_result.cell(row=row, column=hdiff_col_index).style = style_0_000000
218
+            ws_result.cell(row=row, column=rlen_col_index).style = style_0_000000
219
+            ws_result.cell(row=row, column=correct_factor_col_index).style = style_0_00
220
+            ws_result.cell(row=row, column=period_diff_col_index).style = style_0_00
111 221
 
112 222
         # 设置 Dis_Ass 列为“变形”的行的字体颜色为红色
113 223
         red_font = Font(color="FF0000")
114 224
         dis_ass_col_index = df.columns.get_loc('变形判定') + 1  # 获取“变形判定”列的索引
115 225
 
116
-        for row in range(2, ws.max_row + 1):  # 从第二行开始,因为第一行为标题行
117
-            cell_value = ws.cell(row=row, column=dis_ass_col_index).value
226
+        for row in range(2, ws_result.max_row + 1):  # 从第二行开始,因为第一行为标题行
227
+            cell_value = ws_result.cell(row=row, column=dis_ass_col_index).value
118 228
             if cell_value == '变形':
119
-                for col in range(1, ws.max_column + 1):
120
-                    ws.cell(row=row, column=col).font = red_font
229
+                for col in range(1, ws_result.max_column + 1):
230
+                    ws_result.cell(row=row, column=col).font = red_font
231
+
121 232
         # 设置列宽
122
-        ws.column_dimensions['E'].width = 12
123
-        ws.column_dimensions['F'].width = 12
233
+        ws_result.column_dimensions['E'].width = 12
234
+        ws_result.column_dimensions['F'].width = 12
124 235
 
125 236
         # 保存 Excel 文件之前添加单元格合并操作
126 237
         merge_cells = ['A1:A2', 'B1:B2', 'C1:C2', 'D1:D2', 'G1:G2', 'H1:H2', 'I1:I2']
127 238
         for cell_range in merge_cells:
128
-            ws.merge_cells(cell_range)
129
-
130
-        # 设置合并单元格后的居中对齐
131
-        for cell_range in merge_cells:
132
-            cell = ws[cell_range.split(':')[0]]
133
-            cell.alignment = Alignment(horizontal='center', vertical='center')
134
-            # 获取当前时间并格式化为字符串,例如:20231010_143000
135
-        timestamp = time.strftime("%Y%m%d", time.localtime())
136
-        # 保存 Excel 文件
137
-        # excel_filename = f"{os.path.splitext(decoded_utf_en)[0]}-成果数据-{timestamp}.xlsx"
138
-        excel_filepath = os.path.join(export_folder, file_name)
139
-        wb.save(excel_filepath)
140
-
141
-        QMessageBox.information(ui, '成功', f'成果文件已成功导出到 {export_folder}')
142
-    except Exception as e:
143
-        QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
144
-    finally:
145
-        # 关闭数据库连接
146
-        conn.close()
147
-
148
-
149
-def export_initial_data(ui, utf_en, db_path, export_folder,file_name):
150
-    try:
151
-        # 解码 utf_en
152
-        decoded_utf_en = utf_en.decode('utf-8') if isinstance(utf_en, bytes) else utf_en
153
-
154
-        # 创建一个新的 Excel 工作簿
155
-        wb = Workbook()
156
-        ws = wb.active
157
-
158
-        # 合并指定的单元格
159
-        merge_cells = ['A1:B1', 'D1:E1', 'F1:G1', 'I1:J1']
160
-        for cell_range in merge_cells:
161
-            ws.merge_cells(cell_range)
239
+            ws_result.merge_cells(cell_range)
162 240
 
163 241
         # 设置合并单元格后的居中对齐
164 242
         for cell_range in merge_cells:
165
-            cell = ws[cell_range.split(':')[0]]
243
+            cell = ws_result[cell_range.split(':')[0]]
166 244
             cell.alignment = Alignment(horizontal='center', vertical='center')
167
-        # 连接数据库
168
-        conn = sqlite3.connect(db_path)
169
-        cursor = conn.cursor()
170
-
171
-        # 查询 GC_Input_Param 表获取 ObservationLevel, Last_ResultName, New_ResultName, Ms_Station 字段
172
-        query_observation_level = "SELECT ObservationLevel, Last_ResultName, New_ResultName, Ms_Station FROM GC_Input_Param WHERE TableName=?"
173
-        cursor.execute(query_observation_level, (utf_en,))
174
-        result = cursor.fetchone()
175
-        if result:
176
-            observation_level, last_result_name, new_result_name, ms_station = result
177
-        else:
178
-            observation_level = "未找到"
179
-            last_result_name = "未找到"
180
-            new_result_name = "未找到"
181
-            ms_station = "未找到"
182 245
 
183
-        # 填写表头信息
184
-        ws['A1'] = '观测等级'
185
-        ws['C1'] = observation_level  # 将 ObservationLevel 写入 C1 单元格
186
-        ws['A2'] = '序号'
187
-        ws['B2'] = '起点'
188
-        ws['C2'] = '终点'
189
-        ws['D2'] = '高差(m)'
190
-        ws['E2'] = '路线长(km)'
191
-        ws['F1'] = '测站全中误差(mm)'
192
-        ws['F2'] = '序号'
193
-        ws['G2'] = '起点'
194
-        ws['H2'] = '终点'
195
-        ws['I2'] = '高差(m)'
196
-        ws['J2'] = '路线长(km)'
197
-
198
-        # 写入 Last_ResultName, New_ResultName, Ms_Station 到相应的单元格
199
-        ws['D1'] = last_result_name
200
-        ws['I1'] = new_result_name
201
-        ws['H1'] = ms_station
202
-
203
-        # 设置 H1 单元格的数值格式为保留两位小数
204
-        ws['H1'].number_format = '0.00'
205
-
206
-        # 连接数据库
207
-        conn = sqlite3.connect(db_path)
208
-        cursor = conn.cursor()
209
-
210
-        # 查询数据库表为DataFrame,添加 TableName 条件
211
-        query = "SELECT * FROM GC_Input_Point WHERE TableName=?"
212
-        cursor.execute(query, (utf_en,))
213
-        rows = cursor.fetchall()
214
-
215
-        # 获取列名
216
-        column_names = [description[0] for description in cursor.description]
217
-
218
-        # 定义需要的列索引
219
-        last_id_index = column_names.index('Last_ID')
220
-        last_spname_index = column_names.index('Last_SPName')
221
-        last_epname_index = column_names.index('Last_EPName')
222
-        last_hdiff_index = column_names.index('Last_HDiff')
223
-        last_rlen_index = column_names.index('Last_RLen')
224
-        new_id_index = column_names.index('New_ID')
225
-        new_spname_index = column_names.index('New_SPName')
226
-        new_epname_index = column_names.index('New_EPName')
227
-        new_hdiff_index = column_names.index('New_HDiff')
228
-        new_rlen_index = column_names.index('New_RLen')
229
-
230
-        # 填充数据到Excel
231
-        for idx, row in enumerate(rows, start=3):
232
-            ws.cell(row=idx, column=1, value=row[last_id_index])
233
-            ws.cell(row=idx, column=2, value=row[last_spname_index])
234
-            ws.cell(row=idx, column=3, value=row[last_epname_index])
235
-            ws.cell(row=idx, column=4, value=row[last_hdiff_index])
236
-            ws.cell(row=idx, column=5, value=row[last_rlen_index])
237
-            ws.cell(row=idx, column=6, value=row[new_id_index])
238
-            ws.cell(row=idx, column=7, value=row[new_spname_index])
239
-            ws.cell(row=idx, column=8, value=row[new_epname_index])
240
-            ws.cell(row=idx, column=9, value=row[new_hdiff_index])
241
-            ws.cell(row=idx, column=10, value=row[new_rlen_index])
242
-
243
-            # 设置 D, E, I, J 列为强制保留六位小数
244
-            ws.cell(row=idx, column=4).number_format = '0.000000'
245
-            ws.cell(row=idx, column=5).number_format = '0.000000'
246
-            ws.cell(row=idx, column=9).number_format = '0.000000'
247
-            ws.cell(row=idx, column=10).number_format = '0.000000'
248
-        # 设置B,C,G,H的列宽为9.25
249
-        ws.column_dimensions['B'].width = 9.25
250
-        ws.column_dimensions['C'].width = 9.25
251
-        ws.column_dimensions['G'].width = 9.25
252
-        ws.column_dimensions['H'].width = 9.25
253
-
254
-        # 设置 D, E, I, J 列的列宽为11.5
255
-        ws.column_dimensions['D'].width = 11.5
256
-        ws.column_dimensions['E'].width = 11.5
257
-        ws.column_dimensions['I'].width = 11.5
258
-        ws.column_dimensions['J'].width = 11.5
259 246
         # 获取当前时间并格式化为字符串,例如:20231010_143000
260 247
         timestamp = time.strftime("%Y%m%d", time.localtime())
248
+
261 249
         # 设置文件名
262
-        # excel_filename = f"{os.path.splitext(decoded_utf_en)[0]}-初始数据-{timestamp}.xlsx"
263 250
         excel_filepath = os.path.join(export_folder, file_name)
264 251
 
265 252
         # 保存 Excel 文件
266 253
         wb.save(excel_filepath)
267 254
 
268
-        QMessageBox.information(ui, '成功', f'初始数据文件已成功导出到 {export_folder}')
255
+        QMessageBox.information(ui, '成功', f'数据文件已导出到 {export_folder}')
269 256
     except Exception as e:
270 257
         if isinstance(e, PermissionError) or (isinstance(e, OSError) and e.errno == 13):
271 258
             QMessageBox.critical(ui, '错误', '请确认文件没有被其他程序(如Excel、文本编辑器等)打开。')
272 259
         else:
273
-            QMessageBox.critical(ui, '错误', f'导出初始数据过程中发生错误: {str(e)}')
260
+            QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
274 261
             print(e)
262
+    finally:
263
+        # 关闭数据库连接
264
+        conn.close()
275 265
 
276
-
277
-def export_example_data(ui, utf_en, db_path, export_folder,file_name):
266
+def export_example_data(ui, utf_en, db_path, export_folder, file_name):
278 267
     try:
279 268
         # 解码 utf_en
280 269
         decoded_utf_en = utf_en.decode('utf-8') if isinstance(utf_en, bytes) else utf_en
@@ -419,42 +408,11 @@ def process_utf_en(utf_en):
419 408
 
420 409
     return utf_en
421 410
 
422
-def main_function_initial(ui, utf_en, db_path,export_folder,file_name):
423
-
424
-    # # 获取应用的安装目录
425
-    # app_install_dir = os.getcwd()  # 假设脚本文件位于应用的安装目录下
426
-    # export_folder = os.path.join(app_install_dir, 'Export')
427
-    #
428
-    # # 如果 Export 文件夹不存在,则创建它
429
-    # if not os.path.exists(export_folder):
430
-    #     os.makedirs(export_folder)
431 411
 
412
+def main_function_example(ui, utf_en, db_path, export_folder, file_name):
432 413
     # 调用导出初始数据函数
433
-    export_initial_data(ui, utf_en, db_path, export_folder,file_name)
414
+    export_example_data(ui, utf_en, db_path, export_folder, file_name)
434 415
 
435 416
 
436
-def main_function_example(ui, utf_en, db_path,export_folder,file_name):
437
-
438
-    # # 获取应用的安装目录
439
-    # app_install_dir = os.getcwd()  # 假设脚本文件位于应用的安装目录下
440
-    # example_folder = os.path.join(app_install_dir, 'Example')
441
-    #
442
-    # # 如果 Example 文件夹不存在,则创建它
443
-    # if not os.path.exists(example_folder):
444
-    #     os.makedirs(example_folder)
445
-
446
-    # 调用导出初始数据函数
447
-    export_example_data(ui, utf_en, db_path, export_folder,file_name)
448
-
449
-def main_function_result(ui, utf_en, db_path,export_folder,file_name):
450
-    # 处理 utf_en
451
-    utf_en = process_utf_en(utf_en)
452
-    # # 获取应用的安装目录
453
-    # app_install_dir = os.getcwd()  # 假设脚本文件位于应用的安装目录下
454
-    # export_folder = os.path.join(app_install_dir, 'Export')
455
-
456
-    # # 如果 Export 文件夹不存在,则创建它
457
-    # if not os.path.exists(export_folder):
458
-    #     os.makedirs(export_folder)
459
-    # 调用导出结果函数
460
-    export_result_data(ui, utf_en, db_path, export_folder,file_name)
417
+def main_function_combined(ui, utf_en, db_path, export_folder, file_name):
418
+    export_combined_data(ui, utf_en, db_path, export_folder, file_name)

+ 295
- 328
Front/back/WD/WDExport.py Просмотреть файл

@@ -47,295 +47,297 @@ def Arrange_Data1(list1):
47 47
     return list2
48 48
 
49 49
 
50
-def openpyxl_write(folder_name, dbpath, filename,file_name):
51
-    utf_en = filename.encode('utf-8')
52
-    # 新建对应的excel
53
-    wb = openpyxl.Workbook()
54
-    ws1 = wb.create_sheet('稳定性分析成果表')
55
-    ws2 = wb.create_sheet('改算模型')
56
-    ws3 = wb['Sheet']
57
-    wb.remove(ws3)
58
-
59
-    # ws1部分(成果表)
60
-    # 提取数据
61
-    db1 = sqlite3.connect(dbpath)
62
-    # 获取游标
63
-    cursor1 = db1.cursor()
64
-    sqlstr1 = 'select PointName,First_X,First_Y,Last_X,Last_Y,Last_Wight,Result_X,Result_Y,New_Wight,New_FirstX,New_FirstY,New_FirstP,NFDis_Ass,New_LastX,New_LastY,New_LastP,NLDis_Ass,First_ResultName,Last_ResultName,New_ResultName from WD_Result_Point WHERE TableName = ?'
65
-    cursor1.execute(sqlstr1, (utf_en,))
66
-    # 获取结果集
67
-    result1 = cursor1.fetchall()
68
-    # 整理数据
69
-    plist1 = Arrange_Data1(result1)
70
-    ws1.column_dimensions['B'].width = 15
71
-    ws1.column_dimensions['C'].width = 15
72
-    ws1.column_dimensions['D'].width = 15
73
-    ws1.column_dimensions['E'].width = 15
74
-    ws1.column_dimensions['F'].width = 5
75
-    ws1.column_dimensions['G'].width = 15
76
-    ws1.column_dimensions['H'].width = 15
77
-    ws1.column_dimensions['I'].width = 5
78
-    ws1.column_dimensions['M'].width = 5
79
-    ws1.column_dimensions['Q'].width = 5
80
-    ws1.column_dimensions['J'].width = 8
81
-    ws1.column_dimensions['K'].width = 8
82
-    ws1.column_dimensions['L'].width = 8
83
-    ws1.column_dimensions['N'].width = 8
84
-    ws1.column_dimensions['O'].width = 8
85
-    ws1.column_dimensions['P'].width = 8
86
-    ws1.merge_cells(start_row=1, end_row=1,
87
-                    start_column=1, end_column=17)
88
-    ws1.cell(1, 1).value = '稳定性分析成果表'
89
-    ws_area = ws1["A1:Q2"]
90
-    alignment_center = Alignment(horizontal='center', vertical='center')  # 指定区域单元格居中
91
-    for i in ws_area:
92
-        for j in i:
93
-            j.alignment = alignment_center
94
-    alignment_right = Alignment(horizontal='right', vertical='center')
95
-    ws1.merge_cells(start_row=2, end_row=3,
96
-                    start_column=1, end_column=1)
97
-    ws1.cell(2, 1).value = '点号'
98
-    ws1.merge_cells(start_row=2, end_row=2,
99
-                    start_column=2, end_column=3)
100
-    ws1.cell(2, 2).value = plist1[0][17]
101
-    ws1.merge_cells(start_row=2, end_row=2,
102
-                    start_column=4, end_column=6)
103
-    ws1.cell(2, 4).value = plist1[0][18]
104
-    ws1.merge_cells(start_row=2, end_row=2,
105
-                    start_column=7, end_column=9)
106
-
107
-    ws1.cell(2, 7).value = plist1[0][19]
108
-    ws1.merge_cells(start_row=2, end_row=2,
109
-                    start_column=10, end_column=12)
110
-    ws1.cell(2, 10).value = '本期-首期(mm)'
111
-    ws1.merge_cells(start_row=2, end_row=3,
112
-                    start_column=13, end_column=13)
113
-    ws1.cell(2, 13).value = '变形判定'
114
-    ws1.merge_cells(start_row=2, end_row=2,
115
-                    start_column=14, end_column=16)
116
-    ws1.cell(2, 14).value = '本期-上期(mm)'
117
-    ws1.merge_cells(start_row=2, end_row=3,
118
-                    start_column=17, end_column=17)
119
-    ws1.cell(2, 17).value = '变形判定'
120
-    ws1.cell(2, 13).alignment = Alignment(wrap_text=True)
121
-    ws1.cell(2, 17).alignment = Alignment(wrap_text=True)
122
-    ws1.cell(3, 2).value = 'X(m)'
123
-    ws1.cell(3, 3).value = 'Y(m)'
124
-    ws1.cell(3, 4).value = 'X(m)'
125
-    ws1.cell(3, 5).value = 'Y(m)'
126
-    ws1.cell(3, 6).value = '权'
127
-    ws1.cell(3, 7).value = 'X(m)'
128
-    ws1.cell(3, 8).value = 'Y(m)'
129
-    ws1.cell(3, 9).value = '权'
130
-    ws1.cell(3, 10).value = '△X'
131
-    ws1.cell(3, 11).value = '△Y'
132
-    ws1.cell(3, 12).value = '△XY'
133
-    ws1.cell(3, 14).value = '△X'
134
-    ws1.cell(3, 15).value = '△Y'
135
-    ws1.cell(3, 16).value = '△XY'
136
-
137
-    row1 = 4
138
-    for data1 in plist1:
139
-        ws1.cell(row1, 1).value = data1[0]
140
-        ws1.cell(row1, 2).value = round(data1[1], 4)
141
-        ws1.cell(row1, 3).value = round(data1[2], 4)
142
-        ws1.cell(row1, 4).value = round(data1[3], 4)
143
-        ws1.cell(row1, 5).value = round(data1[4], 4)
144
-        ws1.cell(row1, 6).value = int(data1[5])
145
-        ws1.cell(row1, 7).value = round(data1[6], 4)
146
-        ws1.cell(row1, 8).value = round(data1[7], 4)
147
-        ws1.cell(row1, 9).value = int(data1[8])
148
-        ws1.cell(row1, 10).value = round(data1[9], 1)
149
-        ws1.cell(row1, 11).value = round(data1[10], 1)
150
-        ws1.cell(row1, 12).value = round(data1[11], 1)
151
-        if data1[12] == '稳定':
152
-            ws1.cell(row1, 13).value = ''
153
-        else:
154
-            ws1.cell(row1, 13).value = data1[12]
155
-        ws1.cell(row1, 14).value = round(data1[13], 1)
156
-        ws1.cell(row1, 15).value = round(data1[14], 1)
157
-        ws1.cell(row1, 16).value = round(data1[15], 1)
158
-        if data1[16] == '稳定':
159
-            ws1.cell(row1, 17).value = ''
160
-        else:
161
-            ws1.cell(row1, 17).value = data1[16]
162
-        row1 = row1 + 1
163
-
164
-    # ws2部分(公式)
165
-    # 提取数据
166
-    sqlstr2 = 'select Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3 from WD_Result_Param WHERE TableName = ?'
167
-    cursor1.execute(sqlstr2, (utf_en,))
168
-    # 获取结果集
169
-    result3 = cursor1.fetchall()
170
-    newname = result3[0][1].decode('utf-8')
171
-    lastname = result3[0][0].decode('utf-8')
172
-    ws2.column_dimensions['A'].width = 75
173
-    ws_area = ws2["A1:A5"]
174
-    alignment_center = Alignment(horizontal='left', vertical='center')  # 指定区域单元格居中
175
-    for i in ws_area:
176
-        for j in i:
177
-            j.alignment = alignment_center
178
-    str1 = newname + '--' + lastname + '已知系统转换公式:'
179
-    ws2.cell(1, 1).value = str1
180
-    str2 = 'X=(' + str(round(result3[0][2], 14)) + ')·x+(' + str(round(result3[0][3], 14)) + ')·y+(' + str(
181
-        round(result3[0][4], 11)) + ')'
182
-    ws2.cell(2, 1).value = str2
183
-    str3 = 'Y=(' + str(round(result3[0][5], 14)) + ')·x+(' + str(round(result3[0][6], 14)) + ')·y+(' + str(
184
-        round(result3[0][7], 11)) + ')'
185
-    ws2.cell(3, 1).value = str3
186
-    str4 = '式中:x、y为' + newname
187
-    ws2.cell(4, 1).value = str4
188
-    str5 = '     X、Y为' + lastname + '已知系统的' + newname + '归算坐标'
189
-    ws2.cell(5, 1).value = str5
190
-    # 获取当前时间并格式化为字符串,例如:20231010_143000
191
-    timestamp = time.strftime("%Y%m%d", time.localtime())
192
-    # 保存 Excel 文件
193
-    # excel_filename = f"{os.path.splitext(filename)[0]}-成果数据-{timestamp}.xlsx"
194
-    excel_filepath = os.path.join(folder_name, file_name)
195
-    wb.save(excel_filepath)
196
-
197
-
198
-def export_initial_data(ui, db_path, utf_en, export_folder,file_name):
199
-    # 获取当前时间并格式化为字符串,例如:20231010_143000
200
-    timestamp = time.strftime("%Y%m%d", time.localtime())
201
-    # 解码文件名并去掉后缀名
202
-    decoded_utf_en = utf_en.decode('utf-8') if isinstance(utf_en, bytes) else utf_en
203
-    # excel_file_name = f"{os.path.splitext(decoded_utf_en)[0]}-初始数据-{timestamp}.xlsx"
204
-    excel_path = os.path.join(export_folder, file_name)
205
-
206
-    # 创建一个新的工作簿和工作表
207
-    wb = openpyxl.Workbook()
208
-    ws = wb.active
209
-
210
-    # 连接到数据库
211
-    conn = sqlite3.connect(db_path)
212
-    cursor = conn.cursor()
213
-
214
-    # 查询WD_Input_Param表中的数据
215
-    query = """
216
-    SELECT New_ResultName, Last_ResultName, Avg_SL, Ms_Dir, SL_Count, Dir_Count, Scale_Value, First_ResultName
217
-    FROM WD_Input_Param
218
-    WHERE TableName = ?
219
-    """
220
-    cursor.execute(query, (utf_en,))
221
-    result = cursor.fetchone()
222
-
223
-    # 创建样式来保留指定的小数位数
224
-    decimal_style_3 = NamedStyle(name="decimal_style_3")
225
-    decimal_style_3.number_format = '0.0000'
226
-    decimal_style_3.alignment = Alignment(horizontal='center', vertical='center')
227
-
228
-    decimal_style_1 = NamedStyle(name="decimal_style_1")
229
-    decimal_style_1.number_format = '0.0'
230
-    decimal_style_1.alignment = Alignment(horizontal='center', vertical='center')
231
-
232
-    decimal_style_4 = NamedStyle(name="decimal_style_4")
233
-    decimal_style_4.number_format = '0'
234
-    decimal_style_4.alignment = Alignment(horizontal='center', vertical='center')
235
-
236
-    if result:
237
-        new_result_name, last_result_name, avg_sl, ms_dir, sl_count, dir_count, scale_value, first_result_name = result
238
-
239
-        # 填充数据到Excel并应用样式
240
-        ws['B1'] = new_result_name
241
-        ws['B1'].alignment = Alignment(horizontal='center', vertical='center')
242
-
243
-        ws['D1'] = last_result_name
244
-        ws['D1'].alignment = Alignment(horizontal='center', vertical='center')
245
-
246
-        ws['G1'] = first_result_name  # 新增:填入First_ResultName
247
-        ws['G1'].alignment = Alignment(horizontal='center', vertical='center')  # 新增:设置居中对齐
248
-
249
-        ws['J1'] = avg_sl
250
-        ws['J1'].style = decimal_style_3
251
-
252
-        ws['J2'] = ms_dir
253
-        ws['J2'].alignment = Alignment(horizontal='center', vertical='center')
254
-
255
-        ws['J3'] = sl_count
256
-        ws['J3'].style = decimal_style_4
257
-
258
-        ws['J4'] = dir_count
259
-        ws['J4'].style = decimal_style_4
260
-
261
-        ws['J5'] = scale_value
262
-        ws['J5'].style = decimal_style_4
263
-
264
-        # 合并单元格
265
-        ws.merge_cells('B1:C1')
266
-        ws.merge_cells('D1:E1')
267
-        ws.merge_cells('G1:H1')
268
-
269
-        # 设置列宽
270
-        ws.column_dimensions['B'].width = 12.5
271
-        ws.column_dimensions['C'].width = 12.5
272
-        ws.column_dimensions['D'].width = 12.5
273
-        ws.column_dimensions['E'].width = 12.5
274
-        ws.column_dimensions['F'].width = 3
275
-        ws.column_dimensions['F'].alignment = Alignment(horizontal='center', vertical='center')  # 新增:设置F列居中对齐
276
-        ws.column_dimensions['G'].width = 12.5
277
-        ws.column_dimensions['H'].width = 12.5
278
-        ws.column_dimensions['I'].width = 14
279
-        ws.column_dimensions['J'].width = 10
280
-
281
-    # 设置表头
282
-    headers = [
283
-        ("A2", "点名"),
284
-        ("B2", "高斯坐标x(m)"),
285
-        ("C2", "高斯坐标y(m)"),
286
-        ("D2", "高斯坐标x(m)"),
287
-        ("E2", "高斯坐标y(m)"),
288
-        ("F2", "权"),
289
-        ("G2", "高斯坐标x(m)"),
290
-        ("H2", "高斯坐标y(m)"),
291
-        ("I1", "平均边长"),
292
-        ("I2", "方向值中误差"),
293
-        ("I3", "总边数"),
294
-        ("I4", "总方向数"),
295
-        ("I5", "缩放值")
296
-    ]
297
-
298
-    for cell, value in headers:
299
-        ws[cell] = value
300
-        ws[cell].alignment = Alignment(horizontal='center', vertical='center')
301
-
302
-    # 查询WD_Input_Point表中的数据
303
-    query_point = """
304
-    SELECT PointName, New_X, New_Y, Last_X, Last_Y, Wight, First_X, First_Y
305
-    FROM WD_Input_Point
306
-    WHERE TableName = ?
307
-    """
308
-    cursor.execute(query_point, (utf_en,))
309
-    results_point = cursor.fetchall()
310
-
311
-    # 创建一个样式来强制保留四位小数
312
-    decimal_style = NamedStyle(name="decimal_style")
313
-    decimal_style.number_format = '0000.0000'
314
-
315
-    # 填充数据到Excel
316
-    for idx, (point_name, new_x, new_y, last_x, last_y, wight, first_x, first_y) in enumerate(results_point, start=3):
317
-        ws[f'A{idx}'] = point_name
318
-        ws[f'B{idx}'] = round(new_x, 4)
319
-        ws[f'C{idx}'] = round(new_y, 4)
320
-        ws[f'D{idx}'] = round(last_x, 4)
321
-        ws[f'E{idx}'] = round(last_y, 4)
322
-        ws[f'F{idx}'] = round(wight, 0)  # 新增
323
-        ws[f'G{idx}'] = round(first_x, 4)  # 新增
324
-        ws[f'H{idx}'] = round(first_y, 4)  # 新增
325
-
326
-        # 应用样式以保留四位小数
327
-        ws[f'B{idx}'].style = decimal_style
328
-        ws[f'C{idx}'].style = decimal_style
329
-        ws[f'D{idx}'].style = decimal_style
330
-        ws[f'E{idx}'].style = decimal_style
331
-        ws[f'G{idx}'].style = decimal_style  # 新增
332
-        ws[f'H{idx}'].style = decimal_style  # 新增
50
+def export_combined_data(ui, db_path, utf_en, export_folder, file_name):
51
+    try:
52
+        # 解码文件名并去掉后缀名
53
+        decoded_utf_en = utf_en.decode('utf-8') if isinstance(utf_en, bytes) else utf_en
54
+        excel_path = os.path.join(export_folder, file_name)
55
+
56
+        # 创建一个新的工作簿
57
+        wb = openpyxl.Workbook()
58
+
59
+        # 创建三个Sheet
60
+        ws_initial = wb.create_sheet('原始数据')
61
+        ws_stability = wb.create_sheet('稳定性分析成果表')
62
+        ws_model = wb.create_sheet('改算模型')
63
+
64
+        # 删除默认的Sheet
65
+        ws_default = wb['Sheet']
66
+        wb.remove(ws_default)
67
+
68
+        # 连接到数据库
69
+        conn = sqlite3.connect(db_path)
70
+        cursor = conn.cursor()
71
+
72
+        # 查询WD_Input_Param表中的数据
73
+        query_param = """
74
+        SELECT New_ResultName, Last_ResultName, Avg_SL, Ms_Dir, SL_Count, Dir_Count, Scale_Value, First_ResultName
75
+        FROM WD_Input_Param
76
+        WHERE TableName = ?
77
+        """
78
+        cursor.execute(query_param, (utf_en,))
79
+        result_param = cursor.fetchone()
80
+
81
+        # 创建样式来保留指定的小数位数
82
+        decimal_style_3 = NamedStyle(name="decimal_style_3")
83
+        decimal_style_3.number_format = '0.0000'
84
+        decimal_style_3.alignment = Alignment(horizontal='center', vertical='center')
85
+
86
+        decimal_style_1 = NamedStyle(name="decimal_style_1")
87
+        decimal_style_1.number_format = '0.0'
88
+        decimal_style_1.alignment = Alignment(horizontal='center', vertical='center')
89
+
90
+        decimal_style_4 = NamedStyle(name="decimal_style_4")
91
+        decimal_style_4.number_format = '0'
92
+        decimal_style_4.alignment = Alignment(horizontal='center', vertical='center')
93
+
94
+        if result_param:
95
+            new_result_name, last_result_name, avg_sl, ms_dir, sl_count, dir_count, scale_value, first_result_name = result_param
96
+
97
+            # 填充数据到“原始数据”Sheet并应用样式
98
+            ws_initial['B1'] = new_result_name
99
+            ws_initial['B1'].alignment = Alignment(horizontal='center', vertical='center')
100
+
101
+            ws_initial['D1'] = last_result_name
102
+            ws_initial['D1'].alignment = Alignment(horizontal='center', vertical='center')
103
+
104
+            ws_initial['G1'] = first_result_name
105
+            ws_initial['G1'].alignment = Alignment(horizontal='center', vertical='center')
106
+
107
+            ws_initial['J1'] = avg_sl
108
+            ws_initial['J1'].style = decimal_style_3
109
+
110
+            ws_initial['J2'] = ms_dir
111
+            ws_initial['J2'].alignment = Alignment(horizontal='center', vertical='center')
112
+
113
+            ws_initial['J3'] = sl_count
114
+            ws_initial['J3'].style = decimal_style_4
115
+
116
+            ws_initial['J4'] = dir_count
117
+            ws_initial['J4'].style = decimal_style_4
118
+
119
+            ws_initial['J5'] = scale_value
120
+            ws_initial['J5'].style = decimal_style_4
121
+
122
+            # 合并单元格
123
+            ws_initial.merge_cells('B1:C1')
124
+            ws_initial.merge_cells('D1:E1')
125
+            ws_initial.merge_cells('G1:H1')
126
+
127
+            # 设置列宽
128
+            ws_initial.column_dimensions['B'].width = 12.5
129
+            ws_initial.column_dimensions['C'].width = 12.5
130
+            ws_initial.column_dimensions['D'].width = 12.5
131
+            ws_initial.column_dimensions['E'].width = 12.5
132
+            ws_initial.column_dimensions['F'].width = 3
133
+            ws_initial.column_dimensions['G'].width = 12.5
134
+            ws_initial.column_dimensions['H'].width = 12.5
135
+            ws_initial.column_dimensions['I'].width = 14
136
+            ws_initial.column_dimensions['J'].width = 10
137
+
138
+        # 设置表头
139
+        headers = [
140
+            ("A2", "点名"),
141
+            ("B2", "高斯坐标x(m)"),
142
+            ("C2", "高斯坐标y(m)"),
143
+            ("D2", "高斯坐标x(m)"),
144
+            ("E2", "高斯坐标y(m)"),
145
+            ("F2", "权"),
146
+            ("G2", "高斯坐标x(m)"),
147
+            ("H2", "高斯坐标y(m)"),
148
+            ("I1", "平均边长"),
149
+            ("I2", "方向值中误差"),
150
+            ("I3", "总边数"),
151
+            ("I4", "总方向数"),
152
+            ("I5", "缩放值")
153
+        ]
154
+
155
+        for cell, value in headers:
156
+            ws_initial[cell] = value
157
+            ws_initial[cell].alignment = Alignment(horizontal='center', vertical='center')
158
+
159
+        # 查询WD_Input_Point表中的数据
160
+        query_point = """
161
+        SELECT PointName, New_X, New_Y, Last_X, Last_Y, Wight, First_X, First_Y
162
+        FROM WD_Input_Point
163
+        WHERE TableName = ?
164
+        """
165
+        cursor.execute(query_point, (utf_en,))
166
+        results_point = cursor.fetchall()
167
+
168
+        # 创建一个样式来强制保留四位小数
169
+        decimal_style = NamedStyle(name="decimal_style")
170
+        decimal_style.number_format = '0000.0000'
171
+
172
+        # 填充数据到“原始数据”Sheet
173
+        for idx, (point_name, new_x, new_y, last_x, last_y, wight, first_x, first_y) in enumerate(results_point,
174
+                                                                                                  start=3):
175
+            ws_initial[f'A{idx}'] = point_name
176
+            ws_initial[f'B{idx}'] = round(new_x, 4)
177
+            ws_initial[f'C{idx}'] = round(new_y, 4)
178
+            ws_initial[f'D{idx}'] = round(last_x, 4)
179
+            ws_initial[f'E{idx}'] = round(last_y, 4)
180
+            ws_initial[f'F{idx}'] = round(wight, 0)
181
+            ws_initial[f'G{idx}'] = round(first_x, 4)
182
+            ws_initial[f'H{idx}'] = round(first_y, 4)
183
+
184
+            # 应用样式以保留四位小数
185
+            ws_initial[f'B{idx}'].style = decimal_style
186
+            ws_initial[f'C{idx}'].style = decimal_style
187
+            ws_initial[f'D{idx}'].style = decimal_style
188
+            ws_initial[f'E{idx}'].style = decimal_style
189
+            ws_initial[f'G{idx}'].style = decimal_style
190
+            ws_initial[f'H{idx}'].style = decimal_style
191
+
192
+        # 提取“稳定性分析成果表”数据
193
+        sqlstr1 = 'select PointName,First_X,First_Y,Last_X,Last_Y,Last_Wight,Result_X,Result_Y,New_Wight,New_FirstX,New_FirstY,New_FirstP,NFDis_Ass,New_LastX,New_LastY,New_LastP,NLDis_Ass,First_ResultName,Last_ResultName,New_ResultName from WD_Result_Point WHERE TableName = ?'
194
+        cursor.execute(sqlstr1, (utf_en,))
195
+        result1 = cursor.fetchall()
196
+        plist1 = Arrange_Data1(result1)
197
+
198
+        # 设置“稳定性分析成果表”列宽
199
+        ws_stability.column_dimensions['B'].width = 15
200
+        ws_stability.column_dimensions['C'].width = 15
201
+        ws_stability.column_dimensions['D'].width = 15
202
+        ws_stability.column_dimensions['E'].width = 15
203
+        ws_stability.column_dimensions['F'].width = 5
204
+        ws_stability.column_dimensions['G'].width = 15
205
+        ws_stability.column_dimensions['H'].width = 15
206
+        ws_stability.column_dimensions['I'].width = 5
207
+        ws_stability.column_dimensions['M'].width = 5
208
+        ws_stability.column_dimensions['Q'].width = 5
209
+        ws_stability.column_dimensions['J'].width = 8
210
+        ws_stability.column_dimensions['K'].width = 8
211
+        ws_stability.column_dimensions['L'].width = 8
212
+        ws_stability.column_dimensions['N'].width = 8
213
+        ws_stability.column_dimensions['O'].width = 8
214
+        ws_stability.column_dimensions['P'].width = 8
215
+
216
+        # 设置“稳定性分析成果表”表头
217
+        ws_stability.merge_cells(start_row=1, end_row=1, start_column=1, end_column=17)
218
+        ws_stability.cell(1, 1).value = '稳定性分析成果表'
219
+        ws_area = ws_stability["A1:Q2"]
220
+        alignment_center = Alignment(horizontal='center', vertical='center')
221
+        for i in ws_area:
222
+            for j in i:
223
+                j.alignment = alignment_center
224
+
225
+        alignment_right = Alignment(horizontal='right', vertical='center')
226
+        ws_stability.merge_cells(start_row=2, end_row=3, start_column=1, end_column=1)
227
+        ws_stability.cell(2, 1).value = '点号'
228
+
229
+        ws_stability.merge_cells(start_row=2, end_row=2, start_column=2, end_column=3)
230
+        ws_stability.cell(2, 2).value = plist1[0][17]
231
+
232
+        ws_stability.merge_cells(start_row=2, end_row=2, start_column=4, end_column=6)
233
+        ws_stability.cell(2, 4).value = plist1[0][18]
234
+
235
+        ws_stability.merge_cells(start_row=2, end_row=2, start_column=7, end_column=9)
236
+        ws_stability.cell(2, 7).value = plist1[0][19]
237
+
238
+        ws_stability.merge_cells(start_row=2, end_row=2, start_column=10, end_column=12)
239
+        ws_stability.cell(2, 10).value = '本期-首期(mm)'
240
+
241
+        ws_stability.merge_cells(start_row=2, end_row=3, start_column=13, end_column=13)
242
+        ws_stability.cell(2, 13).value = '变形判定'
243
+
244
+        ws_stability.merge_cells(start_row=2, end_row=2, start_column=14, end_column=16)
245
+        ws_stability.cell(2, 14).value = '本期-上期(mm)'
246
+
247
+        ws_stability.merge_cells(start_row=2, end_row=3, start_column=17, end_column=17)
248
+        ws_stability.cell(2, 17).value = '变形判定'
249
+
250
+        ws_stability.cell(2, 13).alignment = Alignment(wrap_text=True)
251
+        ws_stability.cell(2, 17).alignment = Alignment(wrap_text=True)
252
+
253
+        ws_stability.cell(3, 2).value = 'X(m)'
254
+        ws_stability.cell(3, 3).value = 'Y(m)'
255
+        ws_stability.cell(3, 4).value = 'X(m)'
256
+        ws_stability.cell(3, 5).value = 'Y(m)'
257
+        ws_stability.cell(3, 6).value = '权'
258
+        ws_stability.cell(3, 7).value = 'X(m)'
259
+        ws_stability.cell(3, 8).value = 'Y(m)'
260
+        ws_stability.cell(3, 9).value = '权'
261
+        ws_stability.cell(3, 10).value = '△X'
262
+        ws_stability.cell(3, 11).value = '△Y'
263
+        ws_stability.cell(3, 12).value = '△XY'
264
+        ws_stability.cell(3, 14).value = '△X'
265
+        ws_stability.cell(3, 15).value = '△Y'
266
+        ws_stability.cell(3, 16).value = '△XY'
267
+
268
+        row1 = 4
269
+        for data1 in plist1:
270
+            ws_stability.cell(row1, 1).value = data1[0]
271
+            ws_stability.cell(row1, 2).value = round(data1[1], 4)
272
+            ws_stability.cell(row1, 3).value = round(data1[2], 4)
273
+            ws_stability.cell(row1, 4).value = round(data1[3], 4)
274
+            ws_stability.cell(row1, 5).value = round(data1[4], 4)
275
+            ws_stability.cell(row1, 6).value = int(data1[5])
276
+            ws_stability.cell(row1, 7).value = round(data1[6], 4)
277
+            ws_stability.cell(row1, 8).value = round(data1[7], 4)
278
+            ws_stability.cell(row1, 9).value = int(data1[8])
279
+            ws_stability.cell(row1, 10).value = round(data1[9], 1)
280
+            ws_stability.cell(row1, 11).value = round(data1[10], 1)
281
+            ws_stability.cell(row1, 12).value = round(data1[11], 1)
282
+            if data1[12] == '稳定':
283
+                ws_stability.cell(row1, 13).value = ''
284
+            else:
285
+                ws_stability.cell(row1, 13).value = data1[12]
286
+            ws_stability.cell(row1, 14).value = round(data1[13], 1)
287
+            ws_stability.cell(row1, 15).value = round(data1[14], 1)
288
+            ws_stability.cell(row1, 16).value = round(data1[15], 1)
289
+            if data1[16] == '稳定':
290
+                ws_stability.cell(row1, 17).value = ''
291
+            else:
292
+                ws_stability.cell(row1, 17).value = data1[16]
293
+            row1 += 1
294
+
295
+        # 提取“改算模型”数据
296
+        sqlstr2 = 'select Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3 from WD_Result_Param WHERE TableName = ?'
297
+        cursor.execute(sqlstr2, (utf_en,))
298
+        result3 = cursor.fetchall()
299
+        newname = result3[0][1].decode('utf-8')
300
+        lastname = result3[0][0].decode('utf-8')
301
+
302
+        # 设置“改算模型”列宽
303
+        ws_model.column_dimensions['A'].width = 75
304
+
305
+        # 设置“改算模型”表头
306
+        ws_area = ws_model["A1:A5"]
307
+        alignment_center = Alignment(horizontal='left', vertical='center')
308
+        for i in ws_area:
309
+            for j in i:
310
+                j.alignment = alignment_center
311
+
312
+        # 填充“改算模型”数据
313
+        str1 = newname + '--' + lastname + '已知系统转换公式:'
314
+        ws_model.cell(1, 1).value = str1
315
+        str2 = 'X=(' + str(round(result3[0][2], 14)) + ')·x+(' + str(round(result3[0][3], 14)) + ')·y+(' + str(
316
+            round(result3[0][4], 11)) + ')'
317
+        ws_model.cell(2, 1).value = str2
318
+        str3 = 'Y=(' + str(round(result3[0][5], 14)) + ')·x+(' + str(round(result3[0][6], 14)) + ')·y+(' + str(
319
+            round(result3[0][7], 11)) + ')'
320
+        ws_model.cell(3, 1).value = str3
321
+        str4 = '式中:x、y为' + newname
322
+        ws_model.cell(4, 1).value = str4
323
+        str5 = '     X、Y为' + lastname + '已知系统的' + newname + '归算坐标'
324
+        ws_model.cell(5, 1).value = str5
325
+
326
+        # 保存工作簿
327
+        wb.save(excel_path)
328
+
329
+        QMessageBox.information(ui, '成功', f'数据文件已导出到 {export_folder}')
333 330
 
334
-    # 保存工作簿
335
-    wb.save(excel_path)
331
+    except PermissionError as e:
332
+        if e.errno == 13:
333
+            QMessageBox.critical(ui, '错误', '请确认文件没有被其他程序(如Excel、文本编辑器等)打开')
334
+        else:
335
+            QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
336
+    except Exception as e:
337
+        QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
336 338
 
337 339
 
338
-def export_example_data(ui, db_path, utf_en, export_folder,file_name):
340
+def export_example_data(ui, db_path, utf_en, export_folder, file_name):
339 341
     # 解码文件名并去掉后缀名
340 342
     decoded_utf_en = utf_en.decode('utf-8') if isinstance(utf_en, bytes) else utf_en
341 343
     # excel_file_name = f"{os.path.splitext(decoded_utf_en)[0]}.xlsx"
@@ -472,51 +474,16 @@ def export_example_data(ui, db_path, utf_en, export_folder,file_name):
472 474
     # 保存工作簿
473 475
     wb.save(excel_path)
474 476
 
475
-# 主函数 写入excel文件
476
-def main_function(ui, dbpath, excelname,export_folder,file_name):
477
-    # # 获取应用的安装目录
478
-    # app_install_dir = os.getcwd()  # 假设脚本文件位于应用的安装目录下
479
-    # export_folder = os.path.join(app_install_dir, 'Export')
480
-    #
481
-    # # 如果 Export 文件夹不存在,则创建它
482
-    # if not os.path.exists(export_folder):
483
-    #     os.makedirs(export_folder)
484
-    try:
485
-        openpyxl_write(export_folder, dbpath, excelname,file_name)
486
-        QMessageBox.information(ui, '成功', f'成果文件已成功导出到 {export_folder}')
487
-    except Exception as e:
488
-        QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
489 477
 
478
+# 数据文件的导出
479
+def main_function_combined(ui, dbpath, excelname, export_folder, file_name):
480
+    export_combined_data(ui, dbpath, excelname, export_folder, file_name)
490 481
 
491
-def main_function_initial(ui, dbpath, excelname_utf8,export_folder,file_name):
492
-    # # 获取应用的安装目录
493
-    # app_install_dir = os.getcwd()  # 假设脚本文件位于应用的安装目录下
494
-    # export_folder = os.path.join(app_install_dir, 'Export')
495
-    #
496
-    # # 如果 Export 文件夹不存在,则创建它
497
-    # if not os.path.exists(export_folder):
498
-    #     os.makedirs(export_folder)
499
-    try:
500
-        export_initial_data(ui, dbpath, excelname_utf8, export_folder,file_name)
501
-        QMessageBox.information(ui, '成功', f'初始文件已成功导出到 {export_folder}')
502
-    except PermissionError as e:
503
-        if e.errno == 13:
504
-            QMessageBox.critical(ui, '错误', '请确认文件没有被其他程序(如Excel、文本编辑器等)打开')
505
-        else:
506
-            QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
507
-    except Exception as e:
508
-        QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
509 482
 
510
-def main_function_example(ui, dbpath, excelname_utf8,export_folder,file_name):
511
-    # # 获取应用的安装目录
512
-    # app_install_dir = os.getcwd()  # 假设脚本文件位于应用的安装目录下
513
-    # export_folder = os.path.join(app_install_dir, 'Example')
514
-    #
515
-    # # 如果 Export 文件夹不存在,则创建它
516
-    # if not os.path.exists(export_folder):
517
-    #     os.makedirs(export_folder)
483
+# 示例文件的导出
484
+def main_function_example(ui, dbpath, excelname_utf8, export_folder, file_name):
518 485
     try:
519
-        export_example_data(ui, dbpath, excelname_utf8, export_folder,file_name)
486
+        export_example_data(ui, dbpath, excelname_utf8, export_folder, file_name)
520 487
         QMessageBox.information(ui, '成功', f'示例文件已成功导出到 {export_folder}')
521 488
     except PermissionError as e:
522 489
         if e.errno == 13:
@@ -524,4 +491,4 @@ def main_function_example(ui, dbpath, excelname_utf8,export_folder,file_name):
524 491
         else:
525 492
             QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
526 493
     except Exception as e:
527
-        QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')
494
+        QMessageBox.critical(ui, '错误', f'导出过程中发生错误: {str(e)}')

+ 24
- 30
Front/main.py Просмотреть файл

@@ -47,7 +47,7 @@ from pathlib import Path
47 47
 project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
48 48
 sys.path.append(project_root)
49 49
 
50
-os.environ["QT_FONT_DPI"] = "96"  # FIX Problem for High DPI and Scale above 100%
50
+# os.environ["QT_FONT_DPI"] = "96"  # FIX Problem for High DPI and Scale above 100%
51 51
 
52 52
 # SET AS GLOBAL WIDGETS
53 53
 # ///////////////////////////////////////////////////////////////
@@ -234,7 +234,7 @@ class ElTree(QWidget):
234 234
             pass
235 235
 
236 236
     def delete_js(self):
237
-        #选中当前计算
237
+        # 选中当前计算
238 238
         selected_items = widgets.allTreeWidget.selectedItems()
239 239
         item = selected_items[0]
240 240
         parent_name = item.text(0)
@@ -244,7 +244,7 @@ class ElTree(QWidget):
244 244
             QMessageBox.warning(self, '警告', '所选项目没有父节点')
245 245
             return
246 246
         dbname = db_item.text(0)
247
-        dbpath = os.path.join(os.path.abspath('./SQL'), f"{dbname}.db")
247
+        dbpath = resource_path(os.path.join('SQL', f"{dbname}.db"))
248 248
         # 确定要清空的表
249 249
         tables_to_delete = []
250 250
         if parent_name == '水准测段高差稳定计算':
@@ -281,7 +281,7 @@ class ElTree(QWidget):
281 281
         selected_items = widgets.allTreeWidget.selectedItems()
282 282
         item = selected_items[0]
283 283
         dbname = item.text(0)
284
-        dbpath = os.path.join(os.path.abspath('./SQL'), f"{dbname}.db")
284
+        dbpath = resource_path(os.path.join('SQL', f"{dbname}.db"))
285 285
         # 确认删除操作
286 286
         reply = QMessageBox.question(self, '确认删除', f'确定要删除项目 {dbname} 吗?',
287 287
                                      QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
@@ -413,14 +413,14 @@ class ElTree(QWidget):
413 413
 
414 414
         # 根据父节点名称确定导出操作
415 415
         if parent_name == '水准测段高差稳定计算':
416
-            GCExport.main_function_initial(self, tablename_utf8, dbpath,folder_name,file_name)
417
-            GCExport.main_function_result(self, tablename_utf8, dbpath,folder_name,file_name)
416
+            GCExport.main_function_combined(self, tablename_utf8, dbpath, folder_name, file_name)
418 417
         elif parent_name == '控制网复测平面基准计算':
419
-            GSExport.main_function(self, dbpath, tablename,folder_name,file_name)
420
-            GSExport.main_function_initial(self, dbpath, tablename_utf8,folder_name,file_name)
418
+            GSExport.main_function(self, dbpath, tablename, folder_name, file_name)
419
+            GSExport.main_function_initial(self, dbpath, tablename_utf8, folder_name, file_name)
421 420
         elif parent_name == '平面控制网稳定性计算':
422
-            WDExport.main_function(self, dbpath, tablename,folder_name,file_name)
423
-            WDExport.main_function_initial(self, dbpath, tablename_utf8,folder_name,file_name)
421
+            # WDExport.main_function(self, dbpath, tablename, folder_name, file_name)
422
+            # WDExport.main_function_initial(self, dbpath, tablename_utf8, folder_name, file_name)
423
+            WDExport.main_function_combined(self, dbpath, tablename_utf8, folder_name, file_name)
424 424
         else:
425 425
             QMessageBox.warning(self, '警告', '未知的父节点')
426 426
             return
@@ -507,7 +507,7 @@ class ElTree1(QWidget):
507 507
             pass
508 508
 
509 509
     def delete_js(self):
510
-        #选中当前计算
510
+        # 选中当前计算
511 511
         selected_items = widgets.qureyTreeWidget.selectedItems()
512 512
         item = selected_items[0]
513 513
         parent_name = item.text(0)
@@ -517,7 +517,7 @@ class ElTree1(QWidget):
517 517
             QMessageBox.warning(self, '警告', '所选项目没有父节点')
518 518
             return
519 519
         dbname = db_item.text(0)
520
-        dbpath = os.path.join(os.path.abspath('./SQL'), f"{dbname}.db")
520
+        dbpath = resource_path(os.path.join('SQL', f"{dbname}.db"))
521 521
         # 确定要清空的表
522 522
         tables_to_delete = []
523 523
         if parent_name == '水准测段高差稳定计算':
@@ -558,7 +558,7 @@ class ElTree1(QWidget):
558 558
         selected_items = widgets.qureyTreeWidget.selectedItems()
559 559
         item = selected_items[0]
560 560
         dbname = item.text(0)
561
-        dbpath = os.path.join(os.path.abspath('./SQL'), f"{dbname}.db")
561
+        dbpath = resource_path(os.path.join('SQL', f"{dbname}.db"))
562 562
         # 确认删除操作
563 563
         reply = QMessageBox.question(self, '确认删除', f'确定要删除项目 {dbname} 吗?',
564 564
                                      QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
@@ -573,7 +573,7 @@ class ElTree1(QWidget):
573 573
                 pass
574 574
             # 强制垃圾回收
575 575
             gc.collect()
576
-            #删除路径
576
+            # 删除路径
577 577
             os.remove(dbpath)
578 578
             QMessageBox.information(self, '成功', f'项目 {dbname} 中的数据已删除')
579 579
             # 清空树状图
@@ -653,7 +653,7 @@ class ElTree1(QWidget):
653 653
             QMessageBox.critical(self, '错误', f'删除数据时出错: {str(e)}')
654 654
 
655 655
     def export_item(self):
656
-        #对话框
656
+        # 对话框
657 657
         file_path, ok = QFileDialog.getSaveFileName(
658 658
             self,  # 父窗口
659 659
             "保存文件",  # 对话框标题
@@ -695,14 +695,12 @@ class ElTree1(QWidget):
695 695
 
696 696
         # 根据父节点名称确定导出操作
697 697
         if parent_name == '水准测段高差稳定计算':
698
-            GCExport.main_function_initial(self, tablename_utf8, dbpath,folder_name,file_name)  # 导出初始文件
699
-            GCExport.main_function_result(self, tablename_utf8, dbpath,folder_name,file_name)  # 导出结果文件
698
+            GCExport.main_function_combined(self, tablename_utf8, dbpath, folder_name, file_name)  # 导出合并文件
700 699
         elif parent_name == '控制网复测平面基准计算':
701
-            GSExport.main_function(self, dbpath, tablename,folder_name,file_name)  # 导出结果文件
702
-            GSExport.main_function_initial(self, dbpath, tablename_utf8,folder_name,file_name)  # 导出初始文件
700
+            GSExport.main_function_initial(self, dbpath, tablename_utf8, folder_name, file_name)  # 导出初始文件
701
+            GSExport.main_function(self, dbpath, tablename, folder_name, file_name)  # 导出结果文件
703 702
         elif parent_name == '平面控制网稳定性计算':
704
-            WDExport.main_function(self, dbpath, tablename,folder_name,file_name)  # 导出结果文件
705
-            WDExport.main_function_initial(self, dbpath, tablename_utf8,folder_name,file_name)  # 导出初始文件
703
+            WDExport.main_function_combined(self, dbpath, excelname, folder_name, file_name)
706 704
         else:
707 705
             QMessageBox.warning(self, '警告', '未知的父节点')
708 706
             return
@@ -996,8 +994,8 @@ class MainWindow(QMainWindow):
996 994
 
997 995
     # 定义导出数据库的槽函数
998 996
     def on_export_2_clicked(self):
999
-        #不清楚位置的按钮(?)
1000
-        #方法还是那个方法
997
+        # 不清楚位置的按钮(?)
998
+        # 方法还是那个方法
1001 999
         # 弹出输入对话框,让用户输入文件名
1002 1000
         file_path, ok = QFileDialog.getSaveFileName(
1003 1001
             self,  # 父窗口
@@ -1021,7 +1019,6 @@ class MainWindow(QMainWindow):
1021 1019
         else:
1022 1020
             QMessageBox.warning(self, "取消", "用户取消了保存操作")
1023 1021
 
1024
-
1025 1022
     # RESIZE EVENTS
1026 1023
     # ///////////////////////////////////////////////////////////////
1027 1024
     def resizeEvent(self, event):
@@ -1421,12 +1418,11 @@ class MainWindow(QMainWindow):
1421 1418
             # 提取文件名
1422 1419
             file_name = path.name
1423 1420
             # 在这里处理文件保存逻辑
1424
-            Back.WD.WDExport.main_function_example(self, db_path, excelname_utf8,folder_name,file_name)
1421
+            Back.WD.WDExport.main_function_example(self, db_path, excelname_utf8, folder_name, file_name)
1425 1422
             # QMessageBox.information(self, "保存成功", f"文件将保存到: {file_name}")
1426 1423
         else:
1427 1424
             QMessageBox.warning(self, "取消", "用户取消了保存操作")
1428 1425
 
1429
-
1430 1426
     def on_download_2_clicked(self):
1431 1427
         # 获取应用的安装目录
1432 1428
         app_install_dir = os.getcwd()
@@ -1448,12 +1444,11 @@ class MainWindow(QMainWindow):
1448 1444
             # 提取文件名
1449 1445
             file_name = path.name
1450 1446
             # 在这里处理文件保存逻辑
1451
-            Back.GS.GSExport.main_function_example(self, db_path, excelname_utf8,folder_name,file_name)
1447
+            Back.GS.GSExport.main_function_example(self, db_path, excelname_utf8, folder_name, file_name)
1452 1448
             # QMessageBox.information(self, "保存成功", f"文件将保存到: {file_name}")
1453 1449
         else:
1454 1450
             QMessageBox.warning(self, "取消", "用户取消了保存操作")
1455 1451
 
1456
-
1457 1452
     def on_download_3_clicked(self):
1458 1453
         # 获取应用的安装目录
1459 1454
         app_install_dir = os.getcwd()
@@ -1475,14 +1470,13 @@ class MainWindow(QMainWindow):
1475 1470
             # 提取文件名
1476 1471
             file_name = path.name
1477 1472
             # 在这里处理文件保存逻辑
1478
-            Back.GC.GCExport.main_function_example(self, utf_en, db_path,folder_name,file_name)
1473
+            Back.GC.GCExport.main_function_example(self, utf_en, db_path, folder_name, file_name)
1479 1474
             # QMessageBox.information(self, "保存成功", f"文件将保存到: {file_name}")
1480 1475
         else:
1481 1476
             QMessageBox.warning(self, "取消", "用户取消了保存操作")
1482 1477
         # 调用main_function_example函数
1483 1478
 
1484 1479
 
1485
-
1486 1480
 def main():
1487 1481
     app = QApplication(sys.argv)
1488 1482
     app.setWindowIcon(QIcon("icon.ico"))

+ 66
- 88
Front/main.ui Просмотреть файл

@@ -2341,42 +2341,6 @@ background-repeat:no-repeat;</string>
2341 2341
                              <property name="bottomMargin">
2342 2342
                               <number>0</number>
2343 2343
                              </property>
2344
-                             <item>
2345
-                              <widget class="QFrame" name="frame_title_wid_1">
2346
-                               <property name="maximumSize">
2347
-                                <size>
2348
-                                 <width>16777215</width>
2349
-                                 <height>34</height>
2350
-                                </size>
2351
-                               </property>
2352
-                               <property name="frameShape">
2353
-                                <enum>QFrame::Shape::NoFrame</enum>
2354
-                               </property>
2355
-                               <property name="frameShadow">
2356
-                                <enum>QFrame::Shadow::Raised</enum>
2357
-                               </property>
2358
-                               <layout class="QVBoxLayout" name="verticalLayout_18">
2359
-                                <item>
2360
-                                 <widget class="QLabel" name="labelBoxBlenderInstalation">
2361
-                                  <property name="font">
2362
-                                   <font>
2363
-                                    <family>Segoe UI</family>
2364
-                                    <pointsize>10</pointsize>
2365
-                                    <italic>false</italic>
2366
-                                    <bold>false</bold>
2367
-                                   </font>
2368
-                                  </property>
2369
-                                  <property name="styleSheet">
2370
-                                   <string notr="true"/>
2371
-                                  </property>
2372
-                                  <property name="text">
2373
-                                   <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;导入Excel表格&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2374
-                                  </property>
2375
-                                 </widget>
2376
-                                </item>
2377
-                               </layout>
2378
-                              </widget>
2379
-                             </item>
2380 2344
                              <item>
2381 2345
                               <widget class="QFrame" name="frame_content_wid_1">
2382 2346
                                <property name="minimumSize">
@@ -2404,25 +2368,12 @@ background-repeat:no-repeat;</string>
2404 2368
                                    <number>0</number>
2405 2369
                                   </property>
2406 2370
                                   <property name="horizontalSpacing">
2407
-                                   <number>7</number>
2371
+                                   <number>1</number>
2408 2372
                                   </property>
2409 2373
                                   <property name="verticalSpacing">
2410 2374
                                    <number>4</number>
2411 2375
                                   </property>
2412
-                                  <item row="0" column="0">
2413
-                                   <widget class="QLabel" name="label">
2414
-                                    <property name="maximumSize">
2415
-                                     <size>
2416
-                                      <width>60</width>
2417
-                                      <height>16777215</height>
2418
-                                     </size>
2419
-                                    </property>
2420
-                                    <property name="text">
2421
-                                     <string>选择项目:</string>
2422
-                                    </property>
2423
-                                   </widget>
2424
-                                  </item>
2425
-                                  <item row="0" column="1">
2376
+                                  <item row="1" column="1">
2426 2377
                                    <widget class="QComboBox" name="comboBox">
2427 2378
                                     <property name="maximumSize">
2428 2379
                                      <size>
@@ -2490,7 +2441,61 @@ background-repeat:no-repeat;</string>
2490 2441
                                     </item>
2491 2442
                                    </widget>
2492 2443
                                   </item>
2493
-                                  <item row="0" column="2">
2444
+                                  <item row="2" column="0">
2445
+                                   <widget class="QLabel" name="label_4">
2446
+                                    <property name="text">
2447
+                                     <string>选择计算方式:</string>
2448
+                                    </property>
2449
+                                   </widget>
2450
+                                  </item>
2451
+                                  <item row="1" column="0">
2452
+                                   <widget class="QLabel" name="label">
2453
+                                    <property name="maximumSize">
2454
+                                     <size>
2455
+                                      <width>60</width>
2456
+                                      <height>16777215</height>
2457
+                                     </size>
2458
+                                    </property>
2459
+                                    <property name="text">
2460
+                                     <string>选择项目:</string>
2461
+                                    </property>
2462
+                                   </widget>
2463
+                                  </item>
2464
+                                  <item row="2" column="1">
2465
+                                   <widget class="QComboBox" name="comboBox_2">
2466
+                                    <property name="cursor">
2467
+                                     <cursorShape>PointingHandCursor</cursorShape>
2468
+                                    </property>
2469
+                                    <property name="styleSheet">
2470
+                                     <string notr="true">QComboBox QAbstractItemView {
2471
+    border: 2px solid #282c34;
2472
+	background-color: rgba(40, 44, 52,.7);
2473
+    border-radius-bottom: 15px;
2474
+    padding: 1px 2px 1px 2px;  
2475
+    min-width: 9em;   
2476
+}</string>
2477
+                                    </property>
2478
+                                    <property name="currentText">
2479
+                                     <string>控制网复测平面基准计算</string>
2480
+                                    </property>
2481
+                                    <item>
2482
+                                     <property name="text">
2483
+                                      <string>控制网复测平面基准计算</string>
2484
+                                     </property>
2485
+                                    </item>
2486
+                                    <item>
2487
+                                     <property name="text">
2488
+                                      <string>平面控制网稳定性计算</string>
2489
+                                     </property>
2490
+                                    </item>
2491
+                                    <item>
2492
+                                     <property name="text">
2493
+                                      <string>水准测段高差稳定计算</string>
2494
+                                     </property>
2495
+                                    </item>
2496
+                                   </widget>
2497
+                                  </item>
2498
+                                  <item row="1" column="2">
2494 2499
                                    <widget class="QLineEdit" name="lineEdit">
2495 2500
                                     <property name="minimumSize">
2496 2501
                                      <size>
@@ -2515,7 +2520,7 @@ background-repeat:no-repeat;</string>
2515 2520
                                     </property>
2516 2521
                                    </widget>
2517 2522
                                   </item>
2518
-                                  <item row="0" column="3">
2523
+                                  <item row="2" column="2">
2519 2524
                                    <widget class="QPushButton" name="createFile">
2520 2525
                                     <property name="minimumSize">
2521 2526
                                      <size>
@@ -2525,7 +2530,7 @@ background-repeat:no-repeat;</string>
2525 2530
                                     </property>
2526 2531
                                     <property name="maximumSize">
2527 2532
                                      <size>
2528
-                                      <width>60</width>
2533
+                                      <width>16777215</width>
2529 2534
                                       <height>16777215</height>
2530 2535
                                      </size>
2531 2536
                                     </property>
@@ -2552,45 +2557,18 @@ background-repeat:no-repeat;</string>
2552 2557
                                     </property>
2553 2558
                                    </widget>
2554 2559
                                   </item>
2555
-                                  <item row="1" column="0">
2556
-                                   <widget class="QLabel" name="label_4">
2560
+                                  <item row="0" column="1">
2561
+                                   <widget class="QLabel" name="label_14">
2557 2562
                                     <property name="text">
2558
-                                     <string>选择计算方式:</string>
2563
+                                     <string>选择现有项目</string>
2559 2564
                                     </property>
2560 2565
                                    </widget>
2561 2566
                                   </item>
2562
-                                  <item row="1" column="1">
2563
-                                   <widget class="QComboBox" name="comboBox_2">
2564
-                                    <property name="cursor">
2565
-                                     <cursorShape>PointingHandCursor</cursorShape>
2566
-                                    </property>
2567
-                                    <property name="styleSheet">
2568
-                                     <string notr="true">QComboBox QAbstractItemView {
2569
-    border: 2px solid #282c34;
2570
-	background-color: rgba(40, 44, 52,.7);
2571
-    border-radius-bottom: 15px;
2572
-    padding: 1px 2px 1px 2px;  
2573
-    min-width: 9em;   
2574
-}</string>
2575
-                                    </property>
2576
-                                    <property name="currentText">
2577
-                                     <string>控制网复测平面基准计算</string>
2567
+                                  <item row="0" column="2">
2568
+                                   <widget class="QLabel" name="label_15">
2569
+                                    <property name="text">
2570
+                                     <string>创建新项目</string>
2578 2571
                                     </property>
2579
-                                    <item>
2580
-                                     <property name="text">
2581
-                                      <string>控制网复测平面基准计算</string>
2582
-                                     </property>
2583
-                                    </item>
2584
-                                    <item>
2585
-                                     <property name="text">
2586
-                                      <string>平面控制网稳定性计算</string>
2587
-                                     </property>
2588
-                                    </item>
2589
-                                    <item>
2590
-                                     <property name="text">
2591
-                                      <string>水准测段高差稳定计算</string>
2592
-                                     </property>
2593
-                                    </item>
2594 2572
                                    </widget>
2595 2573
                                   </item>
2596 2574
                                  </layout>

+ 2
- 9
Front/modules/ui_functions.py Просмотреть файл

@@ -331,13 +331,6 @@ class UIFunctions(MainWindow):
331 331
     # 计算与展示文件的方法
332 332
     def compute_show_process_excel_file(self, file_path):
333 333
         current_text = self.ui.comboBox_2.currentText()
334
-        # # 获取当前脚本所在的目录
335
-        # current_dir = os.getcwd()
336
-        # # 构建 SQL 文件夹的相对路径(上一级的上一级中的 SQL 文件夹)
337
-        # sql_folder = os.path.join(current_dir, '..', '..', 'SQL')
338
-        # # 将相对路径转换为绝对路径
339
-        # sql_folder = os.path.abspath(sql_folder)
340
-        # db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
341 334
         db_path = os.path.join(resource_path('SQL'), f"{self.ui.comboBox.currentText()}.db")
342 335
         # 转换为utf-8
343 336
         excelname = os.path.basename(file_path)  # 文件名
@@ -367,11 +360,11 @@ class UIFunctions(MainWindow):
367 360
         excelname = os.path.basename(file_path)  # 文件名
368 361
         utf_en = excelname.encode('utf-8')  # 转换文件名为utf-8编码形式
369 362
         if current_text == "水准测段高差稳定计算":
370
-            GCExport.main_function_result(self, utf_en, db_path,folder_name,file_name)
363
+            GCExport.main_function_combined(self, utf_en, db_path,folder_name,file_name)
371 364
         elif current_text == "控制网复测平面基准计算":
372 365
             GSExport.main_function(self, db_path, excelname,folder_name,file_name)
373 366
         elif current_text == "平面控制网稳定性计算":
374
-            WDExport.main_function(self, db_path, excelname,folder_name,file_name)
367
+            WDExport.main_function_combined(self, db_path, excelname,folder_name,file_name)
375 368
         else:
376 369
             QMessageBox.warning(self, '警告', '请选择有效的计算类型')
377 370
 

Загрузка…
Отмена
Сохранить