| | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | public String getDeviceConfig() { |
| | | Object obj = redisUtil.get(RedisKeyType.DEVICE_CONFIG.key); |
| | | if(null == obj){ |
| | | return null; |
| | | } |
| | | return obj.toString(); |
| | | } |
| | | |
| | | public DeviceCommandMsgModel getDeviceCommandMsg(SlaveType deviceType, Integer deviceId) { |
| | | TreeSet<String> listKey = getDeviceCommandMsgListKey(deviceType, deviceId); |
| | | if (listKey.isEmpty()) { |
| | |
| | | |
| | | public String sendDeviceMsg(SlaveType deviceType, Integer deviceId, DeviceMsgModel deviceMsgModel) { |
| | | String key = parseDeviceMsgKey(deviceType, deviceId) + System.currentTimeMillis(); |
| | | redisUtil.set(key, deviceMsgModel, 60 * 60 * 24); |
| | | redisUtil.set(key, deviceMsgModel, 60 * 60); |
| | | return key; |
| | | } |
| | | |
| | | public String sendDeviceCommand(SlaveType deviceType, Integer deviceId, DeviceCommandMsgModel command) { |
| | | String key = parseDeviceCommandMsgKey(deviceType, deviceId) + System.currentTimeMillis(); |
| | | redisUtil.set(key, command, 60 * 60 * 24); |
| | | command.setResultKey(key); |
| | | redisUtil.set(key, command, 60 * 60); |
| | | return key; |
| | | } |
| | | |
| | | public void sendDeviceConfig(String allDevices) { |
| | | 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) { |
| | |
| | | return RedisKeyType.DEVICE_SHUTTLE_MSG_KEY_.key + deviceId + "_"; |
| | | } else if (deviceType.equals(SlaveType.ForkLift)) { |
| | | return RedisKeyType.DEVICE_FORK_LIFT_MSG_KEY_.key + deviceId + "_"; |
| | | } else if (deviceType.equals(SlaveType.Lift)) { |
| | | return RedisKeyType.DEVICE_LIFT_MSG_KEY_.key + deviceId + "_"; |
| | | }else { |
| | | throw new CoolException("设备类型未定义"); |
| | | } |
| | |
| | | return RedisKeyType.DEVICE_SHUTTLE_COMMAND_MSG_KEY.key + deviceId + "_"; |
| | | } else if (deviceType.equals(SlaveType.ForkLift)) { |
| | | return RedisKeyType.DEVICE_FORK_LIFT_COMMAND_MSG_KEY.key + deviceId + "_"; |
| | | } else if (deviceType.equals(SlaveType.Lift)) { |
| | | return RedisKeyType.DEVICE_LIFT_COMMAND_MSG_KEY.key + deviceId + "_"; |
| | | }else { |
| | | throw new CoolException("设备类型未定义"); |
| | | } |