修改打包zip文件的名字,以及只打包一分钟之内的图片

CigaretteSH
Flamingo 9 months ago
parent f8453203c4
commit 9300aee814

@ -52,6 +52,8 @@ ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent)
readyToSendZip = false; readyToSendZip = false;
listToZip.clear(); listToZip.clear();
tmpListToZip.clear(); tmpListToZip.clear();
lastTimeStamp.clear();
zipTimeStamp.clear();
hftp = NULL; hftp = NULL;
hint = NULL; hint = NULL;
@ -328,23 +330,27 @@ void ExportDataThread::run()
if ((b_quit || (!timer->isActive() && !readyToSendZip)) && (!tmpListToZip.isEmpty())) { if ((b_quit || (!timer->isActive() && !readyToSendZip)) && (!tmpListToZip.isEmpty())) {
listToZip += tmpListToZip; listToZip += tmpListToZip;
tmpListToZip.clear(); tmpListToZip.clear();
zipTimeStamp.append(lastTimeStamp[0]);
lastTimeStamp.clear();
readyToSendZip = true; readyToSendZip = true;
} }
if (readyToSendZip) { if (readyToSendZip && !listToZip.isEmpty()) {
QString remotePath; QString remotePath;
QStringList zipFilePaths; QStringList zipFilePaths;
QStringList fileList; QStringList fileList;
QString okStr = "OK"; QString okStr = "OK";
QProcess process(0); QProcess process(0);
QDateTime now_ts = QDateTime::currentDateTime(); //QDateTime now_ts = QDateTime::currentDateTime();
QStringList argsNg; QStringList argsNg;
QStringList argsOk; 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 + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_0.zip");
zipFilePaths.append(g_conf_path.save_pics_path + "/" + now_ts.toString("yyyy-MM-dd_HH-mm-ss_") + "ok.zip"); zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-59_1.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 + "/" + zipTimeStamp[0] + "ng.txt");
fileList.append(g_conf_path.save_pics_path + "/" + now_ts.toString("yyyy-MM-dd_HH-mm-ss_") + "ok.txt"); fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ok.txt");
zipTimeStamp.clear();
QFile fileNg(fileList[0]); QFile fileNg(fileList[0]);
QFile fileOk(fileList[1]); QFile fileOk(fileList[1]);
@ -504,29 +510,38 @@ void ExportDataThread::ConnectServer(QString srcPath, QString destPath) {
void ExportDataThread::GetDataFromSaveThread(QString filePath) { void ExportDataThread::GetDataFromSaveThread(QString filePath) {
QString remotePath; 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 (!listToZip.isEmpty()) {
readyToSendZip = true; if (filePath.indexOf("ng") == -1) {
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) { if (lastTimeStamp.isEmpty() || (currentTimeStamp[0] != lastTimeStamp[0])) {
tmpListToZip.append(filePath); 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); tmpListToZip.append(filePath);
//ConnectServer(filePath, remotePath);
timer->start(1000 * 60 * 5); // 5min
} }
} }
//*****************************************已经调试好,没有理清逻辑前不要动********************** //*****************************************已经调试好,没有理清逻辑前不要动**********************

@ -146,4 +146,9 @@ public:
public slots: public slots:
void EDrecMsgFromCigarette(); void EDrecMsgFromCigarette();
void GetDataFromSaveThread(QString filePath); void GetDataFromSaveThread(QString filePath);
private:
QStringList lastTimeStamp;
QStringList zipTimeStamp;
}; };

Loading…
Cancel
Save