From 87d66c61fc5047fb5708d609f4a5f1f868cd646c Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期四, 10 七月 2025 18:04:30 +0800
Subject: [PATCH] no message

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java |   81 +++++++++++++++++++++++++---------------
 1 files changed, 51 insertions(+), 30 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java
index 7c134b5..1adf5de 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/MobileServiceImpl.java
@@ -76,24 +76,23 @@
     @Autowired
     private OrderDetlMapper orderDetlMapper;
     @Autowired
-    private WaveSeedMapper waveSeedMapper;
+    private WaveSeedService waveSeedMapper;
     @Autowired
     private WaveSeedLogService waveSeedLogService;
     @Autowired
     private OrderDetlLogService orderDetlLogService;
-
     @Autowired
     private PlatformDetlService platformDetlService;
     @Autowired
     private PlatformDetlLogService platformDetlLogService;
 
 
-
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean batchMergeOrders(BatchMergeOrdersParam ordersParam) {
-
-        Loc locServiceOne = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, ordersParam.getMergeNo()), false);
+        Loc locServiceOne = locService.getOne(new LambdaQueryWrapper<Loc>()
+                .eq(Loc::getLocStsId, 1)
+                .eq(Loc::getBarcode, ordersParam.getMergeNo()), false);
         if (!Objects.isNull(locServiceOne)) {
             throw new CoolException("鎵樼洏宸插叆搴擄紝涓嶈兘鍐嶇粍鎵橈紒锛�");
         }
@@ -176,7 +175,6 @@
         if (!locService.updateById(loc)) {
             throw new CoolException("搴撲綅鏇存柊澶辫触锛侊紒");
         }
-
         List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, shelvesParams.getBarcode()));
         if (waitPakins.isEmpty()) {
             throw new CoolException("褰撳墠鎷栫洏娌℃湁缁勬嫋妗�!!");
@@ -204,6 +202,16 @@
             }
             //淇敼鐘舵�佷负鍏ュ簱涓�
             pakin.setIoStatus(1);
+
+            OrderDetl detl = orderDetlService.getById(pakin.getDetlId());
+            if (Objects.isNull(detl)) {
+                throw new CoolException("鏁版嵁閿欒锛氬崟鎹槑缁嗕笉瀛樺湪锛侊紒");
+            }
+            Double qty = Math.round((detl.getQty() + pakin.getAnfme()) * 1000) / 1000.0;
+            detl.setQty(qty);
+            if (!orderDetlService.updateById(detl)) {
+                throw new CoolException("鍗曟嵁鏄庣粏淇敼澶辫触锛侊紒");
+            }
         });
 
         //鍒犻櫎缁勬嫋妗o紝鍔犲叆鍘嗗彶缁勬嫋妗�
@@ -217,30 +225,41 @@
             }
         });
 
-
         //閫氳繃缁勬嫋璁㈠崟ID鑾峰彇璁㈠崟锛屽苟鍒犻櫎鍘熷崟鎹紝鍔犲叆鍗曟嵁鍘嗗彶妗�
         Set<Long> list = waitPakins.stream().map(WaitPakin::getOrderId).collect(Collectors.toSet());
         List<Order> orders = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getId, list));
