From 45b95bf88ab48e4b4db7ff9205e9afa2b83e8737 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期五, 03 四月 2026 19:29:09 +0800
Subject: [PATCH] no message

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  146 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 105 insertions(+), 41 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 a900c9f..78c07c3 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -1510,6 +1510,9 @@
         }
 
         BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite()));
+        if (Objects.isNull(basAreas)) {
+            return R.error("绔欑偣涓嶅瓨鍦紝璇锋鏌ョ珯鐐规槸鍚﹁緭鍏ユ纭紒锛�");
+        }
 
         List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
                 .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
@@ -1531,12 +1534,6 @@
 
     @Transactional(rollbackFor = Exception.class)
     public void generateSOEOInTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
-        List<BasStationDetl> basStationDetls = basStationDetlService
-                .selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", orgSite));
-        if (Objects.isNull(basStationDetls) || basStationDetls.isEmpty()) {
-            throw new CoolException("绔欑偣淇℃伅涓嶅瓨鍦紒锛�");
-        }
-
         List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode));
         if (!tasks.isEmpty()) {
             throw new CoolException("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
@@ -1567,7 +1564,9 @@
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
 
-        for (BasStationDetl basStationDetl : basStationDetls) {
+        List<BasStationDetl> basStationDetls = basStationDetlService
+                .selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", orgSite));
+        basStationDetls.forEach(basStationDetl -> {
             TaskDetl wrkDetl = new TaskDetl();
             BeanUtils.copyProperties(basStationDetl, wrkDetl);
             wrkDetl.setWrkNo(workNo)
@@ -1589,7 +1588,7 @@
             if (!taskDetlService.insert(wrkDetl)) {
                 throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
             }
-        }
+        });
 
         // 淇敼鐩爣搴撲綅鐘舵��
         if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
@@ -1603,22 +1602,18 @@
             throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
         }
 
-        // 淇敼鐩爣绔欑偣淇℃伅
+        // 淇敼鍘熺珯鐐逛俊鎭�
         BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
         if (Objects.isNull(station)) {
             throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
         }
 
-        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)) {
-            station.setLocSts("R"); // S.鍏ュ簱棰勭害
-            station.setBarcode(barcode);
-            station.setModiTime(new Date());
-            station.setModiUser(userId);
-            if (!basStationService.updateById(station)) {
-                throw new CoolException("鏇存柊鐩爣绔欑偣鐘舵�佸け璐�");
-            }
-        } else {
-            throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+        station.setLocSts("R"); // S.鍏ュ簱棰勭害
+        station.setBarcode(barcode);
+        station.setModiTime(new Date());
+        station.setModiUser(userId);
+        if (!basStationService.updateById(station)) {
+            throw new CoolException("鏇存柊鐩爣绔欑偣鐘舵�佸け璐�");
         }
     }
 
@@ -1740,7 +1735,7 @@
                 double val = Math.round((combMat.getAnfme() + wrkDetl.getAnfme()) * 10000) / 10000.0;
                 WrkDetl detl = new WrkDetl();
                 detl.setOrderNo(stationDetl.getOrderNo());
-                detl.setBoxType1(wrkDetl.getBoxType1());
+                detl.setBoxType1(param.getBoxType1());
                 detl.setZpallet(param.getBarcode());
                 detl.setBarcode(param.getBarcode());
                 detl.setThreeCode(combMat.getThreeCode());
