Scan Json create and save.
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
#define APP_VALUES()\
|
#define APP_VALUES()\
|
||||||
ADD_APP_VALUE(InProcessing)\
|
ADD_APP_VALUE(InProcessing)\
|
||||||
ADD_APP_VALUE(LastOperationTime)\
|
ADD_APP_VALUE(LastOperationTime)\
|
||||||
ADD_APP_VALUE(LastOperation)
|
ADD_APP_VALUE(LastOperation)\
|
||||||
|
ADD_APP_VALUE(EmptyScanFlag)\
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include "appvals/AppGlobalValues.h"
|
#include "appvals/AppGlobalValues.h"
|
||||||
|
#include "json/ScanJson.h"
|
||||||
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
|
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
|
||||||
|
|
||||||
#define THROW_ERROR(errormsg)\
|
#define THROW_ERROR(errormsg)\
|
||||||
@@ -31,7 +32,6 @@ const char* getStatusString(int status)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string getJsonFromPatInf(QObject* obj)
|
std::string getJsonFromPatInf(QObject* obj)
|
||||||
{
|
{
|
||||||
return ((QString*)obj)->toStdString();
|
return ((QString*)obj)->toStdString();
|
||||||
@@ -229,6 +229,22 @@ void DeviceManager::timerEvent(QTimerEvent* event) {
|
|||||||
QString s("%1 %2");
|
QString s("%1 %2");
|
||||||
s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")).arg("Scan finished");
|
s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")).arg("Scan finished");
|
||||||
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr, (QObject*)&s);
|
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr, (QObject*)&s);
|
||||||
|
QString outputPath = GetDeviceInfo(DeviceInfo::DEV_OUTPATH);
|
||||||
|
outputPath = outputPath.replace("\\","/");
|
||||||
|
if (outputPath.endsWith('/')) outputPath = outputPath.remove(outputPath.length()-1,1);
|
||||||
|
QStringList list = outputPath.split('/');
|
||||||
|
if (list.length()){
|
||||||
|
if (AppGlobalValues::EmptyScanFlag().toBool()){
|
||||||
|
ScanJson::Current()->setEmptyScanID(list.last().toStdString().c_str());
|
||||||
|
}else{
|
||||||
|
ScanJson::Current()->setScanID(list.last().toStdString().c_str());
|
||||||
|
}
|
||||||
|
ScanJson::Current()->save();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
QString msg("Scan Output Path error!");
|
||||||
|
THROW_ERROR(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//一般不会出现其他情况
|
//一般不会出现其他情况
|
||||||
else {
|
else {
|
||||||
@@ -267,6 +283,7 @@ void DeviceManager::processScan(const char* json, bool empty) {
|
|||||||
AppGlobalValues::setInProcessing(true);
|
AppGlobalValues::setInProcessing(true);
|
||||||
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, (QObject*)&msg);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, (QObject*)&msg);
|
||||||
qDebug() << "SetScanInfo>>>>>>>>>>>>>>>>>>>>";
|
qDebug() << "SetScanInfo>>>>>>>>>>>>>>>>>>>>";
|
||||||
|
AppGlobalValues::setEmptyScanFlag(empty);
|
||||||
int ret = SetScanInfo(json, empty ? 1 : 0);
|
int ret = SetScanInfo(json, empty ? 1 : 0);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo failed";
|
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo failed";
|
||||||
@@ -293,6 +310,9 @@ void DeviceManager::processScan(const char* json, bool empty) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::close() {
|
void DeviceManager::close() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
StopDevice();
|
||||||
|
#endif
|
||||||
previewDataCaller->terminate();
|
previewDataCaller->terminate();
|
||||||
delete previewDataCaller;
|
delete previewDataCaller;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,13 @@
|
|||||||
#include "ui_patientinformationform.h"
|
#include "ui_patientinformationform.h"
|
||||||
#include "json/cJSON.h"
|
#include "json/cJSON.h"
|
||||||
#include "event/EventCenter.h"
|
#include "event/EventCenter.h"
|
||||||
|
#include "json/ScanJson.h"
|
||||||
|
|
||||||
PatientInformationForm::PatientInformationForm(QWidget* parent) :
|
PatientInformationForm::PatientInformationForm(QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::PatientInformationForm)
|
ui(new Ui::PatientInformationForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
//ui->lbl_ID->setText(tr(""));
|
|
||||||
//ui->lbl_Date->setText(tr(""));
|
|
||||||
//ui->lbl_Name->setText(tr(""));
|
|
||||||
//ui->lbl_Sex->setText(tr(""));
|
|
||||||
//ui->lbl_Acc->setText(tr(""));
|
|
||||||
|
|
||||||
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
|
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
@@ -63,6 +59,6 @@ const char* PatientInformationForm::getCurrentPatientJsonString(bool empty) {
|
|||||||
cJSON_AddItemToObject(root, "InstitutionAddress", cJSON_CreateString("HZ"));
|
cJSON_AddItemToObject(root, "InstitutionAddress", cJSON_CreateString("HZ"));
|
||||||
delete jsonstr;
|
delete jsonstr;
|
||||||
jsonstr = cJSON_Print(root);
|
jsonstr = cJSON_Print(root);
|
||||||
cJSON_Delete(root);
|
ScanJson::Current()->store(root);
|
||||||
return jsonstr;
|
return jsonstr;
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/json/ScanJson.cpp
Normal file
20
src/json/ScanJson.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// Created by Krad on 2022/5/11.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ScanJson.h"
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
void ScanJson::save() {
|
||||||
|
if (!root) return;
|
||||||
|
QFile f(QString("%1/%2.json").arg(QCoreApplication::applicationDirPath(),scanID.c_str()));
|
||||||
|
f.open(QFileDevice::ReadWrite);
|
||||||
|
cJSON_AddItemToObject(root, "EmptyScanID", cJSON_CreateString(emptyScanID.c_str()));
|
||||||
|
cJSON_AddItemToObject(root, "ScanID", cJSON_CreateString(scanID.c_str()));
|
||||||
|
char* content = cJSON_Print(root);
|
||||||
|
f.write(content);
|
||||||
|
f.flush();
|
||||||
|
f.close();
|
||||||
|
free(content);
|
||||||
|
}
|
||||||
44
src/json/ScanJson.h
Normal file
44
src/json/ScanJson.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// Created by Krad on 2022/5/11.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef GUI_SCANJSON_H
|
||||||
|
#define GUI_SCANJSON_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "cJSON.h"
|
||||||
|
|
||||||
|
class ScanJson {
|
||||||
|
public:
|
||||||
|
~ScanJson(){
|
||||||
|
if(root)cJSON_Delete(root);
|
||||||
|
}
|
||||||
|
void store(cJSON* json){
|
||||||
|
if(root){
|
||||||
|
cJSON_Delete(root);
|
||||||
|
root = nullptr;
|
||||||
|
}
|
||||||
|
root = json;
|
||||||
|
}
|
||||||
|
void setScanID(const char * id){
|
||||||
|
scanID.clear();
|
||||||
|
scanID.append(id);
|
||||||
|
}
|
||||||
|
void setEmptyScanID(const char * id){
|
||||||
|
emptyScanID.clear();
|
||||||
|
emptyScanID.append(id);
|
||||||
|
setScanID(id);
|
||||||
|
}
|
||||||
|
void save();
|
||||||
|
static ScanJson* Current(){
|
||||||
|
static ScanJson instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::string emptyScanID;
|
||||||
|
std::string scanID;
|
||||||
|
cJSON* root = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //GUI_SCANJSON_H
|
||||||
Reference in New Issue
Block a user