|
|
package com.yoho.search.consumer.service.logic.productIndex.viewBuilder;
|
|
|
|
|
|
import com.yoho.search.consumer.service.bo.ProductIndexBO;
|
|
|
import com.yoho.search.consumer.service.logic.ProductVectorFeatureLogicService;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
import com.yoho.search.consumer.service.bo.ProductIndexBO;
|
|
|
import com.yoho.search.consumer.service.logic.ProductVectorFeatureLogicService;
|
|
|
|
|
|
/**
|
|
|
* Created by wangnan on 2017/1/10.
|
...
|
...
|
@@ -15,13 +16,21 @@ import java.util.Optional; |
|
|
@Component
|
|
|
public class ProductFeatureFactorBuilder implements ViewBuilder {
|
|
|
|
|
|
@Autowired
|
|
|
private ProductVectorFeatureLogicService productVectorFeatureLogicService;
|
|
|
|
|
|
@Override
|
|
|
public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> sknList) {
|
|
|
Map<Integer, String> productVectorFeatureMapBaseSknMap = productVectorFeatureLogicService.queryProductVectorFeatureMap(sknList);
|
|
|
productIndexBOs.stream().forEach(productIndexBO -> productIndexBO.setProductFeatureFactor(Optional.ofNullable(productVectorFeatureMapBaseSknMap.get(productIndexBO.getProductSkn()))
|
|
|
.orElse(null)));
|
|
|
}
|
|
|
@Autowired
|
|
|
private ProductVectorFeatureLogicService productVectorFeatureLogicService;
|
|
|
|
|
|
@Override
|
|
|
public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> sknList) {
|
|
|
Map<Integer, String> productVectorFeatureMapBaseSknMap = productVectorFeatureLogicService.queryProductVectorFeatureMap(sknList);
|
|
|
for (ProductIndexBO productIndexBO : productIndexBOs) {
|
|
|
String productVectorFeature = productVectorFeatureMapBaseSknMap.get(productIndexBO.getProductSkn());
|
|
|
if (StringUtils.isBlank(productVectorFeature)) {
|
|
|
productIndexBO.setProductFeatureFactor(null);
|
|
|
productIndexBO.setProductFeatureFactorExist("N");
|
|
|
} else {
|
|
|
productIndexBO.setProductFeatureFactor(productVectorFeature);
|
|
|
productIndexBO.setProductFeatureFactorExist("Y");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|