From 0d7d874912d0147376826b55667a1deb6547ed91 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 21 五月 2026 15:25:27 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' into dev_宁夏_英泽防锈

---
 src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
index 51e5441..263a52a 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
@@ -17,9 +17,12 @@
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.sales.dto.LossProductModelDto;
 import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
 import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.technology.mapper.TechnologyBomMapper;
+import com.ruoyi.technology.pojo.TechnologyBom;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -43,6 +46,7 @@
 
     private final ProductMapper productMapper;
     private final SalesLedgerProductMapper salesLedgerProductMapper;
+    private final TechnologyBomMapper technologyBomMapper;
     private ProductModelMapper productModelMapper;
 
     @Override
@@ -86,6 +90,14 @@
 
             throw new RuntimeException("宸茬粡瀛樺湪璇ヤ骇鍝佺殑閿�鍞彴璐﹀拰閲囪喘鍙拌处");
         }
+
+        // 鏄惁瀛樺湪BOM
+        List<TechnologyBom> technologyBoms = technologyBomMapper.selectList(new QueryWrapper<TechnologyBom>()
+                .lambda().in(TechnologyBom::getProductModelId, ids));
+        if (CollectionUtils.isNotEmpty(technologyBoms)) {
+            throw new RuntimeException("宸茬粡瀛樺湪璇ヤ骇鍝佺殑BOM鏁版嵁");
+        }
+
         return productModelMapper.deleteBatchIds(Arrays.asList(ids));
     }
 
@@ -112,14 +124,14 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public AjaxResult importProductModel(MultipartFile file, Integer productId) {
+    public R<?> importProductModel(MultipartFile file, Integer productId) {
         if (productId == null) {
-            return AjaxResult.error("璇峰厛閫夋嫨浜у搧鍐嶅鍏ヨ鏍煎瀷鍙�");
+            return R.fail("璇峰厛閫夋嫨浜у搧鍐嶅鍏ヨ鏍煎瀷鍙�");
         }
 
         Product product = productMapper.selectById(productId);
         if (product == null) {
-            return AjaxResult.error("閫夋嫨鐨勪骇鍝佷笉瀛樺湪");
+            return R.fail("閫夋嫨鐨勪骇鍝佷笉瀛樺湪");
         }
 
         try {
@@ -127,7 +139,7 @@
             List<ProductModel> productModelList = productModelExcelUtil.importExcel(file.getInputStream());
 
             if (CollectionUtils.isEmpty(productModelList)) {
-                return AjaxResult.error("瀵煎叆鏁版嵁涓嶈兘涓虹┖");
+                return R.fail("瀵煎叆鏁版嵁涓嶈兘涓虹┖");
             }
 
             //  鑾峰彇褰撳墠浜у搧涓嬫墍鏈夌殑瑙勬牸鍨嬪彿鍚�
@@ -142,13 +154,13 @@
                 int rowNum = i + 2;
 
                 if (StringUtils.isEmpty(item.getProductCode())) {
-                    return AjaxResult.error("绗� " + rowNum + " 琛屽鍏ュけ璐�: [浜у搧缂栫爜] 涓嶈兘涓虹┖");
+                    return R.fail("绗� " + rowNum + " 琛屽鍏ュけ璐�: [浜у搧缂栫爜] 涓嶈兘涓虹┖");
                 }
                 if (StringUtils.isEmpty(item.getModel())) {
-                    return AjaxResult.error("绗� " + rowNum + " 琛屽鍏ュけ璐�: [瑙勬牸鍨嬪彿] 涓嶈兘涓虹┖");
+                    return R.fail("绗� " + rowNum + " 琛屽鍏ュけ璐�: [瑙勬牸鍨嬪彿] 涓嶈兘涓虹┖");
                 }
                 if (StringUtils.isEmpty(item.getUnit())) {
-                    return AjaxResult.error("绗� " + rowNum + " 琛屽鍏ュけ璐�: [鍗曚綅] 涓嶈兘涓虹┖");
+                    return R.fail("绗� " + rowNum + " 琛屽鍏ュけ璐�: [鍗曚綅] 涓嶈兘涓虹┖");
                 }
 
                 //  鍘婚噸,濡傛灉宸插寘鍚鍨嬪彿,鍒欒烦杩�
@@ -168,9 +180,9 @@
             }
 
             if (skipCount == 0) {
-                return AjaxResult.success(String.format("鎴愬姛瀵煎叆 %d 鏉℃暟鎹�", waitToSaveList.size()));
+                return R.ok(null, String.format("鎴愬姛瀵煎叆 %d 鏉℃暟鎹�", waitToSaveList.size()));
             } else {
-                return AjaxResult.success(String.format("鎴愬姛瀵煎叆 %d 鏉★紝璺宠繃宸插瓨鍦ㄦ暟鎹� %d 鏉�", waitToSaveList.size(), skipCount));
+                return R.ok(null, String.format("鎴愬姛瀵煎叆 %d 鏉★紝璺宠繃宸插瓨鍦ㄦ暟鎹� %d 鏉�", waitToSaveList.size(), skipCount));
             }
         } catch (Exception e) {
             log.error("瀵煎叆浜у搧瑙勬牸寮傚父", e);

--
Gitblit v1.9.3