|
@@ -5,14 +5,12 @@ import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.cyksj.common.constant.Constant;
|
|
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.StringUtil;
|
|
import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.mapper.*;
|
|
import com.cyksj.mapper.*;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.request.gpt.ConversationRequest;
|
|
import com.cyksj.model.request.gpt.ConversationRequest;
|
|
|
import com.cyksj.model.response.ConversationLimitResponse;
|
|
import com.cyksj.model.response.ConversationLimitResponse;
|
|
|
-import com.cyksj.model.views.ChatGptUserView;
|
|
|
|
|
import com.cyksj.model.views.ClaudeUserView;
|
|
import com.cyksj.model.views.ClaudeUserView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.claude.ClaudeService;
|
|
import com.cyksj.service.claude.ClaudeService;
|
|
@@ -24,7 +22,6 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
@@ -140,7 +137,7 @@ public class ClaudeServiceImpl implements ClaudeService {
|
|
|
claudeUserConversationRecordMapper.insert(claudeUserConversationRecord);
|
|
claudeUserConversationRecordMapper.insert(claudeUserConversationRecord);
|
|
|
|
|
|
|
|
|
|
|
|
|
- String key = RedisService.key.CHATGPT_CONVERSATION_LIMIT.getName() + ":" + userToken;
|
|
|
|
|
|
|
+ String key = RedisService.key.CLAUDE_CONVERSATION_LIMIT.getName() + ":" + userToken;
|
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
|
|
|
|
|
|
if (redisService.hasKey("claude:clears_in:" + conversationRequest.getCarId())) {
|
|
if (redisService.hasKey("claude:clears_in:" + conversationRequest.getCarId())) {
|
|
@@ -220,6 +217,14 @@ public class ClaudeServiceImpl implements ClaudeService {
|
|
|
return currentSize != null ? currentSize : 0L;
|
|
return currentSize != null ? currentSize : 0L;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Long carLimit(String carId) {
|
|
|
|
|
+ if(redisService.hasKey("claude:clears_in:" + carId)){
|
|
|
|
|
+ return redisService.getExpire("claude:clears_in:" + carId);
|
|
|
|
|
+ }
|
|
|
|
|
+ return 0L;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取车位信息
|
|
* 获取车位信息
|
|
@@ -358,7 +363,7 @@ public class ClaudeServiceImpl implements ClaudeService {
|
|
|
private void recalculateScore(String carId, long currentTimestamp) {
|
|
private void recalculateScore(String carId, long currentTimestamp) {
|
|
|
// 实际应用中,你需要根据高级体验和低级体验的数量重新计算得分
|
|
// 实际应用中,你需要根据高级体验和低级体验的数量重新计算得分
|
|
|
double highExperienceScore = (double) redisService.zCount(RedisService.key.CLAUDE_CAR_CHAT.getName() + carId, currentTimestamp - (3 * 60 * 60 * 1000), currentTimestamp) * 2;
|
|
double highExperienceScore = (double) redisService.zCount(RedisService.key.CLAUDE_CAR_CHAT.getName() + carId, currentTimestamp - (3 * 60 * 60 * 1000), currentTimestamp) * 2;
|
|
|
- redisService.zAdd(RedisService.key.CHATGPT_CAR_SCORES.getName(), highExperienceScore, carId);
|
|
|
|
|
|
|
+ redisService.zAdd(RedisService.key.CLAUDE_CAR_SCORES.getName(), highExperienceScore, carId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|