From 7804263c6061aef813f0db27cb3046f746572606 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 06 三月 2021 16:07:26 +0800 Subject: [PATCH] 后台管理优化 --- src/main/java/com/yeshi/buwan/service/imp/VideoInfoService.java | 121 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 116 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/imp/VideoInfoService.java b/src/main/java/com/yeshi/buwan/service/imp/VideoInfoService.java index 9607e09..647ee25 100644 --- a/src/main/java/com/yeshi/buwan/service/imp/VideoInfoService.java +++ b/src/main/java/com/yeshi/buwan/service/imp/VideoInfoService.java @@ -1,13 +1,14 @@ package com.yeshi.buwan.service.imp; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; +import java.util.*; import javax.annotation.Resource; +import com.yeshi.buwan.util.HibernateSessionFactory; +import com.yeshi.buwan.util.StringUtil; import com.yeshi.buwan.util.TimeUtil; +import com.yeshi.buwan.util.mq.CMQManager; import com.yeshi.buwan.util.video.VideoConstant; import org.hibernate.HibernateException; import org.hibernate.SQLQuery; @@ -137,12 +138,12 @@ /** - * 鏄惁瀛樺湪鐩稿悓鐨勮棰� + * 鏄惁瀛樺湪鐩稿悓鐨勮棰�(鏍规嵁鍚嶇О涓庝笂鏄犳椂闂�) * * @param newVideoInfo * @return */ - public VideoInfo getExistSameVideo(VideoInfo newVideoInfo) { + public VideoInfo getExistSameVideoWithTime(VideoInfo newVideoInfo) { int year = Integer.parseInt(newVideoInfo.getYear()); List<VideoInfo> list = videoInfoDao.listByName(newVideoInfo.getName(), 0, 5); if (list != null && list.size() > 0) @@ -183,6 +184,54 @@ return null; } + /** + * 鏍规嵁鍚嶇О涓庝富婕� + * + * @param newVideoInfo + * @return + */ + public VideoInfo getExistSameVideoWithDirector(VideoInfo newVideoInfo) { + List<VideoInfo> list = videoInfoDao.listByName(newVideoInfo.getName(), 0, 5); + if (list != null && list.size() > 0) { + if (VideoConstant.isMainCategory(newVideoInfo.getVideoType().getId())) { + for (int i = 0; i < list.size(); i++) { + VideoInfo vi = list.get(i); + if (getSameDirectorOrActorCount(vi.getDirector(), newVideoInfo.getDirector()) > 0 || getSameDirectorOrActorCount(vi.getMainActor(), newVideoInfo.getMainActor()) > 0) { +// if (getSameDirectorOrActorCount(vi.getMainActor(), newVideoInfo.getMainActor()) > 0) { + return list.get(i); +// } + } + } + } else { + return list.get(0); + } + } + return null; + } + + private int getSameDirectorOrActorCount(String d1, String d2) { + if (!StringUtil.isNullOrEmpty(d1) && !StringUtil.isNullOrEmpty(d2)) { + List<String> d1List = new ArrayList<>(); + if (d1.contains("/")) { + d1List.addAll(Arrays.asList(d1.trim().split("/"))); + } else { + d1List.addAll(Arrays.asList(d1.trim().split(" "))); + } + + List<String> d2List = new ArrayList<>(); + if (d2.contains("/")) + d2List.addAll(Arrays.asList(d2.trim().split("/"))); + else + d2List.addAll(Arrays.asList(d2.trim().split(" "))); + + d1List.retainAll(d2List); + + return d1List.size(); + } + + return 0; + } + public List<VideoInfo> listByVideoIds(List<String> videoIds) { return videoInfoDao.listByVideoIds(videoIds); @@ -202,4 +251,66 @@ videoInfoDao.statisticVideoExtraInfo(videoId); } + /** + * 鍒楄〃鏌ヨ + * + * @param query + * @return + */ + public List<VideoInfo> list(VideoInfoDao.DaoQuery query) { + return videoInfoDao.list(query); + } + + public long count(VideoInfoDao.DaoQuery query) { + return videoInfoDao.count(query); + } + + + public void updateVideoInfo(VideoInfo videoInfo) { + VideoInfo oldVideo = videoInfoDao.find(VideoInfo.class, videoInfo.getId()); + if (oldVideo == null) + return; + + videoInfoDao.updateSelective(videoInfo); + //鏄惁闇�瑕佹洿鏂版悳绱㈠紩鎿� + boolean needUpdateSolr = false; + //tag鍙樺寲 + if (videoInfo.getTag() != null && !videoInfo.getTag().equalsIgnoreCase(oldVideo.getTag())) { + needUpdateSolr = true; + } + + //鍚嶇О鍙樺寲 + if (videoInfo.getName() != null && !videoInfo.getName().equalsIgnoreCase(oldVideo.getName())) { + needUpdateSolr = true; + } + + //picture鍙樺寲 + if (videoInfo.getHpicture() != null && !videoInfo.getHpicture().equalsIgnoreCase(oldVideo.getHpicture())) { + needUpdateSolr = true; + } + if (videoInfo.getVpicture() != null && !videoInfo.getVpicture().equalsIgnoreCase(oldVideo.getVpicture())) { + needUpdateSolr = true; + } + + if (videoInfo.getPicture() != null && !videoInfo.getPicture().equalsIgnoreCase(oldVideo.getPicture())) { + needUpdateSolr = true; + } + + //瑙嗛绫诲瀷鍙戠敓鍙樺寲 + if (videoInfo.getVideoType() != null && (oldVideo.getVideoType() == null || videoInfo.getVideoType().getId() != oldVideo.getVideoType().getId())) { + needUpdateSolr = true; + } + + //鏄惁鏄剧ず + if (videoInfo.getShow() != null && !videoInfo.getShow().equalsIgnoreCase(oldVideo.getShow())) { + needUpdateSolr = true; + } + + if (needUpdateSolr) { + CMQManager.getInstance().addSolrMsg(videoInfo.getId()); + } + + + } + } -- Gitblit v1.8.0