| | |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.buwan.domain.solr.SolrAlbumVideo; |
| | | 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.videos.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.service.imp.*; |
| | | import com.yeshi.buwan.service.manager.search.SolrAlbumVideoDataManager; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.factory.VideoInfoFactory; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | import com.yeshi.buwan.domain.DetailSystem; |
| | | import com.yeshi.buwan.domain.system.DetailSystem; |
| | | import com.yeshi.buwan.domain.HotStar; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.domain.ad.CommonAd; |
| | |
| | | import com.yeshi.buwan.domain.news.FoundNews; |
| | | import com.yeshi.buwan.domain.news.News; |
| | | import com.yeshi.buwan.domain.special.Special; |
| | | import com.yeshi.buwan.service.imp.AdService; |
| | | import com.yeshi.buwan.service.imp.SpecialService; |
| | | import com.yeshi.buwan.service.imp.StarService; |
| | | import com.yeshi.buwan.service.imp.SystemService; |
| | | import com.yeshi.buwan.service.imp.VideoService; |
| | | import com.yeshi.buwan.service.imp.news.NewsService; |
| | | import com.yeshi.buwan.util.JsonUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | |
| | | @Controller |
| | | public class FoundParser { |
| | | |
| | | @Resource |
| | | private SpecialService specialService; |
| | | @Resource |
| | | private SystemService systemService; |
| | | @Resource |
| | | private StarService starService; |
| | | @Resource |
| | | private NewsService newsService; |
| | | @Resource |
| | | private AdService adService; |
| | | @Resource |
| | | private VideoService videoService; |
| | | @Resource |
| | | private SpecialService specialService; |
| | | @Resource |
| | | private SystemService systemService; |
| | | @Resource |
| | | private StarService starService; |
| | | @Resource |
| | | private NewsService newsService; |
| | | @Resource |
| | | private AdService adService; |
| | | @Resource |
| | | private VideoService videoService; |
| | | @Resource |
| | | private DetailSystemConfigService detailSystemConfigService; |
| | | |
| | | public void getSpecialMainList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | public void getSpecialMainList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<Special> list = specialService.getSpecialOnMain(ds.getId()); |
| | | int pid = 0; |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) |
| | | pid = 1; |
| | | else |
| | | pid = 3; |
| | | 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(); |
| | | Special sc = new Special(); |
| | | CommonAd ca = adList.get(i).getAd(); |
| | | ca.setPid(pid + ""); |
| | | sc.setPicture(ca.getPicture()); |
| | | sc.setIntroduction(ca.getDesc()); |
| | | sc.setCommonAd(ca); |
| | | if (p < list.size()) { |
| | | list.add(p, sc); |
| | | } else {// 直接加到末尾 |
| | | list.add(sc); |
| | | } |
| | | } |
| | | } |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<Special> list = specialService.getSpecialOnMain(ds.getId()); |
| | | int pid = 0; |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) |
| | | pid = 1; |
| | | else |
| | | pid = 3; |
| | | 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(); |
| | | Special sc = new Special(); |
| | | CommonAd ca = adList.get(i).getAd(); |
| | | ca.setPid(pid + ""); |
| | | sc.setPicture(ca.getPicture()); |
| | | sc.setIntroduction(ca.getDesc()); |
| | | sc.setCommonAd(ca); |
| | | if (p < list.size()) { |
| | | list.add(p, sc); |
| | | } else {// 直接加到末尾 |
| | | list.add(sc); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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())); |
| | | } |
| | | 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 getHotStarMainList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | public void getHotStarMainList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<HotStar> list = starService.getHotStarOnMain(ds.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())); |
| | | } |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<HotStar> list = starService.getHotStarOnMain(ds.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 getNewsMainList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<News> newsList = new ArrayList<News>(); |
| | | public void getNewsMainList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<News> newsList = new ArrayList<News>(); |
| | | |
| | | List<FoundNews> list = newsService.getNewsOnMain(ds.getId()); |
| | | for (FoundNews fn : list) { |
| | | if (!StringUtil.isNullOrEmpty(fn.getPicture()) && fn.getNews().getImgList() != null |
| | | && fn.getNews().getImgList().size() > 0) |
| | | fn.getNews().getImgList().get(0).setUrl(fn.getPicture()); |
| | | fn.getNews().setReadCount((int) (Math.random() * 10000)); |
| | | newsList.add(fn.getNews()); |
| | | } |
| | | if (newsList != null && newsList.size() > 0) { |
| | | newsList.get(0).setShowType(4); |
| | | } |
| | | List<FoundNews> list = newsService.getNewsOnMain(ds.getId()); |
| | | for (FoundNews fn : list) { |
| | | if (!StringUtil.isNullOrEmpty(fn.getPicture()) && fn.getNews().getImgList() != null |
| | | && fn.getNews().getImgList().size() > 0) |
| | | fn.getNews().getImgList().get(0).setUrl(fn.getPicture()); |
| | | fn.getNews().setReadCount((int) (Math.random() * 10000)); |
| | | newsList.add(fn.getNews()); |
| | | } |
| | | if (newsList != null && newsList.size() > 0) { |
| | | newsList.get(0).setShowType(4); |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", newsList.size() + ""); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < newsList.size(); i++) |
| | | array.add(StringUtil.outPutResultJson(newsList.get(i))); |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", newsList.size() + ""); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < newsList.size(); i++) |
| | | array.add(StringUtil.outPutResultJson(newsList.get(i))); |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | public void getAppHui(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | public void getAppHui(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | |
| | | int pid = CommonAdUtil.getFoundAPPHuiPosition(acceptData.getPlatform()); |
| | | |
| | | int pid = CommonAdUtil.getFoundAPPHuiPosition(acceptData.getPlatform()); |
| | | // DetailSystem ds = |
| | | // systemService.getDetailSystemByPackage(packageName); |
| | | |
| | | // DetailSystem ds = |
| | | // systemService.getDetailSystemByPackage(packageName); |
| | | List<CommonAdPositionAd> adList = adService.getCommonAdByPid(pid + ""); |
| | | |
| | | List<CommonAdPositionAd> adList = adService.getCommonAdByPid(pid + ""); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", adList.size() + ""); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < adList.size(); i++) { |
| | | adList.get(i).getAd().setPid(pid + ""); |
| | | array.add(StringUtil.outPutResultJson(adList.get(i).getAd())); |
| | | } |
| | | object.put("data", array); |
| | | object.put("Url", "http://www.baidu.com"); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", adList.size() + ""); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < adList.size(); i++) { |
| | | adList.get(i).getAd().setPid(pid + ""); |
| | | array.add(StringUtil.outPutResultJson(adList.get(i).getAd())); |
| | | } |
| | | object.put("data", array); |
| | | object.put("Url", "http://www.baidu.com"); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | @Resource |
| | | private SolrAlbumVideoDataManager solrAlbumVideoDataManager; |
| | | |
| | | // 获取猜你喜欢 |
| | | public void guessLike(AcceptData acceptData,HttpServletRequest request, PrintWriter out) { |
| | | // 获取猜你喜欢 |
| | | public void guessLike(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | String page = request.getParameter("Page"); |
| | | String page = request.getParameter("Page"); |
| | | |
| | | if (StringUtil.isNullOrEmpty(page)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传page")); |
| | | return; |
| | | } |
| | | |
| | | List<VideoInfo> list = videoService.guessLike(Integer.parseInt(page)); |
| | | if (list != null) |
| | | Collections.shuffle(list); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", "1000"); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | list.get(i).setDuration(getDurationDesc(list.get(i).getDuration())); |
| | | list.get(i).setWatchCount((int) (Math.random() * 500) + ""); |
| | | if (!StringUtil.isNullOrEmpty(list.get(i).getHpicture())) |
| | | list.get(i).setPicture(list.get(i).getHpicture()); |
| | | array.add(StringUtil.outPutResultJson(list.get(i))); |
| | | } |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(page)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传page")); |
| | | return; |
| | | } |
| | | |
| | | private String getDurationDesc(String duration) { |
| | | if (StringUtil.isNullOrEmpty(duration)) |
| | | return ""; |
| | | try { |
| | | int d = Integer.parseInt(duration); |
| | | if (d < 3600) { |
| | | int m = d / 60; |
| | | int s = d % 60; |
| | | return (m < 10 ? "0" + m : m + "") + ":" + (s < 10 ? "0" + s : s + ""); |
| | | List<VideoInfo> list = null; |
| | | |
| | | } else { |
| | | int h = d / 3600; |
| | | int m = (d % 3600) / 60; |
| | | int s = d % 60; |
| | | return (h < 10 ? "0" + h : h + "") + ":" + (m < 10 ? "0" + m : m + "") + ":" |
| | | + (s < 10 ? "0" + s : s + ""); |
| | | } |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | //IOS审核版本 |
| | | DetailSystemConfig onLineVersion = detailSystemConfigService.getConfigByKey("ios_online_version", ds, acceptData.getVersion()); |
| | | if (onLineVersion != null && Integer.parseInt(onLineVersion.getValue()) <= acceptData.getVersion()) { |
| | | SolrVideoSearchFilter filter = new SolrVideoSearchFilter(); |
| | | filter.setResourceIds(Arrays.asList(new String[]{PPTVUtil.RESOURCE_ID + ""})); |
| | | SolrResultDTO resultDTO = solrAlbumVideoDataManager.find(filter, Integer.parseInt(page), Constant.pageCount); |
| | | if (resultDTO != null) { |
| | | List<SolrAlbumVideo> solrAlbumVideoList = resultDTO.getVideoList(); |
| | | if (solrAlbumVideoList != null && solrAlbumVideoList.size() > 0) { |
| | | list = new ArrayList<>(); |
| | | for (SolrAlbumVideo av : solrAlbumVideoList) { |
| | | VideoInfo videoInfo = VideoInfoFactory.create(av); |
| | | videoInfo.setDuration(""); |
| | | list.add(videoInfo); |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | list = videoService.guessLike(Integer.parseInt(page)); |
| | | } |
| | | if (list != null) |
| | | Collections.shuffle(list); |
| | | |
| | | } catch (Exception e) { |
| | | } |
| | | return duration; |
| | | } |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", "1000"); |
| | | JSONArray array = new JSONArray(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | list.get(i).setDuration(getDurationDesc(list.get(i).getDuration())); |
| | | list.get(i).setWatchCount((int) (Math.random() * 500) + ""); |
| | | if (!StringUtil.isNullOrEmpty(list.get(i).getHpicture())) |
| | | list.get(i).setPicture(list.get(i).getHpicture()); |
| | | array.add(StringUtil.outPutResultJson(list.get(i))); |
| | | } |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | private String getDurationDesc(String duration) { |
| | | if (StringUtil.isNullOrEmpty(duration)) |
| | | return ""; |
| | | try { |
| | | int d = Integer.parseInt(duration); |
| | | if (d < 3600) { |
| | | int m = d / 60; |
| | | int s = d % 60; |
| | | return (m < 10 ? "0" + m : m + "") + ":" + (s < 10 ? "0" + s : s + ""); |
| | | |
| | | } else { |
| | | int h = d / 3600; |
| | | int m = (d % 3600) / 60; |
| | | int s = d % 60; |
| | | return (h < 10 ? "0" + h : h + "") + ":" + (m < 10 ? "0" + m : m + "") + ":" |
| | | + (s < 10 ? "0" + s : s + ""); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | } |
| | | return duration; |
| | | } |
| | | |
| | | } |