From 2ad2948d0e1c4e0d9d5000c3eb02605c3aceed94 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 09 四月 2026 18:04:00 +0800
Subject: [PATCH] fix: 产品被绑定不允许删除

---
 src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
index 33d4399..3ce997f 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialServiceImpl.java
@@ -271,8 +271,7 @@
     @Override
     public List<ProductMaterialGroupDto> ProductMaterialList(Integer type) {
         List<ProductMaterialConfig> configList = productMaterialConfigService.list(new LambdaQueryWrapper<ProductMaterialConfig>()
-                .eq(ProductMaterialConfig::getConfigType, MaterialConfigTypeEnum.MATERIAL_TYPE.name())
-        );
+                .eq(ProductMaterialConfig::getConfigType, MaterialConfigTypeEnum.MATERIAL_TYPE.name()));
         if (CollectionUtils.isEmpty(configList)) {
             return new ArrayList<>();
         }
@@ -284,7 +283,9 @@
                             ProductMaterial::getId,
                             ProductMaterial::getMaterialTypeId,
                             ProductMaterial::getInventoryCategoryId,
-                            ProductMaterial::getProductName
+                            ProductMaterial::getProductName,
+                            ProductMaterial::getUnit,
+                            ProductMaterial::getRemark
                     )
             );
             materialMap = materialList.stream()
@@ -359,6 +360,8 @@
         dto.setProductName(m.getProductName());
         dto.setMaterialTypeId(m.getMaterialTypeId());
         dto.setInventoryCategoryId(m.getInventoryCategoryId());
+        dto.setUnit(m.getUnit());
+        dto.setRemark(m.getRemark());
         return dto;
     }
 
@@ -404,6 +407,13 @@
         if (ids == null || ids.isEmpty()) {
             throw new ServiceException("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�");
         }
+
+        //  瀛樺湪瑙勬牸灏变笉鑳藉垹闄�
+        long skuCount = productMaterialSkuService.count(new LambdaQueryWrapper<ProductMaterialSku>().in(ProductMaterialSku::getProductId, ids));
+        if (skuCount > 0) {
+            throw new ServiceException("璇ョ墿鏂欎笅瀛樺湪瑙勬牸鏁版嵁锛屾棤娉曞垹闄�");
+        }
+
         if (!this.removeByIds(ids)) {
             throw new ServiceException("鍒犻櫎鐗╂枡澶辫触");
         }

--
Gitblit v1.9.3