|
@@ -6,7 +6,6 @@
|
|
|
|
|
|
#include "../components/custommessagebox.h"
|
|
|
#include "../components/loadingwidget.h"
|
|
|
-#include "../login/loginwindow.h"
|
|
|
#include "../registryManager/registrymanager.h"
|
|
|
#include "../utils/global.h"
|
|
|
#include "../utils/logger.h"
|
|
@@ -255,12 +254,12 @@ QJsonObject BlastOpePage::getMetaInfo() {
|
|
|
}
|
|
|
|
|
|
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 = 10;
|
|
|
+ // // 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();
|
|
|
}
|
|
@@ -274,9 +273,21 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
|
|
|
QList<QSharedPointer<HProject>> projectList =
|
|
|
dao.getHProjectsFromJsonArray(result["data"].toObject()["list"].toArray());
|
|
|
+ QMap<QString, QList<QSharedPointer<HProject>>> groupedProjects;
|
|
|
+ for (const QSharedPointer<HProject> &project : projectList) {
|
|
|
+ QString key = project->getPcSn();
|
|
|
+ if (!groupedProjects.contains(key)) {
|
|
|
+ groupedProjects[key] = QList<QSharedPointer<HProject>>();
|
|
|
+ }
|
|
|
+ groupedProjects[key].append(project);
|
|
|
+ }
|
|
|
|
|
|
totalCount = result["data"].toObject()["count"].toInt();
|
|
|
- pageWidget->setMaxPage(ceil(static_cast<double>(totalCount) / pageSize));
|
|
|
+ // pageWidget->setMaxPage(ceil(static_cast<double>(totalCount) / pageSize));
|
|
|
+
|
|
|
+ // Clear previous data
|
|
|
+ pcSnToFirstRowMap.clear();
|
|
|
+ progressBars.clear();
|
|
|
|
|
|
model = new QStandardItemModel(this);
|
|
|
|
|
@@ -300,46 +311,112 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
propMap[i] = headers[i].prop;
|
|
|
}
|
|
|
model->setHorizontalHeaderLabels(headerLabels);
|
|
|
- for (int row = 0; row < projectList.size(); ++row) {
|
|
|
- HProject &HProject = *projectList.at(row).data();
|
|
|
- QStandardItem *uuidItem = new QStandardItem();
|
|
|
- uuidItem->setData(HProject.getUuid(), Qt::UserRole);
|
|
|
- model->setItem(row, headerCount, uuidItem);
|
|
|
- for (int col = 0; col < headerCount; ++col) {
|
|
|
- QString prop = propMap[col];
|
|
|
- QStandardItem *item = nullptr;
|
|
|
- if (col == 0) {
|
|
|
- item = new QStandardItem();
|
|
|
- item->setCheckable(true);
|
|
|
- item->setCheckState(Qt::Unchecked);
|
|
|
- item->setText("");
|
|
|
+
|
|
|
+ // Create rows with sub-rows for each project, grouped by pcSn
|
|
|
+ QStringList pcSnKeys = groupedProjects.keys();
|
|
|
+ int currentRow = 0;
|
|
|
+
|
|
|
+ for (const QString &pcSn : pcSnKeys) {
|
|
|
+ QList<QSharedPointer<HProject>> projectsForPcSn = groupedProjects[pcSn];
|
|
|
+ pcSnToFirstRowMap[pcSn] = currentRow; // Store the first row index for this pcSn
|
|
|
+
|
|
|
+ // Calculate aggregated blast status for this pcSn group
|
|
|
+ QString combinedBlastStatus = "";
|
|
|
+ QSet<QString> statusSet;
|
|
|
+ for (const QSharedPointer<HProject> &project : projectsForPcSn) {
|
|
|
+ QMetaProperty statusProp =
|
|
|
+ project->metaObject()->property(project->metaObject()->indexOfProperty("blastStatus"));
|
|
|
+ QString status = statusProp.read(project.data()).toString();
|
|
|
+ statusSet.insert(status);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Determine the combined status based on all projects in the group
|
|
|
+ if (statusSet.size() == 1) {
|
|
|
+ // All projects have the same status
|
|
|
+ combinedBlastStatus = statusSet.values().first();
|
|
|
+ } else {
|
|
|
+ // Mixed statuses - use the most advanced status
|
|
|
+ if (statusSet.contains(BlastStatus::Blasted)) {
|
|
|
+ combinedBlastStatus = BlastStatus::Blasted;
|
|
|
+ } else {
|
|
|
+ combinedBlastStatus = BlastStatus::Registered;
|
|
|
}
|
|
|
- if (!prop.isEmpty()) {
|
|
|
- QMetaProperty metaProp =
|
|
|
- HProject.metaObject()->property(HProject.metaObject()->indexOfProperty(prop.toUtf8()));
|
|
|
- QVariant value = metaProp.read(&HProject);
|
|
|
-
|
|
|
- if (prop == "blastStatus") {
|
|
|
- QString statusText;
|
|
|
- if (value.toString() == BlastStatus::Registered) {
|
|
|
- statusText = "待起爆";
|
|
|
- item = new QStandardItem(statusText);
|
|
|
- item->setForeground(QColor("#f3a3k'k1"));
|
|
|
- } else if (value.toString() == BlastStatus::Blasted) {
|
|
|
- statusText = "起 爆 完 成";
|
|
|
- item = new QStandardItem(statusText);
|
|
|
- item->setForeground(QColor("#90d543"));
|
|
|
+ }
|
|
|
+
|
|
|
+ // Store all UUIDs for this pcSn group in the first row
|
|
|
+ QStandardItem *uuidItem = new QStandardItem();
|
|
|
+ QStringList uuids;
|
|
|
+ for (const QSharedPointer<HProject> &project : projectsForPcSn) {
|
|
|
+ uuids << project->getUuid();
|
|
|
+ }
|
|
|
+ uuidItem->setData(uuids.join(","), Qt::UserRole);
|
|
|
+ model->setItem(currentRow, headerCount, uuidItem);
|
|
|
+
|
|
|
+ // Create a sub-row for each project in this pcSn group
|
|
|
+ for (int subIndex = 0; subIndex < projectsForPcSn.size(); ++subIndex) {
|
|
|
+ HProject &project = *projectsForPcSn[subIndex].data();
|
|
|
+
|
|
|
+ for (int col = 0; col < headerCount; ++col) {
|
|
|
+ QString prop = propMap[col];
|
|
|
+ QStandardItem *item = nullptr;
|
|
|
+
|
|
|
+ if (col == 0) {
|
|
|
+ // Only show checkbox on the first row of each pcSn group
|
|
|
+ if (subIndex == 0) {
|
|
|
+ item = new QStandardItem();
|
|
|
+ item->setCheckable(true);
|
|
|
+ item->setCheckState(Qt::Unchecked);
|
|
|
+ item->setText("");
|
|
|
} else {
|
|
|
- item = new QStandardItem(value.toString());
|
|
|
+ item = new QStandardItem("");
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else if (prop == "pcSn") {
|
|
|
+ // Only show pcSn on the first row of each group
|
|
|
+ if (subIndex == 0) {
|
|
|
+ item = new QStandardItem(pcSn);
|
|
|
+ } else {
|
|
|
+ item = new QStandardItem("");
|
|
|
+ }
|
|
|
+ } else if (prop == "blastStatus") {
|
|
|
+ // Only show aggregated blast status on the first row of each group
|
|
|
+ if (subIndex == 0) {
|
|
|
+ QString statusText;
|
|
|
+ if (combinedBlastStatus == BlastStatus::Registered) {
|
|
|
+ statusText = "待起爆";
|
|
|
+ item = new QStandardItem(statusText);
|
|
|
+ item->setForeground(QColor("#f3a3k'k1"));
|
|
|
+ } else if (combinedBlastStatus == BlastStatus::Blasted) {
|
|
|
+ statusText = "起 爆 完 成";
|
|
|
+ item = new QStandardItem(statusText);
|
|
|
+ item->setForeground(QColor("#90d543"));
|
|
|
+ } else {
|
|
|
+ item = new QStandardItem(combinedBlastStatus);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ item = new QStandardItem("");
|
|
|
+ }
|
|
|
+ } else if (col == ColIndexProgressBar || col == ColIndexOpBtn) {
|
|
|
+ // Progress and operation columns will be handled separately with widgets
|
|
|
+ // Only on the first row of each group
|
|
|
+ if (subIndex == 0) {
|
|
|
+ item = new QStandardItem("");
|
|
|
+ } else {
|
|
|
+ item = new QStandardItem("");
|
|
|
+ }
|
|
|
+ } else if (!prop.isEmpty()) {
|
|
|
+ // Show individual project data for other columns
|
|
|
+ QMetaProperty metaProp =
|
|
|
+ project.metaObject()->property(project.metaObject()->indexOfProperty(prop.toUtf8()));
|
|
|
+ QVariant value = metaProp.read(&project);
|
|
|
item = new QStandardItem(value.toString());
|
|
|
}
|
|
|
+
|
|
|
+ if (item) {
|
|
|
+ item->setTextAlignment(Qt::AlignCenter);
|
|
|
+ model->setItem(currentRow, col, item);
|
|
|
+ }
|
|
|
}
|
|
|
- if (item) {
|
|
|
- item->setTextAlignment(Qt::AlignCenter); // 设置文本居中对齐
|
|
|
- model->setItem(row, col, item);
|
|
|
- }
|
|
|
+ currentRow++;
|
|
|
}
|
|
|
}
|
|
|
ui->tableView->setModel(model);
|
|
@@ -362,16 +439,21 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
ui->tableView->setAlternatingRowColors(true);
|
|
|
ui->tableView->verticalHeader()->setDefaultSectionSize(50);
|
|
|
|
|
|
- for (int row = 0; row < projectList.size(); ++row) {
|
|
|
- // 初始化progressBars
|
|
|
- int progressCol = headers.size() - 2; //
|
|
|
+ // 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];
|
|
|
+ int firstRowIndex = pcSnToFirstRowMap[pcSn];
|
|
|
+ int groupRowSpan = projectsForPcSn.size();
|
|
|
+
|
|
|
+ // 初始化progressBars for the first row of this pcSn group
|
|
|
+ int progressCol = headers.size() - 2;
|
|
|
QProgressBar *progressBar1 = new QProgressBar(ui->tableView);
|
|
|
QProgressBar *progressBar2 = new QProgressBar(ui->tableView);
|
|
|
QProgressBar *progressBar3 = new QProgressBar(ui->tableView);
|
|
|
QHBoxLayout *progressBarLayout = new QHBoxLayout;
|
|
|
progressBars.append(ProgressBarTriple(progressBar1, progressBar2, progressBar3));
|
|
|
for (QProgressBar *pb : {progressBar1, progressBar2, progressBar3}) {
|
|
|
- pb->setRange(0, 100); // 设置范围为0到100
|
|
|
+ pb->setRange(0, 100);
|
|
|
pb->setValue(0);
|
|
|
pb->setAlignment(Qt::AlignCenter);
|
|
|
pb->setStyleSheet(
|
|
@@ -384,22 +466,24 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
}
|
|
|
progressBarLayout->setAlignment(Qt::AlignCenter);
|
|
|
progressBarLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
- progressBarLayout->setSpacing(0); // 设置进度条之间的间距为0
|
|
|
+ progressBarLayout->setSpacing(0);
|
|
|
QWidget *progressBarContainer = new QWidget(ui->tableView);
|
|
|
progressBarContainer->setLayout(progressBarLayout);
|
|
|
- QModelIndex progressIndex = model->index(row, progressCol);
|
|
|
+ QModelIndex progressIndex = model->index(firstRowIndex, progressCol);
|
|
|
if (progressIndex.isValid()) {
|
|
|
ui->tableView->setIndexWidget(progressIndex, progressBarContainer);
|
|
|
+ // Set row span to cover all sub-rows for this pcSn
|
|
|
+ ui->tableView->setSpan(firstRowIndex, progressCol, groupRowSpan, 1);
|
|
|
}
|
|
|
- int col = headers.size() - 1;
|
|
|
|
|
|
- // 创建操作按钮
|
|
|
+ // 创建操作按钮 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; }");
|
|
|
|
|
|
- QModelIndex statusIndex = model->index(row, ColIndexBlastStatus);
|
|
|
+ QModelIndex statusIndex = model->index(firstRowIndex, ColIndexBlastStatus);
|
|
|
if (statusIndex.isValid()) {
|
|
|
QString blastStatus = model->data(statusIndex).toString();
|
|
|
if (blastStatus == "待起爆") {
|
|
@@ -413,12 +497,21 @@ void BlastOpePage::loadDataAndDrawTable(int currentPage, int pageSize) {
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
widget->setLayout(layout);
|
|
|
|
|
|
- QModelIndex index = model->index(row, col);
|
|
|
+ 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, row, button]() { handleSingleBlastButtonClicked(row, button); });
|
|
|
+ [this, firstRowIndex, button]() { handleSingleBlastButtonClicked(firstRowIndex, button); });
|
|
|
}
|
|
|
+
|
|
|
+ // 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);
|
|
|
}
|
|
|
|
|
|
LoadingWidget::hideLoading();
|
|
@@ -431,25 +524,45 @@ void BlastOpePage::PageChanged(int page) {
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
+ // QVariant variant = pageWidget->getComboBox()->itemData(index);
|
|
|
+ // int value = variant.toInt();
|
|
|
+ // m_pageSize = value;
|
|
|
+ // m_currentPage = 1;
|
|
|
+ // loadDataAndDrawTable(m_currentPage, m_pageSize);
|
|
|
}
|
|
|
|
|
|
void BlastOpePage::updateProgressBar(int firingStage, int row) {
|
|
|
- if (!progressBars.isEmpty()) {
|
|
|
- QProgressBar *progressBar1 = progressBars[row].bar1;
|
|
|
- QProgressBar *progressBar2 = progressBars[row].bar2;
|
|
|
- QProgressBar *progressBar3 = progressBars[row].bar3;
|
|
|
-
|
|
|
- progressBar1->setRange(0, 100); // 设置范围为0到100
|
|
|
- progressBar1->setValue(0);
|
|
|
- progressBar2->setRange(0, 100); // 设置范围为0到100
|
|
|
- progressBar2->setValue(0);
|
|
|
- progressBar3->setRange(0, 100); // 设置范围为0到100
|
|
|
- progressBar3->setValue(0);
|
|
|
+ // Find the progress bar index for this row's pcSn group
|
|
|
+ QString pcSn;
|
|
|
+ QStandardItem *devItem = model->item(row, ColIndexBlasterDev);
|
|
|
+ if (devItem) {
|
|
|
+ pcSn = devItem->text();
|
|
|
+ if (pcSn.isEmpty()) {
|
|
|
+ // This might be a sub-row, need to find the parent row with pcSn
|
|
|
+ for (int i = row - 1; i >= 0; i--) {
|
|
|
+ QStandardItem *parentDevItem = model->item(i, ColIndexBlasterDev);
|
|
|
+ if (parentDevItem && !parentDevItem->text().isEmpty()) {
|
|
|
+ pcSn = parentDevItem->text();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Find the progress bar index for this pcSn
|
|
|
+ QStringList pcSnKeys = QStringList(pcSnToFirstRowMap.keys());
|
|
|
+ int progressBarIndex = pcSnKeys.indexOf(pcSn);
|
|
|
+
|
|
|
+ if (progressBarIndex >= 0 && progressBarIndex < progressBars.size()) {
|
|
|
+ QProgressBar *progressBar1 = progressBars[progressBarIndex].bar1;
|
|
|
+ QProgressBar *progressBar2 = progressBars[progressBarIndex].bar2;
|
|
|
+ QProgressBar *progressBar3 = progressBars[progressBarIndex].bar3;
|
|
|
+ // reset all progress bars
|
|
|
+ for (QProgressBar *pb : {progressBar1, progressBar2, progressBar3}) {
|
|
|
+ pb->setRange(0, 100); // 设置范围为0到100
|
|
|
+ pb->setValue(0);
|
|
|
+ }
|
|
|
+
|
|
|
switch (firingStage) {
|
|
|
case FiringStages::QuickTesting:
|
|
|
// 起爆检测状态
|
|
@@ -562,11 +675,18 @@ void BlastOpePage::onFiringStageUpdated(int stage, int row) {
|
|
|
|
|
|
void BlastOpePage::handleSingleBlastButtonClicked(int row, QPushButton *button) {
|
|
|
QStandardItem *devItem = model->item(row, ColIndexBlasterDev);
|
|
|
- QString blasterDevUuid;
|
|
|
+ QString blasterDevPcSn;
|
|
|
if (devItem) {
|
|
|
- blasterDevUuid = devItem->text();
|
|
|
+ blasterDevPcSn = devItem->text();
|
|
|
+ }
|
|
|
+
|
|
|
+ // Get all UUIDs for this pcSn group
|
|
|
+ QStandardItem *uuidItem = model->item(row, headers.size());
|
|
|
+ QStringList uuids;
|
|
|
+ if (uuidItem) {
|
|
|
+ QString uuidData = uuidItem->data(Qt::UserRole).toString();
|
|
|
+ uuids = uuidData.split(",", Qt::SkipEmptyParts);
|
|
|
}
|
|
|
- qDebug() << "handleSingleBlastButtonClicked: row = " << row << ", uuid = " << blasterDevUuid;
|
|
|
|
|
|
if (button->text() == startBlastButtonTxt) {
|
|
|
button->setDisabled(true);
|
|
@@ -578,7 +698,10 @@ void BlastOpePage::handleSingleBlastButtonClicked(int row, QPushButton *button)
|
|
|
});
|
|
|
button->setMinimumWidth(80);
|
|
|
button->setText(stopBlastButtonTxt);
|
|
|
- firingWidget *widget = new firingWidget(row, false, blasterDevUuid);
|
|
|
+
|
|
|
+ // 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::startCountdown, this, &BlastOpePage::showCountDownWidget);
|
|
|
connect(widget, &firingWidget::updateProjectStatus, this, &BlastOpePage::handlerUpdateProjectStatus);
|
|
@@ -588,7 +711,7 @@ void BlastOpePage::handleSingleBlastButtonClicked(int row, QPushButton *button)
|
|
|
}
|
|
|
|
|
|
widget->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
- firingWidgetByUuid.insert(blasterDevUuid, widget);
|
|
|
+ firingWidgetByUuid.insert(blasterDevPcSn, widget);
|
|
|
widget->startBlasting();
|
|
|
|
|
|
} else if (button->text() == stopBlastButtonTxt) {
|
|
@@ -597,7 +720,7 @@ void BlastOpePage::handleSingleBlastButtonClicked(int row, QPushButton *button)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- firingWidget *widget = firingWidgetByUuid.value(blasterDevUuid);
|
|
|
+ firingWidget *widget = firingWidgetByUuid.value(blasterDevPcSn);
|
|
|
if (widget) {
|
|
|
widget->sendCancelFiringMsg();
|
|
|
}
|
|
@@ -677,9 +800,10 @@ void BlastOpePage::handleUpdateOpButton(int stage, int row) {
|
|
|
}
|
|
|
|
|
|
void BlastOpePage::handlerUpdateProjectStatus(QString uuid, const QString &newStatus) {
|
|
|
- dao.updateBlastStatusByUuid(uuid, newStatus);
|
|
|
-
|
|
|
- firingWidget *widget = firingWidgetByUuid.value(uuid);
|
|
|
+ // dao.updateBlastStatusByUuid(uuid, newStatus);
|
|
|
+ QJsonObject extParams;
|
|
|
+ qDebug() << "handlerUpdateProjectStatus: uuid = " << uuid << ", newStatus = " << newStatus;
|
|
|
+ // extParams.insert("blastStatus", QJsonArray({newStatus}));
|
|
|
}
|
|
|
|
|
|
void BlastOpePage::destroyFiringWidget(const QString &uuid, int row) {
|
|
@@ -696,25 +820,23 @@ void BlastOpePage::destroyFiringWidget(const QString &uuid, int row) {
|
|
|
void BlastOpePage::onItemCheckboxChanged(QStandardItem *item) {
|
|
|
if (item->column() == 0) { // 仅处理第一列的勾选状态改变
|
|
|
if (item->checkState() == Qt::Checked) {
|
|
|
- QStandardItem *uuidItem = model->item(item->row(), 10);
|
|
|
+ // Find the first row for this pcSn group that contains the UUID data
|
|
|
+ int currentRow = item->row();
|
|
|
+ QStandardItem *uuidItem = model->item(currentRow, headers.size());
|
|
|
if (uuidItem) {
|
|
|
- QVariant uuidVariant = uuidItem->data(Qt::UserRole);
|
|
|
- if (uuidVariant.isValid()) {
|
|
|
- QString uuid = uuidVariant.toString();
|
|
|
- uuidMap[item->row()] = uuid;
|
|
|
+ QString uuidData = uuidItem->data(Qt::UserRole).toString();
|
|
|
+ QStringList uuids = uuidData.split(",", Qt::SkipEmptyParts);
|
|
|
+ if (!uuids.isEmpty()) {
|
|
|
+ // Get the pcSn for this group
|
|
|
+ QStandardItem *pcSnItem = model->item(currentRow, ColIndexBlasterDev);
|
|
|
+ if (pcSnItem) {
|
|
|
+ QString pcSn = pcSnItem->text();
|
|
|
+ uuidMap[currentRow] = pcSn; // Store pcSn using the first row of the group
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else if (item->checkState() == Qt::Unchecked) {
|
|
|
- QStandardItem *uuidItem = model->item(item->row(), 10);
|
|
|
- if (uuidItem) {
|
|
|
- // 从 item 中获取 uuid 数据
|
|
|
- QVariant uuidVariant = uuidItem->data(Qt::UserRole);
|
|
|
- if (uuidVariant.isValid()) {
|
|
|
- QString uuid = uuidVariant.toString();
|
|
|
- // 从数组中移除该 uuid
|
|
|
- uuidMap.remove(item->row());
|
|
|
- }
|
|
|
- }
|
|
|
+ uuidMap.remove(item->row());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -732,15 +854,17 @@ void BlastOpePage::on_btnSelect_clicked() {
|
|
|
|
|
|
for (auto it = uuidMap.begin(); it != uuidMap.end(); ++it) {
|
|
|
int row = it.key();
|
|
|
- QString uuid = it.value();
|
|
|
- firingWidget *widgetSelect = new firingWidget(row, true, uuid);
|
|
|
- QModelIndex index = model->index(row, ColIndexBlasterDev);
|
|
|
+ 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 *>();
|
|
|
- button->setText(stopBlastButtonTxt);
|
|
|
- button->setDisabled(true);
|
|
|
+ if (button) {
|
|
|
+ button->setText(stopBlastButtonTxt);
|
|
|
+ button->setDisabled(true);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -750,7 +874,7 @@ void BlastOpePage::on_btnSelect_clicked() {
|
|
|
connect(widgetSelect, &firingWidget::updateProjectStatus, this, &BlastOpePage::handlerUpdateProjectStatus);
|
|
|
connect(widgetSelect, &firingWidget::closeFiring, this, &BlastOpePage::destroyBatchFiringWidget);
|
|
|
widgetSelect->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
- uuidWidgetSMap.insert(uuid, widgetSelect);
|
|
|
+ uuidWidgetSMap.insert(pcSn, widgetSelect);
|
|
|
widgetSelect->startBlasting();
|
|
|
|
|
|
if (isShowTriggeringWidget) {
|
|
@@ -760,8 +884,8 @@ void BlastOpePage::on_btnSelect_clicked() {
|
|
|
}
|
|
|
|
|
|
// 完成充电
|
|
|
-void BlastOpePage::setBatchBlastTrigger(QString uuid) {
|
|
|
- selectedUuids.insert(uuid);
|
|
|
+void BlastOpePage::setBatchBlastTrigger(QString pcSn) {
|
|
|
+ selectedUuids.insert(pcSn); // Now storing pcSn instead of UUID
|
|
|
bool isSame = checkUuidsSame();
|
|
|
if (isSame) {
|
|
|
bool successSelect;
|
|
@@ -791,17 +915,17 @@ void BlastOpePage::setBatchBlastTrigger(QString uuid) {
|
|
|
}
|
|
|
} else {
|
|
|
Logger::getInstance().error(
|
|
|
- QString("The uuids in selectedUuids and uuidMap are different. uuid: %1").arg(uuid));
|
|
|
+ QString("The pcSns in selectedUuids and uuidMap are different. pcSn: %1").arg(pcSn));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 检查 selectedUuids 和 uuidMap 中的 uuid 是否相同
|
|
|
+// 检查 selectedUuids 和 uuidMap 中的 pcSn 是否相同
|
|
|
bool BlastOpePage::checkUuidsSame() {
|
|
|
- QSet<QString> mapUuids;
|
|
|
+ QSet<QString> mapPcSns;
|
|
|
for (const auto &value : uuidMap) {
|
|
|
- mapUuids.insert(value);
|
|
|
+ mapPcSns.insert(value);
|
|
|
}
|
|
|
- return selectedUuids == mapUuids;
|
|
|
+ return selectedUuids == mapPcSns;
|
|
|
}
|
|
|
|
|
|
void BlastOpePage::showCountDownForBatchBlast() {
|
|
@@ -827,20 +951,20 @@ void BlastOpePage::showCountDownForBatchBlast() {
|
|
|
|
|
|
void BlastOpePage::triggerBatchFiringBlast() {
|
|
|
for (auto it = uuidWidgetSMap.begin(); it != uuidWidgetSMap.end(); ++it) {
|
|
|
- QString uuid = it.key();
|
|
|
+ QString pcSn = it.key();
|
|
|
firingWidget *widget = it.value();
|
|
|
- QString topic = "hxgc/" + uuid + "/BlastTask";
|
|
|
+ QString topic = "hxgc/" + pcSn + "/BlastTask";
|
|
|
QString message = "起爆";
|
|
|
widget->onCountdownFinished(topic, message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void BlastOpePage::destroyBatchFiringWidget(const QString &uuid, int row) {
|
|
|
- firingWidget *widget = uuidWidgetSMap.value(uuid);
|
|
|
+void BlastOpePage::destroyBatchFiringWidget(const QString &pcSn, int row) {
|
|
|
+ firingWidget *widget = uuidWidgetSMap.value(pcSn);
|
|
|
if (widget) {
|
|
|
widget->close();
|
|
|
widget->deleteLater();
|
|
|
- uuidWidgetSMap.remove(uuid);
|
|
|
+ uuidWidgetSMap.remove(pcSn);
|
|
|
}
|
|
|
// reset the table's row by row index
|
|
|
|