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/controller/parser/HomeParser.java | 1057 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 938 insertions(+), 119 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java b/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java index cd763d1..eaf5a25 100644 --- a/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java +++ b/src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java @@ -1,60 +1,85 @@ package com.yeshi.buwan.controller.parser; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; - +import com.google.gson.Gson; import com.yeshi.buwan.domain.*; +import com.yeshi.buwan.domain.entity.PlayUrl; +import com.yeshi.buwan.domain.recommend.HomeRecommendSpecial; +import com.yeshi.buwan.domain.solr.SolrShortVideo; +import com.yeshi.buwan.domain.special.SearchSpecialPositionMap; +import com.yeshi.buwan.domain.system.DetailSystem; +import com.yeshi.buwan.domain.system.DetailSystemConfig; +import com.yeshi.buwan.domain.video.InternetSearchVideo; +import com.yeshi.buwan.domain.video.VideoWatchHistory; +import com.yeshi.buwan.dto.log.BaseLog; +import com.yeshi.buwan.dto.statistic.video.VideoDetailStatisticData; +import com.yeshi.buwan.exception.video.VideoPlayException; +import com.yeshi.buwan.service.imp.*; +import com.yeshi.buwan.service.inter.ad.DeviceAdStrategyService; +import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; +import com.yeshi.buwan.service.inter.juhe.PPTVService; +import com.yeshi.buwan.service.inter.recommend.HomeRecommendSpecialService; +import com.yeshi.buwan.service.inter.recommend.HomeVideoService; +import com.yeshi.buwan.service.inter.search.SearchSpecialPositionMapService; +import com.yeshi.buwan.service.inter.video.VideoResourceInfoMapService; +import com.yeshi.buwan.service.inter.video.VideoWatchHistoryService; +import com.yeshi.buwan.service.manager.APPManager; +import com.yeshi.buwan.service.manager.VideoPlayStatisticManager; +import com.yeshi.buwan.service.manager.search.SolrShortVideoDataManager; +import com.yeshi.buwan.util.*; +import com.yeshi.buwan.util.JuHe.VideoResourceUtil; import com.yeshi.buwan.util.annotation.RequireUid; +import com.yeshi.buwan.util.factory.VideoInfoFactory; +import com.yeshi.buwan.util.log.LoggerUtil; +import com.yeshi.buwan.util.log.UserActiveLogFactory; +import com.yeshi.buwan.util.log.VideoLogFactory; +import com.yeshi.buwan.util.mq.rabbit.RabbitmqManager; +import com.yeshi.buwan.util.video.VideoDetailUtil; +import com.yeshi.buwan.util.video.VideoUtil; +import com.yeshi.buwan.util.zhibo.MeiNvZhiBoUtil; +import com.yeshi.buwan.videos.bilibili.BilibiliUtil; +import com.yeshi.buwan.videos.hanmi.HanmiUtil; +import com.yeshi.buwan.videos.mogotv.MogoTVUtil; +import com.yeshi.buwan.videos.pptv.PPTVApiUtil; +import com.yeshi.buwan.videos.pptv.PPTVUtil; +import com.yeshi.buwan.videos.pptv.entity.PPTVProgram; +import com.yeshi.buwan.videos.pptv.entity.PPTVSeries; +import com.yeshi.buwan.videos.pptv.entity.VideoPPTVMap; +import com.yeshi.buwan.videos.tencent.TencentVideoUtil; +import com.yeshi.buwan.videos.youku.YouKuUtil; import com.yeshi.buwan.vo.AcceptData; +import com.yeshi.buwan.vo.video.VideoDetailVO; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.methods.GetMethod; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import com.yeshi.buwan.domain.entity.PlayUrl; -import com.yeshi.buwan.service.imp.AdService; -import com.yeshi.buwan.service.imp.AttentionService; -import com.yeshi.buwan.service.imp.ClassService; -import com.yeshi.buwan.service.imp.CollectionService; -import com.yeshi.buwan.service.imp.CommentService; -import com.yeshi.buwan.service.imp.ConfigService; -import com.yeshi.buwan.service.imp.HomeAdService; -import com.yeshi.buwan.service.imp.HomeTypeService; -import com.yeshi.buwan.service.imp.StatisticsService; -import com.yeshi.buwan.service.imp.SystemService; -import com.yeshi.buwan.service.imp.UserService; -import com.yeshi.buwan.service.imp.VideoManager; -import com.yeshi.buwan.util.CacheUtil; -import com.yeshi.buwan.util.Constant; -import com.yeshi.buwan.util.JsonUtil; -import com.yeshi.buwan.util.JuheVideoUtil; -import com.yeshi.buwan.util.StringUtil; -import com.yeshi.buwan.util.TimeUtil; -import com.yeshi.buwan.util.Utils; -import com.yeshi.buwan.util.VideoPictureUtil; -import com.yeshi.buwan.util.JuHe.VideoResourceUtil; -import com.yeshi.buwan.util.video.VideoDetailUtil; -import com.yeshi.buwan.util.zhibo.MeiNvZhiBoUtil; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; @Controller public class HomeParser { + + private Logger logger = LoggerFactory.getLogger(HomeParser.class); + @Resource private SystemService systemService; @Resource private HomeAdService homeAdService; @Resource private HomeTypeService homeTypeService; + @Resource - private ConfigService configService; + private HomeVideoService homeVideoService; + + @Resource + private DetailSystemConfigService configService; @Resource private AdService adService; @Resource @@ -80,37 +105,47 @@ @Resource private VideoDetailUtil videoDetailUtil; + @Resource + private ResourceVideoService resourceVideoService; + + @Resource + private PPTVService pptvService; + + @Resource + private VideoWatchHistoryService videoWatchHistoryService; + + @Resource + private HomeRecommendSpecialService homeRecommendSpecialService; + + @Resource + private DeviceAdStrategyService deviceAdStrategyService; + + @Resource + private APPManager appManager; + + @Resource + private VideoResourceInfoMapService videoResourceInfoMapService; + + @Resource + private HanmiUtil hanmiUtil; + + @Resource + private RabbitmqManager rabbitmqManager; + + private final Logger userPlayLogger = LoggerFactory.getLogger("videoPlayUser"); + @RequireUid public void getHomeAd(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { String vtid = request.getParameter("Vtid"); - if (!"310".equals(vtid)) { + HomeRecommendSpecial special = homeRecommendSpecialService.getSpecial(vtid); + //鍏煎鏂扮増鏈� + if (special != null) { + JSONObject object = new JSONObject(); DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); - List<HomeAd> list = homeAdService.getHomeAdList(detailSystem); - - // 娴嬭瘯璺宠浆灏忕▼搴� - // JSONObject xcx = new JSONObject(); - // xcx.put("thumb", - // "http://img.zcool.cn/community/0169235af03daea801206aba8664d7.jpeg@260w_195h_1c_1e_1o_100sh.jpg"); - // xcx.put("title", "娴嬭瘯鏍囬"); - // xcx.put("desc", "绠�浠�"); - // xcx.put("path", "pages/index/index"); - // xcx.put("username", "gh_33b9bea57aff"); - // xcx.put("url", "http://video.yeshitv.com"); - - // 娴嬭瘯鏍囬 - // HomeAd homeAd = new HomeAd(); - // homeAd.setClazz("com"); - // homeAd.setLinkType(5); - // homeAd.setOrderby(0); - // homeAd.setPicture( - // "http://img.zcool.cn/community/0169235af03daea801206aba8664d7.jpeg@260w_195h_1c_1e_1o_100sh.jpg"); - // homeAd.setVideo(new VideoInfo(1 + "")); - // homeAd.setParams(xcx.toString()); - // homeAd.setTitle("鏍囬"); - // list.add(homeAd); + List<HomeAd> list = homeAdService.getHomeAdList(detailSystem, special != null ? special.getDataKey() : null); if (acceptData.getPlatform().equalsIgnoreCase("ios"))// IOS娴嬭瘯 { @@ -136,7 +171,6 @@ for (int i = 0; i < list.size(); i++) array.add(StringUtil.outPutResultJson(list.get(i))); object.put("data", array); - } else { for (HomeAd ad : list) { if (ad.getVideo() != null) { @@ -146,14 +180,6 @@ if (!StringUtil.isNullOrEmpty(ad.getParams())) { ad.setParams(ad.getParams().replace("\"", "\\" + "\"")); } - - // 3.4.7浠ヤ笂鐨勭増鏈墠鍙互鐢� - // com.weikou.beibeivideo.ui.mine.FXBrowserActivity - if ("com.weikou.beibeivideo.ui.mine.FXBrowserActivity".equalsIgnoreCase(ad.getClazz()) - && acceptData.getVersion() < 71) - ad.setClazz("com.weikou.beibeivideo.ui.mine.BrowserActivity"); - else - ad.setClazz("com.weikou.beibeivideo.ui.mine.FXBrowserActivity"); } object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString()); JSONArray array = new JSONArray(); @@ -162,11 +188,11 @@ object.put("data", array); } + object.put("bannerSizeRate", special.getBannerSizeRate()); out.print(JsonUtil.loadTrueJson(object.toString())); } else { classParser.getRecommendCategoryVideoBanner(acceptData, request, out); } - } // 棣栭〉绫诲瀷鑾峰彇 @@ -181,18 +207,21 @@ if (StringUtil.isNullOrEmpty(vtid)) { vtid = "309"; // 涓轰簡鍏煎浠ュ墠鐨勬帹鑽� } + + HomeRecommendSpecial special = homeRecommendSpecialService.getSpecial(vtid); + DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); JSONObject object = new JSONObject(); - List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); - List<HomeType> list1 = homeTypeService.getHomeType(detailSystem.getId(), resourceList, - CacheUtil.getMD5Long(resourceList), -1, Long.parseLong(vtid)); + List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); + List<HomeType> list1 = homeTypeService.getHomeType(detailSystem.getId(), acceptData.getPlatform(), acceptData.getVersion(), resourceList, + CacheUtil.getMD5Long(resourceList), -1, special != null ? special.getDataKey() : null); List<HomeType> list = new ArrayList<>(); for (HomeType ht : list1) list.add(ht); if ("309".equals(vtid)) { if (!"ios".equalsIgnoreCase(acceptData.getPlatform())) { - Map<String, String> confMap = configService.getConfigAsMap(detailSystem, acceptData.getVersion()); + Map<String, String> confMap = configService.getConfigAsMap(acceptData.getChildDetailSystem(), acceptData.getVersion()); String mm = confMap.get("meinv_mm_count"); int count = Integer.parseInt(mm); if (count > 0) { @@ -217,6 +246,20 @@ } } catch (Exception e) { e.printStackTrace(); + } + } + + if (VersionUtil.isGraterThan387(acceptData.getPlatform(), acceptData.getVersion())) { + DetailSystemConfig adContent = configService.getConfigByKey("home_banner_ad_content", acceptData.getChildDetailSystem(), acceptData.getVersion()); + DetailSystemConfig adPosition = configService.getConfigByKey("home_banner_ad_position", acceptData.getChildDetailSystem(), acceptData.getVersion()); + if (adContent != null && adPosition != null) { + HomeType.HomeTypeAd ad = new Gson().fromJson(adContent.getValue(), HomeType.HomeTypeAd.class); + int adP = Integer.parseInt(adPosition.getValue()); + if (adP < list.size() && adP > -1) { + HomeType homeType = new HomeType(); + homeType.setAd(ad); + list.add(adP, homeType); + } } } } @@ -251,13 +294,14 @@ JSONArray array = new JSONArray(); for (HomeType ht : list) { - for (int i = 0; i < ht.getHomeVideoList().size(); i++) { - //鏀瑰彉鍥剧墖 - if (JuheVideoUtil.isNeedDelete(ht.getHomeVideoList().get(i).getVideo(), detailSystem.getId())) { - ht.getHomeVideoList().remove(i); - i--; + if (ht.getHomeVideoList() != null) + for (int i = 0; i < ht.getHomeVideoList().size(); i++) { + //鏀瑰彉鍥剧墖 + if (JuheVideoUtil.isNeedDelete(ht.getHomeVideoList().get(i).getVideo(), detailSystem.getId())) { + ht.getHomeVideoList().remove(i); + i--; + } } - } } for (int i = 0; i < list.size(); i++) @@ -267,8 +311,78 @@ } + // 棣栭〉绫诲瀷鑾峰彇 + public void getHomeTypeNew(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { + // 20170914 涓�绾ц棰戝垎绫籌D + String page = request.getParameter("Page"); + String pageSize = request.getParameter("PageSize"); + String dataKey = request.getParameter("DataKey"); + + long count = homeTypeService.countHomeType(acceptData.getDetailSystem().getId(), acceptData.getVersion(), dataKey); + + List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); + List<HomeType> homeTypeList = homeTypeService.getHomeTypeList(acceptData.getDetailSystem().getId(), acceptData.getVersion(), dataKey, Integer.parseInt(page), Integer.parseInt(pageSize)); + + if (homeTypeList != null) + for (HomeType homeType : homeTypeList) { + String resourceKey = StringUtil.Md5(org.yeshi.utils.StringUtil.concat(resourceList, ",")); + + long bigPictureCount = homeType.isBigPicture() ? 1 : 0;// homeTypeService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, true); + + List<HomeVideo> homeVideoList = homeVideoService.getHomeVideoList(homeType.getId(), resourceKey, resourceList, null, 1, homeType.getNumber() + (int) bigPictureCount); + if (bigPictureCount > 0 && homeVideoList.size() > 0) { + homeVideoList.get(0).setBigPicture(true); + } + long videoCount = homeVideoService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, null); + + if (videoCount - bigPictureCount > homeType.getNumber()) { + while ((videoCount - bigPictureCount) % homeType.getNumber() != 0) { + videoCount--; + } + } + homeType.setCount((int) videoCount); + List<HomeVideo> tempHomeVideoList = new ArrayList<>(); + tempHomeVideoList.addAll(homeVideoList); + while (tempHomeVideoList != null && tempHomeVideoList.size() > 0 && (tempHomeVideoList.size() - bigPictureCount) % homeType.getColumns() != 0 && homeType.getColumns() < 4) + tempHomeVideoList.remove(tempHomeVideoList.size() - 1); + + homeType.setHomeVideoList(tempHomeVideoList); + } + + try { + if (VersionUtil.isGraterThan387(acceptData.getPlatform(), acceptData.getVersion()) && dataKey.equalsIgnoreCase("recommend")) { + DetailSystemConfig adContent = configService.getConfigByKey("home_banner_ad_content", acceptData.getChildDetailSystem(), acceptData.getVersion()); + DetailSystemConfig adPosition = configService.getConfigByKey("home_banner_ad_position", acceptData.getChildDetailSystem(), acceptData.getVersion()); + if (adContent != null && adPosition != null) { + HomeType.HomeTypeAd ad = new Gson().fromJson(adContent.getValue(), HomeType.HomeTypeAd.class); + int adP = Integer.parseInt(adPosition.getValue()); + if (adP < homeTypeList.size() && adP > -1) { + HomeType homeType = new HomeType(); + homeType.setAd(ad); + if ("1".equalsIgnoreCase(page)) { + homeTypeList.add(adP, homeType); + } + count++; + } + } + } + } catch (Exception e) { + + } + + + JSONObject object = new JSONObject(); + JSONArray array = new JSONArray(); + for (int i = 0; i < homeTypeList.size(); i++) + array.add(StringUtil.outPutResultJson(homeTypeList.get(i))); + object.put("data", array); + object.put("count", count + ""); + out.print(JsonUtil.loadTrueJson(object.toString())); + } + + public HomeType convertHomeVideoList(HomeType type) { - List<VideoInfo> vlist = new ArrayList<VideoInfo>(); + List<VideoInfo> vlist = new ArrayList<>(); List<HomeVideo> list = type.getHomeVideoList(); if (list != null) for (HomeVideo hv : list) { @@ -277,6 +391,71 @@ type.setVideoList(vlist); return type; } + + + // 棣栭〉绫诲瀷鑾峰彇 + public void getHomeVideoList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { + + // 20170914 涓�绾ц棰戝垎绫籌D + String homeTypeId = request.getParameter("Id"); + int page = Integer.parseInt(request.getParameter("Page")); + + if (StringUtil.isNullOrEmpty(homeTypeId)) { + out.print(JsonUtil.loadFalseJson("")); + return; + } + + HomeType homeType = homeTypeService.getHomeTypeById(homeTypeId); + if (homeType == null) { + out.print(JsonUtil.loadFalseJson("")); + return; + } + + List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); + //鏌ヨ澶у浘 + List<HomeVideo> bigPictureVideos = new ArrayList<>(); + + if (homeType.isBigPicture()) { + bigPictureVideos = homeVideoService.getHomeVideoList(homeTypeId, org.yeshi.utils.StringUtil.concat(resourceList, ","), resourceList, null, 1, 1); + if (bigPictureVideos != null && bigPictureVideos.size() > 0) + bigPictureVideos.get(0).setBigPicture(true); + } + + //澶у浘闇�瑕佹瘡娆¢兘杩斿洖 + + JSONObject object = new JSONObject(); + String resourceKey = StringUtil.Md5(org.yeshi.utils.StringUtil.concat(resourceList, ",")); + + Long count = homeVideoService.getHomeVideoListCount(homeTypeId, resourceKey, resourceList, null); + if (count - bigPictureVideos.size() > homeType.getNumber()) { + + while ((count - bigPictureVideos.size()) % homeType.getNumber() != 0) { + count--; + } + } + + + List<HomeVideo> list1 = homeVideoService.getHomeVideoList(homeTypeId, resourceKey, resourceList, homeType.isBigPicture(), page, homeType.getNumber()); + List<HomeVideo> list = new ArrayList<>(); + list.addAll(bigPictureVideos); + list.addAll(list1); + JSONObject data = new JSONObject(); + object.put("count", count); + JSONArray array = new JSONArray(); + for (int i = 0; i < list.size(); i++) + array.add(StringUtil.outPutResultJson(list.get(i))); + object.put("list", array); + + //鍒ゆ柇鏄惁杩樻湁涓嬩竴椤� + int totalPage = (int) ((count - bigPictureVideos.size()) % homeType.getNumber() == 0 ? (count - bigPictureVideos.size()) / homeType.getNumber() : (count - bigPictureVideos.size()) / homeType.getNumber() + 1); + + if (page >= totalPage) { + page = 0; + } + object.put("page", page); + out.print(JsonUtil.loadTrueJson(object.toString())); + } + @RequireUid public void getMoreVideo(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { @@ -303,7 +482,7 @@ List<HomeVideo> homeVideoList = homeTypeService.getVideoByTypes(type, pageIndex, detailSystem); - List<VideoInfo> list = new ArrayList<VideoInfo>(); + List<VideoInfo> list = new ArrayList<>(); for (int i = 0; i < homeVideoList.size(); i++) { HomeVideo hv = (HomeVideo) homeVideoList.get(i); if (acceptData.getPackageName().contains("doudou")) { @@ -344,12 +523,249 @@ out.print(JsonUtil.loadTrueJson(object.toString())); } + + @Resource + private InternetSearchVideoService internetSearchVideoService; + @Resource + private YouKuUtil youKuUtil; + + @Resource + private MogoTVUtil mogoTVUtil; + + @Resource + private TencentVideoUtil tencentVideoUtil; + + @Resource + private BilibiliUtil bilibiliUtil; + + @Resource + private VideoPlayStatisticManager videoPlayStatisticManager; + + @Resource + private VideoResourceService videoResourceService; + + + private String createVideoDetailSessionId(AcceptData acceptData, String uid, String videoName, String videoId, String resourceId) { + + try { + VideoDetailStatisticData data = new VideoDetailStatisticData(); + data.setDetailSystemId(acceptData.getDetailSystem().getId()); + data.setLoginUid(uid); + data.setResourceId(Integer.parseInt(resourceId)); + data.setUtdId(acceptData.getUtdId()); + data.setVersion(acceptData.getVersion()); + data.setVideoId(videoId); + data.setVideoName(videoName); + + return videoPlayStatisticManager.createVideoDetailSessionId(data); + } catch (Exception e) { + + } + return null; + } + + + @Resource + private SolrShortVideoDataManager solrShortVideoDataManager; + + public void getVideoDetailForShortVideo(AcceptData acceptData, String videoId, HttpServletRequest request, PrintWriter out) { + String loginUid = request.getParameter("LoginUid"); + SolrShortVideo solrShortVideo = solrShortVideoDataManager.findOne(videoId); + String resourceId = solrShortVideo.getResourceId() + ""; + VideoResource videoResource = videoResourceService.getResource(resourceId); + videoResource.setChecked(true); + VideoInfo info = VideoInfoFactory.create(solrShortVideo); + info.setResourceList(Arrays.asList(new VideoResource[]{videoResource})); + if (info != null) + info.setPageSize(1); + info.setWatchCount("" + (int) (Math.random() * 1000)); + info.setPlayPicture(info.getPicture()); + + JSONArray array = new JSONArray(); + JSONObject obj = new JSONObject(); + out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), + obj.toString())); +// out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), loginUid), null, createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId))), array.toString(), +// obj.toString())); + } + + + public void getVideoDetailForInternetSearch(AcceptData acceptData, String videoId, HttpServletRequest request, PrintWriter out) { + String loginUid = request.getParameter("LoginUid"); + String from = request.getParameter("From"); + InternetSearchVideo internetSearchVideo = internetSearchVideoService.selectByPrimaryKey(videoId); + String resourceId = request.getParameter("ResourceId"); + String position = request.getParameter("Position"); + int pageSize = 100; + if (!StringUtil.isNullOrEmpty(position)) { + if (VersionUtil.isGraterThan391(acceptData.getPlatform(), acceptData.getVersion())) + pageSize = (Integer.parseInt(position) / 100 + 1) * 100; + } + + + if (StringUtil.isNullOrEmpty(resourceId)) { + resourceId = internetSearchVideo.getResourceIds().split(",")[0]; + } + + List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); + + if (resourceList != null) { + if (!resourceList.contains(Long.parseLong(resourceId))) { + out.print(JsonUtil.loadFalseAdmin("")); + return; + } + } + + + VideoInfo info = null; + if (Integer.parseInt(resourceId) == YouKuUtil.RESOURCE_ID) { + try { + info = youKuUtil.getVideoInfo(internetSearchVideo, pageSize); + + } catch (Exception e) { + logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId); + e.printStackTrace(); + out.print(JsonUtil.loadFalseAdmin(e.getMessage())); + return; + } + + } else if (Integer.parseInt(resourceId) == MogoTVUtil.RESOURCE_ID) { + try { + info = mogoTVUtil.getVideoInfo(internetSearchVideo, pageSize); + } catch (Exception e) { + logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId); + out.print(JsonUtil.loadFalseAdmin(e.getMessage())); + return; + } + } else if (Integer.parseInt(resourceId) == TencentVideoUtil.RESOURCE_ID) { + try { + info = tencentVideoUtil.getVideoInfo(internetSearchVideo, pageSize); + } catch (Exception e) { + e.printStackTrace(); + logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId); + out.print(JsonUtil.loadFalseAdmin(e.getMessage())); + return; + } + } else if (Integer.parseInt(resourceId) == BilibiliUtil.RESOURCE_ID) { + try { + info = bilibiliUtil.getVideoInfo(internetSearchVideo, pageSize); + } catch (Exception e) { + logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId); + out.print(JsonUtil.loadFalseAdmin(e.getMessage())); + return; + } + }else if (Integer.parseInt(resourceId) == HanmiUtil.RESOURCE_ID) { + try { + info = hanmiUtil.getVideoInfo(internetSearchVideo, pageSize); + } catch (Exception e) { + logger.error("鍏ㄧ綉鎼滆棰戣鎯呭嚭閿欙細" + videoId); + out.print(JsonUtil.loadFalseAdmin(e.getMessage())); + return; + } + } + + if (info != null) + info.setPageSize(pageSize); + + LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, info.getName(), from)); + + info.setWatchCount("" + (int) (Math.random() * 1000)); + + //瑙嗛杩囨护 + filterVideo(acceptData, info); + + JSONArray array = new JSONArray(); + JSONObject obj = new JSONObject(); + + if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) { + out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel(), loginUid), null, createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId))), array.toString(), + obj.toString())); + } else { + out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), + obj.toString())); + } + } + + //瑙嗛杩囨护 + private void filterVideo(AcceptData acceptData, VideoInfo video) { + //杩囨护瑙嗛璧勬簮 + List<VideoResource> resourceList = videoResourceInfoMapService.filter(acceptData.getDetailSystem().getId(), video.getResourceList()); + video.setResourceList(resourceList); + //鎺у埗鍓嶇鍒楄〃涓殑鏉ユ簮鏄剧ず闂 + if ("48".equalsIgnoreCase(acceptData.getDetailSystem().getId())) { + if (video.getArea() != null && video.getArea().contains("闊╁浗")) { + //鍒ゆ柇褰撳墠鐗堟湰鏄惁姝e湪涓婄嚎 + if (appManager.isOnline(acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel())) { + //濡傛灉鍦ㄤ笂绾垮氨鍒犻櫎鏈�変腑鐨勮祫婧愶紝骞朵笖灏嗗綋鍓嶈祫婧愬彉涓洪煩杩稵V + for (int i = 0; i < video.getResourceList().size(); i++) { + if (!video.getResourceList().get(i).isChecked()) { + video.getResourceList().remove(i--); + } + } + if (video.getResourceList().size() > 0) { + video.getResourceList().get(0).setName("PP瑙嗛"); + //鍦↖D鍓嶉潰娣诲姞native鏍囪瘑 + for (VideoDetailInfo videoDetailInfo : video.getVideoDetailList()) { + videoDetailInfo.setExtraId("native_" + videoDetailInfo.getExtraId()); + } + } + } + } + + } + + } + @RequireUid public void getVideoDetail(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { String videoId = request.getParameter("VideoId"); + if (!NumberUtil.isNumeric(videoId)) { + String[] cidVid = PPTVUtil.parseCidAndVidFromVisualVideoId(videoId); + if (cidVid == null) { + int fromType = VideoUtil.getVideoFromType(videoId); + //鐭棰� + if (fromType == HomeVideo.FROM_TYPE_SHORT) { + getVideoDetailForShortVideo(acceptData, videoId, request, out); + return; + } else if (fromType == HomeVideo.FROM_TYPE_INTERNET) { + getVideoDetailForInternetSearch(acceptData, videoId, request, out); + + //VIVO 娓犻亾姣忔棩骞垮憡鏈�澶氬睍绀轰竴娆� +// if ("vivo".equalsIgnoreCase(acceptData.getChannel())) { +// deviceAdStrategyService.setFSAShowTomorrow(acceptData.getUtdId(), acceptData.getDetailSystem().getId()); +// } + return; + } + } + String cid = cidVid[0]; + String vid = cidVid[1]; + + PPTVSeries series = pptvService.getSeriesDetail(cid); + if (series == null) { + series = PPTVApiUtil.getDetail(cid); + } + + if (series != null) { + JSONObject data = new JSONObject(); + String playUrl = PPTVUtil.getPlayUrl(series, pptvService.selectProgramById(vid)); + data.put("videoId", videoId); + data.put("playUrl", playUrl); + data.put("name", series.getName()); + data.put("pptv", true); + data.put("vip", PPTVUtil.isVIPVideo(series.getFree())); + out.print(JsonUtil.loadTrueJson(data.toString())); + } else { + out.print(JsonUtil.loadFalseJson("宸蹭笅绾�")); + } + + return; + } + String resourceId = request.getParameter("ResourceId"); String thirdType = request.getParameter("Type"); String loginUid = request.getParameter("LoginUid"); + String position = request.getParameter("Position"); + String from = request.getParameter("From"); if (StringUtil.isNullOrEmpty(videoId)) { out.print(JsonUtil.loadFalseJson("璇蜂笂浼燰ideoId")); @@ -360,10 +776,100 @@ return; } - List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getPlatform(), acceptData.getVersion()); + DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); - VideoInfo info = (videoDeailUtil.getVideoInfo(videoId, resourceId, resourceList, - CacheUtil.getMD5Long(resourceList))); + List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); + + //鑾峰彇浼樺厛灞曠ず鐨勬笭閬� + if (StringUtil.isNullOrEmpty(resourceId)) { + Set<Long> rids = new HashSet<>(); + rids.addAll(resourceList); + VideoResource defaultVideoResource = resourceVideoService.getDefaultVideoResource(videoId, rids); + if (defaultVideoResource != null) { + resourceId = defaultVideoResource.getId(); + } + //瑙嗛娌℃湁鏉ユ簮 + if (StringUtil.isNullOrEmpty(resourceId)) { + rabbitmqManager.addVideoResourceDeleteMsg(videoId); + out.print(JsonUtil.loadFalseJson("瑙嗛宸蹭笅绾�")); + return; + } + } + + ThreadUtil.run(new Runnable() { + @Override + public void run() { + int p = 0; + if (!StringUtil.isNullOrEmpty(position)) { + p = Integer.parseInt(position); + } + + VideoWatchHistory history = new VideoWatchHistory(); + history.setDevice(acceptData.getDevice()); + history.setVideoId(videoId); + history.setUid(loginUid); + history.setPosition(p); + videoWatchHistoryService.add(history); + } + }); + + userPlayLogger.info(VideoLogFactory.createUserVideoDetailLog(acceptData.getDevice(), acceptData.getUtdId(), loginUid, acceptData.getDetailSystem().getId(), videoId, resourceId, from)); + + + //PPTV缃戦〉鎾斁 + if (!StringUtil.isNullOrEmpty(resourceId) && Integer.parseInt(resourceId) == PPTVUtil.RESOURCE_ID) { + JSONObject data = new JSONObject(); + VideoPPTVMap map = pptvService.getVideoPPTVMapByVideoId(videoId); + int p = 0; + if (!StringUtil.isNullOrEmpty(position)) { + p = Integer.parseInt(position); + } else { + //鍙栨挱鏀捐褰� + VideoWatchHistory history = videoWatchHistoryService.getWatchHistory(acceptData.getDevice(), videoId); + if (history != null && history.getPosition() != null) { + p = history.getPosition(); + } + } + + String videoName = ""; + String playUrl = null; + + PPTVSeries series = pptvService.getSeriesDetail(map.getInfoId()); + + if (map.getProgramCode() != null) { + PPTVProgram program = pptvService.selectProgramById(map.getProgramCode()); + videoName = program.getProgramSetTiltle(); + playUrl = PPTVUtil.getPlayUrl(series, program); + } else { + videoName = series.getName(); + p = p >= series.getSeries().size() ? 0 : p; + playUrl = PPTVUtil.getPlayUrl(series, series.getSeries().get(p)); + } + + String sessionId = createVideoDetailSessionId(acceptData, loginUid, videoName, videoId, resourceId); + data.put("videoId", videoId); + data.put("playUrl", playUrl); + data.put("name", videoName); + data.put("pptv", true); + data.put("vip", "1".equalsIgnoreCase(series.getFree())); + data.put("sessionId", sessionId); + out.print(JsonUtil.loadTrueJson(data.toString())); + LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, series.getName(), from)); + + ThreadUtil.run(new Runnable() { + @Override + public void run() { + //鐪婸P瑙嗛 + deviceAdStrategyService.watchPPTVVideo(acceptData.getUtdId(), acceptData.getDetailSystem().getId()); + } + }); + return; + } + + + VideoInfo info = videoDeailUtil.getVideoInfo(detailSystem.getId(), videoId, resourceId, resourceList, + CacheUtil.getMD5Long(resourceList)); + LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, info != null ? info.getName() : "", from)); List<VideoType> typeList = classService.getVideoTypeList(info.getId()); if (typeList != null && typeList.size() > 0) { @@ -380,51 +886,267 @@ if (StringUtil.isNullOrEmpty(vd.getExtraId())) vd.setExtraId(vd.getId() + ""); } - System.out.println(info.getPlayPicture()); - // info.setPicture(VideoPictureUtil.getShowPicture(info, platform, - // version)); - - // 杩囨护鐗堟潈瑙嗛鍏抽敭瀛� - DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); - // 缁熻娣诲姞 - // statisticsService.addStatistics(detailSystem.getId(), videoId); JSONArray array = new JSONArray(); - array.add("http://cloud.letv.com"); - if ((acceptData.getPlatform().equalsIgnoreCase("android") - && acceptData.getVersion() > 12) || acceptData.getPlatform().equalsIgnoreCase("ios")) { - for (String st : Constant.POJIE_LIST) - array.add(st); - } - long count = commentService.getComment2ListCount(videoId, thirdType); if (info != null) info.setCommentCount((int) count); JSONObject obj = new JSONObject(); + VideoDetailVO.AttentionInfo attention = null; if (info.getVideoDetailList() != null) if (info.getVideoDetailList().size() > 1) {// 澶氶泦,鍙叧娉� boolean isAttention = false; if (!StringUtil.isNullOrEmpty(loginUid)) { isAttention = attentionService.isAddAttention(loginUid, info.getId()); } + attention = new VideoDetailVO.AttentionInfo(); + attention.setName(info.getName()); + attention.setPicture(info.getPicture()); + if (StringUtil.isNullOrEmpty(info.getUpdatetime())) { + attention.setUpdateInfo("鏇存柊:" + TimeUtil.getCommentTime(info.getCreatetime())); + } else { + attention.setUpdateInfo("鏇存柊:" + TimeUtil.getCommentTime(Long.parseLong(info.getUpdatetime()))); + } + attention.setAttention(isAttention); + + //鍏煎鑰佺増鏈� JSONObject attentionInfo = new JSONObject(); - attentionInfo.put("Name", info.getName()); - attentionInfo.put("Picture", info.getPicture()); - if (StringUtil.isNullOrEmpty(info.getUpdatetime())) - attentionInfo.put("UpdateInfo", "鏇存柊:" + TimeUtil.getCommentTime(info.getCreatetime())); - else - attentionInfo.put("UpdateInfo", "鏇存柊:" + TimeUtil.getCommentTime(Long.parseLong(info.getUpdatetime()))); - attentionInfo.put("IsAttention", isAttention); + attentionInfo.put("Picture", attention.getPicture()); + attentionInfo.put("Name", attention.getName()); + attentionInfo.put("UpdateInfo", attention.getUpdateInfo()); + attentionInfo.put("IsAttention", attention.isAttention()); obj.put("Attention", attentionInfo); } - UserInfo user = userService.getUserInfo(acceptData.getUid()); - if (Utils.isTest(request, user, detailSystem.getId())) - out.print(JsonUtil.loadTrueJson("")); - else + + //瑙嗛杩囨护 + filterVideo(acceptData, info); + + if (VersionUtil.isGraterThan390(acceptData.getPlatform(), acceptData.getVersion())) { + String sessionId = createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId); + + out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel(), loginUid, videoId, from), attention, sessionId)), array.toString(), + obj.toString())); + //VIVO 娓犻亾姣忔棩骞垮憡鏈�澶氬睍绀轰竴娆� +// if ("vivo".equalsIgnoreCase(acceptData.getChannel())) { +// deviceAdStrategyService.setFSAShowTomorrow(acceptData.getUtdId(), acceptData.getDetailSystem().getId()); +// } + } else { out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(), obj.toString())); + } + + ThreadUtil.run(new Runnable() { + @Override + public void run() { + long showTime = TimeUtil.convertGernalTime(TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"); + deviceAdStrategyService.setShortVideoAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), videoId, from, showTime, null); + } + }); } + + + @RequireUid + public void getVideoDetailNew(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { + String videoId = request.getParameter("VideoId"); + if (!NumberUtil.isNumeric(videoId)) { + String[] cidVid = PPTVUtil.parseCidAndVidFromVisualVideoId(videoId); + if (cidVid == null) { + int fromType = VideoUtil.getVideoFromType(videoId); + //鐭棰� + if (fromType == HomeVideo.FROM_TYPE_SHORT) { + getVideoDetailForShortVideo(acceptData, videoId, request, out); + return; + } else if (fromType == HomeVideo.FROM_TYPE_INTERNET) { + getVideoDetailForInternetSearch(acceptData, videoId, request, out); + return; + } + } + String cid = cidVid[0]; + String vid = cidVid[1]; + + PPTVSeries series = pptvService.getSeriesDetail(cid); + if (series == null) { + series = PPTVApiUtil.getDetail(cid); + } + + if (series != null) { + JSONObject data = new JSONObject(); + String playUrl = PPTVUtil.getPlayUrl(series, pptvService.selectProgramById(vid)); + data.put("videoId", videoId); + data.put("playUrl", playUrl); + data.put("name", series.getName()); + data.put("vip", PPTVUtil.isVIPVideo(series.getFree())); + JSONObject pptv = new JSONObject(); + pptv.put("pptv", data); + out.print(JsonUtil.loadTrueJson(pptv.toString())); + } else { + out.print(JsonUtil.loadFalseJson("宸蹭笅绾�")); + } + + return; + } + + String resourceId = request.getParameter("ResourceId"); + String thirdType = request.getParameter("Type"); + String loginUid = request.getParameter("LoginUid"); + String position = request.getParameter("Position"); + String from = request.getParameter("From"); + + if (StringUtil.isNullOrEmpty(videoId)) { + out.print(JsonUtil.loadFalseJson("璇蜂笂浼燰ideoId")); + return; + } + if (StringUtil.isNullOrEmpty(thirdType)) { + out.print(JsonUtil.loadFalseJson("璇蜂笂浼燭ype")); + return; + } + + DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); + + List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); + + //鑾峰彇浼樺厛灞曠ず鐨勬笭閬� + if (StringUtil.isNullOrEmpty(resourceId)) { + Set<Long> rids = new HashSet<>(); + rids.addAll(resourceList); + VideoResource defaultVideoResource = resourceVideoService.getDefaultVideoResource(videoId, rids); + if (defaultVideoResource != null) { + resourceId = defaultVideoResource.getId(); + } + //瑙嗛娌℃湁鏉ユ簮 + if (StringUtil.isNullOrEmpty(resourceId)) { + rabbitmqManager.addVideoResourceDeleteMsg(videoId); + out.print(JsonUtil.loadFalseJson("瑙嗛宸蹭笅绾�")); + return; + } + } + + ThreadUtil.run(new Runnable() { + @Override + public void run() { + int p = 0; + if (!StringUtil.isNullOrEmpty(position)) { + p = Integer.parseInt(position); + } + + VideoWatchHistory history = new VideoWatchHistory(); + history.setDevice(acceptData.getDevice()); + history.setVideoId(videoId); + history.setUid(loginUid); + history.setPosition(p); + videoWatchHistoryService.add(history); + } + }); + + userPlayLogger.info(VideoLogFactory.createUserVideoDetailLog(acceptData.getDevice(), acceptData.getUtdId(), loginUid, acceptData.getDetailSystem().getId(), videoId, resourceId, from)); + + + //PPTV缃戦〉鎾斁 + if (!StringUtil.isNullOrEmpty(resourceId) && Integer.parseInt(resourceId) == PPTVUtil.RESOURCE_ID) { + JSONObject data = new JSONObject(); + VideoPPTVMap map = pptvService.getVideoPPTVMapByVideoId(videoId); + int p = 0; + if (!StringUtil.isNullOrEmpty(position)) { + p = Integer.parseInt(position); + } else { + //鍙栨挱鏀捐褰� + VideoWatchHistory history = videoWatchHistoryService.getWatchHistory(acceptData.getDevice(), videoId); + if (history != null && history.getPosition() != null) { + p = history.getPosition(); + } + } + + String videoName = ""; + String playUrl = null; + + PPTVSeries series = pptvService.getSeriesDetail(map.getInfoId()); + + if (map.getProgramCode() != null) { + PPTVProgram program = pptvService.selectProgramById(map.getProgramCode()); + videoName = program.getProgramSetTiltle(); + playUrl = PPTVUtil.getPlayUrl(series, program); + } else { + videoName = series.getName(); + p = p >= series.getSeries().size() ? 0 : p; + playUrl = PPTVUtil.getPlayUrl(series, series.getSeries().get(p)); + } + + String sessionId = createVideoDetailSessionId(acceptData, loginUid, videoName, videoId, resourceId); + data.put("videoId", videoId); + data.put("playUrl", playUrl); + data.put("name", videoName); + data.put("pptv", true); + data.put("vip", "1".equalsIgnoreCase(series.getFree())); + data.put("sessionId", sessionId); + out.print(JsonUtil.loadTrueJson(data.toString())); + LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, series.getName(), from)); + + ThreadUtil.run(new Runnable() { + @Override + public void run() { + //鐪婸P瑙嗛 + deviceAdStrategyService.watchPPTVVideo(acceptData.getUtdId(), acceptData.getDetailSystem().getId()); + } + }); + return; + } + + + VideoInfo info = videoDeailUtil.getVideoInfo(detailSystem.getId(), videoId, resourceId, resourceList, + CacheUtil.getMD5Long(resourceList)); + LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, info != null ? info.getName() : "", from)); + + List<VideoType> typeList = classService.getVideoTypeList(info.getId()); + if (typeList != null && typeList.size() > 0) { + VideoType type = typeList.get(0); + while (type.getParent() != null) + type = type.getParent(); + info.setVideoType(type); + } + + info.setPlayPicture(VideoPictureUtil.getShowPicture(info, acceptData.getPlatform(), acceptData.getVersion() + "")); + + if (info.getVideoDetailList() != null) + for (VideoDetailInfo vd : info.getVideoDetailList()) { + if (StringUtil.isNullOrEmpty(vd.getExtraId())) + vd.setExtraId(vd.getId() + ""); + } + info.setCommentCount(0); + + + VideoDetailVO.AttentionInfo attention = null; + if (info.getVideoDetailList() != null) + if (info.getVideoDetailList().size() > 1) {// 澶氶泦,鍙叧娉� + boolean isAttention = false; + if (!StringUtil.isNullOrEmpty(loginUid)) { + isAttention = attentionService.isAddAttention(loginUid, info.getId()); + } + attention = new VideoDetailVO.AttentionInfo(); + attention.setName(info.getName()); + attention.setPicture(info.getPicture()); + if (StringUtil.isNullOrEmpty(info.getUpdatetime())) { + attention.setUpdateInfo("鏇存柊:" + TimeUtil.getCommentTime(info.getCreatetime())); + } else { + attention.setUpdateInfo("鏇存柊:" + TimeUtil.getCommentTime(Long.parseLong(info.getUpdatetime()))); + } + attention.setAttention(isAttention); + } + + //瑙嗛杩囨护 + filterVideo(acceptData, info); + String sessionId = createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId); + out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(new VideoDetailVO(Utils.convertVideo(info), deviceAdStrategyService.getVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel(), loginUid, videoId, from), attention, sessionId)))); + + ThreadUtil.run(new Runnable() { + @Override + public void run() { + long showTime = TimeUtil.convertGernalTime(TimeUtil.getGernalTime(System.currentTimeMillis() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"), "yyyy-MM-dd"); + deviceAdStrategyService.setShortVideoAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), videoId, from, showTime, null); + } + }); + } + /** * 鑾峰彇瑙嗛鐨勫墽闆嗗垪琛� @@ -438,6 +1160,7 @@ String videoId = request.getParameter("VideoId"); String resourceId = request.getParameter("ResourceId"); String page = request.getParameter("Page");//椤电爜 + String pageSize = request.getParameter("PageSize");//椤� if (StringUtil.isNullOrEmpty(videoId)) { out.print(JsonUtil.loadFalseJson("璇蜂笂浼燰ideoId")); @@ -452,9 +1175,13 @@ out.print(JsonUtil.loadFalseJson("璇蜂笂浼燩age")); return; } + int pagesize = 100; + if (!StringUtil.isNullOrEmpty(pageSize)) { + pagesize = Integer.parseInt(pageSize); + } - List<VideoDetailInfo> list = videoDetailUtil.getVideoDetailList(videoId, new VideoResource(resourceId), Integer.parseInt(page), 100); + List<VideoDetailInfo> list = videoDetailUtil.getVideoDetailList(videoId, new VideoResource(resourceId), Integer.parseInt(page), pagesize); if (list == null) list = new ArrayList<>(); JSONObject data = new JSONObject(); @@ -481,6 +1208,12 @@ return; } + if (!NumberUtil.isNumeric(detailId)) { + out.print(JsonUtil.loadFalseJson("")); + return; + } + + boolean collect = collectionService.isCollect(acceptData.getUid(), detailId, thirdType); if (collect) out.print(JsonUtil.loadTrueJson("")); @@ -505,17 +1238,22 @@ return; } - if (StringUtil.isNullOrEmpty(type)) { - out.print(JsonUtil.loadFalseJson("璇蜂笂浼爐ype")); - return; - } +// if (StringUtil.isNullOrEmpty(type)) { +// out.print(JsonUtil.loadFalseJson("璇蜂笂浼爐ype")); +// return; +// } if (StringUtil.isNullOrEmpty(id)) id = eid; DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); - PlayUrl pu = videoDeailUtil.getPlayUrl(acceptData,detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId); + PlayUrl pu = null; + try { + pu = videoDeailUtil.getPlayUrl(acceptData, detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId); + } catch (VideoPlayException e) { + e.printStackTrace(); + } if (pu != null) { if (!StringUtil.isNullOrEmpty(pu.getUrl())) @@ -527,6 +1265,55 @@ } } + + + // 鑾峰彇闊╁墽鐨勬挱鏀鹃摼鎺� + public void getHjPlayUrl(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { + String resourceId = request.getParameter("ResourceId"); + String id = request.getParameter("Id"); + String eid = request.getParameter("EId"); + String type = request.getParameter("Type"); + String videoId = request.getParameter("VideoId"); + + if (StringUtil.isNullOrEmpty(resourceId)) { + out.print(JsonUtil.loadFalseJson("璇蜂笂浼燫esourceId")); + return; + } + + if (StringUtil.isNullOrEmpty(id) && StringUtil.isNullOrEmpty(eid)) { + out.print(JsonUtil.loadFalseJson("璇蜂笂浼爄d")); + return; + } + +// if (StringUtil.isNullOrEmpty(type)) { +// out.print(JsonUtil.loadFalseJson("璇蜂笂浼爐ype")); +// return; +// } + + if (StringUtil.isNullOrEmpty(id)) + id = eid; + + DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); + + PlayUrl pu = null; + try { + pu = videoDeailUtil.getPlayUrl(acceptData, detailSystem.getId(), id, type, Integer.parseInt(resourceId), videoId); + } catch (VideoPlayException e) { + e.printStackTrace(); + } + + if (pu != null) { + if (!StringUtil.isNullOrEmpty(pu.getUrl())) + pu.setUrl(pu.getUrl()); + JSONObject object = JSONObject.fromObject(StringUtil.outPutResultJson(pu)); + out.print(JsonUtil.loadTrueJson(object.toString())); + } else { + out.print(JsonUtil.loadFalseJson("鎵句笉鍒拌瑙嗛")); + } + + } + + public List<HomeVideo> getZhiBoVideoList() throws Exception { @@ -569,7 +1356,7 @@ public void isPraise(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); - Config config = configService.getConfigByKey("banner_praise", detailSystem, acceptData.getVersion()); + DetailSystemConfig config = configService.getConfigByKey("banner_praise", acceptData.getChildDetailSystem(), acceptData.getVersion()); if ("鏄�".equals(config.getValue())) { out.print(JsonUtil.loadTrueJson("1")); } else { @@ -577,4 +1364,36 @@ } } + + @Resource + private SearchSpecialPositionMapService searchSpecialPositionMapService; + + /** + * 鑾峰彇鎺ㄨ崘鐨勬悳绱笓棰� + * + * @param acceptData + * @param request + * @param out + */ + public void getRecommendSearchSpecial(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { + DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); + //鎺ㄨ崘鎼滅储涓撻 + DetailSystemConfig config = configService.getConfigByKey("recommend_search_special_position", acceptData.getChildDetailSystem(), acceptData.getVersion()); + if (config == null) { + out.print(JsonUtil.loadFalseAdmin("浣嶇疆涓虹┖")); + return; + } + String key = config.getValue(); + List<SearchSpecialPositionMap> mapList = searchSpecialPositionMapService.listDetailByPosition(key, 1, 20); + JSONArray array = new JSONArray(); + for (SearchSpecialPositionMap map : mapList) { + JSONObject item = new JSONObject(); + item.put("icon", map.getIcon()); + item.put("name", map.getShowName() == null ? map.getSpecial().getName() : map.getShowName()); + item.put("id", map.getSpecialId()); + array.add(item); + } + out.print(JsonUtil.loadTrueJson(array.toString())); + } + } -- Gitblit v1.8.0