From fc24827d4eb7b15c28a184123376eb758d93a9ad Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 10 四月 2026 17:25:30 +0800
Subject: [PATCH] feat: 生产计划导入验证产品是否存在、申请单编号重复、强度是否正确

---
 src/main/java/com/ruoyi/production/service/impl/ProductMaterialSkuServiceImpl.java |   67 +++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 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 3f0008f..f409ff2 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;
 
     /**
      * 鏌ヨ鐗╂枡瑙勬牸鍒楄〃
@@ -67,6 +107,7 @@
             sku.setCreateTime(now);
         }
         sku.setUpdateTime(now);
+        sku.setType(2);
 
         if (!this.save(sku)) {
             throw new ServiceException("鏂板鐗╂枡瑙勬牸澶辫触");
@@ -99,6 +140,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("鍒犻櫎鐗╂枡瑙勬牸澶辫触");
         }

--
Gitblit v1.9.3