From 6df97fba67b0e0698a02673e65c6eca00879d5be Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期五, 05 十二月 2025 08:16:44 +0800
Subject: [PATCH] #出库单

---
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java |  150 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 105 insertions(+), 45 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 2f151ef..3648224 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -13,7 +13,6 @@
 import com.zy.asrs.entity.result.HIKResultDTO;
 import com.zy.asrs.enums.LocAreaType;
 import com.zy.asrs.enums.LocStsType;
-import com.zy.asrs.enums.OrderSettle;
 import com.zy.asrs.mapper.LocMastMapper;
 import com.zy.asrs.mapper.ManLocDetlMapper;
 import com.zy.asrs.service.*;
@@ -1283,25 +1282,68 @@
     }
 
     @Override
-    public R callEmptyCar(AgvCallParams params) {
-        List<LocCache> locSts = locCacheService.selectList(new EntityWrapper<LocCache>().eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type));
-        if (locSts.isEmpty()){
+    public R callEmptyCar(AgvCallParams params, Long userId) {
+
+        BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getOrgSite()));
+
+
+        List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
+                .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
+                .eq("area_id", basAreas.getId())
+        );
+        if (locCaches.isEmpty()){
             throw new CoolException("鏆傛棤绌烘澘搴撲綅");
         }
 
-        HIKApiDTO hikApiDTO =new HIKApiDTO()
-                .setOrg(locSts.get(0).getLocNo())
-                .setOrgType("05")
-                .setTar(params.getTarSite())
-                .setTarType("05")
-                .setTaskType("GT5")
-                .setPriority("1")
-                .setCtnrType("2")
-                ;
-        HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, HIKApiConstant.AGV_CALL_IN_PATH);
-        if (!hikResultDTO.isSuccess()){
-            return R.error(hikResultDTO.getMessage());
+        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>()
+                .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+                .eq("dev_no", params.getTarSite()));
+        if (Objects.isNull(station)) {
+            throw new CoolException("绔欑偣姝e湪鎵ц浠诲姟锛侊紒");
         }
+        generateCacheOutTask(station, locCaches.get(0), userId);
+
+
+//        HIKApiDTO hikApiDTO =new HIKApiDTO()
+//                .setOrg(locCaches.get(0).getLocNo())
+//                .setOrgType("05")
+//                .setTar(params.getTarSite())
+//                .setTarType("05")
+//                .setTaskType("GT5")
+//                .setPriority("1")
+//                .setCtnrType("2")
+//                ;
+//        HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, HIKApiConstant.AGV_CALL_IN_PATH);
+//        if (!hikResultDTO.isSuccess()){
+//            return R.error(hikResultDTO.getMessage());
+//        }
+
+        return R.ok();
+    }
+
+    @Override
+//    @Transactional(rollbackFor = Exception.class)
+    public R collectionInCall(AgvCallParams params, Long userId) {
+        if (Objects.isNull(params.getOrgSite())) {
+            throw new CoolException("婧愮珯鐐逛笉鑳戒负绌猴紒锛�");
+        }
+
+        List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", params.getBarcode()));
+        if (!tasks.isEmpty()){
+            throw new CoolException("鎵樼洏鐮佸凡鐢熸垚浠诲姟");
+        }
+
+        BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite()));
+
+        List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
+                .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type, LocStsType.LOC_STS_TYPE_D.type)
+                .eq("area_id", basAreas.getId())
+        );
+        if (locCaches.isEmpty()) {
+            throw new CoolException("褰撳墠鏆傛棤绌哄簱浣嶏紒锛�");
+        }
+
+        generateAgvTask("agv", locCaches.get(0), params.getOrgSite(), params.getBarcode(), userId);
 
         return R.ok();
     }
