From e0b041aca4e2ed0e0881e596c6cd1ec3dc63ddba Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期五, 09 一月 2026 15:51:20 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/MatController.java |   32 +++++++++++++++++++++++++++-----
 1 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/MatController.java b/src/main/java/com/zy/asrs/controller/MatController.java
index 06d4717..0d10e95 100644
--- a/src/main/java/com/zy/asrs/controller/MatController.java
+++ b/src/main/java/com/zy/asrs/controller/MatController.java
@@ -13,9 +13,7 @@
 import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.EmptyPlateOutParam;
 import com.zy.asrs.entity.result.KeyValueVo;
-import com.zy.asrs.service.InOutService;
-import com.zy.asrs.service.MatBarcodeService;
-import com.zy.asrs.service.MatService;
+import com.zy.asrs.service.*;
 import com.zy.asrs.utils.MatExcelListener;
 import com.zy.common.CodeRes;
 import com.zy.common.config.AdminInterceptor;
@@ -46,6 +44,12 @@
     private InOutService inOutService;
     @Autowired
     private MatBarcodeService matBarcodeService;
+    @Autowired
+    private WaitPakinService waitPakinService;
+    @Autowired
+    private LocDetlService locDetlService;
+    @Autowired
+    private WrkDetlService wrkDetlService;
 
     @RequestMapping(value = "/mat/auto/matnr/auth")
     public R autoMatnr(){
@@ -153,6 +157,9 @@
         if (Cools.isEmpty(mat) || null==mat.getId()){
             return R.error();
         }
+        if (null != matService.selectByMatnr(mat.getMatnr())) {
+            return R.error("鍟嗗搧妯″叿鍚嶇О宸插瓨鍦�");
+        }
         if (mat.getColor().equals("姝e父")){
             mat.setColor("鎶ュ簾");
         }else if (mat.getColor().equals("鎶ュ簾")){
@@ -177,6 +184,12 @@
         if (Cools.isEmpty(mat.getUnit())){
             return R.error(BaseRes.PARAM);
         }
+        if (!mat.getUnit().startsWith("6")&&!mat.getUnit().startsWith("7")&&!mat.getUnit().startsWith("8")){
+            throw new CoolException("鎵樼洏鐮侀浣嶄笉绗﹀悎瑙勮寖");
+        }
+        if (mat.getUnit().length()!= 8){
+            throw new CoolException("鎵樼洏鐮佷笉鏄叓浣嶏紝璇锋鏌�");
+        }
         matBarcodeService.addBarcodeMatnrTwo(mat);
         return R.ok();
     }
@@ -189,9 +202,18 @@
             return R.error();
         }
         for (Mat entity : list){
-            if (!matService.delete(new EntityWrapper<>(entity))) {
-                throw new CoolException("鍒犻櫎澶辫触锛岃鑱旂郴绠$悊鍛�");
+            Integer locCount = locDetlService.selectCountByMatNr(entity.getMatnr());
+            Integer waitCount = waitPakinService.selectCountByMatNr(entity.getMatnr());
+            Integer wrkCount = wrkDetlService.selectCountByMatNr(entity.getMatnr());
+            InOut inOut = inOutService.selectByMatnr(entity.getMatnr());
+            if (locCount > 0 || waitCount > 0 || wrkCount >0){
+                throw new CoolException(entity.getMatnr() + "妯″叿搴撳瓨/缁勬墭/宸ヤ綔妗f暟鎹凡瀛樺湪,涓嶈兘鍒犻櫎");
+            }else {
+                if (!matService.delete(new EntityWrapper<>(entity)) && !inOutService.delete(new EntityWrapper<>(inOut))) {
+                    throw new CoolException("鍒犻櫎鍟嗗搧妗f/鍟嗗搧淇℃伅澶辫触锛岃鑱旂郴绠$悊鍛�");
+                }
             }
+
         }
         return R.ok();
     }

--
Gitblit v1.9.1