From 7270218a6c55de1a0e8431afe4119793ef518d50 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期六, 05 七月 2025 09:02:50 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/utils/DeviceMsgUtils.java | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/zy/core/Utils/DeviceMsgUtils.java b/src/main/java/com/zy/core/utils/DeviceMsgUtils.java similarity index 91% rename from src/main/java/com/zy/core/Utils/DeviceMsgUtils.java rename to src/main/java/com/zy/core/utils/DeviceMsgUtils.java index 97399f9..5a1fb51 100644 --- a/src/main/java/com/zy/core/Utils/DeviceMsgUtils.java +++ b/src/main/java/com/zy/core/utils/DeviceMsgUtils.java @@ -1,9 +1,10 @@ -package com.zy.core.Utils; +package com.zy.core.utils; import com.core.exception.CoolException; import com.zy.common.utils.RedisUtil; import com.zy.core.enums.RedisKeyType; import com.zy.core.enums.SlaveType; +import com.zy.core.model.DeviceCommandMsgModel; import com.zy.core.model.DeviceMsgModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -23,19 +24,18 @@ @Autowired private RedisUtil redisUtil; - - public Object getDeviceCommandMsg(SlaveType deviceType, Integer deviceId) { + public DeviceCommandMsgModel getDeviceCommandMsg(SlaveType deviceType, Integer deviceId) { TreeSet<String> listKey = getDeviceCommandMsgListKey(deviceType, deviceId); if (listKey.isEmpty()) { return null; } String firstKey = listKey.first(); - Object data = redisUtil.get(firstKey); + DeviceCommandMsgModel commandMsgModel = (DeviceCommandMsgModel) redisUtil.get(firstKey); if (destroyAfterReading) { redisUtil.del(firstKey); } - return data; + return commandMsgModel; } public DeviceMsgModel getDeviceMsg(SlaveType deviceType, Integer deviceId) { @@ -68,17 +68,13 @@ redisUtil.set(key, msgModel, 60 * 60); } - public String sendDeviceMsg(SlaveType deviceType, Integer deviceId, Object command) { + public String sendDeviceMsg(SlaveType deviceType, Integer deviceId, DeviceMsgModel deviceMsgModel) { String key = parseDeviceMsgKey(deviceType, deviceId) + System.currentTimeMillis(); - - DeviceMsgModel deviceMsgModel = new DeviceMsgModel(); - deviceMsgModel.setDeviceId(deviceId); - deviceMsgModel.setDeviceMsg(command); redisUtil.set(key, deviceMsgModel, 60 * 60 * 24); return key; } - public String sendDeviceCommand(SlaveType deviceType, Integer deviceId, Object command) { + public String sendDeviceCommand(SlaveType deviceType, Integer deviceId, DeviceCommandMsgModel command) { String key = parseDeviceCommandMsgKey(deviceType, deviceId) + System.currentTimeMillis(); redisUtil.set(key, command, 60 * 60 * 24); return key; -- Gitblit v1.9.1