-        //璁㈠崟鍏ュ巻鍙叉。
         orders.forEach(order -> {
-//            if (order.getOrderType() != OrderType.PK_IN_ORDER.id) {
-//                throw new CoolException("褰撳墠璁㈠崟绫诲瀷:" + order.getOrderType() + ",涓嶅彲鍋氬钩搴撲笂鏋舵搷浣滐紒锛�");
-//            }
-            //淇敼璁㈠崟鐘舵�佷负宸插畬鎴�
-            order.setOrderSettle(OrderSettleType.COMPLETE.val());
-            OrderLog orderLog = new OrderLog();
-            BeanUtils.copyProperties(order, orderLog);
-            orderLog.setId(null);
-            if (!orderLogService.save(orderLog)) {
-                throw new CoolException("鍘嗗彶鍗曟嵁鏇存柊澶辫触锛侊紒");
+            List<OrderDetl> detls = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, order.getId()));
+            Double sum = detls.stream().mapToDouble(OrderDetl::getQty).sum();
+            Double summed = detls.stream().mapToDouble(OrderDetl::getWorkQty).sum();
+            Double v = Math.round((sum + summed) * 1000) / 1000.0;
+            Double anfme = detls.stream().mapToDouble(OrderDetl::getAnfme).sum();
+            if (v.compareTo(anfme) == 0.0) {
+                order.setOrderSettle(OrderSettleType.COMPLETE.val());
+                if (! orderService.updateById(order)) {
+                    throw new CoolException("鍗曟嵁鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+                }
             }
         });
 
+//        //璁㈠崟鍏ュ巻鍙叉。
+//        orders.forEach(order -> {
+////            if (order.getOrderType() != OrderType.PK_IN_ORDER.id) {
+////                throw new CoolException("褰撳墠璁㈠崟绫诲瀷:" + order.getOrderType() + ",涓嶅彲鍋氬钩搴撲笂鏋舵搷浣滐紒锛�");
+////            }
+//            //淇敼璁㈠崟鐘舵�佷负宸插畬鎴�
+//            order.setOrderSettle(OrderSettleType.COMPLETE.val());
+//            OrderLog orderLog = new OrderLog();
+//            BeanUtils.copyProperties(order, orderLog);
+//            orderLog.setId(null);
+//            if (!orderLogService.save(orderLog)) {
+//                throw new CoolException("鍘嗗彶鍗曟嵁鏇存柊澶辫触锛侊紒");
+//            }
+//        });
 //        //鍒犻櫎璁㈠崟鏁版嵁
 //        if (!orderService.removeBatchByIds(orders)) {
 //            throw new CoolException("璁㈠崟鍒犻櫎澶辫触锛侊紒");
 //        }
-
 //        List<OrderDetl> detls = orderDetlMapper.selectList(new LambdaQueryWrapper<OrderDetl>().in(OrderDetl::getOrderId, list));
 //        List<OrderDetlLog> detlLogs = new ArrayList<>();
 //        detls.forEach(delt ->{
@@ -251,7 +270,6 @@
 //            detlLog.setId(null);
 //            detlLogs.add(detlLog);
 //        });
-
 //        //璁㈠崟鏄庣粏杞巻鍙叉。
 //        if (!orderDetlLogService.saveBatch(detlLogs)) {
 //            throw new CoolException("璁㈠崟鏄庣粏杞巻鍙插け璐ワ紒锛�");
@@ -407,15 +425,14 @@
                     .setOrderId(order.getId())
                     .setSiteStatus(CacheSiteStatusType.R.id)
                     .setBarcode(param.get("barcode").toString());
-            if (cacheSiteMapper.updateById(siteNo) < 1) {
+            if (!cacheSiteService.saveOrUpdate(siteNo)) {
                 throw new CoolException("璁㈠崟鎾浣嶇粦瀹氬け璐ワ紒锛�" );
             }
 
-            int update = waveSeedMapper.update(new LambdaUpdateWrapper<WaveSeed>()
+            if (!waveSeedMapper.update(new LambdaUpdateWrapper<WaveSeed>()
                     .eq(WaveSeed::getOrderNo, order.getOrderNo())
                     .set(WaveSeed::getSiteId, siteNo.getId())
-                    .set(WaveSeed::getSiteNo, siteNo.getSiteNo()));
-            if (update < 1) {
+                    .set(WaveSeed::getSiteNo, siteNo.getSiteNo()))) {
                 throw new CoolException("鎾绔欑偣鏇存柊澶辫触锛侊紒");
             }
         } else {
@@ -497,14 +514,14 @@
                     throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦紒锛�");
                 }
             } else { //閮ㄥ垎鎷h揣
-                byId.setQty(order.getWorkQty() + byId.getQty());
+                byId.setQty(Math.round((order.getWorkQty() + byId.getQty()) * 1000) / 1000.0);
                 byId.setWorkQty(0.0);
                 if (!orderDetlService.updateById(byId)) {
                     throw new CoolException("閮ㄥ垎鎷f枡鏄庣粏鏇存柊澶辫触锛侊紒");
                 }
             }
 
-            List<WaveSeed> waveSeeds = waveSeedMapper.selectList(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderDetlId, order.getId()));
+            List<WaveSeed> waveSeeds = waveSeedMapper.list(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderDetlId, order.getId()));
             //fixme 璁㈠崟鏄庣粏鏈挱绉嶏紝榛樿鍙彂璐�
             if (!waveSeeds.isEmpty()) {
                 ArrayList<WaveSeedLog> waveSeedLogs = new ArrayList<>();
@@ -517,11 +534,15 @@
                 if (!waveSeedLogService.saveBatch(waveSeedLogs)) {
                     throw new CoolException("娉㈡槑鍘嗗彶妗d繚瀛樺け璐ワ紒锛�");
                 }
+
+                List<Long> list = waveSeeds.stream().map(WaveSeed::getId).collect(Collectors.toList());
+                //鍒犻櫎鎾鏄庣粏淇℃伅
+                if (!waveSeedMapper.removeByIds(list)) {
+                    throw new CoolException("鎾鏄庣粏鍒犻櫎鎼虹▼锛侊紒");
+                }
+
             }
-            //鍒犻櫎鎾鏄庣粏淇℃伅
-            if (waveSeedMapper.deleteByIds(waveSeeds) < 1) {
-                throw new CoolException("鎾鏄庣粏鍒犻櫎鎼虹▼锛侊紒");
-            }
+
         });
 
         orderList.forEach(one -> {

--
Gitblit v1.9.1