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 |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 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 9825b39..2f94b20 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/ProductServiceImpl.java
@@ -1,6 +1,8 @@
 package com.ruoyi.basic.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.basic.dto.ProductDto;
 import com.ruoyi.basic.dto.ProductTreeDto;
@@ -10,7 +12,11 @@
 import com.ruoyi.basic.pojo.ProductModel;
 import com.ruoyi.basic.service.IProductService;
 import com.ruoyi.common.utils.bean.BeanUtils;
-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 java.util.ArrayList;
@@ -18,12 +24,16 @@
 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) {
@@ -48,6 +58,12 @@
         }
         return tree;
     }
+
+    @Override
+    public IPage<ProductModel> listPageProductModel(Page<ProductModel> page, ProductModel productModel) {
+        return productModelMapper.listPageProductModel(page, productModel);
+    }
+
 
     // 閫掑綊鏋勫缓瀛愯妭鐐�
     private List<ProductTreeDto> buildChildrenNodes(Long parentId) {
@@ -104,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