新增 新增目标关系 功能(录入前序关系)
This commit is contained in:
parent
dfff9f6828
commit
a7941d69c8
|
|
@ -142,6 +142,9 @@ class Ui_MainWindow(object):
|
||||||
self.tab_xgmb = QWidget()
|
self.tab_xgmb = QWidget()
|
||||||
self.tab_xgmb.setObjectName(u"tab_xgmb")
|
self.tab_xgmb.setObjectName(u"tab_xgmb")
|
||||||
self.tabWidget_mubiaojichu.addTab(self.tab_xgmb, "")
|
self.tabWidget_mubiaojichu.addTab(self.tab_xgmb, "")
|
||||||
|
self.tab_xzgx = QWidget()
|
||||||
|
self.tab_xzgx.setObjectName(u"tab_xzgx")
|
||||||
|
self.tabWidget_mubiaojichu.addTab(self.tab_xzgx, "")
|
||||||
self.tab_scgx = QWidget()
|
self.tab_scgx = QWidget()
|
||||||
self.tab_scgx.setObjectName(u"tab_scgx")
|
self.tab_scgx.setObjectName(u"tab_scgx")
|
||||||
self.tabWidget_mubiaojichu.addTab(self.tab_scgx, "")
|
self.tabWidget_mubiaojichu.addTab(self.tab_scgx, "")
|
||||||
|
|
@ -199,14 +202,14 @@ class Ui_MainWindow(object):
|
||||||
|
|
||||||
self.retranslateUi(MainWindow)
|
self.retranslateUi(MainWindow)
|
||||||
|
|
||||||
self.tabWidget_main.setCurrentIndex(5)
|
self.tabWidget_main.setCurrentIndex(0)
|
||||||
self.tabWidget_luru.setCurrentIndex(2)
|
self.tabWidget_luru.setCurrentIndex(0)
|
||||||
self.tabWidget_weihu.setCurrentIndex(3)
|
self.tabWidget_weihu.setCurrentIndex(0)
|
||||||
self.tabWidget_shiyong.setCurrentIndex(1)
|
self.tabWidget_shiyong.setCurrentIndex(0)
|
||||||
self.tabWidget_beikezu.setCurrentIndex(2)
|
self.tabWidget_beikezu.setCurrentIndex(0)
|
||||||
self.tabWidget_latex.setCurrentIndex(1)
|
self.tabWidget_latex.setCurrentIndex(0)
|
||||||
self.tabWidget_mubiaojichu.setCurrentIndex(3)
|
self.tabWidget_mubiaojichu.setCurrentIndex(0)
|
||||||
self.tabWidget_syjl.setCurrentIndex(5)
|
self.tabWidget_syjl.setCurrentIndex(0)
|
||||||
|
|
||||||
|
|
||||||
QMetaObject.connectSlotsByName(MainWindow)
|
QMetaObject.connectSlotsByName(MainWindow)
|
||||||
|
|
@ -239,6 +242,7 @@ class Ui_MainWindow(object):
|
||||||
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_tjjc), QCoreApplication.translate("MainWindow", u"\u65b0\u589e\u57fa\u7840", None))
|
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_tjjc), QCoreApplication.translate("MainWindow", u"\u65b0\u589e\u57fa\u7840", None))
|
||||||
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_bjjc), QCoreApplication.translate("MainWindow", u"\u57fa\u7840\u7f16\u8f91", None))
|
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_bjjc), QCoreApplication.translate("MainWindow", u"\u57fa\u7840\u7f16\u8f91", None))
|
||||||
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_xgmb), QCoreApplication.translate("MainWindow", u"\u4fee\u6539\u76ee\u6807", None))
|
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_xgmb), QCoreApplication.translate("MainWindow", u"\u4fee\u6539\u76ee\u6807", None))
|
||||||
|
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_xzgx), QCoreApplication.translate("MainWindow", u"\u65b0\u589e\u76ee\u6807\u5173\u7cfb", None))
|
||||||
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_scgx), QCoreApplication.translate("MainWindow", u"\u5220\u9664\u76ee\u6807\u5173\u7cfb", None))
|
self.tabWidget_mubiaojichu.setTabText(self.tabWidget_mubiaojichu.indexOf(self.tab_scgx), QCoreApplication.translate("MainWindow", u"\u5220\u9664\u76ee\u6807\u5173\u7cfb", None))
|
||||||
self.tabWidget_main.setTabText(self.tabWidget_main.indexOf(self.tab_mubiaojichu), QCoreApplication.translate("MainWindow", u"\u76ee\u6807\u4e0e\u57fa\u7840\u77e5\u8bc6", None))
|
self.tabWidget_main.setTabText(self.tabWidget_main.indexOf(self.tab_mubiaojichu), QCoreApplication.translate("MainWindow", u"\u76ee\u6807\u4e0e\u57fa\u7840\u77e5\u8bc6", None))
|
||||||
self.tabWidget_syjl.setTabText(self.tabWidget_syjl.indexOf(self.tab_xxdr), QCoreApplication.translate("MainWindow", u"\u5c0f\u95f2\u5bfc\u5165", None))
|
self.tabWidget_syjl.setTabText(self.tabWidget_syjl.indexOf(self.tab_xxdr), QCoreApplication.translate("MainWindow", u"\u5c0f\u95f2\u5bfc\u5165", None))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## Form generated from reading UI file '新增目标关系.ui'
|
||||||
|
##
|
||||||
|
## Created by: Qt User Interface Compiler version 6.6.2
|
||||||
|
##
|
||||||
|
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||||
|
QMetaObject, QObject, QPoint, QRect,
|
||||||
|
QSize, QTime, QUrl, Qt)
|
||||||
|
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||||
|
QFont, QFontDatabase, QGradient, QIcon,
|
||||||
|
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||||
|
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||||
|
from PySide6.QtWidgets import (QApplication, QLabel, QPlainTextEdit, QPushButton,
|
||||||
|
QSizePolicy, QTextBrowser, QWidget)
|
||||||
|
|
||||||
|
class Ui_Form(object):
|
||||||
|
def setupUi(self, Form):
|
||||||
|
if not Form.objectName():
|
||||||
|
Form.setObjectName(u"Form")
|
||||||
|
Form.resize(760, 490)
|
||||||
|
self.label = QLabel(Form)
|
||||||
|
self.label.setObjectName(u"label")
|
||||||
|
self.label.setGeometry(QRect(20, 20, 121, 16))
|
||||||
|
self.plainTextEdit_data = QPlainTextEdit(Form)
|
||||||
|
self.plainTextEdit_data.setObjectName(u"plainTextEdit_data")
|
||||||
|
self.plainTextEdit_data.setGeometry(QRect(20, 40, 351, 421))
|
||||||
|
self.label_2 = QLabel(Form)
|
||||||
|
self.label_2.setObjectName(u"label_2")
|
||||||
|
self.label_2.setGeometry(QRect(390, 20, 54, 16))
|
||||||
|
self.textBrowser = QTextBrowser(Form)
|
||||||
|
self.textBrowser.setObjectName(u"textBrowser")
|
||||||
|
self.textBrowser.setGeometry(QRect(390, 40, 351, 141))
|
||||||
|
self.pushButton_checkvalidity = QPushButton(Form)
|
||||||
|
self.pushButton_checkvalidity.setObjectName(u"pushButton_checkvalidity")
|
||||||
|
self.pushButton_checkvalidity.setGeometry(QRect(670, 190, 71, 51))
|
||||||
|
self.pushButton_import = QPushButton(Form)
|
||||||
|
self.pushButton_import.setObjectName(u"pushButton_import")
|
||||||
|
self.pushButton_import.setGeometry(QRect(670, 250, 71, 51))
|
||||||
|
self.pushButton_commit = QPushButton(Form)
|
||||||
|
self.pushButton_commit.setObjectName(u"pushButton_commit")
|
||||||
|
self.pushButton_commit.setGeometry(QRect(670, 310, 71, 151))
|
||||||
|
font = QFont()
|
||||||
|
font.setBold(True)
|
||||||
|
self.pushButton_commit.setFont(font)
|
||||||
|
self.pushButton_commit.setStyleSheet(u"background-color: rgb(255, 255, 127);")
|
||||||
|
self.label_3 = QLabel(Form)
|
||||||
|
self.label_3.setObjectName(u"label_3")
|
||||||
|
self.label_3.setGeometry(QRect(390, 190, 101, 16))
|
||||||
|
self.plainTextEdit_validity = QPlainTextEdit(Form)
|
||||||
|
self.plainTextEdit_validity.setObjectName(u"plainTextEdit_validity")
|
||||||
|
self.plainTextEdit_validity.setGeometry(QRect(390, 210, 271, 251))
|
||||||
|
self.plainTextEdit_validity.setReadOnly(True)
|
||||||
|
|
||||||
|
self.retranslateUi(Form)
|
||||||
|
|
||||||
|
QMetaObject.connectSlotsByName(Form)
|
||||||
|
# setupUi
|
||||||
|
|
||||||
|
def retranslateUi(self, Form):
|
||||||
|
Form.setWindowTitle(QCoreApplication.translate("Form", u"\u65b0\u589e\u76ee\u6807\u5173\u7cfb", None))
|
||||||
|
self.label.setText(QCoreApplication.translate("Form", u"\u524d\u7f6e\u76ee\u6807\u5173\u7cfb\u6570\u636e", None))
|
||||||
|
self.label_2.setText(QCoreApplication.translate("Form", u"\u8bf4\u660e", None))
|
||||||
|
self.textBrowser.setHtml(QCoreApplication.translate("Form", u"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||||
|
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||||
|
"p, li { white-space: pre-wrap; }\n"
|
||||||
|
"hr { height: 1px; border-width: 0; }\n"
|
||||||
|
"li.unchecked::marker { content: \"\\2610\"; }\n"
|
||||||
|
"li.checked::marker { content: \"\\2612\"; }\n"
|
||||||
|
"</style></head><body style=\" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
|
||||||
|
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">\u5148\u5728"\u524d\u7f6e\u76ee\u6807\u5173\u7cfb\u6570\u636e"\u4e2d\u7c98\u8d34\u76ee\u6807\u4ee3\u7801\u4e4b\u95f4\u7684\u5bf9\u5e94\u5173\u7cfb, \u89c4\u5219\u5982\u4e0b:</p>\n"
|
||||||
|
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">1. \u6bcf\u4e00\u884c\u4ee3\u8868\u4e00\u4e2a\u76ee\u6807\u4e0e\u5176\u524d\u7f6e"
|
||||||
|
"\u76ee\u6807\u7684\u5bf9\u5e94\u5173\u7cfb.</p>\n"
|
||||||
|
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">2. \u6bcf\u4e00\u884c\u7684\u7b2c\u4e00\u4e2a\u7f16\u53f7\u662f\u539f\u59cb\u76ee\u6807\u7684\u7f16\u53f7, \u540e\u7eed\u7684\u7f16\u53f7\u662f\u539f\u59cb\u76ee\u6807\u7684\u524d\u7f6e\u76ee\u6807\u7684\u7f16\u53f7.</p>\n"
|
||||||
|
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">3. \u6bcf\u4e00\u884c\u4e0d\u540c\u7684\u7f16\u53f7\u4e4b\u95f4\u7528"\\t"\u9694\u5f00(Excel\u590d\u5236\u51fa\u6765\u4e4b\u540e\u5c31\u662f\u7528"\\t"\u4f5c\u4e3a\u5206\u9694\u7684)</p></body></html>", None))
|
||||||
|
self.pushButton_checkvalidity.setText(QCoreApplication.translate("Form", u"\u68c0\u67e5\u6709\u6548\u6027", None))
|
||||||
|
self.pushButton_import.setText(QCoreApplication.translate("Form", u"\u9884\u5bfc\u5165", None))
|
||||||
|
self.pushButton_commit.setText(QCoreApplication.translate("Form", u"\u5bfc\u5165\n"
|
||||||
|
"(\u4e0d\u53ef\u9006)", None))
|
||||||
|
self.label_3.setText(QCoreApplication.translate("Form", u"\u6709\u6548\u6027\u68c0\u67e5\u7ed3\u679c", None))
|
||||||
|
# retranslateUi
|
||||||
|
|
||||||
|
|
@ -28,6 +28,7 @@ from 基础知识编辑 import MyWindow_bjjc
|
||||||
from 修改目标内容 import MyWindow_xgmb
|
from 修改目标内容 import MyWindow_xgmb
|
||||||
from 删除使用记录 import MyWindow_scjl
|
from 删除使用记录 import MyWindow_scjl
|
||||||
from 删除课时目标关系 import MyWindow_scgx
|
from 删除课时目标关系 import MyWindow_scgx
|
||||||
|
from 新增目标关系 import MyWindow_xzgx
|
||||||
from database_tools_2 import *
|
from database_tools_2 import *
|
||||||
|
|
||||||
class MyWindow(QMainWindow,Ui_MainWindow):
|
class MyWindow(QMainWindow,Ui_MainWindow):
|
||||||
|
|
@ -152,6 +153,10 @@ class MyWindow(QMainWindow,Ui_MainWindow):
|
||||||
self.scgx = MyWindow_scgx(self.database)
|
self.scgx = MyWindow_scgx(self.database)
|
||||||
self.layout_scgx.addWidget(self.scgx) #以上三行为初始化"删除课时目标关系"tab
|
self.layout_scgx.addWidget(self.scgx) #以上三行为初始化"删除课时目标关系"tab
|
||||||
|
|
||||||
|
self.layout_xzgx = QVBoxLayout(self.tab_xzgx)
|
||||||
|
self.xzgx = MyWindow_xzgx(self.database)
|
||||||
|
self.layout_xzgx.addWidget(self.xzgx) #以上三行为初始化"新增课时目标关系"tab
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for func in [
|
for func in [
|
||||||
|
|
@ -172,7 +177,8 @@ class MyWindow(QMainWindow,Ui_MainWindow):
|
||||||
self.wbzh.setdbname,
|
self.wbzh.setdbname,
|
||||||
self.xgmb.setdbname,
|
self.xgmb.setdbname,
|
||||||
self.scjl.setdbname,
|
self.scjl.setdbname,
|
||||||
self.scgx.setdbname
|
self.scgx.setdbname,
|
||||||
|
self.xzgx.setdbname
|
||||||
]: #在列表中的tab里传送数据库名的连接
|
]: #在列表中的tab里传送数据库名的连接
|
||||||
self.sendDBname.connect(func)
|
self.sendDBname.connect(func)
|
||||||
def sendValue(self):
|
def sendValue(self):
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
<enum>QTabWidget::Triangular</enum>
|
<enum>QTabWidget::Triangular</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>5</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_luru">
|
<widget class="QWidget" name="tab_luru">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
<enum>QTabWidget::Triangular</enum>
|
<enum>QTabWidget::Triangular</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_kxth">
|
<widget class="QWidget" name="tab_kxth">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
@ -94,7 +94,7 @@
|
||||||
<enum>QTabWidget::Triangular</enum>
|
<enum>QTabWidget::Triangular</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_tjzd">
|
<widget class="QWidget" name="tab_tjzd">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
@ -138,7 +138,7 @@
|
||||||
<enum>QTabWidget::Triangular</enum>
|
<enum>QTabWidget::Triangular</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_sxth">
|
<widget class="QWidget" name="tab_sxth">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
@ -187,7 +187,7 @@
|
||||||
<enum>QTabWidget::Triangular</enum>
|
<enum>QTabWidget::Triangular</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_jglr">
|
<widget class="QWidget" name="tab_jglr">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
@ -226,7 +226,7 @@
|
||||||
<enum>QTabWidget::Triangular</enum>
|
<enum>QTabWidget::Triangular</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_wbzh">
|
<widget class="QWidget" name="tab_wbzh">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
@ -260,7 +260,7 @@
|
||||||
<enum>QTabWidget::Triangular</enum>
|
<enum>QTabWidget::Triangular</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>3</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_tjjc">
|
<widget class="QWidget" name="tab_tjjc">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
@ -277,6 +277,11 @@
|
||||||
<string>修改目标</string>
|
<string>修改目标</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_xzgx">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>新增目标关系</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="tab_scgx">
|
<widget class="QWidget" name="tab_scgx">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>删除目标关系</string>
|
<string>删除目标关系</string>
|
||||||
|
|
@ -304,7 +309,7 @@
|
||||||
<enum>QTabWidget::Triangular</enum>
|
<enum>QTabWidget::Triangular</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>5</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_xxdr">
|
<widget class="QWidget" name="tab_xxdr">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
from PySide6.QtWidgets import QWidget, QApplication, QFileDialog, QTableWidgetItem
|
||||||
|
from Ui_新增目标关系 import Ui_Form
|
||||||
|
from database_tools_2 import *
|
||||||
|
|
||||||
|
class MyWindow_xzgx(QWidget,Ui_Form):
|
||||||
|
def __init__(self,database_name):
|
||||||
|
super().__init__()
|
||||||
|
self.database_name = database_name
|
||||||
|
self.current_database_name = database_name
|
||||||
|
self.setupUi(self)
|
||||||
|
self.bind()
|
||||||
|
def setdbname(self,string):
|
||||||
|
self.database_name = string
|
||||||
|
self.pushButton_import.setDisabled(True)
|
||||||
|
self.pushButton_commit.setDisabled(True)
|
||||||
|
try:
|
||||||
|
self.db.close()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
self.db = connect(hostname=db_host, port=db_port, username= db_user, pwd= db_pwd, db=self.database_name)
|
||||||
|
# print(self.database_name)
|
||||||
|
def bind(self):
|
||||||
|
self.pushButton_import.setDisabled(True)
|
||||||
|
self.pushButton_commit.setDisabled(True)
|
||||||
|
self.pushButton_checkvalidity.clicked.connect(self.checkvalidity)
|
||||||
|
self.pushButton_import.clicked.connect(self.importdata)
|
||||||
|
self.pushButton_commit.clicked.connect(self.commit)
|
||||||
|
self.plainTextEdit_data.textChanged.connect(self.disable_import)
|
||||||
|
self.db = connect(hostname=db_host, port=db_port, username= db_user, pwd= db_pwd, db=self.database_name)
|
||||||
|
self.mycursor = self.db.cursor()
|
||||||
|
self.mycursor.execute("SELECT objid from lessonobj;")
|
||||||
|
self.objids = [item[0] for item in self.mycursor.fetchall()]
|
||||||
|
# print(self.objids)
|
||||||
|
|
||||||
|
def checkvalidity(self):
|
||||||
|
self.data_raw = self.plainTextEdit_data.toPlainText().strip()
|
||||||
|
self.data = re.sub(r"[ \t]+","\t",self.data_raw)
|
||||||
|
self.datalines = [line.strip() for line in self.data.split("\n") if not line.strip() == ""]
|
||||||
|
output = f"一共有 {len(self.datalines)} 行数据.\n"
|
||||||
|
self.valid_lines = []
|
||||||
|
validstatus = True
|
||||||
|
for line in self.datalines:
|
||||||
|
linevalidflag = True
|
||||||
|
objids = line.split("\t")
|
||||||
|
mainid = objids.pop(0)
|
||||||
|
if not mainid in self.objids:
|
||||||
|
linevalidflag = False
|
||||||
|
for objid in objids:
|
||||||
|
if not objid in self.objids:
|
||||||
|
linevalidflag = False
|
||||||
|
break
|
||||||
|
if linevalidflag == False:
|
||||||
|
output += f"首个id为 {mainid} 的行数据有误\n"
|
||||||
|
validstatus = False
|
||||||
|
else:
|
||||||
|
self.valid_lines.append((mainid,objids))
|
||||||
|
if validstatus == True:
|
||||||
|
output += "数据全部为有效数据"
|
||||||
|
self.pushButton_import.setEnabled(True)
|
||||||
|
# print(self.valid_lines)
|
||||||
|
self.plainTextEdit_validity.setPlainText(output)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def disable_import(self):
|
||||||
|
self.pushButton_import.setDisabled(True)
|
||||||
|
def importdata(self):
|
||||||
|
self.mycursor = self.db.cursor()
|
||||||
|
output = "导入记录:\n"
|
||||||
|
for line in tqdm.tqdm(self.valid_lines):
|
||||||
|
mainid = line[0]
|
||||||
|
for precid in line[1]:
|
||||||
|
self.mycursor.execute("SELECT * FROM objinherit WHERE objid = %s AND inherit_from = %s;",(mainid,precid))
|
||||||
|
ret_list = self.mycursor.fetchall()
|
||||||
|
if len(ret_list) >= 1:
|
||||||
|
output += f"*** {mainid} 以 {precid} 为前序的记录已在数据库 {self.database_name} 中\n"
|
||||||
|
else:
|
||||||
|
output += f"--- {mainid} 与 {precid} 的前序关系已被记录\n"
|
||||||
|
sql1 = "INSERT INTO objinherit (objid,inherit_from) VALUE (%s,%s);"
|
||||||
|
val1 = (mainid,precid)
|
||||||
|
self.mycursor.execute(sql1,val1)
|
||||||
|
sql2 = "INSERT INTO logs (DATE,TIME,username,action,db_content) VALUE (%s,%s,%s,%s,%s);"
|
||||||
|
val2 = (GetDate(),GetTime(),get_git_username(),"新增目标前序",f"{mainid} <- {precid}")
|
||||||
|
self.mycursor.execute(sql2,val2)
|
||||||
|
self.plainTextEdit_validity.setPlainText(output)
|
||||||
|
self.pushButton_commit.setEnabled(True)
|
||||||
|
def commit(self):
|
||||||
|
self.db.commit()
|
||||||
|
self.pushButton_import.setDisabled(True)
|
||||||
|
self.pushButton_commit.setDisabled(True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app = QApplication([])
|
||||||
|
windows = MyWindow_xzgx("tikutest")
|
||||||
|
windows.show()
|
||||||
|
app.exec()
|
||||||
|
|
||||||
|
|
@ -0,0 +1,152 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>760</width>
|
||||||
|
<height>490</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>新增目标关系</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>121</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>前置目标关系数据</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPlainTextEdit" name="plainTextEdit_data">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>351</width>
|
||||||
|
<height>421</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>390</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>54</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>说明</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTextBrowser" name="textBrowser">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>390</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>351</width>
|
||||||
|
<height>141</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="html">
|
||||||
|
<string><!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;">先在&quot;前置目标关系数据&quot;中粘贴目标代码之间的对应关系, 规则如下:</p>
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">1. 每一行代表一个目标与其前置目标的对应关系.</p>
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">2. 每一行的第一个编号是原始目标的编号, 后续的编号是原始目标的前置目标的编号.</p>
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">3. 每一行不同的编号之间用&quot;\t&quot;隔开(Excel复制出来之后就是用&quot;\t&quot;作为分隔的)</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="pushButton_checkvalidity">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>670</x>
|
||||||
|
<y>190</y>
|
||||||
|
<width>71</width>
|
||||||
|
<height>51</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>检查有效性</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="pushButton_import">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>670</x>
|
||||||
|
<y>250</y>
|
||||||
|
<width>71</width>
|
||||||
|
<height>51</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>预导入</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="pushButton_commit">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>670</x>
|
||||||
|
<y>310</y>
|
||||||
|
<width>71</width>
|
||||||
|
<height>151</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(255, 255, 127);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>导入
|
||||||
|
(不可逆)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>390</x>
|
||||||
|
<y>190</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>16</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>有效性检查结果</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPlainTextEdit" name="plainTextEdit_validity">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>390</x>
|
||||||
|
<y>210</y>
|
||||||
|
<width>271</width>
|
||||||
|
<height>251</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue