From d2b0cd7ae27bb7ea24549d6930a53cbb27c6e44a Mon Sep 17 00:00:00 2001
From: skyouc <958836976@qq.com>
Date: 星期日, 08 三月 2026 19:55:34 +0800
Subject: [PATCH] no message

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  352 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 210 insertions(+), 142 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 8574017..8b58225 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -31,12 +31,12 @@
 import com.zy.common.utils.HttpHandler;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
-import com.zy.system.service.impl.ConfigServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
@@ -916,9 +916,9 @@
                         // todo 鐩樼偣璁板綍銆佷繚瀛樿皟鏁磋褰�
                         // 淇敼鏄庣粏
                         if (!wrkDetlService.updateAnfme(wrkDetl1.getAnfme(), wrkMast.getWrkNo(), wrkDetl.getMatnr(),
-                                wrkDetl.getBatch())) {
+                                wrkDetl.getSuppCode())) {
                             throw new CoolException(wrkMast.getWrkNo() + "鐩樼偣浠诲姟锛�" + wrkDetl.getMatnr() + "鍟嗗搧锛�"
-                                    + wrkDetl.getBatch() + "鎵瑰彿淇敼鏁伴噺澶辫触");
+                                    + wrkDetl.getSuppCode() + "鎵瑰彿淇敼鏁伴噺澶辫触");
                         }
                     }
                     iterator.remove();
@@ -930,7 +930,7 @@
         // 鍒犻櫎鏄庣粏
         for (WrkDetl wrkDetl : wrkDetls) {
             // todo 鐩樼偣璁板綍銆佷繚瀛樿皟鏁磋褰�
-            if (!wrkDetlService.updateAnfme(-1.0D, wrkMast.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getBatch())) {
+            if (!wrkDetlService.updateAnfme(-1.0D, wrkMast.getWrkNo(), wrkDetl.getMatnr(), wrkDetl.getSuppCode())) {
                 throw new CoolException("鍒犻櫎" + wrkMast.getWrkNo() + "鐩樼偣浠诲姟锛�" + wrkDetl.getMatnr() + "鍟嗗搧锛�"
                         + wrkDetl.getBatch() + "鎵瑰彿浠诲姟鏄庣粏澶辫触");
             }
@@ -1328,8 +1328,12 @@
             throw new CoolException("璇锋鏌ョ洰鏍囧簱浣嶆槸鍚﹂棽缃腑锛侊紒");
         }
 
+        String taskType = "M2";
+        if (!params.getIsNewIn().isEmpty()) {
+            taskType = "M1";
+        }
         try {
-            generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId);
+            generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId, taskType);
         } catch (Exception e) {
             throw new CoolException(e.getMessage());
         }
@@ -1510,7 +1514,7 @@
         Task task = new Task();
         task.setWrkNo(workNo)
                 .setIoTime(new Date())
-                .setWrkSts(1L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+                .setWrkSts(201L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍏ュ簱搴揑D
                 .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
                 .setTaskType("agv")
                 .setIoPri(10D)
@@ -1648,147 +1652,194 @@
         if (Objects.isNull(param.getBarcode())) {
             throw new CoolException("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
         }
-
         if (Objects.isNull(param.getCombMats()) || param.getCombMats().isEmpty()) {
             throw new CoolException("缁勬墭鏄庣粏涓嶈兘涓虹┖锛侊紒");
         }
-        // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
-        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode())
-                .eq("io_status", "N")) > 0) {
-            throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
+        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
+                        .eq("wrk_sts", 14)
+                        .eq("io_type", 104)
+                .eq("barcode", param.getBarcode()));
+        if (Objects.isNull(wrkMast)) {
+            throw new CoolException("浠诲姟妗d俊鎭笉瀛樺湪锛侊紒");
         }
 
