Authored by 胡古飞

增加商品特征是否存在的字段

... ... @@ -972,6 +972,10 @@
"type": "string",
"index": "not_analyzed"
},
"productFeatureFactorExist": {
"type": "string",
"index": "not_analyzed"
},
"pools": {
"type": "nested",
"properties": {
... ...
package com.yoho.search.consumer.service.bo;
import com.alibaba.fastjson.JSONArray;
import java.io.Serializable;
import java.math.BigDecimal;
import com.alibaba.fastjson.JSONArray;
/**
* 商品实体索引
*
... ... @@ -99,6 +99,7 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
private String tblCountryName;
private String productFeatureFactor;
private String productFeatureFactorExist;
// from product_pool_detail
private JSONArray pools;
... ... @@ -521,7 +522,15 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
this.productFeatureFactor = productFeatureFactor;
}
public Integer getTblBrandId() {
public String getProductFeatureFactorExist() {
return productFeatureFactorExist;
}
public void setProductFeatureFactorExist(String productFeatureFactorExist) {
this.productFeatureFactorExist = productFeatureFactorExist;
}
public Integer getTblBrandId() {
return tblBrandId;
}
... ...
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");
}
}
}
}
... ...