|
@@ -0,0 +1,55 @@
|
|
|
+package com.persagy.test;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.springframework.data.redis.core.Cursor;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.data.redis.core.ScanOptions;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 报警记录控制层
|
|
|
+ *
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021-09-08 22:30:38
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("test")
|
|
|
+public class TestController {
|
|
|
+ @Resource(name = "alarmRedisTemplate")
|
|
|
+ private RedisTemplate<String, Object> alarmRedisTemplate;
|
|
|
+
|
|
|
+ @PostMapping("/redis")
|
|
|
+ public void testRedis() {
|
|
|
+// Cursor<Map.Entry<Object, Object>> entryCursor = alarmRedisTemplate.opsForHash().scan("ALARM_CONDITION_STATE", ScanOptions.scanOptions() //绑定模糊查询的hash的key
|
|
|
+// .match("Eqdx*") //模糊查询规则
|
|
|
+// .count(10000).build());
|
|
|
+//
|
|
|
+// List<String> keys = new ArrayList<>();
|
|
|
+// while(entryCursor.hasNext()){
|
|
|
+// Map.Entry next = entryCursor.next();
|
|
|
+//
|
|
|
+// String key = next.getKey().toString();
|
|
|
+//
|
|
|
+// // 将查询出的item放入list
|
|
|
+//
|
|
|
+// keys.add(key);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// Set<String> keys1 = alarmRedisTemplate.keys("ALL-PROJECT_ITEM_SEND_TIME*");
|
|
|
+//
|
|
|
+// alarmRedisTemplate.delete(keys1);
|
|
|
+// Iterator<String> iterator = keys.iterator();
|
|
|
+// while (iterator.hasNext()) {
|
|
|
+// alarmRedisTemplate.opsForHash().delete("ALARM_CONDITION_STATE", iterator.next());
|
|
|
+// }
|
|
|
+ long time = 111L;
|
|
|
+ alarmRedisTemplate.opsForValue().set("test", time);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|