Browse Source

完善了GS的计算和展示,修改了GC,GS的部分提示框

wzp 5 months ago
parent
commit
8087091976
7 changed files with 351 additions and 231 deletions
  1. 88
    71
      Back/GC/GCcompute.py
  2. 74
    67
      Back/GS/GS.py
  3. 132
    81
      Back/GS/GScompute.py
  4. 53
    7
      Back/WD/WDshow.py
  5. 1
    1
      Front/main.py
  6. 3
    4
      Front/modules/ui_functions.py
  7. BIN
      SQL/DataBase.db

+ 88
- 71
Back/GC/GCcompute.py View File

2
 import sqlite3
2
 import sqlite3
3
 import math
3
 import math
4
 
4
 
5
+from PySide6.QtWidgets import QMessageBox
6
+
5
 
7
 
6
 def calculate_absolute_height_differences(db_path, file_name, field_name):
8
 def calculate_absolute_height_differences(db_path, file_name, field_name):
7
     """
9
     """
271
 
273
 
272
 
274
 
273
 def main_function(file_path, db_path):
275
 def main_function(file_path, db_path):
274
-    # 获取文件名
275
-    file_name = os.path.basename(file_path)
276
-    file_name_utf8 = file_name.encode('utf-8')
277
-    # 处理查询结果
278
-    abs_last_hdiffs = calculate_absolute_height_differences(db_path, file_name_utf8, "Last_HDiff")
279
-    abs_new_hdiffs = calculate_absolute_height_differences(db_path, file_name_utf8, "New_HDiff")
280
-    # 获取稳定测段
281
-    # last_stable_section = get_last_stable_section(abs_last_hdiffs)
282
-    # current_stable_section = get_current_stable_section(abs_new_hdiffs, len(abs_last_hdiffs))
283
-    # 计算较差
284
-    differences = calculate_differences(abs_last_hdiffs, abs_new_hdiffs)
285
-    # stable_differences = calculate_stable_differences(last_stable_section, current_stable_section)
286
-    # 计算限值
287
-    limit_values = calculate_limits(db_path, file_name_utf8)
288
-    # total_limit = calculate_limits(db_path, file_name, total=True)
289
-    # 高程较差的变形判定
290
-    deformation_results = detect_deformation(differences, limit_values)
291
-    # 第一次稳定分析
292
-    corrected_sum_last_1 = calculate_corrected_old_height_difference(abs_last_hdiffs, deformation_results)  # 上期改正高差
293
-    corrected_sum_new_1 = calculate_corrected_new_height_difference(abs_new_hdiffs, deformation_results,
294
-                                                                    abs_last_hdiffs)  # 本期改正高差
295
-    corrected_height_differences_1 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_1,
296
-                                                                            corrected_sum_new_1)  # 改正高差绝对值
297
-    first_deformation_results = detect_corrected_deformation(corrected_height_differences_1, abs_last_hdiffs,
298
-                                                             limit_values)  # 第一次稳定分析的变形判定
299
-    # 第二次稳定分析
300
-    corrected_sum_last_2 = calculate_corrected_old_height_difference(abs_last_hdiffs, first_deformation_results)
301
-    corrected_sum_new_2 = calculate_corrected_new_height_difference(abs_new_hdiffs, first_deformation_results,
302
-                                                                    abs_last_hdiffs)
303
-    corrected_height_differences_2 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_2,
304
-                                                                            corrected_sum_new_2)
305
-    second_deformation_results = detect_corrected_deformation(corrected_height_differences_2, abs_last_hdiffs,
306
-                                                              limit_values)
307
-    # 第三次稳定分析
308
-    corrected_sum_last_3 = calculate_corrected_old_height_difference(abs_last_hdiffs, second_deformation_results)
309
-    corrected_sum_new_3 = calculate_corrected_new_height_difference(abs_new_hdiffs, second_deformation_results,
310
-                                                                    abs_last_hdiffs)
311
-    corrected_height_differences_3 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_3,
312
-                                                                            corrected_sum_new_3)
313
-    third_deformation_results = detect_corrected_deformation(corrected_height_differences_3, abs_last_hdiffs,
314
-                                                             limit_values)
315
-    # 第四次稳定分析
316
-    corrected_sum_last_4 = calculate_corrected_old_height_difference(abs_last_hdiffs, third_deformation_results)
317
-    corrected_sum_new_4 = calculate_corrected_new_height_difference(abs_new_hdiffs, third_deformation_results,
318
-                                                                    abs_last_hdiffs)
319
-    corrected_height_differences_4 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_4,
320
-                                                                            corrected_sum_new_4)
321
-    fourth_deformation_results = detect_corrected_deformation(corrected_height_differences_4, abs_last_hdiffs,
322
-                                                              limit_values)
323
-    # 第五次稳定分析
324
-    corrected_sum_last_5 = calculate_corrected_old_height_difference(abs_last_hdiffs, fourth_deformation_results)
325
-    corrected_sum_new_5 = calculate_corrected_new_height_difference(abs_new_hdiffs, fourth_deformation_results,
326
-                                                                    abs_last_hdiffs)
327
-    corrected_height_differences_5 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_5,
328
-                                                                            corrected_sum_new_5)
329
-    fifth_deformation_results = detect_corrected_deformation(corrected_height_differences_5, abs_last_hdiffs,
330
-                                                             limit_values)  # 第五次稳定分析的变形判定
331
-    # 更新数据库中的修正系数
332
-    update_correction_factor(db_path, file_name_utf8, corrected_sum_last_5, corrected_sum_new_5)
333
-    # 成果的高差
334
-    new_hdiffs = get_new_hdiffs(db_path, file_name_utf8)
335
-    old_hdiffs = get_old_hdiffs(db_path, file_name_utf8)
336
-    result_height_differences = calculate_corrected_height_differences_with_sin(new_hdiffs,
337
-                                                                                corrected_height_differences_5)  # 结果高差
338
-    # 修正数
339
-    correction_numbers = calculate_correction_numbers(result_height_differences, new_hdiffs)
340
-    # 计算期间差异
341
-    period_differences = calculate_period_differences(old_hdiffs, result_height_differences)
342
-    # 插入数据到Outpoint数据库表
343
-    insert_records_to_output_table(db_path, file_name_utf8, fifth_deformation_results, result_height_differences,
344
-                                   correction_numbers, period_differences)
276
+    try:
277
+        # 获取文件名
278
+        file_name = os.path.basename(file_path)
279
+        file_name_utf8 = file_name.encode('utf-8')
280
+
281
+        # 处理查询结果
282
+        abs_last_hdiffs = calculate_absolute_height_differences(db_path, file_name_utf8, "Last_HDiff")
283
+        abs_new_hdiffs = calculate_absolute_height_differences(db_path, file_name_utf8, "New_HDiff")
284
+
285
+        # 计算较差
286
+        differences = calculate_differences(abs_last_hdiffs, abs_new_hdiffs)
287
+
288
+        # 计算限值
289
+        limit_values = calculate_limits(db_path, file_name_utf8)
290
+
291
+        # 高程较差的变形判定
292
+        deformation_results = detect_deformation(differences, limit_values)
293
+
294
+        # 第一次稳定分析
295
+        corrected_sum_last_1 = calculate_corrected_old_height_difference(abs_last_hdiffs, deformation_results)  # 上期改正高差
296
+        corrected_sum_new_1 = calculate_corrected_new_height_difference(abs_new_hdiffs, deformation_results,
297
+                                                                        abs_last_hdiffs)  # 本期改正高差
298
+        corrected_height_differences_1 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_1,
299
+                                                                                corrected_sum_new_1)  # 改正高差绝对值
300
+        first_deformation_results = detect_corrected_deformation(corrected_height_differences_1, abs_last_hdiffs,
301
+                                                                 limit_values)  # 第一次稳定分析的变形判定
302
+
303
+        # 第二次稳定分析
304
+        corrected_sum_last_2 = calculate_corrected_old_height_difference(abs_last_hdiffs, first_deformation_results)
305
+        corrected_sum_new_2 = calculate_corrected_new_height_difference(abs_new_hdiffs, first_deformation_results,
306
+                                                                        abs_last_hdiffs)
307
+        corrected_height_differences_2 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_2,
308
+                                                                                corrected_sum_new_2)
309
+        second_deformation_results = detect_corrected_deformation(corrected_height_differences_2, abs_last_hdiffs,
310
+                                                                  limit_values)
311
+
312
+        # 第三次稳定分析
313
+        corrected_sum_last_3 = calculate_corrected_old_height_difference(abs_last_hdiffs, second_deformation_results)
314
+        corrected_sum_new_3 = calculate_corrected_new_height_difference(abs_new_hdiffs, second_deformation_results,
315
+                                                                        abs_last_hdiffs)
316
+        corrected_height_differences_3 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_3,
317
+                                                                                corrected_sum_new_3)
318
+        third_deformation_results = detect_corrected_deformation(corrected_height_differences_3, abs_last_hdiffs,
319
+                                                                 limit_values)
320
+
321
+        # 第四次稳定分析
322
+        corrected_sum_last_4 = calculate_corrected_old_height_difference(abs_last_hdiffs, third_deformation_results)
323
+        corrected_sum_new_4 = calculate_corrected_new_height_difference(abs_new_hdiffs, third_deformation_results,
324
+                                                                        abs_last_hdiffs)
325
+        corrected_height_differences_4 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_4,
326
+                                                                                corrected_sum_new_4)
327
+        fourth_deformation_results = detect_corrected_deformation(corrected_height_differences_4, abs_last_hdiffs,
328
+                                                                  limit_values)
329
+
330
+        # 第五次稳定分析
331
+        corrected_sum_last_5 = calculate_corrected_old_height_difference(abs_last_hdiffs, fourth_deformation_results)
332
+        corrected_sum_new_5 = calculate_corrected_new_height_difference(abs_new_hdiffs, fourth_deformation_results,
333
+                                                                        abs_last_hdiffs)
334
+        corrected_height_differences_5 = calculate_corrected_height_differences(abs_new_hdiffs, corrected_sum_last_5,
335
+                                                                                corrected_sum_new_5)
336
+        fifth_deformation_results = detect_corrected_deformation(corrected_height_differences_5, abs_last_hdiffs,
337
+                                                                 limit_values)  # 第五次稳定分析的变形判定
338
+
339
+        # 更新数据库中的修正系数
340
+        update_correction_factor(db_path, file_name_utf8, corrected_sum_last_5, corrected_sum_new_5)
341
+
342
+        # 成果的高差
343
+        new_hdiffs = get_new_hdiffs(db_path, file_name_utf8)
344
+        old_hdiffs = get_old_hdiffs(db_path, file_name_utf8)
345
+        result_height_differences = calculate_corrected_height_differences_with_sin(new_hdiffs,
346
+                                                                                    corrected_height_differences_5)  # 结果高差
347
+
348
+        # 修正数
349
+        correction_numbers = calculate_correction_numbers(result_height_differences, new_hdiffs)
350
+
351
+        # 计算期间差异
352
+        period_differences = calculate_period_differences(old_hdiffs, result_height_differences)
353
+
354
+        # 插入数据到Outpoint数据库表
355
+        insert_records_to_output_table(db_path, file_name_utf8, fifth_deformation_results, result_height_differences,
356
+                                       correction_numbers, period_differences)
357
+
358
+        QMessageBox.information(None, "提示", f"文件 '{file_name}' 计算成功!")
359
+
360
+    except Exception as e:
361
+        QMessageBox.critical(None, "错误", f"文件 '{file_name}' 计算失败!错误信息: {str(e)}")

