|
@@ -3,16 +3,27 @@ package cn.com.ctop.kuaishou.modules.report.controller;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IMaterialReportService;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.constant.AccountReportConstants;
|
|
|
+import org.jeecg.common.util.JsonResourceUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
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.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
@@ -76,7 +87,6 @@ public class MaterialReportController {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@PostMapping(value = "/getMaterialReportByAccount")
|
|
|
public Result<List<JSONObject>> getMaterialReportByAccount(@RequestBody JSONObject json) {
|
|
|
Result<List<JSONObject>> result = new Result<>();
|
|
@@ -87,9 +97,52 @@ public class MaterialReportController {
|
|
|
} catch (Exception e) {
|
|
|
result.setSuccess(false);
|
|
|
}
|
|
|
-
|
|
|
return result;
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 导出数据
|
|
|
+ */
|
|
|
+ @PostMapping("/materialReport/excel")
|
|
|
+ public void getExcelReport(@RequestBody JSONObject requestBody,
|
|
|
+ HttpServletRequest request,
|
|
|
+ HttpServletResponse response) {
|
|
|
+
|
|
|
+ List<JSONObject> excelData = materialReportService.selectReportByAccountIds(requestBody);
|
|
|
+ if(excelData.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<List<Object>> excelList= new ArrayList<>();
|
|
|
+ excelData.forEach(data->{
|
|
|
+ List<Object> temp= new ArrayList<>();
|
|
|
+ temp.add(data.getString("url"));
|
|
|
+ temp.add(data.getString("signature"));
|
|
|
+ temp.add(data.getString("cost"));
|
|
|
+ temp.add(data.getBigDecimal("downloadCompleted"));
|
|
|
+ temp.add(data.getLong("photoShow"));
|
|
|
+ temp.add(data.getLong("photoClick"));
|
|
|
+ temp.add(data.getString("aclick"));
|
|
|
+ temp.add(data.getString("bclick"));
|
|
|
+ temp.add(data.getBigDecimal("photoClickRatio"));
|
|
|
+ temp.add(data.getBigDecimal("actionRatio"));
|
|
|
+ temp.add(data.getBigDecimal("impression1kCost"));
|
|
|
+ temp.add(data.getBigDecimal("photoClickCost"));
|
|
|
+ temp.add(data.getBigDecimal("actionCost"));
|
|
|
+ temp.add(data.getLong("conversions"));
|
|
|
+ temp.add(data.getBigDecimal("conversionPrice"));
|
|
|
+ excelList.add(temp);
|
|
|
+ });
|
|
|
+ try{
|
|
|
+ String[] headers = {"视频","视频md5","花费","安卓下载完成数","封面曝光数","封面点击数","素材曝光数","行为数","封面点击率","行为率","均千次封面曝光花费(元)","平均封面点击单价(元)","平均行为单价(元)","转化数","转化单价(元)"};
|
|
|
+ OutputStream os = response.getOutputStream();
|
|
|
+ ExportExcelUtils eeu = new ExportExcelUtils();
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
+ eeu.exportExcel(workbook, 0, "素材账户报表", headers, excelList);
|
|
|
+ HttpUtils.setResponseHeader(response, "素材账户报表.xlsx");
|
|
|
+ workbook.write(os);
|
|
|
+ os.flush();
|
|
|
+ os.close();
|
|
|
+ }catch (IOException e){
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|