|
|
|
@ -5,10 +5,13 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.Setter;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.data.redis.core.ZSetOperations;
|
|
|
|
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
|
|
|
|
|
|
@ -32,10 +35,15 @@ public abstract class RedisDelayQueue<T> {
|
|
|
|
|
private ZSetOperations<String, Object> zSetOperations;
|
|
|
|
|
|
|
|
|
|
public RedisDelayQueue(RedisTemplate<String, Object> redisTemplate) {
|
|
|
|
|
redisTemplate.setKeySerializer(RedisSerializer.string());
|
|
|
|
|
redisTemplate.setValueSerializer(RedisSerializer.string());
|
|
|
|
|
redisTemplate.setHashKeySerializer(RedisSerializer.string());
|
|
|
|
|
redisTemplate.setHashValueSerializer(RedisSerializer.string());
|
|
|
|
|
zSetOperations = redisTemplate.opsForZSet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
@Setter
|
|
|
|
|
@Getter
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public static class QuestionSettingTaskItem<T> {
|
|
|
|
|
final public String id;
|
|
|
|
@ -43,7 +51,7 @@ public abstract class RedisDelayQueue<T> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum QuestionQueueTypeEnum {
|
|
|
|
|
QUESTION_SETTING
|
|
|
|
|
questionSetting
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -97,7 +105,7 @@ public abstract class RedisDelayQueue<T> {
|
|
|
|
|
*/
|
|
|
|
|
public boolean isExists(String queueKey, String otherKey) {
|
|
|
|
|
Set<Object> objects = zSetOperations.rangeByScore(queueKey, 0, -1);
|
|
|
|
|
return objects.stream().anyMatch(item -> JSON.parseObject(item.toString()).containsValue(otherKey));
|
|
|
|
|
return objects.stream().anyMatch(item -> item.toString().contains(otherKey));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|