|
@@ -1,5 +1,6 @@
|
|
package cn.com.ctop.kuaishou.modules.report.controller;
|
|
package cn.com.ctop.kuaishou.modules.report.controller;
|
|
|
|
|
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKsVideoReportService;
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKsVideoReportService;
|
|
@@ -22,7 +23,9 @@ import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by JQ.bi on 2020.09.27
|
|
* Created by JQ.bi on 2020.09.27
|
|
@@ -37,9 +40,72 @@ public class KsVideoReportCtrl {
|
|
|
|
|
|
@PostMapping("/list")
|
|
@PostMapping("/list")
|
|
public Result<PageInfo<JSONObject>> getListReport(@RequestBody JSONObject requestBody) {
|
|
public Result<PageInfo<JSONObject>> getListReport(@RequestBody JSONObject requestBody) {
|
|
-
|
|
|
|
Result<PageInfo<JSONObject>> result = new Result<>();
|
|
Result<PageInfo<JSONObject>> result = new Result<>();
|
|
- if (requestBody.isEmpty()) {
|
|
|
|
|
|
+ try {
|
|
|
|
+ if (Check.isNull(requestBody)) {
|
|
|
|
+ throw new Exception("入参不能为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int pageSize = requestBody.getInteger("pageSize");
|
|
|
|
+ if (Check.isNull(pageSize)) {
|
|
|
|
+ throw new Exception("请输入查询每页条数");
|
|
|
|
+ }
|
|
|
|
+ int pageNo = requestBody.getInteger("pageNo");
|
|
|
|
+ if (Check.isNull(pageNo)) {
|
|
|
|
+ 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.dicMapKs);
|
|
|
|
+ if (Check.isNull(filedAll)) {
|
|
|
|
+ throw new Exception("初始化查询 字段返回为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
|
+ 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"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ PageInfo<JSONObject> listData = ksVideoReportService.getKuaiShouVideoReportByMap(requestMap, pageSize, pageNo);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /* if (requestBody.isEmpty()) {
|
|
log.error("request body is empty");
|
|
log.error("request body is empty");
|
|
result.setSuccess(false);
|
|
result.setSuccess(false);
|
|
} else {
|
|
} else {
|
|
@@ -57,17 +123,17 @@ public class KsVideoReportCtrl {
|
|
String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapKs);
|
|
String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapKs);
|
|
|
|
|
|
try {
|
|
try {
|
|
- if(accountIds.isEmpty()){
|
|
|
|
- accountIds=null;
|
|
|
|
|
|
+ if (accountIds.isEmpty()) {
|
|
|
|
+ accountIds = null;
|
|
}
|
|
}
|
|
- PageInfo<JSONObject> listData = ksVideoReportService.getVideoReportBy(accountIds, startDate, endDate, filedAll, target, order, clip, shot,plan,pageSize, pageNo);
|
|
|
|
|
|
+ PageInfo<JSONObject> listData = ksVideoReportService.getVideoReportBy(accountIds, startDate, endDate, filedAll, target, order, clip, shot, plan, pageSize, pageNo);
|
|
result.setResult(listData);
|
|
result.setResult(listData);
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage(), e);
|
|
log.error(e.getMessage(), e);
|
|
result.setSuccess(false);
|
|
result.setSuccess(false);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -90,7 +156,7 @@ public class KsVideoReportCtrl {
|
|
if (accountIds.isEmpty()) {
|
|
if (accountIds.isEmpty()) {
|
|
accountIds = null;
|
|
accountIds = null;
|
|
}
|
|
}
|
|
- List<JSONObject> listData = ksVideoReportService.getVideoDetailBy(accountIds, startDate, endDate, filedAll,signature);
|
|
|
|
|
|
+ List<JSONObject> listData = ksVideoReportService.getVideoDetailBy(accountIds, startDate, endDate, filedAll, signature);
|
|
result.setResult(listData);
|
|
result.setResult(listData);
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -106,8 +172,8 @@ public class KsVideoReportCtrl {
|
|
HttpServletRequest request,
|
|
HttpServletRequest request,
|
|
HttpServletResponse response) {
|
|
HttpServletResponse response) {
|
|
//加一个参数区分是table页,还是详情页。
|
|
//加一个参数区分是table页,还是详情页。
|
|
- String exportType= requestBody.getString("exportType");
|
|
|
|
- if(exportType.isEmpty()){
|
|
|
|
|
|
+ String exportType = requestBody.getString("exportType");
|
|
|
|
+ if (exportType.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
JSONArray columns = requestBody.getJSONArray("columns");
|
|
JSONArray columns = requestBody.getJSONArray("columns");
|
|
@@ -118,20 +184,20 @@ public class KsVideoReportCtrl {
|
|
String filed = JsonResourceUtil.joinFiled(AccountReportConstants.dicMapKs, columns);
|
|
String filed = JsonResourceUtil.joinFiled(AccountReportConstants.dicMapKs, columns);
|
|
List<String> titles = new ArrayList<>(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapKs, columns));
|
|
List<String> titles = new ArrayList<>(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapKs, columns));
|
|
//此处增加两个元素是为了保证数据顺序
|
|
//此处增加两个元素是为了保证数据顺序
|
|
- if("exportDetail".equals(exportType)){
|
|
|
|
- titles.add(0,"客户");
|
|
|
|
- titles.add(1,"项目名称");
|
|
|
|
- titles.add(2,"时间");
|
|
|
|
- titles.add(3,"消耗");
|
|
|
|
|
|
+ if ("exportDetail".equals(exportType)) {
|
|
|
|
+ titles.add(0, "客户");
|
|
|
|
+ titles.add(1, "项目名称");
|
|
|
|
+ titles.add(2, "时间");
|
|
|
|
+ titles.add(3, "消耗");
|
|
columns.add(0, "advertiserName");
|
|
columns.add(0, "advertiserName");
|
|
columns.add(1, "projectName");
|
|
columns.add(1, "projectName");
|
|
columns.add(2, "statDate");
|
|
columns.add(2, "statDate");
|
|
- }else{
|
|
|
|
- titles.add(0,"唯一标识");
|
|
|
|
- titles.add(1,"视频");
|
|
|
|
- titles.add(2,"视频名称");
|
|
|
|
- titles.add(3,"项目名称");
|
|
|
|
- titles.add(4,"上传时间");
|
|
|
|
|
|
+ } else {
|
|
|
|
+ titles.add(0, "唯一标识");
|
|
|
|
+ titles.add(1, "视频");
|
|
|
|
+ titles.add(2, "视频名称");
|
|
|
|
+ titles.add(3, "项目名称");
|
|
|
|
+ titles.add(4, "上传时间");
|
|
titles.addAll(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapKs, columns));
|
|
titles.addAll(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapKs, columns));
|
|
columns.add(0, "signature");
|
|
columns.add(0, "signature");
|
|
columns.add(1, "url");
|
|
columns.add(1, "url");
|
|
@@ -152,13 +218,13 @@ public class KsVideoReportCtrl {
|
|
String plan = requestBody.getString("plan");
|
|
String plan = requestBody.getString("plan");
|
|
String target = requestBody.getString("target");
|
|
String target = requestBody.getString("target");
|
|
String order = requestBody.getString("order");
|
|
String order = requestBody.getString("order");
|
|
- List<JSONObject> excelData=null;
|
|
|
|
- if("exportTable".equals(exportType)){
|
|
|
|
- excelData = ksVideoReportService.exportExcelReportBy(accountIds, startDate, endDate, filed, target, order,clip,shot,plan);
|
|
|
|
- }else if("exportDetail".equals(exportType)){
|
|
|
|
- excelData = ksVideoReportService.getVideoDetailBy(accountIds,startDate,endDate,filed,signature);
|
|
|
|
|
|
+ List<JSONObject> excelData = null;
|
|
|
|
+ if ("exportTable".equals(exportType)) {
|
|
|
|
+ excelData = ksVideoReportService.exportExcelReportBy(accountIds, startDate, endDate, filed, target, order, clip, shot, plan);
|
|
|
|
+ } else if ("exportDetail".equals(exportType)) {
|
|
|
|
+ excelData = ksVideoReportService.getVideoDetailBy(accountIds, startDate, endDate, filed, signature);
|
|
}
|
|
}
|
|
- if (null!=excelData&&excelData.isEmpty()) {
|
|
|
|
|
|
+ if (null != excelData && excelData.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
List<List<Object>> excelList = new ArrayList<>();
|
|
List<List<Object>> excelList = new ArrayList<>();
|