+ 74
- 67
Back/GS/GS.py View File

2
 import xlrd
2
 import xlrd
3
 import sqlite3
3
 import sqlite3
4
 import os
4
 import os
5
+
6
+from PySide6.QtWidgets import QMessageBox
5
 from openpyxl import Workbook
7
 from openpyxl import Workbook
6
-import tkinter as tk
7
-from tkinter import messagebox
8
 import math
8
 import math
9
 import numpy as np
9
 import numpy as np
10
 
10
 
11
+
11
 def to_utf8(text):
12
 def to_utf8(text):
12
     str1 = text.encode('utf-8')
13
     str1 = text.encode('utf-8')
13
     return str1
14
     return str1
14
 
15
 
16
+
15
 # 弹窗提示用户是否更新数据
17
 # 弹窗提示用户是否更新数据
16
 def ask_for_update(file_name):
18
 def ask_for_update(file_name):
17
-    root = tk.Tk()
18
-    root.withdraw()  # 隐藏主窗口
19
-    response = messagebox.askyesno("提示", f"检测到数据库中存在相同文件名 '{file_name}',是否更新数据?")
20
-    return response
19
+    response = QMessageBox.question(None, "提示", f"检测到数据库中存在相同文件 '{file_name}',是(Yes)否(No)更新数据?",
20
+                                    QMessageBox.Yes | QMessageBox.No)
21
+    return response == QMessageBox.Yes
22
+
21
 
23
 
22
 # 读取Excel文件并计算公式结果
24
 # 读取Excel文件并计算公式结果
23
-def load_and_calculate_excel(file_path,cell0):
25
+def load_and_calculate_excel(file_path, cell0):
24
     # 加载Excel文件并计算单元格的公式结果。
26
     # 加载Excel文件并计算单元格的公式结果。
25
     workbook = openpyxl.load_workbook(file_path, data_only=True)
27
     workbook = openpyxl.load_workbook(file_path, data_only=True)
26
     sheet = workbook.active
28
     sheet = workbook.active
27
     h1_value = sheet[cell0].value
29
     h1_value = sheet[cell0].value
28
     return h1_value
30
     return h1_value
29
 
31
 
32
+
30
 # 数据库插入函数
33
 # 数据库插入函数
31
-def insert_into_database(database,pastname,newname,excelname,listname1,listpastx1,listpasty1,listcgcs1,listnewx1,listnewy1,pjbc,fxzwc,zrbzwc,points,zbs,zfxs,sf,pjbcs,pjfxs):
32
-    #先把输入的录入数据库
34
+def insert_into_database(database, pastname, newname, excelname, listname1, listpastx1, listpasty1, listcgcs1,
35
+                         listnewx1, listnewy1, pjbc, fxzwc, zrbzwc, points, zbs, zfxs, sf, pjbcs, pjfxs):
36
+    # 先把输入的录入数据库
33
     db = sqlite3.connect(database)
37
     db = sqlite3.connect(database)
34
-    #获取游标
38
+    # 获取游标
35
     cursor = db.cursor()
39
     cursor = db.cursor()
36
-    #字符类的都需要转换成字节存进去
40
+    # 字符类的都需要转换成字节存进去
37
     utf_pan = to_utf8(pastname)
41
     utf_pan = to_utf8(pastname)
38
     utf_nn = to_utf8(newname)
42
     utf_nn = to_utf8(newname)
39
     utf_tn = to_utf8(excelname)
43
     utf_tn = to_utf8(excelname)
58
                 SET Last_ResultName=?,New_ResultName=?,Avg_SL=?,Ms_Dir=?,Ms_WSL=?,Pt_Count=?,SL_Count=?,Dir_Count=?,Scale_Value=?,Avg_MSL=?,Avg_Dir=?
62
                 SET Last_ResultName=?,New_ResultName=?,Avg_SL=?,Ms_Dir=?,Ms_WSL=?,Pt_Count=?,SL_Count=?,Dir_Count=?,Scale_Value=?,Avg_MSL=?,Avg_Dir=?
59
                 WHERE TableName = ?
63
                 WHERE TableName = ?
60
                 """,
64
                 """,
61
-                (utf_pan,utf_nn,pjbc,fxzwc,zrbzwc,points,zbs,zfxs,sf,pjbcs,pjfxs,utf_tn,)
65
+                (utf_pan, utf_nn, pjbc, fxzwc, zrbzwc, points, zbs, zfxs, sf, pjbcs, pjfxs, utf_tn,)
62
             )
66
             )
63
             # 更新现有记录GS_Input_Point 
67
             # 更新现有记录GS_Input_Point 
64
-            #删了已有的数据,重新插入
68
+            # 删了已有的数据,重新插入
65
             cursor.execute(
69
             cursor.execute(
66
                 """
70
                 """
67
                 DELETE FROM GS_Input_Point WHERE TableName = ?
71
                 DELETE FROM GS_Input_Point WHERE TableName = ?
81
                     """
85
                     """
82
                     INSERT INTO GS_Input_Point(TableName,Last_ResultName,New_ResultName,Last_X,Last_Y,New_X,New_Y,PointName,cgcs) VALUES (?,?,?,?,?,?,?,?,?)
86
                     INSERT INTO GS_Input_Point(TableName,Last_ResultName,New_ResultName,Last_X,Last_Y,New_X,New_Y,PointName,cgcs) VALUES (?,?,?,?,?,?,?,?,?)
83
                     """,
87
                     """,
84
-                    (utf_tn,utf_pan,utf_nn,rr2,rr3,rr5,rr6,utf_rr1,rr4,)
88
+                    (utf_tn, utf_pan, utf_nn, rr2, rr3, rr5, rr6, utf_rr1, rr4,)
85
                 )
89
                 )
86
                 rr = rr + 1
90
                 rr = rr + 1
87
-            messagebox.showinfo("提示",
88
-                                f"文件 '{excelname}' 已成功更新到本地数据库中,点击确认以关闭此对话框。对话框关闭后,请点击“计算”以重新计算数据")
91
+            QMessageBox.information(None, "提示",
92
+                                    f"文件 '{excelname}' 已成功更新到本地数据库中,点击'OK'以关闭此对话框。对话框关闭后,请点击“计算”以重新计算数据")
89
         else:
93
         else:
90
             # 插入新记录GS_Input_Param 
