From d7ad840956b690eb86acbb5faa17d8b42fcf220c Mon Sep 17 00:00:00 2001 From: lh <2334563547@qq.com> Date: Wed, 2 Sep 2026 11:34:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(nmNum):=20=E4=BF=AE=E5=A4=8D=E6=88=90?= =?UTF-8?q?=E6=9E=9C=E5=8A=A0=E8=BD=BD=E5=90=8E=E8=87=AA=E5=8A=A8=E6=8B=9F?= =?UTF-8?q?=E5=90=88=E7=BB=93=E6=9E=9C=E7=BB=91=E5=AE=9A=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Include/nmNum/nmData/nmDataAnalyzeManager.h | 10 +++-- Src/nmNum/nmData/nmDataAnalyzeManager.cpp | 45 +++++++++++++++++++-- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Include/nmNum/nmData/nmDataAnalyzeManager.h b/Include/nmNum/nmData/nmDataAnalyzeManager.h index 99c7b1b..502ecb6 100644 --- a/Include/nmNum/nmData/nmDataAnalyzeManager.h +++ b/Include/nmNum/nmData/nmDataAnalyzeManager.h @@ -236,10 +236,12 @@ public: // TODO:有问题,不会更新不同类型的井数据 //void updateWellData(const QVector& newData); - // 添加针对具体井类型的更新方法 - void updateVerticalWells(const QVector& wells); - void updateVerticalFracturedWells(const QVector& wells); - void updateHorizontalFracturedWells(const QVector& wells); + /** @brief 按稳定 UUID 回写直井数据,并恢复井与最后结果快照的弱关联。 */ + void updateVerticalWells(const QVector& wells); + /** @brief 按稳定 UUID 回写压裂直井数据,并恢复井与最后结果快照的弱关联。 */ + void updateVerticalFracturedWells(const QVector& wells); + /** @brief 按稳定 UUID 回写多段压裂水平井数据,并恢复井与最后结果快照的弱关联。 */ + void updateHorizontalFracturedWells(const QVector& wells); // 返回分类后的井数据 // 获取所有直井数据 diff --git a/Src/nmNum/nmData/nmDataAnalyzeManager.cpp b/Src/nmNum/nmData/nmDataAnalyzeManager.cpp index d219d4d..7ffbb79 100644 --- a/Src/nmNum/nmData/nmDataAnalyzeManager.cpp +++ b/Src/nmNum/nmData/nmDataAnalyzeManager.cpp @@ -1180,44 +1180,83 @@ QVector nmDataAnalyzeManager::getWellDataList() const void nmDataAnalyzeManager::updateVerticalWells(const QVector& wells) { + bool bWellUpdated = false; foreach(const auto& newWell, wells) { + const QString sWellInstanceId = newWell.getWellInstanceId(); + if(sWellInstanceId.isEmpty()) { + qWarning() << "Cannot update vertical well without UUID:" + << newWell.getWellName(); + continue; + } foreach(auto* existingWell, m_vWellData) { if(auto * vWell = dynamic_cast(existingWell)) { - if(vWell->getWellName() == newWell.getWellName()) { + // UUID 是井实例的唯一身份,禁止同名新井覆盖旧井。 + if(vWell->getWellInstanceId() == sWellInstanceId) { *vWell = newWell; // 调用赋值运算符 + bWellUpdated = true; break; } } } } + // 井赋值不复制快照绑定,并会解除目标井的弱引用,回写后必须由 Manager 统一恢复。 + if(bWellUpdated) { + rebindPebiResultSnapshotToWells(); + } } void nmDataAnalyzeManager::updateVerticalFracturedWells(const QVector& wells) { + bool bWellUpdated = false; foreach(const auto& newWell, wells) { + const QString sWellInstanceId = newWell.getWellInstanceId(); + if(sWellInstanceId.isEmpty()) { + qWarning() << "Cannot update vertical fractured well without UUID:" + << newWell.getWellName(); + continue; + } foreach(auto* existingWell, m_vWellData) { if(auto * vWell = dynamic_cast(existingWell)) { - if(vWell->getWellName() == newWell.getWellName()) { + // UUID 是井实例的唯一身份,禁止同名新井覆盖旧井。 + if(vWell->getWellInstanceId() == sWellInstanceId) { *vWell = newWell; // 调用赋值运算符 + bWellUpdated = true; break; } } } } + // 井赋值不复制快照绑定,并会解除目标井的弱引用,回写后必须由 Manager 统一恢复。 + if(bWellUpdated) { + rebindPebiResultSnapshotToWells(); + } } void nmDataAnalyzeManager::updateHorizontalFracturedWells(const QVector& wells) { + bool bWellUpdated = false; foreach(const auto& newWell, wells) { + const QString sWellInstanceId = newWell.getWellInstanceId(); + if(sWellInstanceId.isEmpty()) { + qWarning() << "Cannot update horizontal fractured well without UUID:" + << newWell.getWellName(); + continue; + } foreach(auto* existingWell, m_vWellData) { if(auto * vWell = dynamic_cast(existingWell)) { - if(vWell->getWellName() == newWell.getWellName()) { + // UUID 是井实例的唯一身份,禁止同名新井覆盖旧井。 + if(vWell->getWellInstanceId() == sWellInstanceId) { *vWell = newWell; // 调用赋值运算符 + bWellUpdated = true; break; } } } } + // 井赋值不复制快照绑定,并会解除目标井的弱引用,回写后必须由 Manager 统一恢复。 + if(bWellUpdated) { + rebindPebiResultSnapshotToWells(); + } } // 获取所有直井数据