Authored by wangnan9279

列表返回视频 fix

... ... @@ -106,12 +106,10 @@ public class GoodsImagesMqListener extends AbstractMqListener {
// 2、更新图片的时候检查下是否存在视频
String specialSearchFieldVideo = "";
String hasVideo = "N";
String videoUrl = "";
Map<Integer, String> productIdVideoMap = videosBuilder.queryHasVideosProductIds(Arrays.asList(productId));
if (productIdVideoMap.containsKey(productId)) {
Set<Integer> hasVideosProductIds = videosBuilder.queryHasVideosProductIds(Arrays.asList(productId));
if (hasVideosProductIds.contains(productId)) {
specialSearchFieldVideo = specialSearchFieldLogicService.getSpecialSearchFieldVideo(true);
hasVideo = "Y";
videoUrl = productIdVideoMap.get(productId);
}
// 3、更新商品索引
Map<String, Object> indexData = new HashMap<String, Object>();
... ... @@ -120,7 +118,6 @@ public class GoodsImagesMqListener extends AbstractMqListener {
indexData.put(ProductIndexEsField.goodsList, goodInfoList);
indexData.put(ProductIndexEsField.specialSearchFieldVideo, specialSearchFieldVideo);
indexData.put(ProductIndexEsField.hasVideo, hasVideo);
indexData.put(ProductIndexEsField.videoUrl, videoUrl);
indexData.put(ProductIndexEsField.cover_1, productGoodsBO.getCover_1());
indexData.put(ProductIndexEsField.cover_2, productGoodsBO.getCover_2());
this.updateProductIndexWithDataMap(indexData, productId);
... ...
... ... @@ -725,9 +725,6 @@
},
"hasVideo": {
"type": "keyword"
},
"videoUrl": {
"type": "keyword"
}
}
}
... ...
... ... @@ -117,7 +117,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
// from videos
private String specialSearchFieldVideo;
private String hasVideo;
private String videoUrl;
// from product_heat_values
private BigDecimal heatValue;
... ... @@ -170,14 +169,6 @@ public class ProductIndexBO extends ProductIBO implements Serializable {
//from in_storage_time
private Integer inStorageTime;
public String getVideoUrl() {
return videoUrl;
}
public void setVideoUrl(String videoUrl) {
this.videoUrl = videoUrl;
}
public String getHasVideo() {
return hasVideo;
}
... ...
... ... @@ -234,7 +234,6 @@ public class ProductIndexBOToMapService {
map.put(ProductIndexEsField.pools, productIndexBO.getPools());
map.put(ProductIndexEsField.isZeroHelp, productIndexBO.getIsZeroHelp());
map.put(ProductIndexEsField.hasVideo, productIndexBO.getHasVideo());
map.put(ProductIndexEsField.videoUrl, productIndexBO.getVideoUrl());
return map;
}
... ...
... ... @@ -28,49 +28,36 @@ public class VideosBuilder implements IndexFieldBuilder {
@Override
public void build(List<ProductIndexBO> productIndexBOs, List<Integer> ids, List<Integer> sknList) {
Map<Integer, String> productIdVideoMap = this.queryHasVideosProductIds(ids);
Set<Integer> productIdSet = this.queryHasVideosProductIds(ids);
for (ProductIndexBO pi : productIndexBOs) {
boolean hasVideo = productIdVideoMap.containsKey(pi.getProductId());
boolean hasVideo = productIdSet.contains(pi.getProductId());
String specialSearchFieldVideo = specialSearchFieldLogicService.getSpecialSearchFieldVideo(hasVideo);
pi.setSpecialSearchFieldVideo(specialSearchFieldVideo);
pi.setHasVideo(hasVideo ? "Y" : "N");
pi.setVideoUrl(productIdVideoMap.get(pi.getProductId()));
}
}
public Map<Integer, String> queryHasVideosProductIds(List<Integer> productIds) {
Map<Integer, String> productIdVideoUrlMap = new HashMap<>();
for (Integer productId : productIds) {
List<Integer> productIdList = new ArrayList<>(1);
productIdList.add(productId);
List<GoodsImages> goodsImagesList = goodsImagesService.selectListByProductIds(productIdList);
if (CollectionUtils.isEmpty(goodsImagesList)) {
continue;
}
List<Integer> videosIds = new ArrayList<>();
for (GoodsImages goodsImages : goodsImagesList) {
if (goodsImages.getVedioUrlId() != null) {
//if (goodsImages.getIsDefault().equals("Y")) {
videosIds.add(goodsImages.getVedioUrlId());
//}
}
}
if (CollectionUtils.isEmpty(videosIds)) {
continue;
}
List<Videos> videoListByProductIds = videosService.getVideoListByIds(videosIds);
if (CollectionUtils.isEmpty(videoListByProductIds)) {
return productIdVideoUrlMap;
}
Map<Integer, Videos> videosMap = videoListByProductIds.stream().collect(Collectors.toMap(Videos::getId, videos -> videos));
for (Integer videosId : videosIds) {
if (videosMap.containsKey(videosId)) {
Videos videos = videosMap.get(videosId);
productIdVideoUrlMap.put(productId, videos.getUrl());
}
public Set<Integer> queryHasVideosProductIds(List<Integer> productIds) {
Set<Integer> productIdSet = new HashSet<>();
List<GoodsImages> goodsImagesList = goodsImagesService.selectListByProductIds(productIds);
if (CollectionUtils.isEmpty(goodsImagesList)) {
return productIdSet;
}
List<Integer> videosIds = goodsImagesList.stream().filter(a -> a.getVedioUrlId() != null).map(GoodsImages::getVedioUrlId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(videosIds)) {
return productIdSet;
}
List<Videos> videoListByProductIds = videosService.getVideoListByIds(videosIds);
if (CollectionUtils.isEmpty(videoListByProductIds)) {
return productIdSet;
}
Map<Integer, Videos> videosMap = videoListByProductIds.stream().collect(Collectors.toMap(Videos::getId, videos -> videos));
for (GoodsImages gi : goodsImagesList) {
if (videosMap.containsKey(gi.getVedioUrlId())) {
productIdSet.add(gi.getProductId());
}
}
return productIdVideoUrlMap;
return productIdSet;
}
}
... ...