|
@@ -4,9 +4,12 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.google.common.base.Stopwatch;
|
|
|
import com.tzld.piaoquan.recommend.server.repository.WxVideoTagRel;
|
|
|
import com.tzld.piaoquan.recommend.server.repository.WxVideoTagRelRepository;
|
|
|
+import com.tzld.piaoquan.recommend.server.util.CommonCollectionUtils;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -35,7 +38,10 @@ public class VideoCityFilterService {
|
|
|
|
|
|
@ApolloJsonValue("${video.filter.city.tagid.json:{}}")
|
|
|
private Map<String, List<Long>> videoFilterCityTagIdMap;
|
|
|
-
|
|
|
+ @Value("#{'${block.hotscenetype.list:}'.split(',')}")
|
|
|
+ private Set<Long> excludeScenes;
|
|
|
+ @Value("${securityAbExpCode:625}")
|
|
|
+ private String securityAbExpCode;
|
|
|
@Resource
|
|
|
private WxVideoTagRelRepository wxVideoTagRelRepository;
|
|
|
private Map<String, Set<Long>> videoTagCache = new ConcurrentHashMap<>();
|
|
@@ -66,27 +72,31 @@ public class VideoCityFilterService {
|
|
|
if (Objects.isNull(cityCode) || Objects.isNull(tagList) || tagList.isEmpty()) {
|
|
|
continue;
|
|
|
}
|
|
|
- for (Long tagId : tagList) {
|
|
|
- if (tagId == null || tagId <= 0L) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- Set<Long> videosByTag = wxVideoTagRelRepository.findAllByTagId(tagId).stream().map(WxVideoTagRel::getVideoId).collect(Collectors.toSet());
|
|
|
- tmp.put(cityCode, videosByTag);
|
|
|
- }
|
|
|
+ Set<Long> videosByTag = wxVideoTagRelRepository.findAllByTagIdIn(tagList).stream()
|
|
|
+ .map(WxVideoTagRel::getVideoId).collect(Collectors.toSet());
|
|
|
+ tmp.put(cityCode, videosByTag);
|
|
|
}
|
|
|
videoTagCache = tmp;
|
|
|
logger.info("initCacheByValue videoTagCache.size = {} execute time = {}", videoTagCache.size(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
|
|
|
|
|
|
}
|
|
|
|
|
|
- public List<Long> filterVideosByCity(List<Long> videoIds, String cityCode) {
|
|
|
- if (videoIds == null || videoIds.isEmpty() || StringUtils.isBlank(cityCode)) {
|
|
|
+ public List<Long> filterVideosByCity(List<Long> videoIds, Set<String> abExpCodes,
|
|
|
+ Long hotSceneType, String cityCode) {
|
|
|
+ if (CollectionUtils.isEmpty(videoIds) || StringUtils.isBlank(cityCode) || hotSceneType == null) {
|
|
|
+ return videoIds;
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(excludeScenes) && excludeScenes.contains(hotSceneType)) {
|
|
|
+ return videoIds;
|
|
|
+ }
|
|
|
+ if (!CommonCollectionUtils.contains(abExpCodes, securityAbExpCode)) {
|
|
|
return videoIds;
|
|
|
}
|
|
|
List<Long> tagIdList = videoFilterCityTagIdMap.get(cityCode);
|
|
|
if (tagIdList == null || tagIdList.isEmpty()) {
|
|
|
return videoIds;
|
|
|
}
|
|
|
+
|
|
|
videoIds.removeIf(videoId -> {
|
|
|
if (videoId == null || videoId <= 0L) {
|
|
|
return true;
|