Yao 1 mesiac pred
rodič
commit
53307dd48a

+ 3 - 2
blastProject/hprojectdao.cpp

@@ -130,7 +130,8 @@ PaginatedHProjectResult HProjectDao::getAllHProjects(int page, int pageSize) {
     QList<QSharedPointer<HProject>> projects;
     QSqlQuery query(database);
     int offset = (page - 1) * pageSize;
-    query.prepare("SELECT * FROM h_project ORDER BY created_at LIMIT :pageSize OFFSET :offset");
+    query.prepare(
+        "SELECT * FROM h_project ORDER BY created_at desc LIMIT :pageSize OFFSET :offset");
     query.bindValue(":pageSize", pageSize);
     query.bindValue(":offset", offset);
 
@@ -155,7 +156,7 @@ PaginatedHProjectResult HProjectDao::getAllHProjectsByOpera(int page, int pageSi
     QSqlQuery query(database);
     int offset = (page - 1) * pageSize;
     query.prepare(
-        "SELECT * FROM h_project WHERE blast_status = :safeCheckedStatus ORDER BY created_at "
+        "SELECT * FROM h_project WHERE blast_status = :safeCheckedStatus ORDER BY created_at desc "
         "LIMIT :pageSize OFFSET :offset");
     query.bindValue(":safeCheckedStatus", BlastStatus::SafeChecked);
     query.bindValue(":pageSize", pageSize);

+ 2 - 3
blastRecord/blastrecord.cpp

@@ -32,7 +32,6 @@ void BlastRecord::loadDataFromSource(int currentPage, int pageSize) {
     QList<HeaderInfo> headers = {
         {"工程名称", "projectName"},   {"是否离线", "isOfflineBlast"}, {"app版本", "appVersion"},
         {"起爆器编号", "equipmentSn"}, {"注册雷管", "regDetCount"},    {"起爆时间", "blastAt"},
-        {"上报时间", "updatedAt"},
     };
 
     QStringList headerLabels;
@@ -117,8 +116,8 @@ QList<QStandardItem*> BlastRecord::jsonToItem(const QJsonObject& jsonObj) {
     QString formattedCreatedAt = createdAt.toString("yyyy-MM-dd HH:mm:ss");
     QStandardItem* createdItem = new QStandardItem(formattedCreatedAt);
 
-    return QList<QStandardItem*>() << nameItem << isOfflineBlastItem << equipItem << typeItem
-                                   << statusItem << onlineItem << createdItem;
+    return QList<QStandardItem*>()
+           << nameItem << isOfflineBlastItem << equipItem << typeItem << statusItem << onlineItem;
 }
 void BlastRecord::parseJsonString(const QJsonDocument& jsonDoc) {
     QJsonObject jsonObj = jsonDoc.object();

+ 11 - 12
blastopepage.cpp

@@ -408,7 +408,7 @@ void BlastOpePage::loadDataFromSource(int currentPage, int pageSize) {
         QModelIndex statusIndex = model->index(row, propMap.key("blastStatus"));
         if (statusIndex.isValid()) {
             QString blastStatus = model->data(statusIndex).toString();
-            if (blastStatus == "起 爆 完 成") {
+            /*if (blastStatus == "起 爆 完 成") {
                 // 为按钮添加图标,这里假设图标文件名为 icon.png,你需要根据实际情况修改
                 QIcon icon(":/icons/icons/svg/blast.svg");
                 button->setIcon(icon);
@@ -419,7 +419,8 @@ void BlastOpePage::loadDataFromSource(int currentPage, int pageSize) {
                     "    border: none;"
                     "    background-color: transparent;"
                     "}");
-            } else if (blastStatus == "待起爆") {
+            } else*/
+            if (blastStatus == "待起爆") {
                 button->setText(startBlastButtonTxt);
                 button->setEnabled(true);
             } else {
@@ -550,11 +551,6 @@ void BlastOpePage::onUpdateBlastStatus(int status, int row) {
                 customColor = QColor("#90d543");
                 model->setData(index, customColor, Qt::ForegroundRole);
                 break;
-            // case 0:
-            //     model->setData(index, "已 注 册");
-            //     customColor = QColor("#8e620");
-            //     model->setData(index, customColor, Qt::ForeroundRole);
-            //     break;
             case 10:
                 model->setData(index, "按 下 双 建 起 爆 ...");
                 customColor = QColor("#8e620");
@@ -577,12 +573,12 @@ void BlastOpePage::handleRowOperateButtonClick(int row, QPushButton *button) {
     }
 
     if (button->text() == startBlastButtonTxt) {
-        button->setMinimumWidth(100);
+        button->setMinimumWidth(80);
         button->setText(stopBlastButtonTxt);
         firingWidget *widget = new firingWidget(row, false, uuid);
         connect(widget, &firingWidget::progressChanged, this, &BlastOpePage::updateProgressBar);
         connect(widget, &firingWidget::updateBlastStatus, this, &BlastOpePage::onUpdateBlastStatus);
-        connect(widget, &firingWidget::updateButton, this, &BlastOpePage::changeButByMqtt);
+        connect(widget, &firingWidget::updateButton, this, &BlastOpePage::updateOpBtn);
         connect(widget, &firingWidget::countdown, this, &BlastOpePage::showCountDownWidget);
         connect(widget, &firingWidget::updateProjectStatus, this, &BlastOpePage::updateProject);
         connect(widget, &firingWidget::closeFiring, this, &BlastOpePage::destroyFiringWidget);
@@ -601,7 +597,7 @@ void BlastOpePage::handleRowOperateButtonClick(int row, QPushButton *button) {
     }
 }
 
-void BlastOpePage::changeButByMqtt(int status, int row) {
+void BlastOpePage::updateOpBtn(int status, int row) {
     qDebug() << "statusButton:" << status;
     QModelIndex index = model->index(row, 8);
     if (index.isValid()) {
@@ -695,7 +691,7 @@ void BlastOpePage::on_btnSelect_clicked() {
         connect(widgetSelect, &firingWidget::updateBlastStatus, this,
                 &BlastOpePage::onUpdateBlastStatus);
         connect(widgetSelect, &firingWidget::selectSignal, this, &BlastOpePage::handleSelect);
-        connect(widgetSelect, &firingWidget::updateButton, this, &BlastOpePage::changeButByMqtt);
+        connect(widgetSelect, &firingWidget::updateButton, this, &BlastOpePage::updateOpBtn);
         connect(widgetSelect, &firingWidget::updateProjectStatus, this,
                 &BlastOpePage::updateProject);
         connect(widgetSelect, &firingWidget::closeFiring, this,
@@ -703,6 +699,10 @@ void BlastOpePage::on_btnSelect_clicked() {
         widgetSelect->show();
         widgetSelect->setAttribute(Qt::WA_DeleteOnClose);
         uuidWidgetSMap.insert(uuid, widgetSelect);
+
+        if (isShowTriggeringWidget) {
+            widgetSelect->show();
+        }
     }
 }
 
@@ -733,7 +733,6 @@ void BlastOpePage::handleSelect(QString uuid) {
                 },
                 Qt::SingleShotConnection);
 
-            // TODO: receive blast record
         } else {
             qDebug() << "serialTool Not fond.";
             QMessageBox::critical(nullptr, "错误", "trigger button devices not found");

+ 2 - 2
blastopepage.h

@@ -47,7 +47,7 @@ class BlastOpePage : public QWidget {
     void onComboBoxIndexChanged(int index);
     void updateProgressBar(int value, int row);
     void onUpdateBlastStatus(int status, int row);
-    void changeButByMqtt(int status, int row);
+    void updateOpBtn(int status, int row);
     void showCountDownWidget(QString uuid, const QString &topic, const QString &message);
     void updateProject(QString uuid);
     void destroyFiringWidget(const QString &uuid);
@@ -95,6 +95,6 @@ class BlastOpePage : public QWidget {
     int totalCount;
     QString stopBlastButtonTxt = "中止起爆";
     QString startBlastButtonTxt = "开启起爆";
-}
+};
 
 #endif  // BLASTOPEPAGE_H

+ 6 - 1
fireWidget/firingwidget.cpp

@@ -231,6 +231,7 @@ void firingWidget::handleProjectFiringMqttMessage(const QByteArray &message,
                             emit progressChanged(6, m_row);
                             emit updateBlastStatus(6, m_row);
                             emit updateProjectStatus(m_uuid);
+                            emit updateButton(6, m_row);
                             ui->pushButton_2->setText("已完成起爆");
                             navProgress->setState(6);
                             break;
@@ -438,6 +439,9 @@ void firingWidget::uploadBlastRecordToServer(HBlastRecord *blastRecord) {
             QString("Failed to upload blast project. data: %1")
                 .arg(QJsonDocument(blastRecord->ToJson()).toJson(QJsonDocument::Indented)));
     }
+    Logger::getInstance().info(
+        QString("Blast project uploaded to server successfully. blast_uuid: %1")
+            .arg(blastRecord->getUuid()));
 }
 
 HBlastRecord *firingWidget::recordBlastProject(const QJsonObject &jsonObj) {
@@ -453,7 +457,8 @@ HBlastRecord *firingWidget::recordBlastProject(const QJsonObject &jsonObj) {
     record->setCompanyCode(jsonObj["company_code"].toString());
     record->setAppVersion(jsonObj["app_version"].toString());
 
-    record->setLongitude(jsonObj["blast_longitude"].toString().left(10));  // TODO: 确认地址长度
+    // TODO: 如何获得坐标
+    record->setLongitude(jsonObj["blast_longitude"].toString().left(10));
     record->setLatitude(jsonObj["blast_latitude"].toString().left(10));
 
     record->setRegDetCount(jsonObj["reg_deto_count"].toString().toInt());

+ 9 - 4
mainwindow.cpp

@@ -24,7 +24,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
     try {
         this->setWindowFlags(Qt::FramelessWindowHint);
         // this->setWindowState(Qt::WindowMaximized);  // Maximizes the window
-        this->setFixedSize(1000, 600);
+        this->setFixedSize(1360, 864);
         ui->setupUi(this);
         LoadingWidget::init(ui->stackedWidget);
 
@@ -290,12 +290,17 @@ QList<QString> MainWindow::findAllChildUuids(const QJsonArray &addressArray,
                         QString childUuid = child.toObject()["uuid"].toString();
                         childrenUuids.append(childUuid);
 
-                        // Also add any grandchildren
+                        // max depth 3
                         if (child.toObject().contains("children") &&
                             child.toObject()["children"].isArray()) {
                             QJsonArray grandchildren = child.toObject()["children"].toArray();
-                            childrenUuids.append(findAllChildUuids(
-                                grandchildren, child.toObject()["uuid"].toString()));
+                            for (const QJsonValue &grandchild : grandchildren) {
+                                if (grandchild.isObject()) {
+                                    QString grandchildUuid =
+                                        grandchild.toObject()["uuid"].toString();
+                                    childrenUuids.append(grandchildUuid);
+                                }
+                            }
                         }
                     }
                 }