-        int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode()));
-        int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode()));
-        if (countWrk > 0 || countLoc > 0) {
-            WrkMast wrkDetl = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", param.getBarcode()));
-            if (!wrkDetl.getIoType().equals(TaskIOType.MERGE_OUT.type)) {
-                throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
-            }
-        }
-        int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
-        if (countwait > 0) {
-            throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
-        }
-
-        // 鐢熸垚鍏ュ簱閫氱煡妗�
-        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(), elem.getThreeCode());
-            if (DetlDto.has(detlDtos, detlDto)) {
-                DetlDto one = DetlDto.findDto(detlDtos, detlDto);
-                assert one != null;
-                one.setAnfme(one.getAnfme() + detlDto.getAnfme());
-            } else {
-                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() + "!!");
-        }
-        List<Mat> tempMats = new ArrayList<>();
-        for (DetlDto detlDto : detlDtos) {
-            Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", detlDto.getMatnr())
-                    .eq("supp_code", detlDto.getStandby1()));
-            tempMats.add(mat);
-        }
-        Set<Long> tagIds = tempMats.stream().map(Mat::getTagId).collect(Collectors.toSet());
-        if (tagIds.size() > 1) {
-            throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
-        }
-        // 杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
-        Double 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涓嶅瓨鍦�");
-            }
-            // 鏈�澶氬彲鏀炬暟閲�
-            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() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
-            }
-
+        for (CombParam.CombMat combMat : param.getCombMats()) {
             BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>()
                     .eq("zpallet", param.getCarBarcode())
-                    .eq("three_code", detlDto.getThreeCode()));
+                    .eq("three_code", combMat.getThreeCode()));
             if (Objects.isNull(stationDetl)) {
                 throw new CoolException("鏄庣粏鍐呭涓嶅瓨鍦紒锛�");
             }
+            WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>()
+                    .eq("matnr", stationDetl.getMatnr())
+                    .eq("wrk_no", wrkMast.getWrkNo())
+                    .eq("suppCode", combMat.getSuppCode()));
 
-            Double v = Math.round((stationDetl.getAnfme() - stationDetl.getWorkQty()) * 10000) / 10000.0;
-            if (detlDto.getAnfme().compareTo(v) > 0) {
-                throw new CoolException("缁勬墭涓婇檺涓猴細" + stationDetl.getAnfme() + ", 宸茬粍鎵橈細" + stationDetl.getWorkQty() + ", 杩樺彲缁勬墭锛�" + v);
-            }
+            if (Objects.isNull(wrkDetl)) {
+                //TODO 鏂版彃鍏�
+                Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", stationDetl.getMatnr())
+                    .eq("supp_code", combMat.getSuppCode()));
+                if (Objects.isNull(mat)) {
+                    throw new CoolException("鐗╂枡鍩虹淇℃伅宸蹭笉瀛樺湪锛侊紒");
+                }
+                WrkDetl detl = new WrkDetl();
+                BeanUtils.copyProperties(stationDetl, detl);
+                detl.setAnfme(combMat.getAnfme());
+                detl.setBarcode(wrkMast.getBarcode());
+                detl.setBoxType1(combMat.getBoxType1());
+                detl.setStandby1(combMat.getSuppCode());
+                detl.setWrkNo(wrkMast.getWrkNo());
 
