admin
2021-06-16 42fa17d6209d10cbe4774388d0ff3fcf3329eb5a
src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
@@ -31,6 +31,7 @@
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.video.VideoWatchHistoryService;
import com.yeshi.buwan.service.manager.VideoPlayStatisticManager;
import com.yeshi.buwan.tencent.TencentVideoUtil;
@@ -40,6 +41,7 @@
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.videos.bilibili.BilibiliUtil;
import com.yeshi.buwan.vo.AcceptData;
import com.yeshi.buwan.vo.video.VideoDetailVO;
import com.yeshi.buwan.youku.YouKuUtil;
@@ -71,6 +73,10 @@
    private HomeAdService homeAdService;
    @Resource
    private HomeTypeService homeTypeService;
    @Resource
    private HomeVideoService homeVideoService;
    @Resource
    private DetailSystemConfigService configService;
    @Resource
@@ -310,11 +316,11 @@
                long bigPictureCount = homeType.isBigPicture() ? 1 : 0;// homeTypeService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, true);
                List<HomeVideo> homeVideoList = homeTypeService.getHomeVideoList(homeType.getId(), resourceKey, resourceList, null, 1, homeType.getNumber() + (int) bigPictureCount);
                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 = homeTypeService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, null);
                long videoCount = homeVideoService.getHomeVideoListCount(homeType.getId(), resourceKey, resourceList, null);
                if (videoCount - bigPictureCount > homeType.getNumber()) {
                    while ((videoCount - bigPictureCount) % homeType.getNumber() != 0) {
@@ -397,7 +403,7 @@
        List<HomeVideo> bigPictureVideos = new ArrayList<>();
        if (homeType.isBigPicture()) {
            bigPictureVideos = homeTypeService.getHomeVideoList(homeTypeId, org.yeshi.utils.StringUtil.concat(resourceList, ","), resourceList, null, 1, 1);
            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);
        }
@@ -407,7 +413,7 @@
        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) {
@@ -416,7 +422,7 @@
        }
        List<HomeVideo> list1 = homeTypeService.getHomeVideoList(homeTypeId, resourceKey, resourceList, homeType.isBigPicture(), 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);
@@ -463,7 +469,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")) {
@@ -515,6 +521,9 @@
    @Resource
    private TencentVideoUtil tencentVideoUtil;
    @Resource
    private BilibiliUtil bilibiliUtil;
    @Resource
    private VideoPlayStatisticManager videoPlayStatisticManager;
@@ -579,6 +588,14 @@
        } else if (Integer.parseInt(resourceId) == TencentVideoUtil.RESOURCE_ID) {
            try {
                info = tencentVideoUtil.getVideoInfo(internetSearchVideo, pageSize);
            } catch (Exception e) {
                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()));
@@ -730,10 +747,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;
@@ -795,12 +810,20 @@
        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(), loginUid, videoId, from), attention, sessionId)), array.toString(),
                    obj.toString()));
        } 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);
            }
        });
    }