123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- import sqlite3
-
- from PySide6.QtGui import QStandardItemModel
- from Back.Program_Run.data_show import *
-
-
- def main_function(ui, db_path, utf_en):
- # 就用已有的选项卡
- ui.tabWidget.setTabVisible(0, True)
- ui.tabWidget.setTabVisible(1, True)
- ui.tabWidget.setTabVisible(2, True)
- # 重新设置文字名称
- ui.tabWidget.setTabText(0, '复测成果表')
- ui.tabWidget.setTabText(1, '基准归算模型')
- ui.tabWidget.setTabText(2, '复测基准归算表')
-
- # 连接到数据库
- db1 = sqlite3.connect(db_path)
- db1.text_factory = lambda x: str(x, 'utf-8')
- cursor1 = db1.cursor()
- # 隐藏 QLabel
- ui.default_remind.hide()
-
- # 查询表内符合的所有数据(分成两个结果分别显示)
- # 注意查询中的tablename,数据库中如果没有相同的表名,会报错,所以需要先判断一下
- # 复测成果表
- sqlstr1 = 'select PointName,Last_X,Last_Y,Result_X,Result_Y,Last_ResultX,Last_ResultY,Last_ResultP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
- cursor1.execute(sqlstr1, (utf_en,))
- result1 = cursor1.fetchall()
-
- # 基准归算表
- sqlstr11 = 'select PointName,Cal_X,Cal_Y,Last_CalX,Last_CalY,Last_CalP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
- cursor1.execute(sqlstr11, (utf_en,))
- result2 = cursor1.fetchall()
-
- # 对结果集进行处理,把汉字转换过来, 添加表头部分
- nlist1, plist1 = Arrange_Data1(result1)
- nlist2, plist2 = Arrange_Data2(result2)
-
- model1 = Data_in_Cell1(plist1)
- model1.setHorizontalHeaderLabels(
- ['点名', '前期X', '前期Y', '本期X', '本期Y', '前期-本期X', '前期-本期Y', '前期-本期P', '位移判定'])
- model1.setVerticalHeaderLabels(nlist1)
-
- # 展示表格
- ui.resultTableView.setModel(model1)
- ui.resultTableView.show()
- # 隐藏 QLabel
- ui.default_remind.hide()
-
- model2 = Data_in_Cell2(plist2)
- model2.setHorizontalHeaderLabels(
- ['点名', '基准归算X', '基准归算Y', '前期-归算X', '前期-归算Y', '前期-归算P', '位移判定'])
- model2.setVerticalHeaderLabels(nlist2)
-
- # 展示表格
- ui.reconTableView.setModel(model2)
- ui.reconTableView.show()
-
- # 富文本的html
- sqlstr2 = 'select Last_ResultName, New_ResultName, Formula_X1, Formula_X2, Formula_X3, Formula_Y1, Formula_Y2, Formula_Y3 from GS_Trans_Param WHERE TableName = ?'
- cursor1.execute(sqlstr2, (utf_en,))
- result3 = cursor1.fetchone()
- # 检查 result3 是否为 None
- if result3 is None:
- str0 = "<p>未找到相关数据。</p>"
- else:
- str1 = result3[0].decode('utf-8') if isinstance(result3[0], bytes) else result3[0]
- str2 = result3[1].decode('utf-8') if isinstance(result3[1], bytes) else result3[1]
- n1, n2, n3, n4, n5, n6 = result3[2], result3[3], result3[4], result3[5], result3[6], result3[7]
-
- str0 = f"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
- <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
- p, li {{ white-space: pre-wrap; }}
- hr {{ height: 1px; border-width: 0; }}
- li.unchecked::marker {{ content: "\\2610"; }}
- li.checked::marker {{ content: "\\2612"; }}
- </style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
- <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>
- <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;">=({n1})</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+({n2})</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+({n3})</span></p>
- <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;">=({n4})</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+({n5})</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+({n6})</span></p>
- <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;">为{str2}坐标;</span></p>
- <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>"""
-
- ui.printTableView.setHtml(str0)
-
-
- def search_show_function(ui, db_path, utf_en):
- # 就用已有的选项卡
- ui.View.setTabVisible(0, True)
- ui.View.setTabVisible(1, True)
- ui.View.setTabVisible(2, True)
- ui.View.setTabVisible(3, True)
- # 重新设置文字名称
- ui.View.setTabText(0, '输入数据')
- ui.View.setTabText(1, '复测基准归算表')
- ui.View.setTabText(2, '基准归算模型')
- ui.View.setTabText(3, '复测成果表')
-
- # 连接到数据库
- db1 = sqlite3.connect(db_path)
- db1.text_factory = lambda x: str(x, 'utf-8')
- cursor1 = db1.cursor()
-
- # 输入数据
- sqlstr00 = 'select PointName,Last_X,Last_Y,New_X,New_Y,cgcs from GS_Input_Point WHERE TableName = ?'
- sqlstr10 = 'select Last_ResultName,New_ResultName,Avg_SL,Ms_Dir,Ms_WSL,SL_Count,Dir_Count,Scale_Value from GS_Input_Param WHERE TableName = ?'
- cursor1.execute(sqlstr00, (utf_en,))
- result00 = cursor1.fetchall()
- cursor1.execute(sqlstr10, (utf_en,))
- result10 = cursor1.fetchall()
- model0, nlist0 = GS_In_Data(result00, result10[0])
- model0.setHorizontalHeaderLabels(
- ['点名', '前期X', '前期Y', '本期X', '本期Y', '成果次数', '上期成果名', '本期成果名', '平均边长', '方向值中误差',
- '最弱边边长相对中误差', '总测边数', '总方向观测数', '缩放值'])
- model0.setVerticalHeaderLabels(nlist0)
- # 展示表格
- ui.resultTableView1.setModel(model0)
- ui.resultTableView1.show()
- # 隐藏 QLabel
- ui.default_remind1.hide()
-
- # 查询表内符合的所有数据(分成两个结果分别显示)
- # 注意查询中的tablename,数据库中如果没有相同的表名,会报错,所以需要先判断一下
- # 复测成果表
- sqlstr1 = 'select PointName,Last_X,Last_Y,Result_X,Result_Y,Last_ResultX,Last_ResultY,Last_ResultP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
- cursor1.execute(sqlstr1, (utf_en,))
- result1 = cursor1.fetchall()
-
- # 基准归算表
- sqlstr11 = 'select PointName,Cal_X,Cal_Y,Last_CalX,Last_CalY,Last_CalP,Dis_Ass from GS_Result_Point WHERE TableName = ?'
- cursor1.execute(sqlstr11, (utf_en,))
- result2 = cursor1.fetchall()
-
- # 对结果集进行处理,把汉字转换过来, 添加表头部分
- nlist1, plist1 = Arrange_Data1(result1)
- nlist2, plist2 = Arrange_Data2(result2)
-
- model1 = Data_in_Cell1(plist1)
- model1.setHorizontalHeaderLabels(
- ['点名', '前期X', '前期Y', '本期X', '本期Y', '前期-本期X', '前期-本期Y', '前期-本期P', '位移判定'])
- model1.setVerticalHeaderLabels(nlist1)
-
- # 展示表格
- ui.inputTableView1.setModel(model1)
- ui.inputTableView1.show()
- # 隐藏 QLabel
- ui.default_remind1.hide()
-
- model2 = Data_in_Cell2(plist2)
- model2.setHorizontalHeaderLabels(
- ['点名', '基准归算X', '基准归算Y', '前期-归算X', '前期-归算Y', '前期-归算P', '位移判定'])
- model2.setVerticalHeaderLabels(nlist2)
-
- # 展示表格
- ui.reconTableView1.setModel(model2)
- ui.reconTableView1.show()
-
- # 富文本的html
- sqlstr2 = 'select Last_ResultName, New_ResultName, Formula_X1, Formula_X2, Formula_X3, Formula_Y1, Formula_Y2, Formula_Y3 from GS_Trans_Param WHERE TableName = ?'
- cursor1.execute(sqlstr2, (utf_en,))
- result3 = cursor1.fetchone()
- # 检查 result3 是否为 None
- if result3 is None:
- str0 = "<p>未找到相关数据。</p>"
- else:
- str1 = result3[0].decode('utf-8') if isinstance(result3[0], bytes) else result3[0]
- str2 = result3[1].decode('utf-8') if isinstance(result3[1], bytes) else result3[1]
- n1, n2, n3, n4, n5, n6 = result3[2], result3[3], result3[4], result3[5], result3[6], result3[7]
-
- str0 = f"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
- <html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
- p, li {{ white-space: pre-wrap; }}
- hr {{ height: 1px; border-width: 0; }}
- li.unchecked::marker {{ content: "\\2610"; }}
- li.checked::marker {{ content: "\\2612"; }}
- </style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;">
- <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>
- <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;">=({n1})</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+({n2})</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+({n3})</span></p>
- <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;">=({n4})</span><span style=" font-size:14pt; font-weight:700;">x</span><span style=" font-size:14pt;">+({n5})</span><span style=" font-size:14pt; font-weight:700;">y</span><span style=" font-size:14pt;">+({n6})</span></p>
- <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;">为{str2}坐标;</span></p>
- <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>"""
-
- ui.printTableView1.setHtml(str0)
|