| | |
| | | // return ResponseEntity.internalServerError().body("数据处理失败: " + e.getMessage()); |
| | | // } |
| | | if(Objects.nonNull(weightRequest) && CollectionUtil.isNotEmpty(weightRequest.getWeights())){ |
| | | RedisUtil.lSet(WeightRequestDto.DENSITY,weightRequest.getWeights()); |
| | | List<?> objectList = RedisUtil.lGet(WeightRequestDto.DENSITY, 0, -1); |
| | | if(CollectionUtil.isNotEmpty(objectList)){ |
| | | // 删除 Redis 中旧的列表数据 |
| | | RedisUtil.del(WeightRequestDto.DENSITY); |
| | | // 存入新的数据 |
| | | RedisUtil.lSet(WeightRequestDto.DENSITY, weightRequest.getWeights()); |
| | | }else { |
| | | RedisUtil.lSet(WeightRequestDto.DENSITY,weightRequest.getWeights()); |
| | | } |
| | | return Result.success(null,"保存成功"); |
| | | } |
| | | return Result.fail(); |
| | |
| | | numberOfDataEntries.addAndGet(1); |
| | | }else { |
| | | // 从 Redis 中获取列表数据 |
| | | List<Object> objectList = RedisUtil.lGet(refery, 0, -1); |
| | | // List<Object> objectList = RedisUtil.lGet(refery, 0, -1); |
| | | List<?> objectList = RedisUtil.lGet(refery, 0, -1); |
| | | for (Object item : objectList) { |
| | | // System.out.println(item); |
| | | String[] split = item.toString().replace("[","").replace("]","").split(","); |
| | |
| | | * @param start 开始 |
| | | * @param end 结束 0 到 -1代表所有值 |
| | | */ |
| | | public static List<Object> lGet(String key, long start, long end) { |
| | | public static List<?> lGet(String key, long start, long end) { |
| | | try { |
| | | return redisTemplate.opsForList().range(key, start, end); |
| | | } catch (Exception e) { |
| | |
| | | * @param value 值 |
| | | * @return true 存放成功 false存放失败 |
| | | */ |
| | | public static boolean lSet(String key, List<Object> value) { |
| | | public static boolean lSet(String key, List<?> value) { |
| | | try { |
| | | redisTemplate.opsForList().rightPushAll(key, value); |
| | | return true; |