|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
#include "lpReport.h"
|
|
|
|
|
#include "lpReport.h"
|
|
|
|
|
#include "qtimedlg.h"
|
|
|
|
|
#include <QSqlQuery>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
@ -26,7 +26,11 @@ enum EM_TYPE_TIME
|
|
|
|
|
lpReport::lpReport(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//加载语言设置
|
|
|
|
|
QSettings languageSetting("hubdetect.ini", QSettings::IniFormat);
|
|
|
|
|
QString strLanguage = languageSetting.value("language", "Chinese").toString();
|
|
|
|
|
SetLanguage(strLanguage);
|
|
|
|
|
|
|
|
|
|
qRegisterMetaType<QSqlQuery>("QSqlQuery");
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
onInitUI();
|
|
|
|
|
@ -51,14 +55,14 @@ lpReport::lpReport(QWidget *parent)
|
|
|
|
|
nstartTime.setHMS(0, 0, 0);
|
|
|
|
|
nEndTime.setHMS(23, 59, 59);
|
|
|
|
|
m_tableModel = new QStandardItemModel;
|
|
|
|
|
|
|
|
|
|
m_WorkDB = new WorkForDB;
|
|
|
|
|
m_WorkDB->moveToThread(&m_Workthread);
|
|
|
|
|
|
|
|
|
|
m_WorkDB = new WorkForDB;
|
|
|
|
|
m_WorkDB->moveToThread(&m_Workthread);
|
|
|
|
|
m_WorkDB->setDB(m_pDb);
|
|
|
|
|
connect(&m_Workthread, &QThread::finished, m_WorkDB, &QObject::deleteLater);
|
|
|
|
|
connect(this, &lpReport::operate, m_WorkDB, &WorkForDB::doWork);
|
|
|
|
|
connect(m_WorkDB, &WorkForDB::resultReady, this, &lpReport::handleResults);
|
|
|
|
|
m_Workthread.start();
|
|
|
|
|
connect(&m_Workthread, &QThread::finished, m_WorkDB, &QObject::deleteLater);
|
|
|
|
|
connect(this, &lpReport::operate, m_WorkDB, &WorkForDB::doWork);
|
|
|
|
|
connect(m_WorkDB, &WorkForDB::resultReady, this, &lpReport::handleResults);
|
|
|
|
|
m_Workthread.start();
|
|
|
|
|
qDebug() << "start thread m_Workthread";
|
|
|
|
|
|
|
|
|
|
m_WorkCount = new CountData;
|
|
|
|
|
@ -90,7 +94,8 @@ lpReport::lpReport(QWidget *parent)
|
|
|
|
|
InitUIParam();
|
|
|
|
|
SetModelNames(strList);
|
|
|
|
|
|
|
|
|
|
setWindowTitle("数据记录查看");
|
|
|
|
|
setWindowTitle(tr("数据记录查看"));
|
|
|
|
|
|
|
|
|
|
setWindowIcon(QIcon(":/lpReport/Resources/Log.png"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -128,7 +133,7 @@ lpReport::~lpReport()
|
|
|
|
|
if (_pCompleter) {
|
|
|
|
|
delete _pCompleter;
|
|
|
|
|
_pCompleter = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (m_countwidget)
|
|
|
|
|
{
|
|
|
|
|
delete m_countwidget;
|
|
|
|
|
@ -155,9 +160,9 @@ void lpReport::onInitUI()
|
|
|
|
|
connect(this, SIGNAL(sgSetCurrentIndex(int)), ui.stackedWidget, SLOT(setCurrentIndex(int)));
|
|
|
|
|
connect(ui.comboBox_Banci_Calculate, SIGNAL(currentIndexChanged(int)), this, SLOT(SlotCombox(int)));
|
|
|
|
|
connect(ui.comboBox_Banci, SIGNAL(currentIndexChanged(int)), this, SLOT(SlotCombox(int)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.comboBox_Model->setEditable(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui.Prev_checkShengchang, SIGNAL(clicked()), this, SLOT(onHistoryButton()));
|
|
|
|
|
connect(ui.Next_checkShengchang, SIGNAL(clicked()), this, SLOT(onHistoryButton()));
|
|
|
|
|
|
|
|
|
|
@ -165,8 +170,8 @@ void lpReport::onInitUI()
|
|
|
|
|
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));
|
|
|
|
|
ui.showNum_Label_Checkdata->setText(tr("共显示%1条记录").arg(0));
|
|
|
|
|
ui.showPage_Label_Checkdata->setText(tr("第%1页 共%2页").arg(0).arg(0));
|
|
|
|
|
|
|
|
|
|
int nItenCount = ui.check_listWidget->count();
|
|
|
|
|
for (int nIndex = 0; nIndex < nItenCount; nIndex++)
|
|
|
|
|
@ -185,8 +190,8 @@ void lpReport::onInitUI()
|
|
|
|
|
connect(ui.Prev_checklog, SIGNAL(clicked()), this, SLOT(onLogButton()));
|
|
|
|
|
connect(ui.Next_checklog, SIGNAL(clicked()), this, SLOT(onLogButton()));
|
|
|
|
|
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(0).arg(0));
|
|
|
|
|
ui.showNum_Label_Checkdata_2->setText(tr("共显示%1条记录").arg(0));
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(0).arg(0));
|
|
|
|
|
ui.showNum_Label_Checkdata_2->setText(tr("共显示%1条记录").arg(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpReport::timerEvent(QTimerEvent *event)
|
|
|
|
|
@ -271,8 +276,8 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
{
|
|
|
|
|
QObject *obj = sender();
|
|
|
|
|
QString str = obj->objectName();
|
|
|
|
|
if ("pushButton_Checkdata" == str)//查询生产数据
|
|
|
|
|
{/*这里需要做数据分页显示 减少内存泄露*/
|
|
|
|
|
if ("pushButton_Checkdata" == str)//查询生产数据
|
|
|
|
|
{/*这里需要做数据分页显示 减少内存泄露*/
|
|
|
|
|
static bool checkflags = false;
|
|
|
|
|
if (checkflags == false)
|
|
|
|
|
{
|
|
|
|
|
@ -285,13 +290,13 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
{
|
|
|
|
|
if (m_Totaltime.value(strBanci).m_startTime > m_Totaltime.value(strBanci).m_endTime)
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的班次时间是隔夜的,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的班次时间是隔夜的,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
checkflags = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
checkflags = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -301,7 +306,7 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
{
|
|
|
|
|
if (m_startDate_History.date() > m_endDate_History.date())
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
checkflags = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -309,15 +314,15 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
QString m_Title = tr("起始时间:%1 到 结束时间:%2 的历史记录").arg(m_strLast).arg(m_endLast);
|
|
|
|
|
ui.label_Tab2_Title->setText(m_Title);
|
|
|
|
|
if (modelName == tr("全部"))
|
|
|
|
|
if (modelName == tr("全部"))
|
|
|
|
|
CheckDataHistoryByDate(m_strLast, m_endLast, "*");
|
|
|
|
|
else
|
|
|
|
|
CheckDataHistoryByDate(m_strLast, m_endLast, modelName);
|
|
|
|
|
@ -326,7 +331,7 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("正在查询数据,请稍后"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("正在查询数据,请稍后"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("pushButton_SaveHistory" == str)
|
|
|
|
|
@ -335,12 +340,12 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
return;
|
|
|
|
|
if (m_tableModel->rowCount() <= 0)
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString filename = QString("History_%1.csv").arg(QDateTime::currentDateTime().toString("yyyy_MM_dd"));
|
|
|
|
|
QString fileTitle = tr("请选择保存文件的路径");
|
|
|
|
|
QString fileTitle = tr("请选择保存文件的路径");
|
|
|
|
|
QFileDialog *fileDialog = new QFileDialog(NULL, fileTitle, filename);
|
|
|
|
|
fileDialog->setWindowTitle("Save As");
|
|
|
|
|
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
|
@ -362,11 +367,11 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
connect(workerThread, &QSaveCSVThread::finished, workerThread, &QObject::deleteLater);
|
|
|
|
|
workerThread->start();
|
|
|
|
|
|
|
|
|
|
onEventLoop(tr("正在导出数据,请稍等"));
|
|
|
|
|
onEventLoop(tr("正在导出数据,请稍等"));
|
|
|
|
|
|
|
|
|
|
QString strMsg = tr("导出了%1-%2的生产数据").arg(ui.label_Time1_History->text()).arg(ui.label_Time2_History->text());
|
|
|
|
|
QString strMsg = tr("导出了%1-%2的生产数据").arg(ui.label_Time1_History->text()).arg(ui.label_Time2_History->text());
|
|
|
|
|
SaveLog(strMsg);
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("数据导出完成"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("数据导出完成"));
|
|
|
|
|
}
|
|
|
|
|
if (fileDialog) {
|
|
|
|
|
delete fileDialog;
|
|
|
|
|
@ -382,23 +387,23 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
|
|
|
QString m_strLast = ui.label_Time1_warning->text();
|
|
|
|
|
QString m_endLast = ui.label_Time2_warning->text();
|
|
|
|
|
QString strMsg = tr("查询了%1-%2的日志数据").arg(m_strLast).arg(m_endLast);
|
|
|
|
|
QString strMsg = tr("查询了%1-%2的日志数据").arg(m_strLast).arg(m_endLast);
|
|
|
|
|
QString strCombox = ui.comboBox_Wandring_Log->currentText();
|
|
|
|
|
int mType = 0;
|
|
|
|
|
if (strCombox == tr("使用记录查询")) {
|
|
|
|
|
if (strCombox == tr("使用记录查询")) {
|
|
|
|
|
mType = (int)emTypeUseState;
|
|
|
|
|
}
|
|
|
|
|
else if (strCombox == tr("报警记录查询")) {
|
|
|
|
|
else if (strCombox == tr("报警记录查询")) {
|
|
|
|
|
mType = (int)emTypeWaring;
|
|
|
|
|
}
|
|
|
|
|
else if (strCombox == tr("运行状态查询")) {
|
|
|
|
|
else if (strCombox == tr("运行状态查询")) {
|
|
|
|
|
mType = (int)emTypeRunState;
|
|
|
|
|
}
|
|
|
|
|
SaveLog(strMsg);
|
|
|
|
|
QFont font;
|
|
|
|
|
font.setPixelSize(14);
|
|
|
|
|
ui.label_Tab3_Title->setFont(font);
|
|
|
|
|
QString m_Title = tr("起始时间:%1 到 结束时间:%2 的历史记录").arg(m_strLast).arg(m_endLast);
|
|
|
|
|
QString m_Title = tr("起始时间:%1 到 结束时间:%2 的历史记录").arg(m_strLast).arg(m_endLast);
|
|
|
|
|
ui.label_Tab3_Title->setText(m_Title);
|
|
|
|
|
|
|
|
|
|
CheckDataWarningByDate(mType, m_strLast, m_endLast);
|
|
|
|
|
@ -407,23 +412,23 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("正在查询数据,请稍后"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("正在查询数据,请稍后"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (str == "pushButton_SaveWaring")
|
|
|
|
|
{
|
|
|
|
|
if (m_tableWarnModel == NULL)
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (m_tableWarnModel->rowCount() <= 0)
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QString filename = QString("WarnMessage_%1.csv").arg(QDateTime::currentDateTime().toString("yyyy_MM_dd"));
|
|
|
|
|
QString fileTitle = tr("请选择保存文件的路径");
|
|
|
|
|
QString fileTitle = tr("请选择保存文件的路径");
|
|
|
|
|
QFileDialog *fileDialog = new QFileDialog(NULL, fileTitle, filename);
|
|
|
|
|
fileDialog->setWindowTitle("Save As");
|
|
|
|
|
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
|
@ -444,11 +449,11 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
connect(workerThread, &QSaveCSVThread::finished, workerThread, &QObject::deleteLater);
|
|
|
|
|
workerThread->start();
|
|
|
|
|
|
|
|
|
|
onEventLoop(tr("正在导出数据,请稍等"));
|
|
|
|
|
onEventLoop(tr("正在导出数据,请稍等"));
|
|
|
|
|
|
|
|
|
|
QString strMsg = tr("导出了%1-%2的日志数据").arg(ui.label_Time1_warning->text()).arg(ui.label_Time2_warning->text());
|
|
|
|
|
QString strMsg = tr("导出了%1-%2的日志数据").arg(ui.label_Time1_warning->text()).arg(ui.label_Time2_warning->text());
|
|
|
|
|
SaveLog(strMsg);
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("数据导出完成"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("数据导出完成"));
|
|
|
|
|
}
|
|
|
|
|
if (fileDialog) {
|
|
|
|
|
delete fileDialog;
|
|
|
|
|
@ -469,13 +474,13 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
{
|
|
|
|
|
if (m_Totaltime.value(strBanci).m_startTime > m_Totaltime.value(strBanci).m_endTime)
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的班次时间是隔夜的,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的班次时间是隔夜的,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
checkflags = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新起始日期,再查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新起始日期,再查询"));
|
|
|
|
|
checkflags = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -485,14 +490,14 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
{
|
|
|
|
|
if (m_startDate_Count.date() > m_endDate_Count.date())
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("您选择的日期不合理,请您重新选择一下当前查询的日期,再查询"));
|
|
|
|
|
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());
|
|
|
|
|
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);
|
|
|
|
|
@ -501,18 +506,18 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("正在查询数据,请稍后"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("正在查询数据,请稍后"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("pushButton_SaveCalculate" == str)
|
|
|
|
|
{
|
|
|
|
|
if (m_CountNumber.size() <= 0)
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
|
|
|
|
|
onMessageBox(QMessageBox::Warning, tr("提示"), tr("没有数据,请重新查询"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QString filename = QString("Data_%1.csv").arg(QDateTime::currentDateTime().toString("yyyy_MM_dd"));
|
|
|
|
|
QString fileTitle = tr("请选择保存文件的路径");
|
|
|
|
|
QString fileTitle = tr("请选择保存文件的路径");
|
|
|
|
|
QFileDialog *fileDialog = new QFileDialog(NULL, fileTitle, filename);
|
|
|
|
|
fileDialog->setWindowTitle("Save As");
|
|
|
|
|
fileDialog->setAcceptMode(QFileDialog::AcceptSave);
|
|
|
|
|
@ -526,8 +531,8 @@ Q_SLOT void lpReport::onCheckButton()
|
|
|
|
|
{
|
|
|
|
|
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());
|
|
|
|
|
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) {
|
|
|
|
|
@ -545,8 +550,8 @@ bool lpReport::onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString s
|
|
|
|
|
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("取消"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Ok, tr("确认"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Cancel, tr("取消"));
|
|
|
|
|
return (infobox.exec() == QMessageBox::Ok);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -589,14 +594,14 @@ void lpReport::CheckDataHistoryByDate(QString m_strLast, QString m_endLast, QStr
|
|
|
|
|
bool lpReport::SaveDataToCSV(QString filePath, QMap<QString, int> &m_mapTable)
|
|
|
|
|
{
|
|
|
|
|
QFile file(filePath);
|
|
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append))// 追加写入数据
|
|
|
|
|
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";
|
|
|
|
|
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)
|
|
|
|
|
@ -612,9 +617,9 @@ bool lpReport::SaveDataToCSV(QString filePath, QMap<QString, int> &m_mapTable)
|
|
|
|
|
{
|
|
|
|
|
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";
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
@ -631,9 +636,9 @@ void lpReport::CheckDataByDate(QString m_strLast, QString m_endLast)
|
|
|
|
|
|
|
|
|
|
QProgressDialog progress;
|
|
|
|
|
progress.setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
progress.setWindowTitle(tr("查询进度"));
|
|
|
|
|
progress.setWindowTitle(tr("查询进度"));
|
|
|
|
|
progress.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
progress.setLabelText(tr("数据查询中,请稍后....."));
|
|
|
|
|
progress.setLabelText(tr("数据查询中,请稍后....."));
|
|
|
|
|
progress.setCancelButton(0);
|
|
|
|
|
QSqlQuery sql;
|
|
|
|
|
QVariantMap m_Value;
|
|
|
|
|
@ -676,7 +681,7 @@ QString lpReport::getHistoryCheckString()
|
|
|
|
|
QString m_endLast = ui.label_Time2_History->text();
|
|
|
|
|
QString modelName = ui.comboBox_Model->currentText();
|
|
|
|
|
QString strString;
|
|
|
|
|
if (modelName == tr("全部"))
|
|
|
|
|
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);
|
|
|
|
|
@ -702,7 +707,7 @@ Q_SLOT void lpReport::onHistoryButton()
|
|
|
|
|
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)));
|
|
|
|
|
@ -711,7 +716,7 @@ Q_SLOT void lpReport::onHistoryButton()
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
ui.showPage_Label_Checkdata->setText(tr("第%1页 共%2页").arg(m_page).arg(m_totalPage + 1));
|
|
|
|
|
if (m_PrevNum <= 0)
|
|
|
|
|
{
|
|
|
|
|
m_PrevNum = 0;
|
|
|
|
|
@ -734,7 +739,7 @@ Q_SLOT void lpReport::onHistoryButton()
|
|
|
|
|
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)));
|
|
|
|
|
@ -743,7 +748,7 @@ Q_SLOT void lpReport::onHistoryButton()
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
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;
|
|
|
|
|
@ -767,13 +772,13 @@ void lpReport::cleanHistorycal()
|
|
|
|
|
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.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);
|
|
|
|
|
|
|
|
|
|
ui.showNum_Label_Checkdata_2->setText(tr("共显示%1条记录").arg(0));
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(0).arg(0));
|
|
|
|
|
ui.showNum_Label_Checkdata_2->setText(tr("共显示%1条记录").arg(0));
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(0).arg(0));
|
|
|
|
|
ui.Prev_checklog->setDisabled(true);
|
|
|
|
|
ui.Next_checklog->setDisabled(true);
|
|
|
|
|
}
|
|
|
|
|
@ -791,9 +796,9 @@ Q_SLOT void lpReport::onSaveCSVDone(int)
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpReport::handleResults(QString str)
|
|
|
|
|
{
|
|
|
|
|
//QString strMsg = "username" + ":" + tr("系统自动定时查询了一次数据完成,目标是清除超期的数据");
|
|
|
|
|
//QString strMsg = "username" + ":" + tr("系统自动定时查询了一次数据完成,目标是清除超期的数据");
|
|
|
|
|
//m_pCtrl->addLog(strMsg, emTypeRunState);
|
|
|
|
|
onShowMessage(tr("系统自动进行清理完成"));
|
|
|
|
|
onShowMessage(tr("系统自动进行清理完成"));
|
|
|
|
|
}
|
|
|
|
|
Q_SLOT void lpReport::onShowMessage(QString str)
|
|
|
|
|
{
|
|
|
|
|
@ -809,7 +814,7 @@ Q_SLOT void lpReport::onProgressForTsk(QVariantMap m_map)
|
|
|
|
|
QString nType = m_map.value("Type").toString();
|
|
|
|
|
if (nType == "start")
|
|
|
|
|
{
|
|
|
|
|
QString strMsg = m_map.value("msg", tr("正在查询数据")).toString();
|
|
|
|
|
QString strMsg = m_map.value("msg", tr("正在查询数据")).toString();
|
|
|
|
|
m_Progressdlg.setWindowTitle(strMsg);
|
|
|
|
|
m_Progressdlg.Start(50, 150),
|
|
|
|
|
m_Progressdlg.show();
|
|
|
|
|
@ -829,7 +834,7 @@ Q_SLOT void lpReport::handleResultsHistory(QVariantMap Mapstr, QSqlQuery sql)
|
|
|
|
|
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);
|
|
|
|
|
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);
|
|
|
|
|
@ -849,20 +854,20 @@ Q_SLOT void lpReport::handleResultsHistory(QVariantMap Mapstr, QSqlQuery sql)
|
|
|
|
|
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("数据查询完成"));
|
|
|
|
|
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("数据查询完成"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpReport::onShowMsg()
|
|
|
|
|
{
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("操作已生效"));
|
|
|
|
|
onMessageBox(QMessageBox::Information, tr("提示"), tr("操作已生效"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpReport::handleResultsCount(const QString &result, const QMap<QString, int> *p)
|
|
|
|
|
{
|
|
|
|
|
reportdlg->ClearData();
|
|
|
|
|
reportdlg->setTitle(tr("统计结果 "));
|
|
|
|
|
reportdlg->setTitle(tr("统计结果 "));
|
|
|
|
|
if (p == NULL) {
|
|
|
|
|
m_IsRunCountTsk = false;
|
|
|
|
|
return;
|
|
|
|
|
@ -870,9 +875,9 @@ Q_SLOT void lpReport::handleResultsCount(const QString &result, const QMap<QStri
|
|
|
|
|
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->AppendData(tr("总数"), result.toInt(), true);
|
|
|
|
|
reportdlg->UpdateTableView();
|
|
|
|
|
onShowMessage(tr("统计完成"));
|
|
|
|
|
onShowMessage(tr("统计完成"));
|
|
|
|
|
m_IsRunCountTsk = false;
|
|
|
|
|
if (p)
|
|
|
|
|
delete p;
|
|
|
|
|
@ -895,7 +900,7 @@ Q_SLOT void lpReport::onLogButton()
|
|
|
|
|
m_PrevNumlog = 0;
|
|
|
|
|
QString strString = getLogCheckString();
|
|
|
|
|
strString += QString(" LIMIT %1 OFFSET %2 ").arg(limitNum).arg(m_PrevNumlog);
|
|
|
|
|
/*启用线程查询数据 减少界面卡顿*/
|
|
|
|
|
/*启用线程查询数据 减少界面卡顿*/
|
|
|
|
|
CheckThread *workerThread = new CheckThread(this);
|
|
|
|
|
workerThread->setCheckStr(m_pDb, strString);
|
|
|
|
|
connect(workerThread, SIGNAL(resultReady(QSqlQuery)), this, SLOT(onUpdateTableViewShowlog(QSqlQuery)));
|
|
|
|
|
@ -904,7 +909,7 @@ Q_SLOT void lpReport::onLogButton()
|
|
|
|
|
|
|
|
|
|
m_totalPagelog = (m_totlaNumlog / limitNum);
|
|
|
|
|
m_pagelog = ((m_PrevNumlog) / limitNum) + 1;
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(m_pagelog).arg(m_totalPagelog + 1));
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(m_pagelog).arg(m_totalPagelog + 1));
|
|
|
|
|
if (m_PrevNumlog <= 0)
|
|
|
|
|
{
|
|
|
|
|
m_PrevNumlog = 0;
|
|
|
|
|
@ -927,7 +932,7 @@ Q_SLOT void lpReport::onLogButton()
|
|
|
|
|
QString strString = getLogCheckString();
|
|
|
|
|
|
|
|
|
|
strString += QString(" LIMIT %1 OFFSET %2 ").arg(limitNum).arg(m_PrevNumlog);
|
|
|
|
|
/*启用线程查询数据 减少界面卡顿*/
|
|
|
|
|
/*启用线程查询数据 减少界面卡顿*/
|
|
|
|
|
CheckThread *workerThread = new CheckThread(this);
|
|
|
|
|
workerThread->setCheckStr(m_pDb, strString);
|
|
|
|
|
connect(workerThread, SIGNAL(resultReady(QSqlQuery)), this, SLOT(onUpdateTableViewShowlog(QSqlQuery)));
|
|
|
|
|
@ -936,7 +941,7 @@ Q_SLOT void lpReport::onLogButton()
|
|
|
|
|
|
|
|
|
|
m_totalPagelog = (m_totlaNumlog / limitNum);
|
|
|
|
|
m_pagelog = (m_PrevNumlog + limitNum) / limitNum;
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(m_pagelog).arg(m_totalPagelog + 1));
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(m_pagelog).arg(m_totalPagelog + 1));
|
|
|
|
|
if ((m_PrevNumlog + limitNum) >= m_totlaNumlog)
|
|
|
|
|
{
|
|
|
|
|
m_PrevNumlog = m_totlaNumlog;
|
|
|
|
|
@ -952,13 +957,13 @@ QString lpReport::getLogCheckString(int nCheckCount/*=0*/)
|
|
|
|
|
QString m_endLast = ui.label_Time2_warning->text();
|
|
|
|
|
QString strCombox = ui.comboBox_Wandring_Log->currentText();
|
|
|
|
|
int mType = 0;
|
|
|
|
|
if (strCombox == tr("使用记录查询")) {
|
|
|
|
|
if (strCombox == tr("使用记录查询")) {
|
|
|
|
|
mType = (int)emTypeUseState;
|
|
|
|
|
}
|
|
|
|
|
else if (strCombox == tr("报警记录查询")) {
|
|
|
|
|
else if (strCombox == tr("报警记录查询")) {
|
|
|
|
|
mType = (int)emTypeWaring;
|
|
|
|
|
}
|
|
|
|
|
else if (strCombox == tr("运行状态查询")) {
|
|
|
|
|
else if (strCombox == tr("运行状态查询")) {
|
|
|
|
|
mType = (int)emTypeRunState;
|
|
|
|
|
}
|
|
|
|
|
QVariantMap m_vlaue;
|
|
|
|
|
@ -979,29 +984,29 @@ Q_SLOT void lpReport::onUpdateTableViewShow(QSqlQuery sql)
|
|
|
|
|
void lpReport::updateModelShowHistory(QSqlQuery &sql)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *testmodel = new QStandardItemModel;
|
|
|
|
|
ui.tableView_checkShengchang->setModel(testmodel);//先将模型插入后在一次性显示 可以提高显示速率
|
|
|
|
|
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()->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(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();
|
|
|
|
|
@ -1031,7 +1036,7 @@ void lpReport::updateModelShowHistory(QSqlQuery &sql)
|
|
|
|
|
m_tableModel->setItem(nIndex, 7, new QStandardItem(QString("%1").arg(uid)));
|
|
|
|
|
nIndex++;
|
|
|
|
|
}
|
|
|
|
|
ui.showNum_Label_Checkdata->setText(tr("共显示%1条记录").arg(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);
|
|
|
|
|
@ -1068,7 +1073,7 @@ void lpReport::CheckDataWarningByDate(int nType, QString m_strLast, QString m_en
|
|
|
|
|
connect(workThread, SIGNAL(resultCount(int)), this, SLOT(onResultCountlog(int)));
|
|
|
|
|
connect(workThread, &CheckThread::finished, workThread, &QObject::deleteLater);
|
|
|
|
|
workThread->start();
|
|
|
|
|
onEventLoop(tr("正在查询记录,请稍等"));
|
|
|
|
|
onEventLoop(tr("正在查询记录,请稍等"));
|
|
|
|
|
|
|
|
|
|
strString = getLogCheckString();
|
|
|
|
|
int nlimit = ui.LineNumber_log->text().toInt();
|
|
|
|
|
@ -1084,7 +1089,7 @@ void lpReport::CheckDataWarningByDate(int nType, QString m_strLast, QString m_en
|
|
|
|
|
connect(workerThread, &CheckThread::finished, workerThread, &QObject::deleteLater);
|
|
|
|
|
workerThread->start();
|
|
|
|
|
|
|
|
|
|
QString m_Title = tr("从%1 到 %2 的记录 共%3条").arg(m_strLast).arg(m_endLast).arg(m_totlaNumlog);
|
|
|
|
|
QString m_Title = tr("从%1 到 %2 的记录 共%3条").arg(m_strLast).arg(m_endLast).arg(m_totlaNumlog);
|
|
|
|
|
QFont font;
|
|
|
|
|
font.setPixelSize(14);
|
|
|
|
|
font.setBold(true);
|
|
|
|
|
@ -1103,26 +1108,26 @@ void lpReport::CheckDataWarningByDate(int nType, QString m_strLast, QString m_en
|
|
|
|
|
m_totlaNumlog = 0;
|
|
|
|
|
m_pagelog = 0;
|
|
|
|
|
}
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(m_pagelog).arg(m_totalPagelog));
|
|
|
|
|
ui.showPage_Label_Checkdata_2->setText(tr("第%1页 共%2页").arg(m_pagelog).arg(m_totalPagelog));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpReport::updateModelShowLog(QSqlQuery &sql)
|
|
|
|
|
{
|
|
|
|
|
QStandardItemModel *testmodel = new QStandardItemModel;
|
|
|
|
|
ui.tableView_TWarning->setModel(testmodel);//先将模型插入后在一次性显示 可以提高显示速率
|
|
|
|
|
ui.tableView_TWarning->setModel(testmodel);//先将模型插入后在一次性显示 可以提高显示速率
|
|
|
|
|
ui.tableView_TWarning->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
ui.tableView_TWarning->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
ui.tableView_TWarning->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);//自适应行宽
|
|
|
|
|
ui.tableView_TWarning->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);//自适应行宽
|
|
|
|
|
if (m_tableWarnModel == NULL)
|
|
|
|
|
m_tableWarnModel = new QStandardItemModel;
|
|
|
|
|
m_tableWarnModel->clear();
|
|
|
|
|
m_tableWarnModel->setHorizontalHeaderItem(0, new QStandardItem(tr("时间")));
|
|
|
|
|
m_tableWarnModel->setHorizontalHeaderItem(1, new QStandardItem(tr("信息")));
|
|
|
|
|
m_tableWarnModel->setHorizontalHeaderItem(0, new QStandardItem(tr("时间")));
|
|
|
|
|
m_tableWarnModel->setHorizontalHeaderItem(1, new QStandardItem(tr("信息")));
|
|
|
|
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
while (sql.next())
|
|
|
|
|
{
|
|
|
|
|
/*这里下面是统计查询到的通道对应的产品总数*/
|
|
|
|
|
/*这里下面是统计查询到的通道对应的产品总数*/
|
|
|
|
|
QString time = sql.value("time").toString();
|
|
|
|
|
QString message = sql.value("message").toString();
|
|
|
|
|
QString classd = sql.value("class").toString();
|
|
|
|
|
@ -1130,7 +1135,7 @@ void lpReport::updateModelShowLog(QSqlQuery &sql)
|
|
|
|
|
m_tableWarnModel->setItem(nIndex, 1, new QStandardItem(message));
|
|
|
|
|
nIndex++;
|
|
|
|
|
}
|
|
|
|
|
ui.showNum_Label_Checkdata_2->setText(tr("共显示%1条记录").arg(nIndex));
|
|
|
|
|
ui.showNum_Label_Checkdata_2->setText(tr("共显示%1条记录").arg(nIndex));
|
|
|
|
|
ui.tableView_TWarning->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
|
ui.tableView_TWarning->setModel(m_tableWarnModel);
|
|
|
|
|
delete testmodel;
|
|
|
|
|
@ -1166,7 +1171,7 @@ Q_SLOT void lpReport::SlotCombox(int index)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (str == tr("全天"))
|
|
|
|
|
if (str == tr("全天"))
|
|
|
|
|
{
|
|
|
|
|
QString strTime = nstartTime.toString("hh:mm:ss");
|
|
|
|
|
if (m_startDate_Count.date() > m_endDate_Count.date())
|
|
|
|
|
@ -1204,7 +1209,7 @@ Q_SLOT void lpReport::SlotCombox(int index)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (str == tr("全天"))
|
|
|
|
|
if (str == tr("全天"))
|
|
|
|
|
{
|
|
|
|
|
QString strTime = nstartTime.toString("hh:mm:ss");
|
|
|
|
|
if (m_startDate_History.date() > m_endDate_History.date())
|
|
|
|
|
@ -1265,7 +1270,7 @@ Q_SLOT void lpReport::onTableViewClick(QModelIndex mIndex)
|
|
|
|
|
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)));
|
|
|
|
|
@ -1275,7 +1280,7 @@ Q_SLOT void lpReport::onTableViewClick(QModelIndex mIndex)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//初始化UI参数
|
|
|
|
|
//初始化UI参数
|
|
|
|
|
void lpReport::InitUIParam()
|
|
|
|
|
{
|
|
|
|
|
m_startDate_History = QDateTime::currentDateTime();
|
|
|
|
|
@ -1294,18 +1299,18 @@ void lpReport::InitUIParam()
|
|
|
|
|
ui.label_Time2_warning->setText(m_endDate_Warning.toString("yyyy-MM-dd hh:mm:ss"));
|
|
|
|
|
|
|
|
|
|
ui.comboBox_Banci->clear();
|
|
|
|
|
ui.comboBox_Banci->addItem(tr("全天"));
|
|
|
|
|
ui.comboBox_Banci->addItem(tr("全天"));
|
|
|
|
|
ui.comboBox_Banci->addItems(m_Totaltime.keys());
|
|
|
|
|
ui.comboBox_Banci_Calculate->clear();
|
|
|
|
|
ui.comboBox_Banci_Calculate->addItem(tr("全天"));
|
|
|
|
|
ui.comboBox_Banci_Calculate->addItem(tr("全天"));
|
|
|
|
|
ui.comboBox_Banci_Calculate->addItems(m_Totaltime.keys());
|
|
|
|
|
|
|
|
|
|
ui.comboBox_Wandring_Log->clear();
|
|
|
|
|
ui.comboBox_Wandring_Log->addItem(tr("报警记录查询"));
|
|
|
|
|
ui.comboBox_Wandring_Log->addItem(tr("运行状态查询"));
|
|
|
|
|
ui.comboBox_Wandring_Log->addItem(tr("使用记录查询"));
|
|
|
|
|
ui.comboBox_Wandring_Log->addItem(tr("报警记录查询"));
|
|
|
|
|
ui.comboBox_Wandring_Log->addItem(tr("运行状态查询"));
|
|
|
|
|
ui.comboBox_Wandring_Log->addItem(tr("使用记录查询"));
|
|
|
|
|
|
|
|
|
|
ui.label_Title->setText(tr("生产数据查询"));
|
|
|
|
|
ui.label_Title->setText(tr("生产数据查询"));
|
|
|
|
|
ui.stackedWidget->setCurrentIndex(0);
|
|
|
|
|
|
|
|
|
|
if (m_tableModel)
|
|
|
|
|
@ -1317,7 +1322,7 @@ void lpReport::InitUIParam()
|
|
|
|
|
|
|
|
|
|
ui.label_Number->setText("0");
|
|
|
|
|
ui.CheckDlg_label_Pic->clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (reportdlg)
|
|
|
|
|
reportdlg->ClearData();
|
|
|
|
|
}
|
|
|
|
|
@ -1325,7 +1330,7 @@ void lpReport::InitUIParam()
|
|
|
|
|
void lpReport::SetModelNames(QStringList models)
|
|
|
|
|
{
|
|
|
|
|
ui.comboBox_Model->clear();
|
|
|
|
|
ui.comboBox_Model->addItem(tr("全部"));
|
|
|
|
|
ui.comboBox_Model->addItem(tr("全部"));
|
|
|
|
|
if (!models.contains("NG"))
|
|
|
|
|
ui.comboBox_Model->addItem(tr("NG"));
|
|
|
|
|
ui.comboBox_Model->addItems(models);
|
|
|
|
|
@ -1334,4 +1339,83 @@ void lpReport::SetModelNames(QStringList models)
|
|
|
|
|
_pCompleter = new QCompleter(models);
|
|
|
|
|
_pCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
|
ui.comboBox_Model->setCompleter(_pCompleter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpReport::SetLanguage(QString strLanguage)
|
|
|
|
|
{
|
|
|
|
|
QString strDirPath = QString(QCoreApplication::applicationDirPath() + "/language/");
|
|
|
|
|
QString translatorFileName = strLanguage;
|
|
|
|
|
if (!translatorFileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
if (m_VecTranPtr.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
while (m_VecTranPtr.size())
|
|
|
|
|
{
|
|
|
|
|
QTranslator *pVa = m_VecTranPtr.takeFirst();
|
|
|
|
|
qApp->removeTranslator(pVa);
|
|
|
|
|
delete pVa;
|
|
|
|
|
pVa = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//if (strLangage == "Chinese")
|
|
|
|
|
// return;
|
|
|
|
|
QLocale::setDefault(QLocale(translatorFileName));
|
|
|
|
|
|
|
|
|
|
QString transDir = strDirPath + translatorFileName;
|
|
|
|
|
SearchQmFile(transDir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpReport::SearchQmFile(const QString & strDir)
|
|
|
|
|
{
|
|
|
|
|
QDir dir(strDir);
|
|
|
|
|
if (!dir.exists())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
|
dir.setSorting(QDir::DirsFirst); // 文件夹优先
|
|
|
|
|
// 转换成一个List
|
|
|
|
|
QFileInfoList list = dir.entryInfoList();
|
|
|
|
|
if (list.size() < 1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int i = 0;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
QFileInfo fileInfo = list.at(i);
|
|
|
|
|
QString tt = fileInfo.fileName();
|
|
|
|
|
// 如果是文件夹
|
|
|
|
|
bool bisDir = fileInfo.isDir();
|
|
|
|
|
if (bisDir)
|
|
|
|
|
{
|
|
|
|
|
SearchQmFile(fileInfo.filePath());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bool bQm = fileInfo.fileName().endsWith(".qm");
|
|
|
|
|
SetTranslator(fileInfo.filePath());
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
} while (i < list.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpReport::SetTranslator(const QString strPath)
|
|
|
|
|
{
|
|
|
|
|
if (strPath.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QTranslator *pTrans = new QTranslator;
|
|
|
|
|
if (pTrans->load(strPath)) // 如果加载成功
|
|
|
|
|
{
|
|
|
|
|
qApp->installTranslator(pTrans);
|
|
|
|
|
m_VecTranPtr.append(pTrans);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
delete pTrans;
|
|
|
|
|
pTrans = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|