报表查看软件 各页面分开封装,基本调通

master
bob.pan 4 years ago
parent 678e98f484
commit db8ca51fe6

@ -4,7 +4,6 @@
#include <QVariant>
#include <QImage>
#include <QDebug>
#include <QPixmap>
#include "CVUtils.h"
#include "qtcvutils.h"
#include "ICompareModel.h"

@ -115,9 +115,9 @@ void TPTcpClient::createChildRevSocket(int socketNum)
data_sess_ptr->moveToThread(thread_ptr);
connect(thread_ptr, &QThread::finished, data_sess_ptr, &QObject::deleteLater);
connect(data_sess_ptr, &tcpClientRecv::signal_data_recv_completed, this, &TPTcpClient::on_data_recv_completed, Qt::QueuedConnection);
connect(this, &TPTcpClient::signal_session_start, data_sess_ptr, &tcpClientRecv::on_session_start, Qt::QueuedConnection);
connect(data_sess_ptr, &tcpClientRecv::sgException, this, &TPTcpClient::on_data_recv_close, Qt::QueuedConnection);
connect(data_sess_ptr, &tcpClientRecv::signal_data_recv_completed, this, &TPTcpClient::on_data_recv_completed/*, Qt::QueuedConnection*/);
connect(this, &TPTcpClient::signal_session_start, data_sess_ptr, &tcpClientRecv::on_session_start/*, Qt::QueuedConnection*/);
connect(data_sess_ptr, &tcpClientRecv::sgException, this, &TPTcpClient::on_data_recv_close/*, Qt::QueuedConnection*/);
data_sessions_[strUuid] = thread_ptr;
m_childRevSocket_Map[strUuid] = QPair<bool, tcpClientRecv*>(false, data_sess_ptr);
thread_ptr->start();

