From 6827eba9c63451de02dc0b90451d64c31a06068f Mon Sep 17 00:00:00 2001
From: 1 <1>
Date: 星期一, 15 十二月 2025 13:58:45 +0800
Subject: [PATCH] #supplier逻辑组托

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  133 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 103 insertions(+), 30 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 f281805..1f6366c 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -11,9 +11,11 @@
 import com.zy.asrs.mapper.LocMastMapper;
 import com.zy.asrs.mapper.ManLocDetlMapper;
 import com.zy.asrs.service.*;
+import com.zy.asrs.task.core.ReturnT;
 import com.zy.asrs.utils.MatUtils;
 import com.zy.asrs.utils.OrderInAndOutUtil;
 import com.zy.asrs.utils.Utils;
+import com.zy.common.constant.AgvConstant;
 import com.zy.common.constant.MesConstant;
 import com.zy.common.entity.Parameter;
 import com.zy.common.model.DetlDto;
@@ -22,6 +24,7 @@
 import com.zy.common.model.enums.WorkNoType;
 import com.zy.common.service.CommonService;
 import com.zy.common.utils.HttpHandler;
+import com.zy.erp.kingdee.utils.PostMesDataUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -587,6 +590,10 @@
             param.getCombMats().forEach(elem -> {
                 DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(),
                         elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(),  elem.getAnfme());
+                detlDto.setMemo(elem.getMemo());
+                detlDto.setSupp(elem.getSupp());
+                detlDto.setManu(elem.getManu());
+                detlDto.setSuppCode(elem.getSuppCode());
                 if (DetlDto.has(detlDtos, detlDto)) {
                     DetlDto one = DetlDto.findDto(detlDtos, detlDto);
                     assert one != null;
@@ -613,6 +620,10 @@
                 waitPakin.setAppeTime(now);
                 waitPakin.setModiUser(userId);
                 waitPakin.setModiTime(now);
+                waitPakin.setMemo(detlDto.getMemo());
+                waitPakin.setSupp(detlDto.getSupp());
+                waitPakin.setSuppCode(detlDto.getSuppCode());
+                waitPakin.setManu(detlDto.getManu());
                 waitPakin.setStandby1(detlDto.getStandby1());
                 waitPakin.setStandby2(detlDto.getStandby2());
                 waitPakin.setStandby3(detlDto.getStandby3());
@@ -645,6 +656,10 @@
                         elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme());
                 DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(),
                         elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(),  elem.getAnfme());
+                detlDto.setMemo(elem.getMemo());
+                detlDto.setSupp(elem.getSupp());
+                detlDto.setManu(elem.getManu());
+                detlDto.setSuppCode(elem.getSuppCode());
                 if (DetlDto.has(detlDtos, detlDto)) {
                     DetlDto one = DetlDto.findDto(detlDtos, detlDto);
                     assert one != null;
@@ -670,17 +685,21 @@
                 waitPakin.setAppeTime(now);
                 waitPakin.setModiUser(userId);
                 waitPakin.setModiTime(now);
+                waitPakin.setMemo(detlDto.getMemo());
+                waitPakin.setSupp(detlDto.getSupp());
+                waitPakin.setSuppCode(detlDto.getSuppCode());
+                waitPakin.setManu(detlDto.getManu());
                 waitPakin.setStandby1(detlDto.getStandby1());
                 waitPakin.setStandby2(detlDto.getStandby2());
                 waitPakin.setStandby3(detlDto.getStandby3());
                 waitPakin.setBoxType1(detlDto.getBoxType1());
                 waitPakin.setBoxType2(detlDto.getBoxType2());
                 waitPakin.setBoxType3(detlDto.getBoxType3());
-                waitPakin.setMemo(detlDto.getMemo());
                 if (!waitPakinService.insert(waitPakin)) {
                     throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
                 }
             }
+
 //            orderService.updateSettle(order.getId(), 2L, userId);
             OrderInAndOutUtil.updateOrder(Boolean.TRUE,order.getId(), 2L, userId);
         }
@@ -689,7 +708,7 @@
     @Override
     @Transactional
     public void combAgv(CombParam param, Long userId) {
-        if (Cools.isEmpty(param.getBarcode(), param.getCombMats(),param.getLocNo())) {
+        if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
             throw new CoolException(BaseRes.PARAM);
         }
 //        if(param.getCombMats().size()>1){
@@ -715,20 +734,30 @@
         if (countLoc > 0 || countWrk > 0 || countwait > 0) {
             throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
         }
-        if(locMast == null){
-            throw new CoolException("涓嶅瓨鍦ㄨ搴撲綅" + param.getLocNo());
-        }
+
 
         Date now = new Date();
-
+        boolean allEmpty = true;
+        if (param.getCombMats() != null) {
+            for (CombParam.CombMat mat : param.getCombMats()) {
+                if (!Cools.isEmpty(mat.getOrderNo())) {
+                    allEmpty = false;
+                    break;
+                }
+            }
+        }
         // 鏃犲崟缁勬墭
-        if (Cools.isEmpty(param.getOrderNo())) {
+        if (allEmpty) {
 
             // 鐢熸垚鍏ュ簱閫氱煡妗�
             List<DetlDto> detlDtos = new ArrayList<>();
             param.getCombMats().forEach(elem -> {
                 DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(),
                         elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(),  elem.getAnfme());
+                detlDto.setMemo(elem.getMemo());
+                detlDto.setSupp(elem.getSupp());
+                detlDto.setManu(elem.getManu());
+                detlDto.setSuppCode(elem.getSuppCode());
                 if (DetlDto.has(detlDtos, detlDto)) {
                     DetlDto one = DetlDto.findDto(detlDtos, detlDto);
                     assert one != null;
@@ -755,6 +784,10 @@
                 waitPakin.setAppeTime(now);
                 waitPakin.setModiUser(userId);
                 waitPakin.setModiTime(now);
+                waitPakin.setMemo(detlDto.getMemo());
+                waitPakin.setSupp(detlDto.getSupp());
+                waitPakin.setSuppCode(detlDto.getSuppCode());
+                waitPakin.setManu(detlDto.getManu());
                 waitPakin.setStandby1(detlDto.getStandby1());
                 waitPakin.setStandby2(detlDto.getStandby2());
                 waitPakin.setStandby3(detlDto.getStandby3());
@@ -768,7 +801,7 @@
             // 鍏宠仈缁勬墭
         } else {
 //            Order order = orderService.selectByNo(param.getOrderNo());
-            Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getOrderNo());
+            Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getCombMats().get(0).getOrderNo());
             if (Cools.isEmpty(order) || order.getSettle() > 2) {
                 throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
             }
@@ -783,14 +816,14 @@
                 if (elem.getAnfme() > orderDetl.getEnableQty()) {
                     throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
                 }
-                // 淇敼璁㈠崟浣滀笟鏁伴噺
-//                if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) {
-//                    throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
-//                }
                 OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE,order.getId(), elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(),
                         elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme());
                 DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(),
                         elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(),  elem.getAnfme());
+                detlDto.setMemo(elem.getMemo());
+                detlDto.setSupp(elem.getSupp());
+                detlDto.setManu(elem.getManu());
+                detlDto.setSuppCode(elem.getSuppCode());
                 if (DetlDto.has(detlDtos, detlDto)) {
                     DetlDto one = DetlDto.findDto(detlDtos, detlDto);
                     assert one != null;
@@ -816,6 +849,10 @@
                 waitPakin.setAppeTime(now);
                 waitPakin.setModiUser(userId);
                 waitPakin.setModiTime(now);
+                waitPakin.setMemo(detlDto.getMemo());
+                waitPakin.setSupp(detlDto.getSupp());
+                waitPakin.setSuppCode(detlDto.getSuppCode());
+                waitPakin.setManu(detlDto.getManu());
                 waitPakin.setStandby1(detlDto.getStandby1());
                 waitPakin.setStandby2(detlDto.getStandby2());
                 waitPakin.setStandby3(detlDto.getStandby3());
@@ -825,10 +862,26 @@
                 if (!waitPakinService.insert(waitPakin)) {
                     throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
                 }
-                locMast.setLocSts("R");
-                locMastService.updateById(locMast);
             }
-//            orderService.updateSettle(order.getId(), 2L, userId);
+
+            BasAgvLocNoService basAgvLocNoService = SpringUtils.getBean(BasAgvLocNoService.class);
+            BasAgvLocNo basAgvLocNoSou = basAgvLocNoService.selectOne(new EntityWrapper<BasAgvLocNo>().eq("loc_no", param.getLocNo()));
+            AgvBindCtnrAndBinParam agvBindCtnrAndBinParam = new AgvBindCtnrAndBinParam();
+            agvBindCtnrAndBinParam.setCtnrCode(param.getBarcode());
+            agvBindCtnrAndBinParam.setCtnrTyp("1");
+            agvBindCtnrAndBinParam.setStgBinCode(basAgvLocNoSou.getAgvLocNo());
+            agvBindCtnrAndBinParam.setReqCode(String.valueOf(System.currentTimeMillis()));
+            agvBindCtnrAndBinParam.setIndBind("1");
+            ReturnT<String> resultBind = new PostMesDataUtils().postMesDataArmGrating("AGV瀹瑰櫒瑙g粦",
+                    AgvConstant.AGV_URL+"/"+AgvConstant.AGV_1LBind,AgvConstant.getAGVADAPTOR(1), agvBindCtnrAndBinParam);
+            if(resultBind.getCode() != 200){
+                throw new CoolException("agv鍏ュ簱缁戝畾澶辫触");
+            }
+            locMast.setBarcode(param.getBarcode());
+            locMast.setLocSts("R");
+            if(!locMastService.updateById(locMast)){
+                throw new CoolException("鏂板agv鍏ュ簱浠诲姟澶辫触");
+            }
             OrderInAndOutUtil.updateOrder(Boolean.TRUE,order.getId(), 2L, userId);
         }
     }
