| | |
| | | package com.ltkj.web.controller.sqlserver; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.core.controller.BaseController; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | | import com.ltkj.common.core.redis.RedisCache; |
| | | import com.ltkj.common.enums.DataSourceType; |
| | | import com.ltkj.framework.datasource.DynamicDataSourceContextHolder; |
| | | import com.ltkj.hosp.domain.TjOrder; |
| | | import com.ltkj.hosp.domain.TjOrderRemark; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.hosp.sqlDomain.*; |
| | | import com.ltkj.hosp.mapper.TestMapper; |
| | |
| | | public RedisTemplate<Object,Object> redisTemplate; |
| | | @Resource |
| | | private RedisCache redisCache; |
| | | |
| | | @Resource |
| | | private TjAsyncService asyncService; |
| | | @Resource |
| | | private ITjOrderRemarkService remarkService; |
| | | @Resource |
| | | private ITjOrderService orderService; |
| | | @GetMapping("/getRedisValue") |
| | | @ApiOperation(value = "测试redis模糊查询") |
| | | public AjaxResult getRedisValue(@RequestParam String aa) { |
| | | long start = System.currentTimeMillis(); |
| | | //需要匹配的key |
| | | ScanOptions options = ScanOptions.scanOptions() |
| | | //这里指定每次扫描key的数量(很多博客瞎说要指定Integer.MAX_VALUE,这样的话跟 keys有什么区别?) |
| | | .count(10000) |
| | | .match(aa+"*").build(); |
| | | RedisSerializer<String> redisSerializer = (RedisSerializer<String>) redisTemplate.getKeySerializer(); |
| | | Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize)); |
| | | List<Object> result = new ArrayList<>(); |
| | | while(cursor.hasNext()){ |
| | | String s = cursor.next().toString(); |
| | | redisCache.deleteObject(s); |
| | | public AjaxResult getRedisValue() { |
| | | // long start = System.currentTimeMillis(); |
| | | // //需要匹配的key |
| | | // ScanOptions options = ScanOptions.scanOptions() |
| | | // //这里指定每次扫描key的数量(很多博客瞎说要指定Integer.MAX_VALUE,这样的话跟 keys有什么区别?) |
| | | // .count(10000) |
| | | // .match(aa+"*").build(); |
| | | // RedisSerializer<String> redisSerializer = (RedisSerializer<String>) redisTemplate.getKeySerializer(); |
| | | // Cursor cursor = redisTemplate.executeWithStickyConnection(redisConnection -> new ConvertingCursor<>(redisConnection.scan(options), redisSerializer::deserialize)); |
| | | // List<Object> result = new ArrayList<>(); |
| | | // while(cursor.hasNext()){ |
| | | // String s = cursor.next().toString(); |
| | | // redisCache.deleteObject(s); |
| | | // } |
| | | // //切记这里一定要关闭,否则会耗尽连接数。报Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a |
| | | // cursor.close(); |
| | | //// System.out.println(result); |
| | | // log.info("scan扫描共耗时:{} ms key数量:{}",System.currentTimeMillis()-start,result.size()); |
| | | // Map<String,Object>map=new HashMap<>(); |
| | | // map.put("result",result); |
| | | // map.put("scan扫描共耗时:{} ms key数量:{}",System.currentTimeMillis()-start+result.size()); |
| | | List<TjOrderRemark> list = remarkService.list(new LambdaQueryWrapper<TjOrderRemark>().ne(TjOrderRemark::getType,2).groupBy(TjOrderRemark::getTjNumber)); |
| | | for (TjOrderRemark remark : list) { |
| | | TjOrder orderByTjNum = orderService.getOrderByTjNum(remark.getTjNumber()); |
| | | if(null !=orderByTjNum){ |
| | | asyncService.dockerSetWjCustomerByRedis(orderByTjNum.getOrderId(),remark.getDeptId()); |
| | | asyncService.dockerSetYjCustomerByRedis(orderByTjNum.getOrderId(),remark.getDeptId()); |
| | | } |
| | | } |
| | | //切记这里一定要关闭,否则会耗尽连接数。报Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisException: Could not get a |
| | | cursor.close(); |
| | | // System.out.println(result); |
| | | log.info("scan扫描共耗时:{} ms key数量:{}",System.currentTimeMillis()-start,result.size()); |
| | | Map<String,Object>map=new HashMap<>(); |
| | | map.put("result",result); |
| | | map.put("scan扫描共耗时:{} ms key数量:{}",System.currentTimeMillis()-start+result.size()); |
| | | return AjaxResult.success(map); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |