From b41a6efe17ba61d150c5a9b7309651cebae54e0d Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 03 九月 2021 16:40:43 +0800 Subject: [PATCH] 韩迷TV相关bug修改,电视直播完善(后台+前端API) --- src/main/java/com/yeshi/buwan/service/imp/SearchService.java | 64 +++++++++++++++++++++---------- 1 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/imp/SearchService.java b/src/main/java/com/yeshi/buwan/service/imp/SearchService.java index 8707401..8d765cd 100644 --- a/src/main/java/com/yeshi/buwan/service/imp/SearchService.java +++ b/src/main/java/com/yeshi/buwan/service/imp/SearchService.java @@ -10,10 +10,10 @@ import com.yeshi.buwan.domain.web.HotSearchAdmin; import com.yeshi.buwan.dto.search.SolrResultDTO; import com.yeshi.buwan.dto.search.SolrVideoSearchFilter; -import com.yeshi.buwan.pptv.PPTVUtil; +import com.yeshi.buwan.videos.pptv.PPTVUtil; import com.yeshi.buwan.service.inter.video.VideoInfoExtraService; -import com.yeshi.buwan.service.manager.SolrAlbumVideoDataManager; -import com.yeshi.buwan.service.manager.SolrInternetSearchVideoDataManager; +import com.yeshi.buwan.service.manager.search.SolrAlbumVideoDataManager; +import com.yeshi.buwan.service.manager.search.SolrInternetSearchVideoDataManager; import com.yeshi.buwan.util.*; import com.yeshi.buwan.util.factory.VideoInfoFactory; import com.yeshi.buwan.util.video.VideoConstant; @@ -34,6 +34,8 @@ @Service public class SearchService { private Logger logger = LoggerFactory.getLogger(SearchService.class); + + private final String ALBUM_SEARCH_FUZZY_KEYS = "銆�,銆�,銆�"; @Resource @@ -288,7 +290,7 @@ } - private SearchResult searchAlbum(int videoType, String key, int page, int pageSize) { + public SearchResult searchAlbum(int videoType, String key, List<Long> resourceIds, int page, int pageSize) { List<VideoInfo> localList = new ArrayList<>(); //涓撹緫瑙嗛闆嗗悎 Set<String> solrAlbumVids = new HashSet<>(); @@ -296,10 +298,17 @@ SolrVideoSearchFilter filter = new SolrVideoSearchFilter(); filter.setKey(key); if (videoType == Constant.SEARCH_RESULT_TYPE_HIGH_DEFINITION) { - filter.setResourceIds(new String[]{PPTVUtil.RESOURCE_ID + ""}); + filter.setResourceIds(Arrays.asList(new String[]{PPTVUtil.RESOURCE_ID + ""})); logger.info("楂樻竻鎼滅储# key锛歿}", key); - } else + } else { + + List<String> rids = new ArrayList<>(); + for (Long rid : resourceIds) { + rids.add(rid + ""); + } + filter.setResourceIds(rids); filter.setVideoType(videoType == 0 ? null : videoType); + } filter.setContentType(1); SolrResultDTO solrResultDTO = solrAlbumDataManager.find(filter, page, pageSize); @@ -316,7 +325,7 @@ } } - //绗竴椤�,涓嶄负楂樻竻,涓绘悳绱㈠紩鎿庢棤娉曟悳绱㈠埌鍐呭鏃舵悳绱� + //绗竴椤�,涓嶄负楂樻竻鏃舵悳绱� if (page == 1 && videoType != Constant.SEARCH_RESULT_TYPE_HIGH_DEFINITION) { //page涓�1鏃� 鍏ㄧ綉鎼� SolrResultDTO internetSearchResultDTO = solrInternetSearchVideoDataManager.find(filter, 1, 20); @@ -327,7 +336,7 @@ isvList.addAll(iList); //鍒犻櫎鍓嶉潰鏈夌殑鏁版嵁锛屾牴鎹畆ootType涓庡悕绉扮瓫閫� for (int i = 0; i < isvList.size(); i++) { - String uniqueId = isvList.get(i).getName() + "#" + isvList.get(i).getRootType(); + String uniqueId = isvList.get(i).getName() + "#" + isvList.get(i).getRootType() + "#" + isvList.get(i).getYear(); if (albumSet.contains(uniqueId)) { isvList.remove(i); i--; @@ -344,19 +353,30 @@ } } } - //todo 鎸夊叧閿瘝鐨勫尮閰嶅害鎺掑簭 - - Comparator<VideoInfo> cm = new Comparator<VideoInfo>() { - @Override - public int compare(VideoInfo o1, VideoInfo o2) { + //鎸夊叧閿瘝鐨勫尮閰嶅害鎺掑簭 + Comparator<VideoInfo> cm = (VideoInfo o1, VideoInfo o2) -> { + if (o1.getDefinition() - o2.getDefinition() == 0) { float s1 = CompareStrSimUtil.getSimilarityRatio(o1.getName(), key, true); float s2 = CompareStrSimUtil.getSimilarityRatio(o2.getName(), key, true); - return s2 > s1 ? 1 : -1; +// if (s1 != s2)//鐩镐技搴﹁秺楂樿秺闈犲墠 + try { + return s1 != s2 ? (s2 > s1 ? 1 : -1) : (Integer.parseInt(o2.getYear()) - Integer.parseInt(o1.getYear())); + } catch (Exception e) { + return s2 > s1 ? 1 : -1; + } +// else +// return o1.getDefinition() - o2.getDefinition();//楂樻竻鎺掑湪鍓� + } else { + return o2.getDefinition() - o1.getDefinition();//楂樻竻鎺掑湪鍓� } + }; - Collections.sort(localList,cm); - + Collections.sort(localList, cm); + } + //鏈悳绱㈠埌鍐呭 + if (localList == null || localList.size() == 0) { + logger.warn("涓撹緫鎼滅储鏃犵粨鏋�#{}", key); } return new SearchResult(albumCount, localList); } @@ -411,9 +431,11 @@ if (!StringUtil.isNullOrEmpty(key) && key.length() > 30) key = key.substring(0, 30); sh.setKey(key); - UserInfo user = new UserInfo(); - user.setId(uid); - sh.setUser(user); + if (uid != null) { + UserInfo user = new UserInfo(); + user.setId(uid); + sh.setUser(user); + } searchDao.create(sh); // 鏌ヨ鏁版嵁搴� @@ -429,7 +451,7 @@ localList = new ArrayList<>(); //鍏堟悳绱笓杈� int pageSize = 20; - SearchResult searchResult = searchAlbum(videoType, key, page, pageSize); + SearchResult searchResult = searchAlbum(videoType, key, resourceList, page, pageSize); if (searchResult != null && searchResult.videoInfoList != null) { localList.addAll(searchResult.videoInfoList); } @@ -727,7 +749,7 @@ } - class SearchResult { + public static class SearchResult { private int totalCount; private List<VideoInfo> videoInfoList; -- Gitblit v1.8.0