Authored by 胡古飞

ufostorageprice支持showChannel参数过滤

@@ -4,14 +4,13 @@ import com.yoho.search.consumer.index.fullbuild.IIndexBuilder; @@ -4,14 +4,13 @@ import com.yoho.search.consumer.index.fullbuild.IIndexBuilder;
4 import com.yoho.search.consumer.service.bo.ufo.UfoStoragePriceIndexBO; 4 import com.yoho.search.consumer.service.bo.ufo.UfoStoragePriceIndexBO;
5 import com.yoho.search.consumer.service.logicService.cache.UfoBasicDataCacheService; 5 import com.yoho.search.consumer.service.logicService.cache.UfoBasicDataCacheService;
6 import com.yoho.search.consumer.service.logicService.tbl.util.StringUtils; 6 import com.yoho.search.consumer.service.logicService.tbl.util.StringUtils;
  7 +import com.yoho.search.dal.UfoProductMapper;
7 import com.yoho.search.dal.UfoSecondhandImagesMapper; 8 import com.yoho.search.dal.UfoSecondhandImagesMapper;
8 import com.yoho.search.dal.UfoStorageMapper; 9 import com.yoho.search.dal.UfoStorageMapper;
9 import com.yoho.search.dal.UfoStoragePriceMapper; 10 import com.yoho.search.dal.UfoStoragePriceMapper;
10 -import com.yoho.search.dal.model.ufo_product.SecondhandImages;  
11 -import com.yoho.search.dal.model.ufo_product.Size;  
12 -import com.yoho.search.dal.model.ufo_product.Storage;  
13 -import com.yoho.search.dal.model.ufo_product.StoragePrice; 11 +import com.yoho.search.dal.model.ufo_product.*;
14 import org.apache.commons.collections.CollectionUtils; 12 import org.apache.commons.collections.CollectionUtils;
  13 +import org.apache.commons.collections.MapUtils;
