From cebef271a105494b4e4e5c09f2d12636d620304c Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 18 三月 2026 10:14:50 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_宁夏_中盛建材' into dev_宁夏_中盛建材

---
 src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 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 6b43c18..22f248e 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
@@ -27,7 +27,7 @@
     @Transactional
     public Boolean addProductStructureDto(ProductStructureDto dto) {
 
-        Long bomId = dto.getBomId();
+        Integer bomId = dto.getBomId();
 
         //  灏嗘爲鎵佸钩鍖�
         List<ProductStructureDto> flatDtoList = new ArrayList<>();
@@ -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);
         }
@@ -130,8 +139,8 @@
 
 
     @Override
-    public List<ProductStructureDto> listBybomId(Long bomId) {
-        List<ProductStructureDto> list = productStructureMapper.listBybomId(bomId);
+    public List<ProductStructureDto> listByBomId(Integer bomId) {
+        List<ProductStructureDto> list = productStructureMapper.listByBomId(bomId);
 
         Map<Long, ProductStructureDto> map = new HashMap<>();
         for (ProductStructureDto node : list) {

--
Gitblit v1.9.3