From 2ede5469ff64257e97ab92825261afeb643d7b82 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期四, 28 八月 2025 15:56:05 +0800
Subject: [PATCH] #订单出库agv库位锁定,取消,配置

---
 src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java |   62 ++++++++++++++++++++++++++----
 1 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
index 7d91a2d..bddeb9e 100644
--- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -23,6 +23,8 @@
 import com.zy.common.properties.SlaveProperties;
 import com.zy.common.service.CommonService;
 import com.zy.common.web.WcsController;
+import com.zy.system.entity.Config;
+import com.zy.system.service.ConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -74,6 +76,8 @@
     @Autowired
     private OrderDetlService orderDetlService;
     @Autowired
+    private ConfigService configService;
+    @Autowired
     private WcsController wcsController;
     @Autowired
     private RowLastnoService rowLastnoService;
@@ -106,9 +110,9 @@
         BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo(), true);
         // 妫�绱㈠簱浣�
         LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo);
-        List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList());
+//        List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList());
 //        List<String> batchs = param.getList().stream().map(FullStoreParam.MatCodeStore::getBatch).distinct().collect(Collectors.toList());
-        FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(matnrs.get(0));
+        FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(param.getList().get(0));
         StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), findLocNoAttributeVo,locTypeDto);
         if (Cools.isEmpty(dto)){
             throw new CoolException("鏌ヨ搴撲綅澶辫触锛侊紒==銆媠tartupFullPutStore ==銆� commonService.getLocNo");
@@ -397,6 +401,8 @@
                 throw new CoolException("璁㈠崟鍑哄簱寮傚父锛岃鑱旂郴绠$悊鍛�");
             }
         }
+        Config config = configService.selectConfigByCode("AutoMPArea");
+
         // 鑾峰彇搴撲綅
         LocMast locMast = locMastService.selectById(taskDto.getLocNo());
         // 鍒ゆ柇鏄惁鏄洏鐐瑰崟
@@ -404,6 +410,16 @@
         OrderPakout orderPakout = orderPakOutService.selectByNo(orderNo);
         int ioType = orderPakout.getDocType() == 8 ? 107 : (taskDto.isAll() ? 101 : 103);
         StaDesc staDesc = staDescService.queryCrnStnAuto(ioType, locMast.getCrnNo(), staNo.getDevNo());
+        List<LocMast> list = locMastMapper.selectList(
+                new EntityWrapper<LocMast>()
+                        .eq("whs_type", 5)
+                        .eq("loc_sts", "O")
+        );
+        LocMast locMastRgv = list.isEmpty() ? null : list.get(0);
+
+
+
+
         // 鐢熸垚宸ヤ綔鍙�
         int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType));
         // 鐢熸垚宸ヤ綔妗�
@@ -417,6 +433,10 @@
         wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
         wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
         wrkMast.setSourceLocNo(taskDto.getLocNo()); // 婧愬簱浣�
+        if (Boolean.parseBoolean(config.getValue()) && locMastRgv.getLocNo() != null) {  //鑻ユ湁绌哄簱浣嶄笖閰嶇疆鍏佽鍒欑粦瀹氬叾澶囨枡搴撲綅鍙�
+            wrkMast.setLocNo(locMastRgv.getLocNo());
+            wrkMast.setTakeNone("0");  //0rgv鏈彇锛�1rgv宸插彇璐�
+        }
         wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
         wrkMast.setPicking("N"); // 鎷f枡
         wrkMast.setExitMk("N"); // 閫�鍑�
@@ -466,6 +486,18 @@
                     orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3()
                     , locDto.getAnfme());
             OrderInAndOutUtil.updateOrder(Boolean.FALSE,orderDetl.getOrderId(), 2L, userId);
+        }
+        //淇敼agv澶囨枡鍖虹姸鎬�
+        if(locMastRgv.getLocSts().equals("O")){
+            locMastRgv.setLocSts("S");
+            locMastRgv.setModiUser(userId);
+            locMastRgv.setModiTime(now);
+            if (!locMastService.updateById(locMastRgv)) {
+                throw new CoolException("棰勭害agv澶囨枡鍖哄簱浣嶇姸鎬佸け璐ワ紝搴撲綅鍙凤細"+taskDto.getLocNo());
+            }
+        }else{
+            throw new CoolException(taskDto.getLocNo() + "澶囨枡鍖轰笉鏄┖搴撲綅鐘舵��");
+
         }
         // 淇敼搴撲綅鐘舵��:   F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
         locMast = locMastService.selectById(taskDto.getLocNo());
@@ -1128,6 +1160,16 @@
         //鍙栨秷鍑哄簱宸ヤ綔妗f椂锛屾煡璇㈠崟鎹鐞嗚〃锛屽洖婊氫綔涓氫腑鏁伴噺
         if(wrkMast.getIoType() == 101 || wrkMast.getIoType() == 103) {
             List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo());
+            if(wrkMast.getLocNo() != null){
+                LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
+                locMast.setLocSts("O");
+                locMast.setModiTime(now);
+                locMast.setModiUser(userId);
+                boolean locMastRes = locMastService.updateById(locMast);
+                if (!locMastRes) {
+                    throw new CoolException("淇濆瓨鏁版嵁澶辫触");
+                }
+            }
             for (WrkDetl wrkDetl : wrkDetls) {
                 if (!Cools.isEmpty(wrkDetl.getOrderNo())) {
 //                    if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) {
@@ -1201,15 +1243,17 @@
 
         // 淇敼搴撲綅鐘舵��
         LocMast locMast = locMastService.selectById(locNo);
-        if (Cools.isEmpty(locMast)) {
+        if (Cools.isEmpty(locMast) && wrkMast.getIoType() != 12) {
             throw new CoolException("鍙栨秷宸ヤ綔妗eけ璐ワ紝搴撲綅涓嶅瓨鍦�:"+ locNo);
         }
-        locMast.setLocSts(locSts);
-        locMast.setModiTime(now);
-        locMast.setModiUser(userId);
-        boolean locMastRes = locMastService.updateById(locMast);
-        if (!wrkMastRes || !locMastRes) {
-            throw new CoolException("淇濆瓨鏁版嵁澶辫触");
+        if(wrkMast.getIoType() != 12){
+            locMast.setLocSts(locSts);
+            locMast.setModiTime(now);
+            locMast.setModiUser(userId);
+            boolean locMastRes = locMastService.updateById(locMast);
+            if (!wrkMastRes || !locMastRes) {
+                throw new CoolException("淇濆瓨鏁版嵁澶辫触");
+            }
         }
     }
 

--
Gitblit v1.9.1