Explorar o código

用户端 AI模糊搜索 门店列表增加营业时间状态

qinxuyang hai 1 mes
pai
achega
644ee6e1cf

+ 8 - 3
alien-store/src/main/java/shop/alien/store/controller/AiSearchController.java

@@ -108,9 +108,14 @@ public class AiSearchController {
             List<StoreInfoVo> relatedResult = convertToStoreInfoList(jsonObject.getJSONArray("related_results"),map.get("userId"));
             List<StoreInfoVo> matchedResult = convertToStoreInfoList(jsonObject.getJSONArray("matched_results"),map.get("userId"));
 
-            // 查找图片并设置到result中(图片类型1-入口图)
-            fillStoreImages(relatedResult, 1);
-            fillStoreImages(matchedResult, 1);
+            // 并发处理图片和营业时间,提升性能
+            CompletableFuture<Void> relatedImageFuture = CompletableFuture.runAsync(() -> fillStoreImages(relatedResult, 1));
+            CompletableFuture<Void> matchedImageFuture = CompletableFuture.runAsync(() -> fillStoreImages(matchedResult, 1));
+            CompletableFuture<Void> relatedBusinessHoursFuture = CompletableFuture.runAsync(() -> fillBusinessHours(relatedResult));
+            CompletableFuture<Void> matchedBusinessHoursFuture = CompletableFuture.runAsync(() -> fillBusinessHours(matchedResult));
+            
+            // 等待所有任务完成
+            CompletableFuture.allOf(relatedImageFuture, matchedImageFuture, relatedBusinessHoursFuture, matchedBusinessHoursFuture).join();
 
             // 合并两个列表
 //            List<StoreInfoVo> relatedResults = new ArrayList<>();