94
             # 插入新记录GS_Input_Param 
91
             cursor.execute(
95
             cursor.execute(
93
                 INSERT INTO GS_Input_Param (TableName,Last_ResultName,New_ResultName,Avg_SL,Ms_Dir,Ms_WSL,Pt_Count,SL_Count,Dir_Count,Scale_Value,Avg_MSL,Avg_Dir) 
97
                 INSERT INTO GS_Input_Param (TableName,Last_ResultName,New_ResultName,Avg_SL,Ms_Dir,Ms_WSL,Pt_Count,SL_Count,Dir_Count,Scale_Value,Avg_MSL,Avg_Dir) 
94
                 VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
98
                 VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
95
                 """,
99
                 """,
96
-                (utf_tn,utf_pan,utf_nn,pjbc,fxzwc,zrbzwc,points,zbs,zfxs,sf,pjbcs,pjfxs,)
100
+                (utf_tn, utf_pan, utf_nn, pjbc, fxzwc, zrbzwc, points, zbs, zfxs, sf, pjbcs, pjfxs,)
97
             )
101
             )
98
             # 插入新记录GS_Input_Point 
102
             # 插入新记录GS_Input_Point 
99
             rr = 0
103
             rr = 0
109
                     """
113
                     """
110
                     INSERT INTO GS_Input_Point(TableName,Last_ResultName,New_ResultName,Last_X,Last_Y,New_X,New_Y,PointName,cgcs) VALUES (?,?,?,?,?,?,?,?,?)
114
                     INSERT INTO GS_Input_Point(TableName,Last_ResultName,New_ResultName,Last_X,Last_Y,New_X,New_Y,PointName,cgcs) VALUES (?,?,?,?,?,?,?,?,?)
111
                     """,
115
                     """,
112
-                    (utf_tn,utf_pan,utf_nn,rr2,rr3,rr5,rr6,utf_rr1,rr4,)
116
+                    (utf_tn, utf_pan, utf_nn, rr2, rr3, rr5, rr6, utf_rr1, rr4,)
113
                 )
117
                 )
114
                 rr = rr + 1
118
                 rr = rr + 1
115
-            messagebox.showinfo("提示",
116
-                                f"文件 '{excelname}' 已成功添加到本地数据库中,点击确认以关闭此对话框。对话框关闭后,请点击“计算”以计算数据")
119
+            QMessageBox.information(None, "提示",
120
+                                    f"文件 '{excelname}' 已成功添加到本地数据库中,点击'OK'以关闭此对话框。对话框关闭后,请点击“计算”以计算数据")
117
 
121
 
118
         db.commit()
122
         db.commit()
119
     except sqlite3.Error as e:
123
     except sqlite3.Error as e:
123
     finally:
127
     finally:
124
         db.close()
128
         db.close()
125
 
129
 
126
-#读取xls
127
-def xlrd_read(excelpath,dbpath):
130
+
131
+# 读取xls
132
+def xlrd_read(excelpath, dbpath):
128
     global gszbx
133
     global gszbx
129
     global gszby
134
     global gszby
130
     listname1 = []
135
     listname1 = []
134
     listpasty1 = []
139
     listpasty1 = []
135
     listcgcs1 = []
140
     listcgcs1 = []
136
 
141
 
137
-    #excel表名就是表名
142
+    # excel表名就是表名
138
     excelname = os.path.basename(excelpath)
143
     excelname = os.path.basename(excelpath)
139
     # 读取excel
144
     # 读取excel
140
     xlr = xlrd.open_workbook(excelpath)
145
     xlr = xlrd.open_workbook(excelpath)
164
     pjbc = float(tabler.cell(0, 6).value)
169
     pjbc = float(tabler.cell(0, 6).value)
165
     fxzwc = float(tabler.cell(1, 6).value)
170
     fxzwc = float(tabler.cell(1, 6).value)
166
     str1 = str(tabler.cell(2, 6).value)
171
     str1 = str(tabler.cell(2, 6).value)
167
-    #判断下是哪种情况,转化为数值
172
+    # 判断下是哪种情况,转化为数值
168
     if '.' in str1:
173
     if '.' in str1:
169
-        #直接float使用
174
+        # 直接float使用
170
         zrbzwc = float(str1)
175
         zrbzwc = float(str1)
171
     else:
176
     else:
172
-        #转化为分数
177
+        # 转化为分数
173
         # 10的6次方
178
         # 10的6次方
174
         # ten_to_the_six = 10e6
179
         # ten_to_the_six = 10e6
175
-        fzstr = float(str1.split('/',-1)[0])
176
-        fmstr = float(str1.split('/',-1)[1])
177
-        zrbzwc = float(fzstr/fmstr)
180
+        fzstr = float(str1.split('/', -1)[0])
181
+        fmstr = float(str1.split('/', -1)[1])
182
+        zrbzwc = float(fzstr / fmstr)
178
     zbs = float(tabler.cell(3, 6).value)
183
     zbs = float(tabler.cell(3, 6).value)
179
     zfxs = float(tabler.cell(4, 6).value)
184
     zfxs = float(tabler.cell(4, 6).value)
180
     pjbcs = zbs / points
185
     pjbcs = zbs / points
181
     pjfxs = zfxs / points
186
     pjfxs = zfxs / points
182
-    sf = float(tabler.cell(5,6).value)
187
+    sf = float(tabler.cell(5, 6).value)
183
     # 再拆细点
188
     # 再拆细点
184
     wy1 = pjbc / 1000
189
     wy1 = pjbc / 1000
185
     wy2 = wy1 * zrbzwc * 1e6
190
     wy2 = wy1 * zrbzwc * 1e6
192
     wypd0 = wypd
197
     wypd0 = wypd
193
     pastname = tabler.cell(0, 3).value
198
     pastname = tabler.cell(0, 3).value
194
     newname = tabler.cell(0, 1).value
199
     newname = tabler.cell(0, 1).value
195
-    #如果第二次测量或者首次测量为空,则判断为新建
200
+    # 如果第二次测量或者首次测量为空,则判断为新建
196
     while row < rows:
201
     while row < rows:
197
         pname = tabler.cell(row, 0).value
202
         pname = tabler.cell(row, 0).value
198
         pcgcs = 1
203
         pcgcs = 1
199
         try:
204
         try:
200
-            pnewx = round(float(tabler.cell(row, 1).value),4)
205
+            pnewx = round(float(tabler.cell(row, 1).value), 4)
201
         except:
206
         except:
202
             pnewx = 0
207
             pnewx = 0
203
             pcgcs = -2
208
             pcgcs = -2
204
         try:
209
         try:
205
-            pnewy = round(float(tabler.cell(row, 2).value),4)
210
+            pnewy = round(float(tabler.cell(row, 2).value), 4)
206
         except:
211
         except:
207
             pnewy = 0
212
             pnewy = 0
208
             pcgcs = -2
213
             pcgcs = -2
209
         try:
214
         try:
210
-            ppastx = round(float(tabler.cell(row, 3).value),4)
215
+            ppastx = round(float(tabler.cell(row, 3).value), 4)
211
         except:
216
         except:
212
             ppastx = 0
217
             ppastx = 0
213
             pcgcs = -2
218
             pcgcs = -2
214
         try:
219
         try:
215
-            ppasty = round(float(tabler.cell(row, 4).value),4)
220
+            ppasty = round(float(tabler.cell(row, 4).value), 4)
216
         except:
221
         except:
217
             ppasty = 0
222
             ppasty = 0
218
             pcgcs = -2
223
             pcgcs = -2
229
         if pcgcs == -2:
234
         if pcgcs == -2:
230
             points = points - 1
235
             points = points - 1
231
         row = row + 1
236
         row = row + 1
232
-    #插入数据库
233
-    insert_into_database(dbpath,pastname,newname,excelname,listname1,listpastx1,listpasty1,listcgcs1,listnewx1,listnewy1,pjbc,fxzwc,zrbzwc,points,zbs,zfxs,sf,pjbcs,pjfxs)
234
-    #新建点不参与运算
235
-    rr=0
237
+    # 插入数据库
238
+    insert_into_database(dbpath, pastname, newname, excelname, listname1, listpastx1, listpasty1, listcgcs1, listnewx1,
239
+                         listnewy1, pjbc, fxzwc, zrbzwc, points, zbs, zfxs, sf, pjbcs, pjfxs)
240
+    # 新建点不参与运算
241
+    rr = 0
236
     while rr < len(listname1):
242
     while rr < len(listname1):
237
         rr1 = listname1[rr]
243
         rr1 = listname1[rr]
238
         rr2 = listpastx1[rr]
244
         rr2 = listpastx1[rr]
251
             listnewy.append(rr6)
257
             listnewy.append(rr6)
252
             rr = rr + 1
258
             rr = rr + 1
253
 
259
 
254
-#读取xlsx
255
-def openpyxl_read(excelpath,dbpath):
260
+
261
+# 读取xlsx
262
+def openpyxl_read(excelpath, dbpath):
256
     global gszbx
