|
@@ -108,7 +108,8 @@ public class KsVideoReportCtrl {
|
|
if (!Check.isNull(requestBody.getString("order"))) {
|
|
if (!Check.isNull(requestBody.getString("order"))) {
|
|
requestMap.put("order", requestBody.getString("order"));
|
|
requestMap.put("order", requestBody.getString("order"));
|
|
}
|
|
}
|
|
- PageInfo<JSONObject> listData = ksVideoReportService.getKuaiShouVideoReportByMap(requestMap, pageSize, pageNo);
|
|
|
|
|
|
+ PageInfo<JSONObject> listData = ksVideoReportService.getKuaiShouVideoPageReportByMap(requestMap, pageSize, pageNo);
|
|
|
|
+ System.err.println(listData);
|
|
if (Check.isNull(listData)) {
|
|
if (Check.isNull(listData)) {
|
|
throw new Exception("暂无素材相关信息,请检查账户");
|
|
throw new Exception("暂无素材相关信息,请检查账户");
|
|
}
|
|
}
|
|
@@ -266,4 +267,138 @@ public class KsVideoReportCtrl {
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping("/excelV2")
|
|
|
|
+ public void excelV2(@RequestBody JSONObject requestBody,
|
|
|
|
+ HttpServletRequest request,
|
|
|
|
+ HttpServletResponse response) {
|
|
|
|
+ Result<PageInfo<JSONObject>> result = new Result<>();
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (Check.isNull(requestBody)) {
|
|
|
|
+ throw new Exception("入参不能为空");
|
|
|
|
+ }
|
|
|
|
+ JSONArray columns = requestBody.getJSONArray("columns");
|
|
|
|
+ if (Check.isNull(columns)) {
|
|
|
|
+ throw new Exception("请传入表头");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String startDate = requestBody.getString("startDate");
|
|
|
|
+ if (Check.isNull(startDate)) {
|
|
|
|
+ throw new Exception("请输入查询开始时间");
|
|
|
|
+ }
|
|
|
|
+ String endDate = requestBody.getString("endDate");
|
|
|
|
+ if (Check.isNull(endDate)) {
|
|
|
|
+ throw new Exception("请输入查询结束时间");
|
|
|
|
+ }
|
|
|
|
+ String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.kuaishouVideoReportMap);
|
|
|
|
+ // System.err.println(filedAll);
|
|
|
|
+ if (Check.isNull(filedAll)) {
|
|
|
|
+ throw new Exception("初始化查询 字段返回为空");
|
|
|
|
+ }
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ requestMap.put("filed", filedAll);
|
|
|
|
+ requestMap.put("startDate", startDate);
|
|
|
|
+ requestMap.put("endDate", endDate);
|
|
|
|
+ if (!Check.isNull(requestBody.getJSONArray("accountIds"))) {
|
|
|
|
+ requestMap.put("accountIds", requestBody.getJSONArray("accountIds"));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(requestBody.getString("clipId"))) {
|
|
|
|
+ requestMap.put("clipId", requestBody.getString("clipId"));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(requestBody.getString("shotId"))) {
|
|
|
|
+ requestMap.put("shotId", requestBody.getString("shotId"));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(requestBody.getString("planId"))) {
|
|
|
|
+ requestMap.put("planId", requestBody.getString("planId"));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(requestBody.getString("leaderId"))) {
|
|
|
|
+ requestMap.put("leaderId", requestBody.getString("leaderId"));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(requestBody.getString("target"))) {
|
|
|
|
+ requestMap.put("target", requestBody.getString("target"));
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(requestBody.getString("order"))) {
|
|
|
|
+ requestMap.put("order", requestBody.getString("order"));
|
|
|
|
+ }
|
|
|
|
+ List<JSONObject> listData = ksVideoReportService.getKuaiShouVideoReportByMap(requestMap);
|
|
|
|
+ if (Check.isNull(listData)) {
|
|
|
|
+ throw new Exception("暂无素材相关信息,请检查账户");
|
|
|
|
+ }
|
|
|
|
+ columns.add(0, "materialName");
|
|
|
|
+ columns.add(1, "channel");
|
|
|
|
+ columns.add(2, "designLeader");
|
|
|
|
+ columns.add(4, "clip");
|
|
|
|
+ columns.add(4, "plan");
|
|
|
|
+ columns.add(5, "shot");
|
|
|
|
+ columns.add(columns.size(), "url");
|
|
|
|
+
|
|
|
|
+ List<String> titles = new ArrayList<>();
|
|
|
|
+ titles.add(0, "素材名称");
|
|
|
|
+ titles.add(1, "渠道");
|
|
|
|
+ titles.add(2, "设计负责人");
|
|
|
|
+ titles.add(3, "剪辑");
|
|
|
|
+ titles.add(4, "编导");
|
|
|
|
+ titles.add(5, "拍摄");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // ArrayList<String> fileIds = JsonResourceUtil.joinTitle(AccountReportConstants.kuaishouVideoReportMap, columns);
|
|
|
|
+ titles = getfileIds(AccountReportConstants.kuaishouVideoReportMap, columns, titles);
|
|
|
|
+ titles.add(columns.size(), "素材链接");
|
|
|
|
+ List<List<Object>> excelList = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < listData.size(); i++) {
|
|
|
|
+ List<Object> temp = new ArrayList<>();
|
|
|
|
+ JSONObject jsonObject = listData.get(i);
|
|
|
|
+ for (int j = 0; j < columns.size(); j++) {
|
|
|
|
+ String key = columns.getString(j);
|
|
|
|
+ String value = jsonObject.getString(key);
|
|
|
|
+ temp.add(value);
|
|
|
|
+ }
|
|
|
|
+ excelList.add(temp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ // String[] headers = {"视频", "视频md5", "花费", "安卓下载完成数", "封面曝光数", "封面点击数", "素材曝光数", "行为数", "封面点击率", "行为率", "均千次封面曝光花费(元)", "平均封面点击单价(元)", "平均行为单价(元)", "转化数", "转化单价(元)"};
|
|
|
|
+ String[] strings = titles.toArray(new String[]{});
|
|
|
|
+ OutputStream os = response.getOutputStream();
|
|
|
|
+ ExportExcelUtils eeu = new ExportExcelUtils();
|
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
|
+ eeu.exportExcel(workbook, 0, "快手素材报表", strings, excelList);
|
|
|
|
+ HttpUtils.setResponseHeader(response, "快手素材.xlsx");
|
|
|
|
+ workbook.write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ os.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<String> getfileIds(Map<String, Map<String, Object>> kuaishouVideoReportMap, JSONArray columns, List<String> titles) {
|
|
|
|
+ for (int i = 0; i < columns.size(); i++) {
|
|
|
|
+ String string = columns.getString(i);
|
|
|
|
+ Map<String, Object> stringObjectMap = kuaishouVideoReportMap.get(string);
|
|
|
|
+ if (Check.isNull(stringObjectMap)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Object comment = stringObjectMap.get("comment");
|
|
|
|
+ titles.add(String.valueOf(comment));
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return titles;
|
|
|
|
+ }
|
|
}
|
|
}
|