From 18827ae1fab72c4e2e2814d00544269c0d4c310e Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期五, 28 四月 2023 09:00:38 +0800
Subject: [PATCH] 修复订单系统

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |   65 +++++++++++++++-----------------
 1 files changed, 31 insertions(+), 34 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 fff66e0..d7425fb 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -92,23 +92,24 @@
         }
 
         int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode()));
-        int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode()));
-        if (countLoc > 0 || countWrk > 0) {
+        WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode());
+        if (wrkMast != null && wrkMast.getIoType() < 100){
+            throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
+
+        }
+        if (countLoc > 0 ) {
             throw new CoolException("宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
         }
+
+
         //璁剧疆闈瀗ull鎵瑰彿锛�
         for (CombParam.CombMat combMat : param.getCombMats()) {
             if (combMat.getBatch() == null){
                 combMat.setBatch("");
             }
         }
-        for (CombParam.CombMat combMat : param.getCombMats()) {
-            Integer sum = orderDetlService.sameOrderComb(param.getOrderNo(), combMat.getMatnr(),combMat.getBatch());
-            OrderDetl orderDetl = orderDetlService.selectItem(param.getOrderNo(), combMat.getMatnr(), combMat.getBatch());
-            if ( combMat.getAnfme() > (orderDetl.getAnfme() - sum)) {
-                throw new CoolException("缁勬墭鏁伴噺宸茶秴鍑鸿鍗曢渶姹傞噺锛岃妫�鏌ユ槸鍚︽湁鍏朵粬鐨勭粍鎵樺凡瀹屾垚");
-            }
-        }
+
+
 
 
         Date now = new Date();
@@ -152,47 +153,35 @@
             }
         // 鍏宠仈缁勬墭
         } else {
+            // 鐢熸垚鍏ュ簱閫氱煡妗�
             Order order = orderService.selectByNo(param.getOrderNo());
             if (order.getSettle() > 2) {
                 throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
             }
-            // 鐢熸垚鍏ュ簱閫氱煡妗�
-            List<DetlDto> detlDtos = new ArrayList<>();
-            for (CombParam.CombMat elem : param.getCombMats()) {
-                // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
-                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch());
-                if(orderDetl == null){
-                    throw new CoolException("璇ュ崟鎹腑涓嶅瓨鍦ㄨ鐗╂枡鏄庣粏锛�" + elem);
+            for (CombParam.CombMat combMat : param.getCombMats()) {
+                OrderDetl orderDetl = orderDetlService.selectItem(param.getOrderNo(), combMat.getMatnr(), combMat.getBatch());
+                if (orderDetl == null) {
+                    throw new CoolException("鎵句笉鍒扮粍鎵樼殑鍗曟嵁鏄庣粏");
                 }
-                if (elem.getAnfme() > orderDetl.getEnableQty()) {
-                    throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+                //璁㈠崟鏁�-宸ヤ綔涓殑鏁伴噺-缁勬墭鏁伴噺
+                if ( orderDetl.getAnfme() - orderDetl.getWorkQty() - combMat.getAnfme()<0) {
+                    throw new CoolException("缁勬墭鏁伴噺宸茶秴鍑鸿鍗曢渶姹傞噺锛岃妫�鏌ユ槸鍚︽湁鍏朵粬鐨勭粍鎵樺凡瀹屾垚");
                 }
                 // 淇敼璁㈠崟浣滀笟鏁伴噺
-                if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) {
+                if (!orderDetlService.increaseWorkQty(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) {
                     throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
                 }
-
-                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
-                if (DetlDto.has(detlDtos, detlDto)) {
-                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
-                    assert one != null;
-                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
-                } else {
-                    detlDtos.add(detlDto);
-                }
-            }
-            for (DetlDto detlDto : detlDtos) {
-                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
+                Mat mat = matService.selectByMatnr(combMat.getMatnr());
                 if (Cools.isEmpty(mat)) {
-                    throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
+                    throw new CoolException(combMat.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
                 }
                 WaitPakin waitPakin = new WaitPakin();
                 waitPakin.sync(mat);
                 waitPakin.setOrderNo(order.getOrderNo());   // 鍗曟嵁缂栧彿
-                waitPakin.setBatch(detlDto.getBatch());     // 搴忓垪鐮�
+                waitPakin.setBatch(combMat.getBatch());     // 搴忓垪鐮�
                 waitPakin.setZpallet(param.getBarcode());   // 鎵樼洏鐮�
                 waitPakin.setIoStatus("N");     // 鍏ュ嚭鐘舵��
-                waitPakin.setAnfme(detlDto.getAnfme());  // 鏁伴噺
+                waitPakin.setAnfme(combMat.getAnfme());  // 鏁伴噺
                 waitPakin.setStatus("Y");    // 鐘舵��
                 waitPakin.setAppeUser(userId);
                 waitPakin.setAppeTime(now);
@@ -201,6 +190,14 @@
                 if (!waitPakinService.insert(waitPakin)) {
                     throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
                 }
+
+//                DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme());
+//                if (DetlDto.has(detlDtos, detlDto)) {
+//                    DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch());
+//                    assert one != null;
+//                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
+//                } else {
+//                }
             }
             orderService.updateSettle(order.getId(), 2L, userId);
         }

--
Gitblit v1.9.1