From 8e19e67d1178e834a868f4a820d827ddf64c6e01 Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期三, 28 五月 2025 12:46:08 +0800
Subject: [PATCH] #ZH

---
 src/main/java/com/zy/asrs/controller/RgvController.java |  158 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 136 insertions(+), 22 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/RgvController.java b/src/main/java/com/zy/asrs/controller/RgvController.java
index e85e4de..112568f 100644
--- a/src/main/java/com/zy/asrs/controller/RgvController.java
+++ b/src/main/java/com/zy/asrs/controller/RgvController.java
@@ -2,9 +2,11 @@
 
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.annotations.ManagerAuth;
+import com.core.common.Cools;
 import com.core.common.R;
 import com.zy.asrs.entity.BasDevpPosition;
 import com.zy.asrs.service.BasDevpPositionService;
+import com.zy.core.cache.RgvErrCache;
 import com.zy.core.cache.RgvStatusCache;
 import com.zy.core.cache.SlaveConnection;
 import com.zy.core.cache.TaskProtocolCache;
@@ -46,6 +48,7 @@
             map2.put("rgvPos", rgvProtocol.getRgvPos());
             map2.put("rgvPosDestination", rgvProtocol.getRgvPosDestination());
             map2.put("loaded", rgvProtocol.getLoaded().equals((short)-1)? "鏈煡":rgvProtocol.getLoaded()==1? "鏈夌墿":"鏃犵墿");
+            map2.put("errorRgv", RgvErrCache.getErrorDev(rgvProtocol.getRgvNo()));
             res.add(map2);
         }
         return R.ok().add(res);
@@ -75,24 +78,47 @@
         return R.ok().add(res);
     }
 
+    @PostMapping("/run/del")//Take  Put  Walk
+    @ManagerAuth(memo = "娓呯┖浠诲姟")
+    public R rgvRunDel(@RequestParam(defaultValue = "0")  Integer rgvNo
+    ) {
+        if (rgvNo==null || rgvNo==0){
+            return R.error("璇烽�夋嫨灏忚溅");
+        }
+        RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo);
+        TaskProtocolCache taskProtocolCache = rgvThread.getTaskProtocolCache();
+
+        try {
+            ConcurrentHashMap<String, TaskProtocol> allTaskProtocol = taskProtocolCache.getAllTaskProtocol();
+            for (TaskProtocol taskProtocol : allTaskProtocol.values()){
+                taskProtocolCache.removeTaskProtocol(taskProtocol.getTaskNoDirection());
+            }
+
+        } catch (Exception e) {
+            return R.error("浠诲姟鍒犻櫎澶辫触"+e.getMessage());
+        }
+
+        return R.ok("浠诲姟娓呯┖鎴愬姛");
+    }
+
     @PostMapping("/run/walk")//Take  Put  Walk
     @ManagerAuth(memo = "灏忚溅琛岃蛋")
     public R rgvRunWalk(@RequestParam(defaultValue = "0")  Integer rgvNo,
-                            @RequestParam(defaultValue = "0")  Integer taskNo,
-                            @RequestParam(defaultValue = "0")  Integer rgvStaNo,
+                            @RequestParam(defaultValue = "9999")  Integer taskNo,
+                            @RequestParam(defaultValue = "0")  Integer rgvStaNoPut,
                             @RequestParam(defaultValue = "0")  Long rgvPosDestination
     ) {
         if (rgvNo==null || rgvNo==0){
             return R.error("璇烽�夋嫨灏忚溅");
         }
-        if (taskNo==null || taskNo==0){
-            return R.error("浣滀笟鍙疯濉啓");
-        }
-        if ((rgvStaNo == null || rgvStaNo == 0) && (rgvPosDestination==null || rgvPosDestination==0L)){
+        if ((rgvStaNoPut == null || rgvStaNoPut == 0) && (rgvPosDestination==null || rgvPosDestination==0L)){
             return R.error("鐩爣绔欑偣璇峰~鍐�");
         }
         if (rgvPosDestination == null || rgvPosDestination == 0){
-            BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNo));
+            BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNoPut));
+            if (Cools.isEmpty(basDevpPosition)){
+                return R.error("鐩爣绔欑偣涓嶅瓨鍦�");
+            }
             rgvPosDestination = basDevpPosition.getPlcPosition();
         }
         RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo);
@@ -126,17 +152,14 @@
     @PostMapping("/run/put")//Take  Put  Walk
     @ManagerAuth(memo = "灏忚溅鏀捐揣")
     public R rgvPutWalk(@RequestParam(defaultValue = "0")  Integer rgvNo,
-                        @RequestParam(defaultValue = "0")  Integer taskNo,
-                        @RequestParam(defaultValue = "0")  Integer rgvStaNo,
+                        @RequestParam(defaultValue = "9999")  Integer taskNo,
+                        @RequestParam(defaultValue = "0")  Integer rgvStaNoPut,
                         @RequestParam(defaultValue = "0")  Long rgvPosDestination
     ) {
         if (rgvNo==null || rgvNo==0){
             return R.error("璇烽�夋嫨灏忚溅");
         }
-        if (taskNo==null || taskNo==0){
-            return R.error("浣滀笟鍙疯濉啓");
-        }
-        if (rgvStaNo == null || rgvStaNo == 0){
+        if (rgvStaNoPut == null || rgvStaNoPut == 0){
             return R.error("鐩爣绔欑偣璇峰~鍐�");
         }
         RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo);
@@ -150,10 +173,15 @@
                 return R.error("瀛樺湪鎵ц涓换鍔★紝璇峰厛澶勭悊锛侊紒锛�");
             }
 
-            BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNo));
+            BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNoPut));
+            if (Cools.isEmpty(basDevpPosition)){
+                return R.error("鐩爣绔欑偣涓嶅瓨鍦�");
+            }
             //鎵ц
             issuedPut.setTaskNo(Long.valueOf(taskNo));
             issuedPut.setTaskStatus(3);
+            issuedPut.setTargetPositionStaNo(basDevpPosition.getDevNo());
+            issuedPut.setTargetPositionStaNoPlcId(basDevpPosition.getPlcId());
             issuedPut.setTaskNoDirection(issuedPut.gettaskNoDirection$(issuedPut.getTaskNo(), issuedPut.getTaskStatus()));
             issuedPut.setTargetPosition(basDevpPosition.getPlcPosition());
             issuedPut.setIsRunning(1);
@@ -170,18 +198,15 @@
     @PostMapping("/run/take")//Take  Put  Walk
     @ManagerAuth(memo = "灏忚溅鍙栬揣")
     public R rgvTakeWalk(@RequestParam(defaultValue = "0") Integer rgvNo,
-                        @RequestParam(defaultValue = "0") Integer taskNo,
-                        @RequestParam(defaultValue = "0") Integer rgvStaNo,
+                        @RequestParam(defaultValue = "9999") Integer taskNo,
+                        @RequestParam(defaultValue = "0") Integer rgvStaNoTake,
                         @RequestParam(defaultValue = "0") Long rgvPosDestination
     ) {
         if (rgvNo==null || rgvNo==0){
             return R.error("璇烽�夋嫨灏忚溅");
         }
-        if (taskNo==null || taskNo==0){
-            return R.error("浣滀笟鍙疯濉啓");
-        }
-        if (rgvStaNo == null || rgvStaNo == 0){
-            return R.error("鐩爣绔欑偣璇峰~鍐�");
+        if (rgvStaNoTake == null || rgvStaNoTake == 0){
+            return R.error("鍙栬揣绔欑偣璇峰~鍐�");
         }
         RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo);
         TaskProtocolCache taskProtocolCache = rgvThread.getTaskProtocolCache();
@@ -193,10 +218,15 @@
                 return R.error("瀛樺湪鎵ц涓换鍔★紝璇峰厛澶勭悊锛侊紒锛�");
             }
 
-            BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNo));
+            BasDevpPosition basDevpPosition = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNoTake));
+            if (Cools.isEmpty(basDevpPosition)){
+                return R.error("鍙栬揣绔欑偣涓嶅瓨鍦�");
+            }
             //鎵ц
             issuedTake.setTaskNo(Long.valueOf(taskNo));
             issuedTake.setTaskStatus(2);
+            issuedTake.setTargetPositionStaNo(basDevpPosition.getDevNo());
+            issuedTake.setTargetPositionStaNoPlcId(basDevpPosition.getPlcId());
             issuedTake.setTaskNoDirection(issuedTake.gettaskNoDirection$(issuedTake.getTaskNo(), issuedTake.getTaskStatus()));
             issuedTake.setTargetPosition(basDevpPosition.getPlcPosition());
             issuedTake.setIsRunning(1);
@@ -209,4 +239,88 @@
 
         return R.ok("浠诲姟鐢熸垚鎴愬姛");
     }
