Parcourir la source

修改素材库代码sql逻辑

syh il y a 4 ans
Parent
commit
b22c2367ad

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application.yml

@@ -1,7 +1,7 @@
 spring:
   profiles:
-#    active: wps
-    active: @activatedProperties@
+    active: wps
+#    active: @activatedProperties@
 
 swagger:
   production: false

+ 3 - 6
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -190,16 +190,13 @@ public class SampleTest {
 
     @Test
     public void loadBytedanceData(){
-        String strings = "1672894840372238_1674183267750990_1673076203257870_1650079154438157_1670286873337870_1648709018451972_1661556811389966_1676540488471559";
-        String[] tokens = strings.split("_");
-        for (int i=0;i<tokens.length;i++) {
-            Long accountId = Long.parseLong(tokens[i]);
-            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        List<UserAllocation>allocations = allocationService.getByParams(633L,null,0);
+        for (int i=0;i<allocations.size();i++) {
+            CtopOauthToken token = tokenService.getTokenByAccountId(allocations.get(i).getAccountId());
             for(int j=10;j<110;j++){
                 Date getDate = DateUtils.addDay(new Date(), -j);
                 reportService.getAdvertiserReport(token, getDate, getDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
             }
-
         }
     }
 

Fichier diff supprimé car celui-ci est trop grand
+ 467 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouReportAccountDailyDTOEntity.java


+ 38 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java

@@ -2,19 +2,31 @@ package cn.com.ctop.kuaishou.modules.batch.controller;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.vo.ByteDanceReportAccountDailyDTOEntity;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 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;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 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.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -122,6 +134,32 @@ public class KuaiShouController {
         return result;
     }
 
+    @PostMapping("/exportKuaishouSaleProjectInfo")
+    public void exportKuaishouSaleProjectInfo(@RequestBody KuaishouInfoDTO dto, HttpServletResponse response) throws IOException {
+        Result<PageInfo<ProjectAccountDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return ;
+        }
+
+        dto.setPageSize(1000000000);
+        //查询总的消耗信息
+        SheetInfoVo totalSheetVo = accountService.getKuaishouSaleProjectInfoSheetVO(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageNum(),dto.getPageSize(),"", dto.getYn());
+        OutputStream outputStream = response.getOutputStream();
+        String date = DateUtils.formatDate(new Date());
+        HttpUtils.setResponseHeader(response, "快手销售报表" + date + ".xlsx");
+        ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
+        Sheet sheet = new Sheet(1, 0, ByteDanceReportAccountDailyDTOEntity.class);
+        sheet.setSheetName(totalSheetVo.getSheetName());
+        excelWriter.write(totalSheetVo.getDetails(), sheet);
+        excelWriter.finish();
+        outputStream.flush();
+        outputStream.close();
+    }
+
     @RequestMapping("/getKuaishouAccountInfoByProjectId")
     public Result<PageInfo<KuaishouReportDailyAccountDTO>> getKuaishouAccountInfoByProjectId(@RequestBody KuaishouInfoDTO dto) {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
+import cn.com.ctop.common.module.vo.KuaishouReportAccountDailyDTOEntity;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoInfoDTO;
@@ -47,4 +48,5 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
     List<Long> getSaleProjectAccountIds(@Param("userId")String userId, @Param("yn")Integer yn);
 
 
+    List<KuaishouReportAccountDailyDTOEntity> getKuaishouProjectInfoEntity(String startDate, String endDate, List<Long> projectList, Integer yn);
 }

+ 2 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java

@@ -1,15 +1,13 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
+import cn.com.ctop.common.module.vo.SheetInfoVo;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
 import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.github.pagehelper.PageInfo;
-import org.apache.shiro.SecurityUtils;
-import org.jeecg.common.system.vo.LoginUser;
 
-import java.util.ArrayList;
 import java.util.List;
 
 public interface IKuaishouReportDailyAccountService extends IService<KuaishouReportDailyAccount> {
@@ -30,4 +28,5 @@ public interface IKuaishouReportDailyAccountService extends IService<KuaishouRep
 
     PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(List<Long> projectList, Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
+    SheetInfoVo getKuaishouSaleProjectInfoSheetVO(String startDate, String endDate, List<Long> projectList, int pageNum, int pageSize, String s, Integer yn);
 }

+ 30 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java

@@ -1,5 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.service.impl;
 
+import cn.com.ctop.common.module.vo.ByteDanceReportAccountDailyDTOEntity;
+import cn.com.ctop.common.module.vo.KuaishouReportAccountDailyDTOEntity;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO;
 import cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO;
@@ -178,4 +181,31 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         return new PageInfo<>(kuaishouCreativeInfoList);
     }
 
+    @Override
+    public SheetInfoVo getKuaishouSaleProjectInfoSheetVO(String startDate, String endDate, List<Long> projectList, int pageNum, int pageSize, String s, Integer yn) {
+        SheetInfoVo vo = new SheetInfoVo<ByteDanceReportAccountDailyDTOEntity>();
+        if(projectList==null || projectList.size()==0){
+            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            String userId = sysUser.getId();
+            String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+            List<Long> mediaIds = new ArrayList<>();
+            mediaIds.add(2L);
+            mediaIds.add(4L);
+
+            if("admin".equals(roleCode)){
+                projectList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
+            }else{
+                projectList = dailyAccountMapper.queryProjectInfoBySaleId(userId,mediaIds);
+            }
+        }
+
+        PageHelper.startPage(pageNum,pageSize);
+        List<KuaishouReportAccountDailyDTOEntity> dtos = dailyAccountMapper.getKuaishouProjectInfoEntity(startDate,endDate,projectList,yn);
+//        return new PageInfo<>(dailyAccountMapper.getKuaishouProjectInfo(startDate,endDate,projectList,yn));
+        vo.setSheetName("头条销售报表");
+        vo.setDetails(dtos);
+        return vo;
+    }
+
 }

+ 1 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java

@@ -482,9 +482,7 @@ public class BytedanceReportController {
             dto.setEndDate(dateString);
         }
 
-        if(dto.getPageSize() == 0 ){
-            dto.setPageSize(1000000000);
-        }
+        dto.setPageSize(1000000000);
         //查询总的消耗信息
         SheetInfoVo totalSheetVo = bytedanceAccountReportService.getBytedanceSaleProjectInfoSheetVO(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageNum(),dto.getPageSize(),dto.getSort(), dto.getYn());
         OutputStream outputStream = response.getOutputStream();

+ 0 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

@@ -228,7 +228,6 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
         if(projectList==null || projectList.size()==0){
             LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
             String userId = sysUser.getId();
-            //String userId = "388e787edd294ecfb9243fe176a3ae56";
             String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
 
             List<Long> mediaIds = new ArrayList<>();