|
@@ -1,24 +1,28 @@
|
|
|
package cn.com.ctop.kuaishou.modules.report.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.*;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
|
+import cn.com.ctop.common.module.utils.RateUtil;
|
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
|
|
|
import cn.com.ctop.kuaishou.modules.report.entity.ParamsDTO;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentSumService;
|
|
|
-import java.util.Date;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -256,11 +260,12 @@ public class KuaishouReportDailyAgentSumController {
|
|
|
* @param dto
|
|
|
* @return Result<KuaishouReportDailyAgentSum>
|
|
|
*/
|
|
|
- @AutoLog(value = "公司报表按时间汇总")
|
|
|
- @ApiOperation(value="公司报表按时间汇总", notes="公司报表按时间汇总")
|
|
|
+ @AutoLog(value = "公司报表按天明细")
|
|
|
+ @ApiOperation(value="公司报表按天明细", notes="公司报表按天明细")
|
|
|
@PostMapping(value = "/companyReportAccountDetailList")
|
|
|
public Result<List<KuaishouReportDailyAgent>> companyReportAccountDetailList(@RequestBody ParamsDTO dto) {
|
|
|
Result<List<KuaishouReportDailyAgent>> result = new Result<>();
|
|
|
+ String advertiserName = dto.getAdvertiserName();
|
|
|
String date = dto.getDate();
|
|
|
if(StringUtils.isBlank(date)){
|
|
|
result.setSuccess(false);
|
|
@@ -268,7 +273,7 @@ public class KuaishouReportDailyAgentSumController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- List<KuaishouReportDailyAgent> kuaishouReportDailyAgentList = kuaishouReportDailyAgentSumService.companyReportAccountDetailList(date);
|
|
|
+ List<KuaishouReportDailyAgent> kuaishouReportDailyAgentList = kuaishouReportDailyAgentSumService.companyReportAccountDetailList(date, advertiserName);
|
|
|
result.setResult(kuaishouReportDailyAgentList);
|
|
|
result.setSuccess(true);
|
|
|
result.setMessage("success");
|
|
@@ -276,4 +281,125 @@ public class KuaishouReportDailyAgentSumController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+ @AutoLog(value = "公司报表按天导出Excel")
|
|
|
+ @ApiOperation(value="公司报表按天导出Excel", notes="公司报表按天导出Excel")
|
|
|
+ @GetMapping(value = "/companyReportExportExcel")
|
|
|
+ public void companyReportExportExcel( @RequestBody ParamsDTO dto,
|
|
|
+ //@RequestParam("startDate")String startDate,
|
|
|
+ //@RequestParam("endDate")String endDate,
|
|
|
+ HttpServletRequest request,
|
|
|
+ HttpServletResponse response) throws Exception{
|
|
|
+ Result result = new Result<>();
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setMessage("success");
|
|
|
+
|
|
|
+ //公司报表
|
|
|
+ List<KuaishouReportDailyAgentSum> kuaishouReportDailyAgentSumList = kuaishouReportDailyAgentSumService.companyReport(dto.getStartDate(),dto.getEndDate());
|
|
|
+
|
|
|
+ //导出excel
|
|
|
+ List<List<Object>> group = new ArrayList<>();
|
|
|
+ if (!Check.isNull(kuaishouReportDailyAgentSumList)) {
|
|
|
+ for (KuaishouReportDailyAgentSum sum : kuaishouReportDailyAgentSumList) {
|
|
|
+ List<Object> kuaishouReportDailyAgentSum = new ArrayList();
|
|
|
+ kuaishouReportDailyAgentSum.add(DateUtils.formatDate(sum.getDate())); //日期
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getCostCampaignCount() ); //有消费计划数
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getBalance()); //总余额
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getCost()); //总消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getXianjinCost()); //现金消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getFandianCost()); //后返消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getKuangfanCost()); //框返消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getJiliCost()); //激励账户消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getXinyongCost()); //信用账户消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getFengmianShowCount()); //封面曝光数
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getFengmianClickCount()); //封面点击数
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getSucaiShowCount()); //素材曝光数
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getConvertCount()); //行为数
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getFengmianClickCount()); //封面点击率
|
|
|
+ kuaishouReportDailyAgentSum.add(sum.getConvertClickRate()); //转化点击率
|
|
|
+ group.add(kuaishouReportDailyAgentSum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] groupHeaders = {"日期", "有消费计划数", "总余额", "总消耗", "现金消耗", "后返消耗", "框返消耗", "激励账户消耗", "信用账户消耗", "封面曝光数", "封面点击数", "素材曝光数", "行为数", "封面点击率", "转化点击率"};
|
|
|
+ OutputStream os = response.getOutputStream();
|
|
|
+ ExportExcelUtils eeu = new ExportExcelUtils();
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
+ eeu.exportExcel(workbook, 0, "公司日报表", groupHeaders, group);
|
|
|
+ this.setResponseHeader(response, "公司日报表.xlsx");
|
|
|
+ workbook.write(os);
|
|
|
+ os.flush();
|
|
|
+ os.close();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @AutoLog(value = "公司日报明细表按天导出Excel")
|
|
|
+ @ApiOperation(value="公司日报明细表按天导出Excel", notes="公司报表按天导出Excel")
|
|
|
+ @GetMapping(value = "/companyReportAccountDetailListExportExcel")
|
|
|
+ public void companyReportAccountDetailListExportExcel( @RequestBody ParamsDTO dto,
|
|
|
+ //@RequestParam("date")String date,
|
|
|
+ HttpServletRequest request,
|
|
|
+ HttpServletResponse response) throws Exception{
|
|
|
+ Result result = new Result<>();
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setMessage("success");
|
|
|
+
|
|
|
+ //公司报表按天明细
|
|
|
+ List<KuaishouReportDailyAgent> kuaishouReportDailyAgentList = kuaishouReportDailyAgentSumService.companyReportAccountDetailList(dto.getDate(), null);
|
|
|
+
|
|
|
+ //导出excel
|
|
|
+ List<List<Object>> group = new ArrayList<>();
|
|
|
+ if (!Check.isNull(kuaishouReportDailyAgentList)) {
|
|
|
+ for (KuaishouReportDailyAgent agent : kuaishouReportDailyAgentList) {
|
|
|
+ List<Object> kuaishouReportDailyAgentSum = new ArrayList();
|
|
|
+ kuaishouReportDailyAgentSum.add(DateUtils.formatDate(agent.getDate())); //日期
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getKid()); //快手id
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getAdvertiserName()); //广告主名称
|
|
|
+ kuaishouReportDailyAgentSum.add(DateUtils.formatDate(agent.getAdvertiserCreateTime())); //广告主创建时间
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getCostCampaignCount()); //有消费计划数量
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getBalance()); //总余额
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getCost()); //总消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getXianjinCost()); //现金消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getFandianCost()); //后返消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getKuangfanCost()); //框返消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getJiliCost()); //激励账户消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getXinyongCost()); //信用账户消耗
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getFengmianShowCount()); //封面曝光数
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getFengmianClickCount()); //封面点击数
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getSucaiShowCount()); //素材曝光数
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getConvertCount()); //行为数
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getFengmianClickRate()); //封面点击率
|
|
|
+ kuaishouReportDailyAgentSum.add(agent.getConvertClickRate()); //转化点击率
|
|
|
+ group.add(kuaishouReportDailyAgentSum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] groupHeaders = {"日期", "快手id", "广告主名称", "广告主创建时间", "有消费计划数量", "总余额", "总消耗", "现金消耗", "后返消耗", "框返消耗", "激励账户消耗", "信用账户消耗", "封面曝光数", "封面点击数", "素材曝光数", "行为数", "封面点击率", "转化点击率"};
|
|
|
+ OutputStream os = response.getOutputStream();
|
|
|
+ ExportExcelUtils eeu = new ExportExcelUtils();
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
+ eeu.exportExcel(workbook, 0, "公司日报明细表", groupHeaders, group);
|
|
|
+ this.setResponseHeader(response, "公司日报明细表.xlsx");
|
|
|
+ workbook.write(os);
|
|
|
+ os.flush();
|
|
|
+ os.close();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //发送响应流方法
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|