+
+    @PostMapping("/run/TakeAndPut")//Take  Put  Walk
+    @ManagerAuth(memo = "灏忚溅鍙栬揣")
+    public R rgvTakeAndPut(@RequestParam(defaultValue = "0") Integer rgvNo,
+                         @RequestParam(defaultValue = "9999") Integer taskNo,
+                         @RequestParam(defaultValue = "0") Integer rgvStaNoTake,
+                         @RequestParam(defaultValue = "0") Integer rgvStaNoPut,
+                         @RequestParam(defaultValue = "0") Long rgvPosDestination
+    ) {
+        if (rgvNo==null || rgvNo==0){
+            return R.error("璇烽�夋嫨灏忚溅");
+        }
+        if (rgvStaNoTake == null || rgvStaNoTake == 0){
+            return R.error("鍙栬揣绔欑偣璇峰~鍐�");
+        }
+        if (rgvStaNoPut == null || rgvStaNoPut == 0){
+            return R.error("鏀捐揣绔欑偣璇峰~鍐�");
+        }
+        RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo);
+        TaskProtocolCache taskProtocolCache = rgvThread.getTaskProtocolCache();
+
+        TaskProtocol issuedTake = new TaskProtocol();
+        TaskProtocol issuedPut = new TaskProtocol();
+        try {
+            ConcurrentHashMap<String, TaskProtocol> allTaskProtocol = taskProtocolCache.getAllTaskProtocol();
+            if (allTaskProtocol.size() > 0) {
+                return R.error("瀛樺湪鎵ц涓换鍔★紝璇峰厛澶勭悊锛侊紒锛�");
+            }
+
+            BasDevpPosition basDevpPositionTake = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNoTake));
+            if (Cools.isEmpty(basDevpPositionTake)){
+                return R.error("鍙栬揣绔欑偣涓嶅瓨鍦�");
+            }
+            //鎵ц
+            issuedTake.setTaskNo(Long.valueOf(taskNo));
+            issuedTake.setTaskStatus(2);
+            issuedTake.setTargetPositionStaNo(basDevpPositionTake.getDevNo());
+            issuedTake.setTargetPositionStaNoPlcId(basDevpPositionTake.getPlcId());
+            issuedTake.setTaskNoDirection(issuedTake.gettaskNoDirection$(issuedTake.getTaskNo(), issuedTake.getTaskStatus()));
+            issuedTake.setTargetPosition(basDevpPositionTake.getPlcPosition());
+            issuedTake.setIsRunning(1);
+            issuedTake.setDirection(basDevpPositionTake.getRgvSign()==1);
+
+            BasDevpPosition basDevpPositionPut = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStaNoPut));
+            if (Cools.isEmpty(basDevpPositionPut)){
+                return R.error("鐩爣绔欑偣涓嶅瓨鍦�");
+            }
+            //鎵ц
+            issuedPut.setTaskNo(Long.valueOf(taskNo));
+            issuedPut.setTaskStatus(3);
+            issuedPut.setTargetPositionStaNo(basDevpPositionPut.getDevNo());
+            issuedPut.setTargetPositionStaNoPlcId(basDevpPositionPut.getPlcId());
+            issuedPut.setTaskNoDirection(issuedPut.gettaskNoDirection$(issuedPut.getTaskNo(), issuedPut.getTaskStatus()));
+            issuedPut.setTargetPosition(basDevpPositionPut.getPlcPosition());
+            issuedPut.setIsRunning(1);
+            issuedPut.setDirection(basDevpPositionPut.getRgvSign()==1);
+
+            taskProtocolCache.updateTaskProtocol(issuedTake);
+            taskProtocolCache.updateTaskProtocol(issuedPut);
+
+        } catch (Exception e) {
+            return R.error("浠诲姟鐢熸垚澶辫触"+e.getMessage());
+        }
+
+        return R.ok("浠诲姟鐢熸垚鎴愬姛");
+    }
+
+    @PostMapping("/run/delRgvTask")//Take  Put  Walk
+    @ManagerAuth(memo = "灏忚溅鍙栬揣")
+    public R rgvDelRgvTask(@RequestParam(defaultValue = "0") Integer rgvNo
+    ) {
+        if (rgvNo==null || rgvNo==0){
+            return R.error("璇烽�夋嫨灏忚溅");
+        }
+
+        try {
+            RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvNo);
+            rgvThread.setDelRgvTask();
+        } catch (Exception e) {
+            return R.error("浠诲姟鐢熸垚澶辫触"+e.getMessage());
+        }
+
+        return R.ok("浠诲姟鐢熸垚鎴愬姛");
+    }
 }

--
Gitblit v1.9.1