소스 검색

快手图片消耗

syh 4 년 전
부모
커밋
fbb94271e4
21개의 변경된 파일622개의 추가작업 그리고 74개의 파일을 삭제
  1. 0 16
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  2. 50 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ImageCostController.java
  3. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialTagInfoController.java
  4. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IImageReportDailyService.java
  5. 97 15
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ImageReportDailyServiceImpl.java
  6. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java
  7. 0 1
      jeecg-boot-module-system/src/main/resources/application.yml
  8. 69 13
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  9. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java
  10. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/ImageCostVO.java
  11. 123 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/BytedanceImageCostVOEntity.java
  12. 24 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouImageCostVO.java
  13. 167 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouImageCostVOEntity.java
  14. 6 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyReportTaskServiceImpl.java
  15. 4 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java
  16. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyImageMapper.java
  17. 51 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyImageMapper.xml
  18. 5 7
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java
  19. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml
  20. 3 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceFundDailyServiceImpl.java
  21. 1 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

+ 0 - 16
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java

@@ -116,25 +116,9 @@ public class AdvertiserController {
                                                    @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize,
                                                    HttpServletRequest req) {
         Result<IPage<Advertiser>> result = new Result<>();
-        // String roleCode = sysRoleService.getRoleCodeByUserId(advertiser.getUserId());
-      /*  String userId = advertiser.getUserId();
-        if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
-            advertiser.setUserId(null);
-        }*/
-
         String name = advertiser.getName();
         advertiser.setName(null);
         QueryWrapper<Advertiser> queryWrapper = QueryGenerator.initQueryWrapper(advertiser, req.getParameterMap());
-       /* if ("kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode)) {
-            QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
-            userCompanyQueryWrapper.eq("user_id", userId);
-            userCompanyQueryWrapper.orderByDesc("create_time");
-            userCompanyQueryWrapper.last("limit 1");
-            UserCompany userCompany = userCompanyMapper.selectOne(userCompanyQueryWrapper);
-            if (!Check.isNull(userCompany)) {
-                queryWrapper.eq("company_id", userCompany.getCompanyId());
-            }
-        }*/
         if (!Check.isNull(name)) {
             queryWrapper.like("name", name);
         }

+ 50 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ImageCostController.java

@@ -1,11 +1,26 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.vo.BytedanceImageCostVOEntity;
+import cn.com.ctop.common.module.vo.KuaishouImageCostVOEntity;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportMaterialDailyService;
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.metadata.Sheet;
 import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.IImageReportDailyService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+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.Map;
 
 @RestController
@@ -20,8 +35,42 @@ public class ImageCostController {
         return imageReportDailyService.bytedanceImageCost(data);
     }
 
+    @PostMapping("bytedance/cost/export")
+    public void bytedanceImageCostExport(@RequestBody JSONObject data, HttpServletResponse response) throws IOException {
+
+        SheetInfoVo vo = imageReportDailyService.getbytedanceImageCostVo(data);
+        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, BytedanceImageCostVOEntity.class);
+        sheet.setSheetName(vo.getSheetName());
+        excelWriter.write(vo.getDetails(), sheet);
+
+        excelWriter.finish();
+        outputStream.flush();
+        outputStream.close();
+    }
+
     @PostMapping("kuaishou/cost")
     public Map<String,Object> kuaishouImageCost(@RequestBody JSONObject data){
         return imageReportDailyService.kuaishouImageCost(data);
     }
+
+    @PostMapping("kuaishou/cost/export")
+    public void kuaishouImageCostExport(@RequestBody JSONObject data, HttpServletResponse response) throws IOException {
+        SheetInfoVo vo = imageReportDailyService.getkuaishouImageCostVo(data);
+        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, KuaishouImageCostVOEntity.class);
+        sheet.setSheetName(vo.getSheetName());
+        excelWriter.write(vo.getDetails(), sheet);
+        excelWriter.finish();
+        outputStream.flush();
+        outputStream.close();
+    }
+
+
 }

+ 0 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialTagInfoController.java

@@ -50,7 +50,6 @@ public class MaterialTagInfoController {
 		Result<IPage<MaterialTagInfo>> result = new Result<>();
 		QueryWrapper<MaterialTagInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialTagInfo, req.getParameterMap());
 		Page<MaterialTagInfo> page = new Page<>(pageNo, pageSize);