@@ -2250,7 +2245,16 @@
         AtomicReference<Double> totalOut = new AtomicReference<>(0.0);
         listMap.forEach((matnr, detls) -> {
             Map<String, List<LocDetl>> supIds = detls.stream().collect(Collectors.groupingBy(LocDetl::getStandby1));
-            supIds.forEach((supId, sups) -> {
+            for (String supId : supIds.keySet()) {
+                List<LocDetl> sups = supIds.get(supId);
+//            }
+//            supIds.forEach((supId, sups) -> {
+                Mat mats = matService.selectOne(new EntityWrapper<Mat>()
+                        .eq("supp_code", supId)
+                        .eq("matnr", matnr));
+                if (Objects.isNull(mats)) {
+                    throw new CoolException("鐗╂枡涓嶅瓨鍦紒锛�");
+                }
                 // 鏍规嵁supId(渚涘簲鍟�)鍒嗙被锛屽緱鍒伴渶瑕佸瓨鏀剧殑鎬荤┖搴撳瓨鏁伴噺
                 Double sum = sups.stream().mapToDouble(LocDetl::getAnfme).sum();
                 AtomicReference<Double> itemed = new AtomicReference<>(0.0);
@@ -2278,12 +2282,6 @@
                         if (container.getMixMax() > sets.size()) {
                             //浣欎笅鍙贩鏀剧绫�
                             long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000;
-                            Mat mats = matService.selectOne(new EntityWrapper<Mat>()
-                                    .eq("supp_code", supId)
-                                    .eq("matnr", matnr));
-                            if (Objects.isNull(mats)) {
-                                throw new CoolException("鐗╂枡涓嶅瓨鍦紒锛�");
-                            }
                             //浣欎笅鏈�澶у彲鏀炬暟閲�
                             Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0;
                             // 鍏ュ簱鏁伴噺灏忎簬闆朵笖鍏ュ簱鏁伴噺鍑忓幓宸茶鍒掑嚭鏁伴噺澶т簬闆讹紙锛�
@@ -2296,8 +2294,46 @@
                             }
                         }
                     });
+                } else {
+                    // 鑾峰彇褰撳墠渚涘簲鍟�+ 鐗╂枡鍦ㄥ簱
+                    LocMast notFullList = locMastService.selectNotFull(mats.getLocType(), one.getId());
+                    if (Objects.isNull(notFullList)) {
+                        continue;
+                    }
+                    BasContainer container = basContainerService
+                            .selectOne(new EntityWrapper<BasContainer>().eq("barcode", notFullList.getBarcode()));
+                    if (Objects.isNull(container)) {
+                        throw new CoolException("鏁版嵁閿欒锛屽鍣ㄤ笉瀛樺湪锛侊紒");
+                    }
+                    List<LocDetl> adetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", notFullList.getLocNo()));
+                    Set<String> sets = adetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
+                    List<LocDetl> locDtls = new ArrayList<>();
+                    // 鍒ゆ柇瀹瑰櫒鏄惁杩樺彲娣锋斁,鍙婂綋鍓嶇墿鏂欏彲鏀惧灏�
+                    if (container.getMixMax() > sets.size()) {
+                        //浣欎笅鍙贩鏀剧绫�
+                        long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000;
+                        //浣欎笅鏈�澶у彲鏀炬暟閲�
+                        Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0;
+                        // 鍏ュ簱鏁伴噺灏忎簬闆朵笖鍏ュ簱鏁伴噺鍑忓幓宸茶鍒掑嚭鏁伴噺澶т簬闆讹紙锛�
+                        if (sum.compareTo(v) <= 0 && sum.compareTo(itemed.get()) > 0) {
+                            itemed.set(Math.round((itemed.get() + v) * 10000) / 10000.0);
+                            // 鍙斁涓�
+                            LocDetl locDetl = new LocDetl();
+                            BeanUtils.copyProperties(mats, locDetl);
+                            locDetl.setLocNo(notFullList.getLocNo());
+                            locDetl.setAnfme(0.0);
+                            locDetl.setMatnr(mats.getMatnr());
+                            locDetl.setZpallet(notFullList.getBarcode());
+                            locDetl.setSuppCode(mats.getSuppCode());
+                            locDetl.setMaktx(mats.getMaktx());
+                            locDtls.add(locDetl);
+                            CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(notFullList.getLocNo()).setLocDetlList(locDtls);
+                            locMasts.add(crnTaskDetlDTO);
+                            totalOut.set(Math.round((totalOut.get() + itemed.get()) * 10000) / 10000.0);
+                        }
+                    }
                 }
-            });
+            }
         });
 
         /**鏄惁浼樺厛绌烘澘鍑哄簱*/
@@ -2314,7 +2350,6 @@
             }
             CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(new ArrayList<>());
             locMasts.add(crnTaskDetlDTO);
-
             // 绌烘澘鍑哄簱
             generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station);
         } else {
@@ -2626,14 +2661,14 @@
             if (Objects.isNull(station)) {
                 throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
             }
-
-            station.setLocSts("O"); // S.鍏ュ簱棰勭害
+            station.setLocSts("O");
             station.setBarcode(barcode);
             station.setModiTime(new Date());
             station.setModiUser(userId);
             if (!basStationService.updateById(station)) {
                 throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
             }
+            basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo()));
         }
     }
 
