Authored by wangnan9279

fix bug

... ... @@ -129,7 +129,7 @@ public class CustomizeTagBaseService {
private Map<String, List<CustomizeTag>> buildCustomizeTagMap() {
try {
Map<String, List<CustomizeTag>> customizeTagBOMap = new HashMap();
List<CustomizeTag> customizeTagList = this.queryValidCustomizeTags(null);
List<CustomizeTag> customizeTagList = this.queryValidCustomizeTags();
if (CollectionUtils.isEmpty(customizeTagList)) {
return new HashMap<>();
}
... ... @@ -154,14 +154,40 @@ public class CustomizeTagBaseService {
}
/**
* 查CustomizeTag索引,可以查指定的poolId的
* 查CustomizeTag索引,需要满足默认条件
*/
private List<CustomizeTag> queryValidCustomizeTags(Collection<?> poolIds) throws Exception {
private List<CustomizeTag> queryValidCustomizeTags() throws Exception {
SearchParam searchParam = new SearchParam();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
if (CollectionUtils.isNotEmpty(poolIds)) {
boolQueryBuilder.must(QueryBuilders.termsQuery("poolId", poolIds));
boolQueryBuilder.must(QueryBuilders.termQuery("status", 1));
long currentTime = DateUtil.getCurrentTimeSecond();
boolQueryBuilder.must(QueryBuilders.rangeQuery("beginTime").lt(currentTime));
boolQueryBuilder.must(QueryBuilders.rangeQuery("endTime").gt(currentTime));
searchParam.setFiter(boolQueryBuilder);
searchParam.setSize(10000);
SearchResult searchResult = searchCommonService.doSearch(ISearchConstants.INDEX_NAME_CUSTOMIZE_TAG, searchParam);
if (searchResult == null || CollectionUtils.isEmpty(searchResult.getResultList())) {
return Collections.emptyList();
}
List<CustomizeTag> resultList = new ArrayList<>();
for (Map<String, Object> esMap : searchResult.getResultList()) {
if (!esMap.isEmpty()) {
resultList.add(parseCustomizeTagInfo(esMap));
}
}
return resultList;
}
/**
* 查CustomizeTag索引,用poolid过滤和满足默认条件
*/
private List<CustomizeTag> queryValidCustomizeTagsWithPoolId(Collection<?> poolIds) throws Exception {
if (CollectionUtils.isEmpty(poolIds)) {
return Collections.emptyList();
}
SearchParam searchParam = new SearchParam();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must(QueryBuilders.termsQuery("poolId", poolIds));
boolQueryBuilder.must(QueryBuilders.termQuery("status", 1));
long currentTime = DateUtil.getCurrentTimeSecond();
boolQueryBuilder.must(QueryBuilders.rangeQuery("beginTime").lt(currentTime));
... ... @@ -205,7 +231,7 @@ public class CustomizeTagBaseService {
*/
public List<Map<String, Object>> getTagListByIds(List<String> poolIdList, int maxReturnSize) {
try {
List<CustomizeTag> customizeTagBOList = this.queryValidCustomizeTags(poolIdList);
List<CustomizeTag> customizeTagBOList = this.queryValidCustomizeTagsWithPoolId(poolIdList);
if (CollectionUtils.isEmpty(customizeTagBOList)) {
return new ArrayList<>();
}
... ...