From a422cb5b73799050827251f835ebc53d5757a96b Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期六, 24 一月 2026 09:06:21 +0800
Subject: [PATCH] lsh#

---
 rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/AgvServiceImpl.java |   91 ++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 76 insertions(+), 15 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/AgvServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/AgvServiceImpl.java
index 7ddb9d0..4f38bed 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/AgvServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/AgvServiceImpl.java
@@ -10,7 +10,10 @@
 import com.vincent.rsf.server.manager.entity.*;
 import com.vincent.rsf.server.manager.enums.LocStsType;
 import com.vincent.rsf.server.manager.enums.PakinIOStatus;
+import com.vincent.rsf.server.manager.enums.StationTypeEnum;
+import com.vincent.rsf.server.manager.enums.TaskType;
 import com.vincent.rsf.server.manager.service.*;
+import com.vincent.rsf.server.manager.service.impl.DeviceSiteServiceImpl;
 import com.vincent.rsf.server.manager.utils.LocManageUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -35,6 +38,8 @@
     private TaskService taskService;
     @Autowired
     private BasContainerService basContainerService;
+    @Autowired
+    private DeviceSiteServiceImpl deviceSiteService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -44,6 +49,25 @@
         //鐢熸垚浠诲姟
         AGVInTaskStart(waitPakinPda, loginUserId);
         return R.ok();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R AGVBindAndInTaskStart(String barcode) {
+        //楠岃瘉鏉$爜
+        boolean b = checkStaStatus(barcode);
+        if (!b) {
+            return R.error("鏉$爜鏈壘鍒板搴旇鍒�");
+        }
+        return R.ok();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean AGVBindAndInTaskStart(String barcode, String sta) {
+        //楠岃瘉鏉$爜
+        checkStaStatus(barcode,sta);
+        return true;
     }
 
     @Override
@@ -110,7 +134,15 @@
         }
         String targetLoc = LocManageUtil.getTargetLoc(Long.parseLong(area));
 
-        taskService.generateAGVTasks(waitPakin, targetLoc, sta, loginUserId);
+        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
+                .eq(DeviceSite::getSite, sta)
+                .eq(DeviceSite::getAreaIdEnd, Long.parseLong(area))
+                .eq(DeviceSite::getType, TaskType.TASK_TYPE_IN.type).last("limit 1"));
+        if (Cools.isEmpty(deviceSite)) {
+            throw new CoolException("鏃犲彲鐢ㄨ矾寰勶紒锛�");
+        }
+
+        taskService.generateAGVTasks(waitPakin, targetLoc, sta, deviceSite.getTarget(),loginUserId);
 
         basStation.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
         if (!basStationService.updateById(basStation)) {
@@ -224,15 +256,9 @@
             throw new CoolException("瀹瑰櫒鐮佷笉鑳戒负绌�");
         }
         if (Cools.isEmpty(sta)) {
-            throw new CoolException("鎺ラ┏浣嶆潯鐮佷笉鑳戒负绌�");
+            throw new CoolException("绔欑偣淇℃伅涓嶈兘涓虹┖");
         }
-        WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
-                .eq(WaitPakin::getBarcode, barcode)
-                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val)
-        );
-        if (Cools.isEmpty(waitPakin)) {
-            throw new CoolException("瀹瑰櫒鐮佹湭鎵惧埌缁勬墭淇℃伅,璇锋鏌ョ粍鎵樼姸鎬�");
-        }
+
         BasStation isBarcodeSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                         .eq(BasStation::getBarcode, barcode)
                 , false
@@ -245,9 +271,6 @@
         );
         if (Cools.isEmpty(basStation)) {
             throw new CoolException("鏈壘鍒扮珯鐐逛俊鎭�");
-        }
-        if (!basStation.getUseStatus().equals("O")) {
-            throw new CoolException("绔欑偣鐘舵�佷笉涓虹┖闂�");
         }
         if (!Cools.isEmpty(basStation.getContainerType())) {
             List<Long> longs1 = JSONObject.parseArray(basStation.getContainerType(), Long.class);
@@ -263,9 +286,6 @@
                     break;  // 鎵惧埌鍖归厤鐨勫氨閫�鍑哄惊鐜�
                 }
             }
-//            boolean matches = containers.stream()
-//                    .map(BasContainer::getCodeType)
-//                    .anyMatch(codeType -> barcode.matches(codeType));
             if (!matches) {
                 throw new CoolException("鏉$爜涓庣珯鐐逛笉鍖归厤");
             }
@@ -304,6 +324,9 @@
         }
         if (!basStation.getUseStatus().equals("O")) {
             throw new CoolException("绔欑偣鐘舵�佷笉涓虹┖闂�");
+        }
+        if (basStation.getType().equals(StationTypeEnum.STATION_TYPE_MUTI.type)) {
+            throw new CoolException("绔欑偣涓哄厜鐢电珯鐐癸紝绂佹鍛煎彨AGV");
         }
 
         List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class);
@@ -345,4 +368,42 @@
 
         return basStation;
     }
+    private boolean checkStaStatus(String barcode) {
+        if (Cools.isEmpty(barcode)) {
+            throw new CoolException("瀹瑰櫒鐮佷笉鑳戒负绌�");
+        }
+        WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
+                .eq(WaitPakin::getBarcode, barcode)
+                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val)
+        );
+        if (Cools.isEmpty(waitPakin)) {
+            throw new CoolException("瀹瑰櫒鐮佹湭鎵惧埌缁勬墭淇℃伅,璇锋鏌ョ粍鎵樼姸鎬�");
+        }
+        BasStation isBarcodeSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+                        .eq(BasStation::getBarcode, barcode)
+                , false
+        );
+        if (!Cools.isEmpty(isBarcodeSta)) {
+            throw new CoolException("璇ユ潯鐮佸凡琚�" + isBarcodeSta.getStationName() + "绔欑粦瀹�");
+        }
+
+        List<BasContainer> containers = basContainerService.list(
+                new LambdaQueryWrapper<BasContainer>());
+        boolean matches = false;
+        for (BasContainer container : containers) {
+            String codeType = container.getCodeType();  // 鑾峰彇姝e垯琛ㄨ揪寮�
+            if (barcode.matches(codeType)) {  // 鍒ゆ柇鏉$爜鏄惁绗﹀悎杩欎釜姝e垯
+                matches = true;
+                return true;
+            }
+        }
+//            boolean matches = containers.stream()
+//                    .map(BasContainer::getCodeType)
+//                    .anyMatch(codeType -> barcode.matches(codeType));
+        if (!matches) {
+            return false;
+        }
+
+        return true;
+    }
 }

--
Gitblit v1.9.1