|
@@ -6,10 +6,10 @@
|
|
|
|
|
|
#include "../components/custommessagebox.h"
|
|
|
#include "../components/loadingwidget.h"
|
|
|
-#include "../registryManager/registrymanager.h"
|
|
|
#include "../utils/global.h"
|
|
|
#include "../utils/logger.h"
|
|
|
#include "countdownwidget.h"
|
|
|
+#include "sequenceselectorwidget.h"
|
|
|
#include "ui_blastopepage.h"
|
|
|
|
|
|
const int ColIndexBlastStatus = 6;
|
|
@@ -21,7 +21,8 @@ BlastOpePage::BlastOpePage(QWidget *parent)
|
|
|
: QWidget(parent),
|
|
|
ui(new Ui::BlastOpePage),
|
|
|
dao(DatabaseManager::getInstance().getDatabase()),
|
|
|
- m_faceVerification(nullptr) {
|
|
|
+ m_faceVerification(nullptr),
|
|
|
+ m_sequenceSelector(nullptr) {
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
|
|
|
|
|
bool isAllSafetyInspectorConfirmed = true;
|
|
@@ -94,25 +95,15 @@ BlastOpePage::~BlastOpePage() {
|
|
|
if (m_faceVerification) {
|
|
|
delete m_faceVerification;
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-void BlastOpePage::initPagination() {
|
|
|
- // // pageWidget = new PageWidget;
|
|
|
- // //connect(pageWidget, &PageWidget::currentPageChanged, this, &BlastOpePage::PageChanged);
|
|
|
- // connect(pageWidget->getComboBox(), QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
|
|
- // &BlastOpePage::onComboBoxIndexChanged);
|
|
|
- // ui->verticalLayout_4->addWidget(pageWidget);
|
|
|
- m_pageSize = 100;
|
|
|
- m_currentPage = 1;
|
|
|
- RefreshData();
|
|
|
+ if (m_sequenceSelector) {
|
|
|
+ delete m_sequenceSelector;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-void BlastOpePage::RefreshData() { loadDataAndDrawTable(m_currentPage, m_pageSize); }
|
|
|
-
|
|
|
-void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
- LoadingWidget::showLoading(this, "正在加载数据...");
|
|
|
+void BlastOpePage::initPagination() {
|
|
|
QJsonObject extParams{{"blastStatus", QJsonArray({"2"})}};
|
|
|
- QJsonObject result = backendAPIManager::getHProjects(currentPage, pageSize, extParams);
|
|
|
+ QJsonObject result = backendAPIManager::getHProjects(1, 200, extParams);
|
|
|
|
|
|
QList<QSharedPointer<HProject>> projectList =
|
|
|
dao.getHProjectsFromJsonArray(result["data"].toObject()["list"].toArray());
|
|
@@ -125,9 +116,19 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
groupedProjects[key].append(project);
|
|
|
}
|
|
|
|
|
|
- totalCount = result["data"].toObject()["count"].toInt();
|
|
|
- // pageWidget->setMaxPage(ceil(static_cast<double>(totalCount) / pageSize));
|
|
|
+ int totalCount = result["data"].toObject()["count"].toInt();
|
|
|
+ if (totalCount > 200) {
|
|
|
+ QMessageBox::warning(
|
|
|
+ this, "警告",
|
|
|
+ QString("目前可以操作的数量是200。当前查询结果总数:%1, 如需调整请联系开发人员进行调整").arg(totalCount));
|
|
|
+ }
|
|
|
+ m_groupedProjects = groupedProjects;
|
|
|
+
|
|
|
+ drawTable();
|
|
|
+}
|
|
|
|
|
|
+void BlastOpePage::drawTable() {
|
|
|
+ LoadingWidget::showLoading(this, "正在加载数据...");
|
|
|
// Clear previous data
|
|
|
pcSnToFirstRowMap.clear();
|
|
|
progressBars.clear();
|
|
@@ -156,11 +157,11 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
model->setHorizontalHeaderLabels(headerLabels);
|
|
|
|
|
|
// Create rows with sub-rows for each project, grouped by pcSn
|
|
|
- QStringList pcSnKeys = groupedProjects.keys();
|
|
|
+ QStringList pcSnKeys = m_groupedProjects.keys();
|
|
|
int currentRow = 0;
|
|
|
|
|
|
for (const QString &pcSn : pcSnKeys) {
|
|
|
- QList<QSharedPointer<HProject>> projectsForPcSn = groupedProjects[pcSn];
|
|
|
+ QList<QSharedPointer<HProject>> projectsForPcSn = m_groupedProjects[pcSn];
|
|
|
pcSnToFirstRowMap[pcSn] = currentRow; // Store the first row index for this pcSn
|
|
|
|
|
|
// Calculate aggregated blast status for this pcSn group
|
|
@@ -284,7 +285,7 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
|
|
|
// Create progress bars and operation buttons only for the first row of each pcSn group
|
|
|
for (const QString &pcSn : pcSnKeys) {
|
|
|
- QList<QSharedPointer<HProject>> projectsForPcSn = groupedProjects[pcSn];
|
|
|
+ QList<QSharedPointer<HProject>> projectsForPcSn = m_groupedProjects[pcSn];
|
|
|
int firstRowIndex = pcSnToFirstRowMap[pcSn];
|
|
|
int groupRowSpan = projectsForPcSn.size();
|
|
|
|
|
@@ -322,20 +323,20 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
// 创建操作按钮 for the first row of this pcSn group
|
|
|
int operationCol = headers.size() - 1;
|
|
|
QWidget *widget = new QWidget(ui->tableView);
|
|
|
- QPushButton *button = new QPushButton(widget);
|
|
|
- button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
- button->setStyleSheet("QPushButton:disabled { background-color: #d3d3d3; color: gray; }");
|
|
|
+ QPushButton *singleTriggerBtn = new QPushButton(widget);
|
|
|
+ singleTriggerBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
+ singleTriggerBtn->setStyleSheet("QPushButton:disabled { background-color: #d3d3d3; color: gray; }");
|
|
|
|
|
|
QModelIndex statusIndex = model->index(firstRowIndex, ColIndexBlastStatus);
|
|
|
if (statusIndex.isValid()) {
|
|
|
QString blastStatus = model->data(statusIndex).toString();
|
|
|
if (blastStatus == "待起爆") {
|
|
|
- button->setText(startBlastButtonTxt);
|
|
|
- button->setEnabled(true);
|
|
|
+ singleTriggerBtn->setText(startBlastButtonTxt);
|
|
|
+ singleTriggerBtn->setEnabled(true);
|
|
|
}
|
|
|
}
|
|
|
QHBoxLayout *layout = new QHBoxLayout(widget);
|
|
|
- layout->addWidget(button);
|
|
|
+ layout->addWidget(singleTriggerBtn);
|
|
|
layout->setAlignment(Qt::AlignCenter);
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
widget->setLayout(layout);
|
|
@@ -343,36 +344,25 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
QModelIndex index = model->index(firstRowIndex, operationCol);
|
|
|
if (index.isValid()) {
|
|
|
ui->tableView->setIndexWidget(index, widget);
|
|
|
- // Set row span to cover all sub-rows for this pcSn
|
|
|
- ui->tableView->setSpan(firstRowIndex, operationCol, groupRowSpan, 1);
|
|
|
- connect(button, &QPushButton::clicked,
|
|
|
- [this, firstRowIndex, button]() { handleSingleBlastButtonClicked(firstRowIndex, button); });
|
|
|
+ if (groupRowSpan > 1) {
|
|
|
+ ui->tableView->setSpan(firstRowIndex, operationCol, groupRowSpan, 1);
|
|
|
+ }
|
|
|
+ connect(singleTriggerBtn, &QPushButton::clicked, [this, firstRowIndex, singleTriggerBtn]() {
|
|
|
+ handleSingleBlastButtonClicked(firstRowIndex, singleTriggerBtn);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- // Also set span for the pcSn column to merge cells
|
|
|
- ui->tableView->setSpan(firstRowIndex, ColIndexBlasterDev, groupRowSpan, 1);
|
|
|
- // Set span for the checkbox column
|
|
|
- ui->tableView->setSpan(firstRowIndex, 0, groupRowSpan, 1);
|
|
|
- // Set span for the blast status column
|
|
|
- ui->tableView->setSpan(firstRowIndex, ColIndexBlastStatus, groupRowSpan, 1);
|
|
|
+ if (groupRowSpan > 1) {
|
|
|
+ ui->tableView->setSpan(firstRowIndex, ColIndexBlasterDev, groupRowSpan, 1);
|
|
|
+ ui->tableView->setSpan(firstRowIndex, 0, groupRowSpan, 1);
|
|
|
+ ui->tableView->setSpan(firstRowIndex, ColIndexBlastStatus, groupRowSpan, 1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
LoadingWidget::hideLoading();
|
|
|
}
|
|
|
|
|
|
-// 切换页数
|
|
|
-void BlastOpePage::PageChanged(int page) {
|
|
|
- m_currentPage = page;
|
|
|
- loadDataAndDrawTable(m_currentPage, m_pageSize);
|
|
|
-}
|
|
|
-
|
|
|
-void BlastOpePage::onComboBoxIndexChanged(int index) {
|
|
|
- // QVariant variant = pageWidget->getComboBox()->itemData(index);
|
|
|
- // int value = variant.toInt();
|
|
|
- // m_pageSize = value;
|
|
|
- // m_currentPage = 1;
|
|
|
- // loadDataAndDrawTable(m_currentPage, m_pageSize);
|
|
|
-}
|
|
|
+void BlastOpePage::onComboBoxIndexChanged(int index) {}
|
|
|
|
|
|
void BlastOpePage::updateProgressBar(int firingStage, int row) {
|
|
|
// Find the progress bar index for this row's pcSn group
|
|
@@ -525,10 +515,10 @@ void BlastOpePage::handleSingleBlastButtonClicked(int row, QPushButton *button)
|
|
|
|
|
|
// Get all UUIDs for this pcSn group
|
|
|
QStandardItem *uuidItem = model->item(row, headers.size());
|
|
|
- QStringList uuids;
|
|
|
+ QStringList projUuids;
|
|
|
if (uuidItem) {
|
|
|
QString uuidData = uuidItem->data(Qt::UserRole).toString();
|
|
|
- uuids = uuidData.split(",", Qt::SkipEmptyParts);
|
|
|
+ projUuids = uuidData.split(",", Qt::SkipEmptyParts);
|
|
|
}
|
|
|
|
|
|
if (button->text() == startBlastButtonTxt) {
|
|
@@ -545,9 +535,9 @@ void BlastOpePage::handleSingleBlastButtonClicked(int row, QPushButton *button)
|
|
|
// Create firing widget for the pcSn group (use pcSn as identifier)
|
|
|
// Use the first row index for this pcSn group for progress updates
|
|
|
firingWidget *widget = new firingWidget(row, false, blasterDevPcSn);
|
|
|
- connect(widget, &firingWidget::updatefiringStage, this, &BlastOpePage::onFiringStageUpdated);
|
|
|
+ connect(widget, &firingWidget::updateFiringStage, this, &BlastOpePage::onFiringStageUpdated);
|
|
|
connect(widget, &firingWidget::startCountdown, this, &BlastOpePage::showCountDownWidget);
|
|
|
- connect(widget, &firingWidget::updateProjectStatus, this, &BlastOpePage::handlerUpdateProjectStatus);
|
|
|
+ connect(widget, &firingWidget::updateProjectsStatus, this, &BlastOpePage::handlerUpdateProjectStatus);
|
|
|
connect(widget, &firingWidget::closeFiring, this, &BlastOpePage::destroyFiringWidget);
|
|
|
if (isShowTriggeringWidget) {
|
|
|
widget->show();
|
|
@@ -642,11 +632,22 @@ void BlastOpePage::handleUpdateOpButton(int stage, int row) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void BlastOpePage::handlerUpdateProjectStatus(QString uuid, const QString &newStatus) {
|
|
|
- // dao.updateBlastStatusByUuid(uuid, newStatus);
|
|
|
+void BlastOpePage::handlerUpdateProjectStatus(QString blasterDevUuid, const QString &newStatus) {
|
|
|
QJsonObject extParams;
|
|
|
- qDebug() << "handlerUpdateProjectStatus: uuid = " << uuid << ", newStatus = " << newStatus;
|
|
|
- // extParams.insert("blastStatus", QJsonArray({newStatus}));
|
|
|
+ extParams.insert("blastStatus", QJsonArray({newStatus}));
|
|
|
+
|
|
|
+ for (const auto &project : m_groupedProjects.value(blasterDevUuid)) {
|
|
|
+ QString errMsg = backendAPIManager::updateProject(project->getUuid(), extParams);
|
|
|
+ if (errMsg != "") {
|
|
|
+ Logger::getInstance().error(
|
|
|
+ QString("handlerUpdateProjectStatus: update project(%1) failed: %2").arg(blasterDevUuid, errMsg));
|
|
|
+ QMessageBox::critical(this, "错误",
|
|
|
+ QString("更新项目状态失败: %1\n错误信息: %2").arg(blasterDevUuid, errMsg));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Logger::getInstance().info(
|
|
|
+ QString("handlerUpdateProjectStatus: update project %1 to status %2").arg(blasterDevUuid).arg(newStatus));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void BlastOpePage::destroyFiringWidget(const QString &uuid, int row) {
|
|
@@ -685,45 +686,12 @@ void BlastOpePage::onItemCheckboxChanged(QStandardItem *item) {
|
|
|
}
|
|
|
|
|
|
void BlastOpePage::on_btnSelect_clicked() {
|
|
|
- // 禁用表格第一列的选项
|
|
|
- for (int row = 0; row < model->rowCount(); ++row) {
|
|
|
- QStandardItem *item = model->item(row, 0);
|
|
|
- if (item) {
|
|
|
- Qt::ItemFlags flags = item->flags();
|
|
|
- flags &= ~Qt::ItemIsEnabled;
|
|
|
- item->setFlags(flags);
|
|
|
- }
|
|
|
+ if (uuidMap.isEmpty()) {
|
|
|
+ QMessageBox::warning(this, "警告", "请先选择要起爆的设备!");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- for (auto it = uuidMap.begin(); it != uuidMap.end(); ++it) {
|
|
|
- int row = it.key();
|
|
|
- QString pcSn = it.value(); // This is now pcSn instead of uuid
|
|
|
- firingWidget *widgetSelect = new firingWidget(row, true, pcSn);
|
|
|
- QModelIndex index = model->index(row, ColIndexOpBtn); // Use ColIndexOpBtn instead of ColIndexBlasterDev
|
|
|
- if (index.isValid()) {
|
|
|
- QWidget *widgetButton = ui->tableView->indexWidget(index);
|
|
|
- if (widgetButton) {
|
|
|
- QPushButton *button = widgetButton->findChild<QPushButton *>();
|
|
|
- if (button) {
|
|
|
- button->setText(stopBlastButtonTxt);
|
|
|
- button->setDisabled(true);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 信号连接
|
|
|
- connect(widgetSelect, &firingWidget::updatefiringStage, this, &BlastOpePage::onFiringStageUpdated);
|
|
|
- connect(widgetSelect, &firingWidget::batchFiringSignal, this, &BlastOpePage::setBatchBlastTrigger);
|
|
|
- connect(widgetSelect, &firingWidget::updateProjectStatus, this, &BlastOpePage::handlerUpdateProjectStatus);
|
|
|
- connect(widgetSelect, &firingWidget::closeFiring, this, &BlastOpePage::destroyBatchFiringWidget);
|
|
|
- widgetSelect->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
- uuidWidgetSMap.insert(pcSn, widgetSelect);
|
|
|
- widgetSelect->startBlasting();
|
|
|
-
|
|
|
- if (isShowTriggeringWidget) {
|
|
|
- widgetSelect->show();
|
|
|
- }
|
|
|
- }
|
|
|
+ showSequenceSelector();
|
|
|
}
|
|
|
|
|
|
// 完成充电
|
|
@@ -821,3 +789,81 @@ void BlastOpePage::destroyBatchFiringWidget(const QString &pcSn, int row) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+void BlastOpePage::showSequenceSelector() {
|
|
|
+ // Get selected pcSn list from uuidMap
|
|
|
+ QStringList selectedPcSnList;
|
|
|
+ for (auto it = uuidMap.begin(); it != uuidMap.end(); ++it) {
|
|
|
+ QString pcSn = it.value();
|
|
|
+ if (!selectedPcSnList.contains(pcSn)) {
|
|
|
+ selectedPcSnList << pcSn;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (selectedPcSnList.isEmpty()) {
|
|
|
+ QMessageBox::warning(this, "警告", "没有选择的设备!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_sequenceSelector = new SequenceSelectorWidget(selectedPcSnList, this);
|
|
|
+ connect(m_sequenceSelector, &SequenceSelectorWidget::startFiring, this, &BlastOpePage::onSequenceSelected);
|
|
|
+ connect(m_sequenceSelector, &SequenceSelectorWidget::cancel, this, &BlastOpePage::onSequenceCanceled);
|
|
|
+ m_sequenceSelector->show();
|
|
|
+}
|
|
|
+
|
|
|
+void BlastOpePage::onSequenceSelected(const QStringList &orderedPcSnList) {
|
|
|
+ // 禁用表格第一列的选项
|
|
|
+ for (int row = 0; row < model->rowCount(); ++row) {
|
|
|
+ QStandardItem *item = model->item(row, 0);
|
|
|
+ if (item) {
|
|
|
+ Qt::ItemFlags flags = item->flags();
|
|
|
+ flags &= ~Qt::ItemIsEnabled;
|
|
|
+ item->setFlags(flags);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Start firing process with ordered sequence
|
|
|
+ for (auto it = uuidMap.begin(); it != uuidMap.end(); ++it) {
|
|
|
+ int row = it.key();
|
|
|
+ QString pcSn = it.value(); // This is now pcSn instead of uuid
|
|
|
+ firingWidget *widgetSelect = new firingWidget(row, true, pcSn);
|
|
|
+ QModelIndex index = model->index(row, ColIndexOpBtn); // Use ColIndexOpBtn instead of ColIndexBlasterDev
|
|
|
+ if (index.isValid()) {
|
|
|
+ QWidget *widgetButton = ui->tableView->indexWidget(index);
|
|
|
+ if (widgetButton) {
|
|
|
+ QPushButton *button = widgetButton->findChild<QPushButton *>();
|
|
|
+ if (button) {
|
|
|
+ button->setText(stopBlastButtonTxt);
|
|
|
+ button->setDisabled(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 信号连接
|
|
|
+ connect(widgetSelect, &firingWidget::updateFiringStage, this, &BlastOpePage::onFiringStageUpdated);
|
|
|
+ connect(widgetSelect, &firingWidget::batchFiringSignal, this, &BlastOpePage::setBatchBlastTrigger);
|
|
|
+ connect(widgetSelect, &firingWidget::updateProjectsStatus, this, &BlastOpePage::handlerUpdateProjectStatus);
|
|
|
+ connect(widgetSelect, &firingWidget::closeFiring, this, &BlastOpePage::destroyBatchFiringWidget);
|
|
|
+ widgetSelect->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
+ uuidWidgetSMap.insert(pcSn, widgetSelect);
|
|
|
+ widgetSelect->startBlasting();
|
|
|
+
|
|
|
+ if (isShowTriggeringWidget) {
|
|
|
+ widgetSelect->show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Clean up sequence selector
|
|
|
+ if (m_sequenceSelector) {
|
|
|
+ m_sequenceSelector->deleteLater();
|
|
|
+ m_sequenceSelector = nullptr;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void BlastOpePage::onSequenceCanceled() {
|
|
|
+ // Clean up sequence selector
|
|
|
+ if (m_sequenceSelector) {
|
|
|
+ m_sequenceSelector->deleteLater();
|
|
|
+ m_sequenceSelector = nullptr;
|
|
|
+ }
|
|
|
+}
|