From 8d5c50656d81dc3eb04a841ecd259adebf99424a Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期三, 11 二月 2026 15:49:26 +0800
Subject: [PATCH] 搜索库存明细调整不查询删除物料
---
rsf-server/src/main/java/com/vincent/rsf/server/system/service/impl/UserServiceImpl.java | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/system/service/impl/UserServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/system/service/impl/UserServiceImpl.java
index dea12b4..155e883 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/system/service/impl/UserServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/system/service/impl/UserServiceImpl.java
@@ -14,9 +14,16 @@
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
+
+ /** 鎵归噺鏌ヨ缂撳瓨锛歬ey = 鎺掑簭鍚庣殑 ids 鎷兼帴锛寁alue = (杩囨湡鏃堕棿鎴�, 鐢ㄦ埛鍒楄〃)锛孴TL 5 鍒嗛挓 */
+ private static final long CACHE_TTL_MS = 5 * 60 * 1000L;
+ private static final ConcurrentHashMap<String, CacheEntry<List<User>>> USER_MANY_CACHE = new ConcurrentHashMap<>(64);
@Resource
private UserRoleService userRoleService;
@@ -70,4 +77,29 @@
return baseMapper.selectByUsernameWithoutTenant(username,tenantId);
}
+ @Override
+ public List<User> listByIdsCached(Collection<Long> ids) {
+ if (ids == null || ids.isEmpty()) {
+ return Collections.emptyList();
+ }
+ String key = ids.stream().sorted().map(Object::toString).collect(Collectors.joining(","));
+ long now = System.currentTimeMillis();
+ CacheEntry<List<User>> entry = USER_MANY_CACHE.get(key);
+ if (entry != null && entry.expireAt > now) {
+ return entry.data;
+ }
+ List<User> list = listByIds(ids);
+ USER_MANY_CACHE.put(key, new CacheEntry<>(now + CACHE_TTL_MS, list));
+ return list;
+ }
+
+ private static class CacheEntry<T> {
+ final long expireAt;
+ final T data;
+ CacheEntry(long expireAt, T data) {
+ this.expireAt = expireAt;
+ this.data = data;
+ }
+ }
+
}
--
Gitblit v1.9.1