| | |
| | | package com.yeshi.buwan.service.imp; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.buwan.dao.video.AlbumVideoMapDao; |
| | | import com.yeshi.buwan.dao.*; |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.video.AlbumVideoMap; |
| | | import com.yeshi.buwan.domain.web.DetailSystemSelect; |
| | | import com.yeshi.buwan.domain.web.HotSearchAdmin; |
| | | import com.yeshi.buwan.dto.search.SolrResultDTO; |
| | | import com.yeshi.buwan.service.manager.SolrAlbumDataManager; |
| | | import com.yeshi.buwan.util.*; |
| | | import com.yeshi.buwan.util.factory.VideoInfoFactory; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.vo.video.VideoListResultVO; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Session; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.orm.hibernate4.HibernateCallback; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.buwan.dao.DetailSystemDao; |
| | | import com.yeshi.buwan.dao.HotSearchDao; |
| | | import com.yeshi.buwan.dao.SearchDao; |
| | | import com.yeshi.buwan.dao.SuperHotSearchDao; |
| | | import com.yeshi.buwan.dao.VideoBanQuanVideoDao; |
| | | import com.yeshi.buwan.dao.VideoInfoDao; |
| | | import com.yeshi.buwan.domain.web.DetailSystemSelect; |
| | | import com.yeshi.buwan.domain.web.HotSearchAdmin; |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class SearchService { |
| | |
| | | @Resource |
| | | private SuperHotSearchDao superHotSearchDao; |
| | | @Resource |
| | | private ConfigService configService; |
| | | @Resource |
| | | private VideoBanQuanVideoDao videoBanQuanVideoDao; |
| | | @Resource |
| | | private DetailSystemDao detailSystemDao; |
| | | @Resource |
| | | private AlbumVideoMapDao albumVideoMapDao; |
| | | |
| | | @Resource |
| | | private SolrAlbumDataManager solrAlbumDataManager; |
| | | |
| | |
| | | |
| | | |
| | | @Cacheable(value = "userCache", key = "'searchNew'+'-'+#detailSystem+'-'+#key+'-'+#page+'-'+#videoType+'-'+#system+'-'+#cacheMD5") |
| | | public List<VideoInfo> searchNew(String detailSystem, String ip, String uid, String key, int page, int videoType, |
| | | String system, List<Long> resourceList, String cacheMD5) { |
| | | public VideoListResultVO searchNew(String detailSystem, String ip, String uid, String key, int page, int videoType, |
| | | String system, List<Long> resourceList, String cacheMD5) { |
| | | String resourceWhere = ""; |
| | | for (Long re : resourceList) { |
| | | resourceWhere += " rv.resourceid=" + re + " or"; |
| | |
| | | searchDao.create(sh); |
| | | // 查询数据库 |
| | | |
| | | //专辑数量 |
| | | long albumCount = 0L; |
| | | List<VideoInfo> list = new ArrayList<VideoInfo>(); |
| | | List<VideoInfo> localList = null; |
| | | try { |
| | |
| | | |
| | | localList = new ArrayList<>(); |
| | | //先搜索专辑 |
| | | List<SolrVideo> solrVideoList = solrAlbumDataManager.findByKey(key, 1, videoType == 0 ? null : videoType, page); |
| | | int pageSize = 20; |
| | | //专辑视频集合 |
| | | Set<String> solrAlbumVids = new HashSet<>(); |
| | | for (SolrVideo sv : solrVideoList) { |
| | | VideoInfo video = VideoInfoFactory.create(sv); |
| | | video.setShowType(1); |
| | | if (!StringUtil.isNullOrEmpty(video.getMainActor())) { |
| | | video.setMainActor("主演:" + video.getMainActor()); |
| | | } |
| | | |
| | | //设置tag |
| | | String tag = ""; |
| | | if (!StringUtil.isNullOrEmpty(sv.getYear())) { |
| | | tag += sv.getYear() + "/"; |
| | | } |
| | | SolrResultDTO solrResultDTO = solrAlbumDataManager.findByKey(key, 1, videoType == 0 ? null : videoType, page, pageSize); |
| | | if (solrResultDTO != null) { |
| | | albumCount = solrResultDTO.getTotalCount(); |
| | | |
| | | if (video.getVideoType() != null) { |
| | | String vt = VideoConstant.getMainCategoryName(sv.getRootVideoType()); |
| | | if (!StringUtil.isNullOrEmpty(vt)) { |
| | | tag += vt + "/"; |
| | | for (SolrVideo sv : solrResultDTO.getVideoList()) { |
| | | VideoInfo video = VideoInfoFactory.create(sv); |
| | | video.setShowType(1); |
| | | if (!StringUtil.isNullOrEmpty(video.getMainActor())) { |
| | | video.setMainActor("主演:" + video.getMainActor()); |
| | | } |
| | | |
| | | //设置tag |
| | | String tag = ""; |
| | | if (!StringUtil.isNullOrEmpty(sv.getYear())) { |
| | | tag += sv.getYear() + "/"; |
| | | } |
| | | |
| | | if (video.getVideoType() != null) { |
| | | String vt = VideoConstant.getMainCategoryName(sv.getRootVideoType()); |
| | | if (!StringUtil.isNullOrEmpty(vt)) { |
| | | tag += vt + "/"; |
| | | } |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(video.getArea())) { |
| | | tag += video.getArea() + "/"; |
| | | } |
| | | |
| | | if (tag.endsWith("/")) |
| | | tag = tag.substring(0, tag.length() - 1); |
| | | video.setTag(tag); |
| | | |
| | | localList.add(video); |
| | | solrAlbumVids.add(video.getId()); |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(video.getArea())) { |
| | | tag += video.getArea() + "/"; |
| | | } |
| | | |
| | | if (tag.endsWith("/")) |
| | | tag = tag.substring(0, tag.length() - 1); |
| | | video.setTag(tag); |
| | | |
| | | localList.add(video); |
| | | solrAlbumVids.add(video.getId()); |
| | | } |
| | | int commonSolrPage = page - solrResultDTO.getTotalCount() / pageSize; |
| | | |
| | | if (videoType == 0) { |
| | | if (videoType == 0 && commonSolrPage > 0) { |
| | | //搜索原始的 |
| | | List<VideoInfo> solrList = SolrUtil.search(key, page); |
| | | List<VideoInfo> solrList = SolrUtil.search(key, commonSolrPage); |
| | | for (VideoInfo vi : solrList) { |
| | | if (!solrAlbumVids.contains(vi.getId())) { |
| | | localList.add(vi); |
| | |
| | | if (sql.endsWith("union all")) |
| | | sql = sql.substring(0, sql.length() - 9); |
| | | |
| | | List rlist = videoInfoDao.sqlList(sql); |
| | | List rlist = StringUtil.isNullOrEmpty(sql) ? new ArrayList() : videoInfoDao.sqlList(sql); |
| | | List<Integer> pList = new ArrayList<Integer>(); |
| | | for (int i = 0; i < localList.size(); i++) { |
| | | if (Integer.parseInt(rlist.get(i) + "") < 1) { |
| | |
| | | list.add(info); |
| | | } |
| | | } |
| | | |
| | | return list; |
| | | return new VideoListResultVO(list, videoType == 0 ? albumCount : 1000L); |
| | | } |
| | | |
| | | public long searchCount(String key, String system) { |