pull/1023/head
chenzhangyue 2023-08-10 19:12:29 +08:00
parent 44e26d2024
commit 8e34d4e4cb
1 changed files with 16 additions and 3 deletions

View File

@ -16,6 +16,7 @@ import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.JsonUtil;
@ -40,6 +41,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Autowired
private DeviceChannelMapper deviceChannelMapper;
@Autowired
private DeviceMapper deviceMapper;
@Autowired
private UserSetting userSetting;
@ -375,7 +379,8 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
for (Object o : keys) {
String key = (String) o;
Device device = JsonUtil.redisJsonToObject(redisTemplate, key, Device.class);
if (Objects.nonNull(device)) { // 只取没有存过得
if (Objects.nonNull(device)) {
// 只取没有存过得
result.add(JsonUtil.redisJsonToObject(redisTemplate, key, Device.class));
}
}
@ -386,14 +391,22 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override
public Device getDevice(String deviceId) {
String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId;
return JsonUtil.redisJsonToObject(redisTemplate, key, Device.class);
Device device = JsonUtil.redisJsonToObject(redisTemplate, key, Device.class);
if (device == null){
device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device != null) {
updateDevice(device);
}
}
return device;
}
@Override
public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) {
String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gpsMsgInfo.getId();
Duration duration = Duration.ofSeconds(60L);
redisTemplate.opsForValue().set(key, gpsMsgInfo, duration); // 默认GPS消息保存1分钟
redisTemplate.opsForValue().set(key, gpsMsgInfo, duration);
// 默认GPS消息保存1分钟
}
@Override