263
     global gszbx
257
     global gszby
264
     global gszby
258
     listname1 = []
265
     listname1 = []
262
     listpasty1 = []
269
     listpasty1 = []
263
     listcgcs1 = []
270
     listcgcs1 = []
264
 
271
 
265
-    #excel表名就是表名
272
+    # excel表名就是表名
266
     excelname = os.path.basename(excelpath)
273
     excelname = os.path.basename(excelpath)
267
     # 读取excel
274
     # 读取excel
268
     xlr = openpyxl.load_workbook(excelpath)
275
     xlr = openpyxl.load_workbook(excelpath)
292
     pjbc = float(tabler['G1'].value)
299
     pjbc = float(tabler['G1'].value)
293
     fxzwc = float(tabler['G2'].value)
300
     fxzwc = float(tabler['G2'].value)
294
     str1 = str(tabler['G3'].value)
301
     str1 = str(tabler['G3'].value)
295
-    #判断下是哪种情况,转化为数值
302
+    # 判断下是哪种情况,转化为数值
296
     if '.' in str1:
303
     if '.' in str1:
297
-        #直接float使用
304
+        # 直接float使用
298
         zrbzwc = float(str1)
305
         zrbzwc = float(str1)
299
     else:
306
     else:
300
-        #转化为分数
307
+        # 转化为分数
301
         # 10的6次方
308
         # 10的6次方
302
         # ten_to_the_six = 10e6
309
         # ten_to_the_six = 10e6
303
-        fzstr = float(str1.split('/',-1)[0])
304
-        fmstr = float(str1.split('/',-1)[1])
305
-        zrbzwc = float(fzstr/fmstr)
310
+        fzstr = float(str1.split('/', -1)[0])
311
+        fmstr = float(str1.split('/', -1)[1])
312
+        zrbzwc = float(fzstr / fmstr)
306
     try:
313
     try:
307
         zbs = float(tabler['G4'].value)
314
         zbs = float(tabler['G4'].value)
308
     except:
315
     except:
309
-        zbs = load_and_calculate_excel(excelpath,'G4')
316
+        zbs = load_and_calculate_excel(excelpath, 'G4')
310
     try:
317
     try:
311
         zfxs = float(tabler['G5'].value)
318
         zfxs = float(tabler['G5'].value)
312
     except:
319
     except:
313
-        zfxs = load_and_calculate_excel(excelpath,'G5')
320
+        zfxs = load_and_calculate_excel(excelpath, 'G5')
314
     pjbcs = zbs / points
321
     pjbcs = zbs / points
315
     pjfxs = zfxs / points
322
     pjfxs = zfxs / points
316
     sf = float(tabler['G6'].value)
323
     sf = float(tabler['G6'].value)
326
     wypd0 = wypd
333
     wypd0 = wypd
327
     pastname = tabler['D1'].value
334
     pastname = tabler['D1'].value
328
     newname = tabler['B1'].value
335
     newname = tabler['B1'].value
329
-    #如果第二次测量或者首次测量为空,则判断为新建
336
+    # 如果第二次测量或者首次测量为空,则判断为新建
330
     while row <= rows:
337
     while row <= rows:
331
         pname = tabler.cell(row, 1).value
338
         pname = tabler.cell(row, 1).value
332
         pcgcs = 1
339
         pcgcs = 1
333
         try:
340
         try:
334
-            pnewx = round(float(tabler.cell(row, 2).value),4)
341
+            pnewx = round(float(tabler.cell(row, 2).value), 4)
335
         except:
342
         except:
336
             pnewx = 0
343
             pnewx = 0
337
             pcgcs = -2
344
             pcgcs = -2
338
         try:
345
         try:
339
-            pnewy = round(float(tabler.cell(row, 3).value),4)
346
+            pnewy = round(float(tabler.cell(row, 3).value), 4)
340
         except:
347
         except:
341
             pnewy = 0
348
             pnewy = 0
342
             pcgcs = -2
349
             pcgcs = -2
343
         try:
350
         try:
344
-            ppastx = round(float(tabler.cell(row, 4).value),4)
351
+            ppastx = round(float(tabler.cell(row, 4).value), 4)
345
         except:
352
         except:
346
             ppastx = 0
353
             ppastx = 0
347
             pcgcs = -2
354
             pcgcs = -2
348
         try:
355
         try:
349
-            ppasty = round(float(tabler.cell(row, 5).value),4)
356
+            ppasty = round(float(tabler.cell(row, 5).value), 4)
350
         except:
357
         except:
351
             ppasty = 0
358
             ppasty = 0
352
             pcgcs = -2
359
             pcgcs = -2
363
         if pcgcs == -2:
370
         if pcgcs == -2:
364
             points = points - 1
371
             points = points - 1
365
         row = row + 1
372
         row = row + 1
366
-    #插入数据库
367
-    insert_into_database(dbpath,pastname,newname,excelname,listname1,listpastx1,listpasty1,listcgcs1,listnewx1,listnewy1,pjbc,fxzwc,zrbzwc,points,zbs,zfxs,sf,pjbcs,pjfxs)
368
-    #新建点不参与运算
369
-    rr=0
373
+    # 插入数据库
374
+    insert_into_database(dbpath, pastname, newname, excelname, listname1, listpastx1, listpasty1, listcgcs1, listnewx1,
375
+                         listnewy1, pjbc, fxzwc, zrbzwc, points, zbs, zfxs, sf, pjbcs, pjfxs)
376
+    # 新建点不参与运算
377
+    rr = 0
370
     while rr < len(listname1):
378
     while rr < len(listname1):
371
         rr1 = listname1[rr]
379
         rr1 = listname1[rr]
372
         rr2 = listpastx1[rr]
380
         rr2 = listpastx1[rr]
385
             listnewy.append(rr6)
393
             listnewy.append(rr6)
386
             rr = rr + 1
394
             rr = rr + 1
387
 
395
 
396
+
388
 # 主函数 读取excel文件
397
 # 主函数 读取excel文件
389
-def main_function(file_path,dbpath):
398
+def main_function(file_path, dbpath):
390
     # 调用读取Excel文件的函数
399
     # 调用读取Excel文件的函数
391
     file_name = os.path.basename(file_path)
400
     file_name = os.path.basename(file_path)
392
-    #两种加载方式,对于不同的文件
401
+    # 两种加载方式,对于不同的文件
393
     if ".xlsx" in file_path:
402
     if ".xlsx" in file_path:
394
-        #采用openpyxl
395
-        openpyxl_read(file_path,dbpath)
403
+        # 采用openpyxl
404
+        openpyxl_read(file_path, dbpath)
396
     else:
405
     else:
397
-        #采用xlrd
398
-        xlrd_read(file_path,dbpath)
399
-    
400
-    
406
+        # 采用xlrd
407
+        xlrd_read(file_path, dbpath)

+ 132
- 81
Back/GS/GScompute.py View File

1
 import sqlite3
1
 import sqlite3
2
 import os
2
 import os
3
-import tkinter as tk
4
-from tkinter import messagebox
5
 import math
3
 import math
6
 import numpy as np
4
 import numpy as np
5
+from PySide6.QtWidgets import QMessageBox
7
 
6
 
8
-#region 各种方法
7
+
8
+# region 各种方法
9
 
9
 
10
 def to_utf8(text):
10
 def to_utf8(text):
11
     str1 = text.encode('utf-8')
11
     str1 = text.encode('utf-8')
12
     return str1
12
     return str1
13
 
13
 
14
-def sfjs(gsx,listx,gsy,listy):
14
+
15
+def sfjs(gsx, listx, gsy, listy):
15
     s1 = gsx[len(gsx) - 1] - gsx[0]
16
     s1 = gsx[len(gsx) - 1] - gsx[0]
16
     s2 = s1 * s1
17
     s2 = s1 * s1
17
     s3 = gsy[len(gsy) - 1] - gsy[0]
18
     s3 = gsy[len(gsy) - 1] - gsy[0]
24
     t4 = t3 * t3
25
     t4 = t3 * t3
25
     t5 = t2 + t4
26
     t5 = t2 + t4
26
     t6 = math.sqrt(t5)
27
     t6 = math.sqrt(t5)
27
-    num1 = round(s6/t6,8)
28
+    num1 = round(s6 / t6, 8)
28
     return num1
29
     return num1
29
 
30
 
30
-def mxjd(gs,nw):
31
+
32
+def mxjd(gs, nw):
31
     ii = 0
33
     ii = 0
32
     sum1 = 0
34
     sum1 = 0
33
     while ii < len(gs):
35
     while ii < len(gs):
40
     num1 = s4 * 1000
42
     num1 = s4 * 1000
41
     return num1
43
     return num1
42
 
44
 
43
-def xzjs(gsx,listx,gsy,listy):
45
+
46
+def xzjs(gsx, listx, gsy, listy):
44
     s1 = gsx[len(gsx) - 1] - gsx[0]
