| | |
| | | @TableField("device_no") |
| | | private Integer deviceNo; |
| | | |
| | | /** |
| | | * 虚拟设备 |
| | | */ |
| | | @ApiModelProperty(value= "虚拟设备") |
| | | @TableField("fake") |
| | | private Integer fake; |
| | | |
| | | public DeviceConfig() {} |
| | | |
| | | public DeviceConfig(String ip,Integer port,String threadImpl,Date createTime,String deviceType,Integer deviceNo) { |
| | |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | public String getFake$() { |
| | | if (Cools.isEmpty(this.fake)){ |
| | | return ""; |
| | | } |
| | | return this.fake == 1 ? "是" : "否"; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | private void initThread(){ |
| | | List<DeviceConfig> allDevices = new ArrayList<>(); |
| | | List<DeviceConfig> fakeDevices = new ArrayList<>(); |
| | | |
| | | // // 初始化货叉提升机 |
| | | // List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | |
| | | // 初始化四向穿梭车 |
| | | List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Shuttle))); |
| | | allDevices.addAll(shuttleList); |
| | | for (DeviceConfig deviceConfig : shuttleList) { |
| | | News.info("初始化四向穿梭车......................................................"); |
| | | ThreadHandler thread = null; |
| | |
| | | |
| | | new Thread(thread).start(); |
| | | SlaveConnection.put(SlaveType.Shuttle, deviceConfig.getDeviceNo(), thread); |
| | | |
| | | if (deviceConfig.getFake() == 1) { |
| | | fakeDevices.add(deviceConfig); |
| | | }else { |
| | | allDevices.add(deviceConfig); |
| | | } |
| | | } |
| | | |
| | | |
| | | //设备初始化完毕 |
| | | deviceMsgUtils.sendDeviceConfig(JSON.toJSONString(allDevices)); |
| | | deviceMsgUtils.sendFakeDeviceConfig(JSON.toJSONString(fakeDevices)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | //设备配置文件 |
| | | DEVICE_CONFIG("deviceConfig"), |
| | | //虚拟设备配置文件 |
| | | FAKE_DEVICE_CONFIG("fakeDeviceConfig"), |
| | | ; |
| | | |
| | | public String key; |
| | |
| | | redisUtil.set(RedisKeyType.DEVICE_CONFIG.key, allDevices); |
| | | } |
| | | |
| | | public void sendFakeDeviceConfig(String fakeDevices) { |
| | | redisUtil.set(RedisKeyType.FAKE_DEVICE_CONFIG.key, fakeDevices); |
| | | } |
| | | |
| | | public TreeSet<String> getDeviceMsgListKey(SlaveType deviceType, Integer deviceId) { |
| | | String listKey = parseDeviceMsgKey(deviceType, deviceId); |
| | | Set<String> keys = redisUtil.searchKeys(listKey); |
| | |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="device_type" property="deviceType" /> |
| | | <result column="device_no" property="deviceNo" /> |
| | | <result column="fake" property="fake" /> |
| | | |
| | | </resultMap> |
| | | |
| | |
| | | ,{field: 'ip', align: 'center',title: '设备ip'} |
| | | ,{field: 'port', align: 'center',title: '设备端口'} |
| | | ,{field: 'threadImpl', align: 'center',title: '实现类'} |
| | | ,{field: 'fake$', align: 'center',title: '虚拟设备'} |
| | | ,{field: 'createTime$', align: 'center',title: '创建时间'} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | |
| | | <input class="layui-input" name="threadImpl" placeholder="请输入实现类"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">虚拟设备: </label> |
| | | <div class="layui-input-block"> |
| | | <select name="fake"> |
| | | <option value="">请选择状态</option> |
| | | <option value="1">是</option> |
| | | <option value="0">否</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </div> |