@@ -1356,10 +1398,10 @@
         task.setWrkNo(workNo)
                 .setIoTime(new Date())
                 .setWrkSts(11L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
-                .setIoType(101) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+                .setIoType(loc.getLocSts().equals("D") ? 110 : 101) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
                 .setTaskType("agv")
                 .setIoPri(10D)
-                .setFullPlt("Y") // 婊℃澘锛歒
+                .setFullPlt(loc.getLocSts().equals("D") ? "N" : "Y") // 婊℃澘锛歒
                 .setPicking("N") // 鎷f枡
                 .setExitMk("N")// 閫�鍑�
                 .setStaNo(station.getDevNo())
@@ -1375,35 +1417,32 @@
             throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
         }
         List<LocDetl> detls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_id", loc.getId()));
-        if (Objects.isNull(detls) || detls.isEmpty()) {
-            throw new CoolException("鏁版嵁閿欒锛氬簱浣嶆槑缁嗕负绌猴紒锛�");
+        if (!detls.isEmpty()) {
+            List<TaskDetl> taskDetls = new ArrayList<>();
+            detls.forEach(pakin -> {
+                TaskDetl wrkDetl = new TaskDetl();
+                BeanUtils.copyProperties(pakin, wrkDetl);
+                wrkDetl.setWrkNo(workNo)
+                        .setIoTime(new Date())
+                        .setOrderNo(pakin.getOrderNo())
+                        .setAnfme(pakin.getAnfme())
+                        .setZpallet(pakin.getZpallet())
+                        .setBatch(pakin.getBatch())
+                        .setMatnr(pakin.getMatnr())
+                        .setMaktx(pakin.getMaktx())
+                        .setAppeUser(userId)
+                        .setUnit(pakin.getUnit())
+                        .setModel(pakin.getModel())
+                        .setAppeTime(new Date())
+                        .setModiUser(userId);
+                taskDetls.add(wrkDetl);
+            });
+            //淇濆瓨宸ヤ綔妗f槑缁�
+            if (!taskDetlService.insertBatch(taskDetls)) {
+                throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+            }
         }
-        List<TaskDetl> taskDetls = new ArrayList<>();
-        detls.forEach(pakin -> {
-            TaskDetl wrkDetl = new TaskDetl();
-            BeanUtils.copyProperties(pakin, wrkDetl);
-            wrkDetl.setWrkNo(workNo)
-                    .setIoTime(new Date())
-                    .setOrderNo(pakin.getOrderNo())
-                    .setAnfme(pakin.getAnfme())
-                    .setZpallet(pakin.getZpallet())
-                    .setBatch(pakin.getBatch())
-                    .setMatnr(pakin.getMatnr())
-                    .setMaktx(pakin.getMaktx())
-                    .setAppeUser(userId)
-                    .setUnit(pakin.getUnit())
-                    .setModel(pakin.getModel())
-                    .setAppeTime(new Date())
-                    .setModiUser(userId);
-            taskDetls.add(wrkDetl);
-        });
 
-
-
-        //淇濆瓨宸ヤ綔妗f槑缁�
-        if (!taskDetlService.insertBatch(taskDetls)) {
-            throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
-        }
 
         loc.setLocSts(LocStsType.LOC_STS_TYPE_R.type);
         loc.setModiUser(userId);
@@ -1488,6 +1527,13 @@
         if (!taskDetlService.insertBatch(taskDetls)) {
             throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
         }
+
+        pakins.forEach(pakin -> {pakin.setIoStatus("Y");});
+
+        if (!waitPakinService.updateBatchById(pakins)) {
+            throw new CoolException("鏇存柊缁勬墭淇℃伅澶辫触");
+        }
+
         // 淇敼鐩爣搴撲綅鐘舵��
         if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
             loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
@@ -1499,6 +1545,20 @@
         } else {
             throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
         }
+
+        // 淇敼鐩爣绔欑偣淇℃伅
+        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
+        if (station.getLocSts().equals("O")) {
+            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());
+        }
     }
 
 

--
Gitblit v1.9.1