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/ProductMaterialSkuServiceImpl.java | 72 +++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
index 35a2034..3ee1d34 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java
@@ -13,6 +13,22 @@
import com.ruoyi.production.pojo.ProductMaterialSku;
import com.ruoyi.production.dto.ProductMaterialSkuImportDto;
import com.ruoyi.production.service.ProductMaterialSkuService;
+import com.ruoyi.production.mapper.ProductOrderMapper;
+import com.ruoyi.production.mapper.ProductStructureMapper;
+import com.ruoyi.production.mapper.ProductionOrderRouteItemMapper;
+import com.ruoyi.production.mapper.ProductionOrderRouteMapper;
+import com.ruoyi.production.mapper.ProductionOrderStructureMapper;
+import com.ruoyi.production.mapper.ProductionProductInputMapper;
+import com.ruoyi.production.mapper.ProductionProductOutputMapper;
+import com.ruoyi.production.pojo.ProductOrder;
+import com.ruoyi.production.pojo.ProductStructure;
+import com.ruoyi.production.pojo.ProductionOrderRoute;
+import com.ruoyi.production.pojo.ProductionOrderRouteItem;
+import com.ruoyi.production.pojo.ProductionOrderStructure;
+import com.ruoyi.production.pojo.ProductionProductInput;
+import com.ruoyi.production.pojo.ProductionProductOutput;
+import com.ruoyi.productionPlan.mapper.ProductionPlanMapper;
+import com.ruoyi.productionPlan.pojo.ProductionPlan;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -38,6 +54,30 @@
@Autowired
private ProductMaterialMapper productMaterialMapper;
+
+ @Autowired
+ private ProductionPlanMapper productionPlanMapper;
+
+ @Autowired
+ private ProductOrderMapper productOrderMapper;
+
+ @Autowired
+ private ProductStructureMapper productStructureMapper;
+
+ @Autowired
+ private ProductionOrderRouteItemMapper productionOrderRouteItemMapper;
+
+ @Autowired
+ private ProductionOrderRouteMapper productionOrderRouteMapper;
+
+ @Autowired
+ private ProductionOrderStructureMapper productionOrderStructureMapper;
+
+ @Autowired
+ private ProductionProductOutputMapper productionProductOutputMapper;
+
+ @Autowired
+ private ProductionProductInputMapper productionProductInputMapper;
/**
* 鏌ヨ鐗╂枡瑙勬牸鍒楄〃
@@ -99,6 +139,32 @@
if (ids == null || ids.isEmpty()) {
throw new ServiceException("璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�");
}
+
+ if (productionPlanMapper.selectCount(new LambdaQueryWrapper<ProductionPlan>().in(ProductionPlan::getProductMaterialSkuId, ids)) > 0) {
+ throw new ServiceException("璇ョ墿鏂欏凡琚攢鍞敓浜ц鍒掑紩鐢紝鏃犳硶鍒犻櫎");
+ }
+ if (productOrderMapper.selectCount(new LambdaQueryWrapper<ProductOrder>().in(ProductOrder::getProductMaterialSkuId, ids)) > 0) {
+ throw new ServiceException("璇ョ墿鏂欏凡琚敓浜ц鍗曞紩鐢紝鏃犳硶鍒犻櫎");
+ }
+ if (productStructureMapper.selectCount(new LambdaQueryWrapper<ProductStructure>().in(ProductStructure::getProductModelId, ids)) > 0) {
+ throw new ServiceException("璇ョ墿鏂欏凡琚獴OM瀛愯〃寮曠敤锛屾棤娉曞垹闄�");
+ }
+ if (productionOrderRouteItemMapper.selectCount(new LambdaQueryWrapper<ProductionOrderRouteItem>().in(ProductionOrderRouteItem::getProductModelId, ids)) > 0) {
+ throw new ServiceException("璇ョ墿鏂欏凡琚敓浜ц鍗曠粦瀹氱殑宸ヨ壓璺嚎--宸ュ簭琛ㄥ紩鐢紝鏃犳硶鍒犻櫎");
+ }
+ if (productionOrderRouteMapper.selectCount(new LambdaQueryWrapper<ProductionOrderRoute>().in(ProductionOrderRoute::getProductModelId, ids)) > 0) {
+ throw new ServiceException("璇ョ墿鏂欏凡琚敓浜ц鍗曠粦瀹氱殑宸ヨ壓璺嚎琛ㄥ紩鐢紝鏃犳硶鍒犻櫎");
+ }
+ if (productionOrderStructureMapper.selectCount(new LambdaQueryWrapper<ProductionOrderStructure>().in(ProductionOrderStructure::getProductModelId, ids)) > 0) {
+ throw new ServiceException("璇ョ墿鏂欏凡琚敓浜ц鍗曠粦瀹氱殑BOM瀛愯〃寮曠敤锛屾棤娉曞垹闄�");
+ }
+ if (productionProductOutputMapper.selectCount(new LambdaQueryWrapper<ProductionProductOutput>().in(ProductionProductOutput::getProductModelId, ids)) > 0) {
+ throw new ServiceException("璇ョ墿鏂欏凡琚敓浜ф姤宸ヤ骇鍑烘槑缁嗚〃寮曠敤锛屾棤娉曞垹闄�");
+ }
+ if (productionProductInputMapper.selectCount(new LambdaQueryWrapper<ProductionProductInput>().in(ProductionProductInput::getProductId, ids)) > 0) {
+ throw new ServiceException("璇ョ墿鏂欏凡琚敓浜ф姤宸ョ墿鏂欐姇鍏ヨ〃寮曠敤锛屾棤娉曞垹闄�");
+ }
+
if (!this.removeByIds(ids)) {
throw new ServiceException("鍒犻櫎鐗╂枡瑙勬牸澶辫触");
}
@@ -175,8 +241,12 @@
emptyCodeRows.add(currentRow);
continue;
}
+ // 浜у搧瑙勬牸涓嶈兘涓虹┖
if (StringUtils.isEmpty(dto.getModel())) {
- continue;
+ throw new ServiceException("瀵煎叆澶辫触,浜у搧瑙勬牸涓嶈兘涓虹┖");
+ }
+ if (StringUtils.isEmpty(dto.getSupplyType())) {
+ throw new ServiceException("瀵煎叆澶辫触,渚涘簲鏂瑰紡涓嶈兘涓虹┖");
}
String modelKey = dto.getModel().trim();
--
Gitblit v1.9.3