From f537abe9f3646c739beaf15076246a2f71a347e9 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 20 二月 2025 16:57:55 +0800 Subject: [PATCH] IOS广告增加区域屏蔽 --- src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java | 211 +++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 182 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java b/src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java index cd873b2..f884ae5 100644 --- a/src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java +++ b/src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java @@ -6,21 +6,36 @@ import com.yeshi.buwan.dao.video.AlbumVideoMapDao; import com.yeshi.buwan.domain.*; import com.yeshi.buwan.domain.entity.PlayUrl; +import com.yeshi.buwan.domain.solr.SolrAlbumVideo; +import com.yeshi.buwan.domain.system.SystemConfig; import com.yeshi.buwan.domain.video.AlbumVideoMap; -import com.yeshi.buwan.iqiyi.IqiYiNewAPI; -import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; -import com.yeshi.buwan.iqiyi.entity.VideoIqiyi2; -import com.yeshi.buwan.iqiyi.util.IqiyiUtil; -import com.yeshi.buwan.iqiyi.util.IqiyiUtil2; +import com.yeshi.buwan.dto.mq.UpdateResourceVideoMQMsg; +import com.yeshi.buwan.exception.video.IqiyiVideoSolrException; +import com.yeshi.buwan.query.Iqiyi2AlbumQuery; import com.yeshi.buwan.service.imp.CategoryVideoService; import com.yeshi.buwan.service.imp.ResourceVideoService; import com.yeshi.buwan.service.imp.VideoInfoService; import com.yeshi.buwan.service.imp.VideoResourceService; +import com.yeshi.buwan.service.inter.juhe.AlbumVideoMapService; import com.yeshi.buwan.service.inter.juhe.Iqiyi2Service; +import com.yeshi.buwan.service.inter.system.SystemConfigService; +import com.yeshi.buwan.service.manager.search.SolrAlbumVideoDataManager; +import com.yeshi.buwan.util.StringUtil; +import com.yeshi.buwan.util.ThreadUtil; import com.yeshi.buwan.util.TimeUtil; -import com.yeshi.buwan.util.mq.CMQManager; -import com.yeshi.buwan.util.video.VideoConstant; +import com.yeshi.buwan.util.log.VideoLogFactory; +import com.yeshi.buwan.util.mq.rabbit.RabbitmqManager; +import com.yeshi.buwan.videos.iqiyi.IqiYiNewAPI; +import com.yeshi.buwan.videos.iqiyi.entity.IqiyiAlbum2; +import com.yeshi.buwan.videos.iqiyi.entity.VideoIqiyi2; +import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil; +import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil2; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.Serializable; @@ -32,6 +47,9 @@ @Service public class Iqiyi2ServiceImpl implements Iqiyi2Service { + + private final Logger logger = LoggerFactory.getLogger("videoUpdate"); + @Resource private VideoIqiyi2Dao videoIqiyi2Dao; @@ -56,18 +74,46 @@ @Resource private VideoResourceService videoResourceService; - public List<VideoDetailInfo> getVideoDetailList(String videoId) { + @Resource + private SystemConfigService systemConfigService; + + @Resource + private AlbumVideoMapService albumVideoMapService; + + @Resource + private SolrAlbumVideoDataManager solrAlbumVideoDataManager; + + @Resource + private RabbitmqManager rabbitmqManager; + + + + public List<VideoDetailInfo> getVideoDetailList(String videoId, int page, int pageSize) { //鏌ヨ涓撹緫 VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByVideoId(Long.parseLong(videoId)); if (videoIqiyi2 == null) return null; - IqiyiAlbum2 album = iqiyiAlbum2Dao.get(videoIqiyi2.getIqiyiId()); + final IqiyiAlbum2 album = iqiyiAlbum2Dao.get(videoIqiyi2.getIqiyiId()); +// if (album != null) { + ThreadUtil.run(new Runnable() { + @Override + public void run() { + rabbitmqManager.addUpdateResourceVideoMsg(new UpdateResourceVideoMQMsg(videoIqiyi2.getIqiyiId() + "", IqiyiUtil2.RESOURCE_ID, new Date())); + } + }); +// } + List<IqiyiAlbum2> album2List = new ArrayList<>(); if (album.getFeatureAlbumId() > 0) {//鍗曡棰� album2List.add(album); } else {//涓撹緫 - List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByAid(album.getId(), 0, 1000); + //鍒ゆ柇period瀛楁鏄惁涓虹┖ + int sort = album.isSourceAlbum() ? IqiyiAlbum2.SORT_PERIOD : IqiyiAlbum2.SORT_ORDER; + Iqiyi2AlbumQuery query = new Iqiyi2AlbumQuery(); + query.setFeatureAlbumId(album.getId()); + query.setContentType(1); + List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByAid(query, sort, (page - 1) * pageSize, pageSize); if (list != null) album2List.addAll(list); } @@ -100,10 +146,39 @@ } @Override + public void offlineIqiyiAlbum(Long id) { + //鍒犻櫎涓撹緫 + Query query = new Query(); + query.addCriteria(new Criteria().orOperator(Criteria.where("id").is(id), Criteria.where("featureAlbumId").is(id))); + //鍒犻櫎涓撹緫涓嬬殑瑙嗛 + iqiyiAlbum2Dao.delete(query); + } + + + public boolean isUnNormalUpdateVideoName(String name) { + SystemConfig config = systemConfigService.getConfigByKeyCache("iqiyi_update_video_name"); + if (config != null) { + String[] sts = config.getValue().split(","); + List<String> list = new ArrayList<>(); + for (String st : sts) { + list.add(st.trim()); + } + return list.contains(name.trim()); + } + return false; + } + + @Transactional + @Override public void addToVideoInfo(IqiyiAlbum2 album) { if (album.getFeatureAlbumId() > 0L && album.getChannelId() != IqiYiNewAPI.TYPE_DIANYING) { return; } + + if (StringUtil.isNullOrEmpty(album.getName())) { + return; + } + //鍙紦瀛樻湁鏁堢殑 if (album.getEffect() == 0) @@ -119,11 +194,18 @@ return; } - //鏍囬涓彧鑳藉寘鍚腑鑻辨枃涓庢暟瀛� - String regx = "^[(\\u4e00-\\u9fa5)( )a-zA-Z0-9]+$"; - if (!Pattern.matches(regx, album.getName())) { - return; + + if (album.getChannelId() != 1 && !isUnNormalUpdateVideoName(album.getName())) { + //鏍囬涓彧鑳藉寘鍚腑鑻辨枃涓庢暟瀛� + String regx = "^[(\\u4e00-\\u9fa5)(锛�)( )a-zA-Z0-9]+$"; + if (!Pattern.matches(regx, album.getName())) { + return; + } } + + //杩囨护鏌愪簺鐭墖涓庡奖璇� + if (album.getName().contains("銆�") && !isUnNormalUpdateVideoName(album.getName())) + return; //绌虹數瑙嗗墽鎴栬�呮槸绌哄姩婕垯杩斿洖 if (album.getChannelId() == 2 || album.getChannelId() == 4) { @@ -131,6 +213,7 @@ return; } + logger.info(VideoLogFactory.createAddToVideoLog(album)); VideoInfo newVideoInfo = convertAlbumToVideoInfo(album); VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByIqiyiId(album.getId()); @@ -139,7 +222,7 @@ if (videoInfo == null) return; newVideoInfo.setId(videoInfo.getId()); - if (!newVideoInfo.getTag().equalsIgnoreCase(videoInfo.getTag())) { + if (!newVideoInfo.getTag().equalsIgnoreCase(videoInfo.getTag()) || newVideoInfo.getVideocount() != videoInfo.getVideocount()) { newVideoInfo.setCreatetime(videoInfo.getCreatetime()); //鏇存柊淇℃伅tag淇℃伅 videoInfo.setLatestHpicture(newVideoInfo.getLatestHpicture()); @@ -151,14 +234,15 @@ videoInfo.setVpicture(newVideoInfo.getVpicture()); videoInfo.setShow(newVideoInfo.getShow()); videoInfo.setVideoType(newVideoInfo.getVideoType()); - videoInfoDao.update(videoInfo); + videoInfo.setUpdatetime(newVideoInfo.getUpdatetime()); + videoInfoService.update(videoInfo); } } else {//瑙嗛涓嶅瓨鍦� //鍒ゆ柇2涓棰戝疄浣撴槸鍚︿负鍚屼竴瑙嗛 - VideoInfo oldVideo = videoInfoService.getExistSameVideo(newVideoInfo); + VideoInfo oldVideo = videoInfoService.getExistSameVideoWithTime(newVideoInfo); if (oldVideo == null) { //娣诲姞瑙嗛 - Serializable id = videoInfoDao.save(newVideoInfo); + Serializable id = videoInfoService.save(newVideoInfo); newVideoInfo.setId(id + ""); } else {//涓哄悓涓�瑙嗛 //鏇存柊tag @@ -172,11 +256,13 @@ oldVideo.setVpicture(newVideoInfo.getVpicture()); oldVideo.setShow(newVideoInfo.getShow()); oldVideo.setVideoType(newVideoInfo.getVideoType()); - videoInfoDao.update(oldVideo); + oldVideo.setUpdatetime(newVideoInfo.getUpdatetime()); + videoInfoService.update(oldVideo); } //鍔犲叆涓撹緫瑙嗛鏄犲皠 AlbumVideoMap map = new AlbumVideoMap(); + map.setId(newVideoInfo.getId()); map.setCreateTime(new Date()); map.setVideoId(newVideoInfo.getId()); map.setRootVideoType(newVideoInfo.getVideoType().getId()); @@ -195,11 +281,12 @@ //娣诲姞瑙嗛鍒嗙被鏄犲皠 categoryVideoService.addCategoryVideo(newVideoInfo.getId(), newVideoInfo.getVideoType().getId()); - CMQManager.getInstance().addSolrMsg(newVideoInfo.getId()); + rabbitmqManager.addSolrMsg(newVideoInfo.getId()); } @Override public PlayUrl getPlayUrl(String detailSystemId, int resourceId, String id, String videoId) { + IqiyiAlbum2 album = iqiyiAlbum2Dao.get(Long.parseLong(id)); VideoResource vr = videoResourceService.getResource(resourceId + ""); int t = IqiyiUtil2.getPlayType(album); @@ -213,16 +300,31 @@ } else if (t == IqiyiUtil2.PLAY_HTML) { pu.setUrl(album.getH5Url()); } + + //闊╁墽 + if ("48".equalsIgnoreCase(detailSystemId)) { + pu.setUrl(pu.getUrl().replace("_bwap", "_hjvap")); + } + return pu; } @Override public int getShowType(String videoid) { - VideoInfo videoInfo = videoInfoDao.find(VideoInfo.class, videoid); - if (videoInfo.getVideoType() != null && (videoInfo.getVideoType().getId() == VideoConstant.VIDEO_CATEGORY_DIANSHIJU || videoInfo.getVideoType().getId() == VideoConstant.VIDEO_CATEGORY_DONGMAN)) - return 2; - else - return 1; + VideoIqiyi2 iqiyi2 = videoIqiyi2Dao.selectByVideoId(Long.parseLong(videoid)); + if (iqiyi2 != null) { + IqiyiAlbum2 album2 = iqiyiAlbum2Dao.get(iqiyi2.getIqiyiId()); + if (album2 != null) { + if (album2.getChannelId() == 4 || album2.getChannelId() == 2) { + if (album2.isSourceAlbum()) { + return 1; + } else + return 2; + } + } + } + + return 1; } @Override @@ -287,11 +389,11 @@ video.setLatestVpicture(IqiyiUtil.getVPicture(album2.getImageUrl())); } } + long videoCount = iqiyiAlbum2Dao.countVideoByAid(album.getId()); + if (videoCount == 0L) + videoCount = 1; - if (album.getTvQipuIds() != null && album.getTvQipuIds().size() > 0) - video.setVideocount(album.getTvQipuIds().size()); - else - video.setVideocount(1); + video.setVideocount((int) videoCount); video.setUpdatetime(System.currentTimeMillis() + ""); @@ -303,4 +405,55 @@ public IqiyiAlbum2 selectAlbumById(Long id) { return iqiyiAlbum2Dao.get(id); } + + @Override + public long countById(Long id) { + return iqiyiAlbum2Dao.countById(id); + } + + @Override + public void deleteByAid(long id) { + long count = iqiyiAlbum2Dao.countById(id); + if (count > 0) { + iqiyiAlbum2Dao.delete(id); + } + VideoIqiyi2 bean = videoIqiyi2Dao.selectByIqiyiId(id); + if (bean != null) { + videoIqiyi2Dao.deleteById(bean.getVideoId()); + //鍒犻櫎璧勬簮 + resourceVideoService.delete(bean.getVideoId() + "", IqiyiUtil2.RESOURCE_ID + ""); + resourceVideoService.delete(bean.getVideoId() + "", IqiyiUtil.RESOURCE_ID + ""); + } + + } + + @Override + public List<IqiyiAlbum2> listByIds(List<Long> idsList) { + return iqiyiAlbum2Dao.listByIds(idsList); + } + + @Override + public void validAlbumSolrState(Long albumId) throws IqiyiVideoSolrException { + long count = iqiyiAlbum2Dao.countById(albumId); + if (count <= 0L) { + throw new IqiyiVideoSolrException(IqiyiVideoSolrException.CODE_ALBUM_NOT_SAVE, "涓撹緫灏氭湭缂撳瓨"); + } + VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByIqiyiId(albumId); + if (videoIqiyi2 == null) { + throw new IqiyiVideoSolrException(IqiyiVideoSolrException.CODE_ALBUM_NOT_ADD_TO_VIDEO, "涓撹緫灏氭湭娣诲姞鍒拌棰戞�昏"); + } + + + AlbumVideoMap albumVideoMap = albumVideoMapService.selectByVideoId(videoIqiyi2.getVideoId() + ""); + if (albumVideoMap == null) { + throw new IqiyiVideoSolrException(IqiyiVideoSolrException.CODE_VIDEO_NOT_ADD_TO_SOLR_ALBUM, "瑙嗛鏈坊鍔犲埌涓撹緫鎼滅储鏄犲皠"); + } + + SolrAlbumVideo solrAlbumVideo = solrAlbumVideoDataManager.findOne(videoIqiyi2.getVideoId()); + if (solrAlbumVideo == null) { + throw new IqiyiVideoSolrException(IqiyiVideoSolrException.CODE_VIDEO_NOT_SYNC_TO_SOLR, "瑙嗛灏氭湭鍚屾鍒版悳绱㈠紩鎿�"); + } + + + } } -- Gitblit v1.8.0