中控上报信息存储优化
This commit is contained in:
parent
a819ced87f
commit
f9ba7e833e
@ -5,9 +5,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -505,4 +503,34 @@ public class RedisUtil {
|
||||
|
||||
return getRedisTemplate(Database.DB2).opsForValue().multiGet(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取ECU信息(基于已知的SN列表)
|
||||
*
|
||||
* @param ecuSnList ECU序列号列表
|
||||
* @return Map<ECU_SN, ECU_Data> 映射关系
|
||||
*/
|
||||
public Map<String, Object> batchGetEcuWithMap(List<String> ecuSnList) {
|
||||
if (ecuSnList == null || ecuSnList.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
// 构建完整的Redis键列表
|
||||
List<String> keys = ecuSnList.stream()
|
||||
.map(sn -> BIKE_ECU_PREFIX + sn)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量获取值
|
||||
List<Object> values = getRedisTemplate(Database.DB2).opsForValue().multiGet(keys);
|
||||
|
||||
// 构建映射关系
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
for (int i = 0; i < ecuSnList.size(); i++) {
|
||||
String sn = ecuSnList.get(i);
|
||||
Object value = (values != null && i < values.size()) ? values.get(i) : null;
|
||||
result.put(sn, value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user