From 9300aee81409f83229ce196ad559f8e2e4e74b05 Mon Sep 17 00:00:00 2001 From: Flamingo Date: Wed, 24 Apr 2024 23:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8C=85zip?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E5=90=8D=E5=AD=97=EF=BC=8C=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=8F=AA=E6=89=93=E5=8C=85=E4=B8=80=E5=88=86=E9=92=9F?= =?UTF-8?q?=E4=B9=8B=E5=86=85=E7=9A=84=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cigarette/exportData.cpp | 61 +++++++++++++++++++++++++--------------- Cigarette/exportData.h | 5 ++++ 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/Cigarette/exportData.cpp b/Cigarette/exportData.cpp index 95f5816..ec98d29 100644 --- a/Cigarette/exportData.cpp +++ b/Cigarette/exportData.cpp @@ -52,6 +52,8 @@ ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent) readyToSendZip = false; listToZip.clear(); tmpListToZip.clear(); + lastTimeStamp.clear(); + zipTimeStamp.clear(); hftp = NULL; hint = NULL; @@ -328,23 +330,27 @@ void ExportDataThread::run() if ((b_quit || (!timer->isActive() && !readyToSendZip)) && (!tmpListToZip.isEmpty())) { listToZip += tmpListToZip; tmpListToZip.clear(); + zipTimeStamp.append(lastTimeStamp[0]); + lastTimeStamp.clear(); readyToSendZip = true; } - if (readyToSendZip) { + if (readyToSendZip && !listToZip.isEmpty()) { QString remotePath; QStringList zipFilePaths; QStringList fileList; QString okStr = "OK"; QProcess process(0); - QDateTime now_ts = QDateTime::currentDateTime(); + //QDateTime now_ts = QDateTime::currentDateTime(); QStringList argsNg; QStringList argsOk; - zipFilePaths.append(g_conf_path.save_pics_path + "/" + now_ts.toString("yyyy-MM-dd_HH-mm-ss_") + "ng.zip"); - zipFilePaths.append(g_conf_path.save_pics_path + "/" + now_ts.toString("yyyy-MM-dd_HH-mm-ss_") + "ok.zip"); - fileList.append(g_conf_path.save_pics_path + "/" + now_ts.toString("yyyy-MM-dd_HH-mm-ss_") + "ng.txt"); - fileList.append(g_conf_path.save_pics_path + "/" + now_ts.toString("yyyy-MM-dd_HH-mm-ss_") + "ok.txt"); + zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_0.zip"); + zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-59_1.zip"); + fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ng.txt"); + fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ok.txt"); + + zipTimeStamp.clear(); QFile fileNg(fileList[0]); QFile fileOk(fileList[1]); @@ -504,29 +510,38 @@ void ExportDataThread::ConnectServer(QString srcPath, QString destPath) { void ExportDataThread::GetDataFromSaveThread(QString filePath) { QString remotePath; + QStringList currentTimeStamp; + QRegExp rx("((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))_([0-1]?[0-9]|2[0-3])-([0-5][0-9])"); + - if (timer->isActive()) { - if (filePath.indexOf("ng") == -1) { - tmpListToZip.append(filePath); - } - } - else { - if (!tmpListToZip.isEmpty()) { - listToZip = tmpListToZip; - tmpListToZip.clear(); - } + + if (filePath.indexOf("ng") == -1) { - if (!listToZip.isEmpty()) { - readyToSendZip = true; + if (rx.indexIn(filePath) != -1) { + currentTimeStamp = rx.capturedTexts(); + } + else { + QDateTime now_ts = QDateTime::currentDateTime(); + currentTimeStamp.append(now_ts.toString("yyyy-MM-dd_HH-mm")); } - if (filePath.indexOf("ng") == -1) { - tmpListToZip.append(filePath); + if (lastTimeStamp.isEmpty() || (currentTimeStamp[0] != lastTimeStamp[0])) { + if (!tmpListToZip.isEmpty()) { + listToZip = tmpListToZip; + tmpListToZip.clear(); + } + if (!listToZip.isEmpty()) { + zipTimeStamp.append(lastTimeStamp[0]); + readyToSendZip = true; + } + lastTimeStamp.clear(); + lastTimeStamp.append(currentTimeStamp[0]); + timer->stop(); + timer->start(1000 * (60 * 1 + 10)); } - //remotePath = filePath.mid(filePath.indexOf("image") - 1); - //ConnectServer(filePath, remotePath); - timer->start(1000 * 60 * 5); // 5min + tmpListToZip.append(filePath); } + } //*****************************************已经调试好,没有理清逻辑前不要动********************** diff --git a/Cigarette/exportData.h b/Cigarette/exportData.h index cf146e4..028cedf 100644 --- a/Cigarette/exportData.h +++ b/Cigarette/exportData.h @@ -146,4 +146,9 @@ public: public slots: void EDrecMsgFromCigarette(); void GetDataFromSaveThread(QString filePath); + + +private: + QStringList lastTimeStamp; + QStringList zipTimeStamp; };