feat: Add delete policy in recon page and system operation log.

This commit is contained in:
sunwen
2024-09-14 15:59:22 +08:00
parent ea6a6e99e4
commit 3b7f2ebd04
10 changed files with 85 additions and 32 deletions

View File

@@ -116,5 +116,8 @@
},
"patientlist": {
"expire": "7"
},
"reconlist": {
"expire": "30"
}
}

View File

@@ -269,6 +269,11 @@ void DeviceManager::initGUI(bool aIsInitSucceed)
//process expired patient list
QDate date = QDate::currentDate().addDays(-JsonObject::Instance()->getPatientListExpireDays());
SQLHelper::exec(QString("DELETE FROM Patient WHERE AddDate <= %1").arg(date.toString("yyyy-MM-dd")));
//process expired scan list
date = QDate::currentDate().addDays(-JsonObject::Instance()->getScanListExpireDays());
SQLHelper::exec(QString("DELETE FROM Scan WHERE ScanDateTime <= \"%1\"").arg(date.toString("yyyy-MM-dd")));
}
void DeviceManager::processInitializeProgress(const QString& aProgress)

View File

@@ -28,6 +28,8 @@ ScanSearchCriteriaForm::ScanSearchCriteriaForm(QWidget *parent)
ui->mLBBeginDate->setUpdatesEnabled(true);
ui->mLBBeginDate->setText(QDate::currentDate().toString("yyyy-MM-dd"));
ui->mBtnAll->setText(tr("Last %1 days").arg(JsonObject::Instance()->getScanListExpireDays()));
auto endBox = new ListBox(this);
// endBox->setSmallBox(true);
ui->verticalLayoutDate->replaceWidget(ui->mLBEndDate,endBox);
@@ -139,6 +141,7 @@ ScanSearchCriteriaForm::ScanSearchCriteriaForm(QWidget *parent)
});
connect(EventCenter::Default(),&EventCenter::ReloadLanguage,[=](){
ui->retranslateUi(this);
ui->mBtnAll->setText(tr("Last %1 days").arg(JsonObject::Instance()->getScanListExpireDays()));
});
}

View File