@ -13,7 +13,7 @@ public:
SaveImgThread(QObject *parent = 0){};
~SaveImgThread(){};
void setPixmap(const QPixmap& m_pix,const QString filepath,const QString filename){
m_pixmap = m_pix;
m_pixmap = m_pix.copy();
m_path = filepath;
m_filename = filename;

@ -0,0 +1,663 @@
#include "ModeCheckDlg.h"
#include "checkthread.h"
#include "qtimedlg.h"
#include <QTextStream>
#include "QFileDialog"
#include "qsavecsvthread.h"
#include <QDebug>
#pragma execution_character_set("utf-8")
#define WHEEL_PIC_SIZE 150
ModeCheckDlg::ModeCheckDlg(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
nstartTime.setHMS(0, 0, 0);
nEndTime.setHMS(23, 59, 59);
m_tableModel = new QStandardItemModel;
m_WorkHistory = new CheckData;
m_WorkHistory->moveToThread(&m_WorkThreadCheckHistory);
connect(&m_WorkThreadCheckHistory, &QThread::finished, m_WorkHistory, &QObject::deleteLater);
connect(this, &ModeCheckDlg::operateHistory, m_WorkHistory, &CheckData::doWork);
connect(m_WorkHistory, &CheckData::resultReady, this, &ModeCheckDlg::handleResultsHistory);
connect(m_WorkHistory, &CheckData::sgShowProgress, this, &ModeCheckDlg::onProgressForTsk);
m_WorkThreadCheckHistory.start();
connect(ui.pushButton_Set1_History, SIGNAL(clicked()), this, SLOT(SlotEditTime()));
connect(ui.pushButton_Set2_History, SIGNAL(clicked()), this, SLOT(SlotEditTime()));
connect(ui.pushButton_Checkdata, SIGNAL(clicked()), this, SLOT(onCheckButton()));
connect(ui.pushButton_SaveHistory, SIGNAL(clicked()), this, SLOT(onCheckButton()));
connect(ui.Prev_checkShengchang, SIGNAL(clicked()), this, SLOT(onHistoryButton()));
connect(ui.Next_checkShengchang, SIGNAL(clicked()), this, SLOT(onHistoryButton()));
connect(ui.comboBox_Banci, SIGNAL(currentIndexChanged(int)), this, SLOT(SlotCombox(int)));
ui.LineNumber_checkShengchang->setText("50");
QValidator *validator = new QIntValidator(1, 9999, this);
ui.LineNumber_checkShengchang->setValidator(validator);
ui.showNum_Label_Checkdata->setText(tr("共显示%1条记录").arg(0));
ui.showPage_Label_Checkdata->setText(tr("第%1页 共%2页").arg(0).arg(0));
m_startDate_History = QDateTime::currentDateTime();
m_endDate_History = QDateTime::currentDateTime();
QString strstartDate = m_startDate_History.toString("yyyy-MM-dd hh:mm:ss");
ui.label_Time1_History->setText(m_startDate_History.toString("yyyy-MM-dd hh:mm:ss"));
ui.label_Time2_History->setText(m_endDate_History.toString("yyyy-MM-dd hh:mm:ss"));
if (m_tableModel)
{
m_tableModel->clear();
}
ui.comboBox_Model->setEditable(true);
ui.label_Number->setText("0");
ui.CheckDlg_label_Pic->clear();
}
ModeCheckDlg::~ModeCheckDlg()
{
if (m_tableModel) {
delete m_tableModel;
m_tableModel = NULL;
}
if (_pCompleter) {
delete _pCompleter;
_pCompleter = NULL;
}
if (m_WorkThreadCheckHistory.isRunning())
{
qDebug() << "delete m_WorkThreadCheckHistory";
m_WorkThreadCheckHistory.quit();
m_WorkThreadCheckHistory.wait(50);
qDebug() << "delete m_WorkThreadCheckHistory end";
}
}
void ModeCheckDlg::setDBPtr(class DetectDataDB *ptr)
{
m_pDb = ptr;
if(m_WorkHistory)
m_WorkHistory->setDB(ptr);
}
void ModeCheckDlg::initParam(QMap<QString, TimeStruct> timetable, QStringList names)
{
m_Totaltime = timetable;
SetModelNames(names);
ui.comboBox_Banci->clear();
ui.comboBox_Banci->addItem(tr("全天"));
ui.comboBox_Banci->addItems(m_Totaltime.keys());
}
QString ModeCheckDlg::getHistoryCheckString()
{
QString m_strLast = ui.label_Time1_History->text();
QString m_endLast = ui.label_Time2_History->text();
QString modelName = ui.comboBox_Model->currentText();
QString strString;
if (modelName == tr("全部"))
strString = QString("select * from wftable where time >'%1' and time <'%2'").arg(m_strLast).arg(m_endLast);
else
strString = QString("select * from wftable where time >'%1' and time <'%2' and model = '%3'").arg(m_strLast).arg(m_endLast).arg(modelName);
return strString;
}
Q_SLOT void ModeCheckDlg::onHistoryButton()
{
QString strObj = sender()->objectName();
if ("Prev_checkShengchang" == strObj) {
if (m_PrevNum <= 0)
return;
int limitNum = ui.LineNumber_checkShengchang->text().toInt();
if (limitNum <= 0)
{
limitNum = 10;
ui.LineNumber_checkShengchang->setText("10");
}
QString strString = getHistoryCheckString();
m_PrevNum -= limitNum;
if (m_PrevNum <= 0)
m_PrevNum = 0;
strString = strString + QString(" LIMIT %1 OFFSET %2").arg(limitNum).arg(m_PrevNum);
/*启用线程查询数据 减少界面卡顿*/
CheckThread *workerThread = new CheckThread(this);
workerThread->setCheckStr(m_pDb, strString);
connect(workerThread, SIGNAL(resultReady(QSqlQuery)), this, SLOT(onUpdateTableViewShow(QSqlQuery)));
connect(workerThread, &CheckThread::finished, workerThread, &QObject::deleteLater);
workerThread->start();
m_totalPage = (m_totlaNum / limitNum);
m_page = ((m_PrevNum) / limitNum) + 1;
ui.showPage_Label_Checkdata->setText(tr("第%1页 共%2页").arg(m_page).arg(m_totalPage + 1));
if (m_PrevNum <= 0)
{
m_PrevNum = 0;
ui.Prev_checkShengchang->setDisabled(true);
}
ui.Next_checkShengchang->setDisabled(false);
}
else if ("Next_checkShengchang" == strObj) {
if (m_PrevNum >= m_totlaNum)
return;
int limitNum = ui.LineNumber_checkShengchang->text().toInt();
if (limitNum <= 0)
{
limitNum = 10;
ui.LineNumber_checkShengchang->setText("10");
}
m_PrevNum += limitNum;
if (m_PrevNum >= m_totlaNum)
m_PrevNum = m_totlaNum - limitNum;
QString strString = getHistoryCheckString();
strString = strString + QString(" LIMIT %1 OFFSET %2").arg(limitNum).arg(m_PrevNum);
/*启用线程查询数据 减少界面卡顿*/
CheckThread *workerThread = new CheckThread(this);
workerThread->setCheckStr(m_pDb, strString);
connect(workerThread, SIGNAL(resultReady(QSqlQuery)), this, SLOT(onUpdateTableViewShow(QSqlQuery)));
connect(workerThread, &CheckThread::finished, workerThread, &QObject::deleteLater);
workerThread->start();
m_totalPage = (m_totlaNum / limitNum);
m_page = (m_PrevNum + limitNum) / limitNum;
ui.showPage_Label_Checkdata->setText(tr("第%1页 共%2页").arg(m_page).arg(m_totalPage + 1));
if ((m_PrevNum + limitNum) >= m_totlaNum)
{
m_PrevNum = m_totlaNum;
ui.Next_checkShengchang->setDisabled(true);
}
ui.Prev_checkShengchang->setDisabled(false);
}
}
void ModeCheckDlg::cleanHistorycal()
{
m_PrevNum = 0;
m_NextNum = 0;
m_totlaNum = 0;
m_page = 0;
m_totalPage = 0;
m_PrevNumlog = 0;
m_NextNumlog = 0;
m_totlaNumlog = 0;
m_pagelog = 0;
m_totalPagelog = 0;
ui.showNum_Label_Checkdata->setText(tr("共显示%1条记录").arg(0));
ui.showPage_Label_Checkdata->setText(tr("第%1页 共%2页").arg(0).arg(0));
ui.Prev_checkShengchang->setDisabled(true);
ui.Next_checkShengchang->setDisabled(true);
}
Q_SLOT void ModeCheckDlg::handleResultsHistory(QVariantMap Mapstr, QSqlQuery sql)
{
updateModelShowHistory(sql);
QString m_strLast = ui.label_Time1_History->text();
QString m_endLast = ui.label_Time2_History->text();
m_totlaNum = Mapstr.value("sum").toInt();
int nlimit = Mapstr.value("limit").toInt();
int nIndex = Mapstr.value("nIndex").toInt();
QString m_Title = tr("起始时间:%1 到 结束时间:%2 的历史记录 共%3条").arg(m_strLast).arg(m_endLast).arg(m_totlaNum);
ui.label_Number->setText(QString::number(m_totlaNum));
QFont font;
font.setPixelSize(14);
font.setBold(true);
ui.label_Tab2_Title->setFont(font);
ui.label_Tab2_Title->setText(m_Title);
ui.Next_checkShengchang->setDisabled(false);
m_totalPage = (m_totlaNum / nlimit);
if (m_totlaNum > 0)
{
m_totalPage = m_totalPage + 1;
m_page = 1;
nIndex = m_totlaNum;
}
else
{
m_totlaNum = 0;
m_page = 0;
}
ui.showPage_Label_Checkdata->setText(tr("第%1页 共%2页").arg(m_page).arg(m_totalPage));
ui.showNum_Label_Checkdata->setText(tr("共显示%1条记录").arg(nIndex));
//onShowMessage(tr("数据查询完成"));
}
void ModeCheckDlg::updateModelShowHistory(QSqlQuery &sql)
{
QStandardItemModel *testmodel = new QStandardItemModel;
ui.tableView_checkShengchang->setModel(testmodel);//先将模型插入后在一次性显示 可以提高显示速率
ui.tableView_checkShengchang->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui.tableView_checkShengchang->setSelectionBehavior(QAbstractItemView::SelectRows);
ui.tableView_checkShengchang->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);//自适应行宽
ui.tableView_checkShengchang->horizontalHeader()->setMaximumHeight(100);
if (m_tableModel == NULL)
m_tableModel = new QStandardItemModel;
m_tableModel->clear();
ui.CheckDlg_label_Pic->clear();
m_tableModel->setHorizontalHeaderItem(0, new QStandardItem(tr("日期时间")));
m_tableModel->setHorizontalHeaderItem(1, new QStandardItem(tr("匹配型号")));
m_tableModel->setHorizontalHeaderItem(2, new QStandardItem(tr("相似度")));
m_tableModel->setHorizontalHeaderItem(3, new QStandardItem(tr("消耗时间s")));
m_tableModel->setHorizontalHeaderItem(4, new QStandardItem(tr("直径mm")));
m_tableModel->setHorizontalHeaderItem(5, new QStandardItem(tr("厚度mm")));
m_tableModel->setHorizontalHeaderItem(6, new QStandardItem(tr("缩略图")));
m_tableModel->setHorizontalHeaderItem(7, new QStandardItem(tr("uid")));
int nIndex = 0;
while (sql.next())
{
/*这里下面是统计查询到的通道对应的产品总数*/
int uid = sql.value("uid").toInt();
QString time = sql.value("time").toString();
QString model = sql.value("model").toString();
double dCorrelate = sql.value("correlate").toDouble();
QString correlate;
if (dCorrelate >= 1.7976931348623158e+308)
dCorrelate = 0;
correlate = QString::number(dCorrelate * 100, 'f', 3) + "%";
double dDetecttime = sql.value("detecttime").toDouble();
QString detecttime = QString::number(dDetecttime, 'f', 3);
double dDiameter = sql.value("diameter").toDouble();
QString diameter = QString::number(dDiameter, 'f', 3);
double dHight = sql.value("hight").toDouble();
QString hight = QString::number(dHight, 'f', 3);
QByteArray pic = sql.value("pic").toByteArray();
QImage img = QImage::fromData(pic);
QSize s = img.size();
QPixmap m_Pix = QPixmap::fromImage(img);
ui.CheckDlg_label_Pic->setPixmap(m_Pix.scaled(WHEEL_PIC_SIZE, WHEEL_PIC_SIZE));
m_tableModel->setItem(nIndex, 0, new QStandardItem(time));
m_tableModel->setItem(nIndex, 1, new QStandardItem(model));
m_tableModel->setItem(nIndex, 2, new QStandardItem(correlate));
m_tableModel->setItem(nIndex, 3, new QStandardItem(detecttime));
m_tableModel->setItem(nIndex, 4, new QStandardItem(diameter));
m_tableModel->setItem(nIndex, 5, new QStandardItem(hight));
m_tableModel->setItem(nIndex, 6, new QStandardItem(QIcon(m_Pix.scaled(50, 50)), ""));
m_tableModel->setItem(nIndex, 7, new QStandardItem(QString("%1").arg(uid)));
nIndex++;
}
ui.showNum_Label_Checkdata->setText(tr("共显示%1条记录").arg(nIndex));
ui.tableView_checkShengchang->setModel(m_tableModel);
ui.tableView_checkShengchang->hideColumn(7);
ui.tableView_checkShengchang->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
connect(ui.tableView_checkShengchang, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onTableViewClick(QModelIndex)));
delete testmodel;
testmodel = NULL;
}
void ModeCheckDlg::SetModelNames(QStringList models)
{
ui.comboBox_Model->clear();
ui.comboBox_Model->addItem(tr("全部"));
if (!models.contains("NG"))
ui.comboBox_Model->addItem(tr("NG"));
ui.comboBox_Model->addItems(models);
if (_pCompleter)
delete _pCompleter;
_pCompleter = new QCompleter(models);
_pCompleter->setCaseSensitivity(Qt::CaseInsensitive);
ui.comboBox_Model->setCompleter(_pCompleter);
}
Q_SLOT void ModeCheckDlg::onTableViewClick(QModelIndex mIndex)
{
QString strObj = sender()->objectName();
if ("tableView_checkShengchang" == strObj) {
if (m_tableModel)
{
QModelIndex ItemIndex = m_tableModel->index(mIndex.row(), 7);
QString strdata = ItemIndex.data().toString();
if (m_pDb)
{
QVariantMap m_value;
m_value.insert(_CHECK_UID_, strdata);
m_value.insert(_CHECK_TYPE_, EMT_CHECK_BY_UID);
QString seletcStr = m_pDb->genCheckStr(m_value);
/*启用线程查询数据 减少界面卡顿*/
CheckThread *workerThread = new CheckThread(this);
workerThread->setCheckStr(m_pDb, seletcStr);
connect(workerThread, SIGNAL(resultReady(QSqlQuery)), this, SLOT(onSlowPixmap(QSqlQuery)));
connect(workerThread, &CheckThread::finished, workerThread, &QObject::deleteLater);
workerThread->start();
}
}
}
}
Q_SLOT void ModeCheckDlg::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;
}
ui.CheckDlg_label_Pic->setPixmap(m_Pix.scaled(scarew, scareh));
}
nFlag = false;
}
void ModeCheckDlg::CheckDataHistoryByDate(QString m_strLast, QString m_endLast, QString modelname)
{
QSqlQuery sql;
QVariantMap m_Value;
m_Value.insert(_CHECK_TYPE_, EMT_CHECK_BY_NAME);
m_Value.insert(_CHECK_TIME1_, m_strLast);
m_Value.insert(_CHECK_TIME2_, m_endLast);
m_Value.insert(_CHECK_NAME_, modelname);
m_Value.insert(_CHECK_COUNT_, 1);
if (modelname == "*")
m_Value.insert(_CHECK_TYPE_, EMT_CHECK_BY_SAE);
else
m_Value.insert(_CHECK_TYPE_, EMT_CHECK_BY_NAME);
QString strString;
strString = m_pDb->genCheckStr(m_Value);
int nlimit = ui.LineNumber_checkShengchang->text().toInt();
if (nlimit <= 0)
{
nlimit = 10;
ui.LineNumber_checkShengchang->setText("10");
}
m_totlaNum = 0;
m_PrevNum = 0;
QString strStringcheck;
if (modelname == "*")
strStringcheck = QString("select * from wftable where time >'%1' and time <'%2' LIMIT %4 OFFSET %5").arg(m_strLast).arg(m_endLast).arg(nlimit).arg(m_PrevNum);
else
strStringcheck = QString("select * from wftable where time >'%1' and time <'%2' and model = '%3' LIMIT %4 OFFSET %5").arg(m_strLast).arg(m_endLast).arg(modelname).arg(nlimit).arg(m_PrevNum);
QVariantMap m_mapVarite;
m_mapVarite.insert("SqlCount", strString);
m_mapVarite.insert("SqlCheck", strStringcheck);
m_mapVarite.insert("limit", nlimit);
emit operateHistory(m_mapVarite);
}
Q_SLOT void ModeCheckDlg::onProgressForTsk(QVariantMap m_map)
{
QString nType = m_map.value("Type").toString();
if (nType == "start")
{
QString strMsg = m_map.value("msg", tr("正在查询数据")).toString();
m_Progressdlg.setWindowTitle(strMsg);
m_Progressdlg.Start(50, 150),
m_Progressdlg.show();
}
else
{
m_Progressdlg.Stop();
m_Progressdlg.hide();
}
}
Q_SLOT void ModeCheckDlg::SlotEditTime()
{
QObject *obj = sender();
QString str = obj->objectName();
if (str == "pushButton_Set1_History")
{
QTimeDlg dlg(NULL);
dlg.SetDateTime(m_startDate_History);
if (dlg.exec() == QDialog::Accepted)
{
dlg.GetDateTime(m_startDate_History);
QString m_endLast = m_startDate_History.toString("yyyy-MM-dd hh:mm:ss");
ui.label_Time1_History->setText(m_endLast);
}
}
else if (str == "pushButton_Set2_History")
{
QTimeDlg dlg;
dlg.SetDateTime(m_endDate_History);
if (dlg.exec() == QDialog::Accepted)
{
dlg.GetDateTime(m_endDate_History);
QString m_endLast = m_endDate_History.toString("yyyy-MM-dd hh:mm:ss");
ui.label_Time2_History->setText(m_endLast);
}
}
}
Q_SLOT void ModeCheckDlg::onCheckButton()
{
QObject *obj = sender();
QString str = obj->objectName();
if ("pushButton_Checkdata" == str)//查询生产数据
{/*这里需要做数据分页显示 减少内存泄露*/
static bool checkflags = false;
if (checkflags == false)
{
checkflags = true;
QString strBanci = ui.comboBox_Banci->currentText();
QString modelName = ui.comboBox_Model->currentText();
if (m_Totaltime.contains(strBanci))
{
if (m_startDate_History.date() > m_endDate_History.date())
{
if (m_Totaltime.value(strBanci).m_startTime > m_Totaltime.value(strBanci).m_endTime)
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的班次时间是隔夜的,请您重新选择一下当前查询的日期,再查询"));
checkflags = false;
return;
}
else
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新选择一下当前查询的日期,再查询"));
checkflags = false;
return;
}
}
}
else
{
if (m_startDate_History.date() > m_endDate_History.date())
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新选择一下当前查询的日期,再查询"));
checkflags = false;
return;
}
}
QString m_strLast = ui.label_Time1_History->text();
QString m_endLast = ui.label_Time2_History->text();
//QString strMsg = tr("查询了%1-%2的生产数据").arg(m_strLast).arg(m_endLast);
//SaveLog(strMsg);
QApplication::setOverrideCursor(Qt::WaitCursor);
QFont font;
font.setPixelSize(14);
ui.label_Tab2_Title->setFont(font);
QString m_Title = tr("起始时间:%1 到 结束时间:%2 的历史记录").arg(m_strLast).arg(m_endLast);
ui.label_Tab2_Title->setText(m_Title);
if (modelName == tr("全部"))
CheckDataHistoryByDate(m_strLast, m_endLast, "*");
else
CheckDataHistoryByDate(m_strLast, m_endLast, modelName);
QApplication::restoreOverrideCursor();
checkflags = false;
}
else
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("正在查询数据,请稍后"));
}
}
else if ("pushButton_SaveHistory" == str)
{
if (m_tableModel == NULL)
return;
if (m_tableModel->rowCount() <= 0)
{
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
return;
}
QString filename = QString("History_%1.csv").arg(QDateTime::currentDateTime().toString("yyyy_MM_dd"));
QString fileTitle = tr("请选择保存文件的路径");
QFileDialog *fileDialog = new QFileDialog(NULL, fileTitle, filename);
fileDialog->setWindowTitle("Save As");
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
fileDialog->setFileMode(QFileDialog::AnyFile);
fileDialog->setViewMode(QFileDialog::Detail);
fileDialog->setGeometry(10, 30, 300, 200);
fileDialog->setDirectory(".");
fileDialog->setNameFilter("Execl(*.csv)");
if (fileDialog->exec() == QDialog::Accepted)
{
QString path = fileDialog->selectedFiles()[0];
QString strString = getHistoryCheckString();
QSaveCSVThread *workerThread = new QSaveCSVThread(this);
workerThread->setInform(ui.label_Tab2_Title->text(), "username");
workerThread->setCheckStr(m_pDb, strString, path, 0);
connect(workerThread, SIGNAL(resultReady(int)), this, SLOT(onSaveCSVDone(int)));
connect(workerThread, &QSaveCSVThread::finished, workerThread, &QObject::deleteLater);
workerThread->start();
onEventLoop(tr("正在导出数据,请稍等"));
//QString strMsg = tr("导出了%1-%2的生产数据").arg(ui.label_Time1_History->text()).arg(ui.label_Time2_History->text());
//SaveLog(strMsg);
onMessageBox(QMessageBox::Information, tr("提示"), tr("数据导出完成"));
}
if (fileDialog) {
delete fileDialog;
fileDialog = NULL;
}
}
}
bool ModeCheckDlg::onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString strAtl, int onlyOK)
{
QMessageBox::StandardButton button = QMessageBox::Ok;
if (onlyOK == 1)
button = QMessageBox::Cancel;
QMessageBox infobox(ntype, strTitle, strAtl, QMessageBox::Ok | button, NULL);
infobox.setWindowIcon(QIcon(":/image/leaper"));
infobox.setButtonText(QMessageBox::Ok, tr("确认"));
infobox.setButtonText(QMessageBox::Cancel, tr("取消"));
return (infobox.exec() == QMessageBox::Ok);
}
bool ModeCheckDlg::SaveDataToCSV(QString filePath, QMap<QString, int> &m_mapTable)
{
QFile file(filePath);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))// 追加写入数据
return false;
QTextStream out(&file);
QString tableData;
QString m_startStr = m_startDate_Count.toString("yyyy-MM-dd ") + m_startTime.toString("hh:mm:ss");
QString m_endStr = m_endDate_Count.toString("yyyy-MM-dd ") + m_endTime.toString("hh:mm:ss");
out << tr("从%1到%2统计的数据如下").arg(m_startStr).arg(m_endStr) << "\n";
out << tr("序号") << "," << tr("型号") << "," << tr("数量") << "\n";
int index = 1;
int sum = 0;
for (QMap<QString, int>::iterator its = m_mapTable.begin(); its != m_mapTable.end(); ++its)
{
out << (index++) << ",";
tableData = its.key();
out << tableData << ",";
out << QString::number(m_mapTable[tableData]) << ",";
sum += m_mapTable[tableData];
out << "\n";
}
if (!m_mapTable.contains(QString("NG")))
{
out << (index++) << "," << QString("NG") << "," << 0 << "\n";
}
out << (index++) << "," << tr("总数") << "," << QString::number(sum) << "\n";
out << tr("时间:") << "," << QDateTime::currentDateTime().toString("yyyy-MM-dd") << "," << QDateTime::currentDateTime().toString("hh:mm:ss") << "\n";
out << tr("用户:") << "," << "username" << "," << "\n";
file.close();
return true;
}
void ModeCheckDlg::onEventLoop(QString strMsg)
{
WaitingDialog dlg;
dlg.setWindowModality(Qt::ApplicationModal);
dlg.setWindowIcon(QIcon(":/image/leaper"));
dlg.setWindowTitle(strMsg);
dlg.Start(50, 150),
dlg.show();
QEventLoop eventloop;
connect(this, SIGNAL(sgFinish()), &eventloop, SLOT(quit()));
eventloop.exec();
}
Q_SLOT void ModeCheckDlg::SlotCombox(int index)
{
QObject *strobj = sender();
QString objname = strobj->objectName();
if ("comboBox_Banci" == objname)
{
QString str = ui.comboBox_Banci->currentText();
if (m_Totaltime.contains(str))
{
if (m_Totaltime.value(str).m_startTime >= m_Totaltime.value(str).m_endTime)
{
QDate m = m_endDate_History.date();
m = m.addDays(-1);
QString strdata = m.toString("yyyy-MM-dd");
m_startDate_History.setDate(m);
}
else
{
m_startDate_History.setDate(m_endDate_History.date());
}
if (m_startDate_History.date() > m_endDate_History.date())
m_startDate_History.setDate(m_endDate_History.date());
m_startDate_History.setTime(m_Totaltime.value(str).m_startTime);//
m_endDate_History.setTime(m_Totaltime.value(str).m_endTime);//
}
else
{
if (str == tr("全天"))
{
QString strTime = nstartTime.toString("hh:mm:ss");
if (m_startDate_History.date() > m_endDate_History.date())
m_startDate_History.setDate(m_endDate_History.date());
m_startDate_History.setTime(m_startTime);
m_endDate_History.setTime(nEndTime);
QString strStart = m_startDate_History.toString("yyyy-MM-dd hh:mm:ss");
}
}
ui.label_Time1_History->setText(m_startDate_History.toString("yyyy-MM-dd hh:mm:ss"));
ui.label_Time2_History->setText(m_endDate_History.toString("yyyy-MM-dd hh:mm:ss"));
}
}
Q_SLOT void ModeCheckDlg::onUpdateTableViewShow(QSqlQuery sql)
{
updateModelShowHistory(sql);
}
Q_SLOT void ModeCheckDlg::onSaveCSVDone(int)
{
emit(sgFinish());
}

