绑定bug修复

This commit is contained in:
2025-10-11 16:07:14 +08:00
parent 740a638444
commit dab0440128
2 changed files with 21 additions and 2 deletions

View File

@ -189,7 +189,6 @@ public class DeviceBizService {
if (appDeviceBindRecord != null) { if (appDeviceBindRecord != null) {
UpdateWrapper<AppDeviceBindRecord> deviceUpdateWrapper = new UpdateWrapper<>(); UpdateWrapper<AppDeviceBindRecord> deviceUpdateWrapper = new UpdateWrapper<>();
deviceUpdateWrapper.eq("device_id", device.getId()) deviceUpdateWrapper.eq("device_id", device.getId())
.set("binding_status", BindingStatusEnum.BOUND.getCode())
.set("binding_user_id", userId) .set("binding_user_id", userId)
.set("communication_mode", 0) .set("communication_mode", 0)
.set("update_time", new Date()) .set("update_time", new Date())
@ -384,7 +383,7 @@ public class DeviceBizService {
String deviceImei = device.getDeviceImei(); String deviceImei = device.getDeviceImei();
String a = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX + ":history"; String a = GLOBAL_REDIS_KEY+ DEVICE_KEY_PREFIX+ deviceImei + DEVICE_LOCATION_KEY_PREFIX + ":history";
Collection<String> list = RedisUtils.zRangeByScore(a, startTime, endTime); Collection<String> list = RedisUtils.zRangeByScoreDesc(a, startTime, endTime);
if (CollectionUtil.isEmpty(list)) { if (CollectionUtil.isEmpty(list)) {
return null; return null;
} }

View File

@ -394,6 +394,26 @@ public class RedisUtils {
return null; return null;
} }
} }
/**
* 根据时间范围查询Sorted Set中的元素并降序排列
*
* @param key 键
* @param startTime 开始时间戳
* @param endTime 结束时间戳
* @return 指定时间范围内的元素集合(降序)
*/
public static Collection<String> zRangeByScoreDesc(String key, Long startTime, Long endTime) {
try {
RScoredSortedSet<String> sortedSet = CLIENT.getScoredSortedSet(key);
// 使用 valueRangeReversed 方法获取降序排列的结果
return sortedSet.valueRangeReversed(startTime, true, endTime, true);
} catch (Exception e) {
// 记录错误日志(如果项目中有日志工具的话)
// log.error("根据时间范围查询Sorted Set中的元素失败: key={}, startTime={}, endTime={}, error={}",
// key, startTime, endTime, e.getMessage(), e);
return null;
}
}
/** /**