|
@@ -1,21 +1,24 @@
|
|
|
package cn.com.ctop.kuaishou.modules.report.controller;
|
|
|
|
|
|
-import cn.com.ctop.common.module.utils.Check;
|
|
|
-import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
-import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
-import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
+import cn.com.ctop.common.module.utils.*;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IDuanJUReportService;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -93,14 +96,78 @@ public class DuanJUReportController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/getViodeoList")
|
|
|
- public Result<Object> getViodeoList(String startDate, String endDate) {
|
|
|
+ public Result<Object> getViodeoList(String startDate, String endDate, String videoName) {
|
|
|
try {
|
|
|
Long start = DateUtils.dateToLong(startDate);
|
|
|
Long end = DateUtils.dateToLong(endDate);
|
|
|
Map<String, Object> requestMap = new HashMap<>();
|
|
|
requestMap.put("start", start);
|
|
|
requestMap.put("end", end);
|
|
|
+ if (!Check.isNull(videoName)) {
|
|
|
+ requestMap.put("videoName", videoName);
|
|
|
+ }
|
|
|
+ List<JSONObject> data = duanJUReportService.getViodeoList(requestMap);
|
|
|
+ return Result.OK(data);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Result.error("查询失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/exportVideoList")
|
|
|
+ public Result<Object> exportVideoList(String startDate, String endDate, String videoName,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ Long start = DateUtils.dateToLong(startDate);
|
|
|
+ Long end = DateUtils.dateToLong(endDate);
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ requestMap.put("start", start);
|
|
|
+ requestMap.put("end", end);
|
|
|
+ if (!Check.isNull(videoName)) {
|
|
|
+ requestMap.put("videoName", videoName);
|
|
|
+ }
|
|
|
List<JSONObject> data = duanJUReportService.getViodeoList(requestMap);
|
|
|
+ List<List<Object>> exportList = new ArrayList<>();
|
|
|
+ if (!Check.isNull(data)) {
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ JSONObject date = data.get(i);
|
|
|
+ List<Object> export = new ArrayList();
|
|
|
+ export.add(date.getString("photo_id"));
|
|
|
+ export.add(date.getString("photo_name"));
|
|
|
+ export.add(date.getString("cover_url"));
|
|
|
+ export.add(date.getString("photo_url"));
|
|
|
+ export.add(date.getString("charge"));
|
|
|
+ export.add(date.getString("roi"));
|
|
|
+ export.add(date.getString("event_pay_purchase_amount"));
|
|
|
+ export.add(date.getString("aclick"));
|
|
|
+ export.add(date.getString("bclick"));
|
|
|
+ export.add(date.getString("ctr"));
|
|
|
+ export.add(date.getString("cpc"));
|
|
|
+ export.add(date.getString("cpm"));
|
|
|
+ export.add(date.getString("activation"));
|
|
|
+ export.add(date.getString("active_cost"));
|
|
|
+ export.add(date.getString("event_pay"));
|
|
|
+ export.add(date.getString("pay_cost"));
|
|
|
+ export.add(date.getString("event_new_user_pay"));
|
|
|
+ export.add(date.getString("new_pay_cost"));
|
|
|
+ export.add(date.getString("play_3s_rate"));
|
|
|
+ export.add(date.getString("play_5s_rate"));
|
|
|
+ export.add(date.getString("play_end_rate"));
|
|
|
+ exportList.add(export);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String[] headers = new String[]{"素材ID", "素材名称", "封面", "素材链接", "消耗", "ROI", "付费金额", "曝光", "点击", "ctr", "cpc", "cpm", "激活", "激活成本", "付费次数", "付费成本", "新增付费人数", "新增付费单价", "3s播放率", "5s播放率", "完播率"};
|
|
|
+
|
|
|
+
|
|
|
+ OutputStream os = response.getOutputStream();
|
|
|
+ ExportExcelUtils eeu = new ExportExcelUtils();
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
+ eeu.exportExcel(workbook, 0, "短剧报表", headers, exportList);
|
|
|
+ this.setResponseHeader(response, "短剧报表.xls");
|
|
|
+ workbook.write(os);
|
|
|
+ os.flush();
|
|
|
+ os.close();
|
|
|
+
|
|
|
return Result.OK(data);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -109,6 +176,22 @@ public class DuanJUReportController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void setResponseHeader(HttpServletResponse response, String fileName) {
|
|
|
+ try {
|
|
|
+ try {
|
|
|
+ fileName = new String(fileName.getBytes(), "ISO8859-1");
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ response.setContentType("application/octet-stream;charset=ISO8859-1");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
|
|
|
+ response.addHeader("Pargam", "no-cache");
|
|
|
+ response.addHeader("Cache-Control", "no-cache");
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/stopPlan")
|
|
|
public Result<Object> stopPlan(Long accountId) {
|
|
|
try {
|