From 253e9b3735533c4d8c69cf5e6983d5fa1e984ae9 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期五, 05 十二月 2025 12:34:41 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/controller/OpenController.java |  239 +++++++++++++----------------------------------------------
 1 files changed, 54 insertions(+), 185 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index a207073..730403a 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -22,8 +22,10 @@
 import com.zy.core.enums.SlaveType;
 import com.zy.core.enums.WrkIoType;
 import com.zy.core.model.protocol.ForkLiftProtocol;
+import com.zy.core.model.protocol.LiftProtocol;
 import com.zy.core.model.protocol.ShuttleProtocol;
 import com.zy.core.thread.ForkLiftThread;
+import com.zy.core.thread.LiftThread;
 import com.zy.core.thread.ShuttleThread;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,22 +63,6 @@
             return R.error("鍙傛暟涓嶈兘涓虹┖");
         }
         boolean dispatchShuttle = shuttleDispatchUtils.dispatchShuttle(null, param.getLocNo(), param.getShuttleNo());
-        apiLogService.insert(new ApiLog(
-                null
-                , "灏忚溅绉诲姩浠诲姟"
-                , "/createMoveTask"
-                , null
-                , null
-                , null
-                , JSON.toJSONString(param)
-                , null
-                , null
-                , dispatchShuttle ? 1 : 0
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
         if (dispatchShuttle) {
             return R.ok();
         }
@@ -91,22 +77,6 @@
             return R.error("鍙傛暟涓嶈兘涓虹┖");
         }
         boolean result = commonService.createLocMoveTask(param);
-        apiLogService.insert(new ApiLog(
-                null
-                , "绉诲簱浠诲姟"
-                , "/createLocMoveTask"
-                , null
-                , null
-                , null
-                , JSON.toJSONString(param)
-                , null
-                , null
-                , result ? 1 : 0
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
         if (result) {
             return R.ok();
         }
@@ -116,27 +86,11 @@
     //鍏ュ簱浠诲姟
     @PostMapping("/createInTask")
     @OpenApiLog(memo = "鍏ュ簱浠诲姟")
-    public R createInTask(@RequestBody CreateInTaskParam param) {
+    public synchronized R createInTask(@RequestBody CreateInTaskParam param) {
         if (param == null) {
             return R.error("鍙傛暟涓嶈兘涓虹┖");
         }
         boolean result = commonService.createInTask(param);
-        apiLogService.insert(new ApiLog(
-                null
-                , "鍏ュ簱浠诲姟"
-                , "/createInTask"
-                , null
-                , null
-                , null
-                , JSON.toJSONString(param)
-                , null
-                , null
-                , result ? 1 : 0
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
         if (result) {
             return R.ok();
         }
@@ -146,27 +100,11 @@
     //鍑哄簱浠诲姟
     @PostMapping("/createOutTask")
     @OpenApiLog(memo = "鍑哄簱浠诲姟")
-    public R createOutTask(@RequestBody CreateOutTaskParam param) {
+    public synchronized R createOutTask(@RequestBody CreateOutTaskParam param) {
         if (param == null) {
             return R.error("鍙傛暟涓嶈兘涓虹┖");
         }
         boolean result = commonService.createOutTask(param);
-        apiLogService.insert(new ApiLog(
-                null
-                , "鍑哄簱浠诲姟"
-                , "/createOutTask"
-                , null
-                , null
-                , null
-                , JSON.toJSONString(param)
-                , null
-                , null
-                , result ? 1 : 0
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
         if (result) {
             return R.ok();
         }
@@ -180,22 +118,6 @@
             return R.error("鍙傛暟涓嶈兘涓虹┖");
         }
         boolean completeTask = commonService.completeTask(param);
-        apiLogService.insert(new ApiLog(
-                null
-                , "浠诲姟瀹屾垚"
-                , "/completeTask"
-                , null
-                , null
-                , null
-                , JSON.toJSONString(param)
-                , null
-                , null
-                , completeTask ? 1 : 0
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
         if (completeTask) {
             return R.ok();
         }
@@ -209,30 +131,14 @@
             return R.error("鍙傛暟涓嶈兘涓虹┖");
         }
         boolean completeTask = commonService.cancelTask(param);
-        apiLogService.insert(new ApiLog(
-                null
-                , "浠诲姟鍙栨秷"
-                , "/cancelTask"
-                , null
-                , null
-                , null
-                , JSON.toJSONString(param)
-                , null
-                , null
-                , completeTask ? 1 : 0
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
         if (completeTask) {
             return R.ok();
         }
         return R.error("浠诲姟鍙栨秷澶辫触");
     }
 
-    @PostMapping("/deviceStatus")
-    @OpenApiLog(memo = "鑾峰彇璁惧鐘舵��")
+    @RequestMapping("/deviceStatus")
+//    @OpenApiLog(memo = "鑾峰彇璁惧鐘舵��")
     public R getDeviceStatus() {
         HashMap<String, Object> map = new HashMap<>();
         //鑾峰彇灏忚溅鏁版嵁
@@ -269,25 +175,45 @@
             forkLiftProtocols.add(forkLiftProtocol);
         }
 
+        //鑾峰彇鎻愬崌鏈烘暟鎹�
+        ArrayList<LiftProtocol> liftProtocols = new ArrayList<>();
+        List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+                .eq("device_type", String.valueOf(SlaveType.Lift)));
+        for (DeviceConfig device : liftList) {
+            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo());
+            if (liftThread == null) {
+                continue;
+            }
+
+            LiftProtocol liftProtocol = liftThread.getStatus();
+            if (liftProtocol == null) {
+                continue;
+            }
+            liftProtocols.add(liftProtocol);
+        }
+
         map.put("shuttle", shuttleProtocols);
         map.put("forkLift", forkLiftProtocols);
+        map.put("lift", liftProtocols);
 
-        apiLogService.insert(new ApiLog(
-                null
-                , "鑾峰彇璁惧鐘舵��"
-                , "/deviceStatus"
-                , null
-                , null
-                , null
-                , null
-                , JSON.toJSONString(map)
-                , null
-                , null
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
+        return R.ok().add(map);
+    }
+
+    @RequestMapping("/liftDeviceOriginData")
+    public R getLiftDeviceOriginData() {
+        HashMap<Integer, String> map = new HashMap<>();
+
+        //鑾峰彇鎻愬崌鏈烘暟鎹�
+        List<DeviceConfig> liftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+                .eq("device_type", String.valueOf(SlaveType.Lift)));
+        for (DeviceConfig device : liftList) {
+            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getDeviceNo());
+            if (liftThread == null) {
+                continue;
+            }
+
+            map.put(device.getDeviceNo(), liftThread.getRealtimeOriginData());
+        }
 
         return R.ok().add(map);
     }
@@ -306,23 +232,6 @@
         HashMap<String, Object> map = new HashMap<>();
         map.put("locNo", locMast.getLocNo());
         map.put("locSts", locMast.getLocSts());
-
-        apiLogService.insert(new ApiLog(
-                null
-                , "鑾峰彇鎸囧畾搴撲綅淇℃伅"
-                , "/getLocInformation"
-                , null
-                , null
-                , null
-                , JSON.toJSONString(param)
-                , JSON.toJSONString(map)
-                , null
-                , null
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
 
         return R.ok().add(map);
     }
@@ -343,23 +252,6 @@
             list.add(map);
         }
 
-        apiLogService.insert(new ApiLog(
-                null
-                , "鑾峰彇鍏ㄩ儴搴撲綅淇℃伅"
-                , "/getAllLocInformation"
-                , null
-                , null
-                , null
-                , null
-                , JSON.toJSONString(list)
-                , null
-                , null
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
-
         return R.ok().add(list);
     }
 
@@ -367,25 +259,14 @@
     @OpenApiLog(memo = "灏忚溅闆嗗悎")
     public R shuttleGather(@RequestBody ShuttleGatherParam param) {
         List<ShuttleGatherResult> shuttleGather = shuttleDispatchUtils.shuttleGather(param);
-
-        apiLogService.insert(new ApiLog(
-                null
-                , "灏忚溅闆嗗悎"
-                , "/shuttleGather"
-                , null
-                , null
-                , null
-                , null
-                , JSON.toJSONString(shuttleGather)
-                , null
-                , null
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
-
         return R.ok().add(shuttleGather);
+    }
+
+    @PostMapping("/shuttleDemo")
+    @OpenApiLog(memo = "灏忚溅婕旂ず")
+    public R shuttleDemo(@RequestBody ShuttleDemoParam param) {
+        shuttleDispatchUtils.shuttleDemo(param);
+        return R.ok();
     }
 
     @PostMapping("/queryTask")
@@ -404,26 +285,14 @@
             wrapper.eq("io_type", ioType.id);
         }
         List<WrkMast> wrkMasts = wrkMastService.selectList(wrapper);
-        apiLogService.insert(new ApiLog(
-                null
-                , "鏌ヨ浠诲姟"
-                , "/queryTask"
-                , null
-                , null
-                , null
-                , null
-                , JSON.toJSONString(wrkMasts)
-                , null
-                , null
-                , 1
-                , new Date()
-                , null
-                , null
-        ));
-
         return R.ok().add(wrkMasts);
     }
 
+    @GetMapping("/systemStatus")
+    public R systemStatus() {
+        return R.ok();
+    }
+
     @GetMapping("/test")
     public R test() {
         notifyUtils.notify("task", 1, "9999", "W9999", NotifyMsgType.SHUTTLE_MOVING, "data");

--
Gitblit v1.9.1