Showing
1 changed file
with
16 additions
and
9 deletions
@@ -63,7 +63,7 @@ public class ProductIndexFeatureVectorUpdateFlow implements RetryBusinessFlow { | @@ -63,7 +63,7 @@ public class ProductIndexFeatureVectorUpdateFlow implements RetryBusinessFlow { | ||
63 | productVectorFeatureLogicService.updateGenerateDate(); | 63 | productVectorFeatureLogicService.updateGenerateDate(); |
64 | this.versionDate = productVectorFeatureLogicService.getGenerateDate(); | 64 | this.versionDate = productVectorFeatureLogicService.getGenerateDate(); |
65 | } | 65 | } |
66 | - | 66 | + |
67 | @Override | 67 | @Override |
68 | public int getTotalCount() { | 68 | public int getTotalCount() { |
69 | if (StringUtils.isEmpty(this.versionDate)) { | 69 | if (StringUtils.isEmpty(this.versionDate)) { |
@@ -85,18 +85,25 @@ public class ProductIndexFeatureVectorUpdateFlow implements RetryBusinessFlow { | @@ -85,18 +85,25 @@ public class ProductIndexFeatureVectorUpdateFlow implements RetryBusinessFlow { | ||
85 | return true; | 85 | return true; |
86 | } | 86 | } |
87 | List<Integer> sknList = productList.stream().map(Product::getErpProductId).collect(Collectors.toList()); | 87 | List<Integer> sknList = productList.stream().map(Product::getErpProductId).collect(Collectors.toList()); |
88 | - Map<Integer, Integer> skn2IDMap = productList.stream().collect(Collectors.toMap(Product::getErpProductId, Product::getId)); | ||
89 | Map<Integer, String> productVectorFeatureMapBaseSkn = productVectorFeatureLogicService.queryProductVectorFeatureMap(sknList); | 88 | Map<Integer, String> productVectorFeatureMapBaseSkn = productVectorFeatureLogicService.queryProductVectorFeatureMap(sknList); |
90 | logger.info("[{} business][pageNo={}][productVectorFeatureMapBaseSknSize={}]", flowName(), pageNo, productVectorFeatureMapBaseSkn.size()); | 89 | logger.info("[{} business][pageNo={}][productVectorFeatureMapBaseSknSize={}]", flowName(), pageNo, productVectorFeatureMapBaseSkn.size()); |
91 | List<JSONObject> dataList = new ArrayList<JSONObject>(); | 90 | List<JSONObject> dataList = new ArrayList<JSONObject>(); |
92 | - productVectorFeatureMapBaseSkn.forEach((skn, vector) -> { | ||
93 | - if (skn2IDMap.get(skn) != null) { | ||
94 | - JSONObject product = new JSONObject(); | ||
95 | - product.put("id", skn2IDMap.get(skn)); | ||
96 | - product.put("productFeatureFactor", vector); | ||
97 | - dataList.add(product); | 91 | + |
92 | + for (Product product : productList) { | ||
93 | + Integer productId = product.getId(); | ||
94 | + String vector = productVectorFeatureMapBaseSkn.get(product.getErpProductId()); | ||
95 | + JSONObject updateData = new JSONObject(); | ||
96 | + if (StringUtils.isBlank(vector)) { | ||
97 | + updateData.put("id", productId); | ||
98 | + updateData.put("productFeatureFactor", ""); | ||
99 | + updateData.put("productFeatureFactorExist", "N"); | ||
100 | + } else { | ||
101 | + updateData.put("id", productId); | ||
102 | + updateData.put("productFeatureFactor", vector); | ||
103 | + updateData.put("productFeatureFactorExist", "Y"); | ||
98 | } | 104 | } |
99 | - }); | 105 | + dataList.add(updateData); |
106 | + } | ||
100 | if (CollectionUtils.isEmpty(dataList)) { | 107 | if (CollectionUtils.isEmpty(dataList)) { |
101 | return true; | 108 | return true; |
102 | } | 109 | } |
-
Please register or login to post a comment