|
|
@@ -6,6 +6,7 @@ import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.http.Method;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -547,6 +548,17 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
.map((historyView) -> {
|
|
|
ChatgptCarInfoView chatgptCarInfoView = buildChatgptCarInfoView(historyView.getCarId(), redisService.zScore(RedisService.key.CHATGPT_CAR_SCORES.getName(), historyView.getCarId()));
|
|
|
chatgptCarInfoView.setIsHistory(true);
|
|
|
+ String sessionVar = redisService.getStr(RedisService.key.CHATGPT_CAR_SEESSION.getName() + historyView.getCarId());
|
|
|
+ if(JSONUtil.isJson(sessionVar)){
|
|
|
+ JSONObject sessionJson = new JSONObject(sessionVar);
|
|
|
+ JSONArray models = sessionJson.getJSONArray("models");
|
|
|
+ if(models.size() > 1){
|
|
|
+ chatgptCarInfoView.setType("plus");
|
|
|
+ }else {
|
|
|
+ chatgptCarInfoView.setType("3.5");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return chatgptCarInfoView;
|
|
|
}).collect(Collectors.toSet());
|
|
|
|
|
|
@@ -592,8 +604,8 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
// 重新计算指定车队的评分
|
|
|
private void recalculateScore(String carId, long currentTimestamp) {
|
|
|
// 实际应用中,你需要根据高级体验和低级体验的数量重新计算得分
|
|
|
- Double highExperienceScore = (double) redisService.zCount(RedisService.key.CHATGPT_CAR_HIGH_CHAT.getName() + carId, currentTimestamp - (3 * 60 * 60 * 1000), currentTimestamp);
|
|
|
- Double lowExperienceScore = (double) redisService.zCount(RedisService.key.CHATGPT_CAR_LOW_CHAT.getName() + carId, currentTimestamp - (3 * 60 * 60 * 1000), currentTimestamp) / 2;
|
|
|
+ Double highExperienceScore = (double) redisService.zCount(RedisService.key.CHATGPT_CAR_HIGH_CHAT.getName() + carId, currentTimestamp - (3 * 60 * 60 * 1000), currentTimestamp) * 2;
|
|
|
+ Double lowExperienceScore = (double) redisService.zCount(RedisService.key.CHATGPT_CAR_LOW_CHAT.getName() + carId, currentTimestamp - (3 * 60 * 60 * 1000), currentTimestamp);
|
|
|
double newScore = highExperienceScore + lowExperienceScore;
|
|
|
redisService.zAdd(RedisService.key.CHATGPT_CAR_SCORES.getName(), newScore, carId);
|
|
|
}
|
|
|
@@ -649,7 +661,15 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
view.setCarId(carId);
|
|
|
// 假设以下方法从Redis或其他服务获取数据
|
|
|
view.setStatus(score >= 50 ? "繁忙" : "空闲"); // 或“繁忙”
|
|
|
- view.setType("plus");
|
|
|
+ String sessionVar = redisService.getStr(RedisService.key.CHATGPT_CAR_SEESSION.getName() + carId);
|
|
|
+ if(JSONUtil.isJson(sessionVar)){
|
|
|
+ JSONArray models = new JSONObject(sessionVar).getJSONArray("models");
|
|
|
+ if(models!= null && models.size() > 1){
|
|
|
+ view.setType("plus");
|
|
|
+ }else {
|
|
|
+ view.setType("3.5");
|
|
|
+ }
|
|
|
+ }
|
|
|
view.setGptLimit(40); // 假设值
|
|
|
int use = getCarConversationCount(carId, 3L).intValue();
|
|
|
view.setUse(Math.min(use, 40));
|