From a757961fc5b8f5ee5b79cc30615bd22d321d0d72 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 05 七月 2025 17:01:46 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/controller/OpenController.java      |   86 +++++++
 src/main/java/com/zy/core/thread/impl/NyShuttleThread.java    |  114 +++++++--
 src/main/java/com/zy/core/utils/FakeDeviceUtils.java          |  135 ++++++++++++
 src/main/java/com/zy/core/properties/DeviceConfig.java        |    2 
 src/main/java/com/zy/core/thread/ShuttleThread.java           |    7 
 src/main/webapp/views/index.html                              |  242 ++++++++++++++-------
 src/main/java/com/zy/core/model/param/AddFakeDeviceParam.java |   18 +
 src/main/java/com/zy/core/enums/RedisKeyType.java             |   14 -
 src/main/webapp/static/js/common.js                           |    2 
 src/main/java/com/zy/core/model/param/DeleteDeviceParam.java  |   12 +
 src/main/java/com/zy/core/ServerBootstrap.java                |   19 +
 11 files changed, 528 insertions(+), 123 deletions(-)

diff --git a/src/main/java/com/zy/core/ServerBootstrap.java b/src/main/java/com/zy/core/ServerBootstrap.java
index 35a6250..b2a3c33 100644
--- a/src/main/java/com/zy/core/ServerBootstrap.java
+++ b/src/main/java/com/zy/core/ServerBootstrap.java
@@ -10,6 +10,7 @@
 import com.zy.core.thread.impl.LfdZyForkLiftMasterThread;
 import com.zy.core.thread.impl.NyShuttleThread;
 import com.zy.core.utils.DeviceMsgUtils;
+import com.zy.core.utils.FakeDeviceUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
@@ -30,6 +31,8 @@
     private RedisUtil redisUtil;
     @Autowired
     private DeviceMsgUtils deviceMsgUtils;
+    @Autowired
+    private FakeDeviceUtils fakeDeviceUtils;
 
 
     @PostConstruct
@@ -41,6 +44,8 @@
         initMq();
         // 鍒濆鍖栦笅浣嶆満绾跨▼
         initThread();
+        // 鍒濆鍖栬櫄鎷熻澶囩嚎绋�
+        initFakeThread();
         News.info("鏍稿績鎺у埗灞傚凡鍚姩...............................................");
     }
 
@@ -79,6 +84,20 @@
         }
     }
 