@@ -73,6 +73,7 @@ void JsonObject::init()
mDmsSimulator = getBool("dms","simulator");
mOperationLogExpireDays = QString(getJsonString("operatorlog", "expire")).toInt();
mPatientListExpireDays = QString(getJsonString("patientlist", "expire")).toInt();
mScanListExpireDays = QString(getJsonString("reconlist", "expire")).toInt();
mWorklistHost.ae = QString(getJsonString("worklist", "ae"));
mWorklistHost.ip = QString(getJsonString("worklist", "ip"));
@@ -647,6 +648,11 @@ int JsonObject::getPatientListExpireDays()
return mPatientListExpireDays;
}
int JsonObject::getScanListExpireDays()
{
return mScanListExpireDays;
}
bool JsonObject::getMppsOpen()
{
return mMppsOpen;

View File

@@ -124,6 +124,8 @@ public:
int getOperationLogExpireDays();
int getPatientListExpireDays();
int getScanListExpireDays();
QString getReconTransferPath();
bool getScanCanWithoutRecon();
@@ -179,6 +181,7 @@ private:
int mDefaultProtocal;
int mOperationLogExpireDays;
int mPatientListExpireDays;
int mScanListExpireDays;
host mWorklistHost;
host mPacsHost;

View File

@@ -1,6 +1,7 @@
#include "SystemOperationLog.h"
#include "appvals/AppGlobalValues.h"
#include "json/jsonobject.h"
#include <QDir>
@@ -63,3 +64,23 @@ void SystemOperationLog::log(const QString &aOperationText, const QDateTime& aOp
reloadFile();
mStreamOut << aOperationDate.toString(Qt::DateFormat::ISODateWithMs).replace("T","\t")<<"\t"<<aOperationText<<endl;
}
void SystemOperationLog::cleanHistoryLog()
{
int expireDays = JsonObject::Instance()->getOperationLogExpireDays();
QDateTime currentDate = QDateTime::currentDateTime();
QDateTime deleteDate = currentDate.addDays(-expireDays);
QDir dir(LOG_DIR);
QStringList logFiles = dir.entryList(QStringList() << "*.log", QDir::Files);
for(const QString &logFile : logFiles)
{
QString filePath = LOG_DIR + "/" + logFile;
QFileInfo fileInfo(filePath);
QDateTime fileDate = fileInfo.created();
if (fileDate <= deleteDate)
{
QFile::remove(filePath);
}
}
}

View File

@@ -13,6 +13,7 @@ public:
SystemOperationLog();
~SystemOperationLog();
void reloadFile();
static void cleanHistoryLog();
public slots:
void log(const QString& aOperationText, const QDateTime& aOperationDate);

View File

@@ -108,6 +108,7 @@ int main(int argc, char* argv[])
int ret = 0;
KeyboardManager::getInstance();
UserOperationLog::cleanHistoryLog();
SystemOperationLog::cleanHistoryLog();
bool sqlConnected= SQLHelper::Open();
if (sqlConnected)
{

View File

@@ -1655,6 +1655,10 @@ progress:99%</source>
<source>Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Last %1 days</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SelectFormWidget</name>

View File

@@ -469,27 +469,27 @@
<name>DeviceManager</name>
<message>
<location filename="../device/DeviceManager.cpp" line="168"/>
<location filename="../device/DeviceManager.cpp" line="832"/>
<location filename="../device/DeviceManager.cpp" line="840"/>
<location filename="../device/DeviceManager.cpp" line="1444"/>
<location filename="../device/DeviceManager.cpp" line="837"/>
<location filename="../device/DeviceManager.cpp" line="845"/>
<location filename="../device/DeviceManager.cpp" line="1449"/>
<source>DMS connection error</source>
<translation type="unfinished">DMS失去连接</translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="362"/>
<location filename="../device/DeviceManager.cpp" line="371"/>
<location filename="../device/DeviceManager.cpp" line="367"/>
<location filename="../device/DeviceManager.cpp" line="376"/>
<source>progress:%1%</source>
<translation type="unfinished">:%1%</translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="376"/>
<location filename="../device/DeviceManager.cpp" line="381"/>
<source>Patient can leave.
progress:%1%</source>
<translation type="unfinished">
:%1%</translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="383"/>
<location filename="../device/DeviceManager.cpp" line="388"/>
<source>Data quality assessment in progress
progress:99%</source>
<translation type="unfinished">
@@ -497,8 +497,8 @@ progress:99%</source>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="257"/>
<location filename="../device/DeviceManager.cpp" line="893"/>
<location filename="../device/DeviceManager.cpp" line="901"/>
<location filename="../device/DeviceManager.cpp" line="898"/>
<location filename="../device/DeviceManager.cpp" line="906"/>
<source>Initialize Failed.</source>
<translation type="unfinished"></translation>
</message>
@@ -508,101 +508,101 @@ progress:99%</source>
<translation type="unfinished">!</translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="318"/>
<location filename="../device/DeviceManager.cpp" line="323"/>
<source>Device is not ready, start scan operation failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="318"/>
<location filename="../device/DeviceManager.cpp" line="323"/>
<source>Device is not ready, start empty scan operation failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="436"/>
<location filename="../device/DeviceManager.cpp" line="441"/>
<source>Scan completed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="783"/>
<location filename="../device/DeviceManager.cpp" line="788"/>
<source>Error: </source>
<translation type="unfinished">: </translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="867"/>
<location filename="../device/DeviceManager.cpp" line="872"/>
<source>Start scan failed. Reason:time out.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="878"/>
<location filename="../device/DeviceManager.cpp" line="883"/>
<source>Start scan failed. Reason:%1</source>
<translation type="unfinished">%1</translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="903"/>
<location filename="../device/DeviceManager.cpp" line="908"/>
<source>Start CE Scan Failed.</source>
<translation type="unfinished">CE扫查启动失败</translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="935"/>
<location filename="../device/DeviceManager.cpp" line="940"/>
<source>Data is currently being transmitted, please shut down later.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="942"/>
<location filename="../device/DeviceManager.cpp" line="947"/>
<source>Shut down failed, please push emergency button to shutdown.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1033"/>
<location filename="../device/DeviceManager.cpp" line="1043"/>
<location filename="../device/DeviceManager.cpp" line="1119"/>
<location filename="../device/DeviceManager.cpp" line="1038"/>
<location filename="../device/DeviceManager.cpp" line="1048"/>
<location filename="../device/DeviceManager.cpp" line="1124"/>
<source>Scan data transfer failed.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1097"/>
<location filename="../device/DeviceManager.cpp" line="1102"/>
<source>Scan data transfer Succeeded!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1139"/>
<location filename="../device/DeviceManager.cpp" line="1144"/>
<source>Create empty scan data failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1161"/>
<location filename="../device/DeviceManager.cpp" line="1166"/>
<source>Create scan data failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1228"/>
<location filename="../device/DeviceManager.cpp" line="1233"/>
<source>Recon disconnected.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1293"/>
<location filename="../device/DeviceManager.cpp" line="1308"/>
<location filename="../device/DeviceManager.cpp" line="1298"/>
<location filename="../device/DeviceManager.cpp" line="1313"/>
<source>Open pump failed.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1325"/>
<location filename="../device/DeviceManager.cpp" line="1330"/>
<source>Recon error, can&apos;t start scan process</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1366"/>
<location filename="../device/DeviceManager.cpp" line="1418"/>
<location filename="../device/DeviceManager.cpp" line="1371"/>
<location filename="../device/DeviceManager.cpp" line="1423"/>
<source>Start auto locate failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1438"/>
<location filename="../device/DeviceManager.cpp" line="1443"/>
<source>The data quality is low, please restart the data scan.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../device/DeviceManager.cpp" line="1466"/>
<location filename="../device/DeviceManager.cpp" line="1471"/>
<source>Device reset failed, please contact maintenance person</source>
<translation type="unfinished"></translation>
</message>
@@ -2540,6 +2540,12 @@ parameters
<source>Clear Fields</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../forms/recon/ScanSearchCriteriaForm.cpp" line="31"/>
<location filename="../forms/recon/ScanSearchCriteriaForm.cpp" line="144"/>
<source>Last %1 days</source>
<translation type="unfinished">%1</translation>
</message>
</context>
<context>
<name>SelectFormWidget</name>