소스 검색

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

wzp 5 달 전
부모
커밋
8087091976
7개의 변경된 파일351개의 추가작업 그리고 231개의 파일을 삭제
  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 파일 보기

@@ -2,6 +2,8 @@ import os
2 2
 import sqlite3
3 3
 import math
4 4
 
5
+from PySide6.QtWidgets import QMessageBox
6
+
5 7
 
6 8
 def calculate_absolute_height_differences(db_path, file_name, field_name):
7 9
     """
@@ -271,74 +273,89 @@ def insert_records_to_output_table(db_path, file_name, dis_ass, new_hdiff, corre
271 273
 
272 274
 
273 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 파일 보기

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

@@ -1,17 +1,18 @@
1 1
 import sqlite3
2 2
 import os
3
-import tkinter as tk
4
-from tkinter import messagebox
5 3
 import math
6 4
 import numpy as np
5
+from PySide6.QtWidgets import QMessageBox
7 6
 
8
-#region 各种方法
7
+
8
+# region 各种方法
9 9
 
10 10
 def to_utf8(text):
11 11
     str1 = text.encode('utf-8')
12 12
     return str1
13 13
 
14
-def sfjs(gsx,listx,gsy,listy):
14
+
15
+def sfjs(gsx, listx, gsy, listy):
15 16
     s1 = gsx[len(gsx) - 1] - gsx[0]
16 17
     s2 = s1 * s1
17 18
     s3 = gsy[len(gsy) - 1] - gsy[0]
@@ -24,10 +25,11 @@ def sfjs(gsx,listx,gsy,listy):
24 25
     t4 = t3 * t3
25 26
     t5 = t2 + t4
26 27
     t6 = math.sqrt(t5)
27
-    num1 = round(s6/t6,8)
28
+    num1 = round(s6 / t6, 8)
28 29
     return num1
29 30
 
30
-def mxjd(gs,nw):
31
+
32
+def mxjd(gs, nw):
31 33
     ii = 0
32 34
     sum1 = 0
33 35
     while ii < len(gs):
@@ -40,7 +42,8 @@ def mxjd(gs,nw):
40 42
     num1 = s4 * 1000
41 43
     return num1
42 44
 
43
-def xzjs(gsx,listx,gsy,listy):
45
+
46
+def xzjs(gsx, listx, gsy, listy):
44 47
     s1 = gsx[len(gsx) - 1] - gsx[0]
45 48
     s2 = gsy[len(gsy) - 1] - gsy[0]
46 49
     s3 = s2 / s1
@@ -53,7 +56,8 @@ def xzjs(gsx,listx,gsy,listy):
53 56
     num1 = n1 * 180 / math.pi * 3600
54 57
     return num1
55 58
 
56
-def gsjs(x,y,nlist):
59
+
60
+def gsjs(x, y, nlist):
57 61
     listgsx = []
58 62
     xstr1 = nlist[0] * x
59 63
     xstr2 = nlist[1] * y
@@ -65,6 +69,7 @@ def gsjs(x,y,nlist):
65 69
     listgsx.append(yy)
66 70
     return listgsx
67 71
 
72
+
68 73
 def jzys1(listy, zxzby, listx, zxzbx, sf):
69 74
     rlist = []
70 75
     listlen = len(listy)
@@ -80,6 +85,7 @@ def jzys1(listy, zxzby, listx, zxzbx, sf):
80 85
         ll = ll + 1
81 86
     return rlist
82 87
 
88
+
83 89
 def jzys2(listy, zxzby, listx, zxzbx, sf):
84 90
     rlist = []
85 91
     listlen = len(listy)
@@ -93,6 +99,7 @@ def jzys2(listy, zxzby, listx, zxzbx, sf):
93 99
         ll = ll + 1
94 100
     return rlist
95 101
 
102
+
96 103
 def jzys3(listy, aa, bb):
97 104
     rlist = []
98 105
     listlen = len(listy)
@@ -106,6 +113,7 @@ def jzys3(listy, aa, bb):
106 113
         ll = ll + 1
107 114
     return rlist
108 115
 
116
+
109 117
 def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listnewx, zxzbnewx, sf):
110 118
     rlist = []
111 119
     listlen = len(listnewx)
@@ -113,11 +121,12 @@ def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listne
113 121
     while ll < listlen:
114 122
         num1 = (listpastx[ll] - listnewx[ll] - zxzbpastx + zxzbnewx) / sf
115 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 126
         ll = ll + 1
119 127
     return rlist
120 128
 
129
+
121 130
 def jzys5(listp, zxzbp, sf):
122 131
     rlist = []
123 132
     listlen = len(listp)
@@ -128,6 +137,7 @@ def jzys5(listp, zxzbp, sf):
128 137
         ll = ll + 1
129 138
     return rlist
130 139
 
140
+
131 141
 def jzys6(listp, num):
132 142
     rlist = []
133 143
     listlen = len(listp)
@@ -138,6 +148,7 @@ def jzys6(listp, num):
138 148
         ll = ll + 1
139 149
     return rlist
140 150
 
151
+
141 152
 def cjh(listp):
142 153
     rp = 0
143 154
     listlen = len(listp)
@@ -148,6 +159,7 @@ def cjh(listp):
148 159
         ll = ll + 1
149 160
     return rp
150 161
 
162
+
151 163
 def cjh2(lista, listb):
152 164
     rp = 0
153 165
     listlen = len(lista)
@@ -158,6 +170,7 @@ def cjh2(lista, listb):
158 170
         ll = ll + 1
159 171
     return rp
160 172
 
173
+
161 174
 def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpastp, ii):
162 175
     # 新x+(矩阵[jx1 jy1 lx1 ly1]*矩阵z)*缩放-新重心坐标x+旧重心坐标x
163 176
     rlist = []
@@ -165,7 +178,7 @@ def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpas
165 178
     ll = 0
166 179
     while ll < listlen:
167 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 182
         arr1 = np.matmul(arr0, arrz)
170 183
         arr3 = sf * arr1
171 184
         newp = listnewp[ll] + arr3 - zxzbnewp + zxzbpastp
@@ -173,91 +186,117 @@ def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpas
173 186
         ll = ll + 1
174 187
     return rlist
175 188
 
189
+
176 190
 def xcys(newlist, pastlist):
177 191
     listlen = len(newlist)
178 192
     ll = 0
179 193
     rlist = []
180 194
     while ll < listlen:
181
-        num1 =pastlist[ll] - newlist[ll]
195
+        num1 = pastlist[ll] - newlist[ll]
182 196
         num2 = num1 * 1000
183 197
         rlist.append(num2)
184 198
         ll = ll + 1
185 199
     return rlist
186 200
 
201
+
187 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 212
     db1 = sqlite3.connect(database)
195
-    #获取游标
213
+    # 获取游标
196 214
     cursor1 = db1.cursor()
197
-    #先清除已有数据,用来更新
215
+    # 先清除已有数据,用来更新
198 216
     try:
199 217
         sqlstr3 = 'delete from GS_Trans_Param WHERE TableName = ?'
200 218
         sqlstr4 = 'delete from GS_Trans_Point WHERE TableName = ?'
201 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 223
     except:
206 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 230
     for iname in listname1:
210 231
         if iname in listname:
211
-            #属于没问题点的
212
-            #直接使用gsx,gsy
232
+            # 属于没问题点的
233
+            # 直接使用gsx,gsy
213 234
             utf_pointname = to_utf8(str(iname))
214 235
             wystr = to_utf8('稳定')
215 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 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 243
             r3 = r1 * r1
223 244
             r4 = r2 * r2
224 245
             r5 = r3 + r4
225
-            r6 = round(math.sqrt(r5),1)
246
+            r6 = round(math.sqrt(r5), 1)
226 247
             numn1 = listpastx1[index2]
227 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 257
         else:
231 258
             index2 = listname1.index(iname)
232 259
             utf_pointname = to_utf8(str(iname))
233
-            #首先判断有没有第一个点
260
+            # 首先判断有没有第一个点
234 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 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 268
                     r3 = r1 * r1
242 269
                     r4 = r2 * r2
243 270
                     r5 = r3 + r4
244
-                    r6 = round(math.sqrt(r5),1)
271
+                    r6 = round(math.sqrt(r5), 1)
245 272
                     if r6 > 500:
246 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 278
                     else:
249 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 284
                 else:
252 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 292
     db1.commit()
256
-    #做完一切后,先关闭游标,再关闭数据库
293
+    # 做完一切后,先关闭游标,再关闭数据库
257 294
     cursor1.close()
258 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 300
     listcgcs1 = []
262 301
     listname1 = []
263 302
     listpastx1 = []
@@ -271,12 +310,12 @@ def tablein(outpath,str1):
271 310
     listnewx1 = []
272 311
     listnewy1 = []
273 312
     points = 0
274
-    #查询,提取需要的数据
313
+    # 查询,提取需要的数据
275 314
     db2 = sqlite3.connect(outpath)
276 315
     cursor2 = db2.cursor()
277 316
     utfstr1 = to_utf8(str1)
278 317
     sqlstr1 = 'SELECT * FROM GS_Input_Point WHERE TableName = ?'
279
-    cursor2.execute(sqlstr1,(utfstr1,))
318
+    cursor2.execute(sqlstr1, (utfstr1,))
280 319
     all_da = cursor2.fetchall()
281 320
     for da in all_da:
282 321
         listpastx.append(da[3])
@@ -293,8 +332,10 @@ def tablein(outpath,str1):
293 332
         listcgcs1.append(da[8])
294 333
         points = points + 1
295 334
     sqlstr2 = 'SELECT * FROM GS_Input_Param WHERE TableName = ?'
296
-    cursor2.execute(sqlstr2,(utfstr1,))
335
+    cursor2.execute(sqlstr2, (utfstr1,))
297 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 339
     pastname = all_par[0][1].decode('utf-8')
299 340
     newname = all_par[0][2].decode('utf-8')
300 341
     # pjbc是平均边长
@@ -319,18 +360,20 @@ def tablein(outpath,str1):
319 360
     wypd3 = math.sqrt(wypd1 + wypd2)
320 361
     wypd = round(wypd3 * 3, 4)
321 362
     wypd0 = wypd
322
-    #更新下数据库(参数部分)
363
+    # 更新下数据库(参数部分)
323 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 367
     db2.commit()
327
-    #做完一切后,先关闭游标,再关闭数据库
368
+    # 做完一切后,先关闭游标,再关闭数据库
328 369
     cursor2.close()
329 370
     db2.close()
330 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 377
     np.set_printoptions(suppress=False)
335 378
     # pt用于给点数point计数
336 379
     # point会随着回递函数而减少
@@ -363,8 +406,8 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
363 406
     # 先计算平移参数
364 407
     # pycsx = abs(zxzbnewx - zxzbpastx) * 1000
365 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 411
     # 分别得k,sita的值
369 412
     klist = jzys1(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
370 413
     slist = jzys2(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
@@ -379,12 +422,12 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
379 422
     dy2 = cjh(dylist)
380 423
     # 这里再创建矩阵1
381 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 426
     # 矩阵1的逆矩阵矩阵2
384 427
     arr2 = np.linalg.inv(arr1)
385 428
     # 求矩阵l
386 429
     llist = jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx,
387
-                    listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
430
+                  listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
388 431
     # 得到数列e1,e2,e3,e4
389 432
     e1 = cjh2(klist, llist)
390 433
     e2 = cjh2(slist, llist)
@@ -403,15 +446,15 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
403 446
     lylist = jzys3(jylist1, 0, 1)
404 447
     # 求改算坐标
405 448
     gsx = gsys(listnewx, jxlist1, jylist1, lxlist,
406
-                lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
449
+               lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
407 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 459
     xcx = xcys(gsx, listpastx)
417 460
     xcy = xcys(gsy, listpasty)
@@ -458,9 +501,9 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
458 501
         n3 = zxzbpastx - zxzbnewx - s1 - s2 + float(arrz[2])
459 502
         n4 = (-1) * float(arrz[1])
460 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 507
         sxylist = []
465 508
         sxylist.append(n1)
466 509
         sxylist.append(n2)
@@ -484,13 +527,15 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
484 527
         lengs1 = len(gszbx)
485 528
         nlist = relist1[6]
486 529
         # return relist
487
-        #中文再来一次
530
+        # 中文再来一次
488 531
         utf_pan = to_utf8(pastname)
489 532
         utf_nn = to_utf8(newname)
490 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 540
         lenlist1 = len(xcx)
496 541
         ii = 0
@@ -534,14 +579,20 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
534 579
                 mm2 = mm2 + 1
535 580
         print(" Finish!")
536 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 파일 보기

@@ -4,14 +4,60 @@ import sqlite3
4 4
 from PySide6.QtGui import QStandardItemModel
5 5
 
6 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 17
     db1 = sqlite3.connect(db_path)
15
-    db1.text_factory = lambda x: str(x, 'utf-8')
18
+    #获取游标
16 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 파일 보기

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

+ 3
- 4
Front/modules/ui_functions.py 파일 보기

@@ -329,15 +329,14 @@ class UIFunctions(MainWindow):
329 329
         sql_folder = os.path.abspath(sql_folder)
330 330
         db_path = os.path.join(sql_folder, f"{self.ui.comboBox.currentText()}.db")
331 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 334
         if current_text == "水准测段高差稳定计算":
335 335
             GCcompute.main_function(file_path, db_path)
336 336
             GCshow.main_function(self.ui, db_path, utf_en)
337 337
         elif current_text == "控制网复测平面基准计算":
338
-            # GScompute.main_function(file_path, db_path)
338
+            GScompute.main_function(excelname, db_path)
339 339
             GSshow.main_function(self.ui, db_path, utf_en)
340
-            # GSshow.main_function(self.ui, file_path, db_path)
341 340
         elif current_text == "平面控制网稳定性计算":
342 341
             WDcompute.main_function(file_path, db_path)
343 342
             WDshow.main_function(self.ui, db_path, utf_en)

BIN
SQL/DataBase.db 파일 보기


Loading…
취소
저장