...
|
...
|
@@ -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;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|