123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- #include "etMobileTest.h"
- #include "ui_etMobileTest.h"
- #include <QScrollBar>
- #include <QHBoxLayout>
- #include <QLabel>
- #include "CAppInfo.h"
- #include "CQREncode.h"
- #include "awMsgBox.h"
- etMobileTest::etMobileTest(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::etMobileTest)
- {
- ui->setupUi(this);
- setStyleSheet(g_appInfoPtr->m_sQssStr);
- m_nUploadStatus = 2;
- qRegisterMetaType<CGetWXQrCode>("CGetWXQrCode");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnGetWXQrCode, this, &etMobileTest::onGetWXQrCode);
- qRegisterMetaType<CSaveUploadedFileAcknowledgeStatus>("CSaveUploadedFileAcknowledgeStatus");
- connect(g_httpBllPtr.get(), &CHttpBll::sgnSaveUploadedFileAcknowledgeStatus, this, &etMobileTest::onSaveUploadedFileAcknowledgeStatus);
- if (g_websocketPtr == nullptr)
- {
- g_websocketPtr = std::make_shared<CWebsocketProc>();
- }
- g_websocketPtr->open(QString("wss://%1:%2/api/ws/fileAnswer")
- .arg(g_appInfoPtr->m_sHttpServer).arg(g_appInfoPtr->m_sHttpPort),
- g_httpBllPtr->getToken(), g_httpBllPtr->getKey());
- connect(g_websocketPtr.get(), &CWebsocketProc::mobileStatus, this, &etMobileTest::onMobileStatus);
- connect(g_websocketPtr.get(), &CWebsocketProc::fileAnswer, this, &etMobileTest::onFileAnswer);
- CHttpRequestPackage hrp;
- hrp.sUri = "/api/ecs_oe_student/examControl/getQrCode";
- hrp.nRequestType = RequestType::rtGetWXQrCode;
- Json::Value jBody = Json::Value::null;
- jBody["examRecordDataId"] = g_appInfoPtr->m_oExamInfo.nExamId;
- jBody["order"] = 1;
- jBody["transferFileType"] = "AUDIO";
- jBody["testEnv"] = true;
- hrp.sParamList.push_back(QString("CustomBody,%1").arg(jBody.toStyledString().c_str()));
- hrp.eParamType = HttpParamType::hptCustomBody;
- g_httpBllPtr->post(hrp);
- }
- etMobileTest::~etMobileTest()
- {
- g_websocketPtr->close();
- delete ui;
- }
- int etMobileTest::setUI(const int nLeft, const int nTop, const int nWidth)
- {
- setGeometry(nLeft, nTop, nWidth, g_appInfoPtr->m_fRate*427);
- ui->label_etmv_qrcode->setGeometry(g_appInfoPtr->m_fRate*30, g_appInfoPtr->m_fRate*30,
- g_appInfoPtr->m_fRate*220, g_appInfoPtr->m_fRate*220);
- ui->label_etmt_tips->setGeometry(ui->label_etmv_qrcode->x() + ui->label_etmv_qrcode->width() + g_appInfoPtr->m_fRate*30,
- ui->label_etmv_qrcode->y(), g_appInfoPtr->m_fRate*490, g_appInfoPtr->m_fRate*66);
- ui->label_etmt_tips->setText(QString::fromLocal8Bit(R"(<html>
- <body>
- <style type="text/css">
- #normalText {
- color: #717171;
- font-size:%1px;
- font-family:Microsoft YaHei;
- text-align: left;
- }
- #hoverText {
- color: #13BA8C;
- font-size:%2px;
- font-family:Microsoft YaHei;
- text-align: left;
- }
- </style>
- <span id="normalText">请使用</span>
- <span id="hoverText">微信</span>
- <span id="normalText">扫描二维码后,在微信小程序上录音,并上传文件</span>
- </body>
- </html>)").arg((int)(g_appInfoPtr->m_fRate*24)).arg((int)(g_appInfoPtr->m_fRate*24)));
- ui->label_HLine->setGeometry(ui->label_etmt_tips->x(), ui->label_etmt_tips->y() + ui->label_etmt_tips->height() + g_appInfoPtr->m_fRate*20,
- g_appInfoPtr->m_fRate*490, g_appInfoPtr->m_fRate*1);
- ui->label_etmt_status->adjustSize();
- ui->label_etmt_status->setGeometry(ui->label_etmt_tips->x(), ui->label_HLine->y() + ui->label_HLine->height() + 20,
- g_appInfoPtr->m_fRate*490, ui->label_etmt_status->height());
- ui->btn_etmt_canotScan->setGeometry(ui->label_etmt_tips->x(), ui->label_etmv_qrcode->y() + ui->label_etmv_qrcode->height() - g_appInfoPtr->m_fRate*40,
- g_appInfoPtr->m_fRate*240, g_appInfoPtr->m_fRate*40);
- ui->btn_etmt_canotScan->setIconSize(QSize(g_appInfoPtr->m_fRate*13, g_appInfoPtr->m_fRate*13));
- ui->btn_etmt_canotScan->setIcon(QIcon(":/images/btn-can-not-play"));
- ui->btn_etmt_uploadFaild->setGeometry(ui->btn_etmt_canotScan->x() + ui->btn_etmt_canotScan->width() + g_appInfoPtr->m_fRate*10,
- ui->btn_etmt_canotScan->y(), ui->btn_etmt_canotScan->width(), ui->btn_etmt_canotScan->height());
- ui->btn_etmt_uploadFaild->setIconSize(QSize(g_appInfoPtr->m_fRate*13, g_appInfoPtr->m_fRate*13));
- ui->btn_etmt_uploadFaild->setIcon(QIcon(":/images/btn-can-not-play"));
- ui->tablewt_envTest->setGeometry(ui->label_etmv_qrcode->x(), ui->label_etmv_qrcode->y() + ui->label_etmv_qrcode->height() + g_appInfoPtr->m_fRate*30,
- width() - g_appInfoPtr->m_fRate*30*2, height() - ui->label_etmv_qrcode->y() - ui->label_etmv_qrcode->height() - g_appInfoPtr->m_fRate*30);
- ui->tablewt_envTest->setEditTriggers(QAbstractItemView::NoEditTriggers);
- //整行选中的方式
- ui->tablewt_envTest->setSelectionBehavior(QAbstractItemView::SelectRows);
- //设置为只能选中一行
- ui->tablewt_envTest->setSelectionMode(QAbstractItemView::SingleSelection);
- //隐藏列表头
- ui->tablewt_envTest->verticalHeader()->setVisible(false);
- //隐藏边框
- ui->tablewt_envTest->setShowGrid(false);
- //表头不高亮显示
- ui->tablewt_envTest->horizontalHeader()->setHighlightSections(false);
- //设置行数
- ui->tablewt_envTest->setRowCount(2);
- //设置列数
- ui->tablewt_envTest->setColumnCount(3);
- ui->tablewt_envTest->setHorizontalScrollMode(QTableWidget::ScrollPerPixel);
- ui->tablewt_envTest->horizontalScrollBar()->setSingleStep(g_appInfoPtr->m_fRate*5);
- QStringList sHeadStr;
- sHeadStr << QString::fromLocal8Bit("检测项") <<
- QString::fromLocal8Bit("值") <<
- QString::fromLocal8Bit("状态");
- ui->tablewt_envTest->setHorizontalHeaderLabels(sHeadStr);
- ui->tablewt_envTest->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
- ui->tablewt_envTest->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
- ui->tablewt_envTest->verticalHeader()->setDefaultSectionSize(g_appInfoPtr->m_fRate*48);
- ui->tablewt_envTest->setColumnWidth(0, g_appInfoPtr->m_fRate*525);
- ui->tablewt_envTest->setColumnWidth(1, g_appInfoPtr->m_fRate*170);
- ui->tablewt_envTest->setColumnWidth(2, g_appInfoPtr->m_fRate*24);
- ui->tablewt_envTest->horizontalHeader()->setStretchLastSection(true);
- {
- int i = 0;
- ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("扫描二维码")));
- ui->tablewt_envTest->setItem(i, 1, new QTableWidgetItem(QString::fromLocal8Bit("")));
- /* QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout;
- widget->setLayout(layout);
- QLabel *icon = new QLabel;
- icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
- icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
- layout->addWidget(icon);
- layout->addStretch();
- ui->tablewt_envTest->setCellWidget(i, 2, widget);*/
- }
- {
- int i = 1;
- ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("上传录音")));
- ui->tablewt_envTest->setItem(i, 1, new QTableWidgetItem(QString::fromLocal8Bit("")));
- /*QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout;
- widget->setLayout(layout);
- QLabel *icon = new QLabel;
- icon->setFixedSize(QSize(g_appInfoPtr->m_fRate * 12, g_appInfoPtr->m_fRate * 9));
- icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate * 12, g_appInfoPtr->m_fRate * 9));
- layout->addWidget(icon);
- layout->addStretch();
- ui->tablewt_envTest->setCellWidget(i, 2, widget);*/
- }
- return height();
- }
- int etMobileTest::widgetHeight()
- {
- return height();
- }
- void etMobileTest::onGetWXQrCode(CGetWXQrCode getWXQrCode)
- {
- if (getWXQrCode.nCode == 200)
- {
- ui->label_etmv_qrcode->setPixmap(CQREncode::GenerateQRcode(getWXQrCode.sUrl, ui->label_etmv_qrcode->width()));
- }
- else
- {
- if(getWXQrCode.sMessage.isEmpty())
- {
- ShowMsg(QString::fromLocal8Bit("获取二维码失败"), (QWidget*)(this->parent()));
- }
- else
- {
- ShowMsg(getWXQrCode.sMessage, (QWidget*)(this->parent()));
- }
- }
- }
- void etMobileTest::onMobileStatus(__int64 nExamRecordDataId, int nOrder, QString sScanStatus)
- {
- if (sScanStatus == "SCANNED")
- {
- int i = 0;
- ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("扫描二维码")));
- ui->tablewt_envTest->setItem(i, 1, new QTableWidgetItem(QString::fromLocal8Bit("正常")));
- QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout;
- widget->setLayout(layout);
- QLabel *icon = new QLabel;
- icon->setFixedSize(QSize(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
- icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate*12, g_appInfoPtr->m_fRate*9));
- layout->addWidget(icon);
- layout->addStretch();
- ui->tablewt_envTest->setCellWidget(i, 2, widget);
- }
- }
- void etMobileTest::onFileAnswer(__int64 nExamRecordDataId, int nOrder, QString sFileType, QString sFileUrl)
- {
- CHttpRequestPackage hrp;
- hrp.sUri = "/api/ecs_oe_student/examControl/saveUploadedFileAcknowledgeStatus";
- hrp.nRequestType = RequestType::rtSaveUploadedFileAcknowledgeStatus;
- Json::Value jBody = Json::Value::null;
- jBody["examRecordDataId"] = nExamRecordDataId;
- jBody["order"] = nOrder;
- jBody["filePath"] = sFileUrl.toStdString();
- jBody["acknowledgeStatus"] = "CONFIRMED";
- hrp.sParamList.push_back(QString("CustomBody,%1").arg(jBody.toStyledString().c_str()));
- hrp.eParamType = HttpParamType::hptCustomBody;
- g_httpBllPtr->post(hrp);
- }
- void etMobileTest::onSaveUploadedFileAcknowledgeStatus(CSaveUploadedFileAcknowledgeStatus saveUploadedFileAcknowledgeStatus)
- {
- if (saveUploadedFileAcknowledgeStatus.nCode == 200)
- {
- int i = 1;
- ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("上传录音")));
- ui->tablewt_envTest->setItem(i, 1, new QTableWidgetItem(QString::fromLocal8Bit("正常")));
- QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout;
- widget->setLayout(layout);
- QLabel *icon = new QLabel;
- icon->setFixedSize(QSize(g_appInfoPtr->m_fRate * 12, g_appInfoPtr->m_fRate * 9));
- icon->setPixmap(QPixmap(":/images/icon-et-item-pass.png").scaled(g_appInfoPtr->m_fRate * 12, g_appInfoPtr->m_fRate * 9));
- layout->addWidget(icon);
- layout->addStretch();
- ui->tablewt_envTest->setCellWidget(i, 2, widget);
- m_nUploadStatus = 1;
- }
- else
- {
- int i = 1;
- ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("上传录音")));
- ui->tablewt_envTest->setItem(i, 1, new QTableWidgetItem(QString::fromLocal8Bit("出错")));
- QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout;
- widget->setLayout(layout);
- QLabel *icon = new QLabel;
- icon->setFixedSize(QSize(g_appInfoPtr->m_fRate * 8, g_appInfoPtr->m_fRate * 8));
- icon->setPixmap(QPixmap(":/images/icon-et-iten-unpass.png").scaled(g_appInfoPtr->m_fRate * 8, g_appInfoPtr->m_fRate * 8));
- layout->addWidget(icon);
- layout->addStretch();
- ui->tablewt_envTest->setCellWidget(i, 2, widget);
- }
- }
- void etMobileTest::on_btn_etmt_canotScan_clicked()
- {
- int i = 0;
- ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("扫描二维码")));
- ui->tablewt_envTest->setItem(i, 1, new QTableWidgetItem(QString::fromLocal8Bit("出错")));
- QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout;
- widget->setLayout(layout);
- QLabel *icon = new QLabel;
- icon->setFixedSize(QSize(g_appInfoPtr->m_fRate * 8, g_appInfoPtr->m_fRate * 8));
- icon->setPixmap(QPixmap(":/images/icon-et-iten-unpass.png").scaled(g_appInfoPtr->m_fRate * 8, g_appInfoPtr->m_fRate * 8));
- layout->addWidget(icon);
- layout->addStretch();
- ui->tablewt_envTest->setCellWidget(i, 2, widget);
- m_nUploadStatus = 0;
- }
- void etMobileTest::on_btn_etmt_uploadFaild_clicked()
- {
- int i = 1;
- ui->tablewt_envTest->setItem(i, 0, new QTableWidgetItem(QString::fromLocal8Bit("上传录音")));
- ui->tablewt_envTest->setItem(i, 1, new QTableWidgetItem(QString::fromLocal8Bit("出错")));
- QWidget *widget = new QWidget;
- QHBoxLayout *layout = new QHBoxLayout;
- widget->setLayout(layout);
- QLabel *icon = new QLabel;
- icon->setFixedSize(QSize(g_appInfoPtr->m_fRate * 8, g_appInfoPtr->m_fRate * 8));
- icon->setPixmap(QPixmap(":/images/icon-et-iten-unpass.png").scaled(g_appInfoPtr->m_fRate * 8, g_appInfoPtr->m_fRate * 8));
- layout->addWidget(icon);
- layout->addStretch();
- ui->tablewt_envTest->setCellWidget(i, 2, widget);
- m_nUploadStatus = 0;
- }
- int etMobileTest::getCheckStatus()
- {
- return m_nUploadStatus;
- }
|