15 import org.springframework.beans.BeanUtils; 14 import org.springframework.beans.BeanUtils;
16 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.stereotype.Component; 16 import org.springframework.stereotype.Component;
@@ -23,6 +22,8 @@ import java.util.stream.Collectors; @@ -23,6 +22,8 @@ import java.util.stream.Collectors;
23 public class UfoStoragePriceIndexBuilder extends IIndexBuilder { 22 public class UfoStoragePriceIndexBuilder extends IIndexBuilder {
24 23
25 @Autowired 24 @Autowired
  25 + private UfoProductMapper ufoProductMapper;
  26 + @Autowired
26 private UfoStoragePriceMapper ufoStoragePriceMapper; 27 private UfoStoragePriceMapper ufoStoragePriceMapper;
27 @Autowired 28 @Autowired
28 private UfoSecondhandImagesMapper ufoSecondhandImagesMapper; 29 private UfoSecondhandImagesMapper ufoSecondhandImagesMapper;
@@ -48,7 +49,7 @@ public class UfoStoragePriceIndexBuilder extends IIndexBuilder { @@ -48,7 +49,7 @@ public class UfoStoragePriceIndexBuilder extends IIndexBuilder {
48 } 49 }
49 50
50 public List<UfoStoragePriceIndexBO> buildUfoStoragePriceIndexBOListByStoragePriceIds(List<Integer> storagePriceIds) { 51 public List<UfoStoragePriceIndexBO> buildUfoStoragePriceIndexBOListByStoragePriceIds(List<Integer> storagePriceIds) {
51 - if(storagePriceIds==null || storagePriceIds.isEmpty()){ 52 + if (storagePriceIds == null || storagePriceIds.isEmpty()) {
52 return new ArrayList<>(); 53 return new ArrayList<>();
53 } 54 }
54 List<StoragePrice> storagePrices = ufoStoragePriceMapper.selectListByPrimaryKeys(storagePriceIds); 55 List<StoragePrice> storagePrices = ufoStoragePriceMapper.selectListByPrimaryKeys(storagePriceIds);
@@ -59,25 +60,31 @@ public class UfoStoragePriceIndexBuilder extends IIndexBuilder { @@ -59,25 +60,31 @@ public class UfoStoragePriceIndexBuilder extends IIndexBuilder {
59 if (CollectionUtils.isEmpty(storagePrices)) { 60 if (CollectionUtils.isEmpty(storagePrices)) {
60 return new ArrayList<>(); 61 return new ArrayList<>();
61 } 62 }
62 - List<Integer> skupIds = new ArrayList<>(); 63 + List<Integer> productIds = new ArrayList<>();
63 List<Integer> storageIds = new ArrayList<>(); 64 List<Integer> storageIds = new ArrayList<>();
  65 + List<Integer> skupIds = new ArrayList<>();
64 for (StoragePrice storagePrice : storagePrices) { 66 for (StoragePrice storagePrice : storagePrices) {
65 - skupIds.add(storagePrice.getSkup()); 67 + productIds.add(storagePrice.getProductId());
66 storageIds.add(storagePrice.getStorageId()); 68 storageIds.add(storagePrice.getStorageId());
  69 + skupIds.add(storagePrice.getSkup());
67 } 70 }
  71 + // 获取show_channel信息
  72 + Map<Integer, String> showChannelMap = this.buildShowChannelMap(productIds);
68 // 构建尺码信息 73 // 构建尺码信息
69 Map<Integer, Short> storageId2SizeId = this.buildStorageId2SizeId(storageIds); 74 Map<Integer, Short> storageId2SizeId = this.buildStorageId2SizeId(storageIds);
70 // 构建二手图片信息 75 // 构建二手图片信息
71 Map<Integer, String> skupSecondhandImageMap = this.buildSkupSecondhandImageMap(skupIds); 76 Map<Integer, String> skupSecondhandImageMap = this.buildSkupSecondhandImageMap(skupIds);
72 // 获取尺码信息 77 // 获取尺码信息
73 Map<Short, Size> sizeMap = ufoBasicDataCacheService.getUfoSize(); 78 Map<Short, Size> sizeMap = ufoBasicDataCacheService.getUfoSize();
74 -  
75 // 构建结果 79 // 构建结果
76 List<UfoStoragePriceIndexBO> results = new ArrayList<>(); 80 List<UfoStoragePriceIndexBO> results = new ArrayList<>();
77 for (StoragePrice storagePrice : storagePrices) { 81 for (StoragePrice storagePrice : storagePrices) {
78 UfoStoragePriceIndexBO ufoStoragePriceIndexBO = new UfoStoragePriceIndexBO(); 82 UfoStoragePriceIndexBO ufoStoragePriceIndexBO = new UfoStoragePriceIndexBO();
79 BeanUtils.copyProperties(storagePrice, ufoStoragePriceIndexBO); 83 BeanUtils.copyProperties(storagePrice, ufoStoragePriceIndexBO);
80 - // 处理尺码 84 + // 1) 处理showChannel
  85 + String showChannel = MapUtils.getString(showChannelMap, storagePrice.getProductId(), "");
  86 + ufoStoragePriceIndexBO.setShowChannel(showChannel);
  87 + // 2) 处理尺码
81 Short sizeId = storageId2SizeId.get(storagePrice.getStorageId()); 88 Short sizeId = storageId2SizeId.get(storagePrice.getStorageId());
82 if (sizeId != null) { 89 if (sizeId != null) {
83 ufoStoragePriceIndexBO.setSizeId(Integer.valueOf(sizeId)); 90 ufoStoragePriceIndexBO.setSizeId(Integer.valueOf(sizeId));
@@ -87,14 +94,23 @@ public class UfoStoragePriceIndexBuilder extends IIndexBuilder { @@ -87,14 +94,23 @@ public class UfoStoragePriceIndexBuilder extends IIndexBuilder {
87 ufoStoragePriceIndexBO.setSizeId(-1); 94 ufoStoragePriceIndexBO.setSizeId(-1);
88 ufoStoragePriceIndexBO.setSizeName(""); 95 ufoStoragePriceIndexBO.setSizeName("");
89 } 96 }
90 - // 处理二手图片 97 + // 3) 处理二手图片
91 String imageUrl = skupSecondhandImageMap.get(storagePrice.getSkup()); 98 String imageUrl = skupSecondhandImageMap.get(storagePrice.getSkup());
92 ufoStoragePriceIndexBO.setSecondhandImage(imageUrl == null ? "" : imageUrl); 99 ufoStoragePriceIndexBO.setSecondhandImage(imageUrl == null ? "" : imageUrl);
  100 + // 4) 添加结果
93 results.add(ufoStoragePriceIndexBO); 101 results.add(ufoStoragePriceIndexBO);
94 } 102 }
95 return results; 103 return results;
96 } 104 }
97 105
  106 + private Map<Integer, String> buildShowChannelMap(List<Integer> productIds) {
  107 + if (CollectionUtils.isEmpty(productIds)) {
  108 + return new HashMap<>();
  109 + }
  110 + List<Product> productList = ufoProductMapper.selectByIdList(productIds);
  111 + return productList.stream().collect(Collectors.toMap(Product::getId, Product::getShowChannel));
  112 + }
  113 +
98 private Map<Integer, Short> buildStorageId2SizeId(List<Integer> storageIdList) { 114 private Map<Integer, Short> buildStorageId2SizeId(List<Integer> storageIdList) {
99 if (CollectionUtils.isEmpty(storageIdList)) { 115 if (CollectionUtils.isEmpty(storageIdList)) {
100 return new HashMap<>(); 116 return new HashMap<>();
@@ -120,7 +136,7 @@ public class UfoStoragePriceIndexBuilder extends IIndexBuilder { @@ -120,7 +136,7 @@ public class UfoStoragePriceIndexBuilder extends IIndexBuilder {
120 continue; 136 continue;
121 } 137 }
122 // 兜底 138 // 兜底
123 - if(!skupSecondhandImageMap.containsKey(secondhandImages.getSkup())){ 139 + if (!skupSecondhandImageMap.containsKey(secondhandImages.getSkup())) {
124 skupSecondhandImageMap.put(secondhandImages.getSkup(), secondhandImages.getImageUrl()); 140 skupSecondhandImageMap.put(secondhandImages.getSkup(), secondhandImages.getImageUrl());
125 } 141 }
126 } 142 }
@@ -47,6 +47,10 @@ @@ -47,6 +47,10 @@
47 "sizeName": { 47 "sizeName": {
48 "type": "text", 48 "type": "text",
49 "index": "no" 49 "index": "no"
  50 + },
  51 + "showChannel": {
  52 + "type": "text",
  53 + "analyzer": "comma_spliter"
50 } 54 }
51 } 55 }
52 } 56 }
@@ -19,6 +19,9 @@ public class UfoStoragePriceIndexBO { @@ -19,6 +19,9 @@ public class UfoStoragePriceIndexBO {
19 private Integer preSaleFlag; 19 private Integer preSaleFlag;
20 private Integer region; 20 private Integer region;
21 21
  22 + //from ufo_product
  23 + private String showChannel;
  24 +
22 // 二手图片 from secondhand_images 25 // 二手图片 from secondhand_images
23 private String secondhandImage; 26 private String secondhandImage;
24 27