|
@@ -9,6 +9,11 @@ import cn.com.ctop.common.module.service.IProjectService;
|
|
|
import cn.com.ctop.common.module.service.ISysRoleExtService;
|
|
|
import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
import cn.com.ctop.common.module.utils.*;
|
|
|
+import cn.com.ctop.common.module.vo.SheetInfoVo;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouInfoDTO;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAccountService;
|
|
|
import com.alibaba.excel.EasyExcelFactory;
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
import com.alibaba.excel.metadata.Sheet;
|
|
@@ -16,6 +21,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -25,12 +31,12 @@ import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.ctop.entity.Advertiser;
|
|
|
import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
|
|
|
import org.jeecg.modules.ctop.service.IAdvertiserService;
|
|
|
-import org.jeecg.modules.ctop.vo.SheetInfoVo;
|
|
|
-import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
|
|
|
+import org.jeecg.modules.excelutil.entity.*;
|
|
|
import org.jeecg.modules.system.entity.SysCategory;
|
|
|
import org.jeecg.modules.system.entity.UserCompany;
|
|
|
import org.jeecg.modules.system.mapper.UserCompanyMapper;
|
|
|
import org.jeecg.modules.system.service.ISysCategoryService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -67,7 +73,6 @@ public class AdvertiserController {
|
|
|
@Autowired
|
|
|
private IUserAllocationService userAllocationService;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 查询 公司广告主
|
|
|
*
|
|
@@ -405,7 +410,10 @@ public class AdvertiserController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/exportXxlDailyReport")
|
|
|
@ResponseBody
|
|
|
- public void exportXxl(HttpServletRequest request, HttpServletResponse response, Long projectId, String systemType) throws IOException {
|
|
|
+ public void exportXxl(HttpServletRequest request,
|
|
|
+ HttpServletResponse response,
|
|
|
+ Long projectId,
|
|
|
+ String systemType) throws IOException {
|
|
|
List<SheetInfoVo> sheets = new ArrayList<>();
|
|
|
if (null == systemType || "".equals(systemType.trim())) {
|
|
|
systemType = null;
|
|
@@ -441,4 +449,146 @@ public class AdvertiserController {
|
|
|
outputStream.flush();
|
|
|
outputStream.close();
|
|
|
}
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IKuaishouReportDailyAccountService accountService;
|
|
|
+
|
|
|
+ @RequestMapping("/exportKuaishouProjectInfo")
|
|
|
+ public void getKuaishouProjectInfo(@RequestBody KuaishouInfoDTO dto,
|
|
|
+ HttpServletRequest request,
|
|
|
+ HttpServletResponse response)throws IOException {
|
|
|
+ Result<PageInfo<ProjectAccountDTO>> result = new Result<>();
|
|
|
+ result.setSuccess(true);
|
|
|
+
|
|
|
+ if(dto.getPageSize() == 0){
|
|
|
+ dto.setPageSize(100000);
|
|
|
+ }
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ String date = DateUtils.formatDate(new Date());
|
|
|
+ HttpUtils.setResponseHeader(response, "快手效果报表" + date + ".xlsx");
|
|
|
+ ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
|
|
|
+ String type = dto.getType();
|
|
|
+ if(null!=type&&type.trim().equals("project")){
|
|
|
+ SheetInfoVo projectSheetVo = this.getProjectSheetVo(dto, "项目报表");
|
|
|
+ Sheet sheet = new Sheet( 1, 0, EffecfReportProjectEntity.class);
|
|
|
+ sheet.setSheetName(projectSheetVo.getSheetName());
|
|
|
+ excelWriter.write(projectSheetVo.getDetails(), sheet);
|
|
|
+ }
|
|
|
+ if(null!=type&&type.trim().equals("account")){
|
|
|
+ SheetInfoVo accountSheetVo = this.getAccountSheetVo(dto, "账户报表");
|
|
|
+ Sheet sheet = new Sheet( 1, 0, EffecfReportAccountEntity.class);
|
|
|
+ sheet.setSheetName(accountSheetVo.getSheetName());
|
|
|
+ excelWriter.write(accountSheetVo.getDetails(), sheet);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null!=type&&type.trim().equals("campaign")){
|
|
|
+ SheetInfoVo planSheetVo = this.getPlanSheetVo(dto, "广告计划报表");
|
|
|
+ Sheet sheet = new Sheet( 1, 0, EffecfReportPlanEntity.class);
|
|
|
+ sheet.setSheetName(planSheetVo.getSheetName());
|
|
|
+ excelWriter.write(planSheetVo.getDetails(), sheet);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null!=type&&type.trim().equals("group")){
|
|
|
+ SheetInfoVo campaignSheetVo = this.getGroupSheetVo(dto, "广告组报表");
|
|
|
+ Sheet sheet = new Sheet( 1, 0, EffecfReportGroupEntity.class);
|
|
|
+ sheet.setSheetName(campaignSheetVo.getSheetName());
|
|
|
+ excelWriter.write(campaignSheetVo.getDetails(), sheet);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(null!=type&&type.trim().equals("creative")){
|
|
|
+ SheetInfoVo creativeSheetVo = this.getCreativeSheetVo(dto, "广告创意");
|
|
|
+ Sheet sheet = new Sheet( 1, 0, EffecfReportCreativeEntity.class);
|
|
|
+ sheet.setSheetName(creativeSheetVo.getSheetName());
|
|
|
+ excelWriter.write(creativeSheetVo.getDetails(), sheet);
|
|
|
+ }
|
|
|
+
|
|
|
+ excelWriter.finish();
|
|
|
+ outputStream.flush();
|
|
|
+ outputStream.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ private SheetInfoVo getCreativeSheetVo(KuaishouInfoDTO dto, String sheetName) {
|
|
|
+ SheetInfoVo vo = new SheetInfoVo<EffecfReportProjectEntity>();
|
|
|
+ vo.setSheetName(sheetName);
|
|
|
+ PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getProjectList(), dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
|
|
|
+ List<KuaishouReportDailyAccountDTO> dtos = kuaishouCampaignInfoList.getList();
|
|
|
+ if(null!=dtos&&!dtos.isEmpty()){
|
|
|
+ List<EffecfReportCreativeEntity> details = new ArrayList<>();
|
|
|
+ for(KuaishouReportDailyAccountDTO dto1:dtos){
|
|
|
+ EffecfReportCreativeEntity entity = new EffecfReportCreativeEntity();
|
|
|
+ BeanUtils.copyProperties(dto1,entity);
|
|
|
+ details.add(entity);
|
|
|
+ }
|
|
|
+ vo.setDetails(details);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private SheetInfoVo getGroupSheetVo(KuaishouInfoDTO dto, String sheetName) {
|
|
|
+ SheetInfoVo vo = new SheetInfoVo<EffecfReportProjectEntity>();
|
|
|
+ vo.setSheetName(sheetName);
|
|
|
+ PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getProjectList(), dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
|
|
|
+ List<KuaishouReportDailyAccountDTO> dtos = kuaishouCampaignInfoList.getList();
|
|
|
+ if(null!=dtos&&!dtos.isEmpty()){
|
|
|
+ List<EffecfReportGroupEntity> details = new ArrayList<>();
|
|
|
+ for(KuaishouReportDailyAccountDTO dto1:dtos){
|
|
|
+ EffecfReportGroupEntity entity = new EffecfReportGroupEntity();
|
|
|
+ BeanUtils.copyProperties(dto1,entity);
|
|
|
+ details.add(entity);
|
|
|
+ }
|
|
|
+ vo.setDetails(details);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private SheetInfoVo getPlanSheetVo(KuaishouInfoDTO dto, String sheetName) {
|
|
|
+ SheetInfoVo vo = new SheetInfoVo<EffecfReportProjectEntity>();
|
|
|
+ vo.setSheetName(sheetName);
|
|
|
+ PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getProjectList(), dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
|
|
|
+ List<KuaishouReportDailyAccountDTO> dtos = kuaishouCampaignInfoList.getList();
|
|
|
+ if(null!=dtos&&!dtos.isEmpty()){
|
|
|
+ List<EffecfReportPlanEntity> details = new ArrayList<>();
|
|
|
+ for(KuaishouReportDailyAccountDTO dto1:dtos){
|
|
|
+ EffecfReportPlanEntity entity = new EffecfReportPlanEntity();
|
|
|
+ BeanUtils.copyProperties(dto1,entity);
|
|
|
+ details.add(entity);
|
|
|
+ }
|
|
|
+ vo.setDetails(details);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private SheetInfoVo getAccountSheetVo(KuaishouInfoDTO dto, String sheetName) {
|
|
|
+ SheetInfoVo vo = new SheetInfoVo<EffecfReportProjectEntity>();
|
|
|
+ vo.setSheetName(sheetName);
|
|
|
+ PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(),dto.getProjectList(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
|
|
|
+ List<KuaishouReportDailyAccountDTO> dtos = kuaishouReportDailyAccountDTOList.getList();
|
|
|
+ if(null!=dtos&&!dtos.isEmpty()){
|
|
|
+ List<EffecfReportAccountEntity> details = new ArrayList<>();
|
|
|
+ for(KuaishouReportDailyAccountDTO dto1:dtos){
|
|
|
+ EffecfReportAccountEntity entity = new EffecfReportAccountEntity();
|
|
|
+ BeanUtils.copyProperties(dto1,entity);
|
|
|
+ details.add(entity);
|
|
|
+ }
|
|
|
+ vo.setDetails(details);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ private SheetInfoVo getProjectSheetVo(KuaishouInfoDTO dto, String sheetName) {
|
|
|
+ SheetInfoVo vo = new SheetInfoVo<EffecfReportProjectEntity>();
|
|
|
+ vo.setSheetName(sheetName);
|
|
|
+ PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "", dto.getYn());
|
|
|
+ List<ProjectAccountDTO> dtos = projectAccountDTOList.getList();
|
|
|
+ if(null!=dtos&&!dtos.isEmpty()){
|
|
|
+ List<EffecfReportProjectEntity> details = new ArrayList<>();
|
|
|
+ for(ProjectAccountDTO dto1:dtos){
|
|
|
+ EffecfReportProjectEntity entity = new EffecfReportProjectEntity();
|
|
|
+ BeanUtils.copyProperties(dto1,entity);
|
|
|
+ details.add(entity);
|
|
|
+ }
|
|
|
+ vo.setDetails(details);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
}
|