1
|
package com.yoho.search.consumer.service.logic.productIndex.viewBuilder;
|
1
|
package com.yoho.search.consumer.service.logic.productIndex.viewBuilder;
|
2
|
|
2
|
|
3
|
-import com.yoho.search.consumer.service.bo.ProductIndexBO;
|
|
|
4
|
-import com.yoho.search.consumer.service.logic.ProductVectorFeatureLogicService;
|
3
|
+import java.util.List;
|
|
|
4
|
+import java.util.Map;
|
|
|
5
|
+
|
|
|
6
|
+import org.apache.commons.lang.StringUtils;
|
5
|
import org.springframework.beans.factory.annotation.Autowired;
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
6
|
import org.springframework.stereotype.Component;
|
8
|
import org.springframework.stereotype.Component;
|
7
|
|
9
|
|
8
|
-import java.util.List;
|
|
|
9
|
-import java.util.Map;
|
|
|
10
|
-import java.util.Optional;
|
10
|
+import com.yoho.search.consumer.service.bo.ProductIndexBO;
|
|
|
11
|
+import com.yoho.search.consumer.service.logic.ProductVectorFeatureLogicService;
|
11
|
|
12
|
|
12
|
/**
|
13
|
/**
|
13
|
* Created by wangnan on 2017/1/10.
|
14
|
* Created by wangnan on 2017/1/10.
|
|
@@ -15,13 +16,21 @@ import java.util.Optional; |
|
@@ -15,13 +16,21 @@ import java.util.Optional; |
15
|
@Component
|
16
|
@Component
|
16
|
public class ProductFeatureFactorBuilder implements ViewBuilder {
|
17
|
public class ProductFeatureFactorBuilder implements ViewBuilder {
|
17
|
|
18
|
|
18
|
- @Autowired
|
|
|
19
|
- private ProductVectorFeatureLogicService productVectorFeatureLogicService;
|
|
|
20
|
-
|
|
|
21
|
- @Override
|
|
|
22
|
- public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> sknList) {
|
|
|
23
|
- Map<Integer, String> productVectorFeatureMapBaseSknMap = productVectorFeatureLogicService.queryProductVectorFeatureMap(sknList);
|
|
|
24
|
- productIndexBOs.stream().forEach(productIndexBO -> productIndexBO.setProductFeatureFactor(Optional.ofNullable(productVectorFeatureMapBaseSknMap.get(productIndexBO.getProductSkn()))
|
|
|
25
|
- .orElse(null)));
|
|
|
26
|
- }
|
19
|
+ @Autowired
|
|
|
20
|
+ private ProductVectorFeatureLogicService productVectorFeatureLogicService;
|
|
|
21
|
+
|
|
|
22
|
+ @Override
|
|
|
23
|
+ public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> sknList) {
|
|
|
24
|
+ Map<Integer, String> productVectorFeatureMapBaseSknMap = productVectorFeatureLogicService.queryProductVectorFeatureMap(sknList);
|
|
|
25
|
+ for (ProductIndexBO productIndexBO : productIndexBOs) {
|
|
|
26
|
+ String productVectorFeature = productVectorFeatureMapBaseSknMap.get(productIndexBO.getProductSkn());
|
|
|
27
|
+ if (StringUtils.isBlank(productVectorFeature)) {
|
|
|
28
|
+ productIndexBO.setProductFeatureFactor(null);
|
|
|
29
|
+ productIndexBO.setProductFeatureFactorExist("N");
|
|
|
30
|
+ } else {
|
|
|
31
|
+ productIndexBO.setProductFeatureFactor(productVectorFeature);
|
|
|
32
|
+ productIndexBO.setProductFeatureFactorExist("Y");
|
|
|
33
|
+ }
|
|
|
34
|
+ }
|
|
|
35
|
+ }
|
27
|
} |
36
|
} |