From 8257d89c461f6553d66fad1e5e3df3d172a00924 Mon Sep 17 00:00:00 2001
From: 1 <1>
Date: 星期六, 29 十一月 2025 18:10:18 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  146 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 146 insertions(+), 0 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 49ca615..5194d86 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -679,7 +679,153 @@
 //            orderService.updateSettle(order.getId(), 2L, userId);
             OrderInAndOutUtil.updateOrder(Boolean.TRUE,order.getId(), 2L, userId);
         }
+    }
 
+    @Override
+    @Transactional
+    public void combAgv(CombParam param, Long userId) {
+        if (Cools.isEmpty(param.getBarcode(), param.getCombMats(),param.getLocNo())) {
+            throw new CoolException(BaseRes.PARAM);
+        }
+//        if(param.getCombMats().size()>1){
+//            throw new CoolException("璇锋彁鍙栦竴涓晢鍝侊紝鎴栬�呭埛鏂伴噸鏂扮粍鎵橈紒");
+//        }
+        // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
+        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
+                eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) {
+            throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
+        }
+
+        if(param.getBarcode().length()!=6){
+            throw new CoolException("鏉$爜闀垮害涓嶆槸6浣�===>>" + param.getBarcode());
+        }
+//        if (param.getCombMats().size()>1){
+//            throw new CoolException("涓嶅厑璁告贩鏂�===>>" + param.getBarcode());
+//        }
+
+        int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode()));
+        int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode()));
+        int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode()));
+        LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",param.getLocNo()));
+        if (countLoc > 0 || countWrk > 0 || countwait > 0) {
+            throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
+        }
+        if(locMast == null){
+            throw new CoolException("涓嶅瓨鍦ㄨ搴撲綅" + param.getLocNo());
+        }
+
+        Date now = new Date();
+
+        // 鏃犲崟缁勬墭
+        if (Cools.isEmpty(param.getOrderNo())) {
+
+            // 鐢熸垚鍏ュ簱閫氱煡妗�
+            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());
+                if (DetlDto.has(detlDtos, detlDto)) {
+                    DetlDto one = DetlDto.findDto(detlDtos, detlDto);
+                    assert one != null;
+                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
+                } else {
+                    detlDtos.add(detlDto);
+                }
+            });
+
+
+            for (DetlDto detlDto : detlDtos) {
+                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
+                if (Cools.isEmpty(mat)) {
+                    throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
+                }
+                WaitPakin waitPakin = new WaitPakin();
+                waitPakin.sync(mat);
+                waitPakin.setBatch(detlDto.getBatch());
+                waitPakin.setZpallet(param.getBarcode());   // 鎵樼洏鐮�
+                waitPakin.setIoStatus("N");     // 鍏ュ嚭鐘舵��
+                waitPakin.setAnfme(detlDto.getAnfme());  // 鏁伴噺
+                waitPakin.setStatus("Y");    // 鐘舵��
+                waitPakin.setAppeUser(userId);
+                waitPakin.setAppeTime(now);
+                waitPakin.setModiUser(userId);
+                waitPakin.setModiTime(now);
+                waitPakin.setStandby1(detlDto.getStandby1());
+                waitPakin.setStandby2(detlDto.getStandby2());
+                waitPakin.setStandby3(detlDto.getStandby3());
+                waitPakin.setBoxType1(detlDto.getBoxType1());
+                waitPakin.setBoxType2(detlDto.getBoxType2());
+                waitPakin.setBoxType3(detlDto.getBoxType3());
+                if (!waitPakinService.insert(waitPakin)) {
+                    throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
+                }
+            }
+            // 鍏宠仈缁勬墭
+        } else {
+//            Order order = orderService.selectByNo(param.getOrderNo());
+            Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, param.getOrderNo());
+            if (Cools.isEmpty(order) || order.getSettle() > 2) {
+                throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
+            }
+            // 鐢熸垚鍏ュ簱閫氱煡妗�
+            List<DetlDto> detlDtos = new ArrayList<>();
+            param.getCombMats().forEach(elem -> {
+
+                // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
+//                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch());
+                OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(),
+                        elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3());
+                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());
+                if (DetlDto.has(detlDtos, detlDto)) {
+                    DetlDto one = DetlDto.findDto(detlDtos, detlDto);
+                    assert one != null;
+                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
+                } else {
+                    detlDtos.add(detlDto);
+                }
+            });
+            for (DetlDto detlDto : detlDtos) {
+                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
+                if (Cools.isEmpty(mat)) {
+                    throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
+                }
+                WaitPakin waitPakin = new WaitPakin();
+                waitPakin.sync(mat);
+                waitPakin.setOrderNo(order.getOrderNo());   // 鍗曟嵁缂栧彿
+                waitPakin.setBatch(detlDto.getBatch());     // 搴忓垪鐮�
+                waitPakin.setZpallet(param.getBarcode());   // 鎵樼洏鐮�
+                waitPakin.setIoStatus("N");     // 鍏ュ嚭鐘舵��
+                waitPakin.setAnfme(detlDto.getAnfme());  // 鏁伴噺
+                waitPakin.setStatus("Y");    // 鐘舵��
+                waitPakin.setAppeUser(userId);
+                waitPakin.setAppeTime(now);
+                waitPakin.setModiUser(userId);
+                waitPakin.setModiTime(now);
+                waitPakin.setStandby1(detlDto.getStandby1());
+                waitPakin.setStandby2(detlDto.getStandby2());
+                waitPakin.setStandby3(detlDto.getStandby3());
+                waitPakin.setBoxType1(detlDto.getBoxType1());
+                waitPakin.setBoxType2(detlDto.getBoxType2());
+                waitPakin.setBoxType3(detlDto.getBoxType3());
+                if (!waitPakinService.insert(waitPakin)) {
+                    throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
+                }
+                locMast.setLocSts("R");
+                locMastService.updateById(locMast);
+            }
+//            orderService.updateSettle(order.getId(), 2L, userId);
+            OrderInAndOutUtil.updateOrder(Boolean.TRUE,order.getId(), 2L, userId);
+        }
     }
 
     @Override

--
Gitblit v1.9.1