|
|
@@ -697,22 +697,9 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
* 获取车队信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public Set<ChatgptCarInfoView> getCarInfoList(String userToken, Integer limit, Boolean isPlus) {
|
|
|
- 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(), historyView.getCarName(), historyView.getIsPLus(), redisService.zScore(RedisService.key.CHATGPT_CAR_SCORES.getName(), historyView.getCarId()));
|
|
|
- chatgptCarInfoView.setIsHistory(true);
|
|
|
- chatgptCarInfoView.setScore(Math.min(redisService.zScore(RedisService.key.CHATGPT_CAR_SCORES.getName(), historyView.getCarId()), 200));
|
|
|
-
|
|
|
- return chatgptCarInfoView;
|
|
|
- }).collect(Collectors.toCollection(LinkedHashSet::new));
|
|
|
-
|
|
|
- Set<ChatgptCarInfoView> lowestScoreFleets = getLowestScoreFleets(limit, isPlus);
|
|
|
-
|
|
|
- res.addAll(lowestScoreFleets);
|
|
|
-
|
|
|
- return res;
|
|
|
+ public List<ChatgptCarInfoView> getCarInfoList(String userToken, Integer limit, Boolean isPlus) {
|
|
|
+ List<ChatgptCarInfoView> lowestScoreFleets = getLowestScoreFleets(limit, isPlus);
|
|
|
+ return lowestScoreFleets;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -758,22 +745,11 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
|
|
|
|
|
|
// 获取得分最低的N个车队的方法
|
|
|
- public Set<ChatgptCarInfoView> getLowestScoreFleets(int count, Boolean isPlus) {
|
|
|
- Set<ZSetOperations.TypedTuple<Object>> lowestScorecarIds;
|
|
|
- Long fleetsSize = redisService.zCard(RedisService.key.CHATGPT_CAR_SCORES.getName());
|
|
|
- // 构建ChatgptCarInfoView集合
|
|
|
- if (fleetsSize != null && fleetsSize > 10) {
|
|
|
- TASK_EXECUTOR.execute(() -> {
|
|
|
- initFleets(true);
|
|
|
- });
|
|
|
- } else {
|
|
|
- initFleets(false);
|
|
|
- }
|
|
|
- lowestScorecarIds = redisService.zRangeWithScores(RedisService.key.CHATGPT_CAR_SCORES.getName(), 0L, count - 1);
|
|
|
- Map<Object, Double> collect = lowestScorecarIds.stream().collect(Collectors.toMap(ZSetOperations.TypedTuple::getValue, ZSetOperations.TypedTuple::getScore));
|
|
|
- List<ChatgptSession> chatgptSessions = chatgptSessionMapper.selectList(Wrappers.lambdaQuery(ChatgptSession.class).in(ChatgptSession::getCarId, collect.keySet()).eq(isPlus !=null && isPlus, ChatgptSession::getIsPlus, true));
|
|
|
- return chatgptSessions.stream().map((chatgptSession)-> buildChatgptCarInfoView(chatgptSession.getCarId(),chatgptSession.getCarName(), chatgptSession.getIsPlus(), collect.get(chatgptSession.getCarId())))
|
|
|
- .sorted(Comparator.comparing(ChatgptCarInfoView::getScore)).collect(Collectors.toCollection(LinkedHashSet::new));
|
|
|
+ public List<ChatgptCarInfoView> getLowestScoreFleets(int count, Boolean isPlus) {
|
|
|
+ List<ChatgptCarInfoView> chatgptCarInfoViews = beanSearcher.searchList(ChatgptCarInfoView.class, MapUtils.builder().field(ChatgptCarInfoView::getIsPlus, isPlus).orderBy(ChatgptCarInfoView::getScore).desc().limit(0, count).build());
|
|
|
+
|
|
|
+ chatgptCarInfoViews.forEach(this::buildChatgptCarInfoView);
|
|
|
+ return chatgptCarInfoViews;
|
|
|
}
|
|
|
|
|
|
public void initFleets(Boolean flag) {
|
|
|
@@ -796,21 +772,18 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
|
|
|
|
|
|
// 构建ChatgptCarInfoView对象
|
|
|
- private ChatgptCarInfoView buildChatgptCarInfoView(String carId, String carName, Integer isPlus, Double score) {
|
|
|
+ private ChatgptCarInfoView buildChatgptCarInfoView(ChatgptCarInfoView view) {
|
|
|
// 在这里根据carId获取相关信息并填充到ChatgptCarInfoView对象中
|
|
|
- ChatgptCarInfoView view = new ChatgptCarInfoView();
|
|
|
- view.setCarId(carId);
|
|
|
- // 假设以下方法从Redis或其他服务获取数据
|
|
|
- view.setScore(Math.min(score, 200));
|
|
|
- view.setStatus(score >= 50 ? "繁忙" : "空闲"); // 或“繁忙”
|
|
|
|
|
|
- if(carName.contains("T")){
|
|
|
+ view.setStatus(view.getScore() >= 50 ? "繁忙" : "空闲"); // 或“繁忙”
|
|
|
+
|
|
|
+ if(view.getCarName().contains("T") && view.getIsPlus() == 1){
|
|
|
view.setType("Team");
|
|
|
- Long team = carOaiLimit(carId, true);
|
|
|
+ Long team = carOaiLimit(view.getCarId(), true);
|
|
|
if (team != 0L) {
|
|
|
view.setTeamExpTime(new DateTime(System.currentTimeMillis() + team * 1000));
|
|
|
}
|
|
|
- Long aLong = carOaiLimit(carId, false);
|
|
|
+ Long aLong = carOaiLimit(view.getCarId(), false);
|
|
|
if (aLong != 0L) {
|
|
|
view.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
|
|
|
}
|
|
|
@@ -820,17 +793,15 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
|
|
|
view.setStatus("部分停运");
|
|
|
}
|
|
|
}else {
|
|
|
- view.setType(isPlus == 1 ? "Plus" : "3.5");
|
|
|
- Long aLong = carOaiLimit(carId, false);
|
|
|
+ view.setType(view.getIsPlus() == 1 ? "Plus" : "3.5");
|
|
|
+ Long aLong = carOaiLimit(view.getCarId(), false);
|
|
|
if (aLong != 0L) {
|
|
|
view.setStatus("停运");
|
|
|
view.setExpTime(new DateTime(System.currentTimeMillis() + aLong * 1000));
|
|
|
}
|
|
|
}
|
|
|
- int use = getCarConversationCount(carId, 3L).intValue();
|
|
|
+ int use = getCarConversationCount(view.getCarId(), 3L).intValue();
|
|
|
view.setUse(use);
|
|
|
-
|
|
|
- view.setCarName(carName);
|
|
|
return view;
|
|
|
}
|
|
|
|