From 53a71007458bdded764dc52a39d596f8c4ca28db Mon Sep 17 00:00:00 2001
From: DELL <DELL@qq.com>
Date: 星期四, 18 九月 2025 15:42:41 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/controller/OpenController.java |   95 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/zy/core/controller/OpenController.java b/src/main/java/com/zy/core/controller/OpenController.java
index 062a84c..7b23c25 100644
--- a/src/main/java/com/zy/core/controller/OpenController.java
+++ b/src/main/java/com/zy/core/controller/OpenController.java
@@ -1,28 +1,111 @@
 package com.zy.core.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.zy.common.R;
 import com.zy.core.cache.SlaveConnection;
 import com.zy.core.enums.SlaveType;
 import com.zy.core.model.param.AddFakeDeviceParam;
 import com.zy.core.model.param.DeleteDeviceParam;
+import com.zy.core.model.param.GetFakeThreadStatusParam;
+import com.zy.core.model.param.UpdateFakeThreadStatusParam;
 import com.zy.core.properties.DeviceConfig;
+import com.zy.core.thread.FakeThread;
+import com.zy.core.thread.ForkLiftThread;
+import com.zy.core.thread.LiftThread;
 import com.zy.core.thread.ShuttleThread;
 import com.zy.core.utils.DeviceMsgUtils;
 import com.zy.core.utils.FakeDeviceUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
 
 @RestController
 @RequestMapping("/open")
 public class OpenController {
 
+    @Value("${deviceMsgConfig.gatewayId}")
+    private Integer gatewayId;
+    @Value("${deviceMsgConfig.gatewayPort}")
+    private Integer gatewayPort;
+
     @Autowired
     private DeviceMsgUtils deviceMsgUtils;
     @Autowired
     private FakeDeviceUtils fakeDeviceUtils;
+
+    @GetMapping("/getSystemInfo")
+    public R getSystemInfo() {
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("gatewayId", gatewayId);
+        map.put("gatewayPort", gatewayPort);
+        return R.ok().add(map);
+    }
+
+    @PostMapping("/updateFakeThreadStatus")
+    public R updateFakeThreadStatus(@RequestBody UpdateFakeThreadStatusParam param) {
+        FakeThread fakeThread = null;
+        if (param.getDeviceType().equals(String.valueOf(SlaveType.Shuttle))) {
+            fakeThread = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 1);
+        } else if (param.getDeviceType().equals(String.valueOf(SlaveType.ForkLift))) {
+            fakeThread = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 2);
+        } else if (param.getDeviceType().equals(String.valueOf(SlaveType.Lift))) {
+            fakeThread = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 3);
+        }
+
+        if (fakeThread == null) {
+            return R.error("鎵句笉鍒拌澶囩嚎绋�");
+        }
+
+        boolean result = fakeThread.updateFakeStatus(param);
+        if (result) {
+            return R.ok();
+        }
+        return R.error("鏇存柊澶辫触");
+    }
+
+    @PostMapping("/getFakeThreadStatus")
+    public R getFakeThreadStatus(@RequestBody GetFakeThreadStatusParam param) {
+        FakeThread fakeThread = null;
+        if (param.getDeviceType().equals(String.valueOf(SlaveType.Shuttle))) {
+            fakeThread = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 1);
+        } else if (param.getDeviceType().equals(String.valueOf(SlaveType.ForkLift))) {
+            fakeThread = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 2);
+        } else if (param.getDeviceType().equals(String.valueOf(SlaveType.Lift))) {
+            fakeThread = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 3);
+        }
+
+        if (fakeThread == null) {
+            return R.error("鎵句笉鍒拌澶囩嚎绋�");
+        }
+
+        ConcurrentHashMap<String, JSONObject> fakeStatusMap = fakeThread.getFakeStatusMap();
+
+        String key = param.getDeviceType() + param.getDeviceNo();
+        JSONObject result = fakeStatusMap.get(key);
+        if (result == null) {
+            return R.error("鏁版嵁涓嶅瓨鍦�");
+        }
+        return R.ok().add(result);
+    }
+
+    @GetMapping("/getFakeThreadStatusList")
+    public R getFakeThreadStatusList() {
+        FakeThread fakeThread1 = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 1);
+        FakeThread fakeThread2 = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 2);
+        FakeThread fakeThread3 = (FakeThread) SlaveConnection.get(SlaveType.FakeThread, 3);
+
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("fakeNyShuttleStatusMap", fakeThread1.getFakeStatusMap());
+        map.put("fakeZyForkLiftStatusMap", fakeThread2.getFakeStatusMap());
+        map.put("fakeNyLiftStatusMap", fakeThread3.getFakeStatusMap());
+        return R.ok().add(map);
+    }
 
     @GetMapping("/getDeviceList")
     public R getDeviceList() {
@@ -48,6 +131,18 @@
                     continue;
                 }
                 deviceList.add(shuttleThread.getDeviceConfig());
+            } else if (slaveType.equals(SlaveType.ForkLift)) {
+                ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(slaveType, config.getDeviceNo());
+                if(forkLiftThread == null){
+                    continue;
+                }
+                deviceList.add(forkLiftThread.getDeviceConfig());
+            } else if (slaveType.equals(SlaveType.Lift)) {
+                LiftThread liftThread = (LiftThread) SlaveConnection.get(slaveType, config.getDeviceNo());
+                if(liftThread == null){
+                    continue;
+                }
+                deviceList.add(liftThread.getDeviceConfig());
             }
         }
 

--
Gitblit v1.9.1