-		queryWrapper.eq("status",1);
 		IPage<MaterialTagInfo> pageList = materialTagInfoService.page(page, queryWrapper);
 		result.setSuccess(true);
 		result.setResult(pageList);

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IImageReportDailyService.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.service;
 
+import cn.com.ctop.common.module.vo.SheetInfoVo;
 import com.alibaba.fastjson.JSONObject;
 
 import java.util.Map;
@@ -8,4 +9,8 @@ public interface IImageReportDailyService {
     Map<String,Object> bytedanceImageCost(JSONObject data);
 
     Map<String, Object> kuaishouImageCost(JSONObject data);
+
+    SheetInfoVo getkuaishouImageCostVo(JSONObject data);
+
+    SheetInfoVo getbytedanceImageCostVo(JSONObject data);
 }

+ 97 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ImageReportDailyServiceImpl.java

@@ -5,7 +5,8 @@ import cn.com.ctop.common.module.entity.SysUser;
 import cn.com.ctop.common.module.service.IMaterialImageInfoService;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
-import cn.com.ctop.toutiao.modules.report.DTO.ImageCostVO;
+import cn.com.ctop.common.module.vo.*;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyImageMapper;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -23,6 +24,15 @@ import java.util.Map;
 
 @Service
 public class ImageReportDailyServiceImpl implements IImageReportDailyService {
+    @Autowired
+    private IMaterialImageInfoService imageInfoService;
+    @Autowired
+    private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
+    @Autowired
+    private KuaishouReportDailyImageMapper kuaishouReportDailyImageMapper;
+    @Autowired
+    private ISysUserService sysUserService;
+
 
     @Override
     public Map<String,Object> bytedanceImageCost(JSONObject data) {
@@ -52,11 +62,11 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
             pageSize = 10;
         }
         PageHelper.startPage(pageNumber,pageSize);
-        List<ImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code,(pageNumber-1)*pageSize,pageSize);
-        PageInfo<ImageCostVO> pageInfo = new PageInfo<>(vos);
+        List<BytedanceImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code);
+        PageInfo<BytedanceImageCostVO> pageInfo = new PageInfo<>(vos);
         if(null!=vos&&!vos.isEmpty()){
-            List<ImageCostVO>setVos = new ArrayList<>();
-            for(ImageCostVO vo:vos){
+            List<BytedanceImageCostVO>setVos = new ArrayList<>();
+            for(BytedanceImageCostVO vo:vos){
                 MaterialImageInfo imageInfo = imageInfoService.getByCode(vo.getSignature());
                 if(null!=imageInfo){
                     vo.setUserId(imageInfo.getUserId());
@@ -75,6 +85,45 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
     }
 
     @Override
+    public SheetInfoVo getbytedanceImageCostVo(JSONObject data) {
+        SheetInfoVo sheetInfoVo = new SheetInfoVo<BytedanceImageCostVOEntity>();
+        String startDate = data.getString("startDate");
+        if(null == startDate||startDate.trim().equals("")){
+            startDate = null;
+        }
+        String endDate = data.getString("endDate");
+        if(null == endDate||endDate.trim().equals("")){
+            endDate = null;
+        }
+        JSONArray accountList = data.getJSONArray("accountList");
+        if(null==accountList||accountList.isEmpty()){
+            accountList = null;
+        }
+        String code = data.getString("code");
+        if(null == code||code.trim().equals("")){
+            code = null;
+        }
+        List<BytedanceImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code);
+        List<BytedanceImageCostVOEntity>details = new ArrayList<>();
+        if(null!=vos&&!vos.isEmpty()){
+            for(BytedanceImageCostVO vo:vos){
+                BytedanceImageCostVOEntity entity = new BytedanceImageCostVOEntity(vo);
+                MaterialImageInfo imageInfo = imageInfoService.getByCode(vo.getSignature());
+                if(null!=imageInfo){
+                    entity.setUserId(imageInfo.getUserId());
+                    SysUser user = sysUserService.getById(imageInfo.getUserId());
+                    entity.setUserName(user.getUsername());
+                }else{
+                    entity.setUserName("-");
+                }
+                details.add(entity);
+            }
+        }
+        sheetInfoVo.setDetails(details);
+        return sheetInfoVo;
+    }
+
+    @Override
     public Map<String, Object> kuaishouImageCost(JSONObject data) {
         Map<String,Object>result = new HashMap<>();
         String startDate = data.getString("startDate");
@@ -102,11 +151,11 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
             pageSize = 10;
         }
         PageHelper.startPage(pageNumber,pageSize);
-        List<ImageCostVO> vos = bytedanceReportMaterialDailyMapper.bytedanceImageCost(startDate,endDate,accountList,code,(pageNumber-1)*pageSize,pageSize);
-        PageInfo<ImageCostVO> pageInfo = new PageInfo<>(vos);
+        List<KuaishouImageCostVO> vos = kuaishouReportDailyImageMapper.imageCost(startDate,endDate,accountList,code);
+        PageInfo<KuaishouImageCostVO> pageInfo = new PageInfo<>(vos);
         if(null!=vos&&!vos.isEmpty()){
-            List<ImageCostVO>setVos = new ArrayList<>();
-            for(ImageCostVO vo:vos){
+            List<KuaishouImageCostVO>setVos = new ArrayList<>();
+            for(KuaishouImageCostVO vo:vos){
                 MaterialImageInfo imageInfo = imageInfoService.getByCode(vo.getSignature());
                 if(null!=imageInfo){
                     vo.setUserId(imageInfo.getUserId());
@@ -124,10 +173,43 @@ public class ImageReportDailyServiceImpl implements IImageReportDailyService {
         return result;
     }
 
-    @Autowired
-    private IMaterialImageInfoService imageInfoService;
-    @Autowired
-    private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
-    @Autowired
-    private ISysUserService sysUserService;
+    @Override
+    public SheetInfoVo getkuaishouImageCostVo(JSONObject data) {
+        SheetInfoVo sheetInfoVo = new SheetInfoVo<KuaishouImageCostVOEntity>();
+        String startDate = data.getString("startDate");
+        if(null == startDate||startDate.trim().equals("")){
+            startDate = null;
+        }
+        String endDate = data.getString("endDate");
+        if(null == endDate||endDate.trim().equals("")){
+            endDate = null;
+        }
+        JSONArray accountList = data.getJSONArray("accountList");
+        if(null==accountList||accountList.isEmpty()){
+            accountList = null;
+        }
+        String code = data.getString("code");
+        if(null == code||code.trim().equals("")){
+            code = null;
+        }
+        sheetInfoVo.setSheetName("快手图片消耗统计");
+        List<KuaishouImageCostVO> vos = kuaishouReportDailyImageMapper.imageCost(startDate,endDate,accountList,code);
+        List<KuaishouImageCostVOEntity> details = new ArrayList<>();
+        if(null!=vos&&!vos.isEmpty()){
+            for (KuaishouImageCostVO vo:vos) {
+                KuaishouImageCostVOEntity entity = new KuaishouImageCostVOEntity(vo);
+                MaterialImageInfo imageInfo = imageInfoService.getByCode(vo.getSignature());
+                if(null!=imageInfo){
+                    entity.setUserId(imageInfo.getUserId());
+                    SysUser user = sysUserService.getById(imageInfo.getUserId());
+                    entity.setUserName(user.getUsername());
+                }else{
+                    entity.setUserName("-");
+                }
+                details.add(entity);
+            }
+        }
+        sheetInfoVo.setDetails(details);
+        return sheetInfoVo;
+    }
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java

@@ -122,7 +122,7 @@ public class SysBaseApiImpl implements ISysBaseApi {
 	}
 
 	@Override
-	@Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username")
+//	@Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username")
 	public LoginUser getUserByName(String username) {
 		if(oConvertUtils.isEmpty(username)) {
 			return null;

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

@@ -1,6 +1,5 @@
 spring:
   profiles:
-#    active: wps
     active: @activatedProperties@
 
 swagger:

+ 69 - 13
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -9,11 +9,13 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceFundDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -34,6 +36,8 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
+import static org.jeecg.common.util.DateUtils.getAnotherDay;
+
 @RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @ActiveProfiles("wps")
@@ -129,21 +133,73 @@ public class SampleTest {
     public void testLoadBytedanceData() {
         List<UserAllocation> allocations = allocationService.getByParams(633L, null, 0);
         for (UserAllocation allocation : allocations) {
-//            for (int i = 2; i < 10; i++) {
+            System.out.println(allocation.getAccountId());
+            for (int i = 0; i < 1; i++) {
                 CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId());
-                Date getDate = DateUtils.addDay(new Date(), 0);
+                Date getDate = DateUtils.addDay(new Date(), -i);
 //                reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
                 reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
-//            }
+
+//                reportService.getAdvertiserCampaignReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+//                reportService.getAdvertiserCampaignReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+            }
         }
     }
 
     @Test
     public void loadBytedancePlanData(){
-        CtopOauthToken token = tokenService.getTokenByAccountId(1665934552997902L);
-        advertiserDataService.getAdvertiserPlan(token, "", null, null);
+        CtopOauthToken token = tokenService.getTokenByAccountId(100198696723L);
+//        advertiserDataService.getAdvertiserPlan(token, "", null, null);
+        Date getDate = DateUtils.addDay(new Date(), 0);
+        reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+    }
+
+    @Autowired
+    private IBytedanceFundDailyService bytedanceFundDailyService;
+    @Test
+    public void loadFoudData() {
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        for (CtopOauthToken token : tokens) {
+            System.out.println(token.getAccountId()+"############################");
+            for(int i=20;i<130;i++){
+                Date date = DateUtils.addDay(new Date(),-i);
+                bytedanceFundDailyService.loadFundDataByPage(token, DateUtils.formatDate(date), DateUtils.formatDate(date),1);
+                System.out.println(i+"############################");
+            }
+        }
+    }
+
+    @Autowired
+    private IKuaiShouHistoryReportTaskService reportTaskService;
+
+    /**
+     * 测试获取快手图片消耗数据任务
+     */
+    @Test
+    public void loadKuaishouImageTask(){
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        for(int i=1;i<130;i++) {
+            Date getDate = DateUtils.addDay(new Date(), -i);
+            String getDateStr = DateUtils.formatDate(getDate);
+            tokens.forEach(token -> reportTaskService.createTask(token.getAccountId(), token.getAccessToken(), getDateStr, getDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_DAILY));
+        }
     }
 
+    @Autowired
+    private IKuaiShouDailyReportTaskService dailyReportTaskService;
+    /**
+     * 测试获取快手图片消耗数据入库
+     */
+    @Test
+    public void loadKuaishouImageTaskFile(){
+        String nowDate = DateUtils.getDate("yyyy-MM-dd");
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        for(int i=1;i<15;i++){
+            String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -i);
+            tokens.forEach(token -> dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate));
+        }
+        //  查询快手token
+    }
 
     @Test
     public void loadKuaishouAgentData() {
@@ -198,16 +254,19 @@ public class SampleTest {
 
     @Test
     public void loadBytedanceData(){
-        List<UserAllocation>allocations = allocationService.getByParams(633L,null,0);
+        List<UserAllocation>allocations = allocationService.getByParams(289L,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);
+            for(int j=0;j<10;j++){
+                String getDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -j));
+                bytedanceReportService.bytedanceVideoMaterialReport(token, getDate, getDate);
             }
         }
     }
 
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
     @Test
     public void loaddata(){
         for(int i=0;i<30;i++){
@@ -218,13 +277,10 @@ public class SampleTest {
     }
 
     @Autowired
-    private IBytedanceReportService bytedanceReportService;
-
-    @Autowired
     private IByteDanceVideoReportDailyService videoReportDailyService;
     @Test
     public void loadMatData(){
-        List<UserAllocation> allocations = allocationService.getByParams(320L,null,0);
+        List<UserAllocation> allocations = allocationService.getByParams(289L,null,0);
         countDownLatch = new CountDownLatch(allocations.size());
         executorService = Executors.newFixedThreadPool(2);
         allocations.forEach(allocation -> {

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java

@@ -92,6 +92,10 @@ public class LoadFileUtil {
         return flag;
     }
 
+    public static void main(String[] args) throws IOException {
+        System.out.println(getMD5("D:\\data\\6ybjAGrL.mp4"));
+    }
+
     /**
      * 获取文件md5
      *

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/ImageCostVO.java

@@ -1,4 +1,4 @@
-package cn.com.ctop.toutiao.modules.report.DTO;
+package cn.com.ctop.common.module.vo;
 
 import lombok.Data;
 
@@ -6,7 +6,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 
 @Data
-public class ImageCostVO implements Serializable {
+public class BytedanceImageCostVO implements Serializable {
     private String statDate;
     private String signature;
     private String projectName;

+ 123 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/BytedanceImageCostVOEntity.java

@@ -0,0 +1,123 @@
+package cn.com.ctop.common.module.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+import java.math.BigDecimal;
+
+public class BytedanceImageCostVOEntity extends BaseRowModel {
+    @ExcelProperty(index = 1, value = "图片链接")
+    private String imageUrl;
+    @ExcelProperty(index = 1, value = "上传时间")
+    private String statDate;
+    @ExcelProperty(index = 1, value = "图片标识")
+    private String signature;
+    @ExcelProperty(index = 1, value = "项目名称")
+    private String projectName;
+    @ExcelProperty(index = 1, value = "消耗")
+    private BigDecimal cost;
+    @ExcelProperty(index = 1, value = "点击数")
+    private Long click;
+    @ExcelProperty(index = 1, value = "展示数")
+    private Long showNum;
+    @ExcelProperty(index = 1, value = "转化数")
+    private Long convert;
+    @ExcelProperty(index = 1, value = "平面id")
+    private String userId;
+    @ExcelProperty(index = 1, value = "平面名称")
+    private String userName;
+
+    public BytedanceImageCostVOEntity() {
+    }
+
+    public BytedanceImageCostVOEntity(BytedanceImageCostVO vo) {
+        this.imageUrl = vo.getImageUrl();
+        this.statDate = vo.getStatDate();
+        this.signature = vo.getSignature();
+        this.projectName = vo.getProjectName();
+        this.cost = vo.getCost();
+        this.click = vo.getClick();
+        this.showNum = vo.getShowNum();
+        this.convert = vo.getConvert();
+    }
+
+    public String getImageUrl() {
+        return imageUrl;
+    }
+
+    public void setImageUrl(String imageUrl) {
+        this.imageUrl = imageUrl;
+    }
+
+    public String getStatDate() {
+        return statDate;
+    }
+
+    public void setStatDate(String statDate) {
+        this.statDate = statDate;
+    }
+
+    public String getSignature() {
+        return signature;
+    }
+
+    public void setSignature(String signature) {
+        this.signature = signature;
+    }
+
+    public String getProjectName() {
+        return projectName;
+    }
+
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+
+    public BigDecimal getCost() {
+        return cost;
+    }
+
+    public void setCost(BigDecimal cost) {
+        this.cost = cost;
+    }
+
+    public Long getClick() {
+        return click;
+    }
+
+    public void setClick(Long click) {
+        this.click = click;
+    }
+
+    public Long getShowNum() {
+        return showNum;
+    }
+
+    public void setShowNum(Long showNum) {
+        this.showNum = showNum;
+    }
+
+    public Long getConvert() {
+        return convert;
+    }
+
+    public void setConvert(Long convert) {
+        this.convert = convert;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+}

+ 24 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouImageCostVO.java

@@ -0,0 +1,24 @@
+package cn.com.ctop.common.module.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class KuaishouImageCostVO implements Serializable {
+    String imageUrl;
+    String signature;
+    String projectName;
+    BigDecimal charge;
+    Long photoClick;
+    Long photoShow;
+    Long activation;
+    Long eventRegister;
+    Long eventPay;
+    Long formCount;
+    Long eventJinJianApp;
+    Long eventCreditGrantApp;
+    String userId;
+    String userName;
+}

+ 167 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/KuaishouImageCostVOEntity.java

@@ -0,0 +1,167 @@
+package cn.com.ctop.common.module.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+import java.math.BigDecimal;
+
+public class KuaishouImageCostVOEntity extends BaseRowModel {
+    @ExcelProperty(index = 1, value = "图片url")
+    String imageUrl;
+    @ExcelProperty(index = 2, value = "图片标识")
+    String signature;
+    @ExcelProperty(index = 3, value = "所属项目")
+    String projectName;
+    @ExcelProperty(index = 4, value = "消耗")
+    BigDecimal charge;
+    @ExcelProperty(index = 5, value = "封面点击数")
+    Long photoClick;
+    @ExcelProperty(index = 6, value = "封面曝光数")
+    Long photoShow;
+    @ExcelProperty(index = 7, value = "激活数")
+    Long activation;
+    @ExcelProperty(index = 8, value = "注册数")
+    Long eventRegister;
+    @ExcelProperty(index = 9, value = "付费数")
+    Long eventPay;
+    @ExcelProperty(index = 10, value = "表单提交数")
+    Long formCount;
+    @ExcelProperty(index = 11, value = "完件数")
+    Long eventJinJianApp;
+    @ExcelProperty(index = 12, value = "授信数")
+    Long eventCreditGrantApp;
+    @ExcelProperty(index = 13, value = "所属平面id")
+    String userId;
+    @ExcelProperty(index = 14, value = "所属平面")
+    String userName;
+
+    public KuaishouImageCostVOEntity(KuaishouImageCostVO vo) {
+        this.imageUrl = vo.getImageUrl();
+        this.signature = vo.getSignature();
+        this.projectName = vo.getProjectName();
+        this.charge = vo.getCharge();
+        this.photoClick = vo.getPhotoClick();
+        this.photoShow = vo.getPhotoShow();
+        this.activation = vo.getActivation();
+        this.eventRegister = vo.getEventRegister();
+        this.eventPay = vo.getEventPay();
+        this.formCount = vo.getFormCount();
+        this.eventJinJianApp = vo.getEventJinJianApp();
+        this.eventCreditGrantApp = vo.getEventCreditGrantApp();
+    }
+
+    public KuaishouImageCostVOEntity() {
+    }
+
+    public String getImageUrl() {
+        return imageUrl;
+    }
+
+    public void setImageUrl(String imageUrl) {
+        this.imageUrl = imageUrl;
+    }
+
+    public String getSignature() {
+        return signature;
+    }
+
+    public void setSignature(String signature) {
+        this.signature = signature;
+    }
+
+    public String getProjectName() {
+        return projectName;
+    }
+
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+
+    public BigDecimal getCharge() {
+        return charge;
+    }
+
+    public void setCharge(BigDecimal charge) {
+        this.charge = charge;
+    }
+
+    public Long getPhotoClick() {
+        return photoClick;
+    }
+
+    public void setPhotoClick(Long photoClick) {
+        this.photoClick = photoClick;
+    }
+
+    public Long getPhotoShow() {
+        return photoShow;
+    }
+
+    public void setPhotoShow(Long photoShow) {
+        this.photoShow = photoShow;
+    }
+
+    public Long getActivation() {
+        return activation;
+    }
+
+    public void setActivation(Long activation) {
+        this.activation = activation;
+    }
+
+    public Long getEventRegister() {
+        return eventRegister;
+    }
+
+    public void setEventRegister(Long eventRegister) {
+        this.eventRegister = eventRegister;
+    }
+
+    public Long getEventPay() {
+        return eventPay;
+    }
+
+    public void setEventPay(Long eventPay) {
+        this.eventPay = eventPay;
+    }
+
+    public Long getFormCount() {
+        return formCount;
+    }
+
+    public void setFormCount(Long formCount) {
+        this.formCount = formCount;
+    }
+
+    public Long getEventJinJianApp() {
+        return eventJinJianApp;
+    }
+
+    public void setEventJinJianApp(Long eventJinJianApp) {
+        this.eventJinJianApp = eventJinJianApp;
+    }
+
+    public Long getEventCreditGrantApp() {
+        return eventCreditGrantApp;
+    }
+
+    public void setEventCreditGrantApp(Long eventCreditGrantApp) {
+        this.eventCreditGrantApp = eventCreditGrantApp;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+}

+ 6 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyReportTaskServiceImpl.java

@@ -9,6 +9,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskServ
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyGroupMapper;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyImageMapper;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -67,6 +68,7 @@ public class KuaiShouDailyReportTaskServiceImpl extends ServiceImpl<KuaiShouDail
         taskQueryWrapper.eq("task_status", 0);
         taskQueryWrapper.eq("account_id", accountId);
         taskQueryWrapper.eq("stat_date", statDate);
+        taskQueryWrapper.eq("view_type", 7);
         taskQueryWrapper.orderByDesc("create_time");
         List<KuaiShouDailyReportTask> dailyTaskList = this.list(taskQueryWrapper);
         if (!Check.isNull(dailyTaskList)) {
@@ -155,7 +157,8 @@ public class KuaiShouDailyReportTaskServiceImpl extends ServiceImpl<KuaiShouDail
                     };
                     thread.start();
                 }else if(task.getViewType() == 7){
-
+                    //封面报表
+                    kuaishouReportDailyImageMapper.loadImageDailyReport(task.getAccountId(),localPath);
                 }
             }
 
@@ -168,5 +171,7 @@ public class KuaiShouDailyReportTaskServiceImpl extends ServiceImpl<KuaiShouDail
         this.updateById(task);
     }
 
+    @Autowired
+    private KuaishouReportDailyImageMapper kuaishouReportDailyImageMapper;
 
 }

+ 4 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java

@@ -156,7 +156,6 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
     public void getTaskList() {
         log.info("开始历史数据文件检查下载");
         QueryWrapper<KuaiShouHistoryReportTask> taskQueryWrapper = new QueryWrapper<>();
-        taskQueryWrapper.eq("view_type",7);
         taskQueryWrapper.eq("task_status", 0);
         taskQueryWrapper.orderByDesc("create_time");
         List<KuaiShouHistoryReportTask> taskList = this.list(taskQueryWrapper);
@@ -273,13 +272,13 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
     private void getHistoryTypeList() {
 
         historyTypeList = new ArrayList<>();
-        historyTypeList.add(5);
         historyTypeList.add(1);
         historyTypeList.add(2);
         historyTypeList.add(3);
-        historyTypeList.add(10);
         historyTypeList.add(4);
-     //   historyTypeList.add(7);
+        historyTypeList.add(5);
+        historyTypeList.add(7);
+        historyTypeList.add(10);
 
 
     }
@@ -290,16 +289,13 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
         dailyTypeList.add(3);
         dailyTypeList.add(4);
         dailyTypeList.add(5);
+        dailyTypeList.add(7);
         dailyTypeList.add(10);
-//        historyTypeList.add(7);
     }
 
 
     static ExecutorService executorService = Executors.newFixedThreadPool(30);
 
-    @Autowired
-    private ICtopOauthTokenService oauthTokenService;
-
     @Override
     public void getMd5(String statDate, Long accountId) {
         executorService.submit(new Runnable() {

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

@@ -1,8 +1,12 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
+import cn.com.ctop.common.module.vo.KuaishouImageCostVO;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyImage;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * 快手图片报表
  * @author: jeecg-boot
@@ -12,4 +16,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 public interface KuaishouReportDailyImageMapper extends BaseMapper<KuaishouReportDailyImage> {
 
     void loadImageDailyReport(Long accountId, String localPath);
+
+    List<KuaishouImageCostVO> imageCost(String startDate, String endDate, JSONArray accountList, String code);
+
+    void updateImageReportCode();
 }

+ 51 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyImageMapper.xml

@@ -7,10 +7,11 @@
 	    REPLACE INTO TABLE ctop_kuaishou_report_daily_image CHARACTER SET utf8mb4
 		FIELDS TERMINATED BY ',' enclosed by '"' LINES TERMINATED BY '\n'
 		IGNORE 1 LINES
-		(cover_id,
-		image_token,
-		cover_url,
-		@ad_scene,
+		(
+		cover_id,
+        image_token,
+        cover_url,
+        ad_scene,
         charge,
         photo_show,
         aclick,
@@ -28,13 +29,13 @@
         activation,
         submit,
         stat_date,
-        @stat_hour,
+        stat_hour,
         photo_click,
         photo_click_ratio,
         action_ratio,
         impression_1k_cost,
         photo_click_cost,
-        @click_1k_cost,
+        click_1k_cost,
         action_cost,
         event_pay_first_day,
         event_pay_purchase_amount_first_day,
@@ -103,4 +104,48 @@
         )
           set account_id = #{accountId}
     </insert>
+    <select id="imageCost" resultType="cn.com.ctop.common.module.vo.KuaishouImageCostVO">
+        select
+        report.cover_url as 'image_url' ,
+        report.code as 'signature',
+        group_concat(distinct p.project_name) AS 'project_name',
+        sum(report.charge) AS 'charge',
+        sum(report.photo_click) AS 'photo_click',
+        sum(report.photo_show) AS 'photo_show',
+        sum(report.activation) AS 'activation',
+        sum(report.event_register) AS 'event_register',
+        sum(report.event_pay) AS 'event_pay',
+        sum(report.form_count) AS 'form_count',
+        sum(report.event_jin_jian_app) AS 'event_jin_jian_app',
+        sum(report.event_credit_grant_app) AS 'event_credit_grant_app'
+        from ctop_kuaishou_report_daily_image report
+        left join ctop_user_allocation allocation on allocation.account_id = report.account_id
+        left join ctop_project p on p.id = allocation.project_id
+        where
+            1=1
+        and
+            report.code is not null
+        <if test="startDate!=null">
+            and report.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate!=null">
+            and report.stat_date &lt;= #{endDate}
+        </if>
+        <if test="accountList!=null">
+            and report.account_id in
+            <foreach item="accountId" collection="accountList" open="(" separator="," close=")">
+                #{accountId}
+            </foreach>
+        </if>
+        <if test="code!=null">
+            and report.code = #{code}
+        </if>
+        group by report.code
+        order by sum(report.charge) desc
+    </select>
+
+    <update id="updateImageReportCode">
+        update ctop_kuaishou_report_daily_image a inner join  ctop_kuaishou_image_get  image on image.image_token =a.image_token  set a.code = image.signature
+        where a.code is not null;
+    </update>
 </mapper>

+ 5 - 7
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java

@@ -1,7 +1,7 @@
 package cn.com.ctop.toutiao.modules.report.mapper;
 
+import cn.com.ctop.common.module.vo.BytedanceImageCostVO;
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
-import cn.com.ctop.toutiao.modules.report.DTO.ImageCostVO;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportVideoMaterialDaily;
@@ -31,12 +31,10 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
 
     List<BytedanceVideoVo> getVideoVoByDate(@Param("date")String date);
 
-    List<ImageCostVO> bytedanceImageCost(@Param("startDate")String startDate,
-                                         @Param("endDate")String endDate,
-                                         @Param("accountList")JSONArray accountList,
-                                         @Param("code")String code,
-                                         @Param("startIndex")Integer startIndex,
-                                         @Param("pageSize")Integer pageSize);
+    List<BytedanceImageCostVO> bytedanceImageCost(@Param("startDate")String startDate,
+                                                  @Param("endDate")String endDate,
+                                                  @Param("accountList")JSONArray accountList,
+                                                  @Param("code")String code);
 
     void replaceImageBatch(@Param("infos")List<BytedanceReportMaterialDaily> bytedanceReportImageDailyList);
 }

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml

@@ -238,14 +238,14 @@
         ctop_bytedance_report_material_retry
         where status = 0
     </select>
-    <select id="bytedanceImageCost" resultType="cn.com.ctop.toutiao.modules.report.DTO.ImageCostVO">
+    <select id="bytedanceImageCost" resultType="cn.com.ctop.common.module.vo.BytedanceImageCostVO">
         select round(sum(report.cost),2)                              as 'cost',
         sum(report.click)                                             as 'click',
         sum(report.show_material)                                     as 'showNum',
         sum(report.convert_material)                                  as 'convert',
         imageInfo.image_url                                           as 'imageUrl',
         imageInfo.signature                                           as 'signature',
-        group_concat(distinct report.project_name)                as 'projectName',
+        group_concat(distinct report.project_name)                    as 'projectName',
         report.stat_datetime                                          as 'statDate'
             from ctop_bytedance_report_image_daily report
             left join ctop_bytedance_image_info imageInfo on imageInfo.material_id = report.material_id

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

@@ -30,6 +30,9 @@ public class BytedanceFundDailyServiceImpl extends ServiceImpl<BytedanceFundDail
     public void loadFundDataByPage(CtopOauthToken token, String startDate, String endDate, Integer pageNum) {
         Integer pageSize = 100;
         JSONObject result = getAdvertiserFundDailyStat(token, startDate, endDate, pageNum, pageSize);
+        if(null == result||result.isEmpty()){
+            return;
+        }
         var code = result.getInteger("code");
         var message = result.getString("message");
         if (null == code || code != 0) {

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

@@ -82,6 +82,7 @@ public class ReportServiceImpl implements IReportService {
         config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
         JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
         JSONObject getObject = getAdvertiserStat(token, jsonObject);
+        System.out.println(getObject);
         if(null == getObject){
             XxlJobLogger.log("头条广告主数据获取异常");
             return;