| | |
| | | package com.yeshi.buwan.service.imp.juhe; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigInteger; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.apache.log4j.Logger; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Session; |
| | | import org.springframework.orm.hibernate4.HibernateCallback; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.buwan.dao.VideoInfoDao; |
| | | import com.yeshi.buwan.dao.VideoResourceDao; |
| | | import com.yeshi.buwan.dao.juhe.FunTVAlbumDao; |
| | | import com.yeshi.buwan.dao.juhe.FunTVAlbumVideoMapDao; |
| | | import com.yeshi.buwan.dao.juhe.FunTVVideoDao; |
| | | import com.yeshi.buwan.dao.juhe.VideoFunTVDao; |
| | | import com.yeshi.buwan.domain.CategoryVideo; |
| | | import com.yeshi.buwan.domain.ResourceVideo; |
| | | import com.yeshi.buwan.domain.VideoDetailInfo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.domain.VideoResource; |
| | | import com.yeshi.buwan.domain.VideoType; |
| | | import com.yeshi.buwan.domain.VideoUrl; |
| | | import com.yeshi.buwan.dao.juhe.funtv.FunTVAlbumDao; |
| | | import com.yeshi.buwan.dao.juhe.funtv.FunTVAlbumVideoMapDao; |
| | | import com.yeshi.buwan.dao.juhe.funtv.FunTVVideoDao; |
| | | import com.yeshi.buwan.dao.juhe.funtv.VideoFunTVNewDao; |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.entity.PlayUrl; |
| | | import com.yeshi.buwan.domain.push.VideoPushHistory; |
| | | import com.yeshi.buwan.funtv.FunTVUtil; |
| | |
| | | import com.yeshi.buwan.funtv.entity.FunTVAlbumVideoMap; |
| | | import com.yeshi.buwan.funtv.entity.FunTVVideo; |
| | | import com.yeshi.buwan.funtv.entity.VideoFunTV; |
| | | import com.yeshi.buwan.service.imp.BanQuanService; |
| | | import com.yeshi.buwan.service.imp.StatisticsService; |
| | | import com.yeshi.buwan.service.imp.VideoManager; |
| | | import com.yeshi.buwan.service.imp.VideoResourceService; |
| | | import com.yeshi.buwan.service.imp.VideoService; |
| | | import com.yeshi.buwan.service.imp.*; |
| | | import com.yeshi.buwan.service.imp.push.PushService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.log4j.Logger; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Session; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.orm.hibernate4.HibernateCallback; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.math.BigInteger; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class FunTVService implements IVideoDetail { |
| | | Logger log = Logger.getLogger(FunTVService.class); |
| | | @Resource |
| | | private VideoFunTVDao videoFunTVDao; |
| | | @Resource |
| | | private FunTVVideoDao funTVVideoDao; |
| | | @Resource |
| | | private FunTVAlbumDao funTVAlbumDao; |
| | | @Resource |
| | | private FunTVAlbumVideoMapDao funTVAlbumVideoMapDao; |
| | | @Resource |
| | | private VideoFunTVNewDao videoFunTVNewDao; |
| | | |
| | | @Resource |
| | | private StatisticsService statisticsService; |
| | | @Resource |
| | | private PushService pushService; |
| | | @Resource |
| | | private FunTVVideoDao funTVVideoDao; |
| | | |
| | | @Resource |
| | | private VideoService videoService; |
| | | @Resource |
| | | private VideoResourceService videoResourceService; |
| | | @Resource |
| | | private BanQuanService banQuanService; |
| | | @Resource |
| | | private FunTVAlbumDao funTVAlbumDao; |
| | | |
| | | @Resource |
| | | private VideoInfoDao videoInfoDao; |
| | | @Resource |
| | | private FunTVAlbumVideoMapDao funTVAlbumVideoMapDao; |
| | | |
| | | @Resource |
| | | private VideoResourceDao videoResourceDao; |
| | | @Resource |
| | | private StatisticsService statisticsService; |
| | | @Resource |
| | | private PushService pushService; |
| | | |
| | | @Resource |
| | | private VideoManager videoManager; |
| | | @Resource |
| | | private VideoService videoService; |
| | | @Resource |
| | | private VideoResourceService videoResourceService; |
| | | @Resource |
| | | private BanQuanService banQuanService; |
| | | |
| | | static Logger logger = Logger.getLogger(FunTVService.class); |
| | | @Resource |
| | | private VideoInfoDao videoInfoDao; |
| | | |
| | | public FunTVVideo getFunTVVideo(long id) { |
| | | return funTVVideoDao.find(FunTVVideo.class, id); |
| | | } |
| | | @Resource |
| | | private VideoResourceDao videoResourceDao; |
| | | |
| | | public Serializable saveSigleAlbum(FunTVAlbum pm) { |
| | | return funTVAlbumDao.save(pm); |
| | | } |
| | | @Resource |
| | | private VideoManager videoManager; |
| | | |
| | | public Serializable saveFunTVVideo(FunTVVideo pv) { |
| | | return funTVVideoDao.save(pv); |
| | | } |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | public void saveFunTVVideoMap(FunTVAlbumVideoMap pvm) { |
| | | funTVAlbumVideoMapDao.create(pvm); |
| | | } |
| | | static Logger logger = Logger.getLogger(FunTVService.class); |
| | | |
| | | public FunTVAlbum getAlbumByAid(String aid) { |
| | | List<FunTVAlbum> list = funTVAlbumDao.list("from FunTVAlbum a where a.aid=" + aid); |
| | | if (list != null && list.size() > 0) |
| | | return list.get(0); |
| | | else |
| | | return null; |
| | | } |
| | | //TODO 迁移走 |
| | | public FunTVAlbum getAlbumByAid(String aid) { |
| | | FunTVAlbum album = funTVAlbumDao.get(aid); |
| | | return album; |
| | | } |
| | | |
| | | public FunTVVideo getFunTVVideoByVid(String vid) { |
| | | List<FunTVVideo> list = funTVVideoDao.list("from FunTVVideo a where a.vid=" + vid); |
| | | if (list != null && list.size() > 0) |
| | | return list.get(0); |
| | | else |
| | | return null; |
| | | } |
| | | public FunTVVideo getFunTVVideoByVid(String vid) { |
| | | FunTVVideo video = funTVVideoDao.get(vid); |
| | | return video; |
| | | } |
| | | |
| | | public void saveFunTVAlbum(FunTVAlbum pm, List<FunTVVideo> videoList) { |
| | | try { |
| | | FunTVAlbum dpm = getAlbumByAid(pm.getAid()); |
| | | if (dpm == null) { |
| | | Serializable pid = saveSigleAlbum(pm); |
| | | if (pid != null) |
| | | pm.setId(Long.parseLong(pid + "")); |
| | | } else { |
| | | pm.setId(dpm.getId()); |
| | | } |
| | | public void saveAlbum(FunTVAlbum album) { |
| | | if (album.getUpdatetime() == null) |
| | | album.setUpdatetime(new Date()); |
| | | funTVAlbumDao.save(album); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | if (!e.getMessage().contains("Duplicate")) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | } |
| | | public void saveVideo(FunTVVideo video) { |
| | | funTVVideoDao.save(video); |
| | | } |
| | | |
| | | for (FunTVVideo pv : videoList) { |
| | | try { |
| | | FunTVVideo dpv = getFunTVVideoByVid(pv.getVid()); |
| | | public void saveFunTVAlbum(FunTVAlbum pm, List<FunTVVideo> videoList) { |
| | | FunTVAlbum dpm = getAlbumByAid(pm.getAid()); |
| | | if (dpm == null) { |
| | | saveAlbum(pm); |
| | | } |
| | | |
| | | if (dpv == null) { |
| | | Serializable id = saveFunTVVideo(pv); |
| | | pv.setId(Long.parseLong(id + "")); |
| | | } else |
| | | pv.setId(dpv.getId()); |
| | | } catch (Exception e) { |
| | | if (!e.getMessage().contains("Duplicate")) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | } |
| | | for (FunTVVideo pv : videoList) { |
| | | FunTVVideo dpv = getFunTVVideoByVid(pv.getVid()); |
| | | if (dpv == null) { |
| | | saveVideo(pv); |
| | | } |
| | | |
| | | FunTVAlbumVideoMap pvm = new FunTVAlbumVideoMap(); |
| | | pvm.setAlbum(pm); |
| | | pvm.setVideo(pv); |
| | | try { |
| | | saveFunTVVideoMap(pvm); |
| | | } catch (Exception e) { |
| | | if (!e.getMessage().contains("Duplicate")) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | FunTVAlbumVideoMap pvm = new FunTVAlbumVideoMap(pm.getAid(), pv.getVid()); |
| | | funTVAlbumVideoMapDao.save(pvm); |
| | | } |
| | | } |
| | | |
| | | public void saveVideo(FunTVVideo video) { |
| | | try { |
| | | if (funTVVideoDao.find(FunTVVideo.class, video.getId()) == null) |
| | | saveFunTVVideo(video); |
| | | } catch (Exception e) { |
| | | if (!e.getMessage().contains("Duplicate")) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public void updateVideoInfo(final VideoInfo info, final VideoInfo video, final FunTVAlbum p, |
| | | final boolean isUpdate) { |
| | | final VideoInfo vi = video; |
| | | videoFunTVDao.excute(new HibernateCallback() { |
| | | public Object doInHibernate(Session session) throws HibernateException { |
| | | @SuppressWarnings("unchecked") |
| | | public void updateVideoInfo(final VideoInfo info, final VideoInfo video, final FunTVAlbum p, |
| | | final boolean isUpdate) { |
| | | final VideoInfo vi = video; |
| | | videoResourceDao.excute(new HibernateCallback() { |
| | | public Object doInHibernate(Session session) throws HibernateException { |
| | | |
| | | vi.setTag(info.getTag()); |
| | | vi.setVideocount(p.getVideoList() != null ? p.getVideoList().size() : 1); |
| | | vi.setLatestHpicture(info.getLatestHpicture()); |
| | | vi.setLatestVpicture(info.getLatestVpicture()); |
| | | try { |
| | | session.getTransaction().begin(); |
| | | vi.setTag(info.getTag()); |
| | | vi.setVideocount(p.getVideoList() != null ? p.getVideoList().size() : 1); |
| | | vi.setLatestHpicture(info.getLatestHpicture()); |
| | | vi.setLatestVpicture(info.getLatestVpicture()); |
| | | try { |
| | | session.getTransaction().begin(); |
| | | |
| | | if (isUpdate) |
| | | vi.setUpdatetime(System.currentTimeMillis() + ""); |
| | | session.update(vi); |
| | | if (isUpdate) |
| | | vi.setUpdatetime(System.currentTimeMillis() + ""); |
| | | session.update(vi); |
| | | |
| | | VideoFunTV vft = new VideoFunTV(); |
| | | vft.setAlbum(new FunTVAlbum(p.getId())); |
| | | vft.setVideo(new VideoInfo(vi.getId())); |
| | | vft.setTvVideo(null); |
| | | Object obj = session |
| | | .createQuery("select count(*) from VideoFunTV vyk where vyk.video.id=? and vyk.album.id=?") |
| | | .setParameter(0, vi.getId()).setParameter(1, p.getId()).uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) {// 加入 |
| | | // session.persist(vyk); |
| | | session.createSQLQuery( |
| | | String.format("insert into wk_video_funtv (videoid, albumid) values (%s, '%s')", |
| | | vft.getVideo().getId(), vft.getAlbum().getId())) |
| | | .executeUpdate(); |
| | | } |
| | | VideoFunTV vft = new VideoFunTV(); |
| | | vft.setAid(p.getAid()); |
| | | vft.setVideoId(Long.parseLong(vi.getId())); |
| | | vft.setVid(null); |
| | | vft.setId(vft.createId()); |
| | | |
| | | obj = session.createSQLQuery(String.format( |
| | | "select count(*) from wk_resource_video rv where rv.videoid=%s and rv.resourceid=%s", |
| | | vi.getId(), 19 + "")).uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) {// 加入 |
| | | |
| | | session.createSQLQuery(String.format( |
| | | "insert into wk_resource_video(videoid,resourceid) values(%s,%s)", vi.getId(), 19 + "")) |
| | | .executeUpdate(); |
| | | } |
| | | long count = videoFunTVNewDao.countByVideoIdAndAid(Long.parseLong(vi.getId()), p.getAid()); |
| | | if (count <= 0L) {// 加入 |
| | | VideoFunTV ftv = new VideoFunTV(); |
| | | ftv.setVideoId(Long.parseLong(vi.getId())); |
| | | ftv.setAid(p.getAid()); |
| | | ftv.setId(ftv.createId()); |
| | | videoFunTVNewDao.save(ftv); |
| | | } |
| | | |
| | | // 获取最新一集的信息 |
| | | List<FunTVVideo> plist = session |
| | | .createQuery( |
| | | "select map.video from FunTVAlbumVideoMap map where map.album.id=? order by map.video.num desc") |
| | | .setParameter(0, p.getId()).setFirstResult(0).setMaxResults(1).list(); |
| | | if (plist.size() > 0) { |
| | | List<VideoDetailInfo> detailList = new ArrayList<VideoDetailInfo>(); |
| | | detailList.add(FunTVUtil.convertFunTVVideoToVideoDetail(plist.get(0), p)); |
| | | vi.setVideoDetailList(detailList); |
| | | } |
| | | session.flush(); |
| | | session.getTransaction().commit(); |
| | | } catch (Exception e) { |
| | | session.getTransaction().rollback(); |
| | | System.out.println("出错:" + e.getMessage()); |
| | | } |
| | | Object obj = session.createSQLQuery(String.format( |
| | | "select count(*) from wk_resource_video rv where rv.videoid=%s and rv.resourceid=%s", |
| | | vi.getId(), 19 + "")).uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) {// 加入 |
| | | session.createSQLQuery(String.format( |
| | | "insert into wk_resource_video(videoid,resourceid) values(%s,%s)", vi.getId(), 19 + "")) |
| | | .executeUpdate(); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | }); |
| | | if (isUpdate) { |
| | | if (vi.getVideoDetailList() != null && vi.getVideoDetailList().size() > 0) { |
| | | VideoPushHistory vh = new VideoPushHistory(); |
| | | vh.setCreatetime(System.currentTimeMillis() + ""); |
| | | vh.setDetailId(vi.getVideoDetailList().get(0).getExtraId()); |
| | | vh.setResourceId(19 + ""); |
| | | vh.setTag(vi.getTag()); |
| | | vh.setType(vi.getVideoDetailList().get(0).getType()); |
| | | vh.setVideoInfo(vi); |
| | | pushService.addVideoPushHistory(vh); |
| | | } |
| | | } |
| | | } |
| | | // 获取最新一集的信息 |
| | | List<FunTVVideo> plist = funTVVideoDao.listByAid(p.getAid(), "num", Sort.Direction.DESC, 0, 1); |
| | | if (plist.size() > 0) { |
| | | List<VideoDetailInfo> detailList = new ArrayList<>(); |
| | | detailList.add(FunTVUtil.convertFunTVVideoToVideoDetail(plist.get(0), p)); |
| | | vi.setVideoDetailList(detailList); |
| | | } |
| | | session.flush(); |
| | | session.getTransaction().commit(); |
| | | } catch (Exception e) { |
| | | session.getTransaction().rollback(); |
| | | System.out.println("出错:" + e.getMessage()); |
| | | } |
| | | |
| | | // 添加单个视频进入 |
| | | @SuppressWarnings("unchecked") |
| | | public void updateVideoInfo(final VideoInfo info, final VideoInfo video, final FunTVVideo p, final String genre) { |
| | | final VideoInfo vi = video; |
| | | videoFunTVDao.excute(new HibernateCallback() { |
| | | public Object doInHibernate(Session session) throws HibernateException { |
| | | return null; |
| | | } |
| | | }); |
| | | if (isUpdate) { |
| | | if (vi.getVideoDetailList() != null && vi.getVideoDetailList().size() > 0) { |
| | | VideoPushHistory vh = new VideoPushHistory(); |
| | | vh.setCreatetime(System.currentTimeMillis() + ""); |
| | | vh.setDetailId(vi.getVideoDetailList().get(0).getExtraId()); |
| | | vh.setResourceId(19 + ""); |
| | | vh.setTag(vi.getTag()); |
| | | vh.setType(vi.getVideoDetailList().get(0).getType()); |
| | | vh.setVideoInfo(vi); |
| | | pushService.addVideoPushHistory(vh); |
| | | } |
| | | } |
| | | } |
| | | |
| | | vi.setTag(info.getTag()); |
| | | vi.setLatestHpicture(info.getLatestHpicture()); |
| | | vi.setLatestVpicture(info.getLatestVpicture()); |
| | | try { |
| | | session.getTransaction().begin(); |
| | | session.update(vi); |
| | | VideoFunTV vft = new VideoFunTV(); |
| | | vft.setAlbum(null); |
| | | vft.setVideo(new VideoInfo(vi.getId())); |
| | | vft.setTvVideo(new FunTVVideo(p.getId())); |
| | | Object obj = session |
| | | .createQuery( |
| | | "select count(*) from VideoFunTV vft where vft.video.id=? and vft.tvVideo.id=?") |
| | | .setParameter(0, vi.getId()).setParameter(1, p.getId()).uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) {// 加入 |
| | | session.createSQLQuery( |
| | | String.format("insert into wk_video_funtv (videoid, tvvideoid) values (%s, '%s')", |
| | | vft.getVideo().getId(), vft.getTvVideo().getId())) |
| | | .executeUpdate(); |
| | | } |
| | | // 添加单个视频进入 |
| | | @SuppressWarnings("unchecked") |
| | | public void updateVideoInfo(final VideoInfo info, final VideoInfo video, final FunTVVideo p, final String genre) { |
| | | final VideoInfo vi = video; |
| | | videoResourceDao.excute(new HibernateCallback() { |
| | | public Object doInHibernate(Session session) throws HibernateException { |
| | | |
| | | List<Integer> typeList = FunTVUtil.getShortVideoType(p, p.getCate(), p.getSubCate()); |
| | | if (typeList != null) |
| | | for (Integer ty : typeList) { |
| | | CategoryVideo cv = new CategoryVideo(); |
| | | cv.setVideo(new VideoInfo(vi.getId())); |
| | | cv.setVideoType(new VideoType(ty)); |
| | | obj = session |
| | | .createQuery( |
| | | "select count(*) from CategoryVideo cv where cv.videoType.id=? and cv.video.id=?") |
| | | .setParameter(0, (long) ty).setParameter(1, vi.getId()).uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) |
| | | videoService.addCategoryVideo(cv); |
| | | } |
| | | vi.setTag(info.getTag()); |
| | | vi.setLatestHpicture(info.getLatestHpicture()); |
| | | vi.setLatestVpicture(info.getLatestVpicture()); |
| | | try { |
| | | session.getTransaction().begin(); |
| | | session.update(vi); |
| | | VideoFunTV vft = new VideoFunTV(); |
| | | vft.setAid(null); |
| | | vft.setVideoId(Long.parseLong(vi.getId())); |
| | | vft.setVid(p.getVid()); |
| | | vft.setId(vft.createId()); |
| | | |
| | | obj = session.createQuery(String.format( |
| | | "select count(*) from ResourceVideo rv where rv.video.id=%s and rv.resource.id=%s", |
| | | vi.getId(), 19 + "")).uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) {// 加入 |
| | | ResourceVideo rv = new ResourceVideo(); |
| | | rv.setResource(new VideoResource(19 + "")); |
| | | rv.setVideo(new VideoInfo(vi.getId())); |
| | | session.createSQLQuery(String.format( |
| | | "insert into wk_resource_video(videoid,resourceid) values(%s,%s)", vi.getId(), 19 + "")) |
| | | .executeUpdate(); |
| | | } |
| | | session.flush(); |
| | | session.getTransaction().commit(); |
| | | } catch (Exception e) { |
| | | System.out.println("出错:" + e.getMessage()); |
| | | } |
| | | long count = videoFunTVNewDao.countByVideoIdAndVid(Long.parseLong(vi.getId()), p.getVid()); |
| | | |
| | | return null; |
| | | } |
| | | }); |
| | | if (count <= 0) {// 加入 |
| | | VideoFunTV ftv = new VideoFunTV(); |
| | | ftv.setVideoId(vft.getVideoId()); |
| | | ftv.setVid(vft.getVid()); |
| | | ftv.setId(ftv.createId()); |
| | | videoFunTVNewDao.save(ftv); |
| | | } |
| | | |
| | | } |
| | | Object obj = null; |
| | | |
| | | public Serializable addVideoInfo(VideoInfo info, FunTVAlbum p) { |
| | | Serializable id = videoInfoDao.save(info); |
| | | return id; |
| | | } |
| | | List<Integer> typeList = FunTVUtil.getShortVideoType(p, p.getCate(), p.getSubCate()); |
| | | if (typeList != null) |
| | | for (Integer ty : typeList) { |
| | | CategoryVideo cv = new CategoryVideo(); |
| | | cv.setVideo(new VideoInfo(vi.getId())); |
| | | cv.setVideoType(new VideoType(ty)); |
| | | obj = session |
| | | .createQuery( |
| | | "select count(*) from CategoryVideo cv where cv.videoType.id=? and cv.video.id=?") |
| | | .setParameter(0, (long) ty).setParameter(1, vi.getId()).uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) |
| | | videoService.addCategoryVideo(cv); |
| | | } |
| | | |
| | | public Serializable addVideoInfo(VideoInfo info, FunTVVideo p) { |
| | | Serializable id = videoInfoDao.save(info); |
| | | return id; |
| | | } |
| | | obj = session.createQuery(String.format( |
| | | "select count(*) from ResourceVideo rv where rv.video.id=%s and rv.resource.id=%s", |
| | | vi.getId(), 19 + "")).uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) {// 加入 |
| | | ResourceVideo rv = new ResourceVideo(); |
| | | rv.setResource(new VideoResource(19 + "")); |
| | | rv.setVideo(new VideoInfo(vi.getId())); |
| | | session.createSQLQuery(String.format( |
| | | "insert into wk_resource_video(videoid,resourceid) values(%s,%s)", vi.getId(), 19 + "")) |
| | | .executeUpdate(); |
| | | } |
| | | session.flush(); |
| | | session.getTransaction().commit(); |
| | | } catch (Exception e) { |
| | | System.out.println("出错:" + e.getMessage()); |
| | | } |
| | | |
| | | public void saveVideoFunTV(VideoFunTV vyk) { |
| | | try { |
| | | videoFunTVDao.save(vyk); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | public Serializable addVideoInfo(VideoInfo info, FunTVAlbum p) { |
| | | Serializable id = videoInfoDao.save(info); |
| | | return id; |
| | | } |
| | | |
| | | // 错误 |
| | | public void addPlayStatistics(String detailSystemId, String vid) { |
| | | List list = videoFunTVDao.sqlList( |
| | | "SELECT vy.`videoid` FROM wk_funtv_album_video pv LEFT JOIN wk_funtv_album p ON p.`id`=pv.`aid` LEFT JOIN wk_video_youku vy ON vy.`programid`=p.`id` WHERE pv.`videoid`=?", |
| | | new Serializable[] { vid }); |
| | | if (list != null && list.size() > 0) { |
| | | statisticsService.addStatistics(detailSystemId, list.get(0) + ""); |
| | | } else { |
| | | list = videoFunTVDao.sqlList("select y.videoid from wk_video_funtv y where y.funvideoid=?", |
| | | new Serializable[] { vid }); |
| | | if (list != null && list.size() > 0) |
| | | statisticsService.addStatistics(detailSystemId, list.get(0) + ""); |
| | | } |
| | | } |
| | | public Serializable addVideoInfo(VideoInfo info, FunTVVideo p) { |
| | | Serializable id = videoInfoDao.save(info); |
| | | return id; |
| | | } |
| | | |
| | | public long getFunTVVideoCount(String pid) { |
| | | return videoFunTVDao.getCount("select count(*) from VideoFunTV m where m.album.id=?", |
| | | new Serializable[] { pid }); |
| | | } |
| | | public void saveVideoFunTV(VideoFunTV vyk) { |
| | | try { |
| | | if (vyk.getId() == null) |
| | | vyk.setId(vyk.createId()); |
| | | videoFunTVNewDao.save(vyk); |
| | | } catch (Exception e) { |
| | | |
| | | public VideoDetailInfo getLatestVideoDetail(String videoid) { |
| | | } |
| | | |
| | | List<VideoFunTV> list = videoFunTVDao.list("from VideoFunTV vy where vy.video.id=?", new String[] { videoid }); |
| | | if (list != null && list.size() > 0) { |
| | | final VideoFunTV vft = list.get(0); |
| | | if (vft.getAlbum() != null) {// 按节目查找视频 |
| | | List<FunTVVideo> videoList = funTVVideoDao.list( |
| | | "select map.video from FunTVAlbumVideoMap map where map.album.id=? order by map.video.num desc", |
| | | 0, 1, new Serializable[] { vft.getAlbum().getId() }); |
| | | List<VideoDetailInfo> detailList = new ArrayList<VideoDetailInfo>(); |
| | | for (FunTVVideo pv : videoList) |
| | | detailList.add(FunTVUtil.convertFunTVVideoToVideoDetail(pv, vft.getAlbum())); |
| | | return detailList.get(0); |
| | | } else if (vft.getTvVideo() != null) {// 单个视频----待定 |
| | | funTVAlbumDao.list(""); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | // 错误 |
| | | public void addPlayStatistics(String detailSystemId, String id) { |
| | | List<VideoFunTV> list = videoFunTVNewDao.listByVid(id); |
| | | if (list != null && list.size() > 0) { |
| | | statisticsService.addStatistics(detailSystemId, list.get(0).getVideoId() + ""); |
| | | } else { |
| | | list = videoFunTVNewDao.listByAid(id); |
| | | if (list != null && list.size() > 0) |
| | | statisticsService.addStatistics(detailSystemId, list.get(0).getVideoId() + ""); |
| | | } |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public void addFunTVAlbumToVideoInfo(final FunTVAlbum p, final boolean isUpdate) { |
| | | |
| | | final VideoInfo info = FunTVUtil.convertFunTVAlbumToVideoInfo(p); |
| | | // 类型计算 |
| | | final List<Integer> typeList = new ArrayList<Integer>(); |
| | | public VideoDetailInfo getLatestVideoDetail(String videoid) { |
| | | List<VideoFunTV> list = videoFunTVNewDao.listByVideoId(Long.parseLong(videoid)); |
| | | if (list != null && list.size() > 0) { |
| | | final VideoFunTV vft = list.get(0); |
| | | if (vft.getAid() != null) {// 按节目查找视频 |
| | | List<FunTVVideo> videoList = funTVVideoDao.listByAid(vft.getAid(), "num", Sort.Direction.DESC, 0, 1); |
| | | List<VideoDetailInfo> detailList = new ArrayList<>(); |
| | | for (FunTVVideo pv : videoList) { |
| | | FunTVAlbum album = funTVAlbumDao.get(pv.getAid()); |
| | | detailList.add(FunTVUtil.convertFunTVVideoToVideoDetail(pv, album)); |
| | | } |
| | | return detailList.get(0); |
| | | } else if (vft.getVid() != null) {// 单个视频----待定 |
| | | } |
| | | } |
| | | |
| | | int type = FunTVUtil.getFunTVAlbumType(p); |
| | | boolean exist = false; |
| | | for (Integer i : typeList) |
| | | if (i == type) |
| | | exist = true; |
| | | if (!exist && type > 0) |
| | | typeList.add(type); |
| | | return null; |
| | | } |
| | | |
| | | if (typeList.size() == 0) |
| | | typeList.add(299); |
| | | @SuppressWarnings("unchecked") |
| | | public void addFunTVAlbumToVideoInfo(final FunTVAlbum p, final boolean isUpdate) { |
| | | |
| | | try { |
| | | List<VideoInfo> infoList = videoInfoDao.list("from VideoInfo vi where vi.name=?", |
| | | new Serializable[] { p.getTitle() }); |
| | | boolean isSame = false; |
| | | VideoInfo video = null; |
| | | for (VideoInfo vi : infoList) { |
| | | final VideoInfo newVi = vi; |
| | | boolean issame = (Boolean) videoInfoDao.excute(new HibernateCallback<Boolean>() { |
| | | public Boolean doInHibernate(Session session) throws HibernateException { |
| | | return FunTVUtil.isSameVideo(typeList, p, newVi, session); |
| | | } |
| | | }); |
| | | if (issame) { |
| | | isSame = true; |
| | | video = vi; |
| | | break; |
| | | } |
| | | } |
| | | final VideoInfo info = FunTVUtil.convertFunTVAlbumToVideoInfo(p); |
| | | // 类型计算 |
| | | final List<Integer> typeList = new ArrayList<>(); |
| | | |
| | | if (infoList != null && infoList.size() > 0 && isSame) {// 无需加入 |
| | | updateVideoInfo(info, video, p, isUpdate); |
| | | } else {// 需要新加入videoinfo |
| | | Serializable id = addVideoInfo(info, p); |
| | | int type = FunTVUtil.getFunTVAlbumType(p); |
| | | boolean exist = false; |
| | | for (Integer i : typeList) |
| | | if (i == type) |
| | | exist = true; |
| | | if (!exist && type > 0) |
| | | typeList.add(type); |
| | | |
| | | if (id != null) { |
| | | info.setId(id.toString()); |
| | | if (typeList.size() == 0) |
| | | typeList.add(299); |
| | | |
| | | for (Integer ty : typeList) { |
| | | CategoryVideo cv = new CategoryVideo(); |
| | | cv.setVideo(new VideoInfo(info.getId())); |
| | | cv.setVideoType(new VideoType(ty)); |
| | | videoService.addCategoryVideo(cv); |
| | | } |
| | | try { |
| | | List<VideoInfo> infoList = videoInfoDao.list("from VideoInfo vi where vi.name=?", |
| | | new Serializable[]{p.getTitle()}); |
| | | boolean isSame = false; |
| | | VideoInfo video = null; |
| | | for (VideoInfo vi : infoList) { |
| | | final VideoInfo newVi = vi; |
| | | boolean issame = (Boolean) videoInfoDao.excute(new HibernateCallback<Boolean>() { |
| | | public Boolean doInHibernate(Session session) throws HibernateException { |
| | | return FunTVUtil.isSameVideo(typeList, p, newVi, session); |
| | | } |
| | | }); |
| | | if (issame) { |
| | | isSame = true; |
| | | video = vi; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | VideoFunTV vft = new VideoFunTV(); |
| | | vft.setAlbum(new FunTVAlbum(p.getId())); |
| | | vft.setVideo(new VideoInfo(info.getId())); |
| | | vft.setTvVideo(null); |
| | | saveVideoFunTV(vft); |
| | | if (infoList != null && infoList.size() > 0 && isSame) {// 无需加入 |
| | | updateVideoInfo(info, video, p, isUpdate); |
| | | } else {// 需要新加入videoinfo |
| | | Serializable id = addVideoInfo(info, p); |
| | | |
| | | videoResourceService.excuteSQL(String.format( |
| | | "insert into wk_resource_video(videoid,resourceid) values(%s,%s)", info.getId(), 19 + "")); |
| | | } |
| | | } |
| | | if (id != null) { |
| | | info.setId(id.toString()); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | for (Integer ty : typeList) { |
| | | CategoryVideo cv = new CategoryVideo(); |
| | | cv.setVideo(new VideoInfo(info.getId())); |
| | | cv.setVideoType(new VideoType(ty)); |
| | | videoService.addCategoryVideo(cv); |
| | | } |
| | | |
| | | } |
| | | VideoFunTV vft = new VideoFunTV(); |
| | | vft.setAid(p.getAid()); |
| | | vft.setVideoId(Long.parseLong(info.getId())); |
| | | vft.setVid(null); |
| | | vft.setId(vft.createId()); |
| | | saveVideoFunTV(vft); |
| | | |
| | | public void addVideoToVideoInfo(final FunTVVideo p) { |
| | | VideoInfo info = FunTVUtil.convertVideoToVideoInfo(p); |
| | | try { |
| | | synchronized (p.getTitle().intern()) { // 发现了有重复生成VideoInfo.所有根据名称加个锁(一定要加intern())cxx |
| | | videoResourceService.excuteSQL(String.format( |
| | | "insert into wk_resource_video(videoid,resourceid) values(%s,%s)", info.getId(), 19 + "")); |
| | | } |
| | | } |
| | | |
| | | List<VideoInfo> infoList = videoInfoDao.list("from VideoInfo vi where vi.name=?", |
| | | new Serializable[] { p.getTitle() }); |
| | | if (infoList != null && infoList.size() > 0) {// 无需加入 |
| | | // updateVideoInfo(info, infoList.get(0), p, genre); |
| | | return; |
| | | } else {// 需要新加入videoinfo |
| | | Serializable id = addVideoInfo(info, p); |
| | | List<Integer> typeList = new ArrayList<Integer>(); |
| | | typeList = FunTVUtil.getShortVideoType(p, p.getCate(), p.getSubCate()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (typeList == null || typeList.size() <= 0) |
| | | return; |
| | | } |
| | | |
| | | if (id != null) { |
| | | info.setId(id.toString()); |
| | | public void addVideoToVideoInfo(final FunTVVideo p) { |
| | | VideoInfo info = FunTVUtil.convertVideoToVideoInfo(p); |
| | | try { |
| | | synchronized (p.getTitle().intern()) { // 发现了有重复生成VideoInfo.所有根据名称加个锁(一定要加intern())cxx |
| | | |
| | | for (Integer ty : typeList) { |
| | | CategoryVideo cv = new CategoryVideo(); |
| | | cv.setVideo(new VideoInfo(info.getId())); |
| | | cv.setVideoType(new VideoType(ty)); |
| | | videoService.addCategoryVideo(cv); |
| | | } |
| | | List<VideoInfo> infoList = videoInfoDao.list("from VideoInfo vi where vi.name=?", |
| | | new Serializable[]{p.getTitle()}); |
| | | if (infoList != null && infoList.size() > 0) {// 无需加入 |
| | | // updateVideoInfo(info, infoList.get(0), p, genre); |
| | | return; |
| | | } else {// 需要新加入videoinfo |
| | | Serializable id = addVideoInfo(info, p); |
| | | List<Integer> typeList = new ArrayList<>(); |
| | | typeList = FunTVUtil.getShortVideoType(p, p.getCate(), p.getSubCate()); |
| | | |
| | | VideoFunTV vft = new VideoFunTV(); |
| | | vft.setAlbum(null); |
| | | vft.setVideo(new VideoInfo(info.getId())); |
| | | vft.setTvVideo(p); |
| | | saveVideoFunTV(vft); |
| | | videoResourceService.excuteSQL( |
| | | String.format("insert into wk_resource_video(videoid,resourceid) values(%s,%s)", |
| | | info.getId(), 19 + "")); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (typeList == null || typeList.size() <= 0) |
| | | return; |
| | | |
| | | } |
| | | if (id != null) { |
| | | info.setId(id.toString()); |
| | | |
| | | public int getShowType(String vid) { |
| | | List<FunTVAlbum> list = funTVAlbumDao.list("select vs.album From VideoFunTV vs where vs.video.id=?", |
| | | new Serializable[] { vid }); |
| | | if (list != null && list.size() > 0) { |
| | | if (list.get(0) != null) { |
| | | if (list.get(0).getVideoType().contains("电视剧") || list.get(0).getVideoType().contains("动漫")) |
| | | return 2; |
| | | } else { |
| | | return 1; |
| | | } |
| | | } |
| | | for (Integer ty : typeList) { |
| | | CategoryVideo cv = new CategoryVideo(); |
| | | cv.setVideo(new VideoInfo(info.getId())); |
| | | cv.setVideoType(new VideoType(ty)); |
| | | videoService.addCategoryVideo(cv); |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | VideoFunTV vft = new VideoFunTV(); |
| | | vft.setAid(null); |
| | | vft.setVideoId(Long.parseLong(info.getId())); |
| | | vft.setVid(p.getVid()); |
| | | vft.setId(vft.createId()); |
| | | saveVideoFunTV(vft); |
| | | videoResourceService.excuteSQL( |
| | | String.format("insert into wk_resource_video(videoid,resourceid) values(%s,%s)", |
| | | info.getId(), 19 + "")); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public PlayUrl getPlayUrl(String detailSystemId, String id, String type, int resourceid, String videoId) { |
| | | logger.info(String.format("%s#%s#%s#%s", detailSystemId, resourceid, type, id)); |
| | | PlayUrl playUrl = new PlayUrl(); |
| | | } |
| | | |
| | | List<VideoResource> list = videoResourceDao.list("from VideoResource vr where vr.id=" + resourceid); |
| | | if (list != null && list.size() > 0) |
| | | playUrl.setResource(list.get(0)); |
| | | if (StringUtil.isNullOrEmpty(videoId)) |
| | | addPlayStatistics(detailSystemId, id); |
| | | else |
| | | statisticsService.addStatistics(detailSystemId, videoId); |
| | | if (!type.equalsIgnoreCase("funtvvideo")) { |
| | | List<BigInteger> idList = (List<BigInteger>) videoResourceDao.sqlList( |
| | | "SELECT yk.`videoid` FROM wk_video_funtv yk WHERE yk.`albumid`= ( SELECT p.`aid` FROM wk_funtv_video v LEFT JOIN wk_funtv_album_video_map p ON p.`funvideoid`=v.`id` WHERE v.`id`=?)", |
| | | new Serializable[] { id }); |
| | | if (idList != null && idList.size() > 0) { |
| | | boolean isNeedWeb = banQuanService.isNeedWebPlay(detailSystemId, idList.get(0) + ""); |
| | | if (isNeedWeb) |
| | | playUrl.setPlayType(1); |
| | | } |
| | | } |
| | | public int getShowType(String videoId) { |
| | | List<VideoFunTV> list = videoFunTVNewDao.listByVideoId(Long.parseLong(videoId)); |
| | | if (list != null && list.size() > 0) { |
| | | if (list.get(0) != null) { |
| | | FunTVAlbum album = funTVAlbumDao.get(list.get(0).getAid()); |
| | | |
| | | FunTVVideo fvideo = getFunTVVideo(Long.parseLong(id)); |
| | | if (album.getVideoType().contains("电视剧") || album.getVideoType().contains("动漫")) |
| | | return 2; |
| | | } else { |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("vid", fvideo.getVid()); |
| | | playUrl.setParams(object.toString()); |
| | | if (fvideo.getPlayMUrl() != null) |
| | | playUrl.setUrl(fvideo.getPlayMUrl().replace("alliance=2501", "malliance=0")); |
| | | playUrl.setPlayType(1);// 全部跳转网页 |
| | | return playUrl; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | public List<VideoDetailInfo> getVideoDetailList(String videoid) { |
| | | @SuppressWarnings("unchecked") |
| | | public PlayUrl getPlayUrl(String detailSystemId, String id, String type, int resourceid, String videoId) { |
| | | logger.info(String.format("%s#%s#%s#%s", detailSystemId, resourceid, type, id)); |
| | | PlayUrl playUrl = new PlayUrl(); |
| | | |
| | | List<VideoFunTV> list = videoFunTVDao.list("from VideoFunTV vy where vy.video.id=?", new String[] { videoid }); |
| | | if (list != null && list.size() > 0) { |
| | | final VideoFunTV vft = list.get(0); |
| | | List<VideoResource> list = videoResourceDao.list("from VideoResource vr where vr.id=" + resourceid); |
| | | if (list != null && list.size() > 0) |
| | | playUrl.setResource(list.get(0)); |
| | | if (StringUtil.isNullOrEmpty(videoId)) |
| | | addPlayStatistics(detailSystemId, id); |
| | | else |
| | | statisticsService.addStatistics(detailSystemId, videoId); |
| | | if (!type.equalsIgnoreCase("funtvvideo")) { |
| | | List<BigInteger> idList = (List<BigInteger>) videoResourceDao.sqlList( |
| | | "SELECT yk.`videoid` FROM wk_video_funtv yk WHERE yk.`albumid`= ( SELECT p.`aid` FROM wk_funtv_video v LEFT JOIN wk_funtv_album_video_map p ON p.`funvideoid`=v.`id` WHERE v.`id`=?)", |
| | | new Serializable[]{id}); |
| | | if (idList != null && idList.size() > 0) { |
| | | boolean isNeedWeb = banQuanService.isNeedWebPlay(detailSystemId, idList.get(0) + ""); |
| | | if (isNeedWeb) |
| | | playUrl.setPlayType(1); |
| | | } |
| | | } |
| | | |
| | | if (vft != null && vft.getAlbum() != null) {// 按节目查找视频 |
| | | List<FunTVVideo> videoList = funTVVideoDao.list( |
| | | "select map.video from FunTVAlbumVideoMap map where map.album.id=" + vft.getAlbum().getId()); |
| | | Comparator<FunTVVideo> cp = new Comparator<FunTVVideo>() { |
| | | public int compare(FunTVVideo o1, FunTVVideo o2) { |
| | | FunTVVideo fvideo = funTVVideoDao.get(id); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("vid", fvideo.getVid()); |
| | | playUrl.setParams(object.toString()); |
| | | if (fvideo.getPlayMUrl() != null) |
| | | playUrl.setUrl(fvideo.getPlayMUrl().replace("alliance=2501", "malliance=0")); |
| | | playUrl.setPlayType(1);// 全部跳转网页 |
| | | return playUrl; |
| | | } |
| | | |
| | | long t1 = o1.getNum(); |
| | | long t2 = o2.getNum(); |
| | | if (vft.getAlbum().getVideoType().contains("电影")) { |
| | | return (int) (t2 - t1); |
| | | } else if (vft.getAlbum().getVideoType().contains("电视剧")) { |
| | | return (int) (t1 - t2); |
| | | } else if (vft.getAlbum().getVideoType().contains("综艺")) { |
| | | return (int) (t2 - t1); |
| | | } else if (vft.getAlbum().getVideoType().contains("动漫")) { |
| | | return (int) (t1 - t2); |
| | | } else |
| | | return (int) (t2 - t1); |
| | | } |
| | | }; |
| | | Collections.sort(videoList, cp); |
| | | public List<VideoDetailInfo> getVideoDetailList(String videoid, int page, int pageSize) { |
| | | List<VideoFunTV> list = videoFunTVNewDao.listByVideoId(Long.parseLong(videoid)); |
| | | if (list != null && list.size() > 0) { |
| | | final VideoFunTV vft = list.get(0); |
| | | if (vft != null && vft.getAid() != null) {// 按节目查找视频 |
| | | String aid = vft.getAid(); |
| | | FunTVAlbum album = funTVAlbumDao.get(aid); |
| | | if (album == null) { |
| | | resourceVideoService.delete(videoid, FunTVUtil.RESOURCE_ID + ""); |
| | | } |
| | | final String type = album.getVideoType(); |
| | | Sort.Direction sort = Sort.Direction.ASC; |
| | | if (type != null) |
| | | if (type.contains("电影")) { |
| | | sort = Sort.Direction.DESC; |
| | | } else if (type.contains("电视剧")) { |
| | | sort = Sort.Direction.ASC; |
| | | } else if (type.contains("综艺")) { |
| | | sort = Sort.Direction.DESC; |
| | | } else if (type.contains("动漫")) { |
| | | sort = Sort.Direction.ASC; |
| | | } else |
| | | sort = Sort.Direction.DESC; |
| | | |
| | | List<VideoDetailInfo> detailList = new ArrayList<VideoDetailInfo>(); |
| | | for (FunTVVideo pv : videoList) |
| | | detailList.add(FunTVUtil.convertFunTVVideoToVideoDetail(pv, vft.getAlbum())); |
| | | return detailList; |
| | | } else if (vft.getTvVideo() != null) {// 单个视频 |
| | | FunTVVideo pv = vft.getTvVideo(); |
| | | List<VideoDetailInfo> detailList = new ArrayList<VideoDetailInfo>(); |
| | | VideoDetailInfo detail = new VideoDetailInfo(); |
| | | detail.setId(pv.getId()); |
| | | detail.setExtraId(pv.getId() + ""); |
| | | detail.setName(pv.getTitle()); |
| | | detail.setTag(pv.getDesc()); |
| | | detail.setType("funtvvideo"); |
| | | List<VideoUrl> urlList = new ArrayList<VideoUrl>(); |
| | | VideoUrl vu = new VideoUrl(); |
| | | vu.setAdmin(null); |
| | | vu.setBaseUrl(pv.getPlayUrl()); |
| | | vu.setInvalid(0 + ""); |
| | | vu.setResource(new VideoResource("19")); |
| | | vu.setUrl(pv.getPlayMUrl()); |
| | | urlList.add(vu); |
| | | detail.setUrls(urlList); |
| | | detailList.add(detail); |
| | | return detailList; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | List<FunTVVideo> videoList = funTVVideoDao.listByAid(aid, "num", sort, (page - 1) * pageSize, pageSize); |
| | | if (album == null && videoList.size() > 0) {//处理电影 |
| | | album = new FunTVAlbum(); |
| | | album.setTitle(videoList.get(0).getTitle()); |
| | | album.setVideoType(videoList.get(0).getCate()); |
| | | } |
| | | |
| | | public FunTVVideo getLatestFunTVVideo(String programid) { |
| | | List<FunTVVideo> videoList = funTVVideoDao.list(String.format( |
| | | "select map.video from FunTVAlbumVideoMap map where map.album.aid=%s order by map.video.num desc", |
| | | programid), 0, 1, null); |
| | | if (videoList != null && videoList.size() > 0) |
| | | return videoList.get(0); |
| | | return null; |
| | | } |
| | | List<VideoDetailInfo> detailList = new ArrayList<>(); |
| | | for (FunTVVideo pv : videoList) |
| | | detailList.add(FunTVUtil.convertFunTVVideoToVideoDetail(pv, album)); |
| | | return detailList; |
| | | } else if (vft.getVid() != null) {// 单个视频 |
| | | FunTVVideo pv = funTVVideoDao.get(vft.getVid()); |
| | | List<VideoDetailInfo> detailList = new ArrayList<>(); |
| | | VideoDetailInfo detail = new VideoDetailInfo(); |
| | | detail.setId(Long.parseLong(pv.getVid())); |
| | | detail.setExtraId(pv.getId() + ""); |
| | | detail.setName(pv.getTitle()); |
| | | detail.setTag(pv.getDesc()); |
| | | detail.setType("funtvvideo"); |
| | | List<VideoUrl> urlList = new ArrayList<>(); |
| | | VideoUrl vu = new VideoUrl(); |
| | | vu.setAdmin(null); |
| | | vu.setBaseUrl(pv.getPlayUrl()); |
| | | vu.setInvalid(0 + ""); |
| | | vu.setResource(new VideoResource("19")); |
| | | vu.setUrl(pv.getPlayMUrl()); |
| | | urlList.add(vu); |
| | | detail.setUrls(urlList); |
| | | detailList.add(detail); |
| | | return detailList; |
| | | } |
| | | }else{//删除来源 |
| | | resourceVideoService.delete(videoid,FunTVUtil.RESOURCE_ID+""); |
| | | } |
| | | |
| | | public void deleteVideoByAid(String aid) { |
| | | // 查询出对应的VID与videoid |
| | | final FunTVAlbum album = getAlbumByAid(aid); |
| | | return null; |
| | | } |
| | | |
| | | if (album != null) { |
| | | String videoId = (String) funTVVideoDao.excute(new HibernateCallback<String>() { |
| | | public FunTVVideo getLatestFunTVVideo(String programid) { |
| | | FunTVVideo video = funTVVideoDao.getLatestVideo(programid); |
| | | return video; |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public String doInHibernate(Session session) throws HibernateException { |
| | | String videoid = null; |
| | | public void deleteVideoByAid(String aid) { |
| | | // 查询出对应的VID与videoid |
| | | final FunTVAlbum album = getAlbumByAid(aid); |
| | | |
| | | List<FunTVVideo> list = session |
| | | .createQuery("select m.video from FunTVAlbumVideoMap m where m.album.id=" + album.getId()) |
| | | .list(); |
| | | session.getTransaction().begin(); |
| | | try { |
| | | if (album != null) { |
| | | String videoId = (String) videoResourceDao.excute(new HibernateCallback<String>() { |
| | | @SuppressWarnings("unchecked") |
| | | public String doInHibernate(Session session) throws HibernateException { |
| | | String videoid = null; |
| | | List<FunTVVideo> list = funTVVideoDao.listByAid(album.getAid(), 0, 1000); |
| | | session.getTransaction().begin(); |
| | | try { |
| | | for (FunTVVideo tv : list) {// 删除视频 |
| | | funTVVideoDao.delete(tv.getVid()); |
| | | } |
| | | funTVAlbumDao.delete(album.getAid());// 删除专辑 |
| | | List<VideoFunTV> ftlist = videoFunTVNewDao.listByAid(album.getAid()); |
| | | |
| | | for (FunTVVideo tv : list) {// 删除视频 |
| | | session.delete(tv); |
| | | } |
| | | session.delete(album);// 删除专辑 |
| | | List<VideoFunTV> ftlist = session |
| | | .createQuery("from VideoFunTV vf where vf.album!=null and vf.album.id=" + album.getId()) |
| | | .list(); |
| | | if (ftlist.size() > 0) { |
| | | Object obj = session.createQuery( |
| | | "select count(*) from ResourceVideo rv where rv.resource.id!=19 and rv.video.id=" |
| | | + ftlist.get(0).getVideo().getId()) |
| | | .uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) { |
| | | videoid = ftlist.get(0).getVideo().getId(); |
| | | } |
| | | } |
| | | session.createQuery( |
| | | "delete from VideoFunTV vf where vf.album!=null and vf.album.id=" + album.getId()) |
| | | .executeUpdate(); |
| | | session.flush(); |
| | | session.getTransaction().commit(); |
| | | } catch (Exception e) { |
| | | session.getTransaction().rollback(); |
| | | } |
| | | return videoid; |
| | | } |
| | | }); |
| | | if (ftlist.size() > 0) { |
| | | Object obj = session.createQuery( |
| | | "select count(*) from ResourceVideo rv where rv.resource.id!=19 and rv.video.id=" |
| | | + ftlist.get(0).getVideoId()) |
| | | .uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) { |
| | | videoid = ftlist.get(0).getVideoId() + ""; |
| | | } |
| | | } |
| | | for (VideoFunTV funTV : ftlist) |
| | | videoFunTVNewDao.delete(funTV.getId()); |
| | | session.flush(); |
| | | session.getTransaction().commit(); |
| | | } catch (Exception e) { |
| | | session.getTransaction().rollback(); |
| | | } |
| | | return videoid; |
| | | } |
| | | }); |
| | | |
| | | if (videoId != null) {// 可以删除视频 |
| | | videoManager.deleteVideo(videoId); |
| | | } |
| | | if (videoId != null) {// 可以删除视频 |
| | | videoManager.deleteVideo(videoId); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | public void deleteVideoByVid(String vid) { |
| | | // 查询出对应的VID与videoid |
| | | final FunTVVideo video = getFunTVVideoByVid(vid); |
| | | if (video != null) { |
| | | String videoId = (String) funTVVideoDao.excute(new HibernateCallback<String>() { |
| | | public void deleteVideoByVid(String vid) { |
| | | // 查询出对应的VID与videoid |
| | | final FunTVVideo video = getFunTVVideoByVid(vid); |
| | | if (video != null) { |
| | | String videoId = (String) videoResourceDao.excute(new HibernateCallback<String>() { |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public String doInHibernate(Session session) throws HibernateException { |
| | | String videoid = null; |
| | | @SuppressWarnings("unchecked") |
| | | public String doInHibernate(Session session) throws HibernateException { |
| | | String videoid = null; |
| | | |
| | | List<FunTVVideo> list = session |
| | | .createQuery("select m.video from FunTVAlbumVideoMap m where m.album.id=" + video.getId()) |
| | | .list(); |
| | | session.getTransaction().begin(); |
| | | try { |
| | | //TODO 处理 |
| | | List<FunTVVideo> list = session |
| | | .createQuery("select m.video from FunTVAlbumVideoMap m where m.album.id=" + video.getId()) |
| | | .list(); |
| | | session.getTransaction().begin(); |
| | | try { |
| | | |
| | | for (FunTVVideo tv : list) {// 删除视频 |
| | | session.delete(tv); |
| | | } |
| | | session.delete(video);// 删除专辑 |
| | | List<VideoFunTV> ftlist = session |
| | | .createQuery( |
| | | "from VideoFunTV vf where vf.tvVideo!=null and vf.tvVideo.id=" + video.getId()) |
| | | .list(); |
| | | if (ftlist.size() > 0) { |
| | | Object obj = session.createQuery( |
| | | "select count(*) from ResourceVideo rv where rv.resource.id!=19 and rv.video.id=" |
| | | + ftlist.get(0).getVideo().getId()) |
| | | .uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) { |
| | | videoid = ftlist.get(0).getVideo().getId(); |
| | | } |
| | | } |
| | | session.createQuery( |
| | | "delete from VideoFunTV vf where vf.tvVideo!=null and vf.tvVideo.id=" + video.getId()) |
| | | .executeUpdate(); |
| | | session.flush(); |
| | | session.getTransaction().commit(); |
| | | } catch (Exception e) { |
| | | session.getTransaction().rollback(); |
| | | } |
| | | return videoid; |
| | | } |
| | | }); |
| | | for (FunTVVideo tv : list) {// 删除视频 |
| | | session.delete(tv); |
| | | } |
| | | session.delete(video);// 删除专辑 |
| | | List<VideoFunTV> ftlist = session |
| | | .createQuery( |
| | | "from VideoFunTV vf where vf.vid=" + video.getVid()) |
| | | .list(); |
| | | if (ftlist.size() > 0) { |
| | | Object obj = session.createQuery( |
| | | "select count(*) from ResourceVideo rv where rv.resource.id!=19 and rv.video.id=" |
| | | + ftlist.get(0).getVideoId()) |
| | | .uniqueResult(); |
| | | if (Integer.parseInt(obj + "") <= 0) { |
| | | videoid = ftlist.get(0).getVideoId() + ""; |
| | | } |
| | | } |
| | | for (VideoFunTV funTV : ftlist) { |
| | | videoFunTVNewDao.delete(funTV.getId()); |
| | | } |
| | | session.flush(); |
| | | session.getTransaction().commit(); |
| | | } catch (Exception e) { |
| | | session.getTransaction().rollback(); |
| | | } |
| | | return videoid; |
| | | } |
| | | }); |
| | | |
| | | if (videoId != null) {// 可以删除视频 |
| | | videoManager.deleteVideo(videoId); |
| | | } |
| | | if (videoId != null) {// 可以删除视频 |
| | | videoManager.deleteVideo(videoId); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | public PlayUrl getPlayUrl(String detailSystemId, String resourceid, String type, String id) { |
| | | return null; |
| | | } |
| | | public PlayUrl getPlayUrl(String detailSystemId, String resourceid, String type, String id) { |
| | | return null; |
| | | } |
| | | |
| | | } |