-            WaitPakin waitPakin = new WaitPakin();
-            BeanUtils.copyProperties(mat, waitPakin);
-            waitPakin.setBatch(detlDto.getBatch());
-            waitPakin.setType(param.getType());
-            waitPakin.setZpallet(param.getBarcode());
-            // 璁剧疆缁勬墭绫诲瀷
-            waitPakin.setType(param.getType());
-            waitPakin.setIoStatus("N");
-            waitPakin.setAnfme(detlDto.getAnfme());
-            waitPakin.setThreeCode(detlDto.getThreeCode());
-            waitPakin.setStatus("Y");
-            waitPakin.setSuppCode(detlDto.getStandby1());
-            waitPakin.setStandby1(detlDto.getStandby1());
-            waitPakin.setStandby2(detlDto.getStandby2());
-            waitPakin.setStandby3(detlDto.getStandby3());
-            waitPakin.setBoxType1(detlDto.getBoxType1());
-            waitPakin.setBoxType2(detlDto.getBoxType2());
-            waitPakin.setBoxType3(detlDto.getBoxType3());
-            waitPakin.setAppeUser(userId);
-            waitPakin.setAppeTime(now);
-            waitPakin.setModiUser(userId);
-            waitPakin.setModiTime(now);
-            if (!waitPakinService.insert(waitPakin)) {
-                throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
-            }
-
-            Double v1 = Math.round((stationDetl.getWorkQty() + detlDto.getAnfme()) * 10000) / 10000.0;
-            stationDetl.setWorkQty(v1);
-
-            if (!basStationDetlService.updateById(stationDetl)) {
-                throw new CoolException("绔欑偣鏄庣粏淇敼澶辫触");
-            }
-
-            if (v1.compareTo(stationDetl.getAnfme()) >= 0) {
-                if (!basStationDetlService.deleteById(stationDetl)) {
-                    throw new CoolException("鍘熷鏁版嵁绉婚櫎澶辫触锛�");
+                if (!wrkDetlService.insert(detl)) {
+                    throw new CoolException("浠诲姟鏄庣粏淇濆瓨澶辫触锛侊紒");
+                }
+            } else {
+                double val = Math.round((combMat.getAnfme() + wrkDetl.getAnfme()) * 10000) / 10000.0;
+                if (!wrkDetlService.updateAnfme(val, wrkMast.getWrkNo(), wrkDetl.getMatnr(),
+                        wrkDetl.getSuppCode())) {
+                    throw new CoolException(wrkMast.getWrkNo() + "鐩樼偣浠诲姟锛�" + wrkDetl.getMatnr() + "鍟嗗搧锛�"
+                            + wrkDetl.getBatch() + "鎵瑰彿淇敼鏁伴噺澶辫触");
                 }
             }
 
-            List<BasStationDetl> stas = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>()
-                    .eq("dev_no", stationDetl.getDevNo()));
-            if (Objects.isNull(stas) || stas.isEmpty()) {
-                BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", stationDetl.getDevNo()));
-                if (Objects.isNull(station)) {
-                    throw new CoolException("鏁版嵁閿欒锛岀珯鐐逛笉瀛樺湪锛侊紒");
-                }
-                station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
-                station.setBarcode("");
-                if (!basStationService.updateById(station)) {
-                    throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
-                }
-            }
         }
