diff --git a/release/气门芯定位检测更新内容.txt b/release/气门芯定位检测更新内容.txt new file mode 100644 index 0000000..207da2b --- /dev/null +++ b/release/气门芯定位检测更新内容.txt @@ -0,0 +1,11 @@ +2021-10-18 +1、修改了lpengine和lpdesigner模块的功能,增加标定参考线功能 +2、增加相机场景标定功能 +3、增加圆心坐标输出功能 +4、内部station管理逻辑大调整,当前移除了数据存储功能 +5、UI界面操作习惯大调整 + +2021-10-18 2 +1、恢复检测数据结果保存和检测图片保存功能 +2、移除不需要的代码和接口 +3、UI布局调整 \ No newline at end of file diff --git a/runner17/Report.exe b/runner17/Report.exe new file mode 100644 index 0000000..a0bc3ff Binary files /dev/null and b/runner17/Report.exe differ diff --git a/tpvs17/Report/Report.cpp b/tpvs17/Report/Report.cpp new file mode 100644 index 0000000..92cdc86 --- /dev/null +++ b/tpvs17/Report/Report.cpp @@ -0,0 +1,7 @@ +#include "Report.h" + +Report::Report(QWidget *parent) + : QMainWindow(parent) +{ + ui.setupUi(this); +} diff --git a/tpvs17/Report/Report.h b/tpvs17/Report/Report.h new file mode 100644 index 0000000..b0162fa --- /dev/null +++ b/tpvs17/Report/Report.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "ui_Report.h" + +class Report : public QMainWindow +{ + Q_OBJECT + +public: + Report(QWidget *parent = Q_NULLPTR); + +private: + Ui::ReportClass ui; +}; diff --git a/tpvs17/Report/Report.qrc b/tpvs17/Report/Report.qrc new file mode 100644 index 0000000..0d07b69 --- /dev/null +++ b/tpvs17/Report/Report.qrc @@ -0,0 +1,6 @@ + + + Resources/app.png + Resources/app2.png + + diff --git a/tpvs17/Report/Report.ui b/tpvs17/Report/Report.ui new file mode 100644 index 0000000..8c7908b --- /dev/null +++ b/tpvs17/Report/Report.ui @@ -0,0 +1,29 @@ + + ReportClass + + + ReportClass + + + + 0 + 0 + 600 + 400 + + + + Report + + + + + + + + + + + + + diff --git a/tpvs17/Report/Report.vcxproj b/tpvs17/Report/Report.vcxproj new file mode 100644 index 0000000..5f39c45 --- /dev/null +++ b/tpvs17/Report/Report.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + x64 + + + Release + x64 + + + + {B12702AD-ABFB-343A-A199-8E24837244A3} + Qt4VSv1.0 + 10.0.17763.0 + + + + Application + v141 + + + Application + v141 + + + + $(MSBuildProjectDirectory)\QtMsBuild + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(ProjectName)d + + + $(SolutionDir)$(Platform)\$(Configuration)\ + + + + + + + + + + + + + + + + + + + true + UNICODE;_UNICODE;WIN32;WIN64;QT_CORE_LIB;QT_GUI_LIB;QT_SQL_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets;..\..\src\lpMain\sqliteDB;..\..\3part\libzkq\include;..\..\3part\customgui\include;%(AdditionalIncludeDirectories) + Disabled + ProgramDatabase + MultiThreadedDebugDLL + true + + + Windows + $(SolutionDir)..\runner17\$(TargetName)$(TargetExt) + $(QTDIR)\lib;..\..\3part\libzkq\lib;..\..\3part\customgui\lib_x64;%(AdditionalLibraryDirectories) + true + qtmaind.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5Sqld.lib;Qt5Widgetsd.lib;libzkqd.lib;customguid.lib;%(AdditionalDependencies) + + + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + Moc'ing %(Identity)... + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets;..\..\src\lpMain\sqliteDB;..\..\3part\libzkq\include;..\..\3part\customgui\include;%(AdditionalIncludeDirectories) + UNICODE;_UNICODE;WIN32;WIN64;QT_CORE_LIB;QT_GUI_LIB;QT_SQL_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) + + + Uic'ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h + + + Rcc'ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp + + + + + true + UNICODE;_UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_SQL_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets;..\..\src\lpMain\sqliteDB;..\..\3part\libzkq\include;..\..\3part\customgui\include;%(AdditionalIncludeDirectories) + + MultiThreadedDLL + true + + + Windows + $(SolutionDir)..\runner17\$(TargetName)$(TargetExt) + $(QTDIR)\lib;..\..\3part\libzkq\lib;..\..\3part\customgui\lib_x64;%(AdditionalLibraryDirectories) + false + qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Sql.lib;Qt5Widgets.lib;libzkq.lib;customgui.lib;%(AdditionalDependencies) + + + .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp + Moc'ing %(Identity)... + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets;..\..\src\lpMain\sqliteDB;..\..\3part\libzkq\include;..\..\3part\customgui\include;%(AdditionalIncludeDirectories) + UNICODE;_UNICODE;WIN32;WIN64;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_SQL_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) + + + Uic'ing %(Identity)... + .\GeneratedFiles\ui_%(Filename).h + + + Rcc'ing %(Identity)... + .\GeneratedFiles\qrc_%(Filename).cpp + + + + + + + + + + + + + + + + + + + + + + + + + + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets + + + + + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets + + + + + + + + + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets + + + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets + .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtSql;$(QTDIR)\include\QtWidgets + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tpvs17/Report/Report.vcxproj.filters b/tpvs17/Report/Report.vcxproj.filters new file mode 100644 index 0000000..28ccb2c --- /dev/null +++ b/tpvs17/Report/Report.vcxproj.filters @@ -0,0 +1,108 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {99349809-55BA-4b9d-BF79-8FDBB0286EB3} + ui + + + {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} + qrc;* + false + + + {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} + moc;h;cpp + False + + + {254918ee-db1e-4bc7-a132-e121174a9976} + + + + + Source Files + + + Source Files + + + db + + + db + + + db + + + db + + + db + + + db + + + Source Files + + + + + Header Files + + + db + + + db + + + db + + + Header Files + + + + + Form Files + + + Form Files + + + + + Resource Files + + + + + db + + + db + + + db + + + db + + + \ No newline at end of file diff --git a/tpvs17/Report/Report.vcxproj.user b/tpvs17/Report/Report.vcxproj.user new file mode 100644 index 0000000..02424fe --- /dev/null +++ b/tpvs17/Report/Report.vcxproj.user @@ -0,0 +1,18 @@ + + + + + C:\Qt\Qt5.9.4\5.9.4\msvc2017_64 + $(SolutionDir)..\runner17\$(TargetName)$(TargetExt) + $(SolutionDir)..\runner17\ + WindowsLocalDebugger + PATH=$(QTDIR)\bin%3b$(PATH) + + + C:\Qt\Qt5.9.4\5.9.4\msvc2017_64 + $(SolutionDir)..\runner17\$(TargetName)$(TargetExt) + $(SolutionDir)..\runner17\ + WindowsLocalDebugger + PATH=$(QTDIR)\bin%3b$(PATH) + + \ No newline at end of file diff --git a/tpvs17/Report/Resources/app.png b/tpvs17/Report/Resources/app.png new file mode 100644 index 0000000..b2bc426 Binary files /dev/null and b/tpvs17/Report/Resources/app.png differ diff --git a/tpvs17/Report/Resources/app2.png b/tpvs17/Report/Resources/app2.png new file mode 100644 index 0000000..d47d80d Binary files /dev/null and b/tpvs17/Report/Resources/app2.png differ diff --git a/tpvs17/Report/main.cpp b/tpvs17/Report/main.cpp new file mode 100644 index 0000000..1eb8ac2 --- /dev/null +++ b/tpvs17/Report/main.cpp @@ -0,0 +1,29 @@ +#include "Report.h" +#include +#include "stationdb.h" +#include "qcheckdatadlg.h" + +#pragma execution_character_set("utf-8") +int main(int argc, char *argv[]) +{ + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication a(argc, argv); + QString strPath = QCoreApplication::applicationDirPath(); + QString DBFilePath = strPath + "\\DBFiles"; + + StationDB* m_db = new StationDB(DBFilePath + "\\AntMan.db"); + m_db->InitDatabase(); + + QCheckDataDlg dlg; + dlg.setWindowIcon(QIcon(":/Report/Resources/app2.png")); + dlg.setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); + dlg.setDbPtr(m_db); + QStringList strList; + strList<< "λ1" << "λ2"; + dlg.setStationNames(strList); + dlg.show(); + int ret = a.exec(); + delete m_db; + m_db = nullptr; + return ret; +} diff --git a/tpvs17/Report/qcheckdatadlg.cpp b/tpvs17/Report/qcheckdatadlg.cpp new file mode 100644 index 0000000..7ba34b9 --- /dev/null +++ b/tpvs17/Report/qcheckdatadlg.cpp @@ -0,0 +1,372 @@ +#include "qcheckdatadlg.h" +#include "qstandarditemmodel.h" +#include "qmessagebox.h" +#include "qfontmetrics.h" +#pragma execution_character_set("utf-8") +QCheckDataDlg::QCheckDataDlg(QWidget *parent) + : QDialog(parent), m_db(NULL), nPrevNum(0), nTotlaNumber(0) +{ + ui.setupUi(this); + m_ViewImg = new QTpGraphView; + connect(ui.m_pbCheck, SIGNAL(clicked()), this, SLOT(onCheckOutData())); + connect(ui.Prev_checkShengchang, SIGNAL(clicked()), this, SLOT(onChenckButton())); + connect(ui.Next_checkShengchang, SIGNAL(clicked()), this, SLOT(onChenckButton())); + connect(ui.m_pbCount, SIGNAL(clicked()), this, SLOT(onChenckButton())); + setWindowIcon(QIcon(":/leaper/app.png")); + pShowName_label = ui.check_fileName; + pShowName_label->clear(); + + check_showImg_label = ui.check_showImg_label; + check_showImg_label->clear(); + QGridLayout *pGrid = new QGridLayout(this); + pGrid->addWidget(m_ViewImg); + check_showImg_label->setLayout(pGrid); + + m_tableModel = new QStandardItemModel; + tableView = ui.tableView; + connect(tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onTBUI_ItemClick(const QModelIndex &))); + tableView->setModel(m_tableModel); + textBrowser = ui.textBrowser; + + pStartTimeEdit = ui.dateTimeEdit_start; + pEndTimeEdit = ui.dateTimeEdit_end; + QDateTime nDateTime = QDateTime::currentDateTime(); + nDateTime.setTime(QTime(0, 0, 0)); + pStartTimeEdit->setDateTime(nDateTime); + pEndTimeEdit->setDateTime(QDateTime::currentDateTime()); + Qt::WindowFlags flags = Qt::Dialog; + flags |= Qt::WindowMinMaxButtonsHint; + flags |= Qt::WindowCloseButtonHint; + setWindowFlags(flags); + setPageShow(0, 0); +} + +QCheckDataDlg::~QCheckDataDlg() +{ + if (m_tableModel) + { + delete m_tableModel; + m_tableModel = NULL; + } + if (m_ViewImg){ + delete m_ViewImg; + m_ViewImg = NULL; + } +} + +void QCheckDataDlg::createHeader() +{ + QStringList listStr; + listStr.append(QObject::tr("时间")); + listStr.append(QObject::tr("型号")); + listStr.append(QObject::tr("matchScore")); + listStr.append(QObject::tr("BenchMark")); + listStr.append(QObject::tr("Angle")); + listStr.append(QObject::tr("errorType")); + listStr.append(QObject::tr("resultTip")); + listStr.append(QObject::tr("工位")); + m_tableModel->setHorizontalHeaderLabels(listStr); +} + +void QCheckDataDlg::updateModelShowLog(QSqlQuery &sql) +{ + m_tableModel->clear(); + m_strMap.clear(); + createHeader(); + tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); + tableView->setSelectionBehavior(QAbstractItemView::SelectRows); + tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);//自适应行宽 + int nIndex = 0; + while (sql.next()) + { + /*这里下面是统计查询到的通道对应的产品总数*/ + QString time = sql.value("time").toString(); + QString dAngle = sql.value("dAngle").toString(); + QString matchScore = sql.value("matchScore").toString().left(5); + QString errorType = sql.value("errorType").toString(); + QString resultTip = sql.value("resultTip").toString(); + QString threshBenchMark = sql.value("threshBenchMark").toString(); + QString stationName = sql.value("stationName").toString(); + QString strFilename = sql.value("value1").toString();//取出保存图片的路径名 + //QByteArray picByte = sql.value("image").toByteArray(); + QString strModelName = sql.value("value2").toString(); + //QImage img = QImage::fromData(picByte); + + m_tableModel->setItem(nIndex, 0, new QStandardItem(time)); + m_tableModel->setItem(nIndex, 1, new QStandardItem(strModelName)); + m_tableModel->setItem(nIndex, 2, new QStandardItem(matchScore)); + m_tableModel->setItem(nIndex, 3, new QStandardItem(threshBenchMark)); + m_tableModel->setItem(nIndex, 4, new QStandardItem(dAngle)); + m_tableModel->setItem(nIndex, 5, new QStandardItem(errorType)); + m_tableModel->setItem(nIndex, 6, new QStandardItem(resultTip)); + m_tableModel->setItem(nIndex, 7, new QStandardItem(stationName)); + m_strMap.insert(time, strFilename); + pShowName_label->setText(strFilename); + nIndex++; + } + + ui.showNum_Label_Checkdata->setText(QString(QObject::tr("共显示%1条记录")).arg(nIndex)); + tableView->setModel(m_tableModel); + + int page = nPrevNum / getLimitNumber(); + int totalPage = nTotlaNumber / getLimitNumber(); + setPageShow(page+1, totalPage+1); +} + +int QCheckDataDlg::getLimitNumber() +{ + int num = ui.LineNumber_checkShengchang->text().toInt(); + if (num > 1) + return num; + else + { + ui.LineNumber_checkShengchang->setText("50"); + return 50; + } + +} +int QCheckDataDlg::getTotalNumber() +{ + QString startTime = pStartTimeEdit->dateTime().toString("yyyy-MM-dd hh:mm:ss zzz"); + QString endTime = pEndTimeEdit->dateTime().toString("yyyy-MM-dd hh:mm:ss zzz"); + QString stationName = getStationName(); + int errorType = getErrorType(); + QString strSql = QString(); + if (stationName == QObject::tr("全部")&&errorType == 0) + strSql = QString("select count(uid) from RltTable where time >'%1' and time <'%2' ").arg(startTime).arg(endTime); + else if (stationName == QObject::tr("全部") && errorType == 1) + strSql = QString("select count(uid) from RltTable where time >'%1' and time <'%2' and errorType != '%3'").arg(startTime).arg(endTime).arg(0); + else if (stationName != QObject::tr("全部") && errorType == 1) + strSql = QString("select count(uid) from RltTable where time >'%1' and time <'%2' and errorType != '%3' and stationName == '%4' ").arg(startTime).arg(endTime).arg(0).arg(stationName); + else + strSql = QString("select count(uid) from RltTable where time >'%1' and time <'%2' and stationName == '%3'").arg(startTime).arg(endTime).arg(stationName); + + QSqlQuery sqlquery; + m_db->checkoutData(strSql, sqlquery); + int totalNumber =0; + while (sqlquery.next()) + { + QSqlRecord record = sqlquery.record(); + QString fieldName = record.fieldName(0); + QString num = sqlquery.value(0).toString(); + totalNumber = num.toInt(); + // /*这里下面是统计查询到的通道对应的产品总数*/ + } + return totalNumber; +} +Q_SLOT void QCheckDataDlg::onCheckOutData() +{ + nTotlaNumber = 0; + nPrevNum = 0; + int limitNum = getLimitNumber(); + nTotlaNumber = getTotalNumber(); + + onCheckOutData(limitNum, nPrevNum); +} + +void QCheckDataDlg::onCheckOutData(int nLimitNum, int nPrenum) +{ + QString startTime = pStartTimeEdit->dateTime().toString("yyyy-MM-dd hh:mm:ss zzz"); + QString endTime = pEndTimeEdit->dateTime().toString("yyyy-MM-dd hh:mm:ss zzz"); + QString stationName = getStationName(); + int errorType = getErrorType(); + QString strSql = QString(); + if (stationName == QObject::tr("全部")&&errorType == 0) + strSql=QString("select * from RltTable where time >'%1' and time <'%2' LIMIT %3 OFFSET %4 ").arg(startTime).arg(endTime).arg(nLimitNum).arg(nPrenum); + else if (stationName == QObject::tr("全部") && errorType == 1) + strSql = QString("select * from RltTable where time >'%1' and time <'%2' and errorType != '%3' LIMIT %4 OFFSET %5 ").arg(startTime).arg(endTime).arg(0).arg(nLimitNum).arg(nPrenum); + else if (stationName != QObject::tr("全部") && errorType == 1) + strSql = QString("select * from RltTable where time >'%1' and time <'%2' and errorType != '%3' and stationName == '%4' LIMIT %5 OFFSET %6 ").arg(startTime).arg(endTime).arg(0).arg(stationName).arg(nLimitNum).arg(nPrenum); + else + strSql = QString("select * from RltTable where time >'%1' and time <'%2' and stationName == '%3' LIMIT %4 OFFSET %5 ").arg(startTime).arg(endTime).arg(stationName).arg(nLimitNum).arg(nPrenum); + QSqlQuery sqlquery; + m_db->checkoutData(strSql, sqlquery); + updateModelShowLog(sqlquery); +} + +Q_SLOT void QCheckDataDlg::onChenckButton() +{ + QString strObjName = sender()->objectName(); + if (strObjName == "Next_checkShengchang") + { + if (nTotlaNumber <= 0) + return; + if (nPrevNum > nTotlaNumber) + return; + nPrevNum += getLimitNumber(); + if (nPrevNum > nTotlaNumber) + { + nPrevNum -= getLimitNumber(); + QMessageBox infobox(QMessageBox::Information, QObject::tr("提醒"), QObject::tr("已经是最后一页了"), QMessageBox::Ok, NULL); + infobox.setWindowIcon(QIcon(":/leaper/app.png")); + infobox.setButtonText(QMessageBox::Ok, QString(QObject::tr("确认"))); + infobox.exec(); + return; + } + onCheckOutData(getLimitNumber(), nPrevNum); + } + else if (strObjName == "Prev_checkShengchang") + { + if (nTotlaNumber <= 0) + return; + if (nPrevNum < 0) + return; + nPrevNum -= getLimitNumber(); + if (nPrevNum < 0) + { + nPrevNum = 0; + QMessageBox infobox(QMessageBox::Information, QObject::tr("提醒"), QObject::tr("已经是第一页了"), QMessageBox::Ok, NULL); + infobox.setWindowIcon(QIcon(":/leaper/app.png")); + infobox.setButtonText(QMessageBox::Ok, QString(QObject::tr("确认"))); + infobox.exec(); + return; + } + onCheckOutData(getLimitNumber(), nPrevNum); + } + else if (strObjName == "m_pbCount") + { + QString startTime = pStartTimeEdit->dateTime().toString("yyyy-MM-dd hh:mm:ss zzz"); + QString endTime = pEndTimeEdit->dateTime().toString("yyyy-MM-dd hh:mm:ss zzz"); + QString stationName = getStationName(); + QString strSql = QString(); + if (stationName == QObject::tr("全部")) + strSql = QString("select errorType,count(uid) from RltTable where time >'%1' and time <'%2' group by errorType order by errorType").arg(startTime).arg(endTime); + else + strSql = QString("select errorType,count(uid) from RltTable where time >'%1' and time <'%2' and stationName == '%3' group by errorType order by errorType").arg(startTime).arg(endTime).arg(stationName); + + QSqlQuery sqlquery; + m_db->checkoutData(strSql, sqlquery); + QMap nCountMap; + + while (sqlquery.next()) + { + QSqlRecord record = sqlquery.record(); + QString fieldName = record.fieldName(0); + QString nType = sqlquery.value(0).toString(); + int count = sqlquery.value(1).toInt(); + nCountMap.insert(nType, count); + } + int TotalNumber = 0; + int ErrorNumber = 0; + textBrowser->clear(); + for (QMap::iterator its = nCountMap.begin(); its != nCountMap.end();++its) + { + QString strKey = its.key(); + int nValue = nCountMap.value(strKey); + QString str; + if (strKey != "0") + str = QString("errorType:%1 Sum:%2;").arg(strKey).arg(nValue); + else + str = QString("goodType Sum:%2;").arg(nValue); + TotalNumber += nValue; + if (strKey != "0") + { + ErrorNumber += nValue; + } + textBrowser->append(str); + } + QString strEnd = QString("ErrorNumber:%1\nTotalNumber:%2").arg(ErrorNumber).arg(TotalNumber); + textBrowser->append(strEnd); + } +} + +void QCheckDataDlg::setStationNames(QStringList listNames) +{ + ui.comboBox_station->addItems(listNames); +} + +QString QCheckDataDlg::getStationName() +{ + return ui.comboBox_station->currentText(); +} + +int QCheckDataDlg::getErrorType() +{ + QString str = ui.comboBox_errorType->currentText(); + if (str == QObject::tr("全部")) + return 0; + else + return 1; +} + +void QCheckDataDlg::setPageShow(int page,int totalPage) +{ + QString str = QString(QObject::tr("第%1页 共%2页")).arg(page).arg(totalPage); + ui.showPage_Label_Checkdata->setText(str); +} + +Q_SLOT void QCheckDataDlg::onTBUI_ItemClick(const QModelIndex & index) +{ + QModelIndex nindex = m_tableModel->index(index.row(), 0); + QString str = nindex.data().toString(); + if (m_strMap.size() > 0) + { + QString strFileName = m_strMap.value(str); + + if (check_showImg_label) + { + QPixmap npixmap; + QString appPath = QApplication::applicationDirPath(); + npixmap.load(appPath+strFileName); + m_ViewImg->setImg(npixmap); + if (!npixmap.isNull()){ + if (pShowName_label) + { + QFontMetrics fontMetrics(this->font()); + int fontSize = fontMetrics.width(strFileName); + QString str = strFileName; + if (fontSize > pShowName_label->width()) + { + str = fontMetrics.elidedText(strFileName, Qt::ElideRight, pShowName_label->width()); + } + pShowName_label->setText(str); + } + } + else{ + if (pShowName_label){ + pShowName_label->setText(QObject::tr("无图片(或图片已过期/已被删除)")); + } + } + } + } + + int i = 0; +} + +Q_SLOT void QCheckDataDlg::onSlowPixmap(QSqlQuery sql) +{ + static bool nFlag = false; + if (nFlag == true) + return; + nFlag = true; + + sql.next(); + double dHight = sql.value("hight").toDouble(); + QByteArray pic = sql.value("pic").toByteArray(); + QImage img = QImage::fromData(pic); + QSize s = img.size(); + QPixmap m_Pix = QPixmap::fromImage(img); + + { + int dhight = m_Pix.height(); + int dwidth = m_Pix.width(); + double nRate = m_Pix.width()*1.0 / m_Pix.height(); + int scarew = 150; + int scareh = 150 * 1.0 / nRate; + + if (scareh > 150) + { + scarew = 150; + scareh = 150 * 1.0 / nRate; + } + + if (check_showImg_label) + { + m_ViewImg->setImg(m_Pix); + } + } + //label_6->setPixmap(m_Pix.scaled(WHEEL_PIC_SIZE, WHEEL_PIC_SIZE)); + nFlag = false; +} + + diff --git a/tpvs17/Report/qcheckdatadlg.h b/tpvs17/Report/qcheckdatadlg.h new file mode 100644 index 0000000..260eb54 --- /dev/null +++ b/tpvs17/Report/qcheckdatadlg.h @@ -0,0 +1,58 @@ +#ifndef QCHECKDATADLG_H +#define QCHECKDATADLG_H + +#include +#include "ui_qcheckdatadlg.h" +#include "stationdb.h" +#include "qsqlquery.h" +#include "qstandarditemmodel.h" +#include "qtableview.h" +#include "qdatetimeedit.h" +#include "QTextBrowser.h" +#include "cunstomgraphview.h" +class QCheckDataDlg : public QDialog +{ + Q_OBJECT + +public: + QCheckDataDlg(QWidget *parent = 0); + ~QCheckDataDlg(); + void setDbPtr(StationDB *pDb){ m_db = pDb; }; + void setStationNames(QStringList listNames); + +private: + Q_SLOT void onChenckButton(); + Q_SLOT void onCheckOutData(); + Q_SLOT void onTBUI_ItemClick(const QModelIndex & index); + Q_SLOT void onSlowPixmap(QSqlQuery sql); +private: + int getLimitNumber(); + int getTotalNumber(); + int getErrorType(); + + QString getStationName(); + + void createHeader(); + void updateModelShowLog(QSqlQuery &sql); + void onCheckOutData(int nLimitNum, int nPrenum); + void setPageShow(int page, int totalPage); +private: + Ui::QCheckDataDlg ui; + + QLabel *pShowName_label{ nullptr }; + QLabel *check_showImg_label{ nullptr }; + QTextBrowser *textBrowser{ nullptr }; + StationDB *m_db{ nullptr }; + QStandardItemModel *m_tableModel{ nullptr }; + QTableView *tableView{ nullptr }; + QDateTimeEdit *pStartTimeEdit{ nullptr }; + QDateTimeEdit *pEndTimeEdit{ nullptr }; + + QMap m_strMap; + int nPrevNum; + int nTotlaNumber; + + QTpGraphView *m_ViewImg{ nullptr }; +}; + +#endif // QCHECKDATADLG_H diff --git a/tpvs17/Report/qcheckdatadlg.ui b/tpvs17/Report/qcheckdatadlg.ui new file mode 100644 index 0000000..35b6ac5 --- /dev/null +++ b/tpvs17/Report/qcheckdatadlg.ui @@ -0,0 +1,386 @@ + + + QCheckDataDlg + + + + 0 + 0 + 902 + 598 + + + + 检测记录查询 + + + + + + Qt::Horizontal + + + + + 4 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 3 + 0 + + + + Qt::Vertical + + + true + + + 1 + + + true + + + + + 0 + 2 + + + + + + + + + + 查询操作 + + + + + + + 全部 + + + + + error + + + + + + + + 结束时间: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 全部 + + + + + + + + 显示: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + 起始时间: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 工位: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + 查询 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 8 + + + + + + + + + + 显示数据数(条) + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + + 100 + 50 + + + + 50 + + + 4 + + + Qt::AlignCenter + + + + + + + 上一页 + + + + + + + TextLabel + + + + + + + 下一页 + + + + + + + Qt::Horizontal + + + + 151 + 20 + + + + + + + + TextLabel + + + + + + + + + + TextLabel + + + + + + + + + + + + + 6 + 0 + + + + + 250 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Qt::Vertical + + + + + 0 + 3 + + + + 统计 + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + 统计当前设置的查询时间记录总数 + + + 统计 + + + + + + + + + 0 + 6 + + + + + 300 + 300 + + + + + + + + + + + + + + + + + + diff --git a/tpvs17/newValue_tp17.sln b/tpvs17/newValue_tp17.sln index 2ab6dee..fb05681 100644 --- a/tpvs17/newValue_tp17.sln +++ b/tpvs17/newValue_tp17.sln @@ -29,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tpCamHik", "tpCamHik\tpCamH EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tpCamVirtual", "tpCamVirtual\tpCamVirtual.vcxproj", "{707DDF6F-B78B-42F7-9EAD-E786C0FCD5FF}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Report", "Report\Report.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -123,6 +125,12 @@ Global {707DDF6F-B78B-42F7-9EAD-E786C0FCD5FF}.Release|x64.Build.0 = Release|x64 {707DDF6F-B78B-42F7-9EAD-E786C0FCD5FF}.Release|x86.ActiveCfg = Release|Win32 {707DDF6F-B78B-42F7-9EAD-E786C0FCD5FF}.Release|x86.Build.0 = Release|Win32 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.Build.0 = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x86.ActiveCfg = Debug|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.Build.0 = Release|x64 + {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x86.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE