|
@@ -1,8 +1,15 @@
|
|
package org.jeecg.modules.ctop.controller;
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
|
|
import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
|
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
|
+import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
|
+import cn.com.ctop.common.module.utils.ResultMapUtils;
|
|
|
|
+import cn.com.ctop.common.module.utils.StatusCode;
|
|
import cn.com.ctop.common.module.utils.StringUtils;
|
|
import cn.com.ctop.common.module.utils.StringUtils;
|
|
|
|
+import com.alibaba.excel.EasyExcelFactory;
|
|
|
|
+import com.alibaba.excel.ExcelWriter;
|
|
|
|
+import com.alibaba.excel.metadata.Sheet;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -14,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
import org.jeecg.modules.ctop.entity.Advertiser;
|
|
import org.jeecg.modules.ctop.entity.Advertiser;
|
|
import org.jeecg.modules.ctop.entity.Project;
|
|
import org.jeecg.modules.ctop.entity.Project;
|
|
@@ -21,6 +29,8 @@ import org.jeecg.modules.ctop.mapper.ProjectMapper;
|
|
import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
|
|
import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
|
|
import org.jeecg.modules.ctop.service.IAdvertiserService;
|
|
import org.jeecg.modules.ctop.service.IAdvertiserService;
|
|
import org.jeecg.modules.ctop.service.IProjectService;
|
|
import org.jeecg.modules.ctop.service.IProjectService;
|
|
|
|
+import org.jeecg.modules.ctop.vo.SheetInfoVo;
|
|
|
|
+import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
|
|
import org.jeecg.modules.system.entity.SysCategory;
|
|
import org.jeecg.modules.system.entity.SysCategory;
|
|
import org.jeecg.modules.system.entity.SysUser;
|
|
import org.jeecg.modules.system.entity.SysUser;
|
|
import org.jeecg.modules.system.entity.UserCompany;
|
|
import org.jeecg.modules.system.entity.UserCompany;
|
|
@@ -41,6 +51,7 @@ import org.springframework.web.servlet.ModelAndView;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.io.OutputStream;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -381,6 +392,39 @@ public class AdvertiserController {
|
|
return Result.ok("文件导入失败!");
|
|
return Result.ok("文件导入失败!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserAllocationService userAllocationService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导出报表
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/xxlDailyReportList")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Map<String, Object> xxlReportList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject data) throws Exception {
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ List<SheetInfoVo> sheets = new ArrayList<>();
|
|
|
|
+ //查询总的消耗信息
|
|
|
|
+ Long projectId = data.getLong("projectId");
|
|
|
|
+ String systemType = data.getString("systemType");
|
|
|
|
+ if (null == systemType || systemType.trim().equals("")) {
|
|
|
|
+ systemType = null;
|
|
|
|
+ }
|
|
|
|
+ SheetInfoVo totalSheetVo = advertiserService.getXxlStatisticInfo(projectId, systemType, null, null, "汇总表");
|
|
|
|
+ sheets.add(totalSheetVo);
|
|
|
|
+ List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, systemType);
|
|
|
|
+ if (null != allocations && allocations.size() > 0) {
|
|
|
|
+ for (UserAllocation allocation : allocations) {
|
|
|
|
+ SheetInfoVo vo = advertiserService.getXxlStatisticInfo(projectId, systemType, allocation.getAccountId(), "state_date", allocation.getAuthName());
|
|
|
|
+ sheets.add(vo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result.put("data", sheets);
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 导出报表
|
|
* 导出报表
|
|
*
|
|
*
|
|
@@ -388,52 +432,31 @@ public class AdvertiserController {
|
|
*/
|
|
*/
|
|
@RequestMapping(value = "/exportXxlDailyReport")
|
|
@RequestMapping(value = "/exportXxlDailyReport")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
- public void exportXxl(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) throws Exception {
|
|
|
|
|
|
+ public void exportXxl(HttpServletRequest request, HttpServletResponse response, Long projectId, String systemType) throws Exception {
|
|
|
|
+ List<SheetInfoVo> sheets = new ArrayList<>();
|
|
|
|
+ //查询总的消耗信息
|
|
|
|
+ SheetInfoVo totalSheetVo = advertiserService.getXxlStatisticInfo(projectId, systemType, null, null, "汇总表");
|
|
|
|
+ sheets.add(totalSheetVo);
|
|
|
|
+ List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, systemType);
|
|
|
|
+ if (null != allocations && allocations.size() > 0) {
|
|
|
|
+ for (UserAllocation allocation : allocations) {
|
|
|
|
+ SheetInfoVo vo = advertiserService.getXxlStatisticInfo(projectId, systemType, allocation.getAccountId(), "state_date", allocation.getAuthName());
|
|
|
|
+ sheets.add(vo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
-// List<SheetInfoVo> sheets = new ArrayList<SheetInfoVo>();
|
|
|
|
-// List<KuaishouXxlEntity> entities = advertiserService.getXxlStatisticInfo();
|
|
|
|
-//
|
|
|
|
-// List<List<Object>> group = new ArrayList<>();
|
|
|
|
-// List<DailyGroupReportVO> dailyGroupReport = dailyReport.getDailyGroupReport();
|
|
|
|
-// if (!Check.isNull(dailyGroupReport)) {
|
|
|
|
-// for (DailyGroupReportVO groupReportVO : dailyGroupReport) {
|
|
|
|
-// List<Object> dailyGroup = new ArrayList();
|
|
|
|
-// dailyGroup.add(groupReportVO.getAccountId());
|
|
|
|
-// dailyGroup.add(groupReportVO.getAuthName());
|
|
|
|
-// dailyGroup.add(groupReportVO.getStatDate());
|
|
|
|
-// dailyGroup.add(groupReportVO.getCampaignName());
|
|
|
|
-// dailyGroup.add(groupReportVO.getUnitName());
|
|
|
|
-// dailyGroup.add(groupReportVO.getCost()); // 花费
|
|
|
|
-// dailyGroup.add(groupReportVO.getDisCountCost()); // 折后花费
|
|
|
|
-// dailyGroup.add(groupReportVO.getPhotoShow()); // 展示数
|
|
|
|
-// dailyGroup.add(groupReportVO.getPhotoClick()); // 点击数
|
|
|
|
-// dailyGroup.add(groupReportVO.getBclick()); // 行为数
|
|
|
|
-// dailyGroup.add(RateUtil.getRate(groupReportVO.getPhotoClickRatio())); // 点击率
|
|
|
|
-// dailyGroup.add(RateUtil.getRate(groupReportVO.getActionRatio())); // 行为率
|
|
|
|
-//
|
|
|
|
-// dailyGroup.add(groupReportVO.getImpression1kCost()); // 平均千次展现花费
|
|
|
|
-// dailyGroup.add(groupReportVO.getPhotoClickCost()); // 平均点击花费
|
|
|
|
-// dailyGroup.add(groupReportVO.getConversions()); // 转化数
|
|
|
|
-// // dailyGroup.add(groupReportVO.getConversionPrice()); // 转化单价
|
|
|
|
-// dailyGroup.add(groupReportVO.getDiscountConversionPrice()); // 折后转化成本
|
|
|
|
-// dailyGroup.add(RateUtil.getRate(groupReportVO.getClickConversionRate())); // 点击转化率
|
|
|
|
-//
|
|
|
|
-// group.add(dailyGroup);
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// String[] accountHeaders = {"时间", "消耗(元)", "激励花费(元)", "实际消耗(元)", "展示数", "素材曝光数", "点击数", "点击率", "平均点击花费(元)", "行为数", "行为率", "平均千次展现花费(元)", "转化数(元)", "转化单价", "转化率", "折后转化成本(元)"};
|
|
|
|
-// String[] groupHeaders = {"账号", "账号名称", "日期", "计划名称", "广告组名称", "消耗(元)", "折后消耗(元)", "展现", "点击数", "行为数", "点击率", "行为率", "平均千次展现费用(元)", "平均点击费用(元)", "转化数", "折后转化成本(元)", "点击转化率"};
|
|
|
|
-// OutputStream os = response.getOutputStream();
|
|
|
|
-// ExportExcelUtils eeu = new ExportExcelUtils();
|
|
|
|
-// XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
|
-// eeu.exportExcel(workbook, 0, "分日数据", accountHeaders, accountData);
|
|
|
|
-// eeu.exportExcel(workbook, 1, "分组数据", groupHeaders, group);
|
|
|
|
-// this.setResponseHeader(response, "日报.xls");
|
|
|
|
-// workbook.write(os);
|
|
|
|
-// os.flush();
|
|
|
|
-// os.close();
|
|
|
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
|
+ String date = DateUtils.formatDate(new Date());
|
|
|
|
+ this.setResponseHeader(response, "爱上消消消日报" + date + ".xls");
|
|
|
|
+ ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
|
|
|
|
+ for (int i = 0; i < sheets.size(); i++) {
|
|
|
|
+ Sheet sheet = new Sheet(i + 1, 0, KuaishouXxlEntity.class);
|
|
|
|
+ sheet.setSheetName(sheets.get(i).getSheetName());
|
|
|
|
+ excelWriter.write(sheets.get(i).getDetails(), sheet);
|
|
|
|
+ }
|
|
|
|
+ excelWriter.finish();
|
|
|
|
+ outputStream.flush();
|
|
|
|
+ outputStream.close();
|
|
}
|
|
}
|
|
|
|
|
|
//发送响应流方法
|
|
//发送响应流方法
|