@ -0,0 +1,79 @@
#ifndef _MODECHECKDLG_H_
#define _MODECHECKDLG_H_
#include <QWidget>
#include "ui_ModeCheckDlg.h"
#include "checkdata.h"
#include "QThread"
#include "DetectDataDB.h"
#include "QCompleter"
#include "waitingdialog.h"
#include <QString>
#include <QMessageBox>
/*识别数据查询页面*/
class ModeCheckDlg : public QWidget
{
Q_OBJECT
public:
ModeCheckDlg(QWidget *parent = Q_NULLPTR);
~ModeCheckDlg();
void setDBPtr(class DetectDataDB *ptr);//
void initParam(QMap<QString, TimeStruct> timetable, QStringList names);
protected:
QString getHistoryCheckString();
Q_SLOT void onHistoryButton();
void cleanHistorycal();
Q_SLOT void handleResultsHistory(QVariantMap Mapstr, QSqlQuery sql);
void updateModelShowHistory(QSqlQuery &sql);
void SetModelNames(QStringList models);
Q_SLOT void onTableViewClick(QModelIndex mIndex);
Q_SLOT void onSlowPixmap(QSqlQuery sql);
void CheckDataHistoryByDate(QString m_strLast, QString m_endLast, QString modelname);
Q_SLOT void onProgressForTsk(QVariantMap m_map);
Q_SLOT void SlotEditTime();
Q_SLOT void onCheckButton();
bool onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString strAtl, int onlyOK = 0);
bool SaveDataToCSV(QString filePath, QMap<QString, int> &m_mapTable);
void onEventLoop(QString strMsg);
Q_SLOT void SlotCombox(int index);
Q_SLOT void onUpdateTableViewShow(QSqlQuery sql);
Q_SLOT void onSaveCSVDone(int);
signals:
void operateHistory(QVariantMap m_map);
void sgFinish();
private:
Ui::ModeCheckDlg ui;
int m_PrevNum{ 0 };
int m_NextNum{ 0 };
int m_totlaNum{ 0 };
int m_page{ 0 }, m_totalPage{ 0 };
int m_PrevNumlog{ 0 };
int m_NextNumlog{ 0 };
int m_totlaNumlog{ 0 };
int m_pagelog{ 0 }, m_totalPagelog{ 0 };
QThread m_WorkThreadCheckHistory;
CheckData *m_WorkHistory{ nullptr };
QCompleter *_pCompleter{ nullptr };
class DetectDataDB *m_pDb{ nullptr };
QStandardItemModel *m_tableModel{ nullptr };
QDateTime m_startDate_Count, m_endDate_Count;
QDateTime m_startDate_History, m_endDate_History;
QTime m_startTime, m_endTime;
QTime nstartTime;
QTime nEndTime;
WaitingDialog m_Progressdlg;
QMap<QString, TimeStruct> m_Totaltime;//班次时间表
};
#endif