@@ -866,21 +919,41 @@
 
         String orderNo = null;
         for (CombParam.CombMat combMat : param.getCombMats()) {
-            List<OrderDetlPakin> orderDetlPakins = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>()
-                    .eq("matnr", combMat.getMatnr()).eq("box_type3", combMat.getOrderNo())
-                    .eq("standby1", combMat.getStandby1()).eq("standby2", combMat.getStandby2())
-                    .eq("standby3", combMat.getStandby3()));
-            if (orderDetlPakins.size() > 0) {
-                orderNo = orderDetlPakins.get(0).getOrderNo();
-                combMat.setBoxType1(orderDetlPakins.get(0).getBoxType1());
-                combMat.setBoxType2(orderDetlPakins.get(0).getBoxType2());
-                combMat.setBoxType3(orderDetlPakins.get(0).getBoxType3());
-                combMat.setMemo(orderDetlPakins.get(0).getMemo());
-                combMat.setSupp(orderDetlPakins.get(0).getSupp());
-                combMat.setSuppCode(orderDetlPakins.get(0).getSuppCode());
-                combMat.setManu(orderDetlPakins.get(0).getManu());//浠撳簱缂栫爜
-            } else {
-                throw new CoolException("鏈煡璇㈠埌鐩稿叧璁㈠崟===>>" + param.getBarcode());
+            if(combMat.getSupplier().equals("1")){
+                List<OrderDetlPakin> orderDetlPakins = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>()
+                        .eq("matnr", combMat.getMatnr()).eq("box_type3", combMat.getOrderNo())
+                        .eq("standby1", combMat.getStandby1()).eq("standby2", combMat.getStandby2())
+                        .eq("standby3", combMat.getStandby3()).eq("box_type2","BU-00001"));//1鏃舵绱㈠拰寰�
+                if (orderDetlPakins.size() > 0) {
+                    orderNo = orderDetlPakins.get(0).getOrderNo();
+                    combMat.setBoxType1(orderDetlPakins.get(0).getBoxType1());
+                    combMat.setBoxType2(orderDetlPakins.get(0).getBoxType2());
+                    combMat.setBoxType3(orderDetlPakins.get(0).getBoxType3());
+                    combMat.setMemo(orderDetlPakins.get(0).getMemo());
+                    combMat.setSupp(orderDetlPakins.get(0).getSupp());
+                    combMat.setSuppCode(orderDetlPakins.get(0).getSuppCode());
+                    combMat.setManu(orderDetlPakins.get(0).getManu());//浠撳簱缂栫爜
+                } else {
+                    throw new CoolException("鏈煡璇㈠埌鐩稿叧璁㈠崟===>>" + param.getBarcode());
+                }
+            }else{
+                //0
+                List<OrderDetlPakin> orderDetlPakins = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>()
+                        .eq("matnr", combMat.getMatnr()).eq("box_type3", combMat.getOrderNo())
+                        .eq("standby1", combMat.getStandby1()).eq("standby2", combMat.getStandby2())
+                        .eq("standby3", combMat.getStandby3()).eq("box_type2","shyucheng.test"));
+                if (orderDetlPakins.size() > 0) {
+                    orderNo = orderDetlPakins.get(0).getOrderNo();
+                    combMat.setBoxType1(orderDetlPakins.get(0).getBoxType1());
+                    combMat.setBoxType2(orderDetlPakins.get(0).getBoxType2());
+                    combMat.setBoxType3(orderDetlPakins.get(0).getBoxType3());
+                    combMat.setMemo(orderDetlPakins.get(0).getMemo());
+                    combMat.setSupp(orderDetlPakins.get(0).getSupp());
+                    combMat.setSuppCode(orderDetlPakins.get(0).getSuppCode());
+                    combMat.setManu(orderDetlPakins.get(0).getManu());//浠撳簱缂栫爜
+                } else {
+                    throw new CoolException("鏈煡璇㈠埌鐩稿叧璁㈠崟===>>" + param.getBarcode());
+                }
             }
         }
 

--
Gitblit v1.9.1