From 1138d68ff11124f87b8d9e5e0bba1c6d600902ab Mon Sep 17 00:00:00 2001
From: dubin <bindu_bean@163.com>
Date: 星期四, 23 十月 2025 12:40:14 +0800
Subject: [PATCH] 组托调整

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |   65 ++++++++++++++++++++++++++++----
 1 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index 813c865..e842505 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -4,10 +4,7 @@
 import com.core.common.BaseRes;
 import com.core.common.Cools;
 import com.core.exception.CoolException;
-import com.zy.asrs.entity.LocDetl;
-import com.zy.asrs.entity.MatCode;
-import com.zy.asrs.entity.PltBarcode;
-import com.zy.asrs.entity.WrkDetl;
+import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.CombParam;
 import com.zy.asrs.service.*;
 import com.zy.ints.entity.WaitMatin;
@@ -17,7 +14,9 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.text.SimpleDateFormat;
+import java.time.chrono.IsoEra;
 import java.util.Date;
+import java.util.List;
 import java.util.Random;
 
 /**
@@ -37,6 +36,8 @@
     private WrkDetlService wrkDetlService;
     @Autowired
     private PltBarcodeService pltBarcodeService;
+    @Autowired
+    private WrkMastService wrkMastService;
 
     @Override
     @Transactional
@@ -49,7 +50,8 @@
         int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode()));
         int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode()));
         int countPlt = pltBarcodeService.selectCount(new EntityWrapper<PltBarcode>().eq("barcode",param.getBarcode()));
-        if (countPlt > 0 || countLoc > 0 || countWrk > 0) {
+        WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode());
+        if (countPlt > 0 || countLoc > 0 || (countWrk > 0 && wrkMast.getWrkSts() != 15)) {
             throw new CoolException("鏉$爜鏁版嵁宸插瓨鍦�");
         }
 
@@ -77,7 +79,12 @@
                 pltBarcode.setUnit(matCode.getUnit());
                 pltBarcode.setSpecs(matCode.getSpecs());
                 pltBarcode.setSize(matCode.getSize());
-                pltBarcode.setSupplier(combMat.getSupplier());
+                if(Cools.isEmpty(combMat.getSupplier())){
+                    String supp = sdf.format(new Date()) + r;
+                    pltBarcode.setSupplier(supp);
+                }else{
+                    pltBarcode.setSupplier(combMat.getSupplier());
+                }
                 pltBarcode.setMemo(combMat.getMemo());
                 pltBarcode.setColor(matCode.getColor());
                 pltBarcode.setLinkErp(0);
@@ -85,16 +92,38 @@
                 pltBarcode.setModiTime(now);
                 pltBarcode.setAppeUser(userId);
                 pltBarcode.setAppeTime(now);
-
+                if(matCode.getWeight()==null){
+                    matCode.setWeight(0.0);
+                }
+                if(matCode.getStr6()==null){
+                    matCode.setStr6(0.0);
+                    pltBarcode.setAllQty(pltBarcode.getQty());
+                }else {
+                    pltBarcode.setAllQty(matCode.getStr6()*pltBarcode.getQty());
+                }
+                pltBarcode.setWeight(matCode.getWeight());
+                pltBarcode.setAllWeight(matCode.getWeight()*pltBarcode.getQty()+30);
+                pltBarcode.setVendor(combMat.getVendor());
+                pltBarcode.setSource(combMat.getSource());
+                pltBarcode.setQtyBox(matCode.getStr6());
+                pltBarcode.setStr3(matCode.getStr3());
+                pltBarcode.setStr4(matCode.getStr4());
+                pltBarcode.setStr5(matCode.getStr5());
                 if (!pltBarcodeService.insert(pltBarcode)) {
                     throw new CoolException("淇濆瓨鏁版嵁澶辫触");
                 }
             }
         } else {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+            Random rand = new Random();
+            Integer r = rand.nextInt(900)+ 100;
             // 鍏宠仈閫氱煡鍗曠粍鎵�
             for (CombParam.CombMat combMat : param.getCombMats()) {
                 WaitMatin waitMatin = waitMatinService.selectOne(new EntityWrapper<WaitMatin>()
+
                         .eq("bill_no",param.getBillNo()).eq("seq_no",combMat.getSeqNo()));
+
+                MatCode matCode = matCodeService.selectOne(new EntityWrapper<MatCode>().eq("mat_no", combMat.getMatNo()));
 
                 if (waitMatin == null) {
                     throw new CoolException("閫氱煡鍗曚笉瀛樺湪" + combMat.getMatNo() + "鏁版嵁锛�");
@@ -121,7 +150,27 @@
                 pltBarcode.setModiTime(now);
                 pltBarcode.setAppeUser(userId);
                 pltBarcode.setAppeTime(now);
-
+                if(Cools.isEmpty(combMat.getSupplier())){
+                    String supp = sdf.format(new Date()) + r;
+                    pltBarcode.setSupplier(supp);
+                }else{
+                    pltBarcode.setSupplier(combMat.getSupplier());
+                }
+                if(matCode.getWeight()==null){
+                    matCode.setWeight(0.0);
+                }
+                if(matCode.getStr6()==null){
+                    matCode.setStr6(0.0);
+                    pltBarcode.setAllQty(pltBarcode.getQty());
+                }else {
+                    pltBarcode.setAllQty(matCode.getStr6()*pltBarcode.getQty());
+                }
+                pltBarcode.setWeight(matCode.getWeight());
+                pltBarcode.setAllWeight(matCode.getWeight()*pltBarcode.getQty()+30);
+                pltBarcode.setVendor(combMat.getVendor());
+                pltBarcode.setSource(combMat.getSource());
+                pltBarcode.setQtyBox(matCode.getStr6());
+                pltBarcode.setMemo(combMat.getMemo());
                 if (!pltBarcodeService.insert(pltBarcode)) {
                     throw new CoolException("淇濆瓨鏁版嵁澶辫触");
                 }

--
Gitblit v1.9.1