Merge branch 'dev' into feature-integrated_with_JCPP

This commit is contained in:
Guoqs
2026-01-08 09:38:32 +08:00
20 changed files with 573 additions and 156 deletions

View File

@@ -60,9 +60,6 @@ public class Constants {
// 默认端口号
public static final Integer SOCKET_PORT = 9011;
// 阿里云服务器地址
public static final String updateServerIP = "47.103.124.69";
// ftp端口号
public static final int port = 0x15;

View File

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* spring redis 工具类
@@ -603,4 +604,82 @@ public class RedisCache {
redisTemplate.opsForList().trim(redisKey, 0, 9);
}
/**
* 批量获取 Redis List 中每个 key 对应的最后一条数据
*
* @param keys Redis 键集合
* @param <T> 返回值类型
* @return Mapkey 为 Redis 键value 为对应 List 的最后一条数据
*/
public <T> Map<String, T> multiGetLastListValue(final List<String> keys) {
if (keys == null || keys.isEmpty()) {
return new HashMap<>();
}
Map<String, T> result = new HashMap<>();
for (String key : keys) {
if (StringUtils.isNotBlank(key)) {
try {
// 使用 index -1 获取 List 的最后一个元素
T lastValue = (T) redisTemplate.opsForList().index(key, -1);
if (lastValue != null) {
result.put(key, lastValue);
}
} catch (Exception e) {
// 记录错误日志,方便排查问题
logger.error("获取Redis List失败key={}, 可能key的类型不是List", key, e);
}
}
}
return result;
}
/**
* 获取 Redis List 中指定 key 的最后一条数据
*
* @param key Redis 键
* @param <T> 返回值类型
* @return List 的最后一条数据,如果 key 不存在或 List 为空则返回 null
*/
public <T> T getLastListValue(final String key) {
if (StringUtils.isBlank(key)) {
return null;
}
try {
// 使用 index -1 获取 List 的最后一个元素
return (T) redisTemplate.opsForList().index(key, -1);
} catch (Exception e) {
// 记录错误日志,方便排查问题
logger.error("获取Redis List失败key={}, 可能key的类型不是List", key, e);
return null;
}
}
/**
* 批量获取 Redis List 中每个 key 对应的最后一条数据
*
* @param keys Redis 键集合
* @return Mapkey 为入参的 key 值value 为对应 List 的最后一条数据
*/
public Map<String, Object> multiGetLastListValueList(final List<String> keys) {
if (keys == null || keys.isEmpty()) {
return new HashMap<>();
}
Map<String, Object> result = new HashMap<>();
for (String key : keys) {
if (StringUtils.isNotBlank(key)) {
try {
// 使用 index -1 获取 List 的最后一个元素
Object lastValue = redisTemplate.opsForList().index(key, -1);
result.put(key, lastValue);
} catch (Exception e) {
// 记录错误日志,方便排查问题
logger.error("获取Redis List失败key={}, 可能key的类型不是List", key, e);
}
}
}
return result;
}
}