From 853a65ae9b42fe890b66ecc3bdb427f69b23d210 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期三, 01 四月 2026 17:36:48 +0800
Subject: [PATCH] no message

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  533 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 457 insertions(+), 76 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 5a20ba6..620b397 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -6,6 +6,7 @@
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.core.common.*;
 import com.core.exception.CoolException;
+import com.zy.api.enums.MatLocType;
 import com.zy.asrs.entity.*;
 import com.zy.asrs.entity.param.*;
 import com.zy.asrs.entity.result.*;
@@ -21,10 +22,7 @@
 import com.zy.common.constant.HIKApiConstant;
 import com.zy.common.constant.MesConstant;
 import com.zy.common.entity.Parameter;
-import com.zy.common.model.DetlDto;
-import com.zy.common.model.LocTypeDto;
-import com.zy.common.model.MesCombParam;
-import com.zy.common.model.StartupDto;
+import com.zy.common.model.*;
 import com.zy.common.model.enums.WorkNoType;
 import com.zy.common.properties.SlaveProperties;
 import com.zy.common.service.CommonService;
@@ -1258,6 +1256,12 @@
         wrkMast.setModiUser(userId);
         wrkMast.setModiTime(now);
         wrkMast.setBarcode(locMast.getBarcode());
+
+        WrkMast wrkMast1 = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("source_loc_no", locDetl.getLocNo()));
+        if (!Objects.isNull(wrkMast1)) {
+            throw new CoolException("婧愬簱浣嶅凡鍑哄簱锛岃绛夊緟浠诲姟瀹屾垚鍚庯紝鍐嶆墽琛岋紒锛�");
+        }
+
         if (!wrkMastService.insert(wrkMast)) {
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細" + locDetl.getLocNo());
         }
