1
This commit is contained in:
@@ -15,6 +15,7 @@ import cn.van.business.util.ds.GPTClientUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jd.open.api.sdk.DefaultJdClient;
|
||||
import com.jd.open.api.sdk.JdClient;
|
||||
@@ -89,6 +90,8 @@ public class JDUtil {
|
||||
private static final String ACCESS_TOKEN = "";
|
||||
private static final Logger logger = LoggerFactory.getLogger(JDUtil.class);
|
||||
private static final String INTERACTION_STATE_PREFIX = "interaction_state:";
|
||||
/** 与 ruoyi Jarvis 企微多轮会话共用 Redis 时的键前缀;非微信 wxid 流程,不得按 UserInteractionState 解析 */
|
||||
private static final String WECOM_SESSION_REDIS_PREFIX = INTERACTION_STATE_PREFIX + "wecom:";
|
||||
private static final String PRODUCT_TYPE_MAP_PREFIX = "product_type_map";
|
||||
private static final String PRODUCT_TYPE_MAP_PREFIX_TB = "product_type_map_tb";
|
||||
private static HashMap<String, String> productTypeMap = new HashMap<>();
|
||||
@@ -164,8 +167,9 @@ public class JDUtil {
|
||||
private final OrderUtil orderUtil;
|
||||
private final DeepSeekClientUtil deepSeekClientUtil;
|
||||
private final GPTClientUtil gptClientUtil;
|
||||
// 添加ObjectMapper来序列化和反序列化UserInteractionState
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 添加ObjectMapper来序列化和反序列化UserInteractionState(忽略其它系统写入的扩展字段)
|
||||
private final ObjectMapper objectMapper = new ObjectMapper()
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
private final ConcurrentHashMap<String, UserInteractionState> userInteractionStates = new ConcurrentHashMap<>();
|
||||
private HashMap<String, String> cacheMap = new HashMap<>();
|
||||
|
||||
@@ -855,6 +859,9 @@ public class JDUtil {
|
||||
public void cleanUpTimeoutStates() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
redisTemplate.keys(INTERACTION_STATE_PREFIX + "*").forEach(key -> {
|
||||
if (key == null || key.startsWith(WECOM_SESSION_REDIS_PREFIX)) {
|
||||
return;
|
||||
}
|
||||
String stateJson = redisTemplate.opsForValue().get(key);
|
||||
try {
|
||||
UserInteractionState state = objectMapper.readValue(stateJson, UserInteractionState.class);
|
||||
|
||||
Reference in New Issue
Block a user