package com.yeshi.buwan.controller.parser;
|
|
import com.yeshi.buwan.domain.*;
|
import com.yeshi.buwan.domain.ad.CommonAd;
|
import com.yeshi.buwan.domain.ad.CommonAdPositionAd;
|
import com.yeshi.buwan.domain.recommend.CategoryRecommendVideo;
|
import com.yeshi.buwan.domain.recommend.HomeRecommendSpecial;
|
import com.yeshi.buwan.domain.solr.SolrAlbumVideo;
|
import com.yeshi.buwan.domain.special.Special;
|
import com.yeshi.buwan.domain.system.DetailSystem;
|
import com.yeshi.buwan.domain.system.DetailSystemConfig;
|
import com.yeshi.buwan.dto.search.SolrResultDTO;
|
import com.yeshi.buwan.dto.search.SolrVideoSearchFilter;
|
import com.yeshi.buwan.service.manager.search.SolrInternetSearchVideoDataManager;
|
import com.yeshi.buwan.util.factory.VideoInfoFactory;
|
import com.yeshi.buwan.videos.pptv.PPTVUtil;
|
import com.yeshi.buwan.service.imp.*;
|
import com.yeshi.buwan.service.imp.recommend.CategoryRecommendVideoService;
|
import com.yeshi.buwan.service.inter.recommend.HomeRecommendSpecialService;
|
import com.yeshi.buwan.service.manager.search.SolrAlbumVideoDataManager;
|
import com.yeshi.buwan.util.*;
|
import com.yeshi.buwan.util.JuHe.VideoResourceUtil;
|
import com.yeshi.buwan.util.ad.CommonAdUtil;
|
import com.yeshi.buwan.util.annotation.RequireUid;
|
import com.yeshi.buwan.util.video.VideoConstant;
|
import com.yeshi.buwan.vo.AcceptData;
|
import com.yeshi.buwan.vo.HomeClassVO;
|
import com.yeshi.buwan.vo.video.VideoListResultVO;
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
import org.springframework.stereotype.Controller;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import java.io.PrintWriter;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
|
@Controller
|
public class ClassParser {
|
@Resource
|
private SystemService systemService;
|
@Resource
|
private ClassService classService;
|
@Resource
|
private StarService starService;
|
@Resource
|
private HomeTypeService homeTypeService;
|
@Resource
|
private CategoryAreaService categoryAreaService;
|
@Resource
|
private HotVideoTypeService hotVideoTypeService;
|
@Resource
|
private SpecialService specialService;
|
@Resource
|
private UserService userService;
|
@Resource
|
private VideoResourceUtil videoResouceUtil;
|
@Resource
|
private CategoryRecommendVideoService categoryRecommendVideoService;
|
@Resource
|
private AdService adService;
|
@Resource
|
private BanQuanService banQuanService;
|
@Resource
|
private CategoryRecommendCacheVideoService categoryRecommendCacheVideoService;
|
|
@Resource
|
private RedisManager redisManager;
|
@Resource
|
private SolrAlbumVideoDataManager solrAlbumVideoDataManager;
|
|
@Resource
|
private SolrInternetSearchVideoDataManager solrInternetSearchVideoDataManager;
|
|
@Resource
|
private SearchService searchService;
|
|
@Resource
|
private HomeRecommendSpecialService homeRecommendSpecialService;
|
|
@Resource
|
private DetailSystemConfigService detailSystemConfigService;
|
|
|
private static String[] getAreas(String area) {
|
switch (area) {
|
case "港台":
|
return new String[]{"香港", "台湾"};
|
case "其他国家":
|
return new String[]{"澳大利亚", "新加坡", "印度"};
|
case "欧洲":
|
return new String[]{"英国", "法国", "德国", "俄罗斯", "意大利", "土耳其"};
|
default:
|
return new String[]{area};
|
}
|
}
|
|
|
@RequireUid
|
public void getClass(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<SuperVideoType> list = classService.getSuperVideoTypeList(detailSystem.getId());
|
|
if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
for (SuperVideoType type : list) {
|
if (type.getType().getName().contains("资讯")) {
|
type.getType().setName("主播");
|
type.getType().setId(1111);
|
type.getType().setIcon("http://img.zcool.cn/community/017fdb57610d8a0000012e7e74b496.png");
|
break;
|
}
|
}
|
}
|
|
// if ("android".equalsIgnoreCase(acceptData.getPlatform()) && acceptData.getVersion() > 53) {
|
// SuperVideoType sty = new SuperVideoType();
|
// sty.setCreatetime(0 + "");
|
// sty.setPicture("");
|
// VideoType vt = new VideoType(22222);
|
// vt.setName("头条");
|
// vt.setCategoryType("http://wap.baizhan.net/09");
|
// vt.setIcon("http://img.zcool.cn/community/01e299592fd75ba8012193a365723f.png@1280w_1l_2o_100sh.png");
|
// sty.setType(vt);
|
// boolean isC = false;
|
// for (SuperVideoType svt : list) {
|
// if (svt.getType().getId() == vt.getId()) {
|
// isC = true;
|
// break;
|
// }
|
// }
|
//
|
// if (!isC)
|
// list.add(sty);
|
// }
|
|
List<VideoType> typeList = new ArrayList<VideoType>();
|
for (int i = 0; i < list.size(); i++) {
|
if (!StringUtil.isNullOrEmpty(list.get(i).getPicture())) {
|
list.get(i).getType().setIcon(list.get(i).getPicture());
|
}
|
if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && acceptData.getVersion() >= Constant.IOS_ONLINING_VERSION) {
|
if (VideoConstant.isMainCategory(list.get(i).getType().getId())) {
|
typeList.add(list.get(i).getType());
|
}
|
} else
|
typeList.add(list.get(i).getType());
|
}
|
|
|
JSONObject object = new JSONObject();
|
object.put("count", (new StringBuilder(String.valueOf(typeList.size()))).toString());
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < typeList.size(); i++)
|
array.add(StringUtil.outPutResultJson(typeList.get(i)));
|
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
|
}
|
|
@RequireUid
|
public void getNewClass(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<SuperVideoType> list1 = classService.getSuperVideoTypeList(detailSystem.getId());
|
for (SuperVideoType superVideoType : list1) {
|
superVideoType.setPicture(superVideoType.getPicture().trim());
|
}
|
|
List<SuperVideoType> list = new ArrayList<>();
|
list.addAll(list1);
|
|
for (int i = 0; i < list.size(); i++) {
|
if (list.get(i).getType().getName().contains("资讯")) {
|
list.remove(i);
|
break;
|
}
|
}
|
|
|
//Android平台3.8.7之后返回VIP
|
// if ("android".equalsIgnoreCase(acceptData.getPlatform()) && acceptData.getVersion() >= 105) {
|
//
|
// SuperVideoType sty = new SuperVideoType();
|
// sty.setCreatetime(0 + "");
|
// sty.setPicture("");
|
// VideoType vt = new VideoType(Constant.VIDEO_TYPE_VIP);
|
// vt.setName("VIP");
|
// vt.setShow("1");
|
// vt.setIcon("https://hbimg.huabanimg.com/4690ea8f8144f3d46c11e417c77daa5debcb71f9201f-WpAbfw_fw658/format/jpg");
|
// sty.setType(vt);
|
// boolean isC = false;
|
// for (SuperVideoType svt : list) {
|
// if (svt.getType().getId() == vt.getId()) {
|
// isC = true;
|
// break;
|
// }
|
// }
|
// list.add(sty);
|
// }
|
|
|
List<VideoType> typelist = new ArrayList<VideoType>();
|
for (SuperVideoType sv : list) {
|
if (!StringUtil.isNullOrEmpty(sv.getPicture())) {
|
sv.getType().setIcon(sv.getPicture());
|
}
|
VideoType type = sv.getType();
|
if ("1".equals(type.getShow())) {
|
typelist.add(type);
|
}
|
}
|
|
JSONObject object = new JSONObject();
|
object.put("count", (new StringBuilder(String.valueOf(typelist.size()))).toString());
|
JSONArray array = new JSONArray();
|
for (int j = 0; j < typelist.size(); j++)
|
array.add(StringUtil.outPutResultJson(typelist.get(j)));
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
}
|
|
/**
|
* 获取当前系统所有后台视频分类
|
*
|
* @param acceptData
|
* @param request
|
* @param out
|
*/
|
public void getVideoClass(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<SuperVideoType> list = classService.getSuperVideoTypeTitleList(detailSystem.getId());
|
|
if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && acceptData.getVersion() < 50) {
|
for (int i = 0; i < list.size(); i++) {
|
if (list.get(i).getType().getId() == 309 || list.get(i).getType().getId() == 310) {
|
list.remove(i);
|
i--;
|
}
|
}
|
}
|
|
List<VideoType> typelist = new ArrayList<VideoType>();
|
for (SuperVideoType sv : list) {
|
if (!StringUtil.isNullOrEmpty(sv.getPicture())) {
|
sv.getType().setIcon(sv.getPicture());
|
}
|
VideoType type = sv.getType();
|
// if(type.getName().contains("资讯")){
|
// continue;
|
// }
|
typelist.add(type);
|
}
|
|
if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && acceptData.getVersion() >= Constant.IOS_ONLINING_VERSION) {
|
typelist = new ArrayList<>();
|
HomeClassVO vo = new HomeClassVO();
|
vo.setId(309L);
|
vo.setName("推荐");
|
vo.setShowTitle("推荐");
|
vo.setDataType(HomeClassVO.DATA_TYPE_RECOMMEND);
|
typelist.add(vo);
|
|
vo = new HomeClassVO();
|
vo.setId(VideoConstant.VIDEO_CATEGORY_DIANYING);
|
vo.setName("电影");
|
vo.setShowTitle("电影");
|
vo.setDataType(HomeClassVO.DATA_TYPE_CLASS);
|
typelist.add(vo);
|
|
vo = new HomeClassVO();
|
vo.setId(VideoConstant.VIDEO_CATEGORY_DIANSHIJU);
|
vo.setName("电视剧");
|
vo.setShowTitle("电视剧");
|
vo.setDataType(HomeClassVO.DATA_TYPE_CLASS);
|
typelist.add(vo);
|
|
vo = new HomeClassVO();
|
vo.setId(VideoConstant.VIDEO_CATEGORY_DONGMAN);
|
vo.setName("动漫");
|
vo.setShowTitle("动漫");
|
vo.setDataType(HomeClassVO.DATA_TYPE_CLASS);
|
typelist.add(vo);
|
|
vo = new HomeClassVO();
|
vo.setId(VideoConstant.VIDEO_CATEGORY_ZONGYI);
|
vo.setName("综艺");
|
vo.setShowTitle("综艺");
|
vo.setDataType(HomeClassVO.DATA_TYPE_CLASS);
|
typelist.add(vo);
|
}
|
|
JSONObject object = new JSONObject();
|
object.put("count", (new StringBuilder(String.valueOf(typelist.size()))).toString());
|
JSONArray array = new JSONArray();
|
for (int j = 0; j < typelist.size(); j++)
|
array.add(StringUtil.outPutResultJson(typelist.get(j)));
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
|
}
|
|
|
/**
|
* 获取首页导航分类
|
*
|
* @param acceptData
|
* @param request
|
* @param out
|
*/
|
public void getHomeClass(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<SuperVideoType> list = classService.getSuperVideoTypeTitleList(detailSystem.getId());
|
|
List<HomeClassVO> typelist = new ArrayList<>();
|
for (SuperVideoType sv : list) {
|
VideoType type = sv.getType();
|
HomeClassVO vo = new HomeClassVO();
|
|
if ("0".equalsIgnoreCase(type.getShow()))
|
vo.setDataType(HomeClassVO.DATA_TYPE_RECOMMEND);
|
else
|
vo.setDataType(HomeClassVO.DATA_TYPE_CLASS);
|
vo.setId(type.getId());
|
vo.setName(type.getName());
|
vo.setShowTitle(type.getShowTitle());
|
vo.setType(type.getType());
|
vo.setCategoryType(type.getCategoryType());
|
//删除老版本中的除开分类的顶部标签
|
if (sv.getType().getId() != 309L && sv.getType().getId() != 310L)
|
typelist.add(vo);
|
}
|
|
//IOS审核版本
|
DetailSystemConfig onLineVersion = detailSystemConfigService.getConfigByKey("ios_online_version", acceptData.getDetailSystem(), acceptData.getVersion());
|
if (onLineVersion != null && Integer.parseInt(onLineVersion.getValue()) <= acceptData.getVersion()) {
|
typelist.clear();
|
}
|
|
//获取首页推荐标签
|
List<HomeRecommendSpecial> specialList = homeRecommendSpecialService.listSpecialByDetailSystemId(acceptData.getDetailSystem().getId(), null, 1, Constant.pageCount);
|
if (specialList != null) {
|
for (int i = specialList.size() - 1; i >= 0; i--) {
|
HomeRecommendSpecial special = specialList.get(i);
|
HomeClassVO vo = new HomeClassVO();
|
vo.setId(Long.parseLong(special.getId()));
|
vo.setName(special.getName());
|
vo.setShowTitle(special.getName());
|
vo.setDataKey(special.getDataKey());
|
vo.setDataType(HomeClassVO.DATA_TYPE_RECOMMEND);
|
if (vo.getName().contains("高清"))
|
vo.setColor("#ff6600");
|
typelist.add(0, vo);
|
}
|
}
|
|
JSONObject object = new JSONObject();
|
object.put("count", (new StringBuilder(String.valueOf(typelist.size()))).toString());
|
JSONArray array = new JSONArray();
|
for (int j = 0; j < typelist.size(); j++)
|
array.add(StringUtil.outPutResultJson(typelist.get(j)));
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
}
|
|
|
public void getHotStars(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
|
String page = request.getParameter("Page");
|
|
int pageIndex = StringUtil.getPage(page);
|
if (pageIndex == 0) {
|
out.print(JsonUtil.loadFalseJson("Page"));
|
return;
|
}
|
|
List<HotStar> list = starService.getHotStarList(pageIndex, 100);
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user1 = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user1, detailSystem.getId()))
|
list = new ArrayList<HotStar>();
|
|
JSONObject object = new JSONObject();
|
object.put("count", Constant.isUpdate ? "19"
|
: ((Object) ((new StringBuilder(String.valueOf(starService.getHotStarCount()))).toString())));
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
}
|
|
public void getHotStarDetail(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
|
String id = request.getParameter("Id");
|
|
|
HotStar hot = starService.getHotStarDetail(id);
|
out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(hot)));
|
|
}
|
|
@RequireUid
|
public void getHotStarsVideo(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
|
String page = request.getParameter("Page");
|
String starId = request.getParameter("StarId");
|
|
if (StringUtil.isNullOrEmpty(starId)) {
|
out.print(JsonUtil.loadFalseJson("StarId"));
|
return;
|
}
|
|
int pageIndex = StringUtil.getPage(page);
|
if (pageIndex <= 0) {
|
out.print(JsonUtil.loadFalseJson("Page"));
|
return;
|
}
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
|
List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, acceptData.getVersion(), acceptData.getChannel());
|
List<VideoInfo> list = starService.getStarVideo(detailSystem.getId(), starId, pageIndex,
|
CacheUtil.getMD5Long(resourceList));
|
|
String cacheMD5 = "";
|
if (list != null) {
|
for (VideoInfo info : list) {
|
cacheMD5 += info.getId() + "#";
|
}
|
}
|
|
list = banQuanService.getBanQuanVideo(list, detailSystem.getId(), cacheMD5);
|
|
JSONObject object = new JSONObject();
|
object.put("count",
|
Constant.isUpdate ? "19"
|
: ((Object) ((new StringBuilder(
|
String.valueOf(starService.getStarVideoCount(detailSystem.getId(), starId))))
|
.toString())));
|
JSONArray array = new JSONArray();
|
|
for (int i = 0; i < list.size(); i++) {
|
list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), acceptData.getPlatform(), acceptData.getVersion() + ""));
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
}
|
|
object.put("data", array);
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
out.print("");
|
else
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
|
}
|
|
@RequireUid
|
public void getVideoList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String starId = request.getParameter("StarId");
|
String homeType = request.getParameter("HomeType");
|
String videoType = request.getParameter("VideoType");
|
String order = request.getParameter("Order");// 1-最热 2-最新 4-评分最高
|
String page = request.getParameter("Page");
|
String yearId = request.getParameter("YearId");
|
String categoryType = request.getParameter("CategoryType");// 新版接口使用
|
|
if (StringUtil.isNullOrEmpty(starId) && StringUtil.isNullOrEmpty(homeType)
|
&& StringUtil.isNullOrEmpty(videoType)) {
|
out.print(JsonUtil.loadFalseJson("StarId\u6216\u8005HomeType\u6216\u8005 VideoType"));
|
return;
|
}
|
|
int pageIndex = StringUtil.getPage(page);
|
if (pageIndex <= 0) {
|
out.print(JsonUtil.loadFalseJson("Page"));
|
return;
|
}
|
|
DetailSystem detailSystem = acceptData.getDetailSystem();
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel());
|
|
String resourceMD5 = CacheUtil.getMD5Long(resourceList);
|
|
String key = "videolist-" + StringUtil.Md5(String.format("%s#%s#%s#%s#%s#%s#%s#%s", starId + "", homeType + "",
|
videoType + "", categoryType + "", order, resourceMD5, detailSystem.getId(), pageIndex + ""));
|
VideoListResultVO vo = null;
|
|
try {
|
vo = redisManager.getVideoList(key);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
|
List<VideoInfo> list = null;
|
String count = "";
|
|
if (vo != null) {
|
list = vo.getVideoList();
|
count = vo.getCount() + "";
|
} else {
|
|
if (!StringUtil.isNullOrEmpty(starId)) {
|
|
list = starService.getStarVideo(detailSystem.getId(), starId, pageIndex, resourceList,
|
CacheUtil.getMD5Long(resourceList));
|
count = (new StringBuilder(String.valueOf(starService.getStarVideoCount(detailSystem.getId(), starId))))
|
.toString();
|
|
} else if (!StringUtil.isNullOrEmpty(homeType)) {
|
|
list = new ArrayList<>();
|
List<HomeVideo> homeVideoList = homeTypeService.getVideoByTypes(homeType, pageIndex, detailSystem);
|
|
for (HomeVideo hv : homeVideoList) {
|
if (detailSystem.getPackageName().contains("doudou")) {
|
if (!StringUtil.isNullOrEmpty(hv.getPicture()))
|
hv.getVideo().setPicture(hv.getPicture());
|
}
|
list.add(hv.getVideo());
|
}
|
|
count = (new StringBuilder(String.valueOf(homeTypeService.getVideoCountByTypes(homeType, pageIndex))))
|
.toString();
|
} else if (!StringUtil.isNullOrEmpty(videoType)) {
|
if (StringUtil.isNullOrEmpty(categoryType) || "genre".equalsIgnoreCase(categoryType)) {// 按分类检索数据
|
|
if (!StringUtil.isNullOrEmpty(order)) {
|
Long startTime = System.currentTimeMillis();
|
List<VideoInfo> list1 = classService.getTypeVideoList(videoType, detailSystem, pageIndex, 20,
|
Integer.parseInt(order), resourceList, CacheUtil.getMD5Long(resourceList));
|
list = new ArrayList<>();
|
if (list1 != null)
|
for (VideoInfo info : list1)
|
list.add(info);
|
|
System.out.println("列表获取时间:" + (System.currentTimeMillis() - startTime));
|
} else {
|
List<VideoInfo> list1 = classService.getTypeVideoList(videoType, detailSystem, pageIndex, 20, 1,
|
resourceList, CacheUtil.getMD5Long(resourceList));
|
list = new ArrayList<>();
|
if (list1 != null)
|
for (VideoInfo info : list1)
|
list.add(info);
|
}
|
count = 1200 + "";
|
|
|
} else {// 按地区检索数据
|
//非VIP分类
|
List<Integer> vipTypes = Arrays.asList(Constant.vipTypes);
|
if (vipTypes.contains(Integer.parseInt(videoType))) {
|
//VIP分类
|
SolrVideoSearchFilter filter = new SolrVideoSearchFilter();
|
filter.setFreeType(1);
|
switch (Integer.parseInt(videoType)) {
|
case Constant.VIDEO_TYPE_VIP_MOVIE:
|
filter.setVideoType(VideoConstant.VIDEO_CATEGORY_DIANYING);
|
break;
|
case Constant.VIDEO_TYPE_VIP_TV:
|
filter.setVideoType(VideoConstant.VIDEO_CATEGORY_DIANSHIJU);
|
break;
|
case Constant.VIDEO_TYPE_VIP_CARTOON:
|
filter.setVideoType(VideoConstant.VIDEO_CATEGORY_DONGMAN);
|
break;
|
case Constant.VIDEO_TYPE_VIP_SHOW:
|
filter.setVideoType(VideoConstant.VIDEO_CATEGORY_ZONGYI);
|
break;
|
default:
|
}
|
filter.setResourceIds(Arrays.asList(new String[]{PPTVUtil.RESOURCE_ID + ""}));
|
|
//更新时间
|
if ("1".equalsIgnoreCase(order)) {
|
filter.setSortKey("updateTime");
|
} else {
|
//观看次数
|
filter.setSortKey("watchcount");
|
}
|
SolrResultDTO resultDTO = solrAlbumVideoDataManager.find(filter, pageIndex, 20);
|
count = resultDTO.getTotalCount() + "";
|
list = searchService.convertSolrAlbumResultToVideo(resultDTO.getVideoList(), resourceList);
|
} else {
|
String areaId = videoType;// 国籍ID
|
CategoryContry cc = categoryAreaService.getCategoryArea(areaId);
|
String country = cc.getName();
|
long typeid = cc.getParent().getCid();
|
if (StringUtil.isNullOrEmpty(order))
|
order = 1 + "";
|
//通过专辑搜索查询
|
List<String> rids = new ArrayList<>();
|
for (Long rid : resourceList) {
|
rids.add(rid + "");
|
}
|
|
SolrVideoSearchFilter filter = new SolrVideoSearchFilter();
|
filter.setResourceIds(rids);
|
filter.setVideoType((int) typeid);
|
filter.setAreas(Arrays.asList(getAreas(country)));
|
SolrResultDTO result = solrAlbumVideoDataManager.find(filter, pageIndex, 20);
|
|
list = new ArrayList<>();
|
for (Object av : result.getVideoList()) {
|
list.add(VideoInfoFactory.create((SolrAlbumVideo) av));
|
}
|
count = result.getTotalCount() + "";
|
|
if (pageIndex == 1 && result.getTotalCount() == 0) {
|
|
solrInternetSearchVideoDataManager.find(filter,pageIndex,20);
|
|
}
|
|
|
// list = categoryAreaService.getVideoInfoByArea(typeid + "", detailSystem, pageIndex, 20,
|
// Integer.parseInt(order), resourceList, country,
|
// StringUtil.Md5(typeid + "-" + detailSystem + "-" + pageIndex + "-" + order + "-" + country
|
// + "-" + CacheUtil.getMD5Long(resourceList)));
|
System.out.println("列表最终数量:" + list.size());
|
// count = 1000 + "";
|
}
|
}
|
}
|
list = banQuanService.getBanQuanVideo(list, detailSystem.getId(), CacheUtil.getMD5VideoInfo(list));
|
|
for (int i = 0; i < list.size(); i++) {
|
list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), acceptData.getPlatform(), acceptData.getVersion() + ""));
|
if (JuheVideoUtil.isNeedDelete(list.get(i), detailSystem.getId())) {
|
list.remove(i);
|
i--;
|
}
|
}
|
|
//缓存数据
|
|
if (list != null && list.size() > 0) {
|
redisManager.saveVideoList(key, new VideoListResultVO(list, Long.parseLong(count)));
|
}
|
|
}
|
|
// 缓存数据
|
|
JSONObject object = new JSONObject();
|
object.put("count", Constant.isUpdate ? "19" : ((Object) (count)));
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++) {
|
list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), acceptData.getPlatform(), acceptData.getVersion() + ""));
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
}
|
object.put("data", array);
|
object.put("Column", 2);
|
System.out.println(object.optString("Column"));
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
out.flush();
|
out.close();
|
}
|
|
// getFirstChildType
|
public void getFirstChildType(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
|
String parentId = request.getParameter("ParentId");
|
|
if (StringUtil.isNullOrEmpty(parentId)) {
|
out.print(JsonUtil.loadFalseJson("ParentId"));
|
return;
|
}
|
|
|
List<VideoType> list = classService.getFirstTypeList(parentId);
|
if (list == null)
|
list = new ArrayList<VideoType>();
|
VideoType type = new VideoType(Integer.parseInt(parentId));
|
type.setName("全部");
|
type.setShow("1");
|
list.add(0, type);
|
JSONObject object = new JSONObject();
|
object.put("count", list.size());
|
JSONArray array = new JSONArray();
|
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
|
}
|
|
public void getFirstChildTypeNew(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
|
String parentId = request.getParameter("ParentId");
|
|
//是否包含VIP的分类
|
boolean containsVIPType = false;
|
try {
|
List<Integer> vipTypeList = Arrays.asList(Constant.vipTypes);
|
containsVIPType = vipTypeList.contains(Integer.parseInt(parentId));
|
} catch (Exception e) {
|
|
}
|
if (StringUtil.isNullOrEmpty(parentId)) {
|
out.print(JsonUtil.loadFalseJson("请上传ParentId"));
|
return;
|
}
|
JSONArray array = new JSONArray();
|
JSONObject object = new JSONObject();
|
List<VideoType> list = new ArrayList<VideoType>();
|
|
boolean isVersionV2 = false;
|
|
if (acceptData.getPlatform().equalsIgnoreCase("android"))
|
isVersionV2 = acceptData.getVersion() >= Constant.VERSION_NEW_ANDROID_V2;
|
else
|
isVersionV2 = acceptData.getVersion() >= Constant.VERSION_NEW_IOS_V2;
|
|
if ("150".equalsIgnoreCase(parentId) || "151".equalsIgnoreCase(parentId) || "152".equalsIgnoreCase(parentId)
|
|| "153".equalsIgnoreCase(parentId)) {
|
|
List<CategoryContry> clist = categoryAreaService.getCategoryContryListByCid(parentId);
|
|
List<CategoryContry> areaList = categoryAreaService.categoryContryList(clist.get(0).getId() + "");
|
|
if (isVersionV2) {
|
VideoType type = new VideoType(Integer.parseInt(parentId));
|
type.setName("推荐");
|
type.setShow("1");
|
type.setCategoryType("genre");
|
list.add(0, type);
|
}
|
|
for (CategoryContry cc : areaList) {
|
VideoType type = new VideoType(cc.getId());
|
type.setName(cc.getName());
|
type.setShow("1");
|
type.setCategoryType("area");
|
list.add(type);
|
}
|
|
if ("150".equalsIgnoreCase(parentId)) {
|
VideoType vt = classService.getType(282);
|
vt.setParent(null);
|
vt.setCategoryType("genre");
|
list.add(vt);
|
} else if ("151".equalsIgnoreCase(parentId)) {
|
VideoType vt = classService.getType(281);
|
vt.setParent(null);
|
vt.setCategoryType("genre");
|
list.add(vt);
|
} else if ("153".equalsIgnoreCase(parentId)) {
|
VideoType vt = classService.getType(283);
|
vt.setParent(null);
|
vt.setCategoryType("genre");
|
list.add(vt);
|
}
|
|
if (acceptData.getVersion() > 60) { // 20170915删除推荐
|
list.remove(0);
|
}
|
|
} else if (containsVIPType) {
|
//VIP分类
|
|
//VIP根分类
|
if (Constant.VIDEO_TYPE_VIP == Integer.parseInt(parentId)) {
|
VideoType type = new VideoType(Constant.VIDEO_TYPE_VIP);
|
type.setName("全部");
|
type.setShow("1");
|
type.setCategoryType("area");
|
list.add(type);
|
|
|
type = new VideoType(Constant.VIDEO_TYPE_VIP_MOVIE);
|
type.setName("电影");
|
type.setShow("1");
|
type.setCategoryType("area");
|
list.add(type);
|
|
type = new VideoType(Constant.VIDEO_TYPE_VIP_TV);
|
type.setName("电视剧");
|
type.setShow("1");
|
type.setCategoryType("area");
|
list.add(type);
|
|
|
type = new VideoType(Constant.VIDEO_TYPE_VIP_CARTOON);
|
type.setName("动漫");
|
type.setShow("1");
|
type.setCategoryType("area");
|
list.add(type);
|
|
// type = new VideoType(Constant.VIDEO_TYPE_VIP_SHOW);
|
// type.setName("综艺");
|
// type.setShow("1");
|
// type.setCategoryType("area");
|
// list.add(type);
|
} else {
|
VideoType type = new VideoType(Integer.parseInt(parentId));
|
type.setName("全部");
|
type.setShow("1");
|
type.setCategoryType("area");
|
list.add(type);
|
}
|
|
|
} else {
|
List<VideoType> clist = classService.getFirstTypeList(parentId);
|
list = new ArrayList<>();
|
if (clist != null)
|
for (VideoType vt : clist)
|
list.add(vt);
|
|
VideoType type = new VideoType(Integer.parseInt(parentId));
|
if (!isVersionV2)
|
type.setName("全部");
|
else
|
type.setName("推荐");
|
type.setShow("1");
|
type.setCategoryType("genre");
|
list.add(0, type);
|
if (acceptData.getVersion() > 60) { // 20170915删除推荐
|
list.remove(0);
|
}
|
}
|
for (int i = 0; i < list.size(); i++) {
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
}
|
|
object.put("count", array.size());
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
}
|
|
@RequireUid
|
public void getHotType(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<HotVideoType> list = hotVideoTypeService.getSuperHotTypeList(detailSystem.getId());
|
|
JSONObject object = new JSONObject();
|
object.put("count", list.size());
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
}
|
|
public void getSpecialList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
request.getParameterMap();
|
String page = request.getParameter("Page");
|
|
int pageIndex = 1;
|
pageIndex = Integer.parseInt(page);
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
detailSystem = systemService.getDetailSystemById(40 + "");
|
|
List<Special> list = specialService.getSpecialList(detailSystem.getId(), pageIndex);
|
long count = specialService.getSpecialCount(detailSystem.getId());
|
|
JSONObject object = 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("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
}
|
|
@Resource
|
private VideoResourceService videoResourceService;
|
|
@RequireUid
|
public void getSpecialDetail(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String specialid = request.getParameter("Id");
|
Special special = specialService.getSpecial(specialid);
|
List<VideoInfo> list = specialService.getSpecialVideoList(specialid);
|
List<Long> availableResourceIds = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel());
|
List<VideoInfo> tempList = new ArrayList<>();
|
for (VideoInfo videoInfo : list) {
|
List<VideoResource> resourceList = videoResourceService.getResourceByVideo(videoInfo);
|
List<Long> rids = new ArrayList<>();
|
for (VideoResource vr : resourceList) {
|
if (availableResourceIds.contains(Long.parseLong(vr.getId()))) {
|
rids.add(Long.parseLong(vr.getId()));
|
break;
|
}
|
}
|
if (rids.size() > 0) {
|
tempList.add(videoInfo);
|
}
|
}
|
|
list = tempList;
|
|
|
JSONObject object = new JSONObject();
|
object.put("count", list.size());
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++) {
|
list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), acceptData.getPlatform(), acceptData.getVersion() + ""));
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
}
|
object.put("data", array);
|
|
object.put("special", StringUtil.outPutResultJson(special));
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
UserInfo user = userService.getUserInfo(acceptData.getUid());
|
if (Utils.isTest(request, user, detailSystem.getId()))
|
out.print("");
|
else
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
|
}
|
|
public void getRecommendCategoryVideoBanner(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String typeid = request.getParameter("Type");
|
if (StringUtil.isNullOrEmpty(typeid)) {
|
typeid = "310";
|
}
|
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
List<CategoryRecommendVideo> crvList = categoryRecommendVideoService
|
.getCategoryRecommendVideoBannerList(detailSystem.getId(), Integer.parseInt(typeid));
|
|
int pid = CommonAdUtil.getCommonAdPositionByVideoType(Integer.parseInt(typeid), acceptData.getPlatform());
|
List<CommonAdPositionAd> adList = adService.getCommonAdByPid("" + pid);
|
|
if (adList != null && adList.size() > 0) {
|
for (int i = 0; i < adList.size(); i++) {
|
int p = adList.get(i).getPosition();
|
CategoryRecommendVideo sc = new CategoryRecommendVideo();
|
CommonAd ca = adList.get(i).getAd();
|
ca.setPid(pid + "");
|
sc.setPicture(ca.getPicture());
|
sc.setDesc(ca.getDesc());
|
sc.setAd(ca);
|
if (p < crvList.size()) {
|
crvList.add(p, sc);
|
} else {// 直接加到末尾
|
crvList.add(sc);
|
}
|
}
|
}
|
|
JSONObject object = new JSONObject();
|
object.put("count", crvList.size());
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < crvList.size(); i++) {
|
JSONObject json = JSONObject.fromObject(StringUtil.outPutResultJson(crvList.get(i)));
|
if ("310".equals(typeid)) { // 310做的特殊处理:前端处理的是HomeAd,所有需要返回homeAD的形式
|
Object vi = json.get("VideoInfo");
|
json.put("Video", vi);
|
//设置banner的比例
|
object.put("bannerSizeRate", "0.56");
|
}
|
json.put("LinkType", "1");
|
array.add(json);
|
}
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
}
|
|
public void getRecommendCategoryVideoList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
|
String typeid = request.getParameter("Type");
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
|
List<VideoInfo> rankList = null;
|
// if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && acceptData.getVersion() >= Constant.IOS_ONLINING_VERSION) {
|
// SolrVideoSearchFilter filter = new SolrVideoSearchFilter();
|
// filter.setResourceIds(new String[]{25 + ""});
|
// filter.setVideoType(Integer.parseInt(typeid));
|
// filter.setFreeType(0);
|
// SolrResultDTO dto = solrAlbumVideoDataManager.find(filter, 1, 30);
|
// List<SolrAlbumVideo> list = dto.getVideoList();
|
// rankList = new ArrayList<>();
|
// for (SolrAlbumVideo video : list) {
|
// rankList.add(VideoInfoFactory.create(video));
|
// }
|
// }
|
// else {
|
rankList = categoryRecommendCacheVideoService.getVideoListByRank(Integer.parseInt(typeid),
|
detailSystem.getId(), acceptData.getPlatform(), acceptData.getVersion(), acceptData.getChannel());
|
// }
|
|
|
List<VideoInfo> list = new ArrayList<>();
|
list.addAll(rankList);
|
for (VideoInfo vi : list) {// 清除无用数据,防止浪费带宽,更改图片
|
vi.setIntroduction("");
|
vi.setMainActor("");
|
vi.setPicture(VideoPictureUtil.getShowPicture(vi, acceptData.getPlatform(), acceptData.getVersion() + ""));
|
}
|
|
JSONObject object = new JSONObject();
|
int size = list.size();
|
if (size % 2 != 0) {
|
list.remove(list.get(size - 1));
|
}
|
object.put("count", list.size());
|
JSONArray array = new JSONArray();
|
for (int i = 0; i < list.size(); i++)
|
array.add(StringUtil.outPutResultJson(list.get(i)));
|
object.put("data", array);
|
out.print(JsonUtil.loadTrueJson(object.toString()));
|
}
|
|
}
|