From cf65d0a608b21f07dc50a98b864dfe47def4f86b Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 23 三月 2026 17:12:37 +0800
Subject: [PATCH] fix:1.产品删除 2.原材料展示 3.菜单优化 4.区分角色编辑删除

---
 src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java
index fdf2dd3..2f94b20 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java
@@ -12,23 +12,28 @@
 import com.ruoyi.basic.pojo.ProductModel;
 import com.ruoyi.basic.service.IProductService;
 import com.ruoyi.common.utils.bean.BeanUtils;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.framework.web.domain.AjaxResult;
-import lombok.AllArgsConstructor;
+import com.ruoyi.consumables.mapper.ConsumablesInventoryMapper;
+import com.ruoyi.consumables.pojo.ConsumablesInventory;
+import com.ruoyi.stock.mapper.StockInventoryMapper;
+import com.ruoyi.stock.pojo.StockInventory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 @Service
-@AllArgsConstructor
 public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
 
+    @Autowired
     private ProductMapper productMapper;
-
+    @Autowired
     private ProductModelMapper productModelMapper;
+    @Autowired
+    private StockInventoryMapper stockInventoryMapper;
+    @Autowired
+    private ConsumablesInventoryMapper consumablesInventoryMapper;
 
     @Override
     public List<ProductTreeDto> selectProductList(ProductDto productDto) {
@@ -115,15 +120,21 @@
 
     @Override
     public int delProductByIds(Long[] ids) {
+
+        List<StockInventory> stockInventoryList = stockInventoryMapper.selectList(new LambdaQueryWrapper<StockInventory>().in(StockInventory::getProductId, Arrays.asList(ids)));
+        List<ConsumablesInventory> consumablesInventoryList = consumablesInventoryMapper.selectList(new LambdaQueryWrapper<ConsumablesInventory>().in(ConsumablesInventory::getProductId, Arrays.asList(ids)));
+        if (!stockInventoryList.isEmpty() || !consumablesInventoryList.isEmpty()) {
+            throw new RuntimeException("璇ヤ骇鍝佸瓨鍦ㄥ簱瀛樺叧鑱�!");
+        }
+
         // 1. 鍒犻櫎瀛愯〃 product_model 涓叧鑱旂殑鏁版嵁
         LambdaQueryWrapper<ProductModel> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(ProductModel::getProductId, ids);
         productModelMapper.delete(queryWrapper);
 
         // 2. 鍒犻櫎涓昏〃 product 鏁版嵁
-        int deleteCount = productMapper.deleteBatchIds(Arrays.asList(ids));
 
-        return deleteCount;
+        return productMapper.deleteBatchIds(Arrays.asList(ids));
     }
 
 }

--
Gitblit v1.9.3