+    private void initFakeThread(){
+        String fakeDeviceConfig = fakeDeviceUtils.getFakeDeviceConfig();
+        if(null != fakeDeviceConfig){
+            List<DeviceConfig> deviceConfigs = JSON.parseArray(fakeDeviceConfig, DeviceConfig.class);
+            for (DeviceConfig device : deviceConfigs) {
+                if (device.getDeviceType().equals(String.valueOf(SlaveType.ForkLift))) {
+                    initForkLiftThread(device);
+                } else if (device.getDeviceType().equals(String.valueOf(SlaveType.Shuttle))) {
+                    initShuttleThread(device);
+                }
+            }
+        }
+    }
+
 
     @PreDestroy
     public void destroy() {
diff --git a/src/main/java/com/zy/core/controller/OpenController.java b/src/main/java/com/zy/core/controller/OpenController.java
new file mode 100644
index 0000000..37b025a
--- /dev/null
+++ b/src/main/java/com/zy/core/controller/OpenController.java
@@ -0,0 +1,86 @@
+package com.zy.core.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.zy.common.R;
+import com.zy.core.News;
+import com.zy.core.ThreadHandler;
+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.properties.DeviceConfig;
+import com.zy.core.thread.ForkLiftThread;
+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.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RestController
+@RequestMapping("/open")
+public class OpenController {
+
+    @Autowired
+    private DeviceMsgUtils deviceMsgUtils;
+    @Autowired
+    private FakeDeviceUtils fakeDeviceUtils;
+
+    @GetMapping("/getDeviceList")
+    public R getDeviceList() {
+        List<DeviceConfig> deviceList = new ArrayList<>();
+
+        List<DeviceConfig> configList = new ArrayList<>();
+        String deviceConfig = deviceMsgUtils.getDeviceConfig();
+        if(null != deviceConfig){
+            List<DeviceConfig> deviceConfigs = JSON.parseArray(deviceConfig, DeviceConfig.class);
+            configList.addAll(deviceConfigs);
+        }
+
+        String fakeDeviceConfig = fakeDeviceUtils.getFakeDeviceConfig();
+        if(null != fakeDeviceConfig){
+            List<DeviceConfig> deviceConfigs = JSON.parseArray(fakeDeviceConfig, DeviceConfig.class);
+            configList.addAll(deviceConfigs);
+        }
+
+        for (DeviceConfig config : configList) {
+            SlaveType slaveType = SlaveType.findInstance(config.getDeviceType());
+            if(slaveType == null){
+                continue;
+            }
+
+            if(slaveType.equals(SlaveType.Shuttle)) {
+                ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(slaveType, config.getDeviceNo());
+                if(shuttleThread == null){
+                    continue;
+                }
+                deviceList.add(shuttleThread.getDeviceConfig());
+            }
+        }
+
+        return R.ok().add(deviceList);
+    }
+
+    @PostMapping("/addFakeDevice")
+    public R addFakeDevice(@RequestBody AddFakeDeviceParam param) {
+        DeviceConfig deviceConfig = new DeviceConfig();
+        deviceConfig.setDeviceNo(param.getDeviceNo());
+        deviceConfig.setIp(param.getIp());
+        deviceConfig.setPort(param.getPort());
+        deviceConfig.setDeviceType(param.getDeviceType());
+        deviceConfig.setThreadImpl(param.getThreadImpl());
+        deviceConfig.setFake(true);
+
+        fakeDeviceUtils.addFakeDevice(deviceConfig);
+        return R.ok();
+    }
+
+    @PostMapping("/deleteFakeDevice")
+    public R deleteFakeDevice(@RequestBody DeleteDeviceParam param) {
+        fakeDeviceUtils.deleteFakeDevice(param.getDeviceNo(), param.getDeviceType());
+        return R.ok();
+    }
+
+}
diff --git a/src/main/java/com/zy/core/enums/RedisKeyType.java b/src/main/java/com/zy/core/enums/RedisKeyType.java
index 0ac7ce7..16e7065 100644
--- a/src/main/java/com/zy/core/enums/RedisKeyType.java
+++ b/src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -2,18 +2,6 @@
 
 public enum RedisKeyType {
 
-    SHUTTLE_WORK_FLAG("shuttle_wrk_no_"),
-    SHUTTLE_FLAG("shuttle_"),
-    FORK_LIFT_WORK_FLAG("fork_lift_wrk_no_"),
-    FORK_LIFT_FLAG("fork_lift_"),
-    MAP("realtimeBasMap_"),
-    BASIC_MAP("basicMap_"),
-    QUEUE_SHUTTLE("queue_shuttle_"),
-    QUEUE_FORK_LIFT("queue_fork_lift_"),
-    QUEUE_TASK("queue_task_"),
-    FORK_LIFT_PUT_COMPLETE("fork_lift_put_complete_"),
-    OUT_TASK_PREVIEW_DISPATCH_FORKLIFT("out_task_preview_dispatch_forklift_"),
-
     //璁惧娑堟伅KEY
     DEVICE_SHUTTLE_MSG_KEY_("deviceShuttleMsgKey_"),
     DEVICE_FORK_LIFT_MSG_KEY_("deviceForkLiftMsgKey_"),
@@ -24,6 +12,8 @@
 
     //璁惧閰嶇疆鏂囦欢
     DEVICE_CONFIG("deviceConfig"),
+    //铏氭嫙璁惧閰嶇疆鏂囦欢
+    FAKE_DEVICE_CONFIG("fakeDeviceConfig"),
     ;
 
     public String key;
diff --git a/src/main/java/com/zy/core/model/param/AddFakeDeviceParam.java b/src/main/java/com/zy/core/model/param/AddFakeDeviceParam.java
new file mode 100644
index 0000000..c5c0b7c
--- /dev/null
+++ b/src/main/java/com/zy/core/model/param/AddFakeDeviceParam.java
@@ -0,0 +1,18 @@
+package com.zy.core.model.param;
+
+import lombok.Data;
+
+@Data
+public class AddFakeDeviceParam {
+
+    private Integer deviceNo;
+
+    private String ip;
+
+    private Integer port;
+
+    private String threadImpl;
+
+    private String deviceType;
+
+}
diff --git a/src/main/java/com/zy/core/model/param/DeleteDeviceParam.java b/src/main/java/com/zy/core/model/param/DeleteDeviceParam.java
new file mode 100644
index 0000000..d8d1b98
--- /dev/null
+++ b/src/main/java/com/zy/core/model/param/DeleteDeviceParam.java
@@ -0,0 +1,12 @@
+package com.zy.core.model.param;
+
+import lombok.Data;
+
+@Data
+public class DeleteDeviceParam {
+
+    private Integer deviceNo;
+
+    private String deviceType;
+
+}
diff --git a/src/main/java/com/zy/core/properties/DeviceConfig.java b/src/main/java/com/zy/core/properties/DeviceConfig.java
index 0b045d8..4961c2f 100644
--- a/src/main/java/com/zy/core/properties/DeviceConfig.java
+++ b/src/main/java/com/zy/core/properties/DeviceConfig.java
@@ -15,4 +15,6 @@
 
     private Integer deviceNo;
 
+    private Boolean fake = false;
+
 }
diff --git a/src/main/java/com/zy/core/thread/ShuttleThread.java b/src/main/java/com/zy/core/thread/ShuttleThread.java
index 1339028..693ccb0 100644
--- a/src/main/java/com/zy/core/thread/ShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/ShuttleThread.java
@@ -1,7 +1,14 @@
 package com.zy.core.thread;
 
 import com.zy.core.ThreadHandler;
+import com.zy.core.properties.DeviceConfig;
 
 public interface ShuttleThread extends ThreadHandler {
 
+    DeviceConfig getDeviceConfig();
+
+    boolean isFake();
+
+    void stopThread();
+
 }
diff --git a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
index 3296a6b..319e1e7 100644
--- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
@@ -15,10 +15,9 @@
 import com.zy.core.thread.ShuttleThread;
 import lombok.extern.slf4j.Slf4j;
 
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
+import java.io.*;
 import java.net.InetAddress;
+import java.net.ServerSocket;
 import java.net.Socket;
 import java.text.MessageFormat;
 import java.util.*;
@@ -30,12 +29,15 @@
     private DeviceConfig deviceConfig;
     private RedisUtil redisUtil;
     private Socket socket;
+    private ServerSocket serverSocket;
 
-    private static final boolean DEBUG = false;//璋冭瘯妯″紡
+    private boolean fake = false;
+    private boolean stopThread = false;
 
     public NyShuttleThread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
         this.deviceConfig = deviceConfig;
         this.redisUtil = redisUtil;
+        this.fake = deviceConfig.getFake();
     }
 
     @Override
