admin
2024-10-17 b30fb8afd3cd6228bda9b182dc412bb3c8daf69c
src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
@@ -1,47 +1,55 @@
package com.yeshi.buwan.controller.parser;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.google.gson.Gson;
import com.yeshi.buwan.domain.*;
import com.yeshi.buwan.domain.jump.JumpDetail;
import com.yeshi.buwan.domain.jump.JumpTypeEnum;
import com.yeshi.buwan.domain.entity.PlayUrl;
import com.yeshi.buwan.domain.recommend.HomeRecommendSpecial;
import com.yeshi.buwan.domain.system.DetailSystemConfig;
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.mogotv.MogoTVUtil;
import com.yeshi.buwan.pptv.PPTVUtil;
import com.yeshi.buwan.pptv.entity.PPTVSeries;
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.juhe.YouKuService;
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.tencent.TencentVideoUtil;
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 com.yeshi.buwan.youku.YouKuUtil;
import com.yeshi.buwan.youku.entity.YouKuSearchVideoMap;
import com.yeshi.buwan.youku.entity.YouKuShowDetail;
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;
@@ -49,13 +57,11 @@
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import com.yeshi.buwan.domain.entity.PlayUrl;
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 {
@@ -68,6 +74,10 @@
    private HomeAdService homeAdService;
    @Resource
    private HomeTypeService homeTypeService;
    @Resource
    private HomeVideoService homeVideoService;
    @Resource
    private DetailSystemConfigService configService;
    @Resource
@@ -109,6 +119,18 @@
    @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");
@@ -191,7 +213,7 @@
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
        JSONObject object = new JSONObject();
        List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion());
        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<>();
@@ -199,7 +221,7 @@
            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) {
@@ -228,8 +250,8 @@
                }
                if (VersionUtil.isGraterThan387(acceptData.getPlatform(), acceptData.getVersion())) {
                    DetailSystemConfig adContent = configService.getConfigByKey("home_banner_ad_content", acceptData.getDetailSystem(), acceptData.getVersion());
                    DetailSystemConfig adPosition = configService.getConfigByKey("home_banner_ad_position", acceptData.getDetailSystem(), 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());
@@ -298,15 +320,21 @@
        long count = homeTypeService.countHomeType(acceptData.getDetailSystem().getId(), acceptData.getVersion(), dataKey);
        List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion());
        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, ","));
                List<HomeVideo> homeVideoList = homeTypeService.getHomeVideoList(homeType.getId(), resourceKey, resourceList, null, 1, homeType.getNumber());
                long videoCount = homeTypeService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, null);
                long bigPictureCount = homeTypeService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, true);
                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--;
@@ -315,11 +343,33 @@
                homeType.setCount((int) videoCount);
                List<HomeVideo> tempHomeVideoList = new ArrayList<>();
                tempHomeVideoList.addAll(homeVideoList);
                while (tempHomeVideoList != null && (tempHomeVideoList.size() - bigPictureCount) % homeType.getColumns() != 0)
                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();
@@ -332,7 +382,7 @@
    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) {
@@ -361,17 +411,22 @@
            return;
        }
        List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion());
        List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel());
        //查询大图
        List<HomeVideo> bigPictureVideos = homeTypeService.getHomeVideoList(homeTypeId, org.yeshi.utils.StringUtil.concat(resourceList, ","), resourceList, true, 1, homeType.getNumber());
        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 = homeTypeService.getHomeVideoListCount(homeTypeId, resourceKey, resourceList, null);
        Long count = homeVideoService.getHomeVideoListCount(homeTypeId, resourceKey, resourceList, null);
        if (count - bigPictureVideos.size() > homeType.getNumber()) {
            while ((count - bigPictureVideos.size()) % homeType.getNumber() != 0) {
@@ -380,7 +435,7 @@
        }
        List<HomeVideo> list1 = homeTypeService.getHomeVideoList(homeTypeId, resourceKey, resourceList, false, page, homeType.getNumber());
        List<HomeVideo> list1 = homeVideoService.getHomeVideoList(homeTypeId, resourceKey, resourceList, homeType.isBigPicture(), page, homeType.getNumber());
        List<HomeVideo> list = new ArrayList<>();
        list.addAll(bigPictureVideos);
        list.addAll(list1);
@@ -427,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")) {
@@ -481,7 +536,13 @@
    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) {
@@ -504,6 +565,31 @@
    }
    @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");