@ -0,0 +1,866 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ModeCheckDlg</class>
<widget class="QWidget" name="ModeCheckDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>830</width>
<height>632</height>
</rect>
</property>
<property name="windowTitle">
<string>ModeCheckDlg</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_18">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
</property>
<property name="text">
<string>开始日期时间:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_Time1_History">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>2017-11-11 11:11:11</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Set1_History">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 255, 0);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>设置开始时间</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_17">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
</property>
<property name="text">
<string>结束日期时间:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_Time2_History">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>2017-11-11 11:11:11</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Set2_History">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 255, 0);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>设置结束时间</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_14">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(170, 170, 127);
font: 75 14pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>筛选型号</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_Checkdata">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 255, 0);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>查询</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_Model">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
</string>
</property>
<item>
<property name="text">
<string>所有</string>
</property>
</item>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="comboBox_Banci">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<item>
<property name="text">
<string>全天</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_15">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(170, 170, 127);
font: 75 14pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>生产班次</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="pushButton_SaveHistory">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 255, 0);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>导出CSV</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_16">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(170, 170, 127);
font: 75 14pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>查询数量</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_Number">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_Tab2_Title">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>标题</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QTableView" name="tableView_checkShengchang">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="1" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="CheckDlg_label_Pic">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="midLineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>双击单条记录显示图片</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>117</width>
<height>52</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labelTitle_Checkdata">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>显示数据数(条)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="LineNumber_checkShengchang">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>50</string>
</property>
<property name="maxLength">
<number>4</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Prev_checkShengchang">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>上一页</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="showPage_Label_Checkdata">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="Next_checkShengchang">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>下一页</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>68</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="showNum_Label_Checkdata">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

@ -0,0 +1,366 @@
#include "ModeCountDlg.h"
#include "QMap"
#include "QProgressDialog"
#include "QSqlQuery"
#include "qtimedlg.h"
#include <QDebug>
#include "QFileDialog"
#pragma execution_character_set("utf-8")
ModeCountDlg::ModeCountDlg(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
m_GridLayout = new QGridLayout;
reportdlg = new QReportWidget;
m_GridLayout->addWidget(reportdlg);
m_countwidget = new QWidget;
Hbox = new QVBoxLayout;
m_GridLayout->setMargin(0);
m_GridLayout->addLayout(Hbox, 0, 1);
m_countwidget->setLayout(m_GridLayout);
m_WorkCount = new CountData;
m_WorkCount->moveToThread(&m_WorkThreadCount);
connect(&m_WorkThreadCount, &QThread::finished, m_WorkCount, &QObject::deleteLater);
connect(this, &ModeCountDlg::operateCount, m_WorkCount, &CountData::doWork);
connect(m_WorkCount, &CountData::resultReady, this, &ModeCountDlg::handleResultsCount);
connect(m_WorkCount, SIGNAL(sgShowMsg(QString)), this, SLOT(onShowMessage(QString)));
connect(m_WorkCount, &CountData::sgShowProgress, this, &ModeCountDlg::onProgressForTsk);
m_WorkThreadCount.start();
qDebug() << "start thread m_WorkThreadCount";
nstartTime.setHMS(0, 0, 0);
nEndTime.setHMS(23, 59, 59);
m_startDate_Count = QDateTime::currentDateTime();
m_endDate_Count = QDateTime::currentDateTime();
ui.label_Time1_Count->setText(m_startDate_Count.toString("yyyy-MM-dd hh:mm:ss"));
ui.label_Time2_Count->setText(m_endDate_Count.toString("yyyy-MM-dd hh:mm:ss"));
if (reportdlg)
reportdlg->ClearData();
connect(ui.pushButton_Set1_Count, SIGNAL(clicked()), this, SLOT(SlotEditTime()));
connect(ui.pushButton_Set2_Count, SIGNAL(clicked()), this, SLOT(SlotEditTime()));
connect(ui.pushButton_Checkdata_Calculate, SIGNAL(clicked()), this, SLOT(onCheckButton()));
connect(ui.pushButton_SaveCalculate, SIGNAL(clicked()), this, SLOT(onCheckButton()));
connect(ui.comboBox_Banci_Calculate, SIGNAL(currentIndexChanged(int)), this, SLOT(SlotCombox(int)));
m_Progressdlg.setWindowModality(Qt::ApplicationModal);
m_Progressdlg.setWindowIcon(QIcon(":/image/leaper"));
m_IsRunCountTsk = false;
ui.scrollArea->setLayout(m_GridLayout);
}
ModeCountDlg::~ModeCountDlg()
{
if (m_countwidget)
{
delete m_countwidget;
m_countwidget = NULL;
}
if (m_WorkThreadCount.isRunning())
{
qDebug() << "delete m_WorkThreadCount";
m_WorkThreadCount.quit();
m_WorkThreadCount.wait(50);
qDebug() << "delete m_WorkThreadCount end";
}
}
void ModeCountDlg::setDBPtr(class DetectDataDB *ptr)
{
m_pDb = ptr;
if(m_WorkCount)
m_WorkCount->setDB(m_pDb);
}
void ModeCountDlg::initParam(QMap<QString, TimeStruct> timetable, QStringList names)
{
m_Totaltime = timetable;
ui.comboBox_Banci_Calculate->clear();
ui.comboBox_Banci_Calculate->addItem(tr("全天"));
ui.comboBox_Banci_Calculate->addItems(m_Totaltime.keys());
}
Q_SLOT void ModeCountDlg::handleResultsCount(const QString &result, const QMap<QString, int> *p)
{
reportdlg->ClearData();
reportdlg->setTitle(tr("统计结果 "));
if (p == NULL) {
m_IsRunCountTsk = false;
return;
}
m_CountNumber = *p;
reportdlg->SetData(QMap<QString, int>(*p)/*m_CountNumber*/);
if (!p->contains(QString("NG")))
reportdlg->AppendData(QString("NG"), 0, true);
reportdlg->AppendData(tr("总数"), result.toInt(), true);
reportdlg->UpdateTableView();
//onShowMessage(tr("统计完成"));
m_IsRunCountTsk = false;
if (p)
delete p;
}
void ModeCountDlg::CheckDataByDate(QString m_strLast, QString m_endLast)
{
if (m_IsRunCountTsk != false)
{
return;
}
m_IsRunCountTsk = true;
m_CountNumber.clear();
m_channels.clear();
QProgressDialog progress;
progress.setWindowModality(Qt::ApplicationModal);
progress.setWindowTitle(tr("查询进度"));
progress.setWindowIcon(QIcon(":/image/leaper"));
progress.setLabelText(tr("数据查询中,请稍后....."));
progress.setCancelButton(0);
QSqlQuery sql;
QVariantMap m_Value;
m_Value.insert(_CHECK_TYPE_, EMT_CHECK_BY_COUNT);
m_Value.insert(_CHECK_TIME1_, m_strLast);
m_Value.insert(_CHECK_TIME2_, m_endLast);
m_Value.insert("CheckType", "Count");
QString strCheck = m_pDb->genCheckStr(m_Value);
m_Value.insert(_CHECK_COUNT_, 1);
QString strCount = m_pDb->genCheckStr(m_Value);
QVariantMap m_map;
m_map.insert("SqlCount", strCount);
m_map.insert("SqlCheck", strCheck);
emit operateCount(m_map);
}
Q_SLOT void ModeCountDlg::SlotEditTime()
{
QObject *obj = sender();
QString str = obj->objectName();
if (str == "pushButton_Set1_Count")
{
QTimeDlg dlg;
dlg.SetDateTime(m_startDate_Count);
dlg.setWindowModality(Qt::ApplicationModal);
if (dlg.exec() == QDialog::Accepted)
{
dlg.GetDateTime(m_startDate_Count);
QString m_strLast = m_startDate_Count.toString("yyyy-MM-dd hh:mm:ss");
ui.label_Time1_Count->setText(m_strLast);
}
}
else if (str == "pushButton_Set2_Count")
{
QTimeDlg dlg;
dlg.SetDateTime(m_endDate_Count);
if (dlg.exec() == QDialog::Accepted)
{
dlg.GetDateTime(m_endDate_Count);
QString m_endLast = m_endDate_Count.toString("yyyy-MM-dd hh:mm:ss");
ui.label_Time2_Count->setText(m_endLast);
}
}
}
Q_SLOT void ModeCountDlg::onProgressForTsk(QVariantMap m_map)
{
QString nType = m_map.value("Type").toString();
if (nType == "start")
{
QString strMsg = m_map.value("msg", tr("正在查询数据")).toString();
m_Progressdlg.setWindowTitle(strMsg);
m_Progressdlg.Start(50, 150),
m_Progressdlg.show();
}
else
{
m_Progressdlg.Stop();
m_Progressdlg.hide();
}
}
Q_SLOT void ModeCountDlg::onCheckButton()
{
QObject *obj = sender();
QString str = obj->objectName();
if ("pushButton_Checkdata_Calculate" == str)
{
static bool checkflags = false;
if (checkflags == false)
{
checkflags = true;
QString strBanci = ui.comboBox_Banci_Calculate->currentText();
if (m_Totaltime.contains(strBanci))
{
if (m_startDate_Count.date() > m_endDate_Count.date())
{
if (m_Totaltime.value(strBanci).m_startTime > m_Totaltime.value(strBanci).m_endTime)
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的班次时间是隔夜的,请您重新选择一下当前查询的日期,再查询"));
checkflags = false;
return;
}
else
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新起始日期,再查询"));
checkflags = false;
return;
}
}
}
else
{
if (m_startDate_Count.date() > m_endDate_Count.date())
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新选择一下当前查询的日期,再查询"));
checkflags = false;
return;
}
}
QString m_strLast = ui.label_Time1_Count->text();
QString m_endLast = ui.label_Time2_Count->text();
//QString strMsg = tr("查询了%1-%2的统计数据").arg(ui.label_Time1_Count->text()).arg(ui.label_Time2_Count->text());
//SaveLog(strMsg);
QApplication::setOverrideCursor(Qt::WaitCursor);
CheckDataByDate(m_strLast, m_endLast);
QApplication::restoreOverrideCursor();
checkflags = false;
}
else
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("正在查询数据,请稍后"));
}
}
else if ("pushButton_SaveCalculate" == str)
{
if (m_CountNumber.size() <= 0)
{
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
return;
}
QString filename = QString("Data_%1.csv").arg(QDateTime::currentDateTime().toString("yyyy_MM_dd"));
QString fileTitle = tr("请选择保存文件的路径");
QFileDialog *fileDialog = new QFileDialog(NULL, fileTitle, filename);
fileDialog->setWindowTitle("Save As");
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
fileDialog->setFileMode(QFileDialog::AnyFile);
fileDialog->setViewMode(QFileDialog::Detail);
fileDialog->setGeometry(10, 30, 300, 200);
fileDialog->setDirectory(".");
fileDialog->setNameFilter("Execl(*.csv)");
if (fileDialog->exec() == QDialog::Accepted)
{
QString path = fileDialog->selectedFiles()[0];
if (SaveDataToCSV(path, m_CountNumber))
onMessageBox(QMessageBox::Information, tr("提示"), tr("数据导出完成"));
//QString strMsg = tr("导出了%1-%2的统计数据").arg(ui.label_Time1_Count->text()).arg(ui.label_Time2_Count->text());
//SaveLog(strMsg);
}
if (fileDialog) {
delete fileDialog;
fileDialog = NULL;
}
}
}
bool ModeCountDlg::onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString strAtl, int onlyOK)
{
QMessageBox::StandardButton button = QMessageBox::Ok;
if (onlyOK == 1)
button = QMessageBox::Cancel;
QMessageBox infobox(ntype, strTitle, strAtl, QMessageBox::Ok | button, NULL);
infobox.setWindowIcon(QIcon(":/image/leaper"));
infobox.setButtonText(QMessageBox::Ok, tr("确认"));
infobox.setButtonText(QMessageBox::Cancel, tr("取消"));
return (infobox.exec() == QMessageBox::Ok);
}
bool ModeCountDlg::SaveDataToCSV(QString filePath, QMap<QString, int> &m_mapTable)
{
QFile file(filePath);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))// 追加写入数据
return false;
QTextStream out(&file);
QString tableData;
QString m_startStr = m_startDate_Count.toString("yyyy-MM-dd ") + m_startTime.toString("hh:mm:ss");
QString m_endStr = m_endDate_Count.toString("yyyy-MM-dd ") + m_endTime.toString("hh:mm:ss");
out << tr("从%1到%2统计的数据如下").arg(m_startStr).arg(m_endStr) << "\n";
out << tr("序号") << "," << tr("型号") << "," << tr("数量") << "\n";
int index = 1;
int sum = 0;
for (QMap<QString, int>::iterator its = m_mapTable.begin(); its != m_mapTable.end(); ++its)
{
out << (index++) << ",";
tableData = its.key();
out << tableData << ",";
out << QString::number(m_mapTable[tableData]) << ",";
sum += m_mapTable[tableData];
out << "\n";
}
if (!m_mapTable.contains(QString("NG")))
{
out << (index++) << "," << QString("NG") << "," << 0 << "\n";
}
out << (index++) << "," << tr("总数") << "," << QString::number(sum) << "\n";
out << tr("时间:") << "," << QDateTime::currentDateTime().toString("yyyy-MM-dd") << "," << QDateTime::currentDateTime().toString("hh:mm:ss") << "\n";
out << tr("用户:") << "," << "username" << "," << "\n";
file.close();
return true;
}
Q_SLOT void ModeCountDlg::SlotCombox(int index)
{
QObject *strobj = sender();
QString objname = strobj->objectName();
if ("comboBox_Banci_Calculate" == objname)
{
QString str = ui.comboBox_Banci_Calculate->currentText();
if (m_Totaltime.contains(str))
{
if (m_Totaltime.value(str).m_startTime >= m_Totaltime.value(str).m_endTime)
{
QDate m = m_endDate_Count.date();
m = m.addDays(-1);
QString strdata = m.toString("yyyy-MM-dd");
m_startDate_Count.setDate(m);
}
else
{
m_startDate_Count.setDate(m_endDate_Count.date());
}
if (m_startDate_Count.date() > m_endDate_Count.date())
m_startDate_Count.setDate(m_endDate_Count.date());
m_startDate_Count.setTime(m_Totaltime.value(str).m_startTime);//
m_endDate_Count.setTime(m_Totaltime.value(str).m_endTime);//
}
else
{
if (str == tr("全天"))
{
QString strTime = nstartTime.toString("hh:mm:ss");
if (m_startDate_Count.date() > m_endDate_Count.date())
m_startDate_Count.setDate(m_endDate_Count.date());
m_startDate_Count.setTime(m_startTime);
m_endDate_Count.setTime(nEndTime);
QString strStart = m_startDate_Count.toString("yyyy-MM-dd hh:mm:ss");
}
}
ui.label_Time1_Count->setText(m_startDate_Count.toString("yyyy-MM-dd hh:mm:ss"));
ui.label_Time2_Count->setText(m_endDate_Count.toString("yyyy-MM-dd hh:mm:ss"));
}
}
Q_SLOT void ModeCountDlg::onSaveCSVDone(int)
{
emit(sgFinish());
}

