...
|
...
|
@@ -11,7 +11,6 @@ import com.yoho.search.dal.model.Brand; |
|
|
import com.yoho.search.dal.model.Product;
|
|
|
import com.yoho.search.dal.model.ProductSort;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
...
|
...
|
@@ -21,10 +20,7 @@ import org.springframework.context.ApplicationContext; |
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -53,7 +49,8 @@ public class ProductIndexLogicService implements ApplicationContextAware { |
|
|
logger.warn("There is no viewBuilder defined.");
|
|
|
return;
|
|
|
}
|
|
|
viewBuilderList = beanMap.values().stream().collect(Collectors.toList());
|
|
|
viewBuilderList = beanMap.values().stream().sorted(Comparator.comparing(ViewBuilder::getOrder)).collect(Collectors.toList());
|
|
|
System.out.println(viewBuilderList.stream().map(viewBuilder -> viewBuilder.getClass().getSimpleName() + ":" + viewBuilder.getOrder()).collect(Collectors.joining()));
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -137,42 +134,9 @@ public class ProductIndexLogicService implements ApplicationContextAware { |
|
|
}
|
|
|
viewBuilderList.stream().forEach(viewBuilder -> {
|
|
|
viewBuilder.build(productIndexBOs, ids, skns);
|
|
|
logger.info("ProductIndex is Building,running viewBuilder success", viewBuilder.getClass().getSimpleName());
|
|
|
});
|
|
|
|
|
|
// 构造一个由风格、款式和属性拼接而成的关键词字段 用于关键词推荐
|
|
|
productIndexBOs.forEach(productIndexBO -> {
|
|
|
productIndexBO.setProductAttrField(contrustAttrField(productIndexBO));
|
|
|
});
|
|
|
|
|
|
return productIndexBOs;
|
|
|
}
|
|
|
|
|
|
private String contrustAttrField(ProductIndexBO productIndexBO) {
|
|
|
StringBuffer sb = new StringBuffer(100);
|
|
|
String value = productIndexBO.getStyle();
|
|
|
if(StringUtils.isNotEmpty(value)){
|
|
|
sb.append(value).append(',');
|
|
|
}
|
|
|
|
|
|
value = productIndexBO.getStandardOnlyNames();
|
|
|
if(StringUtils.isNotEmpty(value)){
|
|
|
sb.append(value).append(',');
|
|
|
}
|
|
|
|
|
|
value = productIndexBO.getAttributeNames();
|
|
|
if(StringUtils.isNotEmpty(value)){
|
|
|
sb.append(value).append(',');
|
|
|
}
|
|
|
|
|
|
value = productIndexBO.getPattern();
|
|
|
if(StringUtils.isNotEmpty(value)){
|
|
|
sb.append(value).append(',');
|
|
|
}
|
|
|
|
|
|
if(sb.length() == 0){
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
return sb.substring(0, sb.length() - 1).replaceAll("\\/", ",");
|
|
|
}
|
|
|
} |
...
|
...
|
|