From d7d0578b00c9ec24893e3a0c8e8ff3301f82bc2a Mon Sep 17 00:00:00 2001 From: zjh <1084500556@qq.com> Date: 星期三, 13 十二月 2023 18:48:37 +0800 Subject: [PATCH] zjh 2023/12/13--1 --- ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 41 insertions(+), 2 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java index bef5dce..4b94f93 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java @@ -27,6 +27,11 @@ import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.ConvertingCursor; +import org.springframework.data.redis.core.Cursor; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ScanOptions; +import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -89,7 +94,8 @@ @Autowired private ITjRulesService tjRulesService; - + @Autowired + public RedisTemplate<Object,Object> redisTemplate; /** @@ -279,14 +285,47 @@ } } List<TjCustomer> customerLists = new ArrayList<>(); + +// String key="*"; +// if(sysUser.isAdmin()){ +// key="ks"+":*"; +// }else { +// key="ks:"+ksId+":*"; +// } +// ScanOptions options = ScanOptions.scanOptions() +// //杩欓噷鎸囧畾姣忔鎵弿key鐨勬暟閲�(寰堝鍗氬鐬庤瑕佹寚瀹欼nteger.MAX_VALUE锛岃繖鏍风殑璇濊窡 keys鏈変粈涔堝尯鍒紵) +// .count(10000) +// .match(key).build(); +// RedisSerializer<String> redisSerializer = (RedisSerializer<String>) redisTemplate.getKeySerializer(); +// 0鏈,1宸叉 if (type == 0) { +// Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize)); +// while(cursor.hasNext()){ +// String s = cursor.next().toString(); +// TjCustomer wj = redisCache.getCacheMapValue(s,"0"); +// if(null !=wj){ +// customerLists.add(wj); +// } +// } +// //鍒囪杩欓噷涓�瀹氳鍏抽棴锛屽惁鍒欎細鑰楀敖杩炴帴鏁般�傛姤Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a +// cursor.close(); customerLists = redisCache.getCacheMapValue(ksId + "ks", "wj"); } if (type == 1) { +// Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize)); +// while(cursor.hasNext()){ +// String s = cursor.next().toString(); +// TjCustomer wj = redisCache.getCacheMapValue(s,"1"); +// if(null !=wj){ +// customerLists.add(wj); +// } +// } +// //鍒囪杩欓噷涓�瀹氳鍏抽棴锛屽惁鍒欎細鑰楀敖杩炴帴鏁般�傛姤Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a +// cursor.close(); customerLists = redisCache.getCacheMapValue(ksId + "ks", "yj"); } asyncService.dockerSetCustomerLisByRedis(ksproList, String.valueOf(ksId)); - if (customerLists != null && customerLists.size() > 0) { + if (null !=customerLists && customerLists.size() > 0) { Collections.reverse(customerLists); List<TjCustomer> customerList = customerLists.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); Map<String, Object> map = new HashMap<>(); -- Gitblit v1.8.0