|
|
@@ -1,92 +1,63 @@
|
|
|
package com.cec.plugins;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.cec.plugins.enumerate.EstimateEnum;
|
|
|
+import com.cec.plugins.enumerate.TaskEnum;
|
|
|
+import com.cec.plugins.service.RedisClientEvaluate;
|
|
|
import com.cec.plugins.service.RedisClientSource;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
-import org.redisson.api.RKeys;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
-import java.util.Optional;
|
|
|
-
|
|
|
/**
|
|
|
* {@see 'https://www.cnblogs.com/east7/p/16255305.html'}
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@SpringBootTest
|
|
|
-@RequiredArgsConstructor
|
|
|
class PluginsApplicationTests {
|
|
|
|
|
|
- private final RedisClientSource RedisClientSource;
|
|
|
+ @Autowired
|
|
|
+ private RedisClientSource clientSource;
|
|
|
+ @Autowired
|
|
|
+ private RedisClientEvaluate clientEvaluate;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void taskStatus() {
|
|
|
+ String instanceId = clientSource.getCacheStr(TaskEnum.TaskInstanceId.getKey());
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceTaskInstanceId.getKey(), StrUtil.emptyToDefault(instanceId, "7e1cb874-ed07-4d10-a980-taskStatus"));
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceTaskStatusOrder.getKey(), "1");
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceTaskFailReason.getKey(), "任务状态-执行成功");
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
|
- void contextLoads() {
|
|
|
- RedisClientSource.setCacheObject("111", "2222");
|
|
|
- System.out.println(Optional.ofNullable(RedisClientSource.getCacheObject("111")).orElse("--"));
|
|
|
+ void paramConfig() {
|
|
|
+ String instanceId = clientSource.getCacheStr(TaskEnum.ParamConfigInstanceId.getKey());
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceParamConfigInstanceId.getKey(), StrUtil.emptyToDefault(instanceId, "7e1cb874-ed07-4d10-a980-paramConfig"));
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceParamConfigOrder.getKey(), "1");
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceParamConfigFailReason.getKey(), "任务配置-执行成功");
|
|
|
+ }
|
|
|
|
|
|
- RKeys keys = RedisClientSource.getClient().getKeys();
|
|
|
- // 获取所有key值
|
|
|
- Iterable<String> allKeys = keys.getKeys();
|
|
|
- // 模糊查询所有包含关键字key的值
|
|
|
- Iterable<String> foundedKeys = keys.getKeysByPattern("key");
|
|
|
- // 删除多个key值
|
|
|
- long numOfDeletedKeys = keys.delete("obj1", "obj2", "obj3");
|
|
|
- // 模糊删除key值
|
|
|
- long deletedKeysAmount = keys.deleteByPattern("test?");
|
|
|
- // 随机获取key
|
|
|
- String randomKey = keys.randomKey();
|
|
|
- // 查询当前有多少个key
|
|
|
- long keysAmount = keys.count();
|
|
|
+ @Test
|
|
|
+ void command() {
|
|
|
+ String instanceId = clientSource.getCacheStr(TaskEnum.CommandInstanceId.getKey());
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceCommandInstanceId.getKey(), StrUtil.emptyToDefault(instanceId, "7e1cb874-ed07-4d10-a980-command"));
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceCommandOrder.getKey(), "1");
|
|
|
+ clientSource.setCacheObject(TaskEnum.ExceCommandFailReason.getKey(), "控制命令-执行成功");
|
|
|
}
|
|
|
|
|
|
- // private RedisUtils2 redisUtils = null;
|
|
|
- // private void strDemo() {
|
|
|
- // redisUtils.setStr("9999999999", "Hello, String.");
|
|
|
- // redisUtils.setStr("myBucket", "myBucketIsXxx");
|
|
|
- // RBuckets buckets = redisUtils.getBuckets();
|
|
|
- // Map<String, String> foundBuckets = buckets.get("myBucket*");
|
|
|
- // Map<String, Object> map = new HashMap<>();
|
|
|
- // map.put("myBucket1", "value1");
|
|
|
- // map.put("myBucket2", 30L);
|
|
|
- //
|
|
|
- // // 同时保存全部通用对象桶。
|
|
|
- // buckets.set(map);
|
|
|
- // Map<String, String> loadedBuckets = buckets.get("myBucket1", "myBucket2", "myBucket3");
|
|
|
- // log.info("跨桶String 测试数据:{}", loadedBuckets);
|
|
|
- // map.put("myBucket3", 320L);
|
|
|
- // }
|
|
|
- //
|
|
|
- // /** 批量操作 */
|
|
|
- // private void batchDemo() throws ExecutionException, InterruptedException {
|
|
|
- // Map<String, String> map = new HashMap<>();
|
|
|
- // map.put("abc", "testStr");
|
|
|
- // map.put("abcDemo", "redis");
|
|
|
- // redisUtils.setMassStrings(map);
|
|
|
- //
|
|
|
- // log.info("String 测试数据:{}", redisUtils.getStr("abc") + " "
|
|
|
- // + redisUtils.getStr("abcDemo"));
|
|
|
- //
|
|
|
- // RBatch batch = redisUtils.createBatch();
|
|
|
- // // 模拟购物车场景,真实场景中请替换店铺ID shopId 和商品ID commodityId
|
|
|
- // String field = "shopId:commodityId";
|
|
|
- // // 把即将执⾏的命令放进 RBatch
|
|
|
- // RMapAsync<Object, Object> testMap = batch.getMap("customerId:" + 32L);
|
|
|
- // // 更新value,并返回上一次的值
|
|
|
- // String commodityNum = "mapValue" + String.valueOf((int) (Math.random() * 9 + 100));
|
|
|
- // log.info("当前商品数量commodityNum是:{}", commodityNum);
|
|
|
- // testMap.putAsync(field, commodityNum);
|
|
|
- // testMap.putAsync("test2", "mapValue3");
|
|
|
- // testMap.putAsync("test2", "mapValue5");
|
|
|
- // testMap.putAsync("test:" + String.valueOf((int) (Math.random() * 900 + 100)), String.valueOf((int) (Math.random() * 900 + 100)));
|
|
|
- //
|
|
|
- // RAtomicLongAsync counter = batch.getAtomicLong("counter");
|
|
|
- //
|
|
|
- // RFuture<Long> num = counter.incrementAndGetAsync();
|
|
|
- //
|
|
|
- // // 执行RBatch中的全部命令,并返回执行结果
|
|
|
- // BatchResult<?> result = batch.execute();
|
|
|
- // List<?> list = result.getResponses();
|
|
|
- // log.info("Map Batch 执行结果:{}", list);
|
|
|
- // log.info("计数器当前值:{}", num.get());
|
|
|
- // }
|
|
|
+ @Test
|
|
|
+ void estimate() {
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CATS_SendFlow.getKey(), 60);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CATS_RecFlow.getKey(), 60);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CISCS_SendFlow.getKey(), 60);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CISCS_RecFlow.getKey(), 80);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CVOBC_SendFlow.getKey(), 80);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CVOBC_RecFlow.getKey(), 80);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CVOBC_EBLocationMiss.getKey(), 100);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CVOBC_EBCommMiss.getKey(), 100);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CATS_MonState.getKey(), 100);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CATS_DR.getKey(), 100);
|
|
|
+ clientEvaluate.setCacheObject(EstimateEnum.CATS_OTD.getKey(), 100);
|
|
|
+ }
|
|
|
}
|