|
@@ -463,4 +463,157 @@ class UIFunctions(MainWindow):
|
463
|
463
|
db1.close()
|
464
|
464
|
WDcompute.main_function(tableName, dbPath)
|
465
|
465
|
WDshow.main_function(self.ui, dbPath, tableName_utf8)
|
|
466
|
+
|
|
467
|
+ #编辑完后的数据更新
|
|
468
|
+ #输入模型,方法,表名utf8,数据库
|
|
469
|
+ def update_to_db(self,model1,methodName, tableName_utf8, dbPath):
|
|
470
|
+ db1 = sqlite3.connect(dbPath)
|
|
471
|
+ cursor1 = db1.cursor()
|
|
472
|
+ # 通过行锁定对应的字段
|
|
473
|
+ if methodName == '水准测段高差稳定计算':
|
|
474
|
+ #读取有用的数据,按格式录入
|
|
475
|
+ data = GC.get_data_from_excel1(model1)
|
|
476
|
+ cell_values = GC.read_cells_from_excel1(model1)
|
|
477
|
+ ms_station = float(model1[0][12])
|
|
478
|
+ last_station_count = GC.get_last_numeric_cell_value1(model1, 2)
|
|
479
|
+ new_station_count = GC.get_last_numeric_cell_value1(model1, 7)
|
|
480
|
+ last_sum_hdiff = GC.calculate_column_sum1(model1, 4)
|
|
481
|
+ last_sum_rlen = GC.calculate_column_sum1(model1, 5)
|
|
482
|
+ new_sum_hdiff = GC.calculate_column_sum1(model1, 9)
|
|
483
|
+ new_sum_rlen = GC.calculate_column_sum1(model1, 10)
|
|
484
|
+ # 把所有相关的表都删除
|
|
485
|
+ sqlstr1 = """DELETE FROM GC_Input_Point WHERE TableName = ? """
|
|
486
|
+ cursor1.execute(sqlstr1, (tableName_utf8,))
|
|
487
|
+ sqlstr2 = """DELETE FROM GC_Input_Param WHERE TableName = ? """
|
|
488
|
+ cursor1.execute(sqlstr2, (tableName_utf8,))
|
|
489
|
+
|
|
490
|
+ # 先把结果相关的点和参数删一下
|
|
491
|
+ sqlstr3 = """DELETE FROM GC_Output_Point WHERE TableName = ?"""
|
|
492
|
+ cursor1.execute(sqlstr3, (tableName_utf8,))
|
|
493
|
+ # 提交事务
|
|
494
|
+ db1.commit()
|
|
495
|
+ # 关闭db
|
|
496
|
+ db1.close()
|
|
497
|
+ # 直接使用计算方式
|
|
498
|
+ tableName = tableName_utf8.decode('utf-8')
|
|
499
|
+ # 重新更新数据库
|
|
500
|
+ GC.insert_into_database(tableName, cell_values, ms_station, last_station_count, new_station_count,
|
|
501
|
+ last_sum_hdiff,
|
|
502
|
+ new_sum_hdiff, last_sum_rlen, new_sum_rlen, dbPath, tableName_utf8)
|
|
503
|
+ GC.insert_data_into_database(data, tableName, cell_values, dbPath, tableName_utf8)
|
|
504
|
+ GCcompute.main_function(tableName, dbPath)
|
|
505
|
+ GCshow.main_function(self.ui, dbPath, tableName_utf8)
|
|
506
|
+ elif methodName == '控制网复测平面基准计算':
|
|
507
|
+ #读取模型
|
|
508
|
+ ii = 0
|
|
509
|
+ pastname = model1[0][6]
|
|
510
|
+ newname = model1[0][7]
|
|
511
|
+ pjbc = float(model1[0][8])
|
|
512
|
+ fxzwc = float(model1[0][9])
|
|
513
|
+ zrbzwc = float(model1[0][10])
|
|
514
|
+ points = len(model1)
|
|
515
|
+ zbs = float(model1[0][11])
|
|
516
|
+ zfxs = float(model1[0][12])
|
|
517
|
+ sf = float(model1[0][13])
|
|
518
|
+ pjbcs = zbs / points
|
|
519
|
+ pjfxs = zfxs / points
|
|
520
|
+ listname1 = []
|
|
521
|
+ listpastx1 = []
|
|
522
|
+ listpasty1 = []
|
|
523
|
+ listcgcs1 = []
|
|
524
|
+ listnewx1 = []
|
|
525
|
+ listnewy1 = []
|
|
526
|
+ while ii < len(model1):
|
|
527
|
+ if model1[ii][0] == '' or model1[ii][0] == None:
|
|
528
|
+ ii = ii + 1
|
|
529
|
+ else:
|
|
530
|
+ listname1.append(model1[ii][0])
|
|
531
|
+ listpastx1.append(model1[ii][1])
|
|
532
|
+ listpasty1.append(model1[ii][2])
|
|
533
|
+ listnewx1.append(model1[ii][3])
|
|
534
|
+ listnewy1.append(model1[ii][4])
|
|
535
|
+ listcgcs1.append(model1[ii][5])
|
|
536
|
+ ii = ii + 1
|
|
537
|
+
|
|
538
|
+ #把所有相关的表都删除
|
|
539
|
+ sqlstr1 = """DELETE FROM GS_Input_Point WHERE TableName = ? """
|
|
540
|
+ cursor1.execute(sqlstr1, (tableName_utf8, ))
|
|
541
|
+ sqlstr2 = """DELETE FROM GS_Input_Param WHERE TableName = ? """
|
|
542
|
+ cursor1.execute(sqlstr2, (tableName_utf8,))
|
|
543
|
+
|
|
544
|
+ # 先把结果相关的点和参数删一下
|
|
545
|
+ sqlstr3 = """DELETE FROM GS_Result_Point WHERE TableName = ?"""
|
|
546
|
+ cursor1.execute(sqlstr3, (tableName_utf8,))
|
|
547
|
+ sqlstr4 = """DELETE FROM GS_Trans_Point WHERE TableName = ?"""
|
|
548
|
+ cursor1.execute(sqlstr4, (tableName_utf8,))
|
|
549
|
+ sqlstr5 = """DELETE FROM GS_Trans_Param WHERE TableName = ?"""
|
|
550
|
+ cursor1.execute(sqlstr5, (tableName_utf8,))
|
|
551
|
+ # 提交事务
|
|
552
|
+ db1.commit()
|
|
553
|
+ # 关闭db
|
|
554
|
+ db1.close()
|
|
555
|
+ # 直接使用计算方式
|
|
556
|
+ tableName = tableName_utf8.decode('utf-8')
|
|
557
|
+ #重新更新数据库
|
|
558
|
+ GS.insert_into_database(dbPath, pastname, newname, tableName, listname1, listpastx1, listpasty1, listcgcs1, listnewx1,
|
|
559
|
+ listnewy1, pjbc, fxzwc, zrbzwc, points, zbs, zfxs, sf, pjbcs, pjfxs)
|
|
560
|
+ GScompute.main_function(tableName, dbPath)
|
|
561
|
+ GSshow.main_function(self.ui, dbPath, tableName_utf8)
|
|
562
|
+ else:
|
|
563
|
+ # 读取模型
|
|
564
|
+ ii = 0
|
|
565
|
+ bename = model1[0][8]
|
|
566
|
+ pastname = model1[0][9]
|
|
567
|
+ newname = model1[0][10]
|
|
568
|
+ pjbc = float(model1[0][11])
|
|
569
|
+ fxzwc = float(model1[0][12])
|
|
570
|
+ points = len(model1)
|
|
571
|
+ zbs = float(model1[0][13])
|
|
572
|
+ zfxs = float(model1[0][14])
|
|
573
|
+ sf = float(model1[0][15])
|
|
574
|
+ pjbcs = zbs / points
|
|
575
|
+ pjfxs = zfxs / points
|
|
576
|
+ listbex1 = []
|
|
577
|
+ listbey1 = []
|
|
578
|
+ listname1 = []
|
|
579
|
+ listpastx1 = []
|
|
580
|
+ listpasty1 = []
|
|
581
|
+ listcgcs1 = []
|
|
582
|
+ listnewx1 = []
|
|
583
|
+ listnewy1 = []
|
|
584
|
+ while ii < len(model1):
|
|
585
|
+ if model1[ii][0] == '' or model1[ii][0] == None:
|
|
586
|
+ ii = ii + 1
|
|
587
|
+ else:
|
|
588
|
+ listname1.append(model1[ii][0])
|
|
589
|
+ listbex1.append(model1[ii][1])
|
|
590
|
+ listbey1.append(model1[ii][2])
|
|
591
|
+ listpastx1.append(model1[ii][3])
|
|
592
|
+ listpasty1.append(model1[ii][4])
|
|
593
|
+ listcgcs1.append(model1[ii][5])
|
|
594
|
+ listnewx1.append(model1[ii][6])
|
|
595
|
+ listnewy1.append(model1[ii][7])
|
|
596
|
+ ii = ii + 1
|
|
597
|
+ # 平面控制网稳定性计算
|
|
598
|
+ sqlstr1 = """DELETE FROM WD_Input_Point WHERE TableName = ?"""
|
|
599
|
+ cursor1.execute(sqlstr1, (tableName_utf8, ))
|
|
600
|
+ sqlstr2 = """DELETE FROM WD_Input_Param WHERE TableName = ?"""
|
|
601
|
+ cursor1.execute(sqlstr2, (tableName_utf8,))
|
|
602
|
+
|
|
603
|
+ # 先把结果相关的点和参数删一下
|
|
604
|
+ sqlstr3 = """DELETE FROM WD_Result_Point WHERE TableName = ?"""
|
|
605
|
+ cursor1.execute(sqlstr3, (tableName_utf8,))
|
|
606
|
+ sqlstr4 = """DELETE FROM WD_Result_Param WHERE TableName = ?"""
|
|
607
|
+ cursor1.execute(sqlstr4, (tableName_utf8,))
|
|
608
|
+ # 提交事务
|
|
609
|
+ db1.commit()
|
|
610
|
+ # 关闭db
|
|
611
|
+ db1.close()
|
|
612
|
+ # 直接使用计算方式
|
|
613
|
+ tableName = tableName_utf8.decode('utf-8')
|
|
614
|
+ WD.insert_into_database(dbPath, pastname, newname, bename, tableName, listname1, listpastx1, listpasty1,
|
|
615
|
+ listcgcs1, pjbc, fxzwc, points, zbs, zfxs, sf, pjbcs, pjfxs, listbex1, listbey1,
|
|
616
|
+ listnewx1, listnewy1)
|
|
617
|
+ WDcompute.main_function(tableName, dbPath)
|
|
618
|
+ WDshow.main_function(self.ui, dbPath, tableName_utf8)
|
466
|
619
|
# END - GUI DEFINITIONS
|