@@ -1311,34 +1315,71 @@
      * @version 1.0
      */
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public synchronized R callAgvMove(AgvCallParams params, Long userId) {
         if (Objects.isNull(params.getOrgSite())) {
             throw new CoolException("婧愮珯鐐逛笉鑳戒负绌猴紒锛�");
         }
-        BasAreas basAreas = basAreasService
-                .selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
-        LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>()
-                .eq("area_id", basAreas.getId())
-                .eq("frozen", 0)
-                .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
-                .orderAsc(Arrays.asList("loc_no"))
-                .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
-        if (Objects.isNull(locCache)) {
-            throw new CoolException("璇锋鏌ョ洰鏍囧簱浣嶆槸鍚﹂棽缃腑锛侊紒");
-        }
+        if (!Objects.isNull(params.getTaskType()) && params.getTaskType().equals("XM1")) {
+            String taskType = params.getTaskType();
+            generateXAgvTask(params.getOrgSite(), params.getTarSite(), userId, taskType);
+        } else {
+            String taskType = "M2";
+            if (!params.getIsNewIn().isEmpty()) {
+                taskType = "M1";
+                int cacheCount = locCacheService.selectCount(new EntityWrapper<LocCache>().eq("barcode", params.getBarcode()));
+                if (cacheCount > 0) {
+                    throw new CoolException("鍙拌溅宸插叆搴擄紝涓嶈兘鍕鹃�夋柊鍙拌溅锛侊紒");
+                }
+            }
 
-        String taskType = "M2";
-        if (!params.getIsNewIn().isEmpty()) {
-            taskType = "M1";
-        }
-        try {
-            generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId, taskType);
-        } catch (Exception e) {
-            throw new CoolException(e.getMessage());
-        }
+            BasAreas basAreas = basAreasService
+                    .selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
+            LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>()
+                    .eq("area_id", basAreas.getId())
+                    .eq("frozen", 0)
+                    .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+                    .orderAsc(Arrays.asList("loc_no"))
+                    .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+            if (Objects.isNull(locCache)) {
+                throw new CoolException("璇锋鏌ョ洰鏍囧簱浣嶆槸鍚﹂棽缃腑锛侊紒");
+            }
 
+            try {
+                generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId, taskType);
+            } catch (Exception e) {
+                throw new CoolException(e.getMessage());
+            }
+        }
         return R.ok();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void generateXAgvTask(String orgSite, String tarSite, Long userId, String taskType) {
+        // 鑾峰彇宸ヤ綔鍙�
+        int workNo = commonService.getWorkNo(4);
+        // 淇濆瓨宸ヤ綔妗�
+        Task task = new Task();
+        task.setWrkNo(workNo)
+                .setIoTime(new Date())
+                .setWrkSts(201L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+                .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+                .setTaskType("agv")
+                .setIoPri(10D)
+                .setIsNewIn(taskType)
+                .setFullPlt("Y") // 婊℃澘锛歒
+                .setPicking("N") // 鎷f枡
+                .setExitMk("N")// 閫�鍑�
+                .setSourceStaNo(orgSite)
+                .setStaNo(tarSite)
+                .setLinkMis("N")
+                .setAppeUser(userId)
+                .setAppeTime(new Date())
+                .setModiUser(userId)
+                .setModiTime(new Date());
+        if (!taskService.insert(task)) {
+            throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+        }
     }
 
     /**
@@ -1509,7 +1550,7 @@
             throw new CoolException("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
         }
         // 鑾峰彇宸ヤ綔鍙�
-        int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+        int workNo = commonService.getWorkNo(4);
         // 淇濆瓨宸ヤ綔妗�
         Task task = new Task();
         task.setWrkNo(workNo)
@@ -1563,7 +1604,7 @@
             loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
             loc.setModiTime(new Date());
             loc.setModiUser(userId);
-            if (!locCacheService.updateById(loc)) {
+            if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) {
                 throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
             }
         } else {
@@ -1639,7 +1680,7 @@
     }
 
     /**
-     * 缂撳瓨鍖轰笂鏋剁粍鎵�
+     * 缂撳瓨鍖哄苟鏉夸笂鏋剁粍鎵�
      *
      * @param param
      * @param userId
@@ -1656,8 +1697,8 @@
             throw new CoolException("缁勬墭鏄庣粏涓嶈兘涓虹┖锛侊紒");
         }
         WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
-                        .eq("wrk_sts", 14)
-                        .eq("io_type", 104)
+                .eq("wrk_sts", 14)
+                .eq("io_type", 104)
                 .eq("barcode", param.getBarcode()));
         if (Objects.isNull(wrkMast)) {
             throw new CoolException("浠诲姟妗d俊鎭笉瀛樺湪锛侊紒");
@@ -1678,7 +1719,7 @@
             if (Objects.isNull(wrkDetl)) {
                 //TODO 鏂版彃鍏�
                 Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", stationDetl.getMatnr())
-                    .eq("supp_code", combMat.getSuppCode()));
+                        .eq("supp_code", combMat.getSuppCode()));
                 if (Objects.isNull(mat)) {
                     throw new CoolException("鐗╂枡鍩虹淇℃伅宸蹭笉瀛樺湪锛侊紒");
                 }
@@ -1686,22 +1727,63 @@
                 BeanUtils.copyProperties(stationDetl, detl);
                 detl.setAnfme(combMat.getAnfme());
                 detl.setBarcode(wrkMast.getBarcode());
+                detl.setZpallet(param.getBarcode());
                 detl.setBoxType1(combMat.getBoxType1());
                 detl.setStandby1(combMat.getSuppCode());
+                detl.setThreeCode(combMat.getThreeCode());
+                detl.setAdjustQty(combMat.getAdjustQty());
+                detl.setSplusQty(combMat.getSplusQty());
                 detl.setWrkNo(wrkMast.getWrkNo());
 
                 if (!wrkDetlService.insert(detl)) {
                     throw new CoolException("浠诲姟鏄庣粏淇濆瓨澶辫触锛侊紒");
                 }
             } else {
+                if (Objects.isNull(combMat.getAnfme())) {
+                    throw new CoolException("鏁伴噺涓嶈兘涓虹┖锛侊紒");
+                }
                 double val = Math.round((combMat.getAnfme() + wrkDetl.getAnfme()) * 10000) / 10000.0;
-                if (!wrkDetlService.updateAnfme(val, wrkMast.getWrkNo(), wrkDetl.getMatnr(),
-                        wrkDetl.getSuppCode())) {
+                WrkDetl detl = new WrkDetl();
+                detl.setOrderNo(stationDetl.getOrderNo());
+                detl.setBoxType1(combMat.getBoxType1());
+                detl.setZpallet(param.getBarcode());
+                detl.setBarcode(param.getBarcode());
+                detl.setThreeCode(combMat.getThreeCode());
+                detl.setStandby1(combMat.getSuppCode());
+                detl.setAdjustQty(combMat.getAdjustQty());
+                detl.setSplusQty(combMat.getSplusQty());
+                detl.setAnfme(val);
+                detl.setModiTime(new Date());
+                if (!wrkDetlService.update(detl, new EntityWrapper<WrkDetl>()
+                        .eq("wrk_no", wrkMast.getWrkNo())
+                        .eq("supp_code", stationDetl.getSuppCode())
+                        .eq("matnr", stationDetl.getMatnr()))) {
                     throw new CoolException(wrkMast.getWrkNo() + "鐩樼偣浠诲姟锛�" + wrkDetl.getMatnr() + "鍟嗗搧锛�"
                             + wrkDetl.getBatch() + "鎵瑰彿淇敼鏁伴噺澶辫触");
                 }
             }
 
+            BasStationDetl stationDetl1 = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>()
+                    .eq("zpallet", param.getCarBarcode())
+                    .eq("three_code", combMat.getThreeCode()));
+
+            if (!Objects.isNull(stationDetl1)) {
+                Double v = Math.round((stationDetl1.getAnfme() - combMat.getAnfme()) * 10000) / 10000.0;
+                if (v.compareTo(0.0) == 0) {
+                    if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>()
+                            .eq("zpallet", param.getCarBarcode())
+                            .eq("three_code", combMat.getThreeCode()))) {
+                        throw new CoolException("绔欑偣淇℃伅鏇存柊澶辫触锛侊紒");
+                    }
+                } else {
+                    stationDetl1.setAnfme(v);
+                    if (!basStationDetlService.update(stationDetl1, new EntityWrapper<BasStationDetl>()
+                            .eq("zpallet", param.getCarBarcode())
+                            .eq("three_code", combMat.getThreeCode()))) {
+                        throw new CoolException("绔欑偣淇℃伅鏇存柊澶辫触锛侊紒");
+                    }
+                }
+            }
         }
     }
 
@@ -1731,7 +1813,7 @@
             throw new CoolException("瀹瑰櫒缂栫爜鏈淮鎶わ紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
         }
 
-        Integer whsType = 2;
+        Integer whsType = 1;
         Short lcoType = 1;
         //鐢ㄤ簬鍒ゆ柇鏂欑鎵樼洏锛屾枡绠憋紝绗兼
         if (!container.getType().equals(ContainerType.CONTAINER_TYPE_BOX.type)) {
@@ -1868,7 +1950,7 @@
         OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
                 .eq("order_id", orderPakin.getId())
                 .eq("matnr", combMat.getMatnr())
-                .eq(!Cools.isEmpty(combMat.getBatch()),"batch", combMat.getBatch())
+                .eq(!Cools.isEmpty(combMat.getBatch()), "batch", combMat.getBatch())
                 .eq(!Cools.isEmpty(combMat.getStandby1()), "supp_code", combMat.getStandby1()));
         if (Cools.isEmpty(orderDetlPakin)) {
             throw new CoolException("妫�绱㈠崟鎹槑缁嗘暟鎹け璐�");
@@ -2208,7 +2290,7 @@
             if (Objects.isNull(locMast)) {
                 throw new CoolException("鏈煡璇㈠埌鍙敤鐨勭┖鏉夸俊鎭紒锛�");
             }
-            CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls);
+            CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(new ArrayList<>());
             locMasts.add(crnTaskDetlDTO);
 
             // 绌烘澘鍑哄簱
@@ -2228,7 +2310,7 @@
                 if (Objects.isNull(locMast)) {
                     throw new CoolException("鏈煡璇㈠埌鍙敤鐨勭┖鏉夸俊鎭紒锛�");
                 }
-                CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls);
+                CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(new ArrayList<>());
                 locMasts.add(crnTaskDetlDTO);
 
                 // 绌烘澘鍑哄簱
@@ -2258,9 +2340,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();
@@ -2271,7 +2353,7 @@
                 wrkMast.setIoPri(13D); // 浼樺厛绾э細13
                 wrkMast.setCrnNo(locMast.getCrnNo());
 //                wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 婧愮珯
-//                wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
+                wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
                 wrkMast.setSourceLocNo(locMast.getLocNo()); // 婧愬簱浣�
                 //灏忔澗椤圭洰锛岀紦瀛樺嚭搴揂GV绔欑偣锛岀敤浜庢竻绌虹紦瀛樺尯搴撳瓨
                 wrkMast.setPauseMk(station.getDevNo());
@@ -2310,17 +2392,17 @@
             }
             // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
             locMast = locMastService.selectById(locMast.getLocNo());
-            if (locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)
-                    || locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) {
-                locMast.setLocSts(ioType == 101 ? "R" : "P");
-                locMast.setModiUser(userId);
-                locMast.setModiTime(now);
-                if (!locMastService.updateById(locMast)) {
-                    throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + locMast.getLocNo());
-                }
-            } else {
-                throw new CoolException(locMast.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
+//            if (locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)
+//                    || locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) {
+            locMast.setLocSts(ioType == 101 ? "R" : "P");
+            locMast.setModiUser(userId);
+            locMast.setModiTime(now);
+            if (!locMastService.updateById(locMast)) {
+                throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + locMast.getLocNo());
             }
+//            } else {
+//                throw new CoolException(locMast.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
+//            }
         }
     }
 
@@ -2333,7 +2415,7 @@
     @Transactional(rollbackFor = Exception.class)
     public void generateCacheOutTask(BasStation station, LocCache loc, Long userId) {
         // 鑾峰彇宸ヤ綔鍙�
-        int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+        int workNo = commonService.getWorkNo(4);
         // 淇濆瓨宸ヤ綔妗�
         Task task = new Task();
         task.setWrkNo(workNo)
@@ -2390,9 +2472,10 @@
         loc.setModiUser(userId);
         loc.setModiTime(new Date());
 
-        if (!locCacheService.updateById(loc)) {
-            throw new CoolException("鏇存柊搴撲綅鐘舵�佷俊鎭紒锛�");
-        }
+//        if (!) {
+//            throw new CoolException("鏇存柊搴撲綅鐘舵�佷俊鎭紒锛�");
+//        }
+        locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()));
 
         // 淇敼鐩爣绔欑偣淇℃伅
         if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
@@ -2403,7 +2486,8 @@
                 throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
             }
         } else {
-            throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+            log.error("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+//            throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
         }
     }
 
@@ -2420,14 +2504,14 @@
             throw new CoolException("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
         }
         // 鑾峰彇宸ヤ綔鍙�
-        int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+        int workNo = commonService.getWorkNo(4);
         // 淇濆瓨宸ヤ綔妗�
         Task task = new Task();
         task.setWrkNo(workNo)
                 .setIoTime(new Date())
                 .setWrkSts(201L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
                 .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
-                .setTaskType("agv")
+                .setTaskType(type)
                 .setIoPri(10D)
                 .setIsNewIn(isNewIn)
                 .setLocNo(loc.getLocNo()) // 鐩爣搴撲綅
@@ -2442,6 +2526,7 @@
                 .setAppeTime(new Date())
                 .setModiUser(userId)
                 .setModiTime(new Date());
+
         if (!taskService.insert(task)) {
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
@@ -2479,28 +2564,27 @@
                     throw new CoolException("鏇存柊缁勬墭淇℃伅澶辫触");
                 }
             }
-        }
 
-        // 淇敼鐩爣搴撲綅鐘舵��
-        if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
-            loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
-            loc.setModiTime(new Date());
-            loc.setModiUser(userId);
-            if (!locCacheService.updateById(loc)) {
-                throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+            // 淇敼鐩爣搴撲綅鐘舵��
+            if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+                loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
+                loc.setModiTime(new Date());
+                loc.setModiUser(userId);
+
+                if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) {
+                    throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+                }
+            } else {
+                throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
             }
-        } else {
-            throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
-        }
 
-        // 淇敼鐩爣绔欑偣淇℃伅
-        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
-        if (Objects.isNull(station)) {
-            throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
-        }
+            // 淇敼鐩爣绔欑偣淇℃伅
+            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_O.type) || station.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) {
-            station.setLocSts("R"); // S.鍏ュ簱棰勭害
+            station.setLocSts("R"); // R.鍏ュ簱棰勭害
             station.setBarcode(barcode);
             station.setModiTime(new Date());
             station.setModiUser(userId);
@@ -2508,8 +2592,30 @@
                 throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
             }
         } else {
-            throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+            // 淇敼鐩爣搴撲綅鐘舵��
+            loc.setLocSts(LocStsType.LOC_STS_TYPE_D.type); // S.鍏ュ簱棰勭害
+            loc.setModiTime(new Date());
+            loc.setModiUser(userId);
+            if (!locCacheService.update(loc, new EntityWrapper<LocCache>().eq("loc_no", loc.getLocNo()))) {
+                throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+            }
+
+            // 淇敼鐩爣绔欑偣淇℃伅
+            BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
+            if (Objects.isNull(station)) {
+                throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
+            }
+
+            station.setLocSts("O"); // S.鍏ュ簱棰勭害
+            station.setBarcode(barcode);
+            station.setModiTime(new Date());
+            station.setModiUser(userId);
+            if (!basStationService.updateById(station)) {
+                throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+            }
         }
+
+
     }
 
     public HIKResultDTO sendAgvTask(HIKApiDTO haiKangApiDTO, String path) {
@@ -2732,6 +2838,7 @@
 
     /**
      * 鑾峰彇缂撳瓨绔欑偣淇℃伅
+     *
      * @param type
      * @return
      */
@@ -2749,6 +2856,280 @@
     }
 
     /**
+     * 鑾峰彇鎹嗗寘鏄庣粏淇℃伅
+     *
+     * @param params
+     * @return
+     */
+    @Override
+    public R getAllBindInfo(AgvCallParams params) {
+        if (Objects.isNull(params.getCarBarcode())) {
+            return R.error("鍙拌溅缂栫爜涓嶈兘涓虹┖锛�");
+        }
+        List<TaskDetl> taskDetls = taskDetlService.selectList(new EntityWrapper<TaskDetl>()
+//                .eq(!Objects.isNull(params.getMatnr()), "matnr", params.getMatnr())
+                .eq("zpallet", params.getCarBarcode()));
+
+        taskDetls.forEach(taskDetl -> {
+            OrderPakout orderDetlPakout = orderPakoutService.selectOne(new EntityWrapper<OrderPakout>()
+                    .eq("order_no", taskDetl.getOrderNo()));
+            taskDetl.setMemo(orderDetlPakout.getShipCode());
+        });
+
+        return R.ok("鏌ヨ鎴愬姛").add(taskDetls);
+    }
+
+    /**
+     * 鎸夊彴杞﹀嚭搴�
+     *
+     * @param params
+     * @return com.core.common.R
+     * @author Ryan
+     * @date 2026/3/28 8:41
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R outStockByTc(AgvCallParams params) {
+        if (Objects.isNull(params.getCarBarcode())) {
+            return R.error("鍙拌溅鐮佷笉鑳戒负绌猴紒锛�");
+        }
+        LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("barcode", params.getCarBarcode()));
+        if (Objects.isNull(locCache)) {
+            return R.error("褰撳墠鍙拌溅涓嶅湪缂撳啿搴撳尯锛侊紒");
+        }
+        if (Objects.isNull(params.getTarSite())) {
+            return R.error("鐩爣绔欑偣涓嶈兘涓虹┖锛侊紒");
+        }
+        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locCache.getLocNo()));
+        if (Objects.isNull(locDetls) || locDetls.isEmpty()) {
+            return R.error("鍙拌溅涓婃病鏈夊搴旀槑缁嗕俊鎭紒锛�");
+        }
+        List<LocDto> locDtos = new ArrayList<>();
+        locDetls.forEach(locDetl -> {
+            OrderPakout orderPakout = orderPakoutService.selectOne(new EntityWrapper<OrderPakout>()
+                    .eq("doc_type", 5)
+                    .eq("number", locDetl.getOrderNo()));
+            if (!Objects.isNull(orderPakout)) {
+                locDetl.setMemo(orderPakout.getShipCode());
+                locDetl.setOrderNo(orderPakout.getOrderNo());
+            }
+            OrderDetlPakout orderDetl = orderDetlPakoutService.selectOne(new EntityWrapper<OrderDetlPakout>()
+                    .eq("matnr", locDetl.getMatnr())
+                    .eq("supp_code", locDetl.getSuppCode())
+                    .eq("order_no", orderPakout.getOrderNo()));
+            if (Objects.isNull(orderDetl)) {
+                throw new CoolException("璁㈠崟鏄庣粏涓嶅瓨鍦紒锛�");
+            }
+
+            LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(),
+                    locDetl.getAnfme());
+            locDto.setFrozen(locDetl.getFrozen());
+            locDto.setFrozenLoc(locCache.getFrozen());
+//            List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().in("area_id", areaIds));
+//            List<String> collect = basStations.stream().map(BasStation::getDevNo).collect(Collectors.toList());
+//            locDto.setAgvStaNos(collect);
+            locDto.setAgvStaNo(params.getTarSite());
+            locDto.setBrand(orderDetl.getBrand());
+            locDto.setSuppCode(orderDetl.getSuppCode());
+            locDto.setStandby1(orderDetl.getStandby1());
+            locDto.setStandby2(orderDetl.getStandby2());
+            locDto.setStandby3(orderDetl.getStandby3());
+            locDto.setBoxType1(orderDetl.getBoxType1());
+            locDto.setBoxType2(orderDetl.getBoxType2());
+            locDto.setBoxType3(orderDetl.getBoxType3());
+            locDtos.add(locDto);
+//            exist.add(locDetl.getLocNo());
+        });
+
+        generateAgvTaskByTc(locDtos);
+
+
+        return R.ok();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void generateAgvTaskByTc(List<LocDto> locDtos) {
+        List<LocDto> locDtoArrayList = new ArrayList<>();
+        for (LocDto locDto : locDtos){
+            if (locDto.getFrozen()!=1 && locDto.getFrozenLoc()!=1){
+                locDtoArrayList.add(locDto);
+            }
+        }
+        locDtos = locDtoArrayList;
+        if (Cools.isEmpty(locDtos)) {
+            throw new CoolException("搴撳瓨/搴撲綅琚喕缁擄紝璇峰鐞嗗悗鍑哄簱锛侊紒锛�");
+        }
+        boolean lack = true;
+        for (LocDto locDto : locDtos) {
+            if (!locDto.isLack()) {
+                lack = false;
+                break;
+            }
+        }
+        if (lack) {
+            throw new CoolException("搴撳瓨涓嶈冻");
+        }
+
+        try {
+            Thread.sleep(300L);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+
+        List<TaskDto> taskDtos = new ArrayList<>();
+        // 鏍规嵁 锛堝簱浣� & 鍑哄簱绔欙級 鍒嗙粍锛� 鐞嗘兂鐘舵�侊細涓�缁勪负涓�娆″嚭搴撲换鍔�
+        for (LocDto locDto : locDtos) {
+            if (locDto.isLack()) { continue; }
+            TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getAgvStaNo(), locDto);
+            if (TaskDto.hasAgv(taskDtos, taskDto)) {
+                TaskDto dto = TaskDto.findAgv(taskDtos, taskDto);
+                assert dto != null;
+                dto.getLocDtos().addAll(taskDto.getLocDtos());
+            } else {
+                taskDtos.add(taskDto);
+            }
+        }
+        // -----------------------------------------------------------------------------------------------
+        Map<String, List<TaskDto>> listMap = taskDtos.stream().collect(Collectors.groupingBy(TaskDto::getLocNo));
+        listMap.keySet().forEach(locNo -> {
+            listMap.get(locNo).forEach(taskDto -> {
+                BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>()
+                        .in("loc_sts", Arrays.asList(LocStsType.LOC_STS_TYPE_O.type, LocStsType.LOC_STS_TYPE_O.type))
+                        .eq("dev_no", taskDto.getAgvStaNo()));
+                if (Objects.isNull(station)) { throw new CoolException("鏁版嵁閿欒锛岀珯鐐逛笉瀛樺湪鎴栧凡浣跨敤锛侊紒"); }
+                workService.agvStockOut(station, taskDto, 9527L);
+            });
+        });
+    }
+
+
+    /**
+     * 纭鎹嗗寘鍑哄簱
+     *
+     * @param combParam
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R confirmOutstock(CombParam combParam) {
+        if (Objects.isNull(combParam.getCombMats()) || combParam.getCombMats().isEmpty()) {
+            return R.error("鎹嗗寘淇℃伅涓嶈兘涓虹┖锛侊紒");
+        }
+        Task task = taskService.selectOne(new EntityWrapper<Task>()
+                .eq("wrk_sts", 304)
+                .eq("barcode", combParam.getBarcode()));
+        if (Objects.isNull(task)) {
+            throw new CoolException("浠诲姟淇℃伅涓嶅瓨鍦紒锛�");
+        }
+        if (task.getIoType().equals(103)) {
+            List<TaskDetl> taskDetls = taskDetlService.selectList(new EntityWrapper<TaskDetl>()
+                    .eq("wrk_no", task.getWrkNo()));
+
+            int workNo = commonService.getWorkNo(4);
+            Task task1 = new Task();
+            BeanUtils.copyProperties(task, task1);
+            task1.setIoType(53);
+            task1.setLocNo(task.getSourceLocNo());
+            task1.setSourceStaNo(task.getStaNo());
+            task1.setWrkNo(workNo);
+            task1.setWrkSts(TaskStatusType.AGV_IN_START.type);
+
+            if (!taskService.insert(task1)) {
+                throw new CoolException("鍏ュ簱浠诲姟鐢熸垚澶辫触锛侊紒");
+            }
+            if (!Objects.isNull(taskDetls) && !taskDetls.isEmpty()) {
+                for (CombParam.CombMat combMat : combParam.getCombMats()) {
+                    taskDetls.forEach(taskDetl -> {
+                        if (taskDetl.getMatnr().equals(combMat.getMatnr()) && taskDetl.getSuppCode().equals(combMat.getSuppCode())) {
+                            //TODO
+                            if (!taskDetl.getAnfme().equals(combMat.getAnfme())) {
+                                throw new CoolException("鐗╂枡--->" + combMat.getMatnr() + "鏈嫞鏂欏畬鎴愶紝璇风‘璁ゅ畬鎴愬悗鍐嶅皾璇曪紒锛�");
+                            }
+                            List<TaskDetl> taskDetls1 = taskDetlService.selectList(new EntityWrapper<TaskDetl>().eq("wrk_no", task.getWrkNo()));
+                            if (!Objects.isNull(taskDetls1) && !taskDetls1.isEmpty()) {
+                                taskDetls1.forEach(detl -> {
+                                    detl.setWrkNo(workNo);
+                                    detl.setBoxType1(combMat.getBoxType1());
+                                    detl.setSupp(combMat.getSuppCode());
+                                    if (!taskDetlService.update(detl, new EntityWrapper<TaskDetl>()
+                                            .eq("matnr", detl.getMatnr())
+                                            .eq("supp_code", detl.getSuppCode())
+                                            .eq("wrk_no", task.getWrkNo()))) {
+                                        throw new CoolException("浠诲姟鍙蜂俊鎭洿鏂板け璐ワ紒锛�");
+                                    }
+                                });
+                            }
+
+                            task.setWrkSts(TaskStatusType.AGV_INVENTORY_UPDATED_OUT.type);
+                            if (!taskService.update(task, new EntityWrapper<Task>().eq("wrk_no", taskDetl.getWrkNo()))) {
+                                throw new CoolException("浠诲姟淇℃伅鏇存柊澶辫触锛侊紒");
+                            }
+                        }
+                    });
+                }
+
+            }
+        }
+        //TODO 姣斿瀹為檯鍑哄簱鏁伴噺鍜屼换鍔℃。鏁伴噺鏄惁鐩哥瓑锛屼慨鏀瑰師浠诲姟妗d负53锛岀敓鎴愭柊鐨勫叆搴撲换鍔�
+
+        return R.ok("鍛煎彨鎴愬姛锛侊紒");
+    }
+
+
+    /**
+     * 绌烘澘鍑哄簱浠诲姟
+     *
+     * @param params
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R getEmptyOutStock(AgvCallParams params) {
+        if (Objects.isNull(params.getOrgSite())) {
+            return R.error("鎵樼洏绫诲瀷涓嶈兘涓虹┖锛侊紒");
+        }
+        if (Objects.isNull(params.getTarSite())) {
+            return R.error("鐩爣绔欑偣涓嶈兘涓虹┖锛侊紒");
+        }
+        Wrapper<LocMast> wrapper = new EntityWrapper<LocMast>().eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type);
+        if (params.getOrgSite().equals(MatLocType.AUTOMATED.type)) {
+            wrapper.like("barcode", "LX80");
+        } else if (params.getOrgSite().equals(MatLocType.SO_HOLDING.type)) {
+            wrapper.like("barcode", "TP80");
+        } else {
+            wrapper.like("barcode", "TP88");
+        }
+        wrapper.orderAsc(Arrays.asList("row1", "lev1"));
+        LocMast locMast = locMastService.selectOne(wrapper);
+        if (Objects.isNull(locMast)) {
+            return R.error("娌℃湁鍙敤绌烘澘锛侊紒");
+        }
+
+        //TODO 鐢熸垚骞舵澘鍑哄簱浠诲姟
+        WrkMast wrkMast = new WrkMast();
+        wrkMast.setIoType(104);
+        wrkMast.setWrkSts(11L);
+        wrkMast.setStaNo(params.getTarSite());
+        wrkMast.setSourceLocNo(locMast.getLocNo());
+        wrkMast.setBarcode(locMast.getBarcode());
+        wrkMast.setIoPri(14.0);
+        wrkMast.setAppeTime(new Date());
+        wrkMast.setModiTime(new Date());
+        wrkMast.setCrnNo(locMast.getCrnNo());
+        wrkMast.setIoTime(new Date());
+        wrkMast.setWrkDate(new Date());
+        wrkMast.setWrkNo(commonService.getWorkNo(0));
+        wrkMast.setTaskType("crn");
+
+        if (!wrkMastService.insert(wrkMast)) {
+            throw new CoolException("鏂板缓浠诲姟澶辫触锛侊紒");
+        }
+
+        return R.ok().add(wrkMast);
+    }
+
+
+    /**
      * 鐢熸垚绉诲簱浠诲姟
      *
      * @param result

--
Gitblit v1.9.1