@@ -2718,13 +2753,12 @@
         if (Objects.isNull(station)) {
             throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
         }
-
         try {
             //绌哄彴杞﹀洖搴�
             generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId, "M2");
         } catch (Exception e) {
-            e.printStackTrace();
-            return R.error(e.getMessage());
+            log.error(e.getMessage());
+            throw new CoolException(e.getMessage());
         }
 
         return R.ok(locCache);
@@ -3017,15 +3051,18 @@
             if (Objects.isNull(combMat)) {
                 continue;
             }
-            OrderPakin order = orderPakinService.selectOne(new EntityWrapper<OrderPakin>().eq("order_no", combMat.getOrderNo()));
+            OrderPakin order = orderPakinService.selectOne(new EntityWrapper<OrderPakin>()
+                    .lt("settle", 4)
+                    .eq("order_no", combMat.getOrderNo()));
             if (Objects.isNull(order)) {
-                return R.error("涓烘煡璇㈠埌璁㈠崟锛岃纭鏄惁涓哄簱鍙g粍鎵樹俊鎭紒锛�");
+                return R.error("鏈煡璇㈠埌璁㈠崟锛岃纭鏄惁涓哄簱鍙g粍鎵樹俊鎭紒锛�");
             }
             //鍏ュ簱
             OrderDetlPakin detlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
                     .eq("order_no", combMat.getOrderNo())
                     .eq("matnr", combMat.getMatnr())
-                    .eq("supp_code", combMat.getStandby1()));
+                    .eq("supp_code", combMat.getStandby1())
+                    .last("AND anfme != qty"));
 
             if (!Objects.isNull(detlPakin)) {
                 Double v = Math.round((detlPakin.getWorkQty() - combMat.getAnfme()) * 10000) / 10000.0;
@@ -3037,10 +3074,37 @@
                     throw new CoolException("璁㈠崟鏄庣粏鏇存柊澶辫触锛侊紒");
                 }
 
-                if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("order_no", combMat.getOrderNo())
+                BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>()
+                        .eq("order_no", combMat.getOrderNo())
                         .eq("matnr", combMat.getMatnr())
-                        .eq("supp_code", combMat.getStandby1()))) {
-                    throw new CoolException("绔欑偣鏁版嵁鍒犻櫎澶辫触锛侊紒");
+                        .eq("supp_code", combMat.getStandby1()));
+                if (!Objects.isNull(stationDetl)) {
+                    if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>()
+                            .eq("order_no", combMat.getOrderNo())
+                            .eq("matnr", combMat.getMatnr())
+                            .eq("supp_code", combMat.getStandby1()))) {
+                        throw new CoolException("瑙g粦澶辫触锛岀珯鐐瑰簱瀛樺垹闄ゅけ璐ワ紒");
+                    }
+                }
+
+                BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
+                if (Objects.isNull(basAreas)) {
+                    throw new CoolException("绔欑偣鏌ヨ澶辫触锛岃鑱旂郴绠$悊鍛橈紒锛�");
+                }
+
+                LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>()
+                        .eq("area_id", basAreas.getId())
+                        .eq("order_no", combMat.getOrderNo())
+                        .eq("matnr", combMat.getMatnr())
+                        .eq("supp_code", combMat.getStandby1()));
+                if (!Objects.isNull(locDetl)) {
+                    if (!locDetlService.delete(new EntityWrapper<LocDetl>()
+                            .eq("area_id", basAreas.getId())
+                            .eq("order_no", combMat.getOrderNo())
+                            .eq("matnr", combMat.getMatnr())
+                            .eq("supp_code", combMat.getStandby1()))) {
+                        throw new CoolException("瑙g粦澶辫触锛岀紦鍐插簱鍖哄簱瀛樺垹闄ゅけ璐ワ紒");
+                    }
                 }
 
                 WaitPakin waitPakin = waitPakinService.selectOne(new EntityWrapper<WaitPakin>()
@@ -3055,7 +3119,7 @@
                     }
                 }
             } else {
-                throw new CoolException("璁㈠崟鏄庣粏缁戝畾鍏崇郴涓嶅瓨鍦紒锛�");
+                throw new CoolException("璁㈠崟鏄庣粏缁戝畾鍏崇郴涓嶅瓨鍦ㄦ垨宸插畬鎴愬叆搴擄紒锛�");
             }
         }
         return R.ok();

--
Gitblit v1.9.1