@ -0,0 +1,62 @@
#ifndef _MODECOUNTDLG_H_
#define _MODECOUNTDLG_H_
#include <QWidget>
#include "ui_ModeCountDlg.h"
#include "qreportwidget.h"
#include "DetectDataDB.h"
#include "QThread"
#include "countdata.h"
#include "waitingdialog.h"
#include <QMessageBox>
/*识别数据统计页面*/
class ModeCountDlg : public QWidget
{
Q_OBJECT
public:
ModeCountDlg(QWidget *parent = Q_NULLPTR);
~ModeCountDlg();
void setDBPtr(class DetectDataDB *ptr);//
void initParam(QMap<QString, TimeStruct> timetable, QStringList names);
protected:
Q_SLOT void handleResultsCount(const QString &result, const QMap<QString, int> *p);
void CheckDataByDate(QString m_strLast, QString m_endLast);
Q_SLOT void SlotEditTime();
Q_SLOT void onProgressForTsk(QVariantMap m_map);
Q_SLOT void onCheckButton();
bool onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString strAtl, int onlyOK = 0);
bool SaveDataToCSV(QString filePath, QMap<QString, int> &m_mapTable);
Q_SLOT void SlotCombox(int index);
Q_SLOT void onSaveCSVDone(int );
signals:
void operateCount(QVariantMap m_Map);
void sgFinish();
private:
Ui::ModeCountDlg ui;
class QGridLayout *m_GridLayout{ nullptr };
class QVBoxLayout *Hbox{ nullptr };
class QWidget *m_countwidget{ nullptr };
class QReportWidget *reportdlg{ nullptr };
bool m_IsRunCountTsk{ false };
QDateTime m_startDate_Count, m_endDate_Count;
QMap<QString, int> m_CountNumber;
QMap<int, QMap<QString, int>> m_channels;
class DetectDataDB *m_pDb{ nullptr };
QThread m_WorkThreadCount;
CountData *m_WorkCount{ nullptr };
WaitingDialog m_Progressdlg;
QTime m_startTime, m_endTime;
QTime nstartTime;
QTime nEndTime;
QMap<QString, TimeStruct> m_Totaltime;//班次时间表
};
#endif

@ -0,0 +1,385 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ModeCountDlg</class>
<widget class="QWidget" name="ModeCountDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>835</width>
<height>633</height>
</rect>
</property>
<property name="windowTitle">
<string>ModeCountDlg</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_22">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
</property>
<property name="text">
<string>开始日期时间:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_Time1_Count">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>2017-11-11 11:11:11</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Set1_Count">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 255, 0);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>设置开始时间</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_20">
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(170, 170, 127);</string>
</property>
<property name="text">
<string>结束日期时间:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_Time2_Count">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;
background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>2017-11-11 11:11:11</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Set2_Count">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 255, 0);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>设置结束时间</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_SaveCalculate">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 255, 0);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>导出CSV</string>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QLabel" name="label_21">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(170, 170, 127);
font: 75 14pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>生产班次</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboBox_Banci_Calculate">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<item>
<property name="text">
<string>所有</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_Checkdata_Calculate">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(85, 255, 0);
font: 75 12pt &quot;Consolas&quot;;</string>
</property>
<property name="text">
<string>查询</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>813</width>
<height>497</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

