|
@@ -39,6 +39,7 @@ public class BytedanceAccountReportCtrl {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询素材报表chart数据
|
|
* 查询素材报表chart数据
|
|
|
|
+ *
|
|
* @param requestBody
|
|
* @param requestBody
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -49,31 +50,33 @@ public class BytedanceAccountReportCtrl {
|
|
if (requestBody.isEmpty()) {
|
|
if (requestBody.isEmpty()) {
|
|
log.error("request body is empty");
|
|
log.error("request body is empty");
|
|
resultBody.setSuccess(false);
|
|
resultBody.setSuccess(false);
|
|
- }
|
|
|
|
- String mediaId = requestBody.getString("mediaId");
|
|
|
|
- BigDecimal discount = requestBody.getBigDecimal("discount");
|
|
|
|
- JSONArray accounts = requestBody.getJSONArray("accountIds");
|
|
|
|
- if(accounts.isEmpty()){
|
|
|
|
- return resultBody;
|
|
|
|
- }
|
|
|
|
- String startDate = requestBody.getString("startDate");
|
|
|
|
- String endDate = requestBody.getString("endDate");
|
|
|
|
- try {
|
|
|
|
- Map<String, Object> sumData = bytedanceAccountReportService.getSumDataBy(mediaId, discount, accounts, startDate, endDate);
|
|
|
|
- List<JSONObject> chartData = bytedanceAccountReportService.getChartDataBy(mediaId, discount, accounts, startDate, endDate);
|
|
|
|
- result.put("sumData",sumData);
|
|
|
|
- result.put("chartData",chartData);
|
|
|
|
- resultBody.setResult(result);
|
|
|
|
- resultBody.setSuccess(true);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error(e.getMessage(), e);
|
|
|
|
- resultBody.setSuccess(false);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ String mediaId = requestBody.getString("mediaId");
|
|
|
|
+ BigDecimal discount = requestBody.getBigDecimal("discount");
|
|
|
|
+ JSONArray accounts = requestBody.getJSONArray("accountIds");
|
|
|
|
+ if (accounts.isEmpty()) {
|
|
|
|
+ return resultBody;
|
|
|
|
+ }
|
|
|
|
+ String startDate = requestBody.getString("startDate");
|
|
|
|
+ String endDate = requestBody.getString("endDate");
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> sumData = bytedanceAccountReportService.getSumDataBy(mediaId, discount, accounts, startDate, endDate);
|
|
|
|
+ List<JSONObject> chartData = bytedanceAccountReportService.getChartDataBy(mediaId, discount, accounts, startDate, endDate);
|
|
|
|
+ result.put("sumData", sumData);
|
|
|
|
+ result.put("chartData", chartData);
|
|
|
|
+ resultBody.setResult(result);
|
|
|
|
+ resultBody.setSuccess(true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ resultBody.setSuccess(false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return resultBody;
|
|
return resultBody;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询素材报表表格数据
|
|
* 查询素材报表表格数据
|
|
|
|
+ *
|
|
* @param requestBody
|
|
* @param requestBody
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -87,16 +90,16 @@ public class BytedanceAccountReportCtrl {
|
|
String mediaId = requestBody.getString("mediaId");
|
|
String mediaId = requestBody.getString("mediaId");
|
|
BigDecimal discount = requestBody.getBigDecimal("discount");
|
|
BigDecimal discount = requestBody.getBigDecimal("discount");
|
|
JSONArray accounts = requestBody.getJSONArray("accountIds");
|
|
JSONArray accounts = requestBody.getJSONArray("accountIds");
|
|
- if(accounts.isEmpty()){
|
|
|
|
|
|
+ if (accounts.isEmpty()) {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
String startDate = requestBody.getString("startDate");
|
|
String startDate = requestBody.getString("startDate");
|
|
String endDate = requestBody.getString("endDate");
|
|
String endDate = requestBody.getString("endDate");
|
|
- int hour= requestBody.getInteger("hour");
|
|
|
|
- String target= requestBody.getString("target");
|
|
|
|
- String order= requestBody.getString("order");
|
|
|
|
|
|
+ int hour = requestBody.getInteger("hour");
|
|
|
|
+ String target = requestBody.getString("target");
|
|
|
|
+ String order = requestBody.getString("order");
|
|
try {
|
|
try {
|
|
- List<JSONObject> listData= bytedanceAccountReportService.getListDataBy(mediaId,discount,accounts,startDate,endDate,hour,target,order);
|
|
|
|
|
|
+ List<JSONObject> listData = bytedanceAccountReportService.getListDataBy(mediaId, discount, accounts, startDate, endDate, hour, target, order);
|
|
result.setResult(listData);
|
|
result.setResult(listData);
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -107,7 +110,8 @@ public class BytedanceAccountReportCtrl {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 导出数据
|
|
|
|
|
|
+ * 导出数据
|
|
|
|
+ *
|
|
* @param requestBody
|
|
* @param requestBody
|
|
* @param request
|
|
* @param request
|
|
* @param response
|
|
* @param response
|
|
@@ -116,41 +120,41 @@ public class BytedanceAccountReportCtrl {
|
|
public void getExcelReport(@RequestBody JSONObject requestBody,
|
|
public void getExcelReport(@RequestBody JSONObject requestBody,
|
|
HttpServletRequest request,
|
|
HttpServletRequest request,
|
|
HttpServletResponse response) {
|
|
HttpServletResponse response) {
|
|
- JSONArray columns=requestBody.getJSONArray("columns");
|
|
|
|
- if(columns.isEmpty()){
|
|
|
|
|
|
+ JSONArray columns = requestBody.getJSONArray("columns");
|
|
|
|
+ if (columns.isEmpty()) {
|
|
log.error("请选择需要导出的字段");
|
|
log.error("请选择需要导出的字段");
|
|
}
|
|
}
|
|
- String filed= JsonResourceUtil.joinFiled(AccountReportConstants.dicMapBy,columns);
|
|
|
|
- List<String> titles= new ArrayList<>();
|
|
|
|
|
|
+ String filed = JsonResourceUtil.joinFiled(AccountReportConstants.dicMapBy, columns);
|
|
|
|
+ List<String> titles = new ArrayList<>();
|
|
titles.add("账户Id");
|
|
titles.add("账户Id");
|
|
titles.add("账户名称");
|
|
titles.add("账户名称");
|
|
- titles.addAll(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapBy,columns));
|
|
|
|
|
|
+ titles.addAll(JsonResourceUtil.joinTitle(AccountReportConstants.dicMapBy, columns));
|
|
//此处增加两个元素是为了保证数据有序
|
|
//此处增加两个元素是为了保证数据有序
|
|
- columns.add(0,"accountId");
|
|
|
|
- columns.add(1,"authName");
|
|
|
|
|
|
+ columns.add(0, "accountId");
|
|
|
|
+ columns.add(1, "authName");
|
|
String mediaId = requestBody.getString("mediaId");
|
|
String mediaId = requestBody.getString("mediaId");
|
|
JSONArray accounts = requestBody.getJSONArray("accountIds");
|
|
JSONArray accounts = requestBody.getJSONArray("accountIds");
|
|
- if(accounts.isEmpty()){
|
|
|
|
|
|
+ if (accounts.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
String startDate = requestBody.getString("startDate");
|
|
String startDate = requestBody.getString("startDate");
|
|
String endDate = requestBody.getString("endDate");
|
|
String endDate = requestBody.getString("endDate");
|
|
- String target= requestBody.getString("target");
|
|
|
|
- String order= requestBody.getString("order");
|
|
|
|
- int hour= requestBody.getInteger("hour");
|
|
|
|
- List<JSONObject> excelData= bytedanceAccountReportService.getExcelDataBy(filed,mediaId,accounts,startDate,endDate,hour,target,order);
|
|
|
|
- if(excelData.isEmpty()){
|
|
|
|
|
|
+ String target = requestBody.getString("target");
|
|
|
|
+ String order = requestBody.getString("order");
|
|
|
|
+ int hour = requestBody.getInteger("hour");
|
|
|
|
+ List<JSONObject> excelData = bytedanceAccountReportService.getExcelDataBy(filed, mediaId, accounts, startDate, endDate, hour, target, order);
|
|
|
|
+ if (excelData.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- List<List<Object>> excelList= new ArrayList<>();
|
|
|
|
- excelData.forEach(data->{
|
|
|
|
- List<Object> temp= new ArrayList<>();
|
|
|
|
- columns.forEach(k->{
|
|
|
|
|
|
+ List<List<Object>> excelList = new ArrayList<>();
|
|
|
|
+ excelData.forEach(data -> {
|
|
|
|
+ List<Object> temp = new ArrayList<>();
|
|
|
|
+ columns.forEach(k -> {
|
|
temp.add(data.get(k.toString()));
|
|
temp.add(data.get(k.toString()));
|
|
});
|
|
});
|
|
excelList.add(temp);
|
|
excelList.add(temp);
|
|
});
|
|
});
|
|
- try{
|
|
|
|
|
|
+ try {
|
|
String[] headers = titles.toArray(new String[titles.size()]);
|
|
String[] headers = titles.toArray(new String[titles.size()]);
|
|
OutputStream os = response.getOutputStream();
|
|
OutputStream os = response.getOutputStream();
|
|
ExportExcelUtils eeu = new ExportExcelUtils();
|
|
ExportExcelUtils eeu = new ExportExcelUtils();
|
|
@@ -160,7 +164,7 @@ public class BytedanceAccountReportCtrl {
|
|
workbook.write(os);
|
|
workbook.write(os);
|
|
os.flush();
|
|
os.flush();
|
|
os.close();
|
|
os.close();
|
|
- }catch (IOException e){
|
|
|
|
|
|
+ } catch (IOException e) {
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|