From a76e1d17d67641993dea6335cb8e1465a94df58d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 21 五月 2026 15:39:05 +0800
Subject: [PATCH] feat(stock): 优化库存管理和成品树结构功能 1- 为ApproveProcessMapper.xml和ProductBomMapper.xml添加排序功能 2- 在ProductionProductMainDto中新增bomInputQty字段用于产品结构投入数量 3- 修改ProductionProductMainServiceImpl中投入数量计算逻辑,使用前端传入的bomInputQty值 4- 在ProductWorkOrderDto中添加bomInputQty字段并在服务实现中计算标准投入数量 5- 更新SalesLedgerMapper.xml查询逻辑,从product_summary获取电压信息 6- 为SalesLedgerProduct添加stockId字段并修改库存扣减逻辑使用具体库存ID 7- 重构StockInventoryController中的成品库存树查询接口和导入导出功能 8- 新增成品和非成品库存导入导出的数据模型和Excel工具类 9- 优化StockInventoryServiceImpl中的库存扣减逻辑,支持按特定库存ID操作 10- 更新库存导入导出功能,区分成品和非成品类型并提供相应模板

---
 src/main/java/com/ruoyi/warehouse/service/impl/DocumentClassificationServiceImpl.java |   67 +++++++++++++++++++++++++++++++--
 1 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/ruoyi/warehouse/service/impl/DocumentClassificationServiceImpl.java b/src/main/java/com/ruoyi/warehouse/service/impl/DocumentClassificationServiceImpl.java
index 63e4640..54c642e 100644
--- a/src/main/java/com/ruoyi/warehouse/service/impl/DocumentClassificationServiceImpl.java
+++ b/src/main/java/com/ruoyi/warehouse/service/impl/DocumentClassificationServiceImpl.java
@@ -3,6 +3,12 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.dto.ProductTreeDto;
+import com.ruoyi.basic.pojo.Product;
+import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.warehouse.dto.DocumentClassificationDto;
+import com.ruoyi.warehouse.dto.DocumentClassificationTreeDto;
+import com.ruoyi.warehouse.dto.DocumentationDto;
 import com.ruoyi.warehouse.mapper.DocumentationMapper;
 import com.ruoyi.warehouse.pojo.DocumentClassification;
 import com.ruoyi.warehouse.pojo.Documentation;
@@ -11,7 +17,9 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 /**
 * @author 86151
@@ -23,16 +31,65 @@
     implements DocumentClassificationService{
     @Autowired
     private DocumentationMapper documentationMapper;
-
+    @Autowired
+    private DocumentClassificationMapper documentClassificationMapper;
     @Override
     public boolean deleteByIds(List<Long> ids) {
-        List<Documentation> documentations = documentationMapper.selectList(new LambdaQueryWrapper<Documentation>().in(Documentation::getDocumentClassificationId, ids));
-        if(!CollectionUtils.isEmpty(documentations)){
-            return false;
+        List<DocumentClassification> list = documentClassificationMapper.selectList(new LambdaQueryWrapper<DocumentClassification>().in(DocumentClassification::getId, ids));
+        for (DocumentClassification documentClassification : list) {
+          //濡傛灉姣忛」鐨勭埗id涓虹┖锛岃鏄庢槸鏍硅妭鐐癸紝闇�瑕佸垹闄ゆ枃妗d俊鎭〃涓殑鏁版嵁
+            List<DocumentationDto> documentationDtos = documentationMapper.listByDocumentClassificationId(documentClassification.getId());
+            if (CollectionUtils.isNotEmpty(documentationDtos)){
+                throw new RuntimeException("瀛樺湪鏂囨。淇℃伅锛屼笉鑳藉垹闄�");
+            }
+            documentClassificationMapper.deleteById(documentClassification.getId());
         }
-        baseMapper.deleteBatchIds(ids);
         return true;
     }
+
+    @Override
+    public List<DocumentClassificationTreeDto> selectDocumentClassificationList() {
+        // 鏌ヨ鏍硅妭鐐癸紙parentId 涓� null锛�
+        LambdaQueryWrapper<DocumentClassification> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.isNull(DocumentClassification::getParentId);
+
+        // 鏌ヨ鏍硅妭鐐瑰垪琛�
+        List<DocumentClassification> rootList = baseMapper.selectList(queryWrapper);
+
+        // 杞崲涓烘爲鑺傜偣骞堕�掑綊鏋勫缓瀛愭爲
+        List<DocumentClassificationTreeDto> tree = new ArrayList<>();
+        for (DocumentClassification documentClassification : rootList) {
+            DocumentClassificationTreeDto node = convertToTreeDto(documentClassification);
+            node.setChildren(buildDocumentChildrenNodes(documentClassification.getId()));
+            tree.add(node);
+        }
+        return tree;
+    }
+    // 閫掑綊鏋勫缓瀛愯妭鐐�
+    private List<DocumentClassificationTreeDto> buildDocumentChildrenNodes(Long parentId) {
+        // 鏌ヨ褰撳墠鐖惰妭鐐圭殑瀛愯妭鐐�
+        LambdaQueryWrapper<DocumentClassification> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(DocumentClassification::getParentId, parentId);
+        List<DocumentClassification> childList = baseMapper.selectList(queryWrapper);
+
+        // 杞崲瀛愯妭鐐瑰苟閫掑綊鏋勫缓瀹冧滑鐨勫瓙鏍�
+        List<DocumentClassificationTreeDto> children = new ArrayList<>();
+        for (DocumentClassification child : childList) {
+            DocumentClassificationTreeDto childNode = convertToTreeDto(child);
+            childNode.setChildren(buildDocumentChildrenNodes(child.getId()));
+            children.add(childNode);
+        }
+
+        return children;
+    }
+    // 灏� DocumentClassification 杞崲涓� DocumentClassificationTreeDto
+    private DocumentClassificationTreeDto convertToTreeDto(DocumentClassification documentClassification) {
+        DocumentClassificationTreeDto dto = new DocumentClassificationTreeDto();
+        BeanUtils.copyProperties(documentClassification, dto);
+        dto.setCategory(documentClassification.getCategory()); // 璁剧疆 label 涓轰骇鍝佸悕绉�
+        dto.setChildren(new ArrayList<>());
+        return dto;
+    }
 }
 
 

--
Gitblit v1.9.3