| | |
| | | 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; |
| | |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private DeviceMsgUtils deviceMsgUtils; |
| | | @Autowired |
| | | private FakeDeviceUtils fakeDeviceUtils; |
| | | |
| | | |
| | | @PostConstruct |
| | |
| | | initMq(); |
| | | // 初始化下位机线程 |
| | | initThread(); |
| | | // 初始化虚拟设备线程 |
| | | initFakeThread(); |
| | | News.info("核心控制层已启动..............................................."); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | 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() { |
| New file |
| | |
| | | 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(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | 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_"), |
| | |
| | | |
| | | //设备配置文件 |
| | | DEVICE_CONFIG("deviceConfig"), |
| | | //虚拟设备配置文件 |
| | | FAKE_DEVICE_CONFIG("fakeDeviceConfig"), |
| | | ; |
| | | |
| | | public String key; |
| New file |
| | |
| | | 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; |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.core.model.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class DeleteDeviceParam { |
| | | |
| | | private Integer deviceNo; |
| | | |
| | | private String deviceType; |
| | | |
| | | } |
| | |
| | | |
| | | private Integer deviceNo; |
| | | |
| | | private Boolean fake = false; |
| | | |
| | | } |
| | |
| | | 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(); |
| | | |
| | | } |
| | |
| | | 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.*; |
| | |
| | | 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 |
| | |
| | | //监听消息 |
| | | Thread innerThread = new Thread(() -> { |
| | | while (true) { |
| | | if(stopThread) { |
| | | break; |
| | | } |
| | | |
| | | System.out.println("read"); |
| | | |
| | | try { |
| | | Thread.sleep(200); |
| | | listenSocketMessage(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | //执行指令 |
| | | Thread executeThread = new Thread(() -> { |
| | | while (true) { |
| | | if(stopThread) { |
| | | break; |
| | | } |
| | | |
| | | System.out.println("executeThread"); |
| | | try { |
| | | DeviceMsgUtils deviceMsgUtils = null; |
| | | try { |
| | |
| | | } |
| | | }); |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | |
| | | @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(); |
| | | |
| | |
| | | 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; |
| | | } |
| | | } |
| New file |
| | |
| | | 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)); |
| | | } |
| | | |
| | | } |
| | |
| | | var baseUrl = "/rcs"; |
| | | var baseUrl = "/gateway"; |
| | | |
| | | // 赋值 |
| | | function setVal(el, val) { |
| | |
| | | <!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> |