@ -0,0 +1,368 @@
#include "ValueCheckDlg.h"
#include "qstandarditemmodel.h"
#include "qmessagebox.h"
#include "qfontmetrics.h"
#include <QDir>
#include <QSettings>
#include "QSqlRecord"
#pragma execution_character_set("utf-8")
ValueCheckDlg::ValueCheckDlg(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
m_ViewImg = new lpImgViewer;
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());
setPageShow(0, 0);
}
ValueCheckDlg::~ValueCheckDlg()
{
if (m_tableModel)
{
delete m_tableModel;
m_tableModel = NULL;
}
if (m_ViewImg) {
delete m_ViewImg;
m_ViewImg = NULL;
}
}
void ValueCheckDlg::setDBPtr(class DetectDataDB *ptr)
{
m_db = ptr;
}
void ValueCheckDlg::initParam(QMap<QString, TimeStruct> timetable, QStringList names)
{
ui.comboBox_Model->clear();
ui.comboBox_Model->addItem(tr("全部"));
if (!names.contains("NG"))
ui.comboBox_Model->addItem(tr("NG"));
ui.comboBox_Model->addItems(names);
}
void ValueCheckDlg::createHeader()
{
QStringList listStr;
listStr.append(QObject::tr("时间"));
listStr.append(QObject::tr("型号"));
listStr.append(QObject::tr("角度"));
listStr.append(QObject::tr("分数"));
listStr.append(QObject::tr("圆心"));
listStr.append(QObject::tr("错误类型"));
listStr.append(QObject::tr("执行时间"));
listStr.append(QObject::tr("检测状态"));
m_tableModel->setHorizontalHeaderLabels(listStr);
}
void ValueCheckDlg::updateModelShowLog(QSqlQuery &sql)
{
m_tableModel->clear();
m_strMap.clear();
createHeader();
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);//自适应行宽
int nIndex = 0;
while (sql.next())
{
/*这里下面是统计查询到的通道对应的产品总数*/
QString time = sql.value("create_time").toString();
QString strModelName = sql.value("modeName").toString();
double dAngle = sql.value("angle").toDouble();
double dScore = sql.value("score").toDouble();
QString strCenter = sql.value("center").toString();
int errorType = sql.value("errorCode").toInt();
double runtime = sql.value("runtime").toDouble();
QString strFilename = sql.value("ImagePath").toString();//取出保存图片的路径名
QString runState = sql.value("runState").toString();
/*
listStr.append(QObject::tr("时间"));
listStr.append(QObject::tr("型号"));
listStr.append(QObject::tr("角度"));
listStr.append(QObject::tr("分数"));
listStr.append(QObject::tr("圆心"));
listStr.append(QObject::tr("错误类型"));
listStr.append(QObject::tr("执行时间"));
listStr.append(QObject::tr("检测状态"));
*/
m_tableModel->setItem(nIndex, 0, new QStandardItem(time));
m_tableModel->setItem(nIndex, 1, new QStandardItem(strModelName));
m_tableModel->setItem(nIndex, 2, new QStandardItem(QString("%1").arg(dAngle)));
m_tableModel->setItem(nIndex, 3, new QStandardItem(QString("%1").arg(dScore)));
m_tableModel->setItem(nIndex, 4, new QStandardItem(strCenter));
m_tableModel->setItem(nIndex, 5, new QStandardItem(QString("%1").arg(errorType)));
m_tableModel->setItem(nIndex, 6, new QStandardItem(QString("%1").arg(runtime)));
m_tableModel->setItem(nIndex, 7, new QStandardItem(runState));
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 ValueCheckDlg::getLimitNumber()
{
int num = ui.LineNumber_checkShengchang->text().toInt();
if (num > 1)
return num;
else
{
ui.LineNumber_checkShengchang->setText("50");
return 50;
}
}
int ValueCheckDlg::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 modelName = ui.comboBox_Model->currentText();
QString strSql = QString();
if (modelName == QObject::tr("全部"))
strSql = QString("select count(uid) from valueTable where create_time >'%1' and create_time <'%2' ").arg(startTime).arg(endTime);
else
strSql = QString("select count(uid) from valueTable where create_time >'%1' and create_time <'%2' and modeName == '%3'").arg(startTime).arg(endTime).arg(modelName);
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 ValueCheckDlg::onCheckOutData()
{
nTotlaNumber = 0;
nPrevNum = 0;
int limitNum = getLimitNumber();
nTotlaNumber = getTotalNumber();
onCheckOutData(limitNum, nPrevNum);
}
void ValueCheckDlg::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 modelName = ui.comboBox_Model->currentText();
QString strSql = QString();
if (modelName == QObject::tr("全部"))
strSql = QString("select * from valueTable where create_time >'%1' and create_time <'%2' LIMIT %3 OFFSET %4 ").arg(startTime).arg(endTime).arg(nLimitNum).arg(nPrenum);
else
strSql = QString("select * from valueTable where create_time >'%1' and create_time <'%2' and modeName == '%3' LIMIT %4 OFFSET %5 ").arg(startTime).arg(endTime).arg(modelName).arg(nLimitNum).arg(nPrenum);
QSqlQuery sqlquery;
m_db->checkoutData(strSql, sqlquery);
updateModelShowLog(sqlquery);
}
Q_SLOT void ValueCheckDlg::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 modelName = ui.comboBox_Model->currentText();
QString strSql = QString();
if (modelName == QObject::tr("全部"))
strSql = QString("select errorCode,count(uid) from valueTable where create_time >'%1' and create_time <'%2' group by errorCode order by errorCode").arg(startTime).arg(endTime);
else
strSql = QString("select errorCode,count(uid) from valueTable where create_time >'%1' and create_time <'%2' and modeName == '%3' group by errorCode order by errorCode").arg(startTime).arg(endTime).arg(modelName);
QSqlQuery sqlquery;
m_db->checkoutData(strSql, sqlquery);
QMap<QString, int> 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<QString, int>::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 ValueCheckDlg::setPageShow(int page, int totalPage)
{
QString str = QString(QObject::tr("第%1页 共%2页")).arg(page).arg(totalPage);
ui.showPage_Label_Checkdata->setText(str);
}
void ValueCheckDlg::changeEvent(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
{
ui.retranslateUi(this);
}
}
Q_SLOT void ValueCheckDlg::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)
{
QImage npixmap;
QString appPath = QApplication::applicationDirPath();
npixmap.load(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("无图片(或图片已过期/已被删除)"));
}
}
}
}
}
Q_SLOT void ValueCheckDlg::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();
{
int dhight = img.height();
int dwidth = img.width();
double nRate = img.width()*1.0 / img.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(img);
}
}
//label_6->setPixmap(m_Pix.scaled(WHEEL_PIC_SIZE, WHEEL_PIC_SIZE));
nFlag = false;
}

@ -0,0 +1,62 @@
#ifndef _VALUECHECKDLG_H_
#define _VALUECHECKDLG_H_
#include <QWidget>
#include "ui_ValueCheckDlg.h"
#include "qsqlquery.h"
#include "qstandarditemmodel.h"
#include "qtableview.h"
#include "qdatetimeedit.h"
#include "QTextBrowser.h"
#include "lpImgViewer.h"
#include <QTranslator>
#include "databasesql.h"
#include "DetectDataDB.h"
/*¶¨Î»Êý¾Ý²éÑ¯Ò³Ãæ*/
class ValueCheckDlg : public QWidget
{
Q_OBJECT
public:
ValueCheckDlg(QWidget *parent = Q_NULLPTR);
~ValueCheckDlg();
void setDBPtr(class DetectDataDB *ptr);//
void initParam(QMap<QString, TimeStruct> timetable, QStringList names);
private:
Q_SLOT void onChenckButton();
Q_SLOT void onCheckOutData();
Q_SLOT void onTBUI_ItemClick(const QModelIndex & index);
Q_SLOT void onSlowPixmap(QSqlQuery sql);
int getLimitNumber();
int getTotalNumber();
void createHeader();
void updateModelShowLog(QSqlQuery &sql);
void onCheckOutData(int nLimitNum, int nPrenum);
void setPageShow(int page, int totalPage);
protected:
virtual void changeEvent(QEvent *event);
private:
Ui::ValueCheckDlg ui;
QLabel *pShowName_label{ nullptr };
QLabel *check_showImg_label{ nullptr };
QTextBrowser *textBrowser{ nullptr };
DataBaseSql *m_db{ nullptr };
QStandardItemModel *m_tableModel{ nullptr };
QTableView *tableView{ nullptr };
QDateTimeEdit *pStartTimeEdit{ nullptr };
QDateTimeEdit *pEndTimeEdit{ nullptr };
QMap<QString, QString> m_strMap;
int nPrevNum;
int nTotlaNumber;
lpImgViewer *m_ViewImg{ nullptr };
};
#endif

@ -0,0 +1,404 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ValueCheckDlg</class>
<widget class="QWidget" name="ValueCheckDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>772</width>
<height>542</height>
</rect>
</property>
<property name="windowTitle">
<string>ValueCheckDlg</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QFrame" name="frame_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="opaqueResize">
<bool>true</bool>
</property>
<property name="handleWidth">
<number>1</number>
</property>
<property name="childrenCollapsible">
<bool>true</bool>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string>查询操作</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="1">
<widget class="QDateTimeEdit" name="dateTimeEdit_end"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>型号</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDateTimeEdit" name="dateTimeEdit_start"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox_Model">
<item>
<property name="text">
<string>全部</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>结束时间:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>起始时间:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="2">
<widget class="QPushButton" name="m_pbCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>查询</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>8</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="labelTitle_Checkdata">
<property name="text">
<string>显示数据数(条)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="LineNumber_checkShengchang">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>50</height>
</size>
</property>
<property name="text">
<string>50</string>
</property>
<property name="maxLength">
<number>4</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="Prev_checkShengchang">
<property name="text">
<string>上一页</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="showPage_Label_Checkdata">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="Next_checkShengchang">
<property name="text">
<string>下一页</string>
</property>
</widget>
</item>
<item row="2" column="5">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>151</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="6">
<widget class="QLabel" name="showNum_Label_Checkdata">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="7">
<widget class="QTableView" name="tableView">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item row="1" column="0" colspan="7">
<widget class="QLabel" name="check_fileName">
<property name="text">
<string>TextLabel</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>6</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QSplitter" name="splitter_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>3</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>统计</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="1" rowspan="2">
<widget class="QTextBrowser" name="textBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="m_pbCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>统计当前设置的查询时间记录总数</string>
</property>
<property name="text">
<string>统计</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="check_showImg_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>6</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