47
     s1 = gsx[len(gsx) - 1] - gsx[0]
45
     s2 = gsy[len(gsy) - 1] - gsy[0]
48
     s2 = gsy[len(gsy) - 1] - gsy[0]
46
     s3 = s2 / s1
49
     s3 = s2 / s1
53
     num1 = n1 * 180 / math.pi * 3600
56
     num1 = n1 * 180 / math.pi * 3600
54
     return num1
57
     return num1
55
 
58
 
56
-def gsjs(x,y,nlist):
59
+
60
+def gsjs(x, y, nlist):
57
     listgsx = []
61
     listgsx = []
58
     xstr1 = nlist[0] * x
62
     xstr1 = nlist[0] * x
59
     xstr2 = nlist[1] * y
63
     xstr2 = nlist[1] * y
65
     listgsx.append(yy)
69
     listgsx.append(yy)
66
     return listgsx
70
     return listgsx
67
 
71
 
72
+
68
 def jzys1(listy, zxzby, listx, zxzbx, sf):
73
 def jzys1(listy, zxzby, listx, zxzbx, sf):
69
     rlist = []
74
     rlist = []
70
     listlen = len(listy)
75
     listlen = len(listy)
80
         ll = ll + 1
85
         ll = ll + 1
81
     return rlist
86
     return rlist
82
 
87
 
88
+
83
 def jzys2(listy, zxzby, listx, zxzbx, sf):
89
 def jzys2(listy, zxzby, listx, zxzbx, sf):
84
     rlist = []
90
     rlist = []
85
     listlen = len(listy)
91
     listlen = len(listy)
93
         ll = ll + 1
99
         ll = ll + 1
94
     return rlist
100
     return rlist
95
 
101
 
102
+
96
 def jzys3(listy, aa, bb):
103
 def jzys3(listy, aa, bb):
97
     rlist = []
104
     rlist = []
98
     listlen = len(listy)
105
     listlen = len(listy)
106
         ll = ll + 1
113
         ll = ll + 1
107
     return rlist
114
     return rlist
108
 
115
 
116
+
109
 def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listnewx, zxzbnewx, sf):
117
 def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listnewx, zxzbnewx, sf):
110
     rlist = []
118
     rlist = []
111
     listlen = len(listnewx)
119
     listlen = len(listnewx)
113
     while ll < listlen:
121
     while ll < listlen:
114
         num1 = (listpastx[ll] - listnewx[ll] - zxzbpastx + zxzbnewx) / sf
122
         num1 = (listpastx[ll] - listnewx[ll] - zxzbpastx + zxzbnewx) / sf
115
         num2 = (listpasty[ll] - listnewy[ll] - zxzbpasty + zxzbnewy) / sf
123
         num2 = (listpasty[ll] - listnewy[ll] - zxzbpasty + zxzbnewy) / sf
116
-        rlist.append(round(num1,6))
117
-        rlist.append(round(num2,6))
124
+        rlist.append(round(num1, 6))
125
+        rlist.append(round(num2, 6))
118
         ll = ll + 1
126
         ll = ll + 1
119
     return rlist
127
     return rlist
120
 
128
 
129
+
121
 def jzys5(listp, zxzbp, sf):
130
 def jzys5(listp, zxzbp, sf):
122
     rlist = []
131
     rlist = []
123
     listlen = len(listp)
132
     listlen = len(listp)
128
         ll = ll + 1
137
         ll = ll + 1
129
     return rlist
138
     return rlist
130
 
139
 
140
+
131
 def jzys6(listp, num):
141
 def jzys6(listp, num):
132
     rlist = []
142
     rlist = []
133
     listlen = len(listp)
143
     listlen = len(listp)
138
         ll = ll + 1
148
         ll = ll + 1
139
     return rlist
149
     return rlist
140
 
150
 
151
+
141
 def cjh(listp):
152
 def cjh(listp):
142
     rp = 0
153
     rp = 0
143
     listlen = len(listp)
154
     listlen = len(listp)
148
         ll = ll + 1
159
         ll = ll + 1
149
     return rp
160
     return rp
150
 
161
 
162
+
151
 def cjh2(lista, listb):
163
 def cjh2(lista, listb):
152
     rp = 0
164
     rp = 0
153
     listlen = len(lista)
165
     listlen = len(lista)
158
         ll = ll + 1
170
         ll = ll + 1
159
     return rp
171
     return rp
160
 
172
 
173
+
161
 def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpastp, ii):
174
 def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpastp, ii):
162
     # 新x+(矩阵[jx1 jy1 lx1 ly1]*矩阵z)*缩放-新重心坐标x+旧重心坐标x
175
     # 新x+(矩阵[jx1 jy1 lx1 ly1]*矩阵z)*缩放-新重心坐标x+旧重心坐标x
163
     rlist = []
176
     rlist = []
165
     ll = 0
178
     ll = 0
166
     while ll < listlen:
179
     while ll < listlen:
167
         arr0 = np.array((jxlist1[ll], jylist1[ll],
180
         arr0 = np.array((jxlist1[ll], jylist1[ll],
168
-                        lxlist[2*ll+ii], lylist[2*ll+ii]))
181
+                         lxlist[2 * ll + ii], lylist[2 * ll + ii]))
169
         arr1 = np.matmul(arr0, arrz)
182
         arr1 = np.matmul(arr0, arrz)
170
         arr3 = sf * arr1
183
         arr3 = sf * arr1
171
         newp = listnewp[ll] + arr3 - zxzbnewp + zxzbpastp
184
         newp = listnewp[ll] + arr3 - zxzbnewp + zxzbpastp
173
         ll = ll + 1
186
         ll = ll + 1
174
     return rlist
187
     return rlist
175
 
188
 
189
+
176
 def xcys(newlist, pastlist):
190
 def xcys(newlist, pastlist):
177
     listlen = len(newlist)
191
     listlen = len(newlist)
178
     ll = 0
192
     ll = 0
179
     rlist = []
193
     rlist = []
180
     while ll < listlen:
194
     while ll < listlen:
181
-        num1 =pastlist[ll] - newlist[ll]
195
+        num1 = pastlist[ll] - newlist[ll]
182
         num2 = num1 * 1000
196
         num2 = num1 * 1000
183
         rlist.append(num2)
197
         rlist.append(num2)
184
         ll = ll + 1
198
         ll = ll + 1
185
     return rlist
199
     return rlist
186
 
200
 
201
+
187
 def takeFirst(elem):
202
 def takeFirst(elem):
188
-        return elem[0]
203
+    return elem[0]
204
+
189
 
205
 
190
-#endregion
206
+# endregion
191
 
207
 
192
-def insert_into_database1(database,utf_tn,listname1,listname,gsx,gsy,listpastx1,listpasty1,listnewx1,listnewy1,nlist,utf_pan,utf_nn,wypd,sfxs,xzj,pycsx,pycsy,mxjdx,mxjdy,zxzbpastx,zxzbpasty,zxzbnewx,zxzbnewy,n1,n2,n3,n4,n5,n6):
193
-    #将结果输出到数据库
208
+def insert_into_database1(database, utf_tn, listname1, listname, gsx, gsy, listpastx1, listpasty1, listnewx1, listnewy1,
209
+                          nlist, utf_pan, utf_nn, wypd, sfxs, xzj, pycsx, pycsy, mxjdx, mxjdy, zxzbpastx, zxzbpasty,
210
+                          zxzbnewx, zxzbnewy, n1, n2, n3, n4, n5, n6):
211
+    # 将结果输出到数据库
194
     db1 = sqlite3.connect(database)
212
     db1 = sqlite3.connect(database)
195
-    #获取游标
213
+    # 获取游标
196
     cursor1 = db1.cursor()
214
     cursor1 = db1.cursor()
197
-    #先清除已有数据,用来更新
215
+    # 先清除已有数据,用来更新
198
     try:
216
     try:
199
         sqlstr3 = 'delete from GS_Trans_Param WHERE TableName = ?'
217
         sqlstr3 = 'delete from GS_Trans_Param WHERE TableName = ?'
200
         sqlstr4 = 'delete from GS_Trans_Point WHERE TableName = ?'
218
         sqlstr4 = 'delete from GS_Trans_Point WHERE TableName = ?'
201
         sqlstr5 = 'delete from GS_Result_Point WHERE TableName = ?'
219
         sqlstr5 = 'delete from GS_Result_Point WHERE TableName = ?'
202
-        cursor1.execute(sqlstr3,(utf_tn,))
203
-        cursor1.execute(sqlstr4,(utf_tn,))
204
-        cursor1.execute(sqlstr5,(utf_tn,))
220
+        cursor1.execute(sqlstr3, (utf_tn,))
221
+        cursor1.execute(sqlstr4, (utf_tn,))
222
+        cursor1.execute(sqlstr5, (utf_tn,))
205
     except:
223
     except:
206
         pass
224
         pass
