From 6ad5c2cdc193cf7bb02884961b7434cd7f607a0d Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 16 四月 2026 10:48:09 +0800
Subject: [PATCH] feat(production): 扩展生产工艺路线支持多产品绑定及工单权限控制

---
 src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 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..38c7300 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductStructureServiceImpl.java
@@ -2,6 +2,7 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.production.dto.ProductStructureDto;
 import com.ruoyi.production.mapper.ProductStructureMapper;
 import com.ruoyi.production.pojo.ProductStructure;
@@ -27,7 +28,7 @@
     @Transactional
     public Boolean addProductStructureDto(ProductStructureDto dto) {
 
-        Long bomId = dto.getBomId();
+        Integer bomId = dto.getBomId();
 
         //  灏嗘爲鎵佸钩鍖�
         List<ProductStructureDto> flatDtoList = new ArrayList<>();
@@ -86,7 +87,7 @@
         //  鐪熷疄鐨勭埗鑺傜偣 ID
         Long realParentId;
         for (ProductStructureDto psDto : flatDtoList) {
-            if (psDto.getId() == null && psDto.getParentTempId() != null) {
+            if (psDto.getId() == null && StringUtils.isNotEmpty(psDto.getParentTempId())) {
                 ProductStructure child = tempEntityMap.get(psDto.getTempId());
                 if (tempEntityMap.containsKey(psDto.getParentTempId())) {
                     // 鐖惰妭鐐规槸鏂拌妭鐐�
@@ -130,7 +131,7 @@
 
 
     @Override
-    public List<ProductStructureDto> listBybomId(Long bomId) {
+    public List<ProductStructureDto> listBybomId(Integer bomId) {
         List<ProductStructureDto> list = productStructureMapper.listBybomId(bomId);
 
         Map<Long, ProductStructureDto> map = new HashMap<>();
@@ -154,4 +155,18 @@
         return tree;
     }
 
+    @Override
+    public List<ProductStructureDto> listDetailBybomId(Integer bomId) {
+        List<ProductStructureDto> list = productStructureMapper.listBybomId(bomId);
+        Map<String, ProductStructureDto> distinctMap = new LinkedHashMap<>();
+        for (ProductStructureDto dto : list) {
+            if (dto.getParentId() == null || dto.getParentId() == 0) {
+                continue;
+            }
+            String key = dto.getProcessId() == null ? "NULL_PROCESS_" + dto.getId() : String.valueOf(dto.getProcessId());
+            distinctMap.putIfAbsent(key, dto);
+        }
+        return new ArrayList<>(distinctMap.values());
+    }
+
 }

--
Gitblit v1.9.3