@@ -46,7 +48,14 @@
         //鐩戝惉娑堟伅
         Thread innerThread = new Thread(() -> {
             while (true) {
+                if(stopThread) {
+                    break;
+                }
+
+                System.out.println("read");
+
                 try {
+                    Thread.sleep(200);
                     listenSocketMessage();
                 } catch (Exception e) {
                     e.printStackTrace();
@@ -58,6 +67,11 @@
         //鎵ц鎸囦护
         Thread executeThread = new Thread(() -> {
             while (true) {
+                if(stopThread) {
+                    break;
+                }
+
+                System.out.println("executeThread");
                 try {
                     DeviceMsgUtils deviceMsgUtils = null;
                     try {
@@ -79,6 +93,35 @@
             }
         });
         executeThread.start();
+
+        if (this.fake) {
+            Thread fakeThread = new Thread(() -> {
+                try {
+                    serverSocket = new ServerSocket(deviceConfig.getPort());
+
+                    while (true) {
+                        if(stopThread) {
+                            break;
+                        }
+
+                        System.out.println("fakeThread");
+                        Socket accept = serverSocket.accept();
+                        handleClient(accept);
+                    }
+                }catch (Exception e){
+                    e.printStackTrace();
+                }
+            });
+            fakeThread.start();
+        }
+    }
+
+    private void handleClient(Socket socket) throws IOException {
+        InputStream inputStream = socket.getInputStream();
+        OutputStream outputStream = socket.getOutputStream();
+        outputStream.write("test".getBytes());
+        outputStream.flush();
+        socket.close();
     }
 
     private void executeCommand(DeviceCommandMsgModel deviceCommandMsg) {
@@ -159,30 +202,6 @@
         }
     }
 
-    @Override
-    public boolean connect() {
-        try {
-            InetAddress address = InetAddress.getByName(deviceConfig.getIp());
-            if (address.isReachable(10000)) {
-                Socket socket = new Socket(deviceConfig.getIp(), deviceConfig.getPort());
-                socket.setSoTimeout(10000);
-                socket.setKeepAlive(true);
-                this.socket = socket;
-                log.info(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket閾炬帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
-            }
-        } catch (Exception e) {
-            OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket閾炬帴澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
-            return false;
-        }
-
-        return true;
-    }
-
-    @Override
-    public void close() {
-
-    }
-
     public JSONObject parseSocketResult(JSONObject data) {
         JSONObject device = new JSONObject();
 
@@ -231,4 +250,43 @@
         extend.put("countQuantity", data.getInteger("countQuantity"));
         return device;
     }
+
+    @Override
+    public boolean connect() {
+        try {
+            InetAddress address = InetAddress.getByName(deviceConfig.getIp());
+            if (address.isReachable(10000)) {
+                Socket socket = new Socket(deviceConfig.getIp(), deviceConfig.getPort());
+                socket.setSoTimeout(10000);
+                socket.setKeepAlive(true);
+                this.socket = socket;
+                log.info(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket閾炬帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
+            }
+        } catch (Exception e) {
+            OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket閾炬帴澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public void close() {
+
+    }
+
+    @Override
+    public DeviceConfig getDeviceConfig() {
+        return this.deviceConfig;
+    }
+
+    @Override
+    public void stopThread() {
+        this.stopThread = true;
+    }
+
+    @Override
+    public boolean isFake() {
+        return this.fake;
+    }
 }
diff --git a/src/main/java/com/zy/core/utils/FakeDeviceUtils.java b/src/main/java/com/zy/core/utils/FakeDeviceUtils.java
new file mode 100644
index 0000000..27d6d9f
--- /dev/null
+++ b/src/main/java/com/zy/core/utils/FakeDeviceUtils.java
@@ -0,0 +1,135 @@
+package com.zy.core.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.zy.common.R;
+import com.zy.common.exception.CoolException;
+import com.zy.common.utils.RedisUtil;
+import com.zy.core.ThreadHandler;
+import com.zy.core.cache.SlaveConnection;
+import com.zy.core.enums.RedisKeyType;
+import com.zy.core.enums.SlaveType;
+import com.zy.core.properties.DeviceConfig;
+import com.zy.core.thread.ForkLiftThread;
+import com.zy.core.thread.ShuttleThread;
+import com.zy.core.thread.impl.LfdZyForkLiftMasterThread;
+import com.zy.core.thread.impl.NyShuttleThread;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Component
+public class FakeDeviceUtils {
+
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private DeviceMsgUtils deviceMsgUtils;
+
+    public String getFakeDeviceConfig() {
+        Object obj = redisUtil.get(RedisKeyType.FAKE_DEVICE_CONFIG.key);
+        if(null == obj){
+            return null;
+        }
+        return obj.toString();
+    }
+
+    public void addFakeDevice(DeviceConfig deviceConfig) {
+        if (deviceConfig.getDeviceType().equals(String.valueOf(SlaveType.Shuttle))) {
+            addShuttleFakeDevice(deviceConfig);
+        } else if (deviceConfig.getDeviceType().equals(String.valueOf(SlaveType.ForkLift))) {
+            addForkLiftFakeDevice(deviceConfig);
+        }
+    }
+
+    public void deleteFakeDevice(Integer deviceNo, String deviceType) {
+        SlaveType slaveType = SlaveType.findInstance(deviceType);
+        if(slaveType == null){
+            throw new CoolException("璁惧绫诲瀷涓嶅瓨鍦�");
+        }
+
+        if (slaveType.equals(SlaveType.Shuttle)) {
+            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(slaveType, deviceNo);
+            if(shuttleThread == null){
+                throw new CoolException("璁惧绾跨▼涓嶅瓨鍦�");
+            }
+
+            if (!shuttleThread.isFake()) {
+                throw new CoolException("涓嶅厑璁稿垹闄ょ湡瀹炶澶囩嚎绋�");
+            }
+
+            shuttleThread.stopThread();
+        }
+
+        SlaveConnection.remove(slaveType, deviceNo);
+        delFakeDeviceToRedis(deviceNo, deviceType);
+    }
+
+    public void addShuttleFakeDevice(DeviceConfig deviceConfig) {
+        ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, deviceConfig.getDeviceNo());
+        if (shuttleThread != null) {
+            throw new CoolException("璁惧宸插瓨鍦�");
+        }
+
+        ThreadHandler thread = null;
+        if (deviceConfig.getThreadImpl().equals("NyShuttleThread")) {
+            thread = new NyShuttleThread(deviceConfig, redisUtil);
+        } else {
+            throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
+        }
+
+        new Thread(thread).start();
+        SlaveConnection.put(SlaveType.Shuttle, deviceConfig.getDeviceNo(), thread);
+        addFakeDeviceToRedis(deviceConfig);
+    }
+
+    public void addForkLiftFakeDevice(DeviceConfig deviceConfig) {
+        ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, deviceConfig.getDeviceNo());
+        if (forkLiftThread != null) {
+            throw new CoolException("璁惧宸插瓨鍦�");
+        }
+
+        ThreadHandler thread = null;
+        if (deviceConfig.getThreadImpl().equals("LfdZyForkLiftMasterThread")) {
+            thread = new LfdZyForkLiftMasterThread(deviceConfig, redisUtil);
+        } else {
+            throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
+        }
+
+        new Thread(thread).start();
+        SlaveConnection.put(SlaveType.ForkLiftMaster, deviceConfig.getDeviceNo(), thread);
+        addFakeDeviceToRedis(deviceConfig);
+    }
+
+    public void addFakeDeviceToRedis(DeviceConfig deviceConfig) {
+        Object object = redisUtil.get(RedisKeyType.FAKE_DEVICE_CONFIG.key);
+        List<DeviceConfig> list = new ArrayList<>();
+        if (object != null) {
+            list = JSON.parseArray(object.toString(), DeviceConfig.class);
+        }
+
+        list.add(deviceConfig);
+        redisUtil.set(RedisKeyType.FAKE_DEVICE_CONFIG.key, JSON.toJSONString(list));
+    }
+
+    public void delFakeDeviceToRedis(Integer deviceNo, String deviceType) {
+        Object object = redisUtil.get(RedisKeyType.FAKE_DEVICE_CONFIG.key);
+        if (object == null) {
+            return;
+        }
+
+        List<DeviceConfig> newList = new ArrayList<>();
+        List<DeviceConfig> list = JSON.parseArray(object.toString(), DeviceConfig.class);
+        for (DeviceConfig config : list) {
+            if(config.getDeviceNo().equals(deviceNo) && config.getDeviceType().equals(deviceType)){
+                continue;
+            }
+
+            newList.add(config);
+        }
+
+        redisUtil.set(RedisKeyType.FAKE_DEVICE_CONFIG.key, JSON.toJSONString(newList));
+    }
+
+}
diff --git a/src/main/webapp/static/js/common.js b/src/main/webapp/static/js/common.js
index 4d3f029..773df61 100644
--- a/src/main/webapp/static/js/common.js
+++ b/src/main/webapp/static/js/common.js
@@ -1,4 +1,4 @@
-var baseUrl = "/rcs";
+var baseUrl = "/gateway";
 
 // 璧嬪��
 function setVal(el, val) {
diff --git a/src/main/webapp/views/index.html b/src/main/webapp/views/index.html
index 4d9e1c8..97b8c7a 100644
--- a/src/main/webapp/views/index.html
+++ b/src/main/webapp/views/index.html
@@ -1,100 +1,178 @@
 <!DOCTYPE html>
 <html lang="en">
+
 <head>
-    <meta charset="utf-8">
-    <title>鑷姩浠撳簱RCS绯荤粺</title>
-    <link rel="stylesheet" href="../static/css/index.css">
-    <link rel="stylesheet" href="../static/css/layx.min.css" type="text/css" />
-    <script src="../static/js/jquery/jquery-3.3.1.min.js"></script>
-    <script src="../static/js/tools/layx.min.js"></script>
+    <meta charset="UTF-8">
+    <title>浠诲姟绠$悊</title>
+    <link rel="stylesheet" href="../static/vue/element/element.css">
+    <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
+    <script type="text/javascript" src="../static/js/common.js"></script>
+    <script type="text/javascript" src="../static/vue/js/vue.min.js"></script>
+    <script type="text/javascript" src="../static/vue/element/element.js"></script>
     <style>
-        .layx-window.layx-skin-news .layx-control-bar {
-            background-color: #333333;
+        .el-table .success-row {
+            background: #b6ff8e;
         }
     </style>
 </head>
+
 <body>
-<!-- 瀵艰埅鏍� -->
-<div class="sidebar">
-    <div class="nav">
-        <ul class="cl-effect-4">
-            <li><a id="console" onclick="nav(this.id)" class="nav-select" href="#">涓绘帶鍥�</a></li>
-            <li><a id="forklift" onclick="nav(this.id)" class="nav-unselect" href="#">鎻愬崌鏈�</a></li>
-            <li><a id="shuttle" onclick="nav(this.id)" class="nav-unselect" href="#">鍥涘悜绌挎杞�</a></li>
-            <li><a id="admin" onclick="nav(this.id)" class="nav-unselect" href="#">绠$悊鍚庡彴</a></li>
-        </ul>
+<div id="app" style="display: flex;justify-content: center;flex-wrap: wrap;">
+    <div style="width: 50%;">
+        <el-card class="box-card">
+            <div slot="header" class="clearfix">
+                <span>妯℃嫙璁惧</span>
+                <el-button style="float: right; padding: 3px 0" type="text" @click="addDeviceVisible = true">娣诲姞璁惧</el-button>
+            </div>
+
+            <div style="display: flex;flex-wrap: wrap;justify-content: space-between;">
+                <div v-for="item in deviceList" style="width: 49%;margin-top: 20px">
+                    <el-card  class="box-card">
+                        <div slot="header" class="clearfix">
+                            <span>{{ item.deviceType }} - {{ item.deviceNo }}</span>
+                            <el-button style="float: right; padding: 3px 0" type="text" @click="delDevice(item)">鍒犻櫎璁惧</el-button>
+                        </div>
+
+                        <div>
+                            <div>IP: {{ item.ip }}</div>
+                            <div>绔彛: {{ item.port }}</div>
+                            <div>铏氭嫙: {{ item.fake }}</div>
+                            <div>瀹炵幇绫�: {{ item.threadImpl }}</div>
+                        </div>
+                    </el-card>
+                </div>
+            </div>
+        </el-card>
     </div>
+
+
+    <el-dialog title="娣诲姞妯℃嫙璁惧" :visible.sync="addDeviceVisible">
+        <el-form :model="addDeviceParam">
+            <el-form-item label="璁惧缂栧彿" :label-width="formLabelWidth">
+                <el-input v-model="addDeviceParam.deviceNo"></el-input>
+            </el-form-item>
+            <el-form-item label="IP" :label-width="formLabelWidth">
+                <el-input v-model="addDeviceParam.ip"></el-input>
+            </el-form-item>
+            <el-form-item label="绔彛" :label-width="formLabelWidth">
+                <el-input v-model="addDeviceParam.port"></el-input>
+            </el-form-item>
+            <el-form-item label="瀹炵幇绫�" :label-width="formLabelWidth">
+                <el-input v-model="addDeviceParam.threadImpl"></el-input>
+            </el-form-item>
+            <el-form-item label="璁惧绫诲瀷" :label-width="formLabelWidth">
+                <el-input v-model="addDeviceParam.deviceType"></el-input>
+            </el-form-item>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+            <el-button @click="addDeviceVisible = false">鍙� 娑�</el-button>
+            <el-button type="primary" @click="addDevice">纭� 瀹�</el-button>
+        </div>
+    </el-dialog>
+
 </div>
-<!-- 涓讳綋鍐呭 -->
-<iframe id="content" src="console.html"></iframe>
-<!-- 灏鹃儴 -->
-<footer class="footer">
-    Copyright 漏 2015~2025 All Rights Reserved. 娴欐睙涓壃绔嬪簱鎶�鏈湁闄愬叕鍙�  淇濈暀鎵�鏈夋潈鍒�
-</footer>
-</body>
 <script>
-    // 瀵艰埅鏍�
-    function nav(id) {
-        if(id == 'admin') {
-            window.open('./admin/index.html')
-            return
-        }
-        $('.nav-select').attr("class", "nav-unselect");
-        $('#'+id).attr("class", "nav-select");
-        $('#content').attr("src", id+".html");
-    }
-
-    // 绯荤粺杩愯鐘舵��
-    var systemRunning = true;
-
-    // news by http://chuange.gitee.io/vue-layx/
-    news();layx.min('wcs-news');
-    function news() {
-        layx.iframe(
-              'wcs-news' // id
-            , '绯荤粺鍒嗘瀽鎶ュ憡'
-            , "news.html"
-            , {
-                  shadow:false
-                , storeStatus:false
-                // , skin: 'news'
-                , width:800
-                , height:600
-                , position:'rb'
-                // , control:false
-                , opacity:0.9
-                , border:false
-                , icon:'<img src="../static/images/favicon.ico" style="height:22px;display:block;"  alt=""/>'
-                , stickMenu:true
-                , maxMenu:false
-                , closeMenu:false
-                , moveLimit:{
-                    leftOut: false,
-                    rightOut: false,
-                    topOut: false,
-                    bottomOut: false,
-                }
-                , minWidth:300
-                , minHeight:300
-                , borderRadius: '8px'
-                , shadeDestroy:true
-                , escKey: false
-                , event:{
-                    onmin: {
-                        after: function () {
-                            $('.layx-min-statu').css("left", "inherit").css("right", "10px")
+    var app = new Vue({
+        el: '#app',
+        data: {
+            addDeviceVisible: false,
+            addDeviceParam: {
+                deviceNo: '',
+                ip: '',
+                port: '',
+                threadImpl: '',
+                deviceType: ''
+            },
+            formLabelWidth: '120px',
+            deviceList: []
+        },
+        created() {
+            this.init()
+        },
+        methods: {
+            init() {
+                setInterval(() => {
+                    this.getDeviceList()
+                }, 100);
+            },
+            addDevice() {
+                //娣诲姞璁惧
+                let that = this;
+                $.ajax({
+                    url: baseUrl + "/open/addFakeDevice",
+                    headers: {
+                        'token': localStorage.getItem('token')
+                    },
+                    data: JSON.stringify(this.addDeviceParam),
+                    dataType: 'json',
+                    contentType: 'application/json;charset=UTF-8',
+                    method: 'POST',
+                    success: function(res) {
+                        if (res.code == 200) {
+                            console.log(res)
+                        } else {
+                            that.$message({
+                                message: res.msg,
+                                type: 'error'
+                            });
                         }
                     }
-                    , onrestore:{
-                        after: function () {
-                            let win = layx.getFrameContext('wcs-news');
-                            win.autoScroll = true
+                });
+            },
+            getDeviceList() {
+                let that = this;
+                $.ajax({
+                    url: baseUrl + "/open/getDeviceList",
+                    headers: {
+                        'token': localStorage.getItem('token')
+                    },
+                    data: {},
+                    dataType: 'json',
+                    contentType: 'application/json;charset=UTF-8',
+                    method: 'GET',
+                    success: function(res) {
+                        if (res.code == 200) {
+                            let data = res.data;
+                            that.deviceList = data
+                        } else {
+                            that.$message({
+                                message: res.msg,
+                                type: 'error'
+                            });
                         }
                     }
-                }
+                });
+            },
+            delDevice(config) {
+                let that = this;
+                $.ajax({
+                    url: baseUrl + "/open/deleteFakeDevice",
+                    headers: {
+                        'token': localStorage.getItem('token')
+                    },
+                    data: JSON.stringify({
+                        deviceNo: config.deviceNo,
+                        deviceType: config.deviceType
+                    }),
+                    dataType: 'json',
+                    contentType: 'application/json;charset=UTF-8',
+                    method: 'POST',
+                    success: function(res) {
+                        if (res.code == 200) {
+                            let data = res.data;
+                            that.deviceList = data
+                        } else {
+                            that.$message({
+                                message: res.msg,
+                                type: 'error'
+                            });
+                        }
+                    }
+                });
             }
-        );
-    }
-
+        },
+    })
 </script>
+</body>
+
 </html>

--
Gitblit v1.9.1