From 285fa628a51ccc480ee946d2a1ee5bd13e9ae65a Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 18 三月 2026 13:51:58 +0800
Subject: [PATCH] fix: 工艺路线子集SQL去除产品查询

---
 src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
index 2dfd0f3..22f248e 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
@@ -86,17 +86,27 @@
         //  鐪熷疄鐨勭埗鑺傜偣 ID
         Long realParentId;
         for (ProductStructureDto psDto : flatDtoList) {
-            if (psDto.getId() == null && psDto.getParentTempId() != null) {
+            String parentTempId = psDto.getParentTempId();
+            if (psDto.getId() == null && parentTempId != null && !parentTempId.isEmpty()) {
                 ProductStructure child = tempEntityMap.get(psDto.getTempId());
-                if (tempEntityMap.containsKey(psDto.getParentTempId())) {
+                if (tempEntityMap.containsKey(parentTempId)) {
                     // 鐖惰妭鐐规槸鏂拌妭鐐�
-                    realParentId = tempEntityMap.get(psDto.getParentTempId()).getId();
+                    realParentId = tempEntityMap.get(parentTempId).getId();
                 } else {
                     // 鐖惰妭鐐规槸鑰佽妭鐐�
-                    realParentId = Long.valueOf(psDto.getParentTempId());
+                    try {
+                        realParentId = Long.valueOf(parentTempId);
+                    } catch (NumberFormatException e) {
+                        realParentId = 0L;
+                    }
                 }
 
                 child.setParentId(realParentId);
+                parentFixList.add(child);
+            } else if (psDto.getId() == null) {
+                // 濡傛灉 parentTempId 涓虹┖锛屽垯鏄《绾ц妭鐐�
+                ProductStructure child = tempEntityMap.get(psDto.getTempId());
+                child.setParentId(0L);
                 parentFixList.add(child);
             }
         }
@@ -104,7 +114,6 @@
         if (!parentFixList.isEmpty()) {
             this.updateBatchById(parentFixList);
         }
-
         if (!updateList.isEmpty()) {
             this.updateBatchById(updateList);
         }

--
Gitblit v1.9.3