chenbiao 2 anni fa
parent
commit
f273d82a68

+ 7 - 7
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAccountServiceImpl.java

@@ -25,6 +25,7 @@ import com.cyksj.redis.RedisService;
 import com.cyksj.service.chatgpt.ChatGptAccountService;
 import com.cyksj.service.user.UserBindRelationService;
 import com.ejlchina.searcher.BeanSearcher;
+import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.util.MapUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -38,10 +39,7 @@ import javax.imageio.stream.FileImageOutputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.time.LocalDateTime;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -543,11 +541,12 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
      */
     @Override
     public Set<ChatgptCarInfoView> getCarInfoList(String userToken) {
-        List<ChatGptUserConversationRecordHistoryView> search = beanSearcher.searchAll(ChatGptUserConversationRecordHistoryView.class, MapUtils.builder().field("userToken", userToken).limit(0, 2).build());
-        Set<ChatgptCarInfoView> res = search.stream()
+        SearchResult<ChatGptUserConversationRecordHistoryView> search = beanSearcher.search(ChatGptUserConversationRecordHistoryView.class, MapUtils.builder().field("userToken", userToken).limit(0, 2).build());
+        Set<ChatgptCarInfoView> res = search.getDataList().stream()
                 .map((historyView) -> {
                     ChatgptCarInfoView chatgptCarInfoView = buildChatgptCarInfoView(historyView.getCarId(), redisService.zScore(RedisService.key.CHATGPT_CAR_SCORES.getName(), historyView.getCarId()));
                     chatgptCarInfoView.setIsHistory(true);
+                    chatgptCarInfoView.setScore(redisService.zScore(RedisService.key.CHATGPT_CAR_SCORES.getName(), historyView.getCarId()));
                     String sessionVar = redisService.getStr(RedisService.key.CHATGPT_CAR_SEESSION.getName() + historyView.getCarId());
                     if(JSONUtil.isJson(sessionVar)){
                         JSONObject sessionJson = new JSONObject(sessionVar);
@@ -560,7 +559,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
                     }
 
                     return chatgptCarInfoView;
-                }).collect(Collectors.toSet());
+                }).collect(Collectors.toCollection(LinkedHashSet::new));
 
         Set<ChatgptCarInfoView> lowestScoreFleets = getLowestScoreFleets(10);
 
@@ -660,6 +659,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
         ChatgptCarInfoView view = new ChatgptCarInfoView();
         view.setCarId(carId);
         // 假设以下方法从Redis或其他服务获取数据
+        view.setScore(score);
         view.setStatus(score >= 50 ? "繁忙" : "空闲"); // 或“繁忙”
         String sessionVar = redisService.getStr(RedisService.key.CHATGPT_CAR_SEESSION.getName() + carId);
         if(JSONUtil.isJson(sessionVar)){