| | |
| | | package com.yeshi.buwan.service.imp.juhe; |
| | | |
| | | import com.yeshi.buwan.dao.VideoInfoDao; |
| | | import com.yeshi.buwan.dao.juhe.hanmi.HanmiShowDao; |
| | | import com.yeshi.buwan.dao.juhe.hanmi.HanmiShowEpisodeDao; |
| | | import com.yeshi.buwan.dao.juhe.hanmi.VideoHanmiMapDao; |
| | | import com.yeshi.buwan.dao.video.AlbumVideoMapDao; |
| | | import com.yeshi.buwan.domain.AdminInfo; |
| | | import com.yeshi.buwan.domain.VideoDetailInfo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.domain.VideoResource; |
| | | import com.yeshi.buwan.domain.entity.PlayUrl; |
| | | import com.yeshi.buwan.domain.video.AlbumVideoMap; |
| | | 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.domain.video.InternetSearchVideo; |
| | | import com.yeshi.buwan.service.imp.VideoResourceService; |
| | | import com.yeshi.buwan.service.inter.juhe.HanmiService; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import com.yeshi.buwan.util.factory.InternetSearchVideoFactory; |
| | | import com.yeshi.buwan.videos.hanmi.HanmiUtil; |
| | | import com.yeshi.buwan.videos.hanmi.entity.HanmiShow; |
| | | import com.yeshi.buwan.videos.hanmi.entity.HanmiShowEpisode; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | private VideoHanmiMapDao videoHanmiMapDao; |
| | | |
| | | @Resource |
| | | private VideoInfoService videoInfoService; |
| | | |
| | | @Resource |
| | | private VideoInfoDao videoInfoDao; |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | @Resource |
| | | private CategoryVideoService categoryVideoService; |
| | | private InternetSearchVideoService internetSearchVideoService; |
| | | |
| | | @Resource |
| | | private VideoResourceService videoResourceService; |
| | | |
| | | @Resource |
| | | private AlbumVideoMapDao albumVideoMapDao; |
| | | |
| | | public List<VideoDetailInfo> getVideoDetailList(String videoId, int page, int pageSize) { |
| | | //查询专辑 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void addToVideoInfo(HanmiShow show) { |
| | | |
| | | public void addToInternetSearch(HanmiShow show) throws Exception { |
| | | if (StringUtil.isNullOrEmpty(show.getTitle())) { |
| | | return; |
| | | } |
| | | |
| | | VideoInfo newVideoInfo = convertShowToVideoInfo(show); |
| | | VideoHanmiMap map = videoHanmiMapDao.selectByShowId(show.getId()); |
| | | if (map != null) {//渠道视频已经存在 |
| | | VideoInfo videoInfo = videoInfoService.getVideoInfo(map.getVideoId() + ""); |
| | | if (videoInfo == null) |
| | | InternetSearchVideo video = InternetSearchVideoFactory.create(show); |
| | | if (internetSearchVideoService.save(video) == null) { |
| | | return; |
| | | newVideoInfo.setId(videoInfo.getId()); |
| | | if (!newVideoInfo.getTag().equalsIgnoreCase(videoInfo.getTag()) || newVideoInfo.getVideocount() != videoInfo.getVideocount()) { |
| | | newVideoInfo.setCreatetime(videoInfo.getCreatetime()); |
| | | //更新信息tag信息 |
| | | videoInfo.setLatestHpicture(newVideoInfo.getLatestHpicture()); |
| | | videoInfo.setLatestVpicture(newVideoInfo.getLatestVpicture()); |
| | | videoInfo.setVideocount(newVideoInfo.getVideocount()); |
| | | videoInfo.setTag(newVideoInfo.getTag()); |
| | | videoInfo.setPicture(newVideoInfo.getPicture()); |
| | | videoInfo.setHpicture(newVideoInfo.getHpicture()); |
| | | videoInfo.setVpicture(newVideoInfo.getVpicture()); |
| | | videoInfo.setShow(newVideoInfo.getShow()); |
| | | videoInfo.setVideoType(newVideoInfo.getVideoType()); |
| | | videoInfo.setUpdatetime(newVideoInfo.getUpdatetime()); |
| | | videoInfoService.update(videoInfo); |
| | | } |
| | | } else {//视频不存在 |
| | | //判断2个视频实体是否为同一视频 |
| | | VideoInfo oldVideo = videoInfoService.getExistSameVideoWithTime(newVideoInfo); |
| | | if (oldVideo == null) { |
| | | //添加视频 |
| | | Serializable id = videoInfoService.save(newVideoInfo); |
| | | newVideoInfo.setId(id + ""); |
| | | } else {//为同一视频 |
| | | //更新tag |
| | | newVideoInfo.setId(oldVideo.getId()); |
| | | oldVideo.setLatestHpicture(newVideoInfo.getLatestHpicture()); |
| | | oldVideo.setLatestVpicture(newVideoInfo.getLatestVpicture()); |
| | | oldVideo.setVideocount(newVideoInfo.getVideocount()); |
| | | oldVideo.setTag(newVideoInfo.getTag()); |
| | | oldVideo.setPicture(newVideoInfo.getPicture()); |
| | | oldVideo.setHpicture(newVideoInfo.getHpicture()); |
| | | oldVideo.setVpicture(newVideoInfo.getVpicture()); |
| | | oldVideo.setShow(newVideoInfo.getShow()); |
| | | oldVideo.setVideoType(newVideoInfo.getVideoType()); |
| | | oldVideo.setUpdatetime(newVideoInfo.getUpdatetime()); |
| | | videoInfoService.update(oldVideo); |
| | | } |
| | | |
| | | //加入专辑视频映射 |
| | | AlbumVideoMap vmap = new AlbumVideoMap(); |
| | | vmap.setId(newVideoInfo.getId()); |
| | | vmap.setCreateTime(new Date()); |
| | | vmap.setVideoId(newVideoInfo.getId()); |
| | | vmap.setRootVideoType(newVideoInfo.getVideoType().getId()); |
| | | vmap.setVideoCount(newVideoInfo.getVideocount()); |
| | | albumVideoMapDao.save(vmap); |
| | | |
| | | |
| | | //加入映射 |
| | | VideoHanmiMap vi = new VideoHanmiMap(); |
| | | vi.setShowId(show.getId()); |
| | | vi.setVideoId(newVideoInfo.getId()); |
| | | videoHanmiMapDao.save(vi); |
| | | } |
| | | |
| | | //添加视频来源映射 |
| | | resourceVideoService.addVideoResource(newVideoInfo.getId(), HanmiUtil.RESOURCE_ID + ""); |
| | | //添加视频分类映射 |
| | | categoryVideoService.addCategoryVideo(newVideoInfo.getId(), newVideoInfo.getVideoType().getId()); |
| | | |
| | | //加入专辑搜索引擎 |
| | | CMQManager.getInstance().addSolrMsg(newVideoInfo.getId()); |
| | | VideoHanmiMap map = new VideoHanmiMap(); |
| | | map.setShowId(show.getId()); |
| | | map.setVideoId(video.getId()); |
| | | map.setCreateTime(new Date()); |
| | | videoHanmiMapDao.save(map); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (map != null) { |
| | | HanmiShow show = hanmiShowDao.get(map.getShowId()); |
| | | if (show != null) { |
| | | if ("韩剧".equalsIgnoreCase(show.getType())) { |
| | | if ("电视剧".equalsIgnoreCase(show.getType())) { |
| | | return 2; |
| | | } |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public VideoInfo convertShowToVideoInfo(HanmiShow show) { |
| | | Calendar ca = Calendar.getInstance(); |
| | | ca.setTimeInMillis(TimeUtil.convertGernalTime(show.getRelaseDate(), "yyyy-MM-dd")); |
| | | int day = ca.get(Calendar.DAY_OF_MONTH); |
| | | int month = ca.get(Calendar.MONTH) + 1; |
| | | int year = ca.get(Calendar.YEAR); |
| | | |
| | | VideoInfo video = new VideoInfo(); |
| | | video.setArea(show.getArea()); |
| | | video.setBaseurl(show.getUrl()); |
| | | video.setCanSave(false); |
| | | video.setCommentCount(0); |
| | | video.setCreatetime(System.currentTimeMillis()); |
| | | video.setDay(day + ""); |
| | | video.setYear(year + ""); |
| | | video.setMonth(month + ""); |
| | | video.setDirector(show.getDirector()); |
| | | video.setFinish("1"); |
| | | video.setIntroduction(show.getDesc()); |
| | | video.setMainActor(show.getActors()); |
| | | video.setName(show.getTitle()); |
| | | video.setNowNumber(show.getEpisodeList().size() + ""); |
| | | |
| | | video.setOrderby("0" + ""); |
| | | video.setPicture(show.getPicture()); |
| | | video.setVpicture(show.getPicture()); |
| | | |
| | | video.setScore(show.getScore()); |
| | | video.setShare("0"); |
| | | video.setShow("1"); |
| | | |
| | | video.setThirdType("1"); |
| | | video.setTotalNumber("0"); |
| | | |
| | | video.setWatchCount(0 + ""); |
| | | |
| | | video.setAdmin(new AdminInfo("1")); |
| | | video.setContentType(1); |
| | | video.setCommentCount(0); |
| | | |
| | | String tag = show.getTag(); |
| | | video.setTag(tag); |
| | | |
| | | |
| | | long videoCount = show.getEpisodeList().size(); |
| | | if (videoCount == 0L) |
| | | videoCount = 1; |
| | | |
| | | video.setVideocount((int) videoCount); |
| | | |
| | | video.setUpdatetime(System.currentTimeMillis() + ""); |
| | | |
| | | video.setVideoType(HanmiUtil.getVideoType(show)); |
| | | return video; |
| | | } |
| | | |
| | | @Override |
| | |
| | | hanmiShowEpisodeDao.delete(episode.getId()); |
| | | } |
| | | } |
| | | |
| | | |
| | | VideoHanmiMap bean = videoHanmiMapDao.selectByShowId(id); |
| | | if (bean != null) { |
| | | videoHanmiMapDao.delete(bean.getVideoId()); |
| | | //删除资源 |
| | | resourceVideoService.delete(bean.getVideoId() + "", HanmiUtil.RESOURCE_ID + ""); |
| | | resourceVideoService.delete(bean.getVideoId() + "", HanmiUtil.RESOURCE_ID + ""); |
| | | internetSearchVideoService.removeResourceId(bean.getVideoId(), HanmiUtil.RESOURCE_ID); |
| | | } |
| | | } |
| | | |
| | |
| | | if (show != null) { |
| | | show.setEpisodeList(hanmiShowEpisodeDao.listByShowId(id, 0, 1000)); |
| | | } |
| | | |
| | | return show; |
| | | } |
| | | |
| | | @Override |
| | | public List<HanmiShow> listAll(int page, int pageSize) { |
| | | return hanmiShowDao.listAll((page-1)*pageSize, pageSize); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public long countAll() { |
| | | return hanmiShowDao.countAll(); |
| | | } |
| | | } |