资源简介

高速公路绿色通道是为绿色农产品开设的收费口,但是经常有车辆贪图收费优惠,既影响了正常车辆,又浪费了人力,因此本应用将从零开始,搭建一个辅助检测应用。详细搭建步骤请看我的专题从零进行大数据app构建--高速公路大数据辅助检测应用。https://blog.csdn.net/infent/column/info/30927

资源截图

代码片段和文件信息

from PyQt5.QtCore import QThread QDateTime pyqtSignal
from ui import lvtongui calculateui online_rulesloginsqlmode
from startingimage import *
from Sunshinemodel import *


import sys re


# 登录界面
class userlogin(QtWidgets.QWidget login.Ui_Form):
    def __init__(self):
        super(userlogin self).__init__()
        self.setupUi(self)

        # 进行登录校验
        self.login.clicked.connect(self.checkUserInMysql)

    def checkUserInMysql(self):
        employid = self.employid.text()
        password = self.password.text()
        if (employid == ‘‘ or password == ‘‘):
            QtWidgets.QMessageBox.warning(self ‘警告‘ ‘员工号或密码不可为空‘ QtWidgets.QMessageBox.Yes)
            return
        df = userloginQuery(employid)
        # print(employid)
        # print(df[‘password‘].values[0])
        if (len(df) == 0):
            QtWidgets.QMessageBox.information(self ‘提示‘ ‘账号不存在‘)
        else:
            if (df[‘password‘].values[0] == password):
                # print(‘tiaozhuan‘)
                self.user = employid
                self.usergroup = df[‘usergroup‘].values[0]
                lvtong.show()
                self.close()
            else:
                QtWidgets.QMessageBox.information(self ‘提示‘ ‘密码错误‘)
        return
#sqlmode界面
#需求:需要使用多线程和进度条来解决sql查询卡顿的情况
#当数据读取比较少的时候可以直接在init里执行executesql但是数据多了,可以把这部分逻辑
#放在QThread线程中,实现数据显示和数据读取的分离
class sqlThread(QThread):
    sinOut = pyqtSignal(int)
    sinOutFinish = pyqtSignal()
    error = pyqtSignal(str)
    #process = pyqtSignal(int)

    def __init__(selfparent=None):
        super(sqlThreadself).__init__(parent)
        self.tabel = QtWidgets.QTableWidget()
        self.count = 0
    def run(self):
        try:
            sqlmodewidget.execsql.setEnabled(False)
            sql = sqlmodewidget.lineEdit.displayText()
            connect = create_engine(‘mysql+pymysql://root:123456@localhost:3306/lvtong‘)
            self.result = pd.read_sql_query(sql connect)
            #sqlmodewidget.executesql()
            # info = ‘running‘
            # self.sinOut.emit(info)
            print(‘query ending‘)
            #self.sinOut.connect(sqlmodewidget.executesql)

            #sql查询展示部分
            result = self.result
            #这个不是14万了而是乘以维度数了,展开了
            #print(len(result.values.reshape(1 -1)[0]))
            #count = 0
            #tabel = QtWidgets.QTableWidget()

            self.tabel.setRowCount(len(result))
            self.tabel.setColumnCount(len(result.columns))
            self.tabel.setHorizontalHeaderLabels(result.columns)
            #sqlmodewidget.displayresult.addWidget(tabel)
            self.count = self.count + 1
            #self.tabel.horizontalHeader().setSectionresizeMode(QtWidgets.QHeaderView.Stretch)
            #循环也相当耗时,即使分出来界面也卡一下,怎么解决。

            for i j in enumerate(result.values.reshape(1 -1)[0]):
                newItem = QtWidgets.QTableWidgetItem(str(j))

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-12 16:50  lvtongEazyVersion\
     目录           0  2018-12-12 16:50  lvtongEazyVersion\.idea\
     目录           0  2018-12-12 09:31  lvtongEazyVersion\.idea\inspectionProfiles\
     文件         398  2018-12-12 09:31  lvtongEazyVersion\.idea\lvtongEazyVersion.iml
     文件         219  2018-12-12 09:31  lvtongEazyVersion\.idea\misc.xml
     文件         286  2018-12-12 09:14  lvtongEazyVersion\.idea\modules.xml
     文件       29008  2018-12-12 16:50  lvtongEazyVersion\.idea\workspace.xml
     目录           0  2018-12-12 14:18  lvtongEazyVersion\data\
     文件         415  2018-12-05 08:35  lvtongEazyVersion\data\help.txt
     文件        5544  2018-11-15 23:14  lvtongEazyVersion\data\interval_goods_rule2.txt
     文件          80  2018-12-06 02:49  lvtongEazyVersion\data\lvtongversion.txt
     目录           0  2018-12-12 15:42  lvtongEazyVersion\image\
     文件       67646  2018-12-12 15:41  lvtongEazyVersion\image\lvtong.ico
     文件      453174  2018-12-12 15:14  lvtongEazyVersion\image\lvtongdraft.ico
     文件      145825  2018-11-27 06:09  lvtongEazyVersion\image\lvtongdraft.PNG
     文件       16938  2018-12-12 15:27  lvtongEazyVersion\lvtonguilogic.py
     文件        1057  2018-12-12 16:36  lvtongEazyVersion\lvtonguilogic.spec
     目录           0  2018-12-12 09:16  lvtongEazyVersion\model\
     文件    58918816  2018-12-05 03:56  lvtongEazyVersion\model\rf.model
     文件        2631  2018-11-19 10:49  lvtongEazyVersion\readfile2df.py
     文件        1706  2018-12-12 14:32  lvtongEazyVersion\startingimage.py
     文件       13068  2018-12-12 15:21  lvtongEazyVersion\storemysql.py
     文件        9535  2018-12-12 13:40  lvtongEazyVersion\Sunshinemodel.py
     目录           0  2018-12-12 16:09  lvtongEazyVersion\ui\
     文件        2042  2018-12-05 06:40  lvtongEazyVersion\ui\calculateui.py
     文件        2144  2018-12-05 06:40  lvtongEazyVersion\ui\calculateui.ui
     文件        2794  2018-12-12 09:36  lvtongEazyVersion\ui\login.py
     文件        2477  2018-12-07 13:40  lvtongEazyVersion\ui\login.ui
     文件       14774  2018-12-12 09:36  lvtongEazyVersion\ui\lvtongui.py
     文件       13112  2018-12-06 12:43  lvtongEazyVersion\ui\lvtongui.ui
     文件        1006  2018-12-12 15:05  lvtongEazyVersion\ui\lvtonguilogic.spec
............此处省略20个文件信息

评论

共有 条评论