207
-    cursor1.execute('INSERT INTO GS_Trans_Param(TableName,Last_ResultName,New_ResultName,Dis_RefValue,Pt_CalCount,Scale_Factor,Rotate_Angle,Trans_X,Trans_Y,Model_AccX,Model_AccY,Last_GcX,Last_GcY,New_GcX,New_GcY,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,wypd,len(listname),sfxs,xzj,pycsx,pycsy,mxjdx,mxjdy,zxzbpastx,zxzbpasty,zxzbnewx,zxzbnewy,n1,n2,n3,n4,n5,n6,))
208
-    #Trans_Point和Result_Point一起存
225
+    cursor1.execute(
226
+        'INSERT INTO GS_Trans_Param(TableName,Last_ResultName,New_ResultName,Dis_RefValue,Pt_CalCount,Scale_Factor,Rotate_Angle,Trans_X,Trans_Y,Model_AccX,Model_AccY,Last_GcX,Last_GcY,New_GcX,New_GcY,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
227
+        (utf_tn, utf_pan, utf_nn, wypd, len(listname), sfxs, xzj, pycsx, pycsy, mxjdx, mxjdy, zxzbpastx, zxzbpasty,
228
+         zxzbnewx, zxzbnewy, n1, n2, n3, n4, n5, n6,))
229
+    # Trans_Point和Result_Point一起存
209
     for iname in listname1:
230
     for iname in listname1:
210
         if iname in listname:
231
         if iname in listname:
211
-            #属于没问题点的
212
-            #直接使用gsx,gsy
232
+            # 属于没问题点的
233
+            # 直接使用gsx,gsy
213
             utf_pointname = to_utf8(str(iname))
234
             utf_pointname = to_utf8(str(iname))
214
             wystr = to_utf8('稳定')
235
             wystr = to_utf8('稳定')
215
             index1 = listname.index(iname)
236
             index1 = listname.index(iname)
216
-            numm1 = round(gsx[index1],4)
217
-            numm2 = round(gsy[index1],4)
218
-            #先找到首次的index
237
+            numm1 = round(gsx[index1], 4)
238
+            numm2 = round(gsy[index1], 4)
239
+            # 先找到首次的index
219
             index2 = listname1.index(iname)
240
             index2 = listname1.index(iname)
220
-            r1 = (listpastx1[index2] - gsx[index1])*1000
221
-            r2 = (listpasty1[index2] - gsy[index1])*1000
241
+            r1 = (listpastx1[index2] - gsx[index1]) * 1000
242
+            r2 = (listpasty1[index2] - gsy[index1]) * 1000
222
             r3 = r1 * r1
243
             r3 = r1 * r1
223
             r4 = r2 * r2
244
             r4 = r2 * r2
224
             r5 = r3 + r4
245
             r5 = r3 + r4
225
-            r6 = round(math.sqrt(r5),1)
246
+            r6 = round(math.sqrt(r5), 1)
226
             numn1 = listpastx1[index2]
247
             numn1 = listpastx1[index2]
227
             numn2 = listnewx1[index2]
248
             numn2 = listnewx1[index2]
228
-            cursor1.execute('INSERT INTO GS_Trans_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,New_X,New_Y) VALUES (?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listnewx1[index2],listnewy1[index2],))
229
-            cursor1.execute('INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listpastx1[index2],listpasty1[index2],numm1,numm2,0,0,0,r1,r2,r6,wystr,))
249
+            cursor1.execute(
250
+                'INSERT INTO GS_Trans_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,New_X,New_Y) VALUES (?,?,?,?,?,?,?,?)',
251
+                (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2], listnewx1[index2],
252
+                 listnewy1[index2],))
253
+            cursor1.execute(
254
+                'INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
255
+                (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2], listpastx1[index2],
256
+                 listpasty1[index2], numm1, numm2, 0, 0, 0, r1, r2, r6, wystr,))
230
         else:
257
         else:
231
             index2 = listname1.index(iname)
258
             index2 = listname1.index(iname)
232
             utf_pointname = to_utf8(str(iname))
259
             utf_pointname = to_utf8(str(iname))
233
-            #首先判断有没有第一个点
260
+            # 首先判断有没有第一个点
234
             if listnewx1[index2] != 0:
261
             if listnewx1[index2] != 0:
235
-                #有问题的点,使用公式跑
236
-                listxy = gsjs(listnewx1[index2],listnewy1[index2],nlist)   
237
-                #判断有没有第一次的数据,没有就不写
262
+                # 有问题的点,使用公式跑
263
+                listxy = gsjs(listnewx1[index2], listnewy1[index2], nlist)
264
+                # 判断有没有第一次的数据,没有就不写
238
                 if listpastx1[index2] != 0:
265
                 if listpastx1[index2] != 0:
239
-                    r1 = (listpastx1[index2] - listxy[0])*1000
240
-                    r2 = (listpasty1[index2] - listxy[1])*1000
266
+                    r1 = (listpastx1[index2] - listxy[0]) * 1000
267
+                    r2 = (listpasty1[index2] - listxy[1]) * 1000
241
                     r3 = r1 * r1
268
                     r3 = r1 * r1
242
                     r4 = r2 * r2
269
                     r4 = r2 * r2
243
                     r5 = r3 + r4
270
                     r5 = r3 + r4
244
-                    r6 = round(math.sqrt(r5),1)
271
+                    r6 = round(math.sqrt(r5), 1)
245
                     if r6 > 500:
272
                     if r6 > 500:
246
                         wystr = to_utf8('复建')
273
                         wystr = to_utf8('复建')
247
-                        cursor1.execute('INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listxy[0],listxy[1],listxy[0],listxy[1],r1,r2,r6,r1,r2,r6,wystr,))
274
+                        cursor1.execute(
275
+                            'INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
276
+                            (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2], listxy[0],
277
+                             listxy[1], listxy[0], listxy[1], r1, r2, r6, r1, r2, r6, wystr,))
248
                     else:
278
                     else:
249
                         wystr = to_utf8('位移')
279
                         wystr = to_utf8('位移')
250
-                        cursor1.execute('INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listxy[0],listxy[1],listxy[0],listxy[1],r1,r2,r6,r1,r2,r6,wystr,))
280
+                        cursor1.execute(
281
+                            'INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
282
+                            (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2], listxy[0],
283
+                             listxy[1], listxy[0], listxy[1], r1, r2, r6, r1, r2, r6, wystr,))
251
                 else:
284
                 else:
252
                     wystr = to_utf8('新建')
285
                     wystr = to_utf8('新建')
253
-                    cursor1.execute('INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listnewx1[index2],listnewy1[index2],listpastx1[index2],listpasty1[index2],0,0,0,0,0,0,wystr,))
254
-    #数据库执行
286
+                    cursor1.execute(
287
+                        'INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
288
+                        (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2],
289
+                         listnewx1[index2], listnewy1[index2], listpastx1[index2], listpasty1[index2], 0, 0, 0, 0, 0, 0,
290
+                         wystr,))
291
+    # 数据库执行
255
     db1.commit()
292
     db1.commit()
256
-    #做完一切后,先关闭游标,再关闭数据库
293
+    # 做完一切后,先关闭游标,再关闭数据库
257
     cursor1.close()
294
     cursor1.close()
258
     db1.close()
295
     db1.close()
259
 
296
 
260
-def tablein(outpath,str1):
297
+
298
+def tablein(outpath, str1):
299
+    print(f"Connecting to database at path: {outpath}")
261
     listcgcs1 = []
300
     listcgcs1 = []
262
     listname1 = []
301
     listname1 = []
263
     listpastx1 = []
302
     listpastx1 = []
271
     listnewx1 = []
310
     listnewx1 = []
272
     listnewy1 = []
311
     listnewy1 = []
273
     points = 0
312
     points = 0
274
-    #查询,提取需要的数据
313
+    # 查询,提取需要的数据
275
     db2 = sqlite3.connect(outpath)
314
     db2 = sqlite3.connect(outpath)
276
     cursor2 = db2.cursor()
315
     cursor2 = db2.cursor()
277
     utfstr1 = to_utf8(str1)
316
     utfstr1 = to_utf8(str1)
278
     sqlstr1 = 'SELECT * FROM GS_Input_Point WHERE TableName = ?'
317
     sqlstr1 = 'SELECT * FROM GS_Input_Point WHERE TableName = ?'
279
-    cursor2.execute(sqlstr1,(utfstr1,))
318
+    cursor2.execute(sqlstr1, (utfstr1,))
280
     all_da = cursor2.fetchall()
319
     all_da = cursor2.fetchall()
281
     for da in all_da:
320
     for da in all_da:
282
         listpastx.append(da[3])
321
         listpastx.append(da[3])
293
         listcgcs1.append(da[8])
332
         listcgcs1.append(da[8])
294
         points = points + 1
333
         points = points + 1
295
     sqlstr2 = 'SELECT * FROM GS_Input_Param WHERE TableName = ?'
334
     sqlstr2 = 'SELECT * FROM GS_Input_Param WHERE TableName = ?'
296
-    cursor2.execute(sqlstr2,(utfstr1,))
335
+    cursor2.execute(sqlstr2, (utfstr1,))
297
     all_par = cursor2.fetchall()
336
     all_par = cursor2.fetchall()
337
+    if not all_par:
338
+        raise ValueError(f"No data found in GS_Input_Param for TableName: {str1}")
298
     pastname = all_par[0][1].decode('utf-8')
339
     pastname = all_par[0][1].decode('utf-8')
299
     newname = all_par[0][2].decode('utf-8')
340
     newname = all_par[0][2].decode('utf-8')
300
     # pjbc是平均边长
341
     # pjbc是平均边长
319
     wypd3 = math.sqrt(wypd1 + wypd2)
360
     wypd3 = math.sqrt(wypd1 + wypd2)
320
     wypd = round(wypd3 * 3, 4)
361
     wypd = round(wypd3 * 3, 4)
321
     wypd0 = wypd
362
     wypd0 = wypd
322
-    #更新下数据库(参数部分)
363
+    # 更新下数据库(参数部分)
323
     sqlstr3 = 'update GS_Input_Param set Pt_Count=?,Avg_MSL=?,Avg_Dir=? WHERE TableName = ?'
364
     sqlstr3 = 'update GS_Input_Param set Pt_Count=?,Avg_MSL=?,Avg_Dir=? WHERE TableName = ?'
324
-    cursor2.execute(sqlstr3,(points,pjbcs,pjfxs,utfstr1,))
325
-    #数据库执行
365
+    cursor2.execute(sqlstr3, (points, pjbcs, pjfxs, utfstr1,))
366
+    # 数据库执行
326
     db2.commit()
367
     db2.commit()
327
-    #做完一切后,先关闭游标,再关闭数据库
368
+    # 做完一切后,先关闭游标,再关闭数据库
328
     cursor2.close()
369
     cursor2.close()
329
     db2.close()
370
     db2.close()
330
     js = 0
371
     js = 0
331
-    return listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs,sf, newname, pastname, js,listnewx1,listnewy1
372
+    return listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, sf, newname, pastname, js, listnewx1, listnewy1
332
 
373
 
333
-def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs,  sf, newname, pastname, js,listnewx1,listnewy1,excelname):
374
+
375
+def bhjs(dbpath, listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx, listpasty,
376
+         points, listcgcs, sf, newname, pastname, js, listnewx1, listnewy1, excelname):
334
     np.set_printoptions(suppress=False)
