From 2cffa027595247c136a8ee95f5f745c58cb0cce5 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期六, 09 五月 2026 13:08:12 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New_pro' into dev_New_pro

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

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
index cbae0dc..35cdb27 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionBomStructureServiceImpl.java
@@ -33,6 +33,7 @@
      */
     @Override
     public List<ProductionBomStructureVo> listByBomId(Long bomId) {
+        // 鎸塀OMID鏌ヨ鐢熶骇缁撴瀯鏁版嵁
         List<ProductionBomStructureVo> list = productionBomStructureMapper.listByBomId(bomId);
         Map<Long, ProductionBomStructureVo> map = new HashMap<>();
         for (ProductionBomStructureVo node : list) {
@@ -58,13 +59,17 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean addProductionBomStructure(ProductionBomStructureDto dto) {
+        // 鏂板鐢熶骇BOM缁撴瀯
+        // 璇诲彇褰撳墠璁㈠崟BOM涓婚敭锛屽苟鎶婂墠绔爲缁撴瀯鎷嶅钩鎴愬垪琛�
         Long orderBomId = dto.getProductionOrderBomId();
         List<ProductionBomStructureDto> flatDtoList = new ArrayList<>();
         flattenTree(dto.getChildren(), flatDtoList);
 
+        // 鏌ヨ鏁版嵁搴撳凡鏈夌粨鏋勶紝鐢ㄤ簬鍚庣画鍋氬鍒犳敼瀵规瘮
         List<ProductionBomStructure> dbList = this.list(new LambdaQueryWrapper<ProductionBomStructure>()
                 .eq(ProductionBomStructure::getProductionOrderBomId, orderBomId));
 
+        // 鏀堕泦鍓嶇浠嶇劧瀛樺湪鐨勮妭鐐笽D
         Set<Long> frontendIds = new HashSet<>();
         for (ProductionBomStructureDto item : flatDtoList) {
             if (item.getId() != null) {
@@ -72,16 +77,19 @@
             }
         }
 
+        // 璁$畻闇�瑕佸垹闄ょ殑鑺傜偣锛堟暟鎹簱鏈夈�佸墠绔凡鍒犻櫎锛�
         Set<Long> deleteIds = new HashSet<>();
         for (ProductionBomStructure dbItem : dbList) {
             if (!frontendIds.contains(dbItem.getId())) {
                 deleteIds.add(dbItem.getId());
             }
         }
+        // 鍏堝垹鎺夊墠绔凡缁忕Щ闄ょ殑鑺傜偣
         if (!deleteIds.isEmpty()) {
             this.removeByIds(deleteIds);
         }
 
+        // 鎸夋槸鍚︽湁ID鎷嗗垎涓烘柊澧炲拰鏇存柊锛屽悓鏃剁紦瀛樻柊澧炶妭鐐圭殑涓存椂ID鏄犲皠
         List<ProductionBomStructure> insertList = new ArrayList<>();
         List<ProductionBomStructure> updateList = new ArrayList<>();
         Map<String, ProductionBomStructure> tempEntityMap = new HashMap<>();
@@ -99,10 +107,12 @@
             }
         }
 
+        // 鎵归噺鏂板锛屾嬁鍒版暟鎹簱鐢熸垚鐨勭湡瀹濱D
         if (!insertList.isEmpty()) {
             this.saveBatch(insertList);
         }
 
+        // 鏂板鑺傜偣浜屾鍥炲啓鐖禝D锛堝墠绔紶鐨勬槸涓存椂鐖禝D锛�
         List<ProductionBomStructure> parentFixList = new ArrayList<>();
         for (ProductionBomStructureDto item : flatDtoList) {
             if (item.getId() == null && item.getParentTempId() != null) {
@@ -111,15 +121,18 @@
                     continue;
                 }
                 ProductionBomStructure parent = tempEntityMap.get(item.getParentTempId());
+                // 鐖惰妭鐐规槸鏈鏂板鏃讹紝鐩存帴鐢ㄦ柊澧炲悗鐨勭湡瀹濱D锛涘惁鍒欏洖閫�涓哄墠绔紶鍏ョ埗ID
                 Long realParentId = parent != null ? parent.getId() : Long.valueOf(item.getParentTempId());
                 child.setParentId(realParentId);
                 parentFixList.add(child);
             }
         }
 
+        // 鍥炲啓鏂板鑺傜偣鐨勭埗瀛愬叧绯�
         if (!parentFixList.isEmpty()) {
             this.updateBatchById(parentFixList);
         }
+        // 鎵归噺鏇存柊宸叉湁鑺傜偣
         if (!updateList.isEmpty()) {
             this.updateBatchById(updateList);
         }
@@ -130,6 +143,7 @@
      * 灏嗘爲褰㈢粨鏋勬媿骞虫垚鍒楄〃锛屼究浜庣粺涓�淇濆瓨銆�
      */
     private void flattenTree(List<ProductionBomStructureDto> source, List<ProductionBomStructureDto> result) {
+        // 鎵佸钩鍖栧鐞嗘爲
         if (source == null) {
             return;
         }

--
Gitblit v1.9.3