|
@@ -17,8 +17,10 @@ import com.caimei365.commodity.model.search.ProductListVo;
|
|
|
import com.caimei365.commodity.model.search.ShopListVo;
|
|
|
import com.caimei365.commodity.model.vo.*;
|
|
|
import com.caimei365.commodity.service.SearchQueryService;
|
|
|
+import com.caimei365.commodity.utils.ImageUtils;
|
|
|
import com.caimei365.commodity.utils.Json2PojoUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.util.StringUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -29,6 +31,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -255,8 +258,8 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
try {
|
|
|
// 查询推送
|
|
|
JSONObject result = searchOpenService.getResultJsonObject("count:"+docType, searchParams);
|
|
|
- if (1 == result.getInt("status") && result.getJSONArray("items").length()>=0) {
|
|
|
- return result.getJSONArray("items").length();
|
|
|
+ if (1 == result.getInt("status") && result.getInt("total")>=0) {
|
|
|
+ return result.getInt("total");
|
|
|
} else {
|
|
|
return -1;
|
|
|
}
|
|
@@ -401,16 +404,16 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson<String> queryArticleByLabel(Integer id, int pageNum, int pageSize) {
|
|
|
- String queryStr = "a_label:'" + id + "'";
|
|
|
- ArrayList<String> fetchFields = Lists.newArrayList("id", "a_id", "a_title", "a_image", "a_publisher", "a_publish_date", "a_intro", "a_pv", "a_type_id", "a_type_text", "a_label_ids", "a_label_text");
|
|
|
- // 阿里云搜索
|
|
|
- ResponseJson<String> result = scrollArticleForParams(queryStr, fetchFields, pageNum, pageSize, "a_id", 1);
|
|
|
- if (0 == result.getCode()) {
|
|
|
- return result;
|
|
|
- } else {
|
|
|
+// String queryStr = "a_label:'" + id + "'";
|
|
|
+// ArrayList<String> fetchFields = Lists.newArrayList("id", "a_id", "a_title", "a_image", "a_publisher", "a_publish_date", "a_intro", "a_pv", "a_type_id", "a_type_text", "a_label_ids", "a_label_text");
|
|
|
+// // 阿里云搜索
|
|
|
+// ResponseJson<String> result = scrollArticleForParams(queryStr, fetchFields, pageNum, pageSize, "a_id", 1);
|
|
|
+// if (0 == result.getCode()) {
|
|
|
+// return result;
|
|
|
+// } else {
|
|
|
// 阿里云搜索失败,再次从数据库搜索
|
|
|
return queryArticleFromDatabase(pageNum, pageSize, null, null, null, id);
|
|
|
- }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -430,6 +433,23 @@ public class SearchQueryServiceImpl implements SearchQueryService {
|
|
|
}
|
|
|
PageHelper.startPage(num, size);
|
|
|
List<ArticleListVo> articleList = searchMapper.queryArticle(keyword, articleId, typeId, labelText);
|
|
|
+ articleList.forEach(article -> {
|
|
|
+ String imagePath = ImageUtils.getImageURL("", article.getImage(), 0, domain);
|
|
|
+ article.setImage(imagePath);
|
|
|
+ // 搜索供应商文档数据
|
|
|
+ String[] labelTexts = article.getLabelText().split(",");
|
|
|
+ if(labelTexts.length > 0){
|
|
|
+ boolean notEmpty = StringUtil.isNotEmpty(labelTexts[0]);
|
|
|
+ if(notEmpty){
|
|
|
+ List<Integer> labelIdList = searchMapper.findLabelIdsByName(labelTexts);
|
|
|
+ StringBuilder labelIds = new StringBuilder();
|
|
|
+ labelIdList.forEach(id -> {
|
|
|
+ labelIds.append(",").append(id);
|
|
|
+ });
|
|
|
+ article.setLabelIds(labelIds.toString().replaceFirst(",",""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
PaginationVo<ArticleListVo> pageData = new PaginationVo<>(articleList);
|
|
|
int total = pageData.getTotalRecord();
|
|
|
JSONObject pageObj = new JSONObject();
|