@ -0,0 +1,248 @@
#include "lpImgViewer.h"
#include <QResizeEvent>
#include <QWheelEvent>
#include <QRectF>
#include <iostream>
#include <QtDebug>
lpImgViewer::lpImgViewer(QWidget* parent /*= 0*/)
: QGraphicsView(parent), mpImgItem(NULL), mpInfoLabel(NULL), mpImg(NULL), m_scale(1.0), mMinScaleThre(0.01),
mIsFixedSizeScale(false), mFixedSizeScale(1.0), mImgScaleFunc(NULL), mIsAutoResetTransform(false)
{
QGraphicsScene* lpScene = new QGraphicsScene;
setScene(lpScene);
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
}
lpImgViewer::lpImgViewer(QGraphicsScene *scene, QWidget *parent /*= 0*/)
: QGraphicsView(scene, parent), mpImgItem(NULL), mpInfoLabel(NULL), mpImg(NULL), m_scale(1.0),
mIsFixedSizeScale(false), mFixedSizeScale(1.0), mImgScaleFunc(NULL), mIsAutoResetTransform(false)
{
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
}
void lpImgViewer::setInitScale(qreal val)
{
scaleImg2(val);
}
QGraphicsPixmapItem* lpImgViewer::setImg(QImage& img)
{
scene()->setBackgroundBrush(Qt::darkGray);
if (mpImg)
delete mpImg;
mpImg = new QImage(img);
if (!mpImgItem)
{
mpImgItem = scene()->addPixmap(QPixmap::fromImage(img, Qt::NoFormatConversion));
}
else
mpImgItem->setPixmap(QPixmap::fromImage(img, Qt::NoFormatConversion));
QPointF mpos = mpImgItem->pos();
if (mpos.x() == 0 && mpos.y() == 0)
{
mpImgItem->setPos(scene()->width() / 2, scene()->height() / 2);
}
mpImgItem->setOffset(-img.width() / 2.0, -img.height() / 2.0);
scene()->setSceneRect(QRectF(0, 0, img.width(), img.height()));
mImgOriSize = img.size();
mMinScaleThre = 1.0 / std::min(mImgOriSize.width(), mImgOriSize.height());
//qreal scale = std::min((qreal)size().width() / img.width(), (qreal)size().height() / img.height());
if (isAutoResetTransform())
{
mpImgItem->setPos(0, 0);
qreal scale = 1.0f;
scaleImg2(scale);
this->centerOn(0, 0);
}
mpImgItem->setFlags(QGraphicsItem::ItemIsMovable);
return mpImgItem;
}
void lpImgViewer::setResetCenter()
{
if(mpImgItem)
mpImgItem->setPos(scene()->width() /2, scene()->height()/2);
}
void lpImgViewer::wheelEvent(QWheelEvent *evt)
{
if (mpImgItem)
{
qreal numDegrees = evt->angleDelta().y() / 120;
if (!isFixedSizeScale())
{
qreal newScale = transform().m11();
if (numDegrees > 0)
newScale *= std::pow(1.1, numDegrees);
else if (numDegrees < 0)
newScale *= std::pow(0.9, -numDegrees);
mpImgItem->setTransformOriginPoint(0, 0);
scaleImg2(newScale);
emit sgImageScale(newScale);
}
else
{
qreal newScale = fixedSizeScale();
if (numDegrees > 0)
newScale *= std::pow(1.2, numDegrees);
else if (numDegrees < 0)
newScale *= std::pow(0.8, -numDegrees);
if (newScale > 1.0)
newScale = 1.0;
if (newScale < mMinScaleThre)
newScale = mMinScaleThre;
setFixedSizeScale(newScale);
scaleImageWithFixedViewSize();
}
}
}
void lpImgViewer::mouseMoveEvent(QMouseEvent *evt)
{
if (mpImgItem)
{
QPoint curpos = (mpImgItem->mapFromScene(this->mapToScene(evt->pos())) +
QPointF(mImgOriSize.width() / 2.0, mImgOriSize.height() / 2.0)+ QPointF(-0.5, -0.5)).toPoint();
if (mpInfoLabel)//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ֵ
selectPixel(curpos);
else
emit pixelSelected(curpos);
}
if (mpImgItem && mpImgItem->isSelected())
{
QPointF pos = mpImgItem->scenePos();
qDebug() << pos;
emit imgMoved(pos);
}
QGraphicsView::mouseMoveEvent(evt);
}
void lpImgViewer::resizeEvent(QResizeEvent* evt)
{
QGraphicsView::resizeEvent(evt);
}
void lpImgViewer::mouseReleaseEvent(QMouseEvent *evt)
{
QGraphicsView::mouseReleaseEvent(evt);
if (mpImgItem)
mpImgItem->setSelected(false);
}
void lpImgViewer::closeEvent(QCloseEvent *evt)
{
deleteLater();
}
void lpImgViewer::moveImg(QPointF pos)
{
if (mpImgItem)
mpImgItem->setPos(pos);
}
QString lpImgViewer::pixelInfoStr(QPoint pos, QRgb _rgb)
{
QColor rgb(_rgb);
QColor hsv = rgb.toHsv();
QString infoStr("Position:[%1, %2] Color(RGB):[%3, %4, %5] (HSV):[%6, %7, %8]");
infoStr = infoStr.arg(pos.x()).arg(pos.y())
.arg(rgb.red()).arg(rgb.green()).arg(rgb.blue())
.arg(hsv.hue() / 2).arg(hsv.saturation()).arg(hsv.value());
return infoStr;
}
void lpImgViewer::selectPixel(QPoint pos)
{
if (pos.x() < 0 || pos.y() < 0 || pos.x() > mImgOriSize.width() || pos.y() > mImgOriSize.height())
{
mpInfoLabel->setText(QString("out of image..."));
return;
}
if (!mpImgItem)
{
return;
}
QImage img = mpImgItem->pixmap().toImage();
QRgb pixel = img.pixel(pos);
mpInfoLabel->setText(pixelInfoStr(pos, pixel));
}
void lpImgViewer::scaleImageWithFixedViewSize()
{
if (!mpImg)
{
return;
}
QImage scaledImage;
if (!imgScaleFunc())
{
scaledImage = mpImg->scaled(mpImg->width()*mFixedSizeScale, mpImg->height()*mFixedSizeScale,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
mpImgItem->setPixmap(QPixmap::fromImage(scaledImage.scaled(mpImg->width(),
mpImg->height()), Qt::NoFormatConversion));
}
else
{
scaledImage = mImgScaleFunc(*mpImg, mFixedSizeScale, Qt::SmoothTransformation);
mpImgItem->setPixmap(QPixmap::fromImage(mImgScaleFunc(scaledImage,
1.0 / mFixedSizeScale, Qt::FastTransformation), Qt::NoFormatConversion));
}
emit imgScaledWithFixedSize(fixedSizeScale());
}
void lpImgViewer::scaleImg(QTransform tf, QPointF center)
{
this->resetTransform();
this->setTransform(tf);
this->centerOn(center);
}
void lpImgViewer::scaleImg2(qreal scale)
{
if (scale < 0.01)
return;
m_scale = scale;
QTransform t;
t.scale(scale, scale);
this->setTransform(t);
QPointF center = this->mapToScene(width() / 2, height() / 2);
emit imgScaled(this->transform(), center);
}
void lpImgViewer::clear()
{
m_scale = 1.0f;
m_channel = "";
scene()->clear();
mpImgItem = NULL;
if (mpImg)
{
delete mpImg;
mpImg = NULL;
}
}

@ -0,0 +1,85 @@
#ifndef _H_LPIMGVIEWER_H_
#define _H_LPIMGVIEWER_H_
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QLabel>
typedef QImage (*ImageScaleFun)(QImage, double, int);
class lpImgViewer : public QGraphicsView
{
Q_OBJECT
public:
static QString pixelInfoStr(QPoint pos, QRgb rgb);
public:
lpImgViewer(QGraphicsScene *scene, QWidget *parent = 0);
lpImgViewer(QWidget* parent = 0);
virtual ~lpImgViewer(){
if (mpImg)
delete mpImg;
}
virtual QGraphicsPixmapItem* setImg(QImage& img);
void setInfoLabel(QLabel* ipLabel){ mpInfoLabel = ipLabel; }
void setResetCenter();
const QImage* img() { return mpImg; }
QGraphicsPixmapItem* imgItem() { return mpImgItem; }
virtual void wheelEvent(QWheelEvent *evt);
virtual void mouseMoveEvent(QMouseEvent *evt);
virtual void resizeEvent(QResizeEvent* evt);
virtual void mouseReleaseEvent(QMouseEvent *evt);
virtual void closeEvent(QCloseEvent *evt);
virtual void clear();
virtual const qreal getScale(void) const { return m_scale; };
virtual void setChannel(const QString& channel) { m_channel = channel; }
virtual QString getChannel() const { return m_channel; }
bool isFixedSizeScale() const { return mIsFixedSizeScale; }
void setIsFixedSizeScale(bool val) { mIsFixedSizeScale = val; }
qreal fixedSizeScale() const { return mFixedSizeScale; }
void setFixedSizeScale(qreal val) { mFixedSizeScale = val; }
ImageScaleFun imgScaleFunc() const { return mImgScaleFunc; }
void setImgScaleFunc(ImageScaleFun val) { mImgScaleFunc = val; }
void setInitScale(qreal val);
bool isAutoResetTransform() const { return mIsAutoResetTransform; }
void setIsAutoResetTransform(bool val) { mIsAutoResetTransform = val; }
bool isAutoResetToWindowSize() const { return mIsAutoResetToWindowSize; }
void setIsAutoResetToWindowSize(bool val) { mIsAutoResetToWindowSize = val; }
signals:
void imgScaled(QTransform tf, QPointF center);
void imgMoved(QPointF pos);
void pixelSelected(QPoint pos);
void imgScaledWithFixedSize(qreal scale);
void sgImageScale(qreal);
public slots:
void scaleImg(QTransform tf, QPointF center);
void moveImg(QPointF pos);
void selectPixel(QPoint pos);
void scaleImageWithFixedViewSize();
protected:
QGraphicsPixmapItem* mpImgItem{ nullptr };
QSize mImgOriSize;
qreal mMinScaleThre;
QLabel* mpInfoLabel{ nullptr };
QImage* mpImg{ nullptr };
void scaleImg2(qreal scale);
qreal m_scale;
QString m_channel;
bool mIsFixedSizeScale;
qreal mFixedSizeScale;
bool mIsAutoResetTransform;
bool mIsAutoResetToWindowSize;
ImageScaleFun mImgScaleFunc;
};
#endif

File diff suppressed because it is too large Load Diff

@ -12,17 +12,14 @@
#include "ui_lpReport.h"
#include <QDateTime>
#include "InfoFile.h"
#include <QStandardItemModel>
#include "QThread"
#include "workfordb.h"
#include "countdata.h"
#include "waitingdialog.h"
#include "checkdata.h"
#include <QMessageBox>
#include "DetectDataDB.h"
#include <QSettings>
#include <QTranslator>
#include "ModeCheckDlg.h"
#include "ModeCountDlg.h"
#include "ValueCheckDlg.h"
class lpReport : public QMainWindow
{
@ -31,9 +28,6 @@ class lpReport : public QMainWindow
public:
lpReport(QWidget *parent = Q_NULLPTR);
~lpReport();
void onInitUI();
protected:
//国际化
void SetLanguage(QString strLangage);
@ -41,100 +35,23 @@ protected:
void SetTranslator(const QString strPath);
virtual void timerEvent(QTimerEvent *event);
Q_SLOT void SlotEditTime();
Q_SLOT void onCheckButton();
bool onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString strAtl, int onlyOK = 0);
void CheckDataHistoryByDate(QString m_strLast, QString m_endLast, QString modelname);
bool SaveDataToCSV(QString filePath, QMap<QString, int> &m_mapTable);
void CheckDataByDate(QString m_strLast, QString m_endLast);
void onEventLoop(QString strMsg);
void SaveLog(QString str);
QString getHistoryCheckString();
Q_SLOT void onHistoryButton();
void cleanHistorycal();
Q_SLOT void onSetCurrentIndex(int nIndex);
Q_SLOT void onSaveCSVDone(int);
Q_SLOT void handleResults(QString str);
Q_SLOT void onShowMessage(QString str);
Q_SLOT void onProgressForTsk(QVariantMap m_map);
Q_SLOT void handleResultsHistory(QVariantMap Mapstr, QSqlQuery sql);
Q_SLOT void onShowMsg();
Q_SLOT void handleResultsCount(const QString &result, const QMap<QString, int> *p);
Q_SLOT void onLogButton();
QString getLogCheckString(int nCheckCount = 0);
Q_SLOT void onUpdateTableViewShow(QSqlQuery sql);
void updateModelShowHistory(QSqlQuery &sql);
Q_SLOT void onUpdateTableViewShowlog(QSqlQuery sql);
Q_SLOT void onResultCountlog(int nCount);
Q_SLOT void onResultCount(int nCount);
void CheckDataWarningByDate(int nType, QString m_strLast, QString m_endLast);
void updateModelShowLog(QSqlQuery &sql);
Q_SLOT void SlotCombox(int index);
Q_SLOT void onSlowPixmap(QSqlQuery sql);
Q_SLOT void onTableViewClick(QModelIndex mIndex);
void InitUIParam();
void SetModelNames(QStringList models);
signals:
void sgSetCurrentIndex(int);
void sgFinish();
void operate(const QString& strTime, const int &ncount);
void operateCount(QVariantMap m_Map);
void operateHistory(QVariantMap m_map);
void sgshowMsg();
private:
Ui::lpReportClass ui;
class QReportWidget *reportdlg{ nullptr };
class QGridLayout *m_GridLayout{ nullptr };
class QVBoxLayout *Hbox{ nullptr };
class QWidget *m_countwidget{ nullptr };
QVector<QTranslator* > m_VecTranPtr;//国际化语言包管理
protected:
QDateTime m_startDate_Count, m_endDate_Count;
QDateTime m_startDate_History, m_endDate_History;
QDateTime m_startDate_Warning, m_endDate_Warning;
QTime m_startTime, m_endTime;
bool m_CheckFlags{ false };
QTime nstartTime;
QTime nEndTime;
QString m_userName;
QMap<int, QTableView*> m_tableView;
QMap<int, QStandardItemModel*> m_standItemModel;
QMap<QString, TimeStruct> m_Totaltime;//班次时间表
QMap<QString, int> m_CountNumber;
QMap<int, QMap<QString, int>> m_channels;
int m_PrevNum{ 0 };
int m_NextNum{ 0 };
int m_totlaNum{ 0 };
int m_page{ 0 }, m_totalPage{ 0 };
int m_PrevNumlog{ 0 };
int m_NextNumlog{ 0 };
int m_totlaNumlog{ 0 };
int m_pagelog{ 0 }, m_totalPagelog{ 0 };
QThread m_Workthread;
WorkForDB *m_WorkDB{ nullptr };
QThread m_WorkThreadCount;
CountData *m_WorkCount{ nullptr };
QThread m_WorkThreadCheckHistory;
CheckData *m_WorkHistory{ nullptr };
WaitingDialog m_Progressdlg;
QStringList m_strListModelName;
class DetectDataDB *m_pDb{ nullptr };
class ModelDB *m_pModeDB{ nullptr };
bool m_IsRunCountTsk{ false };
QCompleter *_pCompleter{ nullptr };
ModeCheckDlg *m_pModeCheckUI{ nullptr };//型号识别历史数据查询页面
ModeCountDlg *m_pModeCountUI{ nullptr };//型号识别统计数据页面
ValueCheckDlg *m_pValueUI{ nullptr };//定位数据查询页面
QStandardItemModel *m_tableModel{ nullptr };
QStandardItemModel *m_tableWarnModel{ nullptr };
class DetectDataDB *m_pDb{ nullptr };
class ModelDB *m_pModeDB{ nullptr };
};
#endif

