...
|
...
|
@@ -14,11 +14,11 @@ import java.util.stream.Collectors; |
|
|
/**
|
|
|
* Created by wangnan on 2017/5/11.
|
|
|
*/
|
|
|
public class PromotionAggregation extends AbstractSingleFieldAggregation {
|
|
|
public class ZqNameAggregation extends AbstractSingleFieldAggregation {
|
|
|
|
|
|
private ZqNameIndexBaseService zqNameIndexBaseService;
|
|
|
|
|
|
public PromotionAggregation(ZqNameIndexBaseService zqNameIndexBaseService, int count) {
|
|
|
public ZqNameAggregation(ZqNameIndexBaseService zqNameIndexBaseService, int count) {
|
|
|
super(count);
|
|
|
this.zqNameIndexBaseService = zqNameIndexBaseService;
|
|
|
}
|
...
|
...
|
@@ -30,36 +30,31 @@ public class PromotionAggregation extends AbstractSingleFieldAggregation { |
|
|
|
|
|
@Override
|
|
|
public String aggName() {
|
|
|
return "promotionAgg";
|
|
|
return "zqNameAgg";
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String filterName() {
|
|
|
return "promotion";
|
|
|
return "zqName";
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
public Object getAggregationResponseMap(Map<String, Aggregation> aggMaps) {
|
|
|
List<String> promotionIdList = (List<String>) super.getAggregationResponseMap(aggMaps);
|
|
|
if (CollectionUtils.isNotEmpty(promotionIdList)) {
|
|
|
promotionIdList = promotionIdList.stream().collect(Collectors.toList());
|
|
|
}
|
|
|
if (CollectionUtils.isEmpty(promotionIdList)) {
|
|
|
List<String> zqIdList = (List<String>) super.getAggregationResponseMap(aggMaps);
|
|
|
if (CollectionUtils.isEmpty(zqIdList)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
// 调用zqname索引查询title
|
|
|
Map<String, String> promotionParam = new HashMap<>();
|
|
|
promotionParam.put("ids", promotionIdList.stream().collect(Collectors.joining(",")));
|
|
|
List<Map<String, Object>> promotionList = zqNameIndexBaseService.queryZQNameListByParam(promotionParam);
|
|
|
// 调用zqname索引查询zqtitle
|
|
|
String ids = zqIdList.stream().collect(Collectors.joining(","));
|
|
|
List<Map<String, Object>> zqNameList = zqNameIndexBaseService.queryZQNameListByIds(ids);
|
|
|
// promotion_title去重,is_promotion用逗号连接
|
|
|
Map<String, Map<String, Object>> titleMap = new HashMap<>();
|
|
|
for (Map<String, Object> map : promotionList) {
|
|
|
for (Map<String, Object> map : zqNameList) {
|
|
|
String title = map.get("promotion_title").toString();
|
|
|
if (titleMap.containsKey(title)) {
|
|
|
String newKey = map.get("is_promotion").toString();
|
|
|
String oldKey = titleMap.get(title).get("is_promotion").toString();
|
|
|
Map<String, Object> newMap = new HashMap<String, Object>();
|
|
|
Map<String, Object> newMap = new HashMap<>();
|
|
|
newMap.put("promotion_title", title);
|
|
|
newMap.put("is_promotion", newKey + "," + oldKey);
|
|
|
titleMap.put(title, newMap);
|
...
|
...
|
@@ -67,11 +62,11 @@ public class PromotionAggregation extends AbstractSingleFieldAggregation { |
|
|
titleMap.put(title, map);
|
|
|
}
|
|
|
}
|
|
|
promotionList = new ArrayList<>();
|
|
|
zqNameList = new ArrayList<>();
|
|
|
for (Map.Entry<String, Map<String, Object>> entry : titleMap.entrySet()) {
|
|
|
promotionList.add(entry.getValue());
|
|
|
zqNameList.add(entry.getValue());
|
|
|
}
|
|
|
return promotionList == null || promotionList.isEmpty() ? new ArrayList<>() : promotionList;
|
|
|
return zqNameList == null || zqNameList.isEmpty() ? new ArrayList<>() : zqNameList;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|