648540858
2023-09-01 cde7f6460a563a4e9b2624b395d9bdfe6f90e14c
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
old mode 100644 new mode 100755
@@ -16,6 +16,7 @@
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;
@@ -39,6 +40,9 @@
    @Autowired
    private DeviceChannelMapper deviceChannelMapper;
    @Autowired
    private DeviceMapper deviceMapper;
    @Autowired
    private UserSetting userSetting;
@@ -375,7 +379,8 @@
        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 @@
    @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