From 786c173ee8cc72843b6365e7adebe86e06935f7b Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期三, 10 十二月 2025 14:10:44 +0800
Subject: [PATCH] no message

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |   44 ++++++++++++++++++++++++++++++++++----------
 1 files changed, 34 insertions(+), 10 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 e85151a..0aac059 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -599,7 +599,7 @@
         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(!Objects.isNull(param.getType()), "type", param.getType())
+                .eq(!Objects.isNull(param.getType()), "type", param.getType())
                 .eq("zpallet", param.getBarcode()));
         if (countLoc > 0 || countWrk > 0 || countwait > 0) {
             throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
@@ -1465,16 +1465,40 @@
                 detlDtos.add(detlDto);
             }
         });
-
+        BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
+        if (Objects.isNull(container)) {
+            throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
+        }
+        if (container.getMixMax() < detlDtos.size()) {
+            throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
+        }
+        Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet());
+        List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
+        Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet());
+        if (tagIds.size() > 1) {
+            throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
+        }
+        //杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
+        Integer suplus = container.getMixMax();
         Date now = new Date();
         for (DetlDto detlDto : detlDtos) {
             Mat mat = matService.selectByMatnr(detlDto.getMatnr());
             if (Cools.isEmpty(mat)) {
                 throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
             }
-            if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) {
-                throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟鏈�澶х粍鎵樹笂闄愪负锛�" + mat.getUpQty());
+            //鏈�澶氬彲鏀炬暟閲�
+            Double singleMax = mat.getUpQty() * suplus;
+            if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
+                throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
             }
+            BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
+            //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
+            Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
+            suplus = suplus - curr;
+            if (suplus < 0) {
+                throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+            }
+
             WaitPakin waitPakin = new WaitPakin();
             BeanUtils.copyProperties(mat, waitPakin);
             waitPakin.setBatch(detlDto.getBatch());
@@ -1565,7 +1589,7 @@
      * @date 2025/12/9 13:54
      */
     @Transactional(rollbackFor = Exception.class)
-    public void generateCrnInTask(List<WaitPakin> waitPakins, BasStation station, Short locType,  Long userId) {
+    public void generateCrnInTask(List<WaitPakin> waitPakins, BasStation station, Short locType, Long userId) {
         Date now = new Date();
         StationRela rela = stationRelaService.selectOne(new EntityWrapper<StationRela>()
                 .eq("agv_sta", station.getDevNo())
@@ -1582,7 +1606,7 @@
         LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo);
         WaitPakin pakin = waitPakins.stream().findFirst().get();
         FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(pakin);
-        StartupDto dto = commonService.getLocNo( 1, sourceStaNo.getDevNo(),findLocNoAttributeVo, locTypeDto);
+        StartupDto dto = commonService.getLocNo(1, sourceStaNo.getDevNo(), findLocNoAttributeVo, locTypeDto);
         int workNo = dto.getWorkNo();
         // 鐢熸垚宸ヤ綔妗�
         WrkMast wrkMast = new WrkMast();
@@ -1636,19 +1660,19 @@
         // 鏇存柊婧愮珯鐐逛俊鎭�
         sourceStaNo.setWrkNo(workNo);
         sourceStaNo.setModiTime(now);
-        if (!basDevpService.updateById(sourceStaNo)){
+        if (!basDevpService.updateById(sourceStaNo)) {
             throw new CoolException("鏇存柊婧愮珯澶辫触");
         }
         // 鏇存柊鐩爣搴撲綅鐘舵��
         LocMast locMast = locMastService.selectById(dto.getLocNo());
-        if (locMast.getLocSts().equals("O")){
+        if (locMast.getLocSts().equals("O")) {
             locMast.setLocSts("S"); // S.鍏ュ簱棰勭害
             locMast.setModiTime(now);
-            if (!locMastService.updateById(locMast)){
+            if (!locMastService.updateById(locMast)) {
                 throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�");
             }
         } else {
-            throw new CoolException(dto.getLocNo()+"鐩爣搴撲綅宸茶鍗犵敤");
+            throw new CoolException(dto.getLocNo() + "鐩爣搴撲綅宸茶鍗犵敤");
         }
 
     }

--
Gitblit v1.9.1