From bb8842f772baf2bd782e3ffd6cc5640950a62983 Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期二, 06 二月 2024 16:02:40 +0800
Subject: [PATCH] 输送线改造

---
 src/main/java/com/zy/common/web/WcsController.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/zy/common/web/WcsController.java b/src/main/java/com/zy/common/web/WcsController.java
index 89b6f8c..6ccd5fe 100644
--- a/src/main/java/com/zy/common/web/WcsController.java
+++ b/src/main/java/com/zy/common/web/WcsController.java
@@ -20,8 +20,10 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -32,6 +34,8 @@
 @RestController
 @RequestMapping("/rpc")
 public class WcsController {
+
+    private static HashMap<String,String> currentContainerMap;
 
     @Autowired
     private WrkMastService wrkMastService;
@@ -614,15 +618,66 @@
 
     }
 
+    @PostMapping("/current/containerCode")
+    @ResponseBody
+    public R move(@RequestBody ReplenishmentParam param){
+
+        if(Cools.isEmpty(currentContainerMap)){
+            currentContainerMap = new HashMap<>();
+        }
+
+        String devNo = param.getDevNo();
+        String containerCode = param.getContainerCode();
+        String currentContainerCode = currentContainerMap.get(devNo);
+
+        //鍒ゆ柇瀹瑰櫒鏄惁鍙戠敓鍙樺寲
+        if(!Cools.eq(containerCode,currentContainerCode)){
+            //鏌ヨ鏃у鍣ㄧ殑宸ヤ綔妗�
+            AgvWrkMast agvWrkMast = agvWrkMastService.selectByContainerCode(currentContainerCode);
+            if(agvWrkMast.getIoType() == 101){
+                //鍙戦�佸鍣ㄧ珛鍦鸿姹傦紝瀹屾垚宸ヤ綔妗�
+                List<AgvWrkMast> agvWrkMastList = new ArrayList<>();
+                agvWrkMastList.add(agvWrkMast);
+                try {
+                    int code = agvWrkMastService.containerMoveOut(agvWrkMastList);
+                    if(code == 0){
+                        //灏嗗伐浣滃厷鐘舵�佹敼涓哄鍣ㄧ鍦�
+                        agvWrkMast.setWrkSts(206L);
+                        agvWrkMastService.updateById(agvWrkMast);
+                    }
+                } catch (IOException e) {
+                    log.error(e.getMessage());
+                }
+            }
+        }
+
+        currentContainerMap.put(devNo,containerCode);
+
+        return R.ok();
+    }
+
     /*
     鏄剧ずAGV杈撻�佺嚎鎷f枡銆佺洏鐐广�佸叆搴撲俊鎭�
      */
     @PostMapping("/info")
     @ResponseBody
-    public R showAgvBasDevInfo(@RequestBody ReplenishmentParam param){
+    public R containerMove(@RequestBody ReplenishmentParam param){
 
+        String devNo = param.getDevNo();
+        String containerCode = currentContainerMap.get(devNo);
 
-        return R.ok();
+        //鏌ユ壘璇ュ鍣ㄧ殑宸ヤ綔妗�
+        AgvWrkMast agvWrkMast = agvWrkMastService.selectByContainerCode(containerCode);
+        if(!Cools.isEmpty(agvWrkMast)){
+            return R.ok(agvWrkMast);
+        }
+        //鏌ユ壘璇ュ鍣ㄧ殑鍏ュ簱閫氱煡妗�
+        AgvWaitPakin agvWaitPakin = agvWaitPakinService.selectByContainerCode(containerCode);
+        if(!Cools.isEmpty(agvWaitPakin)){
+            return R.ok(agvWaitPakin);
+        }
+
+        return R.error("娌℃湁璇ュ鍣ㄧ殑鍑哄簱銆佹嫞鏂欍�佸叆搴撲俊鎭瓑");
     }
 
 

--
Gitblit v1.9.1