File diff suppressed because it is too large Load Diff

@ -117,13 +117,17 @@
<ClCompile Include="databasesql.cpp" />
<ClCompile Include="DetectDataDB.cpp" />
<ClCompile Include="gensql.cpp" />
<ClCompile Include="lpImgViewer.cpp" />
<ClCompile Include="lpReport.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="ModeCheckDlg.cpp" />
<ClCompile Include="ModeCountDlg.cpp" />
<ClCompile Include="ModelDB.cpp" />
<ClCompile Include="qcheckcal.cpp" />
<ClCompile Include="qreportwidget.cpp" />
<ClCompile Include="qtimedlg.cpp" />
<ClCompile Include="testwidget.cpp" />
<ClCompile Include="ValueCheckDlg.cpp" />
<ClCompile Include="waitingdialog.cpp" />
</ItemGroup>
<ItemGroup>
@ -131,8 +135,11 @@
</ItemGroup>
<ItemGroup>
<QtUic Include="lpReport.ui" />
<QtUic Include="ModeCheckDlg.ui" />
<QtUic Include="ModeCountDlg.ui" />
<QtUic Include="qtimedlg.ui" />
<QtUic Include="testwidget.ui" />
<QtUic Include="ValueCheckDlg.ui" />
</ItemGroup>
<ItemGroup>
<QtRcc Include="lpReport.qrc" />
@ -207,7 +214,23 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="gensql.h" />
<QtMoc Include="lpImgViewer.h">
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
</QtMoc>
<QtMoc Include="ModeCheckDlg.h">
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
</QtMoc>
<QtMoc Include="ModeCountDlg.h">
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
</QtMoc>
<ClInclude Include="resource.h" />
<QtMoc Include="ValueCheckDlg.h">
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
</QtMoc>
<QtMoc Include="ModelDB.h">
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>
<IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtSql</IncludePath>

@ -68,6 +68,18 @@
<ClCompile Include="ModelDB.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ValueCheckDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="lpImgViewer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ModeCheckDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ModeCountDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="lpReport.h">
@ -112,6 +124,18 @@
<QtMoc Include="ModelDB.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="ValueCheckDlg.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="lpImgViewer.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="ModeCheckDlg.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="ModeCountDlg.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<QtUic Include="lpReport.ui">
@ -123,6 +147,15 @@
<QtUic Include="testwidget.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="ValueCheckDlg.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="ModeCheckDlg.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="ModeCountDlg.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<QtRcc Include="lpReport.qrc">

@ -7,6 +7,7 @@ QPLCDevice::QPLCDevice(QObject *parent)
m_pTask = new lpThread(func2);
m_pTask->setPriority(QThread::HighestPriority);
m_pTask->StartThread();
connect(this, SIGNAL(sgSendHeartBit()), this, SLOT(onSendHeartBit()));
}
QPLCDevice::~QPLCDevice()
@ -55,7 +56,6 @@ void QPLCDevice::onRecvFunc(QByteArray data)
void QPLCDevice::sendByteData(QByteArray byteData)
{
QSharedPointer<QByteArray> sendData = QSharedPointer<QByteArray>(new QByteArray);
sendData->append(byteData);
if (m_rawTcpServer)
{
@ -116,7 +116,8 @@ void QPLCDevice::onParaster(QByteArray recvData)
}
else if (cmd.toInt() == 2) //ĐÄĚřÓŚ´đ
{
onSendHeartBit();
//onSendHeartBit();
emit sgSendHeartBit();
emit sgRecvHeartBit();
}
else if (cmd.toInt() == 3)

@ -25,18 +25,18 @@ public:
bool onRunTask();
void onParaster(QByteArray recvData);
void onSendValueRlt(const ValueResult& rlt);//发送定位结果
void onSendHeartBit();//发送心跳
Q_SLOT void onSendHeartBit();//发送心跳
void onAckTrigerCam(int stationID);//发送触发应答
Q_SLOT void on_serv_status_changed(int id, ServerStatus status);
Q_SLOT void on_client_connect_status(QString strID, ServerStatus status);
bool getClinetInfo(QString &client);
signals:
void sgSendAlgResult(int camID);
void sgTrigerCam(int camID);
void sgSendDataCallBack(QByteArray);
void sgRecvDataCallBack(QByteArray);
void sgRecvHeartBit();
void sgSendHeartBit();
private:
lptkRawTcpServer *m_rawTcpServer{ nullptr };
QMutex mMtLock;

@ -29,7 +29,7 @@ valueMainUI::valueMainUI(QWidget *parent)
setupTrayIcon();//后台任务栏初始化
setWindowIcon(QIcon(WINDOWICON));
setWindowTitle(tr("识别定位一体检测系统(v1.0.9 21.12.10)"));
setWindowTitle(tr("识别定位一体检测系统(v1.1.0 21.12.13)"));
lpGlobalData::instance();
lpConfig::instance()->loadConfig();

@ -30,6 +30,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<TargetName>$(ProjectName)d</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
@ -61,10 +62,11 @@
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
<OutputFile>$(SolutionDir)..\runner17\$(ProjectName)d.exe</OutputFile>
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>qtmaind.lib;Qt5Cored.lib;Qt5Guid.lib;Qt5WebSocketsd.lib;Qt5Widgetsd.lib;Qt5Locationd.lib;Qt5Networkd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ProgramDatabaseFile>$(SolutionDir)..\runner17\$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<QtMoc>
<OutputFile>.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</OutputFile>
@ -92,10 +94,11 @@
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
<OutputFile>$(SolutionDir)..\runner17\$(ProjectName).exe</OutputFile>
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5WebSockets.lib;Qt5Widgets.lib;Qt5Location.lib;Qt5Network.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ProgramDatabaseFile>$(SolutionDir)..\runner17\$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<QtMoc>
<OutputFile>.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</OutputFile>

Loading…
Cancel
Save