+//        // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
+//        if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode())
+//                .eq("io_status", "N")) > 0) {
+//            throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
+//        }
+//
+//        int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode()));
+//        int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode()));
+//        if (countWrk > 0 || countLoc > 0) {
+//            WrkMast wrkDetl = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", param.getBarcode()));
+//            if (!wrkDetl.getIoType().equals(TaskIOType.MERGE_OUT.type)) {
+//                throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
+//            }
+//        }
+//        int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
+//        if (countwait > 0) {
+//            throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
+//        }
+//
+//        // 鐢熸垚鍏ュ簱閫氱煡妗�
+//        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(), elem.getThreeCode());
+//            if (DetlDto.has(detlDtos, detlDto)) {
+//                DetlDto one = DetlDto.findDto(detlDtos, detlDto);
+//                assert one != null;
+//                one.setAnfme(one.getAnfme() + detlDto.getAnfme());
+//            } else {
+//                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() + "!!");
+//        }
+//        List<Mat> tempMats = new ArrayList<>();
+//        for (DetlDto detlDto : detlDtos) {
+//            Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", detlDto.getMatnr())
+//                    .eq("supp_code", detlDto.getStandby1()));
+//            tempMats.add(mat);
+//        }
+//        Set<Long> tagIds = tempMats.stream().map(Mat::getTagId).collect(Collectors.toSet());
+//        if (tagIds.size() > 1) {
+//            throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
+//        }
+//        // 杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
+//        Double 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涓嶅瓨鍦�");
+//            }
+//            // 鏈�澶氬彲鏀炬暟閲�
+//            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() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+//            }
+//
+//            BasStationDetl stationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>()
+//                    .eq("zpallet", param.getCarBarcode())
+//                    .eq("three_code", detlDto.getThreeCode()));
+//            if (Objects.isNull(stationDetl)) {
+//                throw new CoolException("鏄庣粏鍐呭涓嶅瓨鍦紒锛�");
+//            }
+//
+//            Double v = Math.round((stationDetl.getAnfme() - stationDetl.getWorkQty()) * 10000) / 10000.0;
+//            if (detlDto.getAnfme().compareTo(v) > 0) {
+//                throw new CoolException("缁勬墭涓婇檺涓猴細" + stationDetl.getAnfme() + ", 宸茬粍鎵橈細" + stationDetl.getWorkQty() + ", 杩樺彲缁勬墭锛�" + v);
+//            }
+//
+//            WaitPakin waitPakin = new WaitPakin();
+//            BeanUtils.copyProperties(mat, waitPakin);
+//            waitPakin.setBatch(detlDto.getBatch());
+//            waitPakin.setType(param.getType());
+//            waitPakin.setZpallet(param.getBarcode());
+//            // 璁剧疆缁勬墭绫诲瀷
+//            waitPakin.setType(param.getType());
+//            waitPakin.setIoStatus("N");
+//            waitPakin.setAnfme(detlDto.getAnfme());
+//            waitPakin.setThreeCode(detlDto.getThreeCode());
+//            waitPakin.setStatus("Y");
+//            waitPakin.setSuppCode(detlDto.getStandby1());
+//            waitPakin.setStandby1(detlDto.getStandby1());
+//            waitPakin.setStandby2(detlDto.getStandby2());
+//            waitPakin.setStandby3(detlDto.getStandby3());
+//            waitPakin.setBoxType1(detlDto.getBoxType1());
+//            waitPakin.setBoxType2(detlDto.getBoxType2());
+//            waitPakin.setBoxType3(detlDto.getBoxType3());
+//            waitPakin.setAppeUser(userId);
+//            waitPakin.setAppeTime(now);
+//            waitPakin.setModiUser(userId);
+//            waitPakin.setModiTime(now);
+//            if (!waitPakinService.insert(waitPakin)) {
+//                throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
+//            }
+//
+//            Double v1 = Math.round((stationDetl.getWorkQty() + detlDto.getAnfme()) * 10000) / 10000.0;
+//            stationDetl.setWorkQty(v1);
+//
+//            if (!basStationDetlService.updateById(stationDetl)) {
+//                throw new CoolException("绔欑偣鏄庣粏淇敼澶辫触");
+//            }
+//
+//            if (v1.compareTo(stationDetl.getAnfme()) >= 0) {
+//                if (!basStationDetlService.deleteById(stationDetl)) {
+//                    throw new CoolException("鍘熷鏁版嵁绉婚櫎澶辫触锛�");
+//                }
+//            }
+//
+//            List<BasStationDetl> stas = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>()
+//                    .eq("dev_no", stationDetl.getDevNo()));
+//            if (Objects.isNull(stas) || stas.isEmpty()) {
+//                BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", stationDetl.getDevNo()));
+//                if (Objects.isNull(station)) {
+//                    throw new CoolException("鏁版嵁閿欒锛岀珯鐐逛笉瀛樺湪锛侊紒");
+//                }
+//                station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
+//                station.setBarcode("");
+//                if (!basStationService.updateById(station)) {
+//                    throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+//                }
+//            }
+//        }
     }
 
     /**
@@ -1817,12 +1868,14 @@
             throw new CoolException("瀹瑰櫒缂栫爜鏈淮鎶わ紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
         }
 
-        Integer whsType = 1;
+        Integer whsType = 2;
+        Short lcoType = 1;
         //鐢ㄤ簬鍒ゆ柇鏂欑鎵樼洏锛屾枡绠憋紝绗兼
-        if (container.getType().equals(ContainerType.CONTAINER_TYPE_SALVER.type)) {
-            whsType = 3;
-        } else if (container.getType().equals(ContainerType.CONTAINER_TYPE_CAGE.type)) {
+        if (!container.getType().equals(ContainerType.CONTAINER_TYPE_BOX.type)) {
             whsType = 2;
+            if (container.getType().equals(ContainerType.CONTAINER_TYPE_SALVER.type)) {
+                lcoType = 2;
+            }
         }
 
         WrkMast barcode = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", param.getBarcode()));
@@ -1855,7 +1908,7 @@
                     throw new CoolException("鏁版嵁閿欒,缁勬嫋妗e凡涓嶅瓨鍦�!!");
                 }
 
-                WrkMast wrkMast = generateCrnInTask(waitPakins, whsType, station, param.getLocType1(), userId);
+                WrkMast wrkMast = generateCrnInTask(waitPakins, whsType, station, lcoType, userId);
 
                 response.put("taskNo", wrkMast.getWrkNo());
                 response.put("locNo", wrkMast.getLocNo());
@@ -2031,6 +2084,20 @@
         if (!Objects.isNull(mast)) {
             if (mast.getIoType().equals(TaskIOType.MERGE_OUT.type) || mast.getIoType().equals(TaskIOType.PICK_OUT.type) || mast.getIoType().equals(TaskIOType.CHECK_OUT.type)) {
                 int ioType = mast.getIoType() - 50;
+
+                List<WrkDetl> wrkDetls103 = wrkDetlService
+                        .selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo()));
+                if (wrkDetls103.isEmpty()) {
+                    ioType = 10;
+                }
+                List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo()));
+                if (!Objects.isNull(locDetls) && !locDetls.isEmpty()) {
+                    Double sum = wrkDetls103.stream().mapToDouble(WrkDetl::getAnfme).sum();
+                    Double summed = locDetls.stream().mapToDouble(LocDetl::getAnfme).sum();
+                    if (summed.compareTo(sum) <= 0) {
+                        ioType = 10;
+                    }
+                }
                 mast.setIoType(ioType);
                 mast.setWrkSts(2L);
                 mast.setSourceStaNo(mast.getSourceStaNo());
@@ -2328,9 +2395,9 @@
             // 鐢熸垚宸ヤ綔鍙�
             int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType));
             if (Cools.isEmpty(wrkMast1)) {
-                Integer outSta = devp.getDevNo();
+//                Integer outSta = devp.getDevNo();
                 // 鑾峰彇璺緞
-                StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta);
+//                StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta);
 
                 // 鐢熸垚宸ヤ綔妗�
                 WrkMast wrkMast = new WrkMast();
@@ -2340,8 +2407,8 @@
                 wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶被鍨�
                 wrkMast.setIoPri(13D); // 浼樺厛绾э細13
                 wrkMast.setCrnNo(locMast.getCrnNo());
-                wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 婧愮珯
-                wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
+//                wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 婧愮珯
+//                wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
                 wrkMast.setSourceLocNo(locMast.getLocNo()); // 婧愬簱浣�
                 //灏忔澗椤圭洰锛岀紦瀛樺嚭搴揂GV绔欑偣锛岀敤浜庢竻绌虹紦瀛樺尯搴撳瓨
                 wrkMast.setPauseMk(station.getDevNo());
@@ -2484,7 +2551,7 @@
      * @version 1.0
      */
     @Transactional(rollbackFor = Exception.class)
-    public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
+    public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId, String isNewIn) {
         List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode));
         if (!tasks.isEmpty()) {
             throw new CoolException("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
@@ -2499,6 +2566,7 @@
                 .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
                 .setTaskType("agv")
                 .setIoPri(10D)
+                .setIsNewIn(isNewIn)
                 .setLocNo(loc.getLocNo()) // 鐩爣搴撲綅
                 .setFullPlt("Y") // 婊℃澘锛歒
                 .setPicking("N") // 鎷f枡
@@ -2665,7 +2733,7 @@
 
         try {
             //绌哄彴杞﹀洖搴�
-            generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId);
+            generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId, "M2");
         } catch (Exception e) {
             e.printStackTrace();
             return R.error(e.getMessage());

--
Gitblit v1.9.1