123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- package com.ylcm.sys.controller;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.alibaba.fastjson.JSONObject;
- import com.ylcm.sys.common.ExcelUtil;
- import com.ylcm.sys.common.Util;
- import com.ylcm.sys.domain.AdTv;
- import com.ylcm.sys.excel.model.SpecialAnalysisExportDTO;
- import com.ylcm.sys.service.AdTvService;
- import com.ylcm.sys.vo.*;
- import org.apache.commons.collections.CollectionUtils;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.ylcm.sys.common.Constants;
- import com.ylcm.sys.form.AdTheatreAnalysisDetailQueryForm;
- import com.ylcm.sys.form.AdTheatreAnalysisQueryForm;
- import com.ylcm.sys.service.AdTheatreTvStatService;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.RequestParam;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.stream.Collectors;
- @Slf4j
- @Controller
- @RequestMapping("/theatre_analysis")
- public class TheatreAnalysisController extends BaseController{
- @Resource
- private AdTheatreTvStatService adTheatreTvStatService;
- @Resource
- private AdTvService adTvService;
-
- /**
- * @param keyword 电视剧名称
- * @return
- */
- @RequestMapping(value = "/index.do")
- public String brandAnalysis(ModelMap model,String keyword) {
- /**
- * 1.跳转到列表页面
- */
- model.put("keyword", keyword);
- return "analysis/theatre_analysis";
- }
-
- @RequestMapping(value = "/ajax_list.do")
- public void ajaxSearchList(HttpServletResponse response, AdTheatreAnalysisQueryForm queryForm) {
- try {
-
- IPage<AdTheatreAnalysisVO> page = adTheatreTvStatService.getPage(queryForm);
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", page);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- @RequestMapping(value = "/export_list.do")
- public void exportSearchList(HttpServletResponse response, AdTheatreAnalysisQueryForm queryForm) {
- ExcelUtil.exportExcelToWebsite(response,"央卫视电视剧收视指标",new AdTheatreAnalysisVO(),(currentPage, pageSize) -> {
- queryForm.setPageNo(currentPage);
- queryForm.setPageSize(pageSize);
- return adTheatreTvStatService.getPage(queryForm).getRecords();
- });
- }
- /**
- * 央卫视电视剧收视明细
- * @param response
- * @param queryForm
- */
- @RequestMapping(value = "/ajax_detail_list.do")
- public void ajaxDetailList(HttpServletResponse response, AdTheatreAnalysisDetailQueryForm queryForm) {
- try {
-
- IPage<AdTheatreAnalysisDetailVO> page = adTheatreTvStatService.getDetailPage(queryForm);
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", page);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- @RequestMapping(value = "/export_detail_list.do")
- public void exportDetailList(HttpServletResponse response, AdTheatreAnalysisDetailQueryForm queryForm) {
- ExcelUtil.exportExcelToWebsite(response,"央卫视电视剧收视明细",new AdTheatreAnalysisDetailVO(),(currentPage, pageSize) -> {
- queryForm.setPageNo(currentPage);
- queryForm.setPageSize(pageSize);
- return adTheatreTvStatService.getDetailPage(queryForm).getRecords();
- });
- }
- /**
- * 山东卫视电视剧收视分析
- */
- @RequestMapping(value = "/ajax_tv_ratio.do")
- public void tvRatio(HttpServletResponse response, AdTheatreAnalysisDetailQueryForm queryForm) {
- try {
- AdTvRatioVO adTvRatioVO = adTheatreTvStatService.getTvRatioVO(queryForm);
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", adTvRatioVO);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- /**
- * 电视剧收视区域分布
- */
- @RequestMapping(value = "/ajax_tv_zone.do")
- public void tvZone(HttpServletResponse response, AdTheatreAnalysisDetailQueryForm queryForm) {
- try {
- AdTvZoneVO adTvZoneVO = adTheatreTvStatService.getTvZoneVO(queryForm);
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", adTvZoneVO);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- /**
- * 电视剧产品投放分析
- */
- @RequestMapping(value = "/ajax_tv_product.do")
- public void tvProduct(HttpServletResponse response, AdTheatreAnalysisDetailQueryForm queryForm) {
- try {
- List<AdTheatreProductDistVO> productVO = adTheatreTvStatService.getProductVO(queryForm);
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", productVO);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- /**
- * 电视剧体裁结构分析
- */
- @RequestMapping(value = "/ajax_tv_theme.do")
- public void tvTheme(HttpServletResponse response, AdTheatreAnalysisDetailQueryForm queryForm) {
- try {
- List<AdThemeDistVO> themeVOs = adTheatreTvStatService.getThemeDistVO(queryForm);
- if (CollectionUtils.isNotEmpty(themeVOs)) {
- float ratio = 0.0f;
- for (AdThemeDistVO adThemeDistVO:themeVOs) {
- ratio += adThemeDistVO.getRatio();
- }
- ratio = Util.newScale(ratio/themeVOs.size(), 3);
- themeVOs.add(new AdThemeDistVO("平均",0,ratio));
- }
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", themeVOs);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- /**
- * 剧场电视剧收视率排名
- * @param response
- * @param startDate
- * @param endDate
- */
- @RequestMapping(value = "/ajax_tvTop_list.do")
- public void ajaxTvTopList(HttpServletResponse response, Integer theatreTime, String startDate, String endDate) {
- try {
- List<AdTheatreTopVO> list = adTheatreTvStatService.getTvTop(theatreTime, startDate, endDate);
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", list);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- /**
- * 卫视剧场排名
- * @param name 剧名
- * @param theatreTime 剧场:0日间 1黄金2午夜3凌晨
- * @param startDate 播放时间
- * @param endDate 播放时间
- */
- @RequestMapping(value = "/ajax_mediaTop_list.do")
- public void ajaxMediaTopList(HttpServletResponse response, String name, Integer theatreTime, String startDate, String endDate, Integer limitSize) {
- try {
- limitSize = (limitSize == null ? 30 : limitSize);
- List<AdTheatreTopVO> list = adTheatreTvStatService.getMediaTop(name, theatreTime, startDate, endDate, limitSize);
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", list);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- @RequestMapping(value = "/ajax_topList.do")
- public void ajaxTopList(HttpServletResponse response, Integer theatreTime, String startDate, String endDate) {
- try {
- List<AdTheatreTopVO> tvList = adTheatreTvStatService.getTvTop(theatreTime, startDate, endDate);
- List<AdTheatreTopVO> mediaList = adTheatreTvStatService.getMediaTop(null, theatreTime, startDate, endDate, null);
- JSONObject listJson = new JSONObject();
- listJson.put("tv", tvList);
- listJson.put("media", mediaList);
- /**
- * 3.返回结果
- */
- JSONObject jsonobj = new JSONObject();
- jsonobj.put("data", listJson);
- jsonobj.put("code", Constants.CODE_SUCCESS);
- ajaxJson(jsonobj.toString(), response);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- ajaxJson("{\"code\":\"0\",\"msg\":\"获取列表失败\"}", response);
- }
- }
- /**
- * to 对标页
- * @param ids 对标的剧id
- * @param startDate 日期范围
- * @param endDate 日期范围
- * @param day 日期范围的天数
- */
- @RequestMapping(value = "/benchmarking.do")
- public String benchmarking(@RequestParam String ids, String startDate, String endDate, Integer day, HttpServletRequest request){
- request.setAttribute("ids", ids);
- request.setAttribute("startDate", startDate);
- request.setAttribute("endDate", endDate);
- request.setAttribute("day", day);
- // 参数转型
- List<Integer> idList = Arrays.stream(ids.split(",")).map(s -> Integer.parseInt(s.trim()))
- .collect(Collectors.toList());
- // 获取剧列表
- List<AdTv> tvList = adTvService.getListByIds(idList);
- request.setAttribute("tvList", tvList);
- return "analysis/tv_benchmarking";
- }
- @RequestMapping(value = "/add_benchmarking_tv.do")
- public String addTv(ModelMap model, String ids, String startDate, String endDate, Integer day) {
- model.put("ids", ids);
- model.put("startDate", startDate);
- model.put("endDate", endDate);
- model.put("day", day);
- return "analysis/benchmark_tv_choose";
- }
- }
|