377
     np.set_printoptions(suppress=False)
335
     # pt用于给点数point计数
378
     # pt用于给点数point计数
336
     # point会随着回递函数而减少
379
     # point会随着回递函数而减少
363
     # 先计算平移参数
406
     # 先计算平移参数
364
     # pycsx = abs(zxzbnewx - zxzbpastx) * 1000
407
     # pycsx = abs(zxzbnewx - zxzbpastx) * 1000
365
     # pycsy = abs(zxzbnewy - zxzbpasty) * 1000
408
     # pycsy = abs(zxzbnewy - zxzbpasty) * 1000
366
-    pycsx = round((zxzbpastx - zxzbnewx),4)
367
-    pycsy = round((zxzbpasty - zxzbnewy),4)
409
+    pycsx = round((zxzbpastx - zxzbnewx), 4)
410
+    pycsy = round((zxzbpasty - zxzbnewy), 4)
368
     # 分别得k,sita的值
411
     # 分别得k,sita的值
369
     klist = jzys1(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
412
     klist = jzys1(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
370
     slist = jzys2(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
413
     slist = jzys2(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
379
     dy2 = cjh(dylist)
422
     dy2 = cjh(dylist)
380
     # 这里再创建矩阵1
423
     # 这里再创建矩阵1
381
     arr1 = np.array(((k2, 0, 0, 0), (0, s2, 0, 0),
424
     arr1 = np.array(((k2, 0, 0, 0), (0, s2, 0, 0),
382
-                    (0, 0, dx2, 0), (0, 0, 0, dy2)))
425
+                     (0, 0, dx2, 0), (0, 0, 0, dy2)))
383
     # 矩阵1的逆矩阵矩阵2
426
     # 矩阵1的逆矩阵矩阵2
384
     arr2 = np.linalg.inv(arr1)
427
     arr2 = np.linalg.inv(arr1)
385
     # 求矩阵l
428
     # 求矩阵l
386
     llist = jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx,
429
     llist = jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx,
387
-                    listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
430
+                  listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
388
     # 得到数列e1,e2,e3,e4
431
     # 得到数列e1,e2,e3,e4
389
     e1 = cjh2(klist, llist)
432
     e1 = cjh2(klist, llist)
390
     e2 = cjh2(slist, llist)
433
     e2 = cjh2(slist, llist)
403
     lylist = jzys3(jylist1, 0, 1)
446
     lylist = jzys3(jylist1, 0, 1)
404
     # 求改算坐标
447
     # 求改算坐标
405
     gsx = gsys(listnewx, jxlist1, jylist1, lxlist,
448
     gsx = gsys(listnewx, jxlist1, jylist1, lxlist,
406
-                lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
449
+               lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
407
     gsy = gsys(listnewy, jxlist2, jylist2, lxlist,
450
     gsy = gsys(listnewy, jxlist2, jylist2, lxlist,
408
-                lylist, arrz, sf, zxzbnewy, zxzbpasty, 1)
409
-    #缩放系数也是计算出来的sfxs
410
-    sfxs = sfjs(gsx,listnewx,gsy,listnewy)
411
-    #旋转角,模型精度
412
-    xzj = xzjs(gsx,listnewx,gsy,listnewy)
413
-    mxjdx = mxjd(gsx,listpastx)
414
-    mxjdy = mxjd(gsy,listpasty)
451
+               lylist, arrz, sf, zxzbnewy, zxzbpasty, 1)
452
+    # 缩放系数也是计算出来的sfxs
453
+    sfxs = sfjs(gsx, listnewx, gsy, listnewy)
454
+    # 旋转角,模型精度
455
+    xzj = xzjs(gsx, listnewx, gsy, listnewy)
456
+    mxjdx = mxjd(gsx, listpastx)
457
+    mxjdy = mxjd(gsy, listpasty)
415
     # 还是要先求较差
458
     # 还是要先求较差
416
     xcx = xcys(gsx, listpastx)
459
     xcx = xcys(gsx, listpastx)
417
     xcy = xcys(gsy, listpasty)
460
     xcy = xcys(gsy, listpasty)
458
         n3 = zxzbpastx - zxzbnewx - s1 - s2 + float(arrz[2])
501
         n3 = zxzbpastx - zxzbnewx - s1 - s2 + float(arrz[2])
459
         n4 = (-1) * float(arrz[1])
502
         n4 = (-1) * float(arrz[1])
460
         n5 = n1
503
         n5 = n1
461
-        s3 = (-1)*float(arrz[0])*zxzbnewy
462
-        s4 = float(arrz[1])*zxzbnewx
463
-        n6 = s3 + s4 + float(arrz[3])+zxzbpasty-zxzbnewy
504
+        s3 = (-1) * float(arrz[0]) * zxzbnewy
505
+        s4 = float(arrz[1]) * zxzbnewx
506
+        n6 = s3 + s4 + float(arrz[3]) + zxzbpasty - zxzbnewy
464
         sxylist = []
507
         sxylist = []
465
         sxylist.append(n1)
508
         sxylist.append(n1)
466
         sxylist.append(n2)
509
         sxylist.append(n2)
484
         lengs1 = len(gszbx)
527
         lengs1 = len(gszbx)
485
         nlist = relist1[6]
528
         nlist = relist1[6]
486
         # return relist
529
         # return relist
487
-        #中文再来一次
530
+        # 中文再来一次
488
         utf_pan = to_utf8(pastname)
531
         utf_pan = to_utf8(pastname)
489
         utf_nn = to_utf8(newname)
532
         utf_nn = to_utf8(newname)
490
         utf_tn = to_utf8(excelname)
533
         utf_tn = to_utf8(excelname)
491
-        insert_into_database1(dbpath,utf_tn,listname1,listname,gsx,gsy,listpastx1,listpasty1,listnewx1,listnewy1,nlist,utf_pan,utf_nn,wypd,sfxs,xzj,pycsx,pycsy,mxjdx,mxjdy,zxzbpastx,zxzbpasty,zxzbnewx,zxzbnewy,n1,n2,n3,n4,n5,n6)
534
+        insert_into_database1(dbpath, utf_tn, listname1, listname, gsx, gsy, listpastx1, listpasty1, listnewx1,
535
+                              listnewy1, nlist, utf_pan, utf_nn, wypd, sfxs, xzj, pycsx, pycsy, mxjdx, mxjdy, zxzbpastx,
536
+                              zxzbpasty, zxzbnewx, zxzbnewy, n1, n2, n3, n4, n5, n6)
492
 
537
 
493
-    else:           
538
+    else:
494
         # 先把所有的合在一起,方便删除
539
         # 先把所有的合在一起,方便删除
495
         lenlist1 = len(xcx)
540
         lenlist1 = len(xcx)
496
         ii = 0
541
         ii = 0
534
                 mm2 = mm2 + 1
579
                 mm2 = mm2 + 1
535
         print(" Finish!")
580
         print(" Finish!")
536
         js1 = 1
581
         js1 = 1
537
-        bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx,
538
-                listpasty, points, listcgcs, sf, newname, pastname, js1,listnewx1,listnewy1,excelname)
582
+        bhjs(dbpath, listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx,
583
+             listpasty, points, listcgcs, sf, newname, pastname, js1, listnewx1, listnewy1, excelname)
539
 
584
 
540
 
585
 
541
 # 主函数 计算
586
 # 主函数 计算
542
-def main_function(dbpath,file_name):
543
-    #从数据库中调用
544
-    listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs,sf, newname, pastname, js,listnewx1,listnewy1 = tablein(dbpath,file_name)
545
-    #计算
546
-    bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs,sf, newname, pastname, js,listnewx1,listnewy1,file_name)
547
-    messagebox.showinfo("提示",f"文件 '{file_name}' 计算成功!")
587
+def main_function(file_name, dbpath):
588
+    try:
589
+        print(f"File name: {file_name}")
590
+        # 从数据库中调用
591
+        listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, sf, newname, pastname, js, listnewx1, listnewy1 = tablein(
592
+            dbpath, file_name)
593
+        # 计算
594
+        bhjs(dbpath, listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,
595
+             listpasty, points, listcgcs, sf, newname, pastname, js, listnewx1, listnewy1, file_name)
596
+        QMessageBox.information(None, "提示", f"文件 '{file_name}' 计算成功!")
597
+    except Exception as e:
598
+        QMessageBox.critical(None, "错误", f"文件 '{file_name}' 计算失败!错误信息: {str(e)}")

+ 53
- 7
Back/WD/WDshow.py View File

4
 from PySide6.QtGui import QStandardItemModel
4
 from PySide6.QtGui import QStandardItemModel
5
 
5
 
6
 def main_function(ui, db_path, utf_en):
6
 def main_function(ui, db_path, utf_en):
7
-    # 只显示一个tab
8
-    ui.tabWidget.setTabVisible(0, True)
9
-    ui.tabWidget.setTabVisible(1, False)
10
-    ui.tabWidget.setTabVisible(2, False)
11
-    # 重新设置文字名称
12
-    ui.tabWidget.setTabText(0, '平面控制网稳定性计算成果表')
7
+    #只显示头两个tab
8
+    ui.tabWidget.setTabVisible(0,True)
9
+    ui.tabWidget.setTabVisible(1,True)
10
+    ui.tabWidget.setTabVisible(2,False)
11
+    #重新设置文字名称
12
+    ui.tabWidget.setTabText(0,'稳定性分析成果表')
13
+    ui.tabWidget.setTabText(1,'自由网成果归算模型')
14
+    #链接数据库并显示
13
     # 连接到数据库
15
     # 连接到数据库
16
+    #将结果输出到数据库
14
     db1 = sqlite3.connect(db_path)
17
     db1 = sqlite3.connect(db_path)
15
-    db1.text_factory = lambda x: str(x, 'utf-8')
18
+    #获取游标
16
     cursor1 = db1.cursor()
19
     cursor1 = db1.cursor()
20
+    #查询表内符合的所有数据
21
+    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 from WD_Result_Point WHERE TableName = ?'
22
+    cursor1.execute(sqlstr1,(utf_en,))
23
+    #获取结果集
24
+    result = cursor1.fetchall()
25
+    #对结果集进行处理,把汉字转换过来,添加表头部分
26
+    nlist,plist = Arrange_Data(result)
27
+    # 创建一个数据模型
28
+    model = QStandardItemModel()
29
+    #把数据放进去
30
+    model1 = Data_in_Cell(plist)
31
+    #设置表头
32
+    model1.setHorizontalHeaderLabels(['点名', '首期X','首期Y','上期X', '上期Y','权','本期X','本期Y','权','本期-首期X','本期-首期Y','本期-首期P','位移判定', '本期-上期X','本期-上期Y','本期-上期P','位移判定'])
33
+    model1.setVerticalHeaderLabels(nlist)
34
+    #QTableView并将数据模型与之关联
35
+    ui.resultTableView.setModel(model1)
36
+    ui.resultTableView.show()
17
 
37
 
38
+    #富文本的html
39
+    sqlstr2 = 'select Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3 from WD_Result_Param WHERE TableName = ?'
40
+    cursor1.execute(sqlstr2,(utf_en,))
41
+    #获取结果集
42
+    result1 = cursor1.fetchall()
43
+    str1 = result1[0][0].decode('utf-8')
44
+    str2 = result1[0][1].decode('utf-8')
45
+    n1 = result1[0][2]
46
+    n2 = result1[0][3]
47
+    n3 = result1[0][4]
48
+    n4 = result1[0][5]
49
+    n5 = result1[0][6]
50
+    n6 = result1[0][7]
51
+    str0 = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
52
+<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
53
+p, li { white-space: pre-wrap; }
54
+hr { height: 1px; border-width: 0; }
55
+li.unchecked::marker { content: "\2610"; }
56
+li.checked::marker { content: "\2612"; }
57
+</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
58
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; color:#000000;">"""+str2+"""--"""+str1+"""</span><span style=" font-size:14pt;">已知系统转换公式:</span></p>
59
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">X</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n1)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n2)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n3)+"""</span><span style=" font-size:14pt;">)</span></p>
60
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:700;">Y</span><span style=" font-size:14pt;">=(</span><span style=" font-size:14pt; color:#aa0000;">"""+str(n4)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00aa00;">"""+str(n5)+"""</span><span style=" font-size:14pt;">)</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+(</span><span style=" font-size:14pt; color:#00007f;">"""+str(n6)+"""</span><span style=" font-size:14pt;">)</span></p>
61
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">式中:</span><span style=" font-size:14pt; font-weight:700; color:#000000;">x、y</span><span style=" font-size:14pt;">为</span><span style=" font-size:14pt; color:#000000;">"""+str2+"""</span><span style=" font-size:14pt;">坐标;</span></p>
62
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">          </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为"""+str1+"""已知系统的"""+str2+"""归算坐标。</span></p></body></html>"""
63
+    ui.printTableView.setHtml(str0)

+ 1
- 1
Front/main.py View File

234
                 # 1秒后自动跳转
234
                 # 1秒后自动跳转
235
                 QTimer.singleShot(1000, lambda: self.simulateButtonClick("btn_new"))
235
                 QTimer.singleShot(1000, lambda: self.simulateButtonClick("btn_new"))
236
             else:
236
             else:
237
-                QMessageBox.warning(self, '警告', '请先上传文件到本地数据库中')
237
+                QMessageBox.warning(self, '警告', '请先选择项目并上传文件')
238
 
238
 
239
         # 输出点击回馈
239
         # 输出点击回馈
240
         print(f'Button "{btnName}" pressed!')
240
         print(f'Button "{btnName}" pressed!')

+ 3
- 4
Front/modules/ui_functions.py View File

329
         sql_folder = os.path.abspath(sql_folder)
329
         sql_folder = os.path.abspath(sql_folder)
330
         db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
330
         db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
331
         # 转换为utf-8
331
         # 转换为utf-8
332
-        excelname = os.path.basename(file_path)
333
-        utf_en = excelname.encode('utf-8')
332
+        excelname = os.path.basename(file_path)  # 文件名
333
+        utf_en = excelname.encode('utf-8')  # 转换文件名为utf-8编码形式
334
         if current_text == "水准测段高差稳定计算":
334
         if current_text == "水准测段高差稳定计算":
335
             GCcompute.main_function(file_path, db_path)
335
             GCcompute.main_function(file_path, db_path)
336
             GCshow.main_function(self.ui, db_path, utf_en)
336
             GCshow.main_function(self.ui, db_path, utf_en)
337
         elif current_text == "控制网复测平面基准计算":
337
         elif current_text == "控制网复测平面基准计算":
338
-            # GScompute.main_function(file_path, db_path)
338
+            GScompute.main_function(excelname, db_path)
339
             GSshow.main_function(self.ui, db_path, utf_en)
339
             GSshow.main_function(self.ui, db_path, utf_en)
340
-            # GSshow.main_function(self.ui, file_path, db_path)
341
         elif current_text == "平面控制网稳定性计算":
340
         elif current_text == "平面控制网稳定性计算":
342
             WDcompute.main_function(file_path, db_path)
341
             WDcompute.main_function(file_path, db_path)
343
             WDshow.main_function(self.ui, db_path, utf_en)
342
             WDshow.main_function(self.ui, db_path, utf_en)

BIN
SQL/DataBase.db View File


Loading…
Cancel
Save