@@ -520,6 +606,17 @@
        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 {
@@ -544,6 +641,23 @@
            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;
@@ -557,11 +671,14 @@
        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(), loginUid), null, createVideoDetailSessionId(acceptData, loginUid, info.getName(), videoId, resourceId))), array.toString(),
            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(),
@@ -569,11 +686,78 @@
        }
    }
    //视频过滤
    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("韩国")) {
                //判断当前版本是否正在上线
                if (appManager.isOnline(acceptData.getDetailSystem().getId(), acceptData.getVersion(), acceptData.getChannel())) {
                    //如果在上线就删除未选中的资源,并且将当前资源变为韩迷TV
                    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视频");
                        //在ID前面添加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)) {
            getVideoDetailForInternetSearch(acceptData, videoId, request, out);
            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;
        }
@@ -594,7 +778,7 @@
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
        List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion());
        List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel());
        //获取优先展示的渠道
        if (StringUtil.isNullOrEmpty(resourceId)) {
@@ -603,6 +787,12 @@
            VideoResource defaultVideoResource = resourceVideoService.getDefaultVideoResource(videoId, rids);
            if (defaultVideoResource != null) {
                resourceId = defaultVideoResource.getId();
            }
            //视频没有来源
            if (StringUtil.isNullOrEmpty(resourceId)) {
               rabbitmqManager.addVideoResourceDeleteMsg(videoId);
                out.print(JsonUtil.loadFalseJson("视频已下线"));
                return;
            }
        }
@@ -627,9 +817,9 @@
        //PPTV网页播放
        if (resourceId != null && Integer.parseInt(resourceId) == PPTVUtil.RESOURCE_ID) {
        if (!StringUtil.isNullOrEmpty(resourceId) && Integer.parseInt(resourceId) == PPTVUtil.RESOURCE_ID) {
            JSONObject data = new JSONObject();
            PPTVSeries series = pptvService.getSeriesDetailByVideoId(videoId);
            VideoPPTVMap map = pptvService.getVideoPPTVMapByVideoId(videoId);
            int p = 0;
            if (!StringUtil.isNullOrEmpty(position)) {
                p = Integer.parseInt(position);
@@ -641,14 +831,27 @@
                }
            }
            p = p >= series.getSeries().size() ? 0 : p;
            String videoName = "";
            String playUrl = null;
            String sessionId = createVideoDetailSessionId(acceptData, loginUid, series.getName(), videoId, resourceId);
            String playUrl = PPTVUtil.getPlayUrl(series, series.getSeries().get(p));
            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", series.getName());
            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));
@@ -656,10 +859,8 @@
            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.setVideoDetailAdStrategy(acceptData.getUtdId(), acceptData.getDetailSystem().getId(), showTime, null);
                    //看PP视频
                    deviceAdStrategyService.watchPPTVVideo(acceptData.getUtdId(), acceptData.getDetailSystem().getId());
                }
            });
            return;
@@ -717,16 +918,233 @@
                attentionInfo.put("IsAttention", attention.isAttention());
                obj.put("Attention", attentionInfo);
            }
        UserInfo user = userService.getUserInfo(acceptData.getUid());
        //视频过滤
        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(), loginUid), attention, sessionId)), array.toString(),
            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("请上传VideoId"));
            return;
        }
        if (StringUtil.isNullOrEmpty(thirdType)) {
            out.print(JsonUtil.loadFalseJson("请上传Type"));
            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() {
                    //看PP视频
                    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);
            }
        });
    }
@@ -820,17 +1238,22 @@
            return;
        }
        if (StringUtil.isNullOrEmpty(type)) {
            out.print(JsonUtil.loadFalseJson("请上传type"));
            return;
        }
//        if (StringUtil.isNullOrEmpty(type)) {
//            out.print(JsonUtil.loadFalseJson("请上传type"));
//            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()))
@@ -842,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("请上传ResourceId"));
            return;
        }
        if (StringUtil.isNullOrEmpty(id) && StringUtil.isNullOrEmpty(eid)) {
            out.print(JsonUtil.loadFalseJson("请上传id"));
            return;
        }
//        if (StringUtil.isNullOrEmpty(type)) {
//            out.print(JsonUtil.loadFalseJson("请上传type"));
//            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 {
@@ -884,7 +1356,7 @@
    public void isPraise(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
        DetailSystemConfig 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 {
@@ -892,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()));
    }
}