FaceAccess/Linguist/recoUi/recoUiHealthCode.cpp

1890 lines
68 KiB
C++
Raw Normal View History

2024-07-11 11:27:12 +08:00
#include "recoUiHealthCode.h"
#include <QDebug>
#include <QPainter>
#include <QJsonObject>
#include <QJsonDocument>
#include "libcJSON.h"
#include "rw_zlog.h"
#include "common_utils.h"
#include "file_utils.h"
#include "ScopeGuard.h"
static const QColor green(31, 164, 38); //166
static const QColor yellow(232, 105, 20);
static const QColor red(250, 59, 59);
static const QColor purple(128, 0, 128);
const int recoUiHealthCodePage::PIC_WIDGET_H_W[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY] = {200, 200, 200, 201, 201};
#if 1
recoUiHealthCodePage::recoUiHealthCodePage(int type, QWidget *parent) : QWidget(parent)
{
qDebug() << "recoUiHealthCodePage()";
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
setAutoFillBackground(true);
QPalette labelPal;
labelPal.setColor(QPalette::Background,QColor(0, 0, 0, 0));
QFont ft;
m_labelTitle = new QLabel(this);
m_labelTitle->setText(tr("健康码智能核验系统"));
labelPal.setColor(QPalette::WindowText, Qt::white);
m_labelTitle->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(12);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelTitle->setFont(ft);
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor(255, 255, 255, 255));
RoundedWidget* healthMsg = new RoundedWidget(this);
healthMsg->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.9),
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.45));
healthMsg->setAutoFillBackground(true);
healthMsg->setPalette(pal);
m_labelTempTip = new QLabel(this);
m_labelTempTip->setText(tr("体温:"));
labelPal.setColor(QPalette::WindowText, Qt::black);
m_labelTempTip->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(14);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelTempTip->setFont(ft);
m_labelTemp = new QLabel("36.5℃", healthMsg);
m_labelTemp->setPalette(labelPal);
m_labelTemp->setFont(ft);
QLabel* labelCodePic = new QLabel(healthMsg);
//QLabel* labelCode = new QLabel(healthMsg);
//labelCode->setAutoFillBackground(true);
//labelCode->setAlignment(Qt::AlignCenter);
//labelCode->setFixedWidth(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.7));
if(0 == type){
labelCodePic->setPixmap(QPixmap(":/res/image/health_code_green_large.png").scaled(140, 140, Qt::KeepAspectRatio));
//labelCode->setText(tr("绿码"));
//pal.setColor(QPalette::WindowText, green);
//pal.setColor(QPalette::Background, QColor(200, 247, 200, 100));
}else if(1 == type){
labelCodePic->setPixmap(QPixmap(":/res/image/health_code_yellow_large.png").scaled(140, 140, Qt::KeepAspectRatio));
//labelCode->setText(tr("黄码"));
//pal.setColor(QPalette::WindowText, yellow);
//pal.setColor(QPalette::Background, QColor(232, 105, 20, 100));
}else if(2 == type){
labelCodePic->setPixmap(QPixmap(":/res/image/health_code_red_large.png").scaled(140, 140, Qt::KeepAspectRatio));
//labelCode->setText(tr("红码"));
//pal.setColor(QPalette::WindowText, red);
//pal.setColor(QPalette::Background, QColor(218, 59, 59, 100));
}
else if(3 == type){
labelCodePic->setPixmap(QPixmap(":/res/image/health_code_grey_large.png").scaled(140, 140, Qt::KeepAspectRatio));
//labelCode->setText(tr("红码"));
//pal.setColor(QPalette::WindowText, red);
//pal.setColor(QPalette::Background, QColor());
}
//labelCode->setPalette(pal);
QLabel* labelNameTip = new QLabel(healthMsg);
labelNameTip->setText(tr("姓名:"));
labelNameTip->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(8);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
labelNameTip->setFont(ft);
m_labelName = new QLabel("张**", healthMsg);
m_labelName->setPalette(labelPal);
m_labelName->setFont(ft);
QLabel* labelIdNoTip = new QLabel(healthMsg);
labelIdNoTip->setText(tr("身份证:"));
labelIdNoTip->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(8);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
labelIdNoTip->setFont(ft);
m_labelIdNo = new QLabel("**************5934", healthMsg);
m_labelIdNo->setPalette(labelPal);
m_labelIdNo->setFont(ft);
pal.setColor(QPalette::WindowText, Qt::white);
pal.setColor(QPalette::Background, QColor(245, 245, 245));
const int MSG_WGT_WIDTH = static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.4);
const int MSG_WGT_HEIGHT = static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.2);
m_covid19Testing = new RoundedWidget(healthMsg);
m_covid19Testing->setFixedSize(MSG_WGT_WIDTH, MSG_WGT_HEIGHT);
m_covid19Testing->setAutoFillBackground(true);
m_covid19Testing->setPalette(pal);
m_labelC19T = new QLabel(m_covid19Testing);
m_labelC19T->setPixmap(QPixmap(":/res/image/c19t_white_large.png"));
m_labelC19TTitle = new QLabel(m_covid19Testing);
m_labelC19TTitle->setText(tr("核酸检测"));
m_labelC19TTitle->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(8);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelC19TTitle->setFont(ft);
m_stackC19T = new QStackedWidget(m_covid19Testing);
m_stackC19T->setFixedSize(static_cast<int>(MSG_WGT_WIDTH * 0.8), static_cast<int>(MSG_WGT_HEIGHT * 0.4));
for(int i=0; i<3; i++){
QWidget* wgt = new QWidget(m_stackC19T);
QLabel* time = new QLabel(QString::number((i + 1) * 24), wgt);
time->setPalette(pal);
ft.setPointSize(16);
time->setFont(ft);
QLabel* tip = new QLabel("小时\n阴性", wgt);
tip->setPalette(pal);
ft.setPointSize(6);
tip->setFont(ft);
QHBoxLayout* hb = new QHBoxLayout();
hb->addStretch();
hb->addWidget(time);
hb->addWidget(tip);
//hb->setSpacing(0);
hb->setMargin(0);
hb->addStretch();
wgt->setLayout(hb);
m_stackC19T->addWidget(wgt);
}
ft.setBold(true);
ft.setPointSize(10);
QLabel* labelNegative = new QLabel("阴性", m_stackC19T);
labelNegative->setFont(ft);
labelNegative->setAlignment(Qt::AlignCenter);
m_stackC19T->addWidget(labelNegative);
QLabel* labelPositive = new QLabel("阳性", m_stackC19T);
labelPositive->setFont(ft);
labelPositive->setAlignment(Qt::AlignCenter);
m_stackC19T->addWidget(labelPositive);
pal.setColor(QPalette::WindowText, Qt::black);
QLabel* labelNodata = new QLabel("暂无数据", m_stackC19T);
labelNodata->setAlignment(Qt::AlignCenter);
labelNodata->setPalette(pal);
ft.setBold(true);
ft.setPointSize(10);
labelNodata->setFont(ft);
m_stackC19T->addWidget(labelNodata);
m_stackC19T->setCurrentIndex(5); //test.........................................................
m_labelC19TTime = new QLabel("2022-04-01", m_covid19Testing);
m_labelC19TTime->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(6);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelC19TTime->setFont(ft);
RoundedWidget* antibodyTesting = new RoundedWidget(healthMsg);
antibodyTesting->setFixedSize(MSG_WGT_WIDTH, MSG_WGT_HEIGHT);
antibodyTesting->setAutoFillBackground(true);
antibodyTesting->setPalette(pal);
QLabel* labelAbT = new QLabel(antibodyTesting);
labelAbT->setPixmap(QPixmap(":/res/image/abt_large.png"));
m_labelABTTitle = new QLabel(antibodyTesting);
m_labelABTTitle->setText(tr("新冠疫苗"));
m_labelABTTitle->setPalette(labelPal);
m_labelABTTitle->setAlignment(Qt::AlignCenter);
ft.setBold(false);
ft.setPointSize(8);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelABTTitle->setFont(ft);
m_labelABTRes = new QLabel("已接种第3针", antibodyTesting);
m_labelABTRes->setAlignment(Qt::AlignCenter);
m_labelABTRes->setFixedSize(static_cast<int>(MSG_WGT_WIDTH * 0.8), static_cast<int>(MSG_WGT_HEIGHT * 0.4));
m_labelABTRes->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(10);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelABTRes->setFont(ft);
m_labelABTTime = new QLabel("2022-4-2 15:33:34", antibodyTesting);
m_labelABTTime->setPalette(labelPal);
m_labelABTTime->setAlignment(Qt::AlignCenter);
ft.setBold(false);
ft.setPointSize(6);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelABTTime->setFont(ft);
QHBoxLayout* hlayC19Title = new QHBoxLayout();
hlayC19Title->addStretch();
hlayC19Title->addWidget(m_labelC19T);
hlayC19Title->addWidget(m_labelC19TTitle);
hlayC19Title->addStretch();
QHBoxLayout* hlayAbtTitle = new QHBoxLayout();
hlayAbtTitle->addStretch();
hlayAbtTitle->addWidget(labelAbT);
hlayAbtTitle->addWidget(m_labelABTTitle);
hlayAbtTitle->addStretch();
QHBoxLayout* hlayTemp = new QHBoxLayout();
hlayTemp->addStretch();
hlayTemp->addWidget(m_labelTempTip);
hlayTemp->addWidget(m_labelTemp);
hlayTemp->addStretch();
hlayTemp->setSpacing(0);
QHBoxLayout* hlayName = new QHBoxLayout();
hlayName->addStretch();
hlayName->addWidget(labelNameTip);
hlayName->addWidget(m_labelName);
hlayName->addStretch();
QHBoxLayout* hlayIdNo = new QHBoxLayout();
hlayIdNo->addStretch();
hlayIdNo->addWidget(labelIdNoTip);
hlayIdNo->addWidget(m_labelIdNo);
hlayIdNo->addStretch();
QVBoxLayout* vlayIdMsg = new QVBoxLayout();
vlayIdMsg->addLayout(hlayName);
vlayIdMsg->addLayout(hlayIdNo);
QVBoxLayout* vlayCovid19Testing = new QVBoxLayout();
vlayCovid19Testing->addLayout(hlayC19Title);
//vlayCovid19Testing->addWidget(m_labelC19TTitle, 1, Qt::AlignCenter);
//vlayCovid19Testing->addWidget(m_labelC19TRes, 1, Qt::AlignCenter);
vlayCovid19Testing->addWidget(m_stackC19T, 1, Qt::AlignCenter);
vlayCovid19Testing->addWidget(m_labelC19TTime, 1, Qt::AlignCenter);
vlayCovid19Testing->setSpacing(0);
vlayCovid19Testing->setMargin(5);
m_covid19Testing->setLayout(vlayCovid19Testing);
QVBoxLayout* vlayAntibodyTesting = new QVBoxLayout();
vlayAntibodyTesting->addLayout(hlayAbtTitle);
//vlayAntibodyTesting->addWidget(m_labelABTTitle, 1, Qt::AlignCenter);
vlayAntibodyTesting->addWidget(m_labelABTRes, 1, Qt::AlignCenter);
vlayAntibodyTesting->addWidget(m_labelABTTime, 1, Qt::AlignCenter);
vlayAntibodyTesting->setSpacing(0);
vlayAntibodyTesting->setMargin(5);
antibodyTesting->setLayout(vlayAntibodyTesting);
QHBoxLayout* hlayTesting = new QHBoxLayout();
hlayTesting->addWidget(m_covid19Testing);
hlayTesting->addWidget(antibodyTesting);
hlayTesting->setSpacing(0);
QVBoxLayout* vlayHealth = new QVBoxLayout();
vlayHealth->addLayout(hlayTemp);
vlayHealth->addWidget(labelCodePic, 1, Qt::AlignCenter);
//vlayHealth->addWidget(labelCode, 1, Qt::AlignCenter);
vlayHealth->addLayout(vlayIdMsg);
vlayHealth->addLayout(hlayTesting);
healthMsg->setLayout(vlayHealth);
// trip msg
RoundedWidget* tripMsg = new RoundedWidget(this);
tripMsg->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.9),
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.2));
pal.setColor(QPalette::Background, QColor(255, 255, 255, 255));
tripMsg->setAutoFillBackground(true);
tripMsg->setPalette(pal);
QLabel* m_labelTrip = new QLabel(tripMsg);
m_labelTrip->setPixmap(QPixmap(":/res/image/pass_large.png"));
m_labelTripRes = new QLabel("近14天途经中高风险地区", tripMsg);
m_labelTripRes->setWordWrap(true);
m_labelTripRes->setAlignment(Qt::AlignCenter);
ft.setPointSize(10);
m_labelTripRes->setFont(ft);
m_labelTripResTime = new QLabel("2022-04-20 10:12:13", tripMsg);
ft.setPointSize(6);
m_labelTripResTime->setFont(ft);
m_labelTripResTime->hide();
QHBoxLayout* hlayTrip = new QHBoxLayout();
hlayTrip->addWidget(m_labelTrip, 1);
hlayTrip->addWidget(m_labelTripRes, 9);
//hlayTrip->addStretch();
tripMsg->setLayout(hlayTrip);
//access msg
RoundedWidget* accMsg = new RoundedWidget(this);
accMsg->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.9),
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.2));
pal.setColor(QPalette::Background, QColor(255, 255, 255, 255));
accMsg->setAutoFillBackground(true);
accMsg->setPalette(pal);
m_labelAcc = new QLabel(accMsg);
m_labelAcc->setPixmap(QPixmap(":/res/image/pass_large.png"));
m_labelAccRes = new QLabel("请通行", accMsg);
labelPal.setColor(QPalette::WindowText, Qt::white);
m_labelAccRes->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(16);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelAccRes->setFont(ft);
m_failReason = new QLabel(accMsg);
m_labelFacePic = new QWidget(accMsg);
m_labelFacePic->setAutoFillBackground(true);
QVBoxLayout* vlayAcc = new QVBoxLayout();
vlayAcc->addWidget(m_labelAccRes, 99, Qt::AlignCenter);
vlayAcc->addWidget(m_failReason, 1, Qt::AlignCenter);
vlayAcc->setSpacing(5);
vlayAcc->setMargin(5);
QHBoxLayout* hlayAccRes = new QHBoxLayout();
hlayAccRes->addWidget(m_labelAcc, 1, Qt::AlignLeft);
hlayAccRes->addLayout(vlayAcc, 99);
//hlayAccRes->addStretch();
hlayAccRes->addWidget(m_labelFacePic, 1, Qt::AlignRight);
hlayAccRes->setSpacing(5);
accMsg->setLayout(hlayAccRes);
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(m_labelTitle, 1, Qt::AlignCenter | Qt::AlignTop);
//vlay->addWidget(m_labelCurTime, 1, Qt::AlignCenter | Qt::AlignTop);//
vlay->addWidget(healthMsg, 7, Qt::AlignCenter | Qt::AlignTop);
vlay->addStretch();
vlay->addWidget(tripMsg, 1, Qt::AlignCenter | Qt::AlignBottom);
vlay->addWidget(accMsg, 1, Qt::AlignCenter | Qt::AlignBottom);
//vlay->setContentsMargins(0, 10, 0, (UiConfig::GetInstance()->getUiHeight() / 12) >> 1 << 1);
//vlay->setMargin(0);
setLayout(vlay);
}
#else
recoUiHealthCodePage::recoUiHealthCodePage(int type, QWidget *parent) : QWidget(parent)
{
qDebug() << "recoUiHealthCodePage()";
resize(UiConfig::GetInstance()->getUiWidth(), UiConfig::GetInstance()->getUiHeight());
setAutoFillBackground(true);
QPalette labelPal;
labelPal.setColor(QPalette::Background,QColor(0, 0, 0, 0));
QFont ft;
//ft.setWeight(20);//Weight must be between 0 and 99
m_labelTitle = new QLabel(this);
m_labelTitle->setText(tr("健康码智能核验系统"));
m_labelTitle->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(12);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelTitle->setFont(ft);
#if 0
m_labelCurTime = new QLabel("2022-4-2 15:33:34", this);
m_labelCurTime->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(8);
m_labelCurTime->setFont(ft);
#endif
QPalette pal = palette();
#if 0
if(0 == type){
pal.setColor(QPalette::Background, green);
}else if(1 == type){
pal.setColor(QPalette::Background, yellow);
}else if(2 == type){
pal.setColor(QPalette::Background, red);
}
setPalette(pal);
#endif
pal.setColor(QPalette::Background, QColor(255, 255, 255, 255));
RoundedWidget* healthMsg = new RoundedWidget(this);
healthMsg->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.9),
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.65));
healthMsg->setAutoFillBackground(true);
healthMsg->setPalette(pal);
m_labelTempTip = new QLabel(this);
m_labelTempTip->setText(tr("体温:"));
m_labelTempTip->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(14);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelTempTip->setFont(ft);
m_labelTemp = new QLabel("36.5℃", healthMsg);
m_labelTemp->setPalette(labelPal);
m_labelTemp->setFont(ft);
QLabel* labelCodePic = new QLabel(healthMsg);
QLabel* labelCode = new QLabel(healthMsg);
labelCode->setAutoFillBackground(true);
labelCode->setAlignment(Qt::AlignCenter);
labelCode->setFixedWidth(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.7));
if(0 == type){
labelCodePic->setPixmap(QPixmap(":/res/image/health_code_green_large.png"));
labelCode->setText(tr("绿码"));
pal.setColor(QPalette::WindowText, green);
QColor bg(green);
pal.setColor(QPalette::Background, QColor(200, 247, 200, 100));
}else if(1 == type){
labelCodePic->setPixmap(QPixmap(":/res/image/health_code_yellow_large.png"));
labelCode->setText(tr("黄码"));
pal.setColor(QPalette::WindowText, yellow);
pal.setColor(QPalette::Background, QColor(232, 105, 20, 100));
}else if(2 == type){
labelCodePic->setPixmap(QPixmap(":/res/image/health_code_red_large.png"));
labelCode->setText(tr("红码"));
pal.setColor(QPalette::WindowText, red);
pal.setColor(QPalette::Background, QColor(218, 59, 59, 100));
}
labelCode->setPalette(pal);
QLabel* labelNameTip = new QLabel(healthMsg);
labelNameTip->setText(tr("姓名:"));
labelNameTip->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(8);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
labelNameTip->setFont(ft);
m_labelName = new QLabel("张**", healthMsg);
m_labelName->setPalette(labelPal);
m_labelName->setFont(ft);
QLabel* labelIdNoTip = new QLabel(healthMsg);
labelIdNoTip->setText(tr("身份证:"));
labelIdNoTip->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(8);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
labelIdNoTip->setFont(ft);
m_labelIdNo = new QLabel("**************5934", healthMsg);
m_labelIdNo->setPalette(labelPal);
m_labelIdNo->setFont(ft);
pal.setColor(QPalette::WindowText, Qt::white);
pal.setColor(QPalette::Background, QColor(245, 245, 245));
const int MSG_WGT_WIDTH = static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.4);
const int MSG_WGT_HEIGHT = static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.25);
m_covid19Testing = new RoundedWidget(healthMsg);
m_covid19Testing->setFixedSize(MSG_WGT_WIDTH, MSG_WGT_HEIGHT);
m_covid19Testing->setAutoFillBackground(true);
m_covid19Testing->setPalette(pal);
m_labelC19TTitle = new QLabel(m_covid19Testing);
m_labelC19TTitle->setText(tr("核酸检测"));
m_labelC19TTitle->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(8);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelC19TTitle->setFont(ft);
#if 0
m_labelC19TRes = new QLabel("24小时阴性", m_covid19Testing);
m_labelC19TRes->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(8);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelC19TRes->setFont(ft);
#endif
m_stackC19T = new QStackedWidget(m_covid19Testing);
m_stackC19T->setFixedSize(static_cast<int>(MSG_WGT_WIDTH * 0.8), static_cast<int>(MSG_WGT_HEIGHT * 0.4));
for(int i=0; i<3; i++){
QWidget* wgt = new QWidget(m_stackC19T);
QLabel* time = new QLabel(QString::number((i + 1) * 24), wgt);
time->setPalette(pal);
ft.setPointSize(16);
time->setFont(ft);
QLabel* tip = new QLabel("小时\n阴性", wgt);
tip->setPalette(pal);
ft.setPointSize(6);
tip->setFont(ft);
QHBoxLayout* hb = new QHBoxLayout();
hb->addStretch();
hb->addWidget(time);
hb->addWidget(tip);
//hb->setSpacing(0);
hb->setMargin(0);
hb->addStretch();
wgt->setLayout(hb);
m_stackC19T->addWidget(wgt);
}
ft.setBold(true);
ft.setPointSize(10);
QLabel* labelNegative = new QLabel("阴性", m_stackC19T);
labelNegative->setFont(ft);
labelNegative->setAlignment(Qt::AlignCenter);
m_stackC19T->addWidget(labelNegative);
QLabel* labelPositive = new QLabel("阳性", m_stackC19T);
labelPositive->setFont(ft);
labelPositive->setAlignment(Qt::AlignCenter);
m_stackC19T->addWidget(labelPositive);
pal.setColor(QPalette::WindowText, Qt::black);
QLabel* labelNodata = new QLabel("暂无数据", m_stackC19T);
labelNodata->setAlignment(Qt::AlignCenter);
labelNodata->setPalette(pal);
ft.setBold(true);
ft.setPointSize(10);
labelNodata->setFont(ft);
m_stackC19T->addWidget(labelNodata);
m_stackC19T->setCurrentIndex(5); //test.........................................................
m_labelC19TTime = new QLabel("2022-04-01", m_covid19Testing);
m_labelC19TTime->setPalette(labelPal);
ft.setBold(false);
ft.setPointSize(6);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelC19TTime->setFont(ft);
RoundedWidget* antibodyTesting = new RoundedWidget(healthMsg);
antibodyTesting->setFixedSize(MSG_WGT_WIDTH, MSG_WGT_HEIGHT);
antibodyTesting->setAutoFillBackground(true);
antibodyTesting->setPalette(pal);
m_labelABTTitle = new QLabel(antibodyTesting);
m_labelABTTitle->setText(tr("新冠疫苗"));
m_labelABTTitle->setPalette(labelPal);
m_labelABTTitle->setAlignment(Qt::AlignCenter);
ft.setBold(false);
ft.setPointSize(8);
//ft.setPointSize(PERSON_NAME_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelABTTitle->setFont(ft);
m_labelABTRes = new QLabel("已接种第3针", antibodyTesting);
m_labelABTRes->setAlignment(Qt::AlignCenter);
m_labelABTRes->setFixedSize(static_cast<int>(MSG_WGT_WIDTH * 0.8), static_cast<int>(MSG_WGT_HEIGHT * 0.4));
m_labelABTRes->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(10);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelABTRes->setFont(ft);
m_labelABTTime = new QLabel("2022-4-2 15:33:34", antibodyTesting);
m_labelABTTime->setPalette(labelPal);
m_labelABTTime->setAlignment(Qt::AlignCenter);
ft.setBold(false);
ft.setPointSize(6);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelABTTime->setFont(ft);
m_labelAccRes = new QLabel("请通行", this);
labelPal.setColor(QPalette::WindowText, Qt::white);
m_labelAccRes->setPalette(labelPal);
ft.setBold(true);
ft.setPointSize(16);
//ft.setPointSize(WEL_MSG_FONT_SIZE[UiConfig::GetInstance()->getScreenConfigIndex()][UiConfig::GetInstance()->getLanguageType()]);
m_labelAccRes->setFont(ft);
QHBoxLayout* hlayTemp = new QHBoxLayout();
hlayTemp->addStretch();
hlayTemp->addWidget(m_labelTempTip);
hlayTemp->addWidget(m_labelTemp);
hlayTemp->addStretch();
hlayTemp->setSpacing(0);
QHBoxLayout* hlayName = new QHBoxLayout();
hlayName->addStretch();
hlayName->addWidget(labelNameTip);
hlayName->addWidget(m_labelName);
hlayName->addStretch();
QHBoxLayout* hlayIdNo = new QHBoxLayout();
hlayIdNo->addStretch();
hlayIdNo->addWidget(labelIdNoTip);
hlayIdNo->addWidget(m_labelIdNo);
hlayIdNo->addStretch();
QVBoxLayout* vlayIdMsg = new QVBoxLayout();
vlayIdMsg->addLayout(hlayName);
vlayIdMsg->addLayout(hlayIdNo);
QVBoxLayout* vlayCovid19Testing = new QVBoxLayout();
vlayCovid19Testing->addWidget(m_labelC19TTitle, 1, Qt::AlignCenter);
//vlayCovid19Testing->addWidget(m_labelC19TRes, 1, Qt::AlignCenter);
vlayCovid19Testing->addWidget(m_stackC19T, 1, Qt::AlignCenter);
vlayCovid19Testing->addWidget(m_labelC19TTime, 1, Qt::AlignCenter);
vlayCovid19Testing->setSpacing(0);
m_covid19Testing->setLayout(vlayCovid19Testing);
QVBoxLayout* vlayAntibodyTesting = new QVBoxLayout();
vlayAntibodyTesting->addWidget(m_labelABTTitle, 1, Qt::AlignCenter);
vlayAntibodyTesting->addWidget(m_labelABTRes, 1, Qt::AlignCenter);
vlayAntibodyTesting->addWidget(m_labelABTTime, 1, Qt::AlignCenter);
vlayAntibodyTesting->setSpacing(0);
antibodyTesting->setLayout(vlayAntibodyTesting);
QHBoxLayout* hlayTesting = new QHBoxLayout();
hlayTesting->addWidget(m_covid19Testing);
hlayTesting->addWidget(antibodyTesting);
hlayTesting->setSpacing(0);
QVBoxLayout* vlayHealth = new QVBoxLayout();
vlayHealth->addLayout(hlayTemp);
vlayHealth->addWidget(labelCodePic, 1, Qt::AlignCenter);
vlayHealth->addLayout(vlayIdMsg);
vlayHealth->addWidget(labelCode, 1, Qt::AlignCenter);
vlayHealth->addLayout(hlayTesting);
healthMsg->setLayout(vlayHealth);
// acc msg
RoundedWidget* accMsg = new RoundedWidget(this);
accMsg->setFixedSize(static_cast<int>(UiConfig::GetInstance()->getUiWidth() * 0.9),
static_cast<int>(UiConfig::GetInstance()->getUiHeight() * 0.2));
pal.setColor(QPalette::Background, QColor(255, 255, 255, 255));
accMsg->setAutoFillBackground(true);
accMsg->setPalette(pal);
m_labelAcc = new QLabel(accMsg);
if(0 == type){
m_labelAcc->setPixmap(QPixmap(":/res/image/pass_large.png"));
}else{
m_labelAcc->setPixmap(QPixmap(":/res/image/no_entry_large.png"));
}
m_labelTripRes = new QLabel("近14天途经中高风险地区", accMsg);
m_labelTripRes->setWordWrap(true);
m_labelTripRes->setAlignment(Qt::AlignCenter);
ft.setPointSize(10);
m_labelTripRes->setFont(ft);
m_labelTripResTime = new QLabel("2022-04-20 10:12:13", accMsg);
ft.setPointSize(6);
m_labelTripResTime->setFont(ft);
m_labelTripResTime->hide();
m_labelFacePic = new QWidget(accMsg);
m_labelFacePic->setAutoFillBackground(true);
QHBoxLayout* hlayAccRes = new QHBoxLayout();
hlayAccRes->addStretch();
hlayAccRes->addWidget(m_labelAcc);
hlayAccRes->addWidget(m_labelAccRes);
hlayAccRes->addStretch();
hlayAccRes->setSpacing(5);
QVBoxLayout* vlayTrip = new QVBoxLayout();
//vlayTrip->addWidget(m_labelAccRes, 1, Qt::AlignCenter);
vlayTrip->addLayout(hlayAccRes);
vlayTrip->addWidget(m_labelTripRes, 99, Qt::AlignCenter);
vlayTrip->addWidget(m_labelTripResTime, 1, Qt::AlignCenter);
vlayTrip->setSpacing(5);
vlayTrip->setMargin(5);
QHBoxLayout* hlayAcc = new QHBoxLayout();
//hlayAcc->addWidget(m_labelAcc);
hlayAcc->addLayout(vlayTrip);
hlayAcc->addWidget(m_labelFacePic);
hlayAcc->setSpacing(5);
hlayAcc->setMargin(5);
accMsg->setLayout(hlayAcc);
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(m_labelTitle, 1, Qt::AlignCenter | Qt::AlignTop);
//vlay->addWidget(m_labelCurTime, 1, Qt::AlignCenter | Qt::AlignTop);//
vlay->addWidget(healthMsg, 6, Qt::AlignCenter | Qt::AlignTop);
vlay->addStretch();
vlay->addWidget(accMsg, 1, Qt::AlignCenter | Qt::AlignBottom);
//vlay->setContentsMargins(0, 10, 0, (UiConfig::GetInstance()->getUiHeight() / 12) >> 1 << 1);
//vlay->setMargin(0);
setLayout(vlay);
}
#endif
void recoUiHealthCodePage::showTemp(float temp)
{
if(temp > 2.0f){
QString strTemp;
strTemp.setNum(temp, 'f', 1);
strTemp += "";
m_labelTemp->setText(strTemp);
m_labelTemp->show();
m_labelTempTip->show();
}else{
m_labelTempTip->hide();
m_labelTemp->hide();
}
}
void recoUiHealthCodePage::showPersonMsg(const QString& name, const QString& idNum, const unsigned char* jpgDate, int len)
{
m_labelName->setText(name.contains("*") ? name : QString(utils::hideStrMidSeg(name.toStdString()).c_str()));
m_labelIdNo->setText(idNum.contains("*") ? idNum : idNum.left(4) + QString(idNum.size() - 8, QChar('*')) + idNum.right(4));
//m_labelCurTime->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
if(jpgDate == nullptr || len <= 0){
qDebug() << "face img data error";
m_labelFacePic->hide();
return;
}
QImage faceImg;
faceImg.loadFromData(jpgDate, len, "JPG");
if(faceImg.isNull()){
qDebug() << "load face img failed!";
return;
}
QPalette pal(m_labelFacePic->palette());
QImage img(ScaleImage(faceImg,
QSize(PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()],
PIC_WIDGET_H_W[UiConfig::GetInstance()->getScreenConfigIndex()])));
m_labelFacePic->setFixedSize(img.width(), img.height());
pal.setBrush(QPalette::Background, QBrush(img));
m_labelFacePic->setPalette(pal);
m_labelFacePic->show();
}
void recoUiHealthCodePage::showAntibodyTestingMsg(int num, const QString& testingTime)
{
QPalette pal(m_labelABTRes->palette());
if(num > 0){
m_labelABTRes->setText(QString("已接种第%1针").arg(num));
pal.setColor(QPalette::WindowText, green);
m_labelABTTime->setText(testingTime);
m_labelABTTime->show();
}else{
m_labelABTRes->setText(tr("暂无数据"));
pal.setColor(QPalette::WindowText, Qt::black);
m_labelABTTime->hide();
}
m_labelABTRes->setPalette(pal);
}
void recoUiHealthCodePage::showCovid19TestingMsg(int res, const QString& testingTime)
{
QPalette palTitle(m_labelC19TTitle->palette());
QPalette pal(m_covid19Testing->palette());
if(res > 0){
if(1 == res){
qint64 interval = QDateTime::fromString(testingTime, "yyyy-MM-dd hh:mm:ss").secsTo(QDateTime::currentDateTime());
if(interval <= 24 * 3600){m_stackC19T->setCurrentIndex(0);pal.setColor(QPalette::Background, QColor(6, 118, 244));}
else if(interval <= 48 * 3600){m_stackC19T->setCurrentIndex(1);pal.setColor(QPalette::Background, QColor(131, 107, 231));}
else if(interval <= 72 * 3600){m_stackC19T->setCurrentIndex(2);pal.setColor(QPalette::Background, QColor(47, 191, 186));}
else{m_stackC19T->setCurrentIndex(3);pal.setColor(QPalette::Background, QColor(47, 191, 186));}
}else{
m_stackC19T->setCurrentIndex(4); //阳性
pal.setColor(QPalette::Background, QColor(218, 59, 59));
}
m_labelC19TTime->setText(testingTime);
m_labelC19TTime->show();
palTitle.setColor(QPalette::WindowText, Qt::white);
m_labelC19T->setPixmap(QPixmap(":/res/image/c19t_white_large.png"));
}else{
m_stackC19T->setCurrentIndex(5);
m_labelC19TTime->hide();
pal.setColor(QPalette::Background, QColor(245, 245, 245));
palTitle.setColor(QPalette::WindowText, Qt::black);
m_labelC19T->setPixmap(QPixmap(":/res/image/c19t_grey_large.png"));
}
m_covid19Testing->setPalette(pal);
m_labelC19TTitle->setPalette(palTitle);
}
void recoUiHealthCodePage::showAntiGenTestingMsg(int res, const QString& testingTime)
{
QPalette pal(m_labelABTRes->palette());
if(res > 0){
if(1 == res){
m_labelABTRes->setText("阴性");
pal.setColor(QPalette::WindowText, green);
}else if(2 == res){
m_labelABTRes->setText("阳性");
pal.setColor(QPalette::WindowText, red);
}
m_labelABTTime->setText(testingTime);
m_labelABTTime->show();
}else{
m_labelABTRes->setText(tr("暂无数据"));
pal.setColor(QPalette::WindowText, Qt::black);
m_labelABTTime->hide();
}
m_labelABTRes->setPalette(pal);
}
void recoUiHealthCodePage::showTripMsg(int res, const QString& tripCity)
{
QPalette pal(m_labelTripRes->palette());
if(tripCity.isEmpty()){
if(res > 0){
m_labelTripRes->setText(1 == res ? "近7日未途经中高风险地区" : "近7日途经中高风险地区");
pal.setColor(QPalette::WindowText, 1 == res ? green : red);
}else{
m_labelTripRes->setText("7天内经过 ");
pal.setColor(QPalette::WindowText, Qt::black);
}
m_labelTripRes->setPalette(pal);
}else{
do{
cJSON *root = cJSON_Parse(tripCity.toStdString().c_str());
if(!root){m_labelTripRes->setText("行程数据异常");break;}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
cJSON* jsonTmp = cJSON_GetObjectItem(root, "code");
if(!jsonTmp){m_labelTripRes->setText("行程数据异常");break;}
if(jsonTmp->valueint != 0){break;}
jsonTmp = cJSON_GetObjectItem(root, "data");
if(!jsonTmp){m_labelTripRes->setText("行程数据异常");break;}
cJSON* item = cJSON_GetObjectItem(jsonTmp, "riskLevel");
if(!item){m_labelTripRes->setText("行程数据异常");break;}
if(6 == item->valueint){
item = cJSON_GetObjectItem(jsonTmp, "status");
if(!item){m_labelTripRes->setText("行程数据异常");break;}
if(0 == item->valueint){m_labelTripRes->setText("行程卡识别失败,请重试");}
pal.setColor(QPalette::WindowText, Qt::black);
m_labelTripRes->setPalette(pal);
break;
}else if(1 == item->valueint || 2 == item->valueint){ //低风险、无风险
m_labelTripRes->setText("近7日未途经中高风险地区");
pal.setColor(QPalette::WindowText, Qt::green);
m_labelTripRes->setPalette(pal);
break;
}
QString showRes;
item = cJSON_GetObjectItem(jsonTmp, "keyAreas");
if(item){
int cnt = cJSON_GetArraySize(item);
LOGI("array size:%d", cnt);
QString citys;
for(int i=0; i<cnt; i++){
cJSON * arrayItem = cJSON_GetArrayItem(item, i);
if(arrayItem){if(i){citys += "";}citys += arrayItem->valuestring;}
}
if(cnt){
showRes += QString("<font color = #000000 >%1</font>").arg("近7日途经重点风险地区<br>");
showRes += QString("<font color = #800080 >%1</font>").arg(citys);
}
}
item = cJSON_GetObjectItem(jsonTmp, "highRiskAreas");
if(item){
int cnt = cJSON_GetArraySize(item);
LOGI("array size:%d", cnt);
QString citys;
for(int i=0; i<cnt; i++){
cJSON * arrayItem = cJSON_GetArrayItem(item, i);
if(arrayItem){if(i){citys += "";}citys += arrayItem->valuestring;}
}
if(cnt){
if(showRes.isEmpty()){showRes += QString("<font color = #000000 >%1</font>").arg("近7日途经高风险地区<br>");}
else{showRes += "";}
showRes += QString("<font color = #FF0000 >%1</font>").arg(citys);
}
}
item = cJSON_GetObjectItem(jsonTmp, "middleRiskAreas");
if(item){
int cnt = cJSON_GetArraySize(item);
LOGI("array size:%d", cnt);
QString citys;
for(int i=0; i<cnt; i++){
cJSON * arrayItem = cJSON_GetArrayItem(item, i);
if(arrayItem){if(i){citys += "";}citys += arrayItem->valuestring;}
}
if(cnt){
if(showRes.isEmpty()){showRes += QString("<font color = #000000 >%1</font>").arg("近7日途经中风险地区<br>");}
else{showRes += "";}
showRes += QString("<font color = #FFD700 >%1</font>").arg(citys);
}
}
m_labelTripRes->setText(showRes);
}while(0);
}
}
void recoUiHealthCodePage::showAccResult(bool pass, const QString& failReason, int bgColor)
{
m_labelAccRes->setText(pass ? tr("请通行") : tr("禁止通行"));
QPalette pal(m_labelAccRes->palette());
pal.setColor(QPalette::WindowText, pass ? green : red);
m_labelAccRes->setPalette(pal);
m_labelAcc->setPixmap(pass ? QPixmap(":/res/image/ok_large.png") : QPixmap(":/res/image/fail2_large.png"));
m_failReason->setText(failReason);
if(bgColor >= 0 && bgColor <= 3){
QPalette pal2 = palette();
const QColor colors[] = {green, yellow, red, purple};
pal2.setColor(QPalette::Background, colors[bgColor]);
setPalette(pal2);
}
}
void recoUiHealthCodePage::setResultShowType(int type)
{
switch(type){
case 1:
m_labelTitle->setText(tr("CA数字哨兵"));
m_labelABTTitle->setText(tr("抗原检测"));
break;
case 2:
m_labelTitle->setText(tr("智能防疫核验系统"));
break;
default:
break;
}
}
#if 0
void recoUiHealthCodePage::setBgColorByResult(int codeColor, int c19t, int trip, bool pass)
{
QColor color{green};
if(c19t == 2 || trip == 3){//核酸阳性、到过重点地区
color = purple;
}else if(trip == 4){//行程卡核验失败
color = yellow;
}else if(!pass){
color = red;
}
QPalette pal = palette();
pal.setColor(QPalette::Background, color);
setPalette(pal);
}
#endif
recoUiHealthCode::recoUiHealthCode(QWidget *parent) : WidgetWithBackstageInterface(parent)
{
qDebug() << "recoUiHealthCode()";
m_stackPages = new QStackedWidget(this);
m_pageGreen = new recoUiHealthCodePage(0, this);
m_stackPages->addWidget(m_pageGreen);
m_pageYellow = new recoUiHealthCodePage(1, this);
m_stackPages->addWidget(m_pageYellow);
m_pageRed = new recoUiHealthCodePage(2, this);
m_stackPages->addWidget(m_pageRed);
m_pageGrey = new recoUiHealthCodePage(3, this);
m_stackPages->addWidget(m_pageGrey);
QVBoxLayout* vlay = new QVBoxLayout();
vlay->addWidget(m_stackPages);
vlay->setMargin(0);
setLayout(vlay);
}
void recoUiHealthCode::showHealthMsg(int type, float temp, const QString& msg, bool pass,
const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
LOGI("_x_watch_point_, showHealthMsg type %d, msg %s", type, msg.toStdString().c_str());
//m_backstageIf->stopIdentyState();//需要外设输入如身份证终止展示
switch(type){
case 0:_showType0HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 1:_showType1HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 2:_showType2HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 3:_showType3HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 4:_showType4HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 5:_showType5HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 6:_showType6HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 7:_showType7HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 8:_showType8HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 9:_showType9HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
case 101:_showType101HealthData(temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor);break;
default:LOGE("unknow health data type:%d", type);
}
}
void recoUiHealthCode::setResultShowType(int type)
{
m_pageGreen->setResultShowType(type);
m_pageYellow->setResultShowType(type);
m_pageRed->setResultShowType(type);
m_pageGrey->setResultShowType(type);
}
void recoUiHealthCode::_showType0HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
QJsonParseError jsonError;
const QJsonDocument cfgDoc = QJsonDocument::fromJson(QByteArray(msg.toStdString().c_str()), &jsonError);
if (cfgDoc.isNull() || (jsonError.error != QJsonParseError::NoError)) {
qDebug() << "json data error:" << jsonError.error;
return;
}
const QJsonObject obj = cfgDoc.object();
if (!obj.contains("data")){
return;
}
const QJsonObject& resObj = obj.value("data").toObject();
recoUiHealthCodePage* page = m_pageGreen;
int pageIndex = 0;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
const QString& colorCode = resObj.value("jkmStatus").toString();
if(colorCode == "yellow"){page = m_pageYellow;pageIndex = 1;}
else if(colorCode == "red"){page = m_pageRed;pageIndex = 2;}
name = resObj.value("idCardName").toString(),
idNum = resObj.value("idCardNo").toString();
if(resObj.contains("hsjcSearchStatus") && 1 == resObj.value("hsjcSearchStatus").toInt()){
c19tRes = resObj.value("hsjcStatus").toString() == "阴性" ? 1 : 2;
c19tTime = resObj.value("hsjcQuestTime").toString();
}
if(resObj.contains("ymjzSearchStatus") && 1 == resObj.value("ymjzSearchStatus").toInt()){
abtRes = resObj.value("ymjzStatus").toInt();
abtTime = resObj.value("ymjzQuestTime").toString();
}
if(resObj.contains("xcmSearchStatus") && 1 == resObj.value("xcmSearchStatus").toInt()){
tripRes = ("1" == resObj.value("xcmStatus").toString() ? 1 : 2);//行程码返回数据为字符串
}
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType1HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGrey;
int pageIndex = 3;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
int cnt = cJSON_GetArraySize(root);
qDebug() << "cnt:" << cnt;
for(int i=0; i<cnt; i++){
cJSON * arrayItem = cJSON_GetArrayItem(root, i);
cJSON * hsRes = cJSON_GetObjectItem(arrayItem, "hs1_result");
if(hsRes){
hsRes = cJSON_GetObjectItem(hsRes, "data");
if(hsRes){hsRes = cJSON_GetObjectItem(hsRes, "data");}
if(hsRes){hsRes = cJSON_GetArrayItem(hsRes, 0);}
if(hsRes){
cJSON * jsTmp = cJSON_GetObjectItem(hsRes, "jcjg");
if(jsTmp){
const QString c19t{jsTmp->valuestring};
if(!c19t.isEmpty()){c19tRes = (c19t == "阴性" ? 1 : 2);}
}
jsTmp = cJSON_GetObjectItem(hsRes, "jc_rq");// 检测时间
if(jsTmp){c19tTime = jsTmp->valuestring;}
}
continue;
}
cJSON * ykmRes = cJSON_GetObjectItem(arrayItem, "ykm_result");
if(ykmRes){
ykmRes = cJSON_GetObjectItem(ykmRes, "data");
if(ykmRes){ykmRes = cJSON_GetObjectItem(ykmRes, "data");}
if(ykmRes){ykmRes = cJSON_GetArrayItem(ykmRes, 0);}
if(ykmRes){ykmRes = cJSON_GetObjectItem(ykmRes, "JKMYS");}
if(ykmRes){
if(QString(ykmRes->valuestring) == "绿"){page = m_pageGreen;pageIndex = 0;}
else if(QString(ykmRes->valuestring) == ""){page = m_pageYellow;pageIndex = 1;}
else if(QString(ykmRes->valuestring) == ""){page = m_pageRed;pageIndex = 2;}
}
continue;
}
cJSON * idMsg = cJSON_GetObjectItem(arrayItem, "sqfydsry_result");
if(idMsg){
cJSON * jsTmp = cJSON_GetObjectItem(idMsg, "identityNum");
if(jsTmp){idNum = jsTmp->valuestring;}
jsTmp = cJSON_GetObjectItem(idMsg, "name");
if(jsTmp){name = jsTmp->valuestring;}
continue;
}
cJSON * ymRes = cJSON_GetObjectItem(arrayItem, "ym_result");
if(ymRes){
ymRes = cJSON_GetObjectItem(ymRes, "data");
if(ymRes){ymRes = cJSON_GetObjectItem(ymRes, "data");}
if(ymRes){
int needleTimes = cJSON_GetArraySize(ymRes);
qDebug() << "needleTimes" << needleTimes;
QString nt{"0"};
for(int j=0; j<needleTimes; j++){
cJSON * jsArrayItem = cJSON_GetArrayItem(ymRes, j);
if(jsArrayItem){
cJSON * jsTmp = cJSON_GetObjectItem(jsArrayItem, "needletimes");
if(jsTmp){
if(QString(jsTmp->valuestring) > nt){
nt = jsTmp->valuestring;
jsTmp = cJSON_GetObjectItem(jsArrayItem, "inoculationdate");
if(jsTmp){abtTime = jsTmp->valuestring;}
}
}
}
}
abtRes = nt.toInt();
}
continue;
}
}
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType2HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGreen;
int pageIndex = 0;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
cJSON* jsonTmp = cJSON_GetObjectItem(root, "retCode");
if(!jsonTmp){return;}
if(0 != jsonTmp->valueint){return;}
jsonTmp = cJSON_GetObjectItem(root, "idCard");
if(jsonTmp){idNum = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "name");
if(jsonTmp){name = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "healthStatus");
if(jsonTmp){
const std::string status{jsonTmp->valuestring};
if(status == "中风险"){page = m_pageYellow;pageIndex = 1;}
else if(status == "高风险"){page = m_pageRed;pageIndex = 2;}
}
jsonTmp = cJSON_GetObjectItem(root, "covid19Testing");
if(jsonTmp){
cJSON * jsTmp = cJSON_GetObjectItem(jsonTmp, "result");
if(jsTmp){
const QString c19t{jsTmp->valuestring};
if(!c19t.isEmpty()){c19tRes = (c19t == "阴性" ? 1 : 2);}
}
jsTmp = cJSON_GetObjectItem(jsonTmp, "testingTime");
if(jsTmp){c19tTime = jsTmp->valuestring;}
}
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType3HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGreen;
int pageIndex = 0;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
//TODO
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType4HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGreen;
int pageIndex = 0;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
cJSON* jsonTmp = cJSON_GetObjectItem(root, "health");
if(jsonTmp){
cJSON* jsTmp = cJSON_GetObjectItem(jsonTmp, "color");
if(jsTmp){
std::string colorCode{jsTmp->valuestring};
if("yellow" == colorCode){page = m_pageYellow;pageIndex = 1;}
else if("red" == colorCode){page = m_pageRed;pageIndex = 2;}
}
}
jsonTmp = cJSON_GetObjectItem(root, "nucleicAcid");
if(jsonTmp){
cJSON * jsTmp = cJSON_GetObjectItem(jsonTmp, "colorText");
if(jsTmp){
std::string c19t{jsTmp->valuestring};
if("阴性" == c19t){c19tRes = 1;}
else if("阳性" == c19t){c19tRes = 2;}
}
jsTmp = cJSON_GetObjectItem(jsonTmp, "datetime");
if(jsTmp){c19tTime = jsTmp->valuestring;}
}
jsonTmp = cJSON_GetObjectItem(root, "vaccine");
if(jsonTmp){
cJSON * jsTmp = cJSON_GetObjectItem(jsonTmp, "count");
if(jsTmp){abtRes = jsTmp->valueint;}
jsTmp = cJSON_GetObjectItem(jsonTmp, "date");
if(jsTmp){abtTime = jsTmp->valuestring;}
}
jsonTmp = cJSON_GetObjectItem(root, "user");
if(jsonTmp){
cJSON * jsTmp = cJSON_GetObjectItem(jsonTmp, "name");
if(jsTmp){name = jsTmp->valuestring;}
jsTmp = cJSON_GetObjectItem(jsonTmp, "idNo");
if(jsTmp){idNum = jsTmp->valuestring;}
}
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType5HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
if(m_resultType != 1){
m_resultType = 1;
setResultShowType(m_resultType);
}
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGrey;
int pageIndex = 3;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
cJSON* jsonTmp = cJSON_GetObjectItem(root, "code");
if(!jsonTmp){return;}
if(0 != jsonTmp->valueint){return;}
jsonTmp = cJSON_GetObjectItem(root, "result");
if(!jsonTmp){return;}
cJSON* item = cJSON_GetObjectItem(jsonTmp, "name");
if(item){name = item->valuestring;}
item = cJSON_GetObjectItem(jsonTmp, "paper_no");
if(item){idNum = item->valuestring;}
item = cJSON_GetObjectItem(jsonTmp, "health_code");
if(item){
std::string colorCode{item->valuestring};
if("00" == colorCode){page = m_pageGreen;pageIndex = 0;}
else if("01" == colorCode){page = m_pageYellow;pageIndex = 1;}
else if("10" == colorCode){page = m_pageRed;pageIndex = 2;}
}
item = cJSON_GetObjectItem(jsonTmp, "nucleic_info");
int cnt = cJSON_GetArraySize(item);
LOGI("array size:%d", cnt);
//for(int i=0; i<cnt; i++)
{
cJSON * arrayItem = cJSON_GetArrayItem(item, 0);
cJSON * jsTmp = cJSON_GetObjectItem(arrayItem, "nat_result");
if(jsTmp){
std::string c19t{jsTmp->valuestring};
if(c19t.find("阴性") != std::string::npos){c19tRes = 1;}
else if(c19t.find("阳性") != std::string::npos){c19tRes = 2;}
}
jsTmp = cJSON_GetObjectItem(arrayItem, "nat_time");// 检测时间
if(jsTmp){c19tTime = jsTmp->valuestring;}
}
#if 0
item = cJSON_GetObjectItem(jsonTmp, "vaccine_info");
if(item){
cJSON * jsTmp = cJSON_GetObjectItem(item, "count");
if(jsTmp){abtRes = jsTmp->valueint;}
jsTmp = cJSON_GetObjectItem(item, "last_vac_time");
if(jsTmp){abtTime = jsTmp->valuestring;}
}
#else
item = cJSON_GetObjectItem(jsonTmp, "antigen_info");
if(item){
cJSON * jsTmp = cJSON_GetObjectItem(item, "antigen_code");
if(jsTmp){
std::string antiGen{jsTmp->valuestring};
if(antiGen == "-1"){abtRes = 1;}
else if(antiGen == "1"){abtRes = 2;}
}
jsTmp = cJSON_GetObjectItem(item, "report_time");
if(jsTmp){abtTime = jsTmp->valuestring;}
}
#endif
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
//page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showAntiGenTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showTypexHealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGreen;
int pageIndex = 0;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
cJSON* jsonTmp = cJSON_GetObjectItem(root, "code");
if(!jsonTmp){return;}
if(std::string(jsonTmp->valuestring) != "0000"){return;}
jsonTmp = cJSON_GetObjectItem(root, "data");
if(!jsonTmp){return;}
cJSON* item = cJSON_GetObjectItem(jsonTmp, "queryStatus");
if(!item){return;}
if(std::string(jsonTmp->valuestring) != "0"){return;}
item = cJSON_GetObjectItem(jsonTmp, "name");
if(item){name = item->valuestring;}
item = cJSON_GetObjectItem(jsonTmp, "idcardNo");
if(item){idNum = item->valuestring;}
item = cJSON_GetObjectItem(jsonTmp, "level");
if(item){
std::string colorCode{item->valuestring};
if("YELLOW" == colorCode){page = m_pageYellow;pageIndex = 1;}
else if("RED" == colorCode){page = m_pageRed;pageIndex = 2;}
}
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType101HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGreen;
int pageIndex = 0;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
cJSON* jsonTmp = cJSON_GetObjectItem(root, "errcode");
if(!jsonTmp){return;}
if(jsonTmp->valueint != 0){return;}
jsonTmp = cJSON_GetObjectItem(root, "data");
if(!jsonTmp){return;}
cJSON* item = cJSON_GetObjectItem(jsonTmp, "color");
if(item){
std::string colorCode{item->valuestring};
if("Y" == colorCode){page = m_pageYellow;pageIndex = 1;}
else if("R" == colorCode){page = m_pageRed;pageIndex = 2;}
}
item = cJSON_GetObjectItem(jsonTmp, "name");
if(item){name = item->valuestring;}
item = cJSON_GetObjectItem(jsonTmp, "cid");
if(item){idNum = item->valuestring;}
item = cJSON_GetObjectItem(jsonTmp, "ext");
if(item){
cJSON *r = cJSON_Parse(item->valuestring);
if(r){
ON_SCOPE_EXIT([&]{cJSON_Delete(r);});
item = cJSON_GetObjectItem(r, "nat");
if(item){
int cnt = cJSON_GetArraySize(item);
LOGI("array size:%d", cnt);
if(cnt){
cJSON * arrayItem = cJSON_GetArrayItem(item, 0);
if(arrayItem){
cJSON * jsTmp = cJSON_GetObjectItem(arrayItem, "result");
if(jsTmp){
std::string c19t{jsTmp->valuestring};
if("阴性" == c19t){c19tRes = 1;}
else if("阳性" == c19t){c19tRes = 2;}
}
jsTmp = cJSON_GetObjectItem(arrayItem, "dtime");
if(jsTmp){c19tTime = jsTmp->valuestring;}
}
}
}
item = cJSON_GetObjectItem(r, "vac");
if(item){
int cnt = cJSON_GetArraySize(item);
LOGI("array size:%d", cnt);
if(cnt){
cJSON * arrayItem = cJSON_GetArrayItem(item, 0);
if(arrayItem){
cJSON * jsTmp = cJSON_GetObjectItem(arrayItem, "needle_times");
if(jsTmp){abtRes = jsTmp->valueint;}
jsTmp = cJSON_GetObjectItem(arrayItem, "date");
if(jsTmp){abtTime = jsTmp->valuestring;}
}
}
}
}
}
#if 0
jsonTmp = cJSON_GetObjectItem(root, "healthCode");
if(jsonTmp){
cJSON *r = cJSON_Parse(jsonTmp->valuestring);
if(r){
ON_SCOPE_EXIT([&]{cJSON_Delete(r);});
item = cJSON_GetObjectItem(r, "name");
if(item){name = item->valuestring;}
item = cJSON_GetObjectItem(r, "cid");
if(item){idNum = item->valuestring;}
}
}
#endif
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType6HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor)
{
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGrey;
int pageIndex = 3;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
cJSON* jsonTmp = cJSON_GetObjectItem(root, "code");
if(!jsonTmp){return;}
if(std::string(jsonTmp->valuestring) != "0000"){return;}
jsonTmp = cJSON_GetObjectItem(root, "ID");
if(jsonTmp && jsonTmp->valuestring){idNum = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "name");
if(jsonTmp && jsonTmp->valuestring){name = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "provinceRisklevel");
if(jsonTmp && jsonTmp->valuestring){
const std::string status{jsonTmp->valuestring};
if(status == "00"){page = m_pageGreen;pageIndex = 0;}
else if(status == "01"){page = m_pageYellow;pageIndex = 1;}
else if(status == "10"){page = m_pageRed;pageIndex = 2;}
}
jsonTmp = cJSON_GetObjectItem(root, "hsjcjg");
if(jsonTmp && jsonTmp->valuestring){
std::string c19t{jsonTmp->valuestring};
if("阴性" == c19t){c19tRes = 1;}
else if("阳性" == c19t){c19tRes = 2;}
}
jsonTmp = cJSON_GetObjectItem(root, "hsjcsj");
if(jsonTmp && jsonTmp->valuestring){c19tTime = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "ymjzcs");
if(jsonTmp){abtRes = jsonTmp->valueint;}
jsonTmp = cJSON_GetObjectItem(root, "jzrq");
if(jsonTmp && jsonTmp->valuestring){abtTime = jsonTmp->valuestring;}
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType7HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor){
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGrey;
int pageIndex = 3;
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
QString antiGentime;
int tripRes = 0;
// int antigenSts = 0;
cJSON* state = cJSON_GetObjectItem(root, "state");
if(!state && state->valueint != 1) return;
cJSON* data = cJSON_GetObjectItem(root, "data");
if(!data) return;
cJSON* jsonTmp = cJSON_GetObjectItem(data, "health_status");
if(jsonTmp){
//FJQRJKM 健康码颜色 "1":红码; "2":黄码; "3":绿码
if(strcmp(jsonTmp->valuestring, "3") == 0){page = m_pageGreen;pageIndex = 0;}
else if(strcmp(jsonTmp->valuestring, "2") == 0){page = m_pageYellow;pageIndex = 1;}
else if(strcmp(jsonTmp->valuestring, "1") == 0){page = m_pageRed;pageIndex = 2;}
}
jsonTmp = cJSON_GetObjectItem(data, "vaccines_num");
if(jsonTmp){
//疫苗接种次数
abtRes = atoi(jsonTmp->valuestring);
}
jsonTmp = cJSON_GetObjectItem(data, "caid_status");
if(jsonTmp){
//FJQRJKM 核酸检测结果 "-1":异常; "0":无 核酸; "2":阴性; "1":阳性
c19tRes = 0;
if(strcmp(jsonTmp->valuestring, "2") == 0){
c19tRes = 1;
}else if(strcmp(jsonTmp->valuestring, "1") == 0){
c19tRes = 2;
}
}
jsonTmp = cJSON_GetObjectItem(data, "newest_sampling_time");
// if(jsonTmp) {c19tTime = QString::fromStdString(FileUtils::getTimeString(atol(jsonTmp->valuestring)));}
if(jsonTmp && std::string(jsonTmp->valuestring) != ""){
int newestSamplingTimeStp = atol(jsonTmp->valuestring);
if(newestSamplingTimeStp > 0){
c19tTime = QString::fromStdString(FileUtils::getTimeString(newestSamplingTimeStp));
}
}
if(c19tTime.isEmpty() && c19tRes > 0){
LOGI("c19 time invalid!!!");
c19tRes = 0;
}
jsonTmp = cJSON_GetObjectItem(data, "user_name");
if(jsonTmp) {name = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(data, "cid");
if(jsonTmp) {idNum = jsonTmp->valuestring;}
//停留中高风险地区状态 0-去过1-未去过2-信息不全
jsonTmp = cJSON_GetObjectItem(data, "stay_risk_area_status");
if(jsonTmp){
#if 0
if(strcmp(jsonTmp->valuestring, "0") == 0){
tripRes = 2;
}else if(strcmp(jsonTmp->valuestring, "1") == 0){
tripRes = 1;
}
#else
//07天内途经省内中高风险地区且无省外旅居史17天内未途经省内中高风险地区且无省外旅居史27天内有省外旅居史
if(std::string(jsonTmp->valuestring) == "0"){tripRes = 2;}
else if(std::string(jsonTmp->valuestring) == "1"){tripRes = 1;}
else if(std::string(jsonTmp->valuestring) == "2"){tripRes = 2;}
#endif
}
//抗原检测结果 -1:异常; 0:无抗原检测; 2:阴性; 1:阳性 目前不作展示
// jsonTmp = cJSON_GetObjectItem(data, "antigen_status");
// if(jsonTmp != nullptr){
// if(strcmp(jsonTmp->valuestring, "2") == 0){
// antigenSts = 1;
// }else if(strcmp(jsonTmp->valuestring, "1") == 0){
// antigenSts = 2;
// }
// }
// jsonTmp = cJSON_GetObjectItem(data, "newest_antigen_time");
// if(jsonTmp != nullptr){
// antiGentime = QString::fromStdString(FileUtils::getTimeString(atol(jsonTmp->valuestring)));
// }
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, (c19tRes > 0)&&(!c19tTime.toStdString().empty()) ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, (abtRes > 0) && (!abtTime.toStdString().empty()) ? abtTime : "");
// page->showAntiGenTestingMsg(antigenSts, (antigenSts > 0) && (!antiGentime.toStdString().empty()) ? antiGentime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType8HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor){
if(m_resultType != 2){
m_resultType = 2;
setResultShowType(m_resultType);
}
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if (!root) {
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
QString name;
QString idNum;
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
QString antiGentime;
int tripRes = 0;
// int antigenSts = 0;
recoUiHealthCodePage* page = m_pageGrey;
int pageIndex = 3;
cJSON* state = cJSON_GetObjectItem(root, "code");
if(!state && std::string(state->valuestring) != "0") return;
cJSON* jsonTmp = cJSON_GetObjectItem(root, "idNum");
if(jsonTmp) {idNum = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "name");
if(jsonTmp) {name = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "healthSts");
if(jsonTmp){
//颜色:"0":绿码; "1":黄码; "2":红码;
if(strcmp(jsonTmp->valuestring, "0") == 0){page = m_pageGreen;pageIndex = 0;}
else if(strcmp(jsonTmp->valuestring, "1") == 0){page = m_pageYellow;pageIndex = 1;}
else if(strcmp(jsonTmp->valuestring, "2") == 0){page = m_pageRed;pageIndex = 2;}
}
jsonTmp = cJSON_GetObjectItem(root, "caidSts");
if(jsonTmp){
//核酸检测结果 "-1":无结果; "0":阴性; "1":阳性
if(std::string(jsonTmp->valuestring) == "0"){
c19tRes = 1;
}if(std::string(jsonTmp->valuestring) == "1"){
c19tRes = 2;
}
}
jsonTmp = cJSON_GetObjectItem(root, "caidNewstSampleTime");
if(jsonTmp) {c19tTime = jsonTmp->valuestring;}
if(c19tTime.isEmpty() && c19tRes > 0){
LOGI("c19 time invalid!!!");
c19tRes = 0;
}
jsonTmp = cJSON_GetObjectItem(root, "vaccinesNum");
if(jsonTmp) {abtRes = jsonTmp->valueint;}
jsonTmp = cJSON_GetObjectItem(root, "vaccinesNewstTime");
if(jsonTmp) {abtTime = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "stayRiskAreaSts");
if(jsonTmp){
#if 0
if(std::string(jsonTmp->valuestring) == "0"){tripRes = 1;}
else if(std::string(jsonTmp->valuestring) == "1"){tripRes = 2;}
#else
//07天内途经省内中高风险地区且无省外旅居史17天内未途经省内中高风险地区且无省外旅居史27天内有省外旅居史
if(std::string(jsonTmp->valuestring) == "0"){tripRes = 2;}
else if(std::string(jsonTmp->valuestring) == "1"){tripRes = 1;}
else if(std::string(jsonTmp->valuestring) == "2"){tripRes = 2;}
#endif
}
//抗原检测结果 -1:异常; 0:无抗原检测; 2:阴性; 1:阳性 目前不作展示
// jsonTmp = cJSON_GetObjectItem(data, "antigen_status");
// if(jsonTmp != nullptr){
// if(strcmp(jsonTmp->valuestring, "2") == 0){
// antigenSts = 1;
// }else if(strcmp(jsonTmp->valuestring, "1") == 0){
// antigenSts = 2;
// }
// }
// jsonTmp = cJSON_GetObjectItem(data, "newest_antigen_time");
// if(jsonTmp != nullptr){
// antiGentime = QString::fromStdString(FileUtils::getTimeString(atol(jsonTmp->valuestring)));
// }
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}
void recoUiHealthCode::_showType9HealthData(float temp, const QString& msg, bool pass, const unsigned char* jpgDate, int jpgLen, const QString& tripCity, const QString& failReason, int bgColor){
cJSON *root = cJSON_Parse(msg.toStdString().c_str());
if(!root){
qDebug() << "json data error";
return;
}
ON_SCOPE_EXIT([&]{cJSON_Delete(root);});
recoUiHealthCodePage* page = m_pageGrey;
int pageIndex = 3;
QString name;
QString idNum{"******************"};
int c19tRes = 0;
QString c19tTime;
int abtRes = 0;
QString abtTime;
int tripRes = 0;
cJSON* jsonTmp = cJSON_GetObjectItem(root, "errcode");
if(!jsonTmp){return;}
QString errCode{jsonTmp->valuestring};
if( errCode != "000000" && (errCode < "100303" || errCode > "100306") ){return;}
jsonTmp = cJSON_GetObjectItem(root, "colourstatus");
if(jsonTmp){
//健康码颜色 "1":红码; "2":黄码; "0":绿码
if(strcmp(jsonTmp->valuestring, "0") == 0){page = m_pageGreen;pageIndex = 0;;}
else if(strcmp(jsonTmp->valuestring, "1") == 0){page = m_pageRed;pageIndex = 2;}
else if(strcmp(jsonTmp->valuestring, "2") == 0){page = m_pageYellow;pageIndex = 1;}
}
jsonTmp = cJSON_GetObjectItem(root, "hsstatus");
if(jsonTmp){//核酸检测结果,0阴性1阳性
c19tRes = 0;
if(strcmp(jsonTmp->valuestring, "0") == 0){c19tRes = 1;}
else if(strcmp(jsonTmp->valuestring, "1") == 0){c19tRes = 2;}
}
jsonTmp = cJSON_GetObjectItem(root, "hsjcsj"); //检测时间, hscysj采样时间
if(jsonTmp){c19tTime = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "name");
if(jsonTmp){name = jsonTmp->valuestring;}
jsonTmp = cJSON_GetObjectItem(root, "ymtimes");
if(jsonTmp){abtRes = atoi(jsonTmp->valuestring);}
jsonTmp = cJSON_GetObjectItem(root, "ymzssj");
if(jsonTmp){abtTime = jsonTmp->valuestring;}
page->showTemp(temp);
page->showPersonMsg(name, idNum, jpgDate, jpgLen);
page->showCovid19TestingMsg(c19tRes, c19tRes > 0 ? c19tTime : "");
page->showAntibodyTestingMsg(abtRes, abtRes > 0 ? abtTime : "");
page->showTripMsg(tripRes, tripCity);
page->showAccResult(pass, failReason, bgColor);
m_stackPages->setCurrentIndex(pageIndex);
}