Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
syh 4 years ago
parent
commit
56cf7fc182
63 changed files with 3259 additions and 560 deletions
  1. 2 2
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/MD5Util.java
  2. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 34 124
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  4. 0 55
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouSuZaoLoadJob.java
  5. 10 9
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/orderplatform/mapper/xml/PlatformScriptMapper.xml
  6. 79 44
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  7. 44 0
      module-common/src/main/java/cn/com/ctop/common/module/enums/SceneIdEnum.java
  8. 16 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  9. 50 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BaseReportVideoDailyLoadJob.java
  10. 1 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceMaterialsLoadJob.java
  11. 30 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ETLReportVideoCleanJob.java
  12. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiSuzaoVideoJob.java
  13. 0 34
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSuZaoLoadJob.java
  14. 349 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaiShouAppInfoController.java
  15. 7 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreativeRefusalController.java
  16. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java
  17. 122 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaiShouAppInfo.java
  18. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaiShouAppInfoMapper.java
  19. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaiShouAppInfoMapper.xml
  20. 22 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaiShouAppInfoService.java
  21. 283 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaiShouAppInfoServiceImpl.java
  22. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java
  23. 2 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  24. 1 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouBatchCampaignPreviewController.java
  25. 26 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouBatchGroupPreviewController.java
  26. 11 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java
  27. 8 42
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  28. 5 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchCampaignPreview.java
  29. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchCreativePreview.java
  30. 26 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchGroupPreview.java
  31. 8 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  32. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouMaterialUploadService.java
  33. 2 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  34. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/ISyncPullMaterialService.java
  35. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouMaterialUploadServiceImpl.java
  36. 163 13
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouBatchCampaignPreviewServiceImpl.java
  37. 145 102
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  38. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java
  39. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouVideoRelateCreativesServiceImpl.java
  40. 0 28
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/SyncPullMaterialServiceImpl.java
  41. 330 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouGroupExploreController.java
  42. 112 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouGroupExplore.java
  43. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAgent.java
  44. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouGroupExploreMapper.java
  45. 14 14
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouDailyAgentMapper.xml
  46. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouGroupExploreMapper.xml
  47. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouGroupExploreService.java
  48. 228 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouGroupExploreServiceImpl.java
  49. 196 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/entity/BaseReportBytedanceVideoDaily.java
  50. 436 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/entity/ETLReportBytedanceVideo.java
  51. 11 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/BaseReportBytedanceVideoDailyMapper.java
  52. 29 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/ETLReportBytedanceVideoMapper.java
  53. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/BaseReportBytedanceVideoDailyMapper.xml
  54. 109 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/ETLReportBytedanceVideoMapper.xml
  55. 11 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/IBaseReportBytedanceVideoDailyService.java
  56. 17 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/IETLReportBytedanceVideoService.java
  57. 15 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/impl/BaseReportBytedanceVideoDailyServiceImpl.java
  58. 105 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/impl/ETLReportBytedanceVideoServiceImpl.java
  59. 25 43
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceVideoReportMapper.xml
  60. 3 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceVideoReportService.java
  61. 0 5
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java
  62. 67 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceVideoReportServiceImpl.java
  63. 4 4
      module-toutiao/src/main/resources/json_template/bytedance_video_report_mapping.json

+ 2 - 2
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/MD5Util.java

@@ -28,10 +28,10 @@ public class MD5Util {
 		}
 		}
 		return String.valueOf(str);
 		return String.valueOf(str);
 	}
 	}
-	public static String getMd5(String msg) {
+	public static String getMd5(String url) {
 		MessageDigest md5 = MD5.get();
 		MessageDigest md5 = MD5.get();
 		md5.reset();
 		md5.reset();
-		return toHexStr(md5.digest(msg.getBytes()));
+		return toHexStr(md5.digest(url.getBytes()));
 	}
 	}
 
 
 	public static String byteArrayToHexString(byte b[]) {
 	public static String byteArrayToHexString(byte b[]) {

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -187,6 +187,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/batch/kuaiShouGroupTemplate/*", "anon");
         filterChainDefinitionMap.put("/batch/kuaiShouGroupTemplate/*", "anon");
         filterChainDefinitionMap.put("/kuaishouBatch/**", "anon");
         filterChainDefinitionMap.put("/kuaishouBatch/**", "anon");
         filterChainDefinitionMap.put("/kuaishou/creative/*", "anon");
         filterChainDefinitionMap.put("/kuaishou/creative/*", "anon");
+        filterChainDefinitionMap.put("/ai/aiKuaiShouAppInfo/*", "anon");
+        filterChainDefinitionMap.put("/explore/*", "anon");
 
 
         // 添加自己的过滤器并且取名为jwt
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 34 - 124
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -17,7 +17,6 @@ import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
@@ -36,8 +35,6 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
@@ -112,9 +109,36 @@ public class TestController {
     private IBindAccountAuthService bindAccountAuthService;
     private IBindAccountAuthService bindAccountAuthService;
     @Autowired
     @Autowired
     private UserAllocationMapper allocationMapper;
     private UserAllocationMapper allocationMapper;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+
+    @GetMapping("/loadMatData")
+    public Map<String, Object> getData(String startDate, String endDate, Long accountId) {
+        Map<String, Object> result = new HashMap<>();
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        Date start = DateUtils.parseDate(startDate, "yyyy-MM-dd");
+        int days = DateUtils.getdaysOfTwoDate(startDate, endDate) + 1;
+        for (int i = 0; i < days; i++) {
+            String getDate = DateUtils.formatDate(DateUtils.addDay(start, i));
+            // bytedanceReportService.bytedanceMaterialReport(token, getDate, getDate);
+
+            suzhaoService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    bytedanceReportService.bytedanceMaterialReport(token, getDate, getDate);
+
+                }
+            });
+
+        }
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
 
 
     @GetMapping("/testKuaishou")
     @GetMapping("/testKuaishou")
-    public String kuaishouCallback( @RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
+    public String kuaishouCallback(@RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
         try {
         try {
             JSONObject json = JSONObject.parseObject(state);
             JSONObject json = JSONObject.parseObject(state);
             if (Check.isNull(json)) {
             if (Check.isNull(json)) {
@@ -224,14 +248,14 @@ public class TestController {
 
 
 
 
     @GetMapping("/getBytedanceMatReport")
     @GetMapping("/getBytedanceMatReport")
-    public Map<String,Object>getData(){
+    public Map<String, Object> getData() {
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         executorService = Executors.newFixedThreadPool(10);
         executorService = Executors.newFixedThreadPool(10);
         CountDownLatch countDownLatch = new CountDownLatch(tokens.size());
         CountDownLatch countDownLatch = new CountDownLatch(tokens.size());
         tokens.forEach(record -> executorService.submit(() -> {
         tokens.forEach(record -> executorService.submit(() -> {
             try {
             try {
-                reportService.getAdvertiserReport(record, DateUtils.parseDate("2021-01-01","yyyy-MM-dd"), DateUtils.parseDate("2021-01-31","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-                log.info("账户数据获取完成:account:{},时间:{}-{}",record.getAccountId(),"2021-01-01","2020-01-31");
+                reportService.getAdvertiserReport(record, DateUtils.parseDate("2021-01-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                log.info("账户数据获取完成:account:{},时间:{}-{}", record.getAccountId(), "2021-01-01", "2020-01-31");
             } catch (Exception e) {
             } catch (Exception e) {
 
 
             } finally {
             } finally {
@@ -249,8 +273,8 @@ public class TestController {
 //        bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
 //        bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
 //        bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
 //        bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
 //        bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
 //        bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
-        Map<String,Object> result =  new HashMap<>();
-        ResultMapUtils.setResultMap(new HashMap<>(),StatusCode.COMMON_SUCCESS);
+        Map<String, Object> result = new HashMap<>();
+        ResultMapUtils.setResultMap(new HashMap<>(), StatusCode.COMMON_SUCCESS);
         return result;
         return result;
     }
     }
 
 
@@ -649,38 +673,6 @@ public class TestController {
         return "success";
         return "success";
     }
     }
 
 
-
-    @GetMapping(value = "/getSuZhao")
-    public void getSuZhao() throws JobExecutionException {
-        try {
-            //1:查询当日数据
-            QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("media_id", 2);
-            queryWrapper.orderByDesc("create_time");
-            List<CtopOauthToken> tokens = tokenService.list(queryWrapper);
-            if (null == tokens || tokens.size() <= 0) {
-                log.info("定时获取快手数据异常:未获取到可用的token");
-                return;
-            }
-
-            tokens.forEach(token -> {
-                suzhaoService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        //1: 获取广告主信息数据
-                        log.info("获取素造素材:accountId:{}", token.getAccountId());
-                        kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
-                    }
-                });
-            });
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-
-    }
-
-
     @GetMapping(value = "/getAccountList")
     @GetMapping(value = "/getAccountList")
     public void getAccountList(String startDate, String endDate) throws JobExecutionException {
     public void getAccountList(String startDate, String endDate) throws JobExecutionException {
         Thread thread = new Thread() {
         Thread thread = new Thread() {
@@ -719,91 +711,9 @@ public class TestController {
     }
     }
 
 
 
 
-    @GetMapping(value = "/getVideo")
-    public String getVideo(String startDate, String endDate) throws IOException {
-        try {
-            Thread thread = new Thread() {
-                @Override
-                public void run() {
-                    QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
-                    tokenQueryWrapper.eq("media_id", 2);
-                    List<CtopOauthToken> list = tokenService.list(tokenQueryWrapper);
-                    list.forEach(token -> {
-                        videoService.submit(new Runnable() {
-                            @Override
-                            public void run() {
-                                try {
-                                    kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
-                                    kuaishouInterfaceService.getVideoList(token, null, null);
-                                    Thread.sleep(5000);
-                                     /*String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-                                    String videoEndDate = DateUtils.addDay(nowDate, -180);
-                                   SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                                    Date end = simpleDateFormat.parse(nowDate);
-                                    Date start = simpleDateFormat.parse(videoEndDate);
-                                    List<Date> dates = DateUtils.findDates(start, end);
-                                    for (int i = 0; i < dates.size(); i++) {
-                                        String formatDate = simpleDateFormat.format(dates.get(i));
-                                        kuaishouInterfaceService.getImageList(token, formatDate);
-                                        Thread.sleep(500);
-                                    }*/
-
-                                } catch (Exception e) {
-                                    e.printStackTrace();
-                                } finally {
-                                }
-                            }
-                        });
-                    });
-                    log.info("快手物料数据同步完成");
-                }
-            };
-            thread.start();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return "Success";
-    }
 
 
 
 
-    @GetMapping(value = "/getVideoByAccountId")
-    public String getVideoByAccountId(Long accountId) throws IOException {
-        try {
-            Thread thread = new Thread() {
-                @Override
-                public void run() {
-                    QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
-                    tokenQueryWrapper.eq("media_id", 2);
-                    tokenQueryWrapper.eq("account_id", accountId);
-                    CtopOauthToken one = tokenService.getOne(tokenQueryWrapper);
-                    try {
-                        kuaishouInterfaceService.getSuZaoList(one.getAccessToken(), one.getAccountId(), 1, null, null);
-                        kuaishouInterfaceService.getVideoList(one, null, null);
-                        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-                        String videoEndDate = DateUtils.addDay(nowDate, -180);
-                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                        Date end = simpleDateFormat.parse(nowDate);
-                        Date start = simpleDateFormat.parse(videoEndDate);
-                        List<Date> dates = DateUtils.findDates(start, end);
-                        for (int i = 0; i < dates.size(); i++) {
-                            String formatDate = simpleDateFormat.format(dates.get(i));
-
-                            kuaishouInterfaceService.getImageList(one, formatDate);
-                            Thread.sleep(100);
-                        }
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                    }
-                    log.info("快手物料数据同步完成");
-                }
-            };
-            thread.start();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return "Success";
-    }
+
 
 
 
 
     @GetMapping(value = "/createCutTask")
     @GetMapping(value = "/createCutTask")

+ 0 - 55
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouSuZaoLoadJob.java

@@ -1,55 +0,0 @@
-package org.jeecg.modules.ctop.job;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-@Slf4j
-public class KuaishouSuZaoLoadJob implements Job {
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
-    static ExecutorService executorService = null;
-
-    @Override
-    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        Thread thread = new Thread() {
-            @Override
-            public void run() {
-                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-                executorService = Executors.newFixedThreadPool(8);
-                tokens.forEach(token -> {
-                    executorService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            try {
-                                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-                                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, 1);
-                                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
-                                kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate);
-                            } catch (Exception e) {
-                                e.printStackTrace();
-                            } finally {
-                            }
-                        }
-                    });
-                });
-                log.info("快手素造数据同步完成");
-            }
-        };
-        thread.start();
-
-    }
-}

+ 10 - 9
jeecg-boot-module-system/src/main/java/org/jeecg/modules/orderplatform/mapper/xml/PlatformScriptMapper.xml

@@ -4,17 +4,18 @@
 
 
     <select id="pageQuery" resultType="com.alibaba.fastjson.JSONObject">
     <select id="pageQuery" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         SELECT
-        t1.id,
-        t1.`name`,
-        t1.size,
-        t1.create_time,
+            t1.id,
+            t1.`name`,
+            t1.size,
+            t1.create_time,
         FROM_UNIXTIME(ROUND((t1.create_time/1000),0)) as createTime,
         FROM_UNIXTIME(ROUND((t1.create_time/1000),0)) as createTime,
-        (SELECT realname from sys_user where id=t1.creator limit 1) as creatorName,
-        (SELECT project_name from ctop_project where id=t1.project_id limit 1) as projectName,
-        t2.material_name as materialName
+            (SELECT realname from sys_user where id=t1.creator limit 1) as creatorName,
+            (SELECT project_name from ctop_project where id=t1.project_id limit 1) as projectName,
+            t2.material_name as materialName
+
         FROM
         FROM
-        ctop_platform_script t1
-        LEFT JOIN ctop_platform_material t2 ON t1.id = t2.script_id
+            ctop_platform_script t1
+                LEFT JOIN ctop_platform_material t2 ON t1.id = t2.script_id
         where t2.material_code is not null
         where t2.material_code is not null
         <if test="projectId != null">
         <if test="projectId != null">
             AND t1.project_id= #{projectId}
             AND t1.project_id= #{projectId}

+ 79 - 44
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -3,8 +3,9 @@ package org.jeecg;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.entity.UserAllocation;
-import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
-import cn.com.ctop.common.module.service.*;
+import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
@@ -17,6 +18,7 @@ import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatUserListService;
 import cn.com.ctop.oa.modules.service.IWechatUserListService;
+import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
@@ -44,7 +46,7 @@ import static org.jeecg.common.util.DateUtils.getAnotherDay;
 
 
 @RunWith(SpringRunner.class)
 @RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ActiveProfiles("wps")
+@ActiveProfiles("dev")
 @Slf4j
 @Slf4j
 public class SampleTest {
 public class SampleTest {
     @Autowired
     @Autowired
@@ -63,47 +65,36 @@ public class SampleTest {
     private IBindAccountLoginService bindAccountLoginService;
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
-    @Autowired
-    private IOauthConfigService configService;
-    @Autowired
-    private CtopOauthTokenMapper oauthTokenMapper;
-    @Autowired
-    private IKuaishouInterfaceService iKuaishouInterfaceService;
-    @Autowired
-    private IRefreshTokenService refreshTokenService;
+ /*   @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
+
+*/
 
 
 
 
     @Test
     @Test
     public void loadBytedanceCreativeData() throws ParseException {
     public void loadBytedanceCreativeData() throws ParseException {
-        CtopOauthToken token = oauthTokenMapper.selectByAccountId(9784689L);
+        //    1662234704806924
+       /* CtopOauthToken token = new CtopOauthToken();
+        token.setAccountId(9549277L);
+        token.setAccessToken("bc5327c8f2bd8a67513e51148c9206c8");
 
 
-        refreshTokenService.getKuaiShouRefresh();
 
 
 
 
-     //   iKuaishouInterfaceService.getVideoList(token, null, null);
-
-      /*  List<CtopOauthToken> oauthTokens = oauthTokenMapper.selectKuaiShouTokens(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (!Check.isNull(oauthTokens)) {
-            Map<Long, String> configMap = configService.getConfigMapByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
-            for (CtopOauthToken oauthToken : oauthTokens) {
-                XxlJobHelper.log("刷新token,accountId:{}", oauthToken.getAccountId());
-                //快手
-                if (CtopAdConstant.PLATFORM_TYPE_KUAISHOU.equals(oauthToken.getMediaId().trim())) {
-                    String secret = configMap.get(oauthToken.getAppId());
-                    System.err.println(secret);
-                    oauthTokenService.getKuaiShouRefreshToken(oauthToken.getAccountId(), oauthToken.getAccessToken(), oauthToken.getRefreshToken(), oauthToken.getAppId(), secret);
-                }
-            }
-        } else {
-            XxlJobHelper.log("----------------------刷新token获取数据返回结果为空----------------------------------");
-        }*/
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date parse = simpleDateFormat.parse("2021-02-02");
+        kuaishouInterfaceService.getAdvertiserReportDaily(token, parse, parse);*/
 
 
+        CtopOauthToken token = new CtopOauthToken();
+        token.setAccountId(9767055L);
+        token.setAccessToken("28e4e6b124e1443d6971ba4c699de6c9");
 
 
-      /*  Map<Long, String> configMap = configService.getConfigMapByMediaId(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT);
-        System.err.println(configMap);*/
+        kuaishouInterfaceService.getVideoList(token, null, null);
+        kuaishouInterfaceService.getVideoInfo("28e4e6b124e1443d6971ba4c699de6c9",9767055L,"5208131540349742192");
 
 
-
-      /*  List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
+     /*   CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1662234704806924L);
+        advertiserDataService.getMaterialList(tokenByAccountId);*/
+       /* getVideoByPage(token, "", 1);
+        List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
         if (!Check.isNull(KuaiShouVideoGets)) {
         if (!Check.isNull(KuaiShouVideoGets)) {
             JSONArray dateList = new JSONArray();
             JSONArray dateList = new JSONArray();
             JSONArray photoIds = new JSONArray();
             JSONArray photoIds = new JSONArray();
@@ -292,16 +283,6 @@ public class SampleTest {
     }
     }
 
 
     @Test
     @Test
-    public void testData11() {
-        CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
-        int dimeDiff = 5;
-        Date now = new Date();
-        String startTime = DateUtils.formatDate("2021-01-11 18:25:00");
-        String endTime = DateUtils.formatDate(now, "2021-01-11 18:35:00");
-        kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime, endTime);
-    }
-
-    @Test
     public void loadKuaishouAgentData() {
     public void loadKuaishouAgentData() {
         kuaishouReportDailyAgentService.loginAgent();
         kuaishouReportDailyAgentService.loginAgent();
         try {
         try {
@@ -632,4 +613,58 @@ public class SampleTest {
         CtopOauthToken token = tokenService.getTokenByAccountId(1660666858777607L);
         CtopOauthToken token = tokenService.getTokenByAccountId(1660666858777607L);
         reportService.getAdvertiserPlanReport(token, DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         reportService.getAdvertiserPlanReport(token, DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
     }
     }
+
+    @Autowired
+    IBytedanceVideoReportService bytedanceVideoReportService;
+
+    @Test
+    public void etlBytedanceVideoReport() {
+
+//        for (int i = 1; i <= 62; i++) {
+//            etlBytedanceVideo(DateUtils.formatDate(DateUtils.addDay(new Date(), -i)));
+//        }
+        etlBytedanceVideo("2021-02-03");
+
+    }
+
+    private void etlBytedanceVideo(String statDate) {
+        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
+        executorService = Executors.newFixedThreadPool(10);
+        countDownLatch = new CountDownLatch(tokens.size());
+        tokens.forEach(token -> executorService.submit(() -> {
+            try {
+                bytedanceVideoReportService.pullVideoReport(token, statDate, statDate, 1);
+            } catch (Exception e) {
+
+            } finally {
+                countDownLatch.countDown();
+            }
+        }));
+        try {
+            countDownLatch.await();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Autowired
+    IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
+
+    @Test
+    public void etlBytedanceVideoReportClean() {
+        //for (int i = 1; i <= 1; i++) {
+          //  String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
+            ietlReportBytedanceVideoService.cleanETL("2020-12-31");
+        //}
+    }
+
+    @Test
+    public void etlBytedanceVideoReportClean1() {
+        //executorService = Executors.newFixedThreadPool(31);
+        //countDownLatch = new CountDownLatch(31);
+        for (int i = 3; i <= 31; i++) {
+            String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
+            ietlReportBytedanceVideoService.cleanETL(statDate);
+        }
+    }
 }
 }

+ 44 - 0
module-common/src/main/java/cn/com/ctop/common/module/enums/SceneIdEnum.java

@@ -0,0 +1,44 @@
+package cn.com.ctop.common.module.enums;
+
+/**
+ * 条件枚举
+ *
+ * @param
+ * @author ZHAOXA
+ * @return
+ * @throws
+ */
+public enum SceneIdEnum {
+    ONE(1, "优选广告位"),
+    THREE(3, "视频播放页广告"),
+    FIVE(5, "联盟广告"),
+    SIX(6, "上下滑大屏广告"),
+    SEVEN(7, "信息流广告"),
+    TEN(10, "激励视频"),
+    ELEVEN(11, "快看点场景");
+
+    private Integer id;
+    private String name;
+
+    private SceneIdEnum(Integer id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    public static SceneIdEnum getEnumById(Integer id) {
+        for (SceneIdEnum em : SceneIdEnum.values()) {
+            if (em.id == id) {
+                return em;
+            }
+        }
+        return null;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+}

+ 16 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -322,5 +322,21 @@ public class KuaishouInterfaceConstant {
      * 频库-视频关联创意数查询
      * 频库-视频关联创意数查询
      */
      */
     public static final String VIDEO_RELATE_CREATIVES = "/rest/openapi/v1/file/ad/video/relate/creatives";
     public static final String VIDEO_RELATE_CREATIVES = "/rest/openapi/v1/file/ad/video/relate/creatives";
+/**
+     * 查询加速探索信息接口
+     */
+    public static final String UNIT_EXPLORE_INFO_GET = "/rest/openapi/v1/ad_unit/explore/info/get";
+/**
+     * 广告组的加速探索预算设置
+     */
+    public static final String UNIT_EXPLORE_BUDGET_UPDATE = "/rest/openapi/v1/ad_unit/explore/budget/update";
+/**
+     * 暂停广告组的加速探索预算
+     */
+    public static final String UNIT_EXPLORE_STATUS_PAUSE = "/rest/openapi/v1/ad_unit/explore/status/pause";
+/**
+     * 查询广告组的加速探索报表接口
+     */
+    public static final String QUERY_SPEED_EXPLORE_REPORT = "/rest/openapi/v1/report/speed_explore";
 
 
 }
 }

+ 50 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BaseReportVideoDailyLoadJob.java

@@ -0,0 +1,50 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoReportService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class BaseReportVideoDailyLoadJob {
+
+    @Autowired
+    ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    IBytedanceVideoReportService bytedanceVideoReportService;
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+    private CountDownLatch countDownLatch;
+    @XxlJob("baseReportVideoDailyLoadJob")
+    public void execute() throws Exception {
+        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
+        countDownLatch = new CountDownLatch(tokens.size());
+        String statDate= DateUtils.formatDate(DateUtils.addDay(new Date(), -1));
+        tokens.forEach(token -> executorService.submit(() -> {
+            try {
+                bytedanceVideoReportService.pullVideoReport(token,statDate,statDate,1);
+            } catch (Exception e) {
+                XxlJobHelper.log("头条视频报表基础数据拉取异常:{}",e.getMessage());
+            } finally {
+                countDownLatch.countDown();
+            }
+        }));
+        try {
+            countDownLatch.await();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        if(!executorService.isShutdown()){
+            executorService.shutdown();
+        }
+    }
+}

+ 1 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceMaterialsLoadJob.java

@@ -17,7 +17,7 @@ import java.util.concurrent.Executors;
 public class BytedanceMaterialsLoadJob {
 public class BytedanceMaterialsLoadJob {
     @Autowired
     @Autowired
     private ICtopOauthTokenService tokenService;
     private ICtopOauthTokenService tokenService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(4);
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
     //线程计数器
     //线程计数器
     static CountDownLatch countDownLatch = null;
     static CountDownLatch countDownLatch = null;
     @Autowired
     @Autowired

+ 30 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ETLReportVideoCleanJob.java

@@ -0,0 +1,30 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+@Component
+public class ETLReportVideoCleanJob {
+
+    @Autowired
+    IETLReportBytedanceVideoService etlReportBytedanceVideoService;
+
+    @XxlJob("ETLReportVideoCleanJob")
+    public void execute() throws Exception {
+        String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -1));
+        try {
+            etlReportBytedanceVideoService.cleanETL(statDate);
+        } catch (Exception e) {
+            XxlJobHelper.log("头条视频报表基础数据拉取异常:{}", e.getMessage());
+        } finally {
+            XxlJobHelper.log("ETLReportVideoCleanJob is finish");
+        }
+    }
+}
+

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAiSuzaoVideoJob.java

@@ -37,7 +37,7 @@ public class KuaishouAiSuzaoVideoJob {
             Long now = System.currentTimeMillis();
             Long now = System.currentTimeMillis();
             String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
             String startTime = DateUtils.formatDate(new Date(now + timeStart*60*1000),"yyyy-MM-dd HH:mm:ss");
             String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
             String endTime = DateUtils.formatDate(new Date(now + timeEnd*60*1000),"yyyy-MM-dd HH:mm:ss");
-            kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime,endTime);
+           // kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime,endTime);
         });
         });
     }
     }
 }
 }

+ 0 - 34
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSuZaoLoadJob.java

@@ -1,34 +0,0 @@
-package cn.com.ctop.job.kuaishou.handler;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.xxl.job.core.context.XxlJobHelper;
-import com.xxl.job.core.handler.annotation.XxlJob;
-import org.jeecg.common.util.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-@Component
-public class KuaishouSuZaoLoadJob {
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(8);
-    @XxlJob("kuaishouSuZao")
-    public void execute() throws Exception {
-        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, 1);
-        String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
-        tokens.forEach(token -> executorService.submit(() -> kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate)));
-        XxlJobHelper.log("快手素造数据同步完成");
-    }
-
-
-}

+ 349 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaiShouAppInfoController.java

@@ -0,0 +1,349 @@
+package cn.com.ctop.kuaishou.modules.ai.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
+import com.alibaba.fastjson.JSON;
+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 io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * ai批量上传应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-02-02
+ */
+@Slf4j
+@Api(tags = "ai批量上传应用")
+@RestController
+@RequestMapping("/ai/aiKuaiShouAppInfo")
+public class AiKuaiShouAppInfoController {
+    @Autowired
+    private IAiKuaiShouAppInfoService aiKuaiShouAppInfoService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+
+    @PostMapping(value = "/getAppDetail")
+    public JSONObject getAppDetail(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请输入账户");
+            }
+            Long appId = requestJson.getLong("appId");
+            if (Check.isNull(appId)) {
+                throw new Exception("请传入appId");
+            }
+            QueryWrapper<AiKuaiShouAppInfo> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("account_id", accountId);
+            queryWrapper.eq("app_id", appId);
+            queryWrapper.last("limit 1");
+            AiKuaiShouAppInfo appInfo = aiKuaiShouAppInfoService.getOne(queryWrapper);
+            if (Check.isNull(appInfo)) {
+                throw new Exception("通过appId未获取到相关信息");
+            }
+            returnJson.put("code", 0);
+            returnJson.put("message", "success");
+            returnJson.put("data", appInfo);
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
+    @PostMapping(value = "/importAppExcel")
+    public JSONObject importExcel(@RequestParam("file") MultipartFile file,
+                                  @RequestParam("accountId") Long accountId,
+                                  @RequestParam("platform") Integer platform,
+                                  @RequestParam("imageToken") String imageToken) {
+        FileInputStream fis = null;
+        JSONObject returnJson = new JSONObject();
+        try {
+            CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            returnJson = aiKuaiShouAppInfoService.importExcel(file, accountId, imageToken, platform, oauthToken.getAccessToken());
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        } finally {
+            if (fis != null) {
+                try {
+                    fis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return returnJson;
+    }
+
+    /**
+     * 上传应用头像
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/uploadAppIconImage")
+    public JSONObject uploadAppIconImage(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            String url = requestJson.getString("url");
+            if (Check.isNull(url)) {
+                throw new Exception("请传入素材url");
+            }
+            returnJson = aiKuaiShouAppInfoService.uploadAppIconImage(url, accountId, oauthToken.getAccessToken());
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    @GetMapping(value = "/appCreate")
+    public void appCreate(Long accountId, String accessToken) {
+        aiKuaiShouAppInfoService.appCreative(accountId, accessToken);
+    }
+
+
+    /**
+     * 分页列表查询
+     *
+     * @param aiKuaiShouAppInfo
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "ai批量上传应用-分页列表查询")
+    @ApiOperation(value = "ai批量上传应用-分页列表查询", notes = "ai批量上传应用-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<AiKuaiShouAppInfo>> queryPageList(AiKuaiShouAppInfo aiKuaiShouAppInfo,
+                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                          HttpServletRequest req) {
+        Result<IPage<AiKuaiShouAppInfo>> result = new Result<>();
+        QueryWrapper<AiKuaiShouAppInfo> queryWrapper = QueryGenerator.initQueryWrapper(aiKuaiShouAppInfo, req.getParameterMap());
+        Page<AiKuaiShouAppInfo> page = new Page<AiKuaiShouAppInfo>(pageNo, pageSize);
+        IPage<AiKuaiShouAppInfo> pageList = aiKuaiShouAppInfoService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param aiKuaiShouAppInfo
+     * @return
+     */
+    @AutoLog(value = "ai批量上传应用-添加")
+    @ApiOperation(value = "ai批量上传应用-添加", notes = "ai批量上传应用-添加")
+    @PostMapping(value = "/add")
+    public Result<AiKuaiShouAppInfo> add(@RequestBody AiKuaiShouAppInfo aiKuaiShouAppInfo) {
+        Result<AiKuaiShouAppInfo> result = new Result<>();
+        try {
+            aiKuaiShouAppInfoService.save(aiKuaiShouAppInfo);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param aiKuaiShouAppInfo
+     * @return
+     */
+    @AutoLog(value = "ai批量上传应用-编辑")
+    @ApiOperation(value = "ai批量上传应用-编辑", notes = "ai批量上传应用-编辑")
+    @PutMapping(value = "/edit")
+    public Result<AiKuaiShouAppInfo> edit(@RequestBody AiKuaiShouAppInfo aiKuaiShouAppInfo) {
+        Result<AiKuaiShouAppInfo> result = new Result<AiKuaiShouAppInfo>();
+        AiKuaiShouAppInfo aiKuaiShouAppInfoEntity = aiKuaiShouAppInfoService.getById(aiKuaiShouAppInfo.getId());
+        if (aiKuaiShouAppInfoEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = aiKuaiShouAppInfoService.updateById(aiKuaiShouAppInfo);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "ai批量上传应用-通过id删除")
+    @ApiOperation(value = "ai批量上传应用-通过id删除", notes = "ai批量上传应用-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            aiKuaiShouAppInfoService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "ai批量上传应用-批量删除")
+    @ApiOperation(value = "ai批量上传应用-批量删除", notes = "ai批量上传应用-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<AiKuaiShouAppInfo> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<AiKuaiShouAppInfo> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.aiKuaiShouAppInfoService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "ai批量上传应用-通过id查询")
+    @ApiOperation(value = "ai批量上传应用-通过id查询", notes = "ai批量上传应用-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<AiKuaiShouAppInfo> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<AiKuaiShouAppInfo> result = new Result<>();
+        AiKuaiShouAppInfo aiKuaiShouAppInfo = aiKuaiShouAppInfoService.getById(id);
+        if (aiKuaiShouAppInfo == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(aiKuaiShouAppInfo);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<AiKuaiShouAppInfo> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                AiKuaiShouAppInfo aiKuaiShouAppInfo = JSON.parseObject(deString, AiKuaiShouAppInfo.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(aiKuaiShouAppInfo, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<AiKuaiShouAppInfo> pageList = aiKuaiShouAppInfoService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "ai批量上传应用列表");
+        mv.addObject(NormalExcelConstants.CLASS, AiKuaiShouAppInfo.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("ai批量上传应用列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<AiKuaiShouAppInfo> listAiKuaiShouAppInfos = ExcelImportUtil.importExcel(file.getInputStream(), AiKuaiShouAppInfo.class, params);
+                aiKuaiShouAppInfoService.saveBatch(listAiKuaiShouAppInfos);
+                return Result.ok("文件导入成功!数据行数:" + listAiKuaiShouAppInfos.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 7 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouCreativeRefusalController.java

@@ -42,7 +42,7 @@ public class KuaiShouCreativeRefusalController {
     private IKuaiShouImageGetService imageGetService;
     private IKuaiShouImageGetService imageGetService;
     @Autowired
     @Autowired
     private IKuaiShouMaterialUploadService uploadService;
     private IKuaiShouMaterialUploadService uploadService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(100);
+    static ExecutorService executorService = Executors.newFixedThreadPool(80);
 
 
     /**
     /**
      * 创意拒审重提
      * 创意拒审重提
@@ -51,7 +51,7 @@ public class KuaiShouCreativeRefusalController {
      * @return
      * @return
      */
      */
     @PostMapping(value = "again")
     @PostMapping(value = "again")
-    public JSONObject campaignCreate(@RequestBody JSONObject requestJson) {
+    public JSONObject again(@RequestBody JSONObject requestJson) {
         JSONObject returnJson = new JSONObject();
         JSONObject returnJson = new JSONObject();
         try {
         try {
             if (Check.isNull(requestJson)) {
             if (Check.isNull(requestJson)) {
@@ -104,6 +104,11 @@ public class KuaiShouCreativeRefusalController {
                             } else {
                             } else {
                                 log.info("自动投放拒审重提失败,accountId:{},creativeId:{}", accountId, creativeId);
                                 log.info("自动投放拒审重提失败,accountId:{},creativeId:{}", accountId, creativeId);
                             }
                             }
+                            try {
+                                Thread.sleep(1000L);
+                            } catch (InterruptedException e) {
+                                e.printStackTrace();
+                            }
                         }
                         }
                     }
                     }
                 });
                 });

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/KuaiShouMaterialControer.java

@@ -63,7 +63,7 @@ public class KuaiShouMaterialControer {
             }
             }
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             iKuaishouInterfaceService.getVideoList(token, nowDate, nowDate);
             iKuaishouInterfaceService.getVideoList(token, nowDate, nowDate);
-            iKuaishouInterfaceService.getSuZaoList(token.getAccessToken(), accountId, 1, nowDate, nowDate);
+          //  iKuaishouInterfaceService.getSuZaoList(token.getAccessToken(), accountId, 1, nowDate, nowDate);
             KuaiShouVideoLastTime videoLastTime = lastTimeService.getById(accountId);
             KuaiShouVideoLastTime videoLastTime = lastTimeService.getById(accountId);
             Date startTime;
             Date startTime;
             Date endDate = new Date();
             Date endDate = new Date();

+ 122 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaiShouAppInfo.java

@@ -0,0 +1,122 @@
+package cn.com.ctop.kuaishou.modules.ai.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * ai批量上传应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-02-02
+ */
+@Data
+@TableName("ctop_ai_kuaishou_app_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_ai_kuaishou_app_info对象", description = "ai批量上传应用")
+public class AiKuaiShouAppInfo {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户id
+     */
+    @Excel(name = "账户id", width = 15)
+    @ApiModelProperty(value = "账户id")
+    private Long accountId;
+    /**
+     * 应用标记
+     */
+    @Excel(name = "应用标记", width = 15)
+    @ApiModelProperty(value = "应用标记")
+    private String appVersion;
+    /**
+     * 应用名称
+     */
+    @Excel(name = "应用名称", width = 15)
+    @ApiModelProperty(value = "应用名称")
+    private String appName;
+    /**
+     * 应用包名
+     */
+    @Excel(name = "应用包名	", width = 15)
+    @ApiModelProperty(value = "应用包名	")
+    private String packageName;
+    /**
+     * 应用类型 1:Android应用下载,2:Android网页游戏,3:iOS应用下载,4:iOS网页游戏
+     */
+    @Excel(name = "应用类型 1:Android应用下载,2:Android网页游戏,3:iOS应用下载,4:iOS网页游戏", width = 15)
+    @ApiModelProperty(value = "应用类型 1:Android应用下载,2:Android网页游戏,3:iOS应用下载,4:iOS网页游戏")
+    private Integer platform;
+    /**
+     * 应用下载地址/网页游戏链接地址
+     */
+    @Excel(name = "应用下载地址/网页游戏链接地址	", width = 15)
+    @ApiModelProperty(value = "应用下载地址/网页游戏链接地址	")
+    private String url;
+    /**
+     * 是否接入快手广告监测SDK	 0:未接入,1:已接入
+     */
+    @Excel(name = "是否接入快手广告监测SDK	 0:未接入,1:已接入", width = 15)
+    @ApiModelProperty(value = "是否接入快手广告监测SDK	 0:未接入,1:已接入")
+    private Integer useSdk;
+    /**
+     * app隐私政策链接 安卓类应用必填
+     */
+    @Excel(name = "app隐私政策链接 安卓类应用必填", width = 15)
+    @ApiModelProperty(value = "app隐私政策链接 安卓类应用必填")
+    private String appPrivacyUrl;
+    private String trackUrl;
+    /**
+     * app文件MD5
+     */
+    @Excel(name = "app文件MD5", width = 15)
+    @ApiModelProperty(value = "app文件MD5")
+    private String appMd5;
+    private String imageToken;
+    /**
+     * 状态
+     */
+    @Excel(name = "状态", width = 15)
+    @ApiModelProperty(value = "状态")
+    private Integer status;
+    private String remark;
+    /**
+     * app_id
+     */
+    @Excel(name = "app_id", width = 15)
+    @ApiModelProperty(value = "app_id")
+    private Long appId;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaiShouAppInfoMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.ai.mapper;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * ai批量上传应用
+ *
+ * @author: jeecg-boot
+ * @date: 2021-02-02
+ * @cersion: V1.0
+ */
+public interface AiKuaiShouAppInfoMapper extends BaseMapper<AiKuaiShouAppInfo> {
+
+}

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaiShouAppInfoMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaiShouAppInfoMapper">
+
+</mapper>

+ 22 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaiShouAppInfoService.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.kuaishou.modules.ai.service;
+
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @Description: ai批量上传应用
+ * @Author: jeecg-boot
+ * @Date: 2021-02-02
+ * @Version: V1.0
+ */
+public interface IAiKuaiShouAppInfoService extends IService<AiKuaiShouAppInfo> {
+
+    JSONObject importExcel(MultipartFile file, Long accountId, String imageToken, Integer platform, String accessToken);
+
+    JSONObject uploadAppIconImage(String url, Long accountId, String accessToken);
+
+    void appCreative(Long accountId, String accessToken);
+
+}

+ 283 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaiShouAppInfoServiceImpl.java

@@ -0,0 +1,283 @@
+package cn.com.ctop.kuaishou.modules.ai.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
+import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaiShouAppInfoMapper;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.util.MD5Util;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * ai批量上传应用
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-02-02
+ */
+@Service
+@Slf4j
+public class AiKuaiShouAppInfoServiceImpl extends ServiceImpl<AiKuaiShouAppInfoMapper, AiKuaiShouAppInfo> implements IAiKuaiShouAppInfoService {
+    @Autowired
+    private IKuaiShouMaterialUploadService materialUploadService;
+    @Autowired
+    private AiKuaiShouAppInfoMapper aiKuaiShouAppInfoMapper;
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    /**
+     * 文件导入
+     *
+     * @param
+     * @param accountId
+     * @param imageToken
+     * @return
+     */
+    @Override
+    public JSONObject importExcel(MultipartFile myFile, Long accountId, String imageToken, Integer platform, String accessToken) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            Workbook workbook = null;
+            String fileName = myFile.getOriginalFilename();
+            String substring = fileName.substring(fileName.lastIndexOf(".") + 1).toUpperCase();
+            if (substring.equals("XLS")) {
+                workbook = new HSSFWorkbook(myFile.getInputStream());
+            } else if (substring.equals("XLSX")) {
+                workbook = new XSSFWorkbook(myFile.getInputStream());
+            } else {
+                throw new Exception("文件不是Excel文件");
+            }
+            Sheet sheet = workbook.getSheet("Sheet1");
+            int rows = sheet.getLastRowNum();// 指的行数,一共有多少行+
+            if (rows == 0) {
+                throw new Exception("请填写数据");
+            }
+            List<AiKuaiShouAppInfo> appList = new ArrayList<>();
+            for (int i = 1; i <= rows + 1; i++) {
+                Row row = sheet.getRow(i);
+                if (row != null) {
+                    AiKuaiShouAppInfo appInfo = new AiKuaiShouAppInfo();
+                    appInfo.setStatus(0);
+                    appInfo.setRemark("应用待创建");
+                    appInfo.setAccountId(accountId);
+                    appInfo.setPlatform(platform);
+                    appInfo.setImageToken(imageToken);
+                    String appName = getCellValue(row.getCell(0));
+                    appInfo.setAppName(appName);
+                    String packageName = getCellValue(row.getCell(1));
+                    appInfo.setPackageName(packageName);
+                    String appVersion = getCellValue(row.getCell(2));
+                    appInfo.setAppVersion(appVersion);
+                    String useSdk = getCellValue(row.getCell(3));
+                    if (!Check.isNull(useSdk)) {
+                        appInfo.setUseSdk(Integer.valueOf(useSdk));
+                    }
+                    String appPrivacyUrl = getCellValue(row.getCell(4));
+                    if (!Check.isNull(appPrivacyUrl)) {
+                        appInfo.setAppPrivacyUrl(appPrivacyUrl);
+                    }
+                    String url = getCellValue(row.getCell(5));
+                    if (!Check.isNull(url)) {
+                        appInfo.setUrl(url);
+                    }
+                    String trackUrl = getCellValue(row.getCell(6));
+                    if (!Check.isNull(trackUrl)) {
+                        appInfo.setTrackUrl(trackUrl);
+                    }
+                    appList.add(appInfo);
+                }
+            }
+            this.saveBatch(appList);
+            appCreative(accountId, accessToken);
+            returnJson.put("code", 0);
+            returnJson.put("message", "文件导入成功,异步创建中,请稍后...");
+        } catch (Exception e) {
+            e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    @Override
+    public void appCreative(Long accountId, String accessToken) {
+        List<AiKuaiShouAppInfo> appListByStatus = getAppListByStatus(accountId, 0);
+        for (AiKuaiShouAppInfo appInfo : appListByStatus) {
+            AiKuaiShouAppInfo updateAppInfo = new AiKuaiShouAppInfo();
+            updateAppInfo.setId(appInfo.getId());
+            String md5 = MD5Util.getMd5(appInfo.getUrl());
+            if (Check.isNull(md5)) {
+                updateAppInfo.setStatus(3);
+                updateAppInfo.setRemark("获取应用MD5失败");
+                this.updateById(updateAppInfo);
+                continue;
+            }
+            updateAppInfo.setAppMd5(md5);
+            updateAppInfo.setStatus(1);
+            updateAppInfo.setRemark("应用创建中");
+            this.updateById(updateAppInfo);
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        JSONObject requestJson = new JSONObject();
+                        requestJson.put("advertiser_id", appInfo.getAccountId());
+                        requestJson.put("app_version", appInfo.getAppVersion());
+                        requestJson.put("app_name", appInfo.getAppName());
+                        requestJson.put("image_token", appInfo.getImageToken());
+                        requestJson.put("package_name", appInfo.getPackageName());
+                        requestJson.put("platform", appInfo.getPlatform());
+                        requestJson.put("url", appInfo.getUrl());
+                        requestJson.put("use_sdk", appInfo.getUseSdk());
+                        requestJson.put("app_privacy_url", appInfo.getAppPrivacyUrl());
+                        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_CREATE;
+                        Map<String, String> headerMap = new HashMap<>();
+                        headerMap.put("Content-Type", "multipart/form-data");
+                        headerMap.put("Access-Token", accessToken);
+                        String s = materialUploadService.exceptInfoForRestTemplate(url, requestJson, headerMap);
+                        JSONObject resultJson = JSONObject.parseObject(s);
+                        log.info("上传应用返回信息:{}", resultJson);
+                        if (!Check.isNull(resultJson)) {
+                            Integer code = resultJson.getInteger("code");
+                            if (code == 0) {
+                                JSONObject data = resultJson.getJSONObject("data");
+                                Long app_id = data.getLong("app_id");
+                                updateAppInfo.setStatus(2);
+                                updateAppInfo.setRemark("创建应用成功");
+                                updateAppInfo.setAppId(app_id);
+                            } else {
+                                updateAppInfo.setStatus(3);
+                                updateAppInfo.setRemark(resultJson.getString("message"));
+                            }
+                        } else {
+                            updateAppInfo.setStatus(3);
+                            updateAppInfo.setRemark("上传应用返回结果为空");
+                        }
+
+                    } catch (Exception e) {
+                        updateAppInfo.setStatus(3);
+                        updateAppInfo.setRemark("系统异常");
+
+                    }
+                    aiKuaiShouAppInfoMapper.updateById(updateAppInfo);
+                }
+            });
+        }
+    }
+
+
+    private List<AiKuaiShouAppInfo> getAppListByStatus(Long accountId, Integer status) {
+        QueryWrapper<AiKuaiShouAppInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("status", status);
+        return this.list(queryWrapper);
+    }
+
+
+    private String getCellValue(Cell cell) {
+        String value = "";
+        if (cell != null) {
+            // 以下是判断数据的类型
+            switch (cell.getCellType()) {
+                case HSSFCell.CELL_TYPE_NUMERIC: // 数字
+                    value = cell.getNumericCellValue() + "";
+                    if (HSSFDateUtil.isCellDateFormatted(cell)) {
+                        Date date = cell.getDateCellValue();
+                        if (date != null) {
+                            value = new SimpleDateFormat("yyyy-MM-dd").format(date);
+                        } else {
+                            value = "";
+                        }
+                    } else {
+                        value = new DecimalFormat("0").format(cell.getNumericCellValue());
+                    }
+                    break;
+                case HSSFCell.CELL_TYPE_STRING: // 字符串
+                    value = cell.getStringCellValue();
+                    break;
+                case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean
+                    value = cell.getBooleanCellValue() + "";
+                    break;
+                case HSSFCell.CELL_TYPE_FORMULA: // 公式
+                    value = cell.getCellFormula() + "";
+                    break;
+                case HSSFCell.CELL_TYPE_BLANK: // 空值
+                    value = "";
+                    break;
+                case HSSFCell.CELL_TYPE_ERROR: // 故障
+                    value = "非法字符";
+                    break;
+                default:
+                    value = "未知类型";
+                    break;
+            }
+        }
+        return value.trim();
+    }
+
+
+    @Override
+    public JSONObject uploadAppIconImage(String url, Long accountId, String accessToken) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            Map<String, String> headerMap = new HashMap<>();
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", accountId);
+            headerMap.put("Access-Token", accessToken);
+            headerMap.put("Content-Type", "multipart/form-data");
+            requestJson.put("url", url);
+            requestJson.put("type", 1);
+            requestJson.put("upload_type", "2");
+            String requestUrl = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
+            String result = materialUploadService.exceptInfoForRestTemplate(requestUrl, requestJson, headerMap);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                if (resultJson.getInteger("code") == 0) {
+                    JSONObject dataJson = resultJson.getJSONObject("data");
+                    if (!Check.isNull(dataJson)) {
+                        String signature = dataJson.getString("signature");
+                        String image_token = dataJson.getString("image_token");
+                        returnJson.put("code", 0);
+                        returnJson.put("imageToken", image_token);
+                        returnJson.put("signature", signature);
+
+                    } else {
+                        log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
+                        returnJson.put("code", -1);
+                        returnJson.put("message", "图片上传失败");
+                    }
+                } else {
+                    log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
+                    returnJson.put("code", -1);
+                    returnJson.put("message", resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", "系统错误,请重新上传");
+        }
+
+        return returnJson;
+    }
+}

+ 13 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaiShouCreateServiceImpl.java

@@ -165,6 +165,16 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                 if (!Check.isNull(groupCreateJson.getLong("fiction_id"))) {
                 if (!Check.isNull(groupCreateJson.getLong("fiction_id"))) {
                     createJson.put("fiction_id", groupCreateJson.getLong("fiction_id")); //小说ID
                     createJson.put("fiction_id", groupCreateJson.getLong("fiction_id")); //小说ID
                 }
                 }
+
+                if (unit_type == 7) {
+                    if (!Check.isNull(groupCreateJson.getBoolean("smart_cover"))) {
+                        createJson.put("smart_cover", groupCreateJson.getBoolean("smart_cover")); //是否开启智能抽帧
+                    }
+                    if (!Check.isNull(groupCreateJson.getBoolean("asset_mining"))) {
+                        createJson.put("asset_mining", groupCreateJson.getBoolean("asset_mining")); //程序化创意2.0素材挖掘
+                    }
+                }
+
                 if (!Check.isNull(groupCreateJson.getLong("template_id"))) {
                 if (!Check.isNull(groupCreateJson.getLong("template_id"))) {
                     createJson.put("template_id", groupCreateJson.getLong("template_id")); //定向模板id
                     createJson.put("template_id", groupCreateJson.getLong("template_id")); //定向模板id
                 } else {
                 } else {
@@ -365,6 +375,8 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
                     }
                     }
                 }
                 }
                 programJson.put("cover_image_tokens", cover_image_tokens);
                 programJson.put("cover_image_tokens", cover_image_tokens);
+            } else {
+                programJson.put("cover_image_tokens", new JSONArray());
             }
             }
             if (!Check.isNull(programCreativeJson.getLong("site_id"))) {
             if (!Check.isNull(programCreativeJson.getLong("site_id"))) {
                 programJson.put("site_id", programCreativeJson.getLong("site_id"));
                 programJson.put("site_id", programCreativeJson.getLong("site_id"));
@@ -399,6 +411,7 @@ public class KuaiShouCreateServiceImpl implements IKuaiShouCreateService {
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
             String result = HttpUtils.kuaiShouhttpPostRequest(url, programJson.toJSONString(), headers);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, programJson.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             JSONObject resultJson = JSONObject.parseObject(result);
+            log.info("创建程序化创意返回结果:{}", resultJson);
             JSONObject returnJson = new JSONObject();
             JSONObject returnJson = new JSONObject();
             returnJson.put("creative_uuid", creative_uuid);
             returnJson.put("creative_uuid", creative_uuid);
             returnJson.put("unit_id", unit_id);
             returnJson.put("unit_id", unit_id);

+ 2 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -155,13 +155,13 @@ public class BatchController {
             };
             };
             thread2.start();
             thread2.start();
 
 
-            Thread thread3 = new Thread() {
+          /*  Thread thread3 = new Thread() {
                 @Override
                 @Override
                 public void run() {
                 public void run() {
                     iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), accountId, 1, nowDate, endDate);
                     iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), accountId, 1, nowDate, endDate);
                 }
                 }
             };
             };
-            thread3.start();
+            thread3.start();*/
 
 
             Thread thread4 = new Thread() {
             Thread thread4 = new Thread() {
                 @Override
                 @Override
@@ -2269,9 +2269,7 @@ public class BatchController {
         try {
         try {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -30);
             String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -30);
-            String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, 1);
             syncPullMaterialService.getSyncVideoList(accountId, startDate, nowDate);
             syncPullMaterialService.getSyncVideoList(accountId, startDate, nowDate);
-            syncPullMaterialService.getSyncSuZaoList(accountId, startDate, endDate);
             Thread.sleep(5 * 1000L);
             Thread.sleep(5 * 1000L);
             result.setSuccess(true);
             result.setSuccess(true);
             result.setResult(true);
             result.setResult(true);

+ 1 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouBatchCampaignPreviewController.java

@@ -24,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -140,7 +139,7 @@ public class KuaishouBatchCampaignPreviewController {
             return Result.ok(obj);
             return Result.ok(obj);
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("queryByBatchId is error", e);
             log.error("queryByBatchId is error", e);
-            return Result.error(e.getMessage());
+            return Result.error("查询异常");
         }
         }
     }
     }
 
 

+ 26 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouBatchGroupPreviewController.java

@@ -1,7 +1,10 @@
 package cn.com.ctop.kuaishou.modules.batch.controller;
 package cn.com.ctop.kuaishou.modules.batch.controller;
 
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCreativePreviewService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchGroupPreviewService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchGroupPreviewService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -54,6 +57,8 @@ import java.util.Map;
 public class KuaishouBatchGroupPreviewController {
 public class KuaishouBatchGroupPreviewController {
     @Autowired
     @Autowired
     private IKuaishouBatchGroupPreviewService kuaishouBatchGroupPreviewService;
     private IKuaishouBatchGroupPreviewService kuaishouBatchGroupPreviewService;
+    @Autowired
+    private IKuaishouBatchCreativePreviewService kuaishouBatchCreativePreview;
 
 
     /**
     /**
      * 分页列表查询
      * 分页列表查询
@@ -112,16 +117,29 @@ public class KuaishouBatchGroupPreviewController {
     @PostMapping(value = "/edit")
     @PostMapping(value = "/edit")
     public Result<KuaishouBatchGroupPreview> edit(@RequestBody KuaishouBatchGroupPreview kuaishouBatchGroupPreview) {
     public Result<KuaishouBatchGroupPreview> edit(@RequestBody KuaishouBatchGroupPreview kuaishouBatchGroupPreview) {
         Result<KuaishouBatchGroupPreview> result = new Result<KuaishouBatchGroupPreview>();
         Result<KuaishouBatchGroupPreview> result = new Result<KuaishouBatchGroupPreview>();
-        KuaishouBatchGroupPreview kuaishouBatchGroupPreviewEntity = kuaishouBatchGroupPreviewService.getById(kuaishouBatchGroupPreview.getId());
-        if (kuaishouBatchGroupPreviewEntity == null) {
-            result.error500("未找到对应实体");
-        } else {
-            boolean ok = kuaishouBatchGroupPreviewService.updateById(kuaishouBatchGroupPreview);
-            if (ok) {
-                result.success("修改成功!");
+        try {
+            KuaishouBatchGroupPreview kuaishouBatchGroupPreviewEntity = kuaishouBatchGroupPreviewService.getById(kuaishouBatchGroupPreview.getId());
+            if (kuaishouBatchGroupPreviewEntity == null) {
+                result.error500("未找到对应实体");
+            } else {
+                boolean ok = kuaishouBatchGroupPreviewService.updateById(kuaishouBatchGroupPreview);
+                if (!Check.isNull(kuaishouBatchGroupPreview.getClickTrackUrl()) && !Check.isNull(kuaishouBatchGroupPreview.getSiteId()) && !Check.isNull(kuaishouBatchGroupPreview.getActionbarClickUrl())) {
+                    KuaishouBatchCreativePreview creative = new KuaishouBatchCreativePreview();
+                    creative.setClickTrackUrl(kuaishouBatchGroupPreview.getClickTrackUrl());
+                    creative.setSiteId(kuaishouBatchGroupPreview.getSiteId());
+                    creative.setActionbarClickUrl(kuaishouBatchGroupPreview.getActionbarClickUrl());
+                    QueryWrapper<KuaishouBatchCreativePreview> wrapper = new QueryWrapper<>();
+                    wrapper.eq("group_id", kuaishouBatchGroupPreview.getId());
+                    kuaishouBatchCreativePreview.update(creative, wrapper);
+                }
+                if (ok) {
+                    result.success("修改成功!");
+                }
             }
             }
+        } catch (Exception e) {
+            log.error("修改异常", e);
+            result.error500("修改失败");
         }
         }
-
         return result;
         return result;
     }
     }
 
 

+ 11 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java

@@ -157,8 +157,17 @@ public class KuaishouTemplateController {
                 throw new Exception("未获取到账户信息");
                 throw new Exception("未获取到账户信息");
             }
             }
             JSONObject returnJson = kuaishouTemplateService.updateTemplate(accountId, oauthToken.getAccessToken(), requestJson);
             JSONObject returnJson = kuaishouTemplateService.updateTemplate(accountId, oauthToken.getAccessToken(), requestJson);
-            result.setSuccess(true);
-            result.setResult(returnJson);
+            Integer code = returnJson.getInteger("code");
+            if (code == 0) {
+                result.setSuccess(true);
+                result.setMessage("修改成功");
+            } else {
+                result.setSuccess(false);
+                result.setMessage(returnJson.getString("message"));
+            }
+
+
+            // result.setResult(returnJson);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
             result.setSuccess(false);
             result.setSuccess(false);

+ 8 - 42
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java

@@ -32,49 +32,18 @@ public class KuaiShouVideoGet {
     @TableId
     @TableId
     @ApiModelProperty(value = "id")
     @ApiModelProperty(value = "id")
     private String id;
     private String id;
-    /**
-     * 账户ID
-     */
-    @Excel(name = "账户ID", width = 15)
-    @ApiModelProperty(value = "账户ID")
     private Long accountId;
     private Long accountId;
-    /**
-     * 视频id
-     */
-    @Excel(name = "视频id", width = 15)
-    @ApiModelProperty(value = "视频id")
-    private String photoId;
-    /**
-     * 宽
-     */
-    @Excel(name = "宽", width = 15)
-    @ApiModelProperty(value = "宽")
-    private Integer width;
-    /**
-     * 高
-     */
-    @Excel(name = "高", width = 15)
-    @ApiModelProperty(value = "高")
-    private Integer height;
-    /**
-     * 视频预览链接
-     */
-    @Excel(name = "视频预览链接", width = 15)
-    @ApiModelProperty(value = "视频预览链接")
-    private String url;
-    /**
-     * 视频首帧图片链接
-     */
-    @Excel(name = "视频首帧图片链接", width = 15)
-    @ApiModelProperty(value = "视频首帧图片链接")
     private String coverUrl;
     private String coverUrl;
-    private String signature;
-
+    private String photoId;
+    private String photoName;
     private Date statDate;
     private Date statDate;
-
+    private String signature;
+    private String url;
+    private Integer height;
+    private Integer width;
     private Integer materialType;
     private Integer materialType;
-
-    private String materialId;
+    private Integer channelType;
+    private Integer status;
     /**
     /**
      * 创建时间
      * 创建时间
      */
      */
@@ -93,7 +62,4 @@ public class KuaiShouVideoGet {
     private Date updateTime;
     private Date updateTime;
 
 
 
 
-    private Integer channelType;
-    private Integer status;
-    private Long userId;
 }
 }

+ 5 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchCampaignPreview.java

@@ -10,7 +10,6 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
 
-import javax.persistence.Table;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
@@ -47,6 +46,10 @@ public class KuaishouBatchCampaignPreview {
     @ApiModelProperty(value = "计划名称")
     @ApiModelProperty(value = "计划名称")
     private String campaignName;
     private String campaignName;
     /**
     /**
+     * 命名格式
+     */
+    private String campaignNameFormat;
+    /**
      * 2 - 提升应用安装;
      * 2 - 提升应用安装;
      */
      */
     @Excel(name = "2 - 提升应用安装;", width = 15)
     @Excel(name = "2 - 提升应用安装;", width = 15)
@@ -112,6 +115,6 @@ public class KuaishouBatchCampaignPreview {
     private Long campaignId;
     private Long campaignId;
 
 
     @TableField(exist = false)
     @TableField(exist = false)
-    private List<KuaishouBatchGroupPreview>  kuaishouBatchGroupPreviews;
+    private List<KuaishouBatchGroupPreview> kuaishouBatchGroupPreviews;
 
 
 }
 }

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchCreativePreview.java

@@ -116,7 +116,7 @@ public class KuaishouBatchCreativePreview {
      */
      */
     @Excel(name = "安卓下载中间页", width = 15)
     @Excel(name = "安卓下载中间页", width = 15)
     @ApiModelProperty(value = "安卓下载中间页")
     @ApiModelProperty(value = "安卓下载中间页")
-    private Integer siteId;
+    private Long siteId;
     /**
     /**
      * 便利贴创意短广告语
      * 便利贴创意短广告语
      */
      */

+ 26 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchGroupPreview.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.entity;
 package cn.com.ctop.kuaishou.modules.batch.entity;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -46,6 +47,12 @@ public class KuaishouBatchGroupPreview {
      */
      */
     private Long templateId;
     private Long templateId;
     /**
     /**
+     * 定向模板id
+     */
+
+    @TableField(exist = false)
+    private String templateName;
+    /**
      * 广告活动ID
      * 广告活动ID
      */
      */
     @Excel(name = "广告活动ID", width = 15)
     @Excel(name = "广告活动ID", width = 15)
@@ -58,6 +65,10 @@ public class KuaishouBatchGroupPreview {
     @ApiModelProperty(value = "广告组名称")
     @ApiModelProperty(value = "广告组名称")
     private String unitName;
     private String unitName;
     /**
     /**
+     * 命名格式
+     */
+    private String unitNameFormat;
+    /**
      * 投放状态 1:投放中;2:暂停
      * 投放状态 1:投放中;2:暂停
      */
      */
     @Excel(name = "投放状态 1:投放中;2:暂停", width = 15)
     @Excel(name = "投放状态 1:投放中;2:暂停", width = 15)
@@ -233,4 +244,19 @@ public class KuaishouBatchGroupPreview {
      */
      */
     private Long unitId;
     private Long unitId;
 
 
+    @TableField(exist = false)
+    private JSONArray materialArr;
+
+    @TableField(exist = false)
+    private JSONArray descriptionArr;
+
+    @TableField(exist = false)
+    private String clickTrackUrl;
+
+    @TableField(exist = false)
+    private String actionbarClickUrl;
+
+    @TableField(exist = false)
+    private Long siteId;
+
 }
 }

+ 8 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -5,29 +5,34 @@
         replace into ctop_kuaishou_video_get(
         replace into ctop_kuaishou_video_get(
         id,
         id,
         account_id,
         account_id,
+        status,
         photo_id,
         photo_id,
         width,
         width,
         height,
         height,
         url,
         url,
         cover_url,
         cover_url,
         material_type,
         material_type,
+        channel_type,
+        stat_date,
         signature,
         signature,
-        update_time
+        photo_name
         )
         )
         values
         values
         <foreach collection="videos" item="video" separator=",">
         <foreach collection="videos" item="video" separator=",">
             (
             (
             #{video.id},
             #{video.id},
             #{video.accountId},
             #{video.accountId},
+            #{video.status},
             #{video.photoId},
             #{video.photoId},
             #{video.width},
             #{video.width},
             #{video.height},
             #{video.height},
             #{video.url},
             #{video.url},
             #{video.coverUrl},
             #{video.coverUrl},
             #{video.materialType},
             #{video.materialType},
+            #{video.channelType},
+            #{video.statDate},
             #{video.signature},
             #{video.signature},
-            #{video.updateTime}
-
+            #{video.photoName}
             )
             )
         </foreach>
         </foreach>
     </insert>
     </insert>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouMaterialUploadService.java

@@ -2,8 +2,13 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 
 
+import java.util.Map;
+
 public interface IKuaiShouMaterialUploadService {
 public interface IKuaiShouMaterialUploadService {
     JSONObject video(String url, Integer type, Long accountId, String accessToken, String signature);
     JSONObject video(String url, Integer type, Long accountId, String accessToken, String signature);
 
 
     String kuauiShouImageUpload(String url, String signature, Long accountId, String token);
     String kuauiShouImageUpload(String url, String signature, Long accountId, String token);
+
+
+    String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap);
 }
 }

+ 2 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -445,14 +445,8 @@ public interface IKuaishouInterfaceService {
     JSONArray getAppSearch(Long accountId, String accessToken, String appName);
     JSONArray getAppSearch(Long accountId, String accessToken, String appName);
 
 
 
 
-    /**
-     * 获取素造素材列表
-     *
-     * @param token
-     * @param accountId
-     * @param page
-     */
-    void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate);
+
+   // void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate);
 
 
     /**
     /**
      * 异步获取创意信息
      * 异步获取创意信息

+ 0 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/ISyncPullMaterialService.java

@@ -3,5 +3,4 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 public interface ISyncPullMaterialService {
 public interface ISyncPullMaterialService {
     void getSyncVideoList(Long accountId, String startDate, String endDate);
     void getSyncVideoList(Long accountId, String startDate, String endDate);
 
 
-    void getSyncSuZaoList(Long accountId, String nowDate, String endDate);
 }
 }

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

@@ -186,7 +186,8 @@ public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploa
     @Autowired
     @Autowired
     private RestTemplate rest;
     private RestTemplate rest;
 
 
-    private String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) {
+    @Override
+    public String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) {
         try {
         try {
             MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
             MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
             if (!Check.isNullMap(paramMap)) {
             if (!Check.isNullMap(paramMap)) {

+ 163 - 13
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouBatchCampaignPreviewServiceImpl.java

@@ -1,23 +1,34 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 
+import cn.com.ctop.common.module.enums.SceneIdEnum;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCampaignPreview;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchCreativePreview;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouBatchGroupPreview;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCampaignPreviewMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCampaignPreviewMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCreativePreviewMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchCreativePreviewMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchGroupPreviewMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouBatchGroupPreviewMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCampaignPreviewService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouBatchCampaignPreviewService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
 import com.alibaba.excel.util.CollectionUtils;
 import com.alibaba.excel.util.CollectionUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 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;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xxl.job.core.enums.NoEn;
 import com.xxl.job.core.enums.NoEn;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 
 /**
 /**
  * 快手-广告计划预览信息
  * 快手-广告计划预览信息
@@ -36,6 +47,10 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
     KuaishouBatchGroupPreviewMapper groupPreviewMapper;
     KuaishouBatchGroupPreviewMapper groupPreviewMapper;
     @Autowired
     @Autowired
     KuaishouBatchCreativePreviewMapper creativePreviewMapper;
     KuaishouBatchCreativePreviewMapper creativePreviewMapper;
+    @Autowired
+    private IKuaishouTemplateService kuaishouTemplateService;
+    @Autowired
+    private IKuaiShouAppListService kuaiShouAppListService;
 
 
     @Override
     @Override
     public JSONObject queryByBatchId(String batchId, String accountId) {
     public JSONObject queryByBatchId(String batchId, String accountId) {
@@ -43,18 +58,58 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
         QueryWrapper<KuaishouBatchCampaignPreview> campaignWrapper = new QueryWrapper<>();
         QueryWrapper<KuaishouBatchCampaignPreview> campaignWrapper = new QueryWrapper<>();
         campaignWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
         campaignWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
         List<KuaishouBatchCampaignPreview> campaignPreviewList = campaignPreviewMapper.selectList(campaignWrapper);
         List<KuaishouBatchCampaignPreview> campaignPreviewList = campaignPreviewMapper.selectList(campaignWrapper);
-        obj.put("campaignList", campaignPreviewList);
         QueryWrapper<KuaishouBatchGroupPreview> groupWrapper = new QueryWrapper<>();
         QueryWrapper<KuaishouBatchGroupPreview> groupWrapper = new QueryWrapper<>();
         groupWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
         groupWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
         List<KuaishouBatchGroupPreview> groupPreviewList = groupPreviewMapper.selectList(groupWrapper);
         List<KuaishouBatchGroupPreview> groupPreviewList = groupPreviewMapper.selectList(groupWrapper);
-        obj.put("groupList", groupPreviewList);
         QueryWrapper<KuaishouBatchCreativePreview> creativeWrapper = new QueryWrapper<>();
         QueryWrapper<KuaishouBatchCreativePreview> creativeWrapper = new QueryWrapper<>();
         creativeWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
         creativeWrapper.eq("batch_id", batchId).eq("account_id", accountId).orderByDesc("create_time");
         List<KuaishouBatchCreativePreview> creativePreviewList = creativePreviewMapper.selectList(creativeWrapper);
         List<KuaishouBatchCreativePreview> creativePreviewList = creativePreviewMapper.selectList(creativeWrapper);
-        obj.put("creativeList", creativePreviewList);
+        obj.put("campaignList", getCampaignList(campaignPreviewList, groupPreviewList, creativePreviewList));
         return obj;
         return obj;
     }
     }
 
 
+    private List<KuaishouBatchCampaignPreview> getCampaignList(List<KuaishouBatchCampaignPreview> campaignPreviewList, List<KuaishouBatchGroupPreview> kuaishouBatchGroupPreviews, List<KuaishouBatchCreativePreview> kuaishouBatchCreativePreviews) {
+        List<KuaishouBatchGroupPreview> groups = new ArrayList<>();
+
+        for (KuaishouBatchGroupPreview groupPreview : kuaishouBatchGroupPreviews) {
+            JSONArray materialArr = new JSONArray();
+            JSONArray descriptionArr = new JSONArray();
+            for (KuaishouBatchCreativePreview creativePreview : kuaishouBatchCreativePreviews) {
+                if (groupPreview.getPlanId().equals(creativePreview.getPlanId()) && creativePreview.getGroupId().equals(groupPreview.getId())) {
+                    JSONObject obj = new JSONObject();
+                    obj.put("photoId", creativePreview.getPhotoId());
+                    obj.put("imageUrl", creativePreview.getImageUrl());
+                    materialArr.add(obj);
+                    descriptionArr.add(creativePreview.getDescription());
+                    groupPreview.setSiteId(creativePreview.getSiteId());
+                    groupPreview.setClickTrackUrl(creativePreview.getClickTrackUrl());
+                    groupPreview.setActionbarClickUrl(creativePreview.getActionbarClickUrl());
+                }
+            }
+            QueryWrapper<KuaishouTemplate> queryWrapper = new QueryWrapper();
+            queryWrapper.eq("template_id", groupPreview.getTemplateId());
+            KuaishouTemplate template = kuaishouTemplateService.getOne(queryWrapper);
+            if (!Check.isNull(template)) {
+                groupPreview.setTemplateName(template.getTemplateName());
+            }
+            groupPreview.setMaterialArr(materialArr);
+            groupPreview.setDescriptionArr(descriptionArr);
+            groups.add(groupPreview);
+        }
+        List<KuaishouBatchCampaignPreview> campaigns = new ArrayList<>();
+        for (KuaishouBatchCampaignPreview campaignPreview : campaignPreviewList) {
+            List<KuaishouBatchGroupPreview> groupList = new ArrayList<>();
+            for (KuaishouBatchGroupPreview group : groups) {
+                if (campaignPreview.getId().equals(group.getPlanId())) {
+                    groupList.add(group);
+                }
+            }
+            campaignPreview.setKuaishouBatchGroupPreviews(groupList);
+            campaigns.add(campaignPreview);
+        }
+        return campaigns;
+    }
+
     @Override
     @Override
     public void addPreviewData(JSONObject data) throws Exception {
     public void addPreviewData(JSONObject data) throws Exception {
         String batchId = data.getString("batchId");
         String batchId = data.getString("batchId");
@@ -121,7 +176,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
         //应用分配方式 1 按账户,2按广告计划,3按广告组
         //应用分配方式 1 按账户,2按广告计划,3按广告组
         Integer appAllocation = appList.getInteger("appAllocation");
         Integer appAllocation = appList.getInteger("appAllocation");
         Integer appId = null;
         Integer appId = null;
-        Integer siteId = null;
+        Long siteId = null;
         String url = null;
         String url = null;
         JSONArray appArr = appList.getJSONArray("appArr");
         JSONArray appArr = appList.getJSONArray("appArr");
         JSONArray urlArr = appList.getJSONArray("urlArr");
         JSONArray urlArr = appList.getJSONArray("urlArr");
@@ -140,7 +195,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
         if (appAllocation == 1) {
         if (appAllocation == 1) {
             if (appNoNull) {
             if (appNoNull) {
                 appId = appArr.getJSONObject(0).getInteger("appId");
                 appId = appArr.getJSONObject(0).getInteger("appId");
-                siteId = appArr.getJSONObject(0).getInteger("siteId");
+                siteId = appArr.getJSONObject(0).getLong("siteId");
             }
             }
             if (urlNoNull) {
             if (urlNoNull) {
                 url = urlArr.getString(0);
                 url = urlArr.getString(0);
@@ -182,7 +237,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
                 if (appAllocation == 2) {
                 if (appAllocation == 2) {
                     if (appNoNull) {
                     if (appNoNull) {
                         appId = appArr.getJSONObject(i).getInteger("appId");
                         appId = appArr.getJSONObject(i).getInteger("appId");
-                        siteId = appArr.getJSONObject(i).getInteger("siteId");
+                        siteId = appArr.getJSONObject(i).getLong("siteId");
                     }
                     }
                     if (urlNoNull) {
                     if (urlNoNull) {
                         url = urlArr.getString(i);
                         url = urlArr.getString(i);
@@ -197,14 +252,14 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
                     }
                     }
                 }
                 }
                 campaignPreview.setId(null);
                 campaignPreview.setId(null);
-                campaignPreview.setCampaignName(campaignPreview.getCampaignName() + i);
+                campaignPreview.setCampaignName(getName(campaignPreview.getCampaignName(), null, null, appId, null) + i);
                 campaignPreviewMapper.insert(campaignPreview);
                 campaignPreviewMapper.insert(campaignPreview);
                 for (int j = 0; j < materialList.size(); j++) {
                 for (int j = 0; j < materialList.size(); j++) {
                     if (appAllocation == 3) {
                     if (appAllocation == 3) {
                         appCount--;
                         appCount--;
                         if (appNoNull) {
                         if (appNoNull) {
                             appId = appArr.getJSONObject(appCount).getInteger("appId");
                             appId = appArr.getJSONObject(appCount).getInteger("appId");
-                            siteId = appArr.getJSONObject(appCount).getInteger("siteId");
+                            siteId = appArr.getJSONObject(appCount).getLong("siteId");
                         }
                         }
                         if (urlNoNull) {
                         if (urlNoNull) {
                             url = urlArr.getString(appCount);
                             url = urlArr.getString(appCount);
@@ -223,7 +278,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
                     groupPreview.setAppId(appId);
                     groupPreview.setAppId(appId);
                     groupPreview.setPlanId(campaignPreview.getId());
                     groupPreview.setPlanId(campaignPreview.getId());
                     groupPreview.setTemplateId(targetIds.getLong(i));
                     groupPreview.setTemplateId(targetIds.getLong(i));
-                    groupPreview.setUnitName(groupPreview.getUnitName() + j);
+                    groupPreview.setUnitName(getName(groupPreview.getUnitName(), targetIds.getLong(i), groupPreview.getSceneId(), appId, groupPreview.getUnitType()) + j);
                     groupPreview.setUrl(url);
                     groupPreview.setUrl(url);
                     groupPreviewMapper.insert(groupPreview);
                     groupPreviewMapper.insert(groupPreview);
                     JSONObject material = materialList.getJSONObject(j);
                     JSONObject material = materialList.getJSONObject(j);
@@ -266,7 +321,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
                 if (appAllocation == 2) {
                 if (appAllocation == 2) {
                     if (appNoNull) {
                     if (appNoNull) {
                         appId = appArr.getJSONObject(i).getInteger("appId");
                         appId = appArr.getJSONObject(i).getInteger("appId");
-                        siteId = appArr.getJSONObject(i).getInteger("siteId");
+                        siteId = appArr.getJSONObject(i).getLong("siteId");
                     }
                     }
                     if (urlNoNull) {
                     if (urlNoNull) {
                         url = urlArr.getString(i);
                         url = urlArr.getString(i);
@@ -281,7 +336,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
                     }
                     }
                 }
                 }
                 campaignPreview.setId(null);
                 campaignPreview.setId(null);
-                campaignPreview.setCampaignName(campaignPreview.getCampaignName() + i);
+                campaignPreview.setCampaignName(getName(campaignPreview.getCampaignName(), null, null, appId, null) + i);
                 campaignPreviewMapper.insert(campaignPreview);
                 campaignPreviewMapper.insert(campaignPreview);
                 JSONObject material = materialList.getJSONObject(i);
                 JSONObject material = materialList.getJSONObject(i);
                 JSONArray photoArr = material.getJSONArray("photoArr");
                 JSONArray photoArr = material.getJSONArray("photoArr");
@@ -294,7 +349,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
                         appCount--;
                         appCount--;
                         if (appNoNull) {
                         if (appNoNull) {
                             appId = appArr.getJSONObject(appCount).getInteger("appId");
                             appId = appArr.getJSONObject(appCount).getInteger("appId");
-                            siteId = appArr.getJSONObject(appCount).getInteger("siteId");
+                            siteId = appArr.getJSONObject(appCount).getLong("siteId");
                         }
                         }
                         if (urlNoNull) {
                         if (urlNoNull) {
                             url = urlArr.getString(appCount);
                             url = urlArr.getString(appCount);
@@ -313,7 +368,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
                     groupPreview.setAppId(appId);
                     groupPreview.setAppId(appId);
                     groupPreview.setPlanId(campaignPreview.getId());
                     groupPreview.setPlanId(campaignPreview.getId());
                     groupPreview.setTemplateId(targetIds.getLong(j));
                     groupPreview.setTemplateId(targetIds.getLong(j));
-                    groupPreview.setUnitName(groupPreview.getUnitName() + j);
+                    groupPreview.setUnitName(getName(groupPreview.getUnitName(), targetIds.getLong(i), groupPreview.getSceneId(), appId, groupPreview.getUnitType()) + j);
                     groupPreview.setUrl(url);
                     groupPreview.setUrl(url);
                     groupPreviewMapper.insert(groupPreview);
                     groupPreviewMapper.insert(groupPreview);
                     for (int k = 0; k < photoArr.size(); k++) {
                     for (int k = 0; k < photoArr.size(); k++) {
@@ -386,6 +441,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
         KuaishouBatchCampaignPreview campaignPreview = new KuaishouBatchCampaignPreview();
         KuaishouBatchCampaignPreview campaignPreview = new KuaishouBatchCampaignPreview();
         campaignPreview.setAccountId(campaignJson.getLong("accountId"));
         campaignPreview.setAccountId(campaignJson.getLong("accountId"));
         campaignPreview.setCampaignName(campaignJson.getString("campaignName"));
         campaignPreview.setCampaignName(campaignJson.getString("campaignName"));
+        campaignPreview.setCampaignNameFormat(campaignJson.getString("campaignName"));
         campaignPreview.setCampaignType(campaignJson.getInteger("campaignType"));
         campaignPreview.setCampaignType(campaignJson.getInteger("campaignType"));
         campaignPreview.setPutStatus(campaignJson.getInteger("campaignStatus"));
         campaignPreview.setPutStatus(campaignJson.getInteger("campaignStatus"));
         campaignPreview.setDayBudget(campaignJson.getInteger("dayBudget"));
         campaignPreview.setDayBudget(campaignJson.getInteger("dayBudget"));
@@ -408,6 +464,7 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
         KuaishouBatchGroupPreview groupPreview = new KuaishouBatchGroupPreview();
         KuaishouBatchGroupPreview groupPreview = new KuaishouBatchGroupPreview();
         groupPreview.setAccountId(groupJson.getLong("accountId"));
         groupPreview.setAccountId(groupJson.getLong("accountId"));
         groupPreview.setUnitName(groupJson.getString("unitName"));
         groupPreview.setUnitName(groupJson.getString("unitName"));
+        groupPreview.setUnitNameFormat(groupJson.getString("unitName"));
         groupPreview.setPutStatus(campaignJson.getInteger("unitStatus") == 2 ? 2 : null);
         groupPreview.setPutStatus(campaignJson.getInteger("unitStatus") == 2 ? 2 : null);
         groupPreview.setBidType(groupJson.getInteger("bidType"));
         groupPreview.setBidType(groupJson.getInteger("bidType"));
         if (groupJson.getInteger("bidType") == 2) {
         if (groupJson.getInteger("bidType") == 2) {
@@ -472,4 +529,97 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
         return creativePreview;
         return creativePreview;
     }
     }
 
 
+    /**
+     * @param content    通配符String
+     * @param templateId 定向模板ID
+     * @param sceneId    广告位置ID
+     * @param appId      应用包id、渠道号
+     * @param unitType   创意制作方式
+     * @return
+     */
+    private String getName(String content, Long templateId, String sceneId, Integer appId, Integer unitType) {
+        String reg = "\\{\\{(.+?)\\}\\}";
+        List<String> params = getParams(reg, content);
+        if (Check.isNull(params)) {
+            return content;
+        }
+        Map<String, String> data = new HashMap<>();
+        for (int i = 0; i < params.size(); i++) {
+            String regName = params.get(i);
+            if ("日期".equals(regName)) {
+                data.put(regName, DateUtils.getNowDate("yyyy-MM-dd"));
+            } else if ("定向包".equals(regName)) {
+                if (!Check.isNull(templateId)) {
+                    QueryWrapper<KuaishouTemplate> queryWrapper = new QueryWrapper();
+                    queryWrapper.eq("template_id", templateId);
+                    KuaishouTemplate template = kuaishouTemplateService.getOne(queryWrapper);
+                    data.put(regName, template.getTemplateName());
+                }
+            } else if ("广告位置".equals(regName)) {
+                if (!Check.isNull(sceneId)) {
+                    Integer sceneid = JSONObject.parseArray(sceneId).getInteger(0);
+                    if (sceneid == 1 || sceneid == 5) {
+                        data.put(regName, SceneIdEnum.getEnumById(sceneid).getName());
+                    } else {
+                        data.put(regName, "场景广告位");
+                    }
+                }
+            } else if ("应用名称".equals(regName)) {
+                if (!Check.isNull(appId)) {
+                    QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper();
+                    queryWrapper.eq("app_id", appId);
+                    KuaiShouAppList one = kuaiShouAppListService.getOne(queryWrapper);
+                    data.put(regName, one.getAppName());
+                }
+            } else if ("渠道号".equals(regName)) {
+                if (!Check.isNull(appId)) {
+                    QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper();
+                    queryWrapper.eq("app_id", appId);
+                    KuaiShouAppList one = kuaiShouAppListService.getOne(queryWrapper);
+                    data.put(regName, one.getAppVersion());
+                }
+            } else if ("创意制作方式".equals(regName)) {
+                if (!Check.isNull(unitType)) {
+                    data.put(regName, unitType == 4 ? "自定义" : "程序化创意2.0");
+                }
+            }
+        }
+        String text = parse(reg, content, data);
+        return text;
+    }
+
+
+    public static String parse(String pattern, String content, Map<String, String> data) {
+        Pattern p = Pattern.compile(pattern);
+        Matcher m = p.matcher(content);
+
+        StringBuffer sb = new StringBuffer();
+        while (m.find()) {
+            String key = m.group(1);
+            String value = data.get(key);
+            m.appendReplacement(sb, value == null ? "" : value);
+        }
+        m.appendTail(sb);
+        return sb.toString();
+    }
+
+    /**
+     * 根据正则表达式获取文本中的变量名列表
+     *
+     * @param pattern
+     * @param content
+     * @return
+     */
+    public static List<String> getParams(String pattern, String content) {
+        Pattern p = Pattern.compile(pattern);
+        Matcher m = p.matcher(content);
+
+        List<String> result = new ArrayList<String>();
+        while (m.find()) {
+            result.add(m.group(1));
+        }
+        return result;
+    }
+
+
 }
 }

+ 145 - 102
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.MaterialCutFrame;
 import cn.com.ctop.common.module.entity.OauthConfig;
 import cn.com.ctop.common.module.entity.OauthConfig;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.enums.MaterialEnum;
 import cn.com.ctop.common.module.enums.MaterialEnum;
@@ -213,43 +212,56 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
                 log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
                 return;
                 return;
             }
             }
-            KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(token.getAccountId());
-            Long userId = null;
-            if (!Check.isNull(baseInfo)) {
-                userId = Long.valueOf(baseInfo.getUserId());
-            }
+            List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
             for (int i = 0; i < details.size(); i++) {
             for (int i = 0; i < details.size(); i++) {
-                var detailJson = details.getJSONObject(i);
+                JSONObject detailJson = details.getJSONObject(i);
+                if (Check.isNull(detailJson)) {
+                    continue;
+                }
+                KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
+                String photo_id = detailJson.getString("photo_id");
+                videoGet.setId(token.getAccountId() + photo_id);
+                videoGet.setAccountId(token.getAccountId());
+                videoGet.setCoverUrl(detailJson.getString("cover_url"));
+                videoGet.setPhotoId(photo_id);
+                videoGet.setPhotoName(detailJson.getString("photo_name"));
+                videoGet.setStatDate(detailJson.getDate("upload_time"));
+                String signature = detailJson.getString("signature");
+                videoGet.setSignature(signature);
                 Integer source = detailJson.getInteger("source");
                 Integer source = detailJson.getInteger("source");
                 if (source == 2) {
                 if (source == 2) {
-                    continue;
+                    videoGet.setChannelType(1);
+                } else {
+                    videoGet.setChannelType(0);
                 }
                 }
-                KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(token.getAccountId() + detailJson.getString("photo_id"));
-                if (!Check.isNull(byId)) {
-                    continue;
+                Integer new_status = detailJson.getInteger("new_status");
+                if (new_status == 1) {
+                    videoGet.setStatus(0);
+                } else {
+                    videoGet.setStatus(1);
                 }
                 }
-                var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
-                kuaiShouVideoGet.setId(token.getAccountId() + kuaiShouVideoGet.getPhotoId());
-                kuaiShouVideoGet.setAccountId(token.getAccountId());
-                kuaiShouVideoGet.setStatDate(detailJson.getDate("upload_time"));
-                kuaiShouVideoGet.setUpdateTime(new Date());
-                Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
+                videoGet.setUrl(detailJson.getString("url"));
+                Integer width = detailJson.getInteger("width");
+                videoGet.setWidth(width);
+                Integer height = detailJson.getInteger("height");
+                videoGet.setHeight(height);
+                Integer type = MaterialEnum.getTypeBySize(width, height);
                 if (!Check.isNull(type)) {
                 if (!Check.isNull(type)) {
-                    kuaiShouVideoGet.setMaterialType(type);
+                    videoGet.setMaterialType(type);
                 }
                 }
-
-                kuaiShouVideoGet.setUserId(userId);
-                kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
-
+                videoGetList.add(videoGet);
                 Thread thread = new Thread() {
                 Thread thread = new Thread() {
                     @Override
                     @Override
                     public void run() {
                     public void run() {
-                        videoGetService.getKeyFrame(token.getAccessToken(), token.getAccountId(), kuaiShouVideoGet.getSignature(), kuaiShouVideoGet.getPhotoId());
+                        videoGetService.getKeyFrame(token.getAccessToken(), token.getAccountId(), signature, photo_id);
                     }
                     }
                 };
                 };
                 thread.start();
                 thread.start();
-
             }
             }
+            if (!Check.isNull(videoGetList)) {
+                videoGetService.replaceBatch(videoGetList);
+            }
+
             getVideoListByPage(token, startDate, endDate, page + 1);
             getVideoListByPage(token, startDate, endDate, page + 1);
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
@@ -919,7 +931,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
 
         historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
         historyReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
         getVideoList(token, null, null);
         getVideoList(token, null, null);
-        getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
+        //   getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, null, null);
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
         String videoEndDate = DateUtils.addDay(nowDate, -180);
         String videoEndDate = DateUtils.addDay(nowDate, -180);
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -1022,9 +1034,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
                     if (!Check.isNull(dataJson)) {
                         Long unitId = dataJson.getLong("unit_id");
                         Long unitId = dataJson.getLong("unit_id");
-                        Thread.sleep(100);Thread thread = new Thread(){
+                        Thread.sleep(100);
+                        Thread thread = new Thread() {
                             @Override
                             @Override
-                            public void run(){
+                            public void run() {
                                 getKuaiShouGroupService.getGroupByUnitId(accessToken, advertiserId, unitId);
                                 getKuaiShouGroupService.getGroupByUnitId(accessToken, advertiserId, unitId);
                             }
                             }
                         };
                         };
@@ -1586,45 +1599,61 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             if (!Check.isNull(resultJson)) {
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
                 if (code == 0) {
-                    JSONArray dataArray = resultJson.getJSONArray("data");
-                    if (!Check.isNull(dataArray)) {
-                        KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
-                        Long userId = null;
-                        if (!Check.isNull(baseInfo)) {
-                            userId = Long.valueOf(baseInfo.getUserId());
+                    JSONArray details = resultJson.getJSONArray("data");
+                    if (Check.isNull(details)) {
+                        return;
+                    }
+                    List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
+                    for (int i = 0; i < details.size(); i++) {
+                        JSONObject detailJson = details.getJSONObject(i);
+                        if (Check.isNull(detailJson)) {
+                            continue;
                         }
                         }
-                        for (int i = 0; i < dataArray.size(); i++) {
-                            JSONObject detailJson = dataArray.getJSONObject(i);
-                            if (!Check.isNull(detailJson)) {
-
-                                KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(accountId + photoId);
-                                if (!Check.isNull(byId)) {
-                                    continue;
-                                }
-                                var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
-                                kuaiShouVideoGet.setId(accountId + photoId);
-
-                                kuaiShouVideoGet.setAccountId(accountId);
-                                kuaiShouVideoGet.setStatDate(detailJson.getDate("upload_time"));
-                                kuaiShouVideoGet.setUpdateTime(new Date());
-                                Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
-                                if (!Check.isNull(type)) {
-                                    kuaiShouVideoGet.setMaterialType(type);
-                                }
-
-                                kuaiShouVideoGet.setUserId(userId);
-                                kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
-
-                                Thread thread = new Thread() {
-                                    @Override
-                                    public void run() {
-                                        videoGetService.getKeyFrame(accessToken, accountId, kuaiShouVideoGet.getSignature(), kuaiShouVideoGet.getPhotoId());
-                                    }
-                                };
-                                thread.start();
-                            }
+                        KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
+                        String photo_id = detailJson.getString("photo_id");
+                        videoGet.setId(accountId + photo_id);
+                        videoGet.setAccountId(accountId);
+                        videoGet.setCoverUrl(detailJson.getString("cover_url"));
+
+                        videoGet.setPhotoId(photo_id);
+                        videoGet.setPhotoName(detailJson.getString("photo_name"));
+                        videoGet.setStatDate(detailJson.getDate("upload_time"));
+                        String signature = detailJson.getString("signature");
+                        videoGet.setSignature(signature);
+                        Integer source = detailJson.getInteger("source");
+                        if (source == 2) {
+                            videoGet.setChannelType(1);
+                        } else {
+                            videoGet.setChannelType(0);
+                        }
+                        Integer new_status = detailJson.getInteger("new_status");
+                        if (new_status == 1) {
+                            videoGet.setStatus(0);
+                        } else {
+                            videoGet.setStatus(1);
+                        }
+                        videoGet.setUrl(detailJson.getString("url"));
+                        Integer width = detailJson.getInteger("width");
+                        videoGet.setWidth(width);
+                        Integer height = detailJson.getInteger("height");
+                        videoGet.setHeight(height);
+                        Integer type = MaterialEnum.getTypeBySize(width, height);
+                        if (!Check.isNull(type)) {
+                            videoGet.setMaterialType(type);
                         }
                         }
+                        videoGetList.add(videoGet);
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                videoGetService.getKeyFrame(accessToken, accountId, signature, photo_id);
+                            }
+                        };
+                        thread.start();
                     }
                     }
+                    if (!Check.isNull(videoGetList)) {
+                        videoGetService.replaceBatch(videoGetList);
+                    }
+
                 } else {
                 } else {
                     log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
                     log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
                 }
                 }
@@ -1632,9 +1661,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             } else {
             } else {
                 log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
                 log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
             }
             }
-        } catch (Exception e) {
+        } catch (
+                Exception e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
+
     }
     }
 
 
 
 
@@ -2916,7 +2947,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaiShouVideoGetService videoGetService;
     private IKuaiShouVideoGetService videoGetService;
     static ExecutorService suZhaoService = Executors.newFixedThreadPool(15);
     static ExecutorService suZhaoService = Executors.newFixedThreadPool(15);
 
 
-    @Override
+   /* @Override
     public void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate) {
     public void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate) {
         String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
         String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
         Map<String, String> headers = new HashMap<String, String>();
         Map<String, String> headers = new HashMap<String, String>();
@@ -2932,6 +2963,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         }
         String result = HttpUtils.httpPostRequest(url, param, headers);
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         JSONObject resultJson = JSONObject.parseObject(result);
+        System.err.println(resultJson);
         if (Check.isNull(resultJson)) {
         if (Check.isNull(resultJson)) {
             return;
             return;
         }
         }
@@ -2951,49 +2983,60 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         if (Check.isNull(details)) {
         if (Check.isNull(details)) {
             return;
             return;
         }
         }
-        KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
-        Long userId = null;
-        if (!Check.isNull(baseInfo)) {
-            userId = Long.valueOf(baseInfo.getUserId());
-        }
+
+        List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
         for (int i = 0; i < details.size(); i++) {
         for (int i = 0; i < details.size(); i++) {
-            JSONObject jsonObject = details.getJSONObject(i);
-            if (!Check.isNull(jsonObject)) {
-                KuaiShouVideoGet kuaiShouVideoGet = new KuaiShouVideoGet();
-                Long photo_id = jsonObject.getLong("photo_id");
-                kuaiShouVideoGet.setId(String.valueOf(accountId) + String.valueOf(photo_id));
-                kuaiShouVideoGet.setPhotoId(String.valueOf(photo_id));
-                kuaiShouVideoGet.setUrl(jsonObject.getString("watermark_url"));
-                kuaiShouVideoGet.setWidth(jsonObject.getInteger("width"));
-                kuaiShouVideoGet.setHeight(jsonObject.getInteger("height"));
-                kuaiShouVideoGet.setCoverUrl(jsonObject.getString("cover_url"));
-                kuaiShouVideoGet.setAccountId(accountId);
-                String md5 = jsonObject.getString("md5");
-                kuaiShouVideoGet.setSignature(md5);
-                kuaiShouVideoGet.setStatDate(jsonObject.getDate("sync_date"));
-                kuaiShouVideoGet.setChannelType(1);
-                kuaiShouVideoGet.setUserId(userId);
-                kuaiShouVideoGet.setMaterialId(jsonObject.getString("material_id"));
-                Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
-                if (!Check.isNull(type)) {
-                    kuaiShouVideoGet.setMaterialType(type);
-                }
-                kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
-                suZhaoService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        List<MaterialCutFrame> cutFrames = cutFrameService.getListByVideoSignature(md5);
-                        if (null == cutFrames || cutFrames.isEmpty()) {
-                            videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
-                        }
-                    }
-                });
+            JSONObject detailJson = details.getJSONObject(i);
+            if (Check.isNull(detailJson)) {
+                continue;
+            }
+            KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
+            String photo_id = detailJson.getString("photo_id");
+            videoGet.setId(accountId + photo_id);
+            videoGet.setAccountId(accountId);
+            videoGet.setCoverUrl(detailJson.getString("cover_url"));
+            videoGet.setPhotoId(photo_id);
+            videoGet.setPhotoName(detailJson.getString("photo_name"));
+            videoGet.setStatDate(detailJson.getDate("upload_time"));
+            String signature = detailJson.getString("signature");
+            videoGet.setSignature(signature);
+            Integer source = detailJson.getInteger("source");
+            if (source == 2) {
+                videoGet.setChannelType(1);
+            } else {
+                videoGet.setChannelType(0);
             }
             }
+            Integer new_status = detailJson.getInteger("new_status");
+            if (new_status == 1) {
+                videoGet.setStatus(0);
+            } else {
+                videoGet.setStatus(1);
+            }
+            videoGet.setUrl(detailJson.getString("url"));
+            Integer width = detailJson.getInteger("width");
+            videoGet.setWidth(width);
+            Integer height = detailJson.getInteger("height");
+            videoGet.setHeight(height);
+            Integer type = MaterialEnum.getTypeBySize(width, height);
+            if (!Check.isNull(type)) {
+                videoGet.setMaterialType(type);
+            }
+            videoGetList.add(videoGet);
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    videoGetService.getKeyFrame(token, accountId, signature, photo_id);
+                }
+            };
+            thread.start();
+        }
+        if (!Check.isNull(videoGetList)) {
+            videoGetService.replaceBatch(videoGetList);
         }
         }
 
 
         getSuZaoList(token, accountId, page + 1, startDate, endDate);
         getSuZaoList(token, accountId, page + 1, startDate, endDate);
 
 
-    }
+    }*/
 
 
     @Autowired
     @Autowired
     private IMaterialCutFrameService cutFrameService;
     private IMaterialCutFrameService cutFrameService;

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

@@ -342,6 +342,7 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
      */
      */
     @Override
     @Override
     public JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson) {
     public JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson) {
+        System.err.println(requestJson);
         JSONObject returnJson = new JSONObject();
         JSONObject returnJson = new JSONObject();
         try {
         try {
             if (Check.isNull(requestJson.getString("templateName"))) {
             if (Check.isNull(requestJson.getString("templateName"))) {
@@ -458,6 +459,7 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             headers.put("Access-Token", accessToken);
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", " application/json");
             headers.put("Content-Type", " application/json");
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
+            System.err.println("入参:" + param);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
             if (!Check.isNull(resultJson)) {
@@ -470,8 +472,9 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
                         returnJson.put("templateId", data.getLong("template_id"));
                         returnJson.put("templateId", data.getLong("template_id"));
                     }
                     }
                 } else {
                 } else {
+                    log.error("修改失败:{}", resultJson);
                     returnJson.put("code", -1);
                     returnJson.put("code", -1);
-                    returnJson.put("message", returnJson.getString("message"));
+                    returnJson.put("message", resultJson.getString("message"));
                 }
                 }
             } else {
             } else {
                 returnJson.put("code", -1);
                 returnJson.put("code", -1);

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

@@ -76,7 +76,6 @@ public class KuaishouVideoRelateCreativesServiceImpl extends ServiceImpl<Kuaisho
             params.put("advertiser_id", accountId);
             params.put("advertiser_id", accountId);
             params.put("photo_ids", photoIds);
             params.put("photo_ids", photoIds);
             params.put("share_advertiser_ids", shareAdvertiserIds);
             params.put("share_advertiser_ids", shareAdvertiserIds);
-            System.out.println(params);
             String result = HttpUtils.httpPostRequest(url, params, header);
             String result = HttpUtils.httpPostRequest(url, params, header);
             JSONObject resultJson = JSONObject.parseObject(result);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
             if (!Check.isNull(resultJson)) {

+ 0 - 28
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/SyncPullMaterialServiceImpl.java

@@ -58,33 +58,5 @@ public class SyncPullMaterialServiceImpl implements ISyncPullMaterialService {
         }
         }
     }
     }
 
 
-    /**
-     * 获取素造素材
-     *
-     * @param accountId
-     * @param startDate
-     * @param endDate
-     */
-    @Override
-    public void getSyncSuZaoList(Long accountId, String startDate, String endDate) {
-
-        KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
-        if (!Check.isNull(baseInfo)) {
-            List<KuaiShouAdvertiserBaseInfo> baseInfoList = KuaiShouAdvertiserBaseInfoService.getAccountIdList(baseInfo.getUserId());
-            if (!Check.isNull(baseInfoList)) {
-                for (KuaiShouAdvertiserBaseInfo advertiserBaseInfo : baseInfoList) {
-                    CtopOauthToken token = oauthTokenService.getTokenByAccountId(advertiserBaseInfo.getAccountId());
-                    if (!Check.isNull(token)) {
-                        suZhaoExecutorService.submit(new Runnable() {
-                            @Override
-                            public void run() {
-                                iKuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate);
-                            }
-                        });
-                    }
-                }
-            }
-        }
 
 
-    }
 }
 }

+ 330 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouGroupExploreController.java

@@ -0,0 +1,330 @@
+package cn.com.ctop.kuaishou.modules.report.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
+import com.alibaba.fastjson.JSON;
+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 io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 广告组的加速探索报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-02-02
+ */
+@Slf4j
+@Api(tags = "广告组的加速探索报表")
+@RestController
+@RequestMapping("/explore")
+public class KuaishouGroupExploreController {
+    @Autowired
+    private IKuaishouGroupExploreService kuaishouGroupExploreService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouGroupExplore
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "广告组的加速探索报表-分页列表查询")
+    @ApiOperation(value = "广告组的加速探索报表-分页列表查询", notes = "广告组的加速探索报表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouGroupExplore>> queryPageList(KuaishouGroupExplore kuaishouGroupExplore,
+                                                             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                             HttpServletRequest req) {
+        Result<IPage<KuaishouGroupExplore>> result = new Result<>();
+        QueryWrapper<KuaishouGroupExplore> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouGroupExplore, req.getParameterMap());
+        Page<KuaishouGroupExplore> page = new Page<KuaishouGroupExplore>(pageNo, pageSize);
+        IPage<KuaishouGroupExplore> pageList = kuaishouGroupExploreService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 查询加速探索信息接口
+     *
+     * @param kuaishouGroupExplore
+     * @return
+     */
+    @AutoLog(value = "查询加速探索信息接口")
+    @ApiOperation(value = "查询加速探索信息接口", notes = "查询加速探索信息接口")
+    @PostMapping(value = "/unitExploreInfoGet")
+    public Result<Object> unitExploreInfoGet(@RequestBody JSONObject data) {
+        try {
+            return kuaishouGroupExploreService.unitExploreInfoGet(data);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("操作失败");
+        }
+    }
+
+    /**
+     * 广告组的加速探索预算设置接口
+     *
+     * @param kuaishouGroupExplore
+     * @return
+     */
+    @AutoLog(value = "广告组的加速探索预算设置接口")
+    @ApiOperation(value = "广告组的加速探索预算设置接口", notes = "广告组的加速探索预算设置接口")
+    @PostMapping(value = "/unitExploreBudgetUpdate")
+    public Result<Object> unitExploreBudgetUpdate(@RequestBody JSONObject data) {
+        try {
+            return kuaishouGroupExploreService.unitExploreBudgetUpdate(data);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("操作失败");
+        }
+    }
+
+    /**
+     * 暂停广告组的加速探索预算接口
+     *
+     * @param kuaishouGroupExplore
+     * @return
+     */
+    @AutoLog(value = "暂停广告组的加速探索预算接口")
+    @ApiOperation(value = "暂停广告组的加速探索预算接口", notes = "暂停广告组的加速探索预算接口")
+    @PostMapping(value = "/unitExploreStatusPause")
+    public Result<Object> unitExploreStatusPause(@RequestBody JSONObject data) {
+        try {
+            return kuaishouGroupExploreService.unitExploreStatusPause(data);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("操作失败");
+        }
+    }
+
+    /**
+     * 查询广告组的加速探索报表接口
+     *
+     * @param kuaishouGroupExplore
+     * @return
+     */
+    @AutoLog(value = "查询广告组的加速探索报表接口")
+    @ApiOperation(value = "查询广告组的加速探索报表接口", notes = "查询广告组的加速探索报表接口")
+    @PostMapping(value = "/querySpeedExploreReport")
+    public Result<Object> querySpeedExploreReport(@RequestBody JSONObject data) {
+        try {
+            return kuaishouGroupExploreService.querySpeedExploreReport(data);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            return Result.error("操作失败");
+        }
+    }
+
+
+    /**
+     * 添加
+     *
+     * @param kuaishouGroupExplore
+     * @return
+     */
+    @AutoLog(value = "广告组的加速探索报表-添加")
+    @ApiOperation(value = "广告组的加速探索报表-添加", notes = "广告组的加速探索报表-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouGroupExplore> add(@RequestBody KuaishouGroupExplore kuaishouGroupExplore) {
+        Result<KuaishouGroupExplore> result = new Result<>();
+        try {
+            kuaishouGroupExploreService.save(kuaishouGroupExplore);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouGroupExplore
+     * @return
+     */
+    @AutoLog(value = "广告组的加速探索报表-编辑")
+    @ApiOperation(value = "广告组的加速探索报表-编辑", notes = "广告组的加速探索报表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouGroupExplore> edit(@RequestBody KuaishouGroupExplore kuaishouGroupExplore) {
+        Result<KuaishouGroupExplore> result = new Result<KuaishouGroupExplore>();
+        KuaishouGroupExplore kuaishouGroupExploreEntity = kuaishouGroupExploreService.getById(kuaishouGroupExplore.getId());
+        if (kuaishouGroupExploreEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouGroupExploreService.updateById(kuaishouGroupExplore);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "广告组的加速探索报表-通过id删除")
+    @ApiOperation(value = "广告组的加速探索报表-通过id删除", notes = "广告组的加速探索报表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouGroupExploreService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "广告组的加速探索报表-批量删除")
+    @ApiOperation(value = "广告组的加速探索报表-批量删除", notes = "广告组的加速探索报表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouGroupExplore> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouGroupExplore> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouGroupExploreService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "广告组的加速探索报表-通过id查询")
+    @ApiOperation(value = "广告组的加速探索报表-通过id查询", notes = "广告组的加速探索报表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouGroupExplore> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouGroupExplore> result = new Result<>();
+        KuaishouGroupExplore kuaishouGroupExplore = kuaishouGroupExploreService.getById(id);
+        if (kuaishouGroupExplore == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouGroupExplore);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouGroupExplore> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouGroupExplore kuaishouGroupExplore = JSON.parseObject(deString, KuaishouGroupExplore.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouGroupExplore, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouGroupExplore> pageList = kuaishouGroupExploreService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "广告组的加速探索报表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouGroupExplore.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("广告组的加速探索报表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouGroupExplore> listKuaishouGroupExplores = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouGroupExplore.class, params);
+                kuaishouGroupExploreService.saveBatch(listKuaishouGroupExplores);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouGroupExplores.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 112 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouGroupExplore.java

@@ -0,0 +1,112 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 广告组的加速探索报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-02-02
+ */
+@Data
+@TableName("ctop_kuaishou_group_explore")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_group_explore对象", description = "广告组的加速探索报表")
+public class KuaishouGroupExplore {
+
+    /**
+     * id
+     */
+    @TableId
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 广告组ID
+     */
+    @Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+    private Long unitId;
+    /**
+     * 探索预算,单位:里
+     */
+    @Excel(name = "探索预算,单位:里", width = 15)
+    @ApiModelProperty(value = "探索预算,单位:里")
+    private Long exploreBudget;
+    /**
+     * 优化目标
+     */
+    @Excel(name = "优化目标", width = 15)
+    @ApiModelProperty(value = "优化目标")
+    private Integer ocpxActionType;
+    /**
+     * 总消耗
+     */
+    @Excel(name = "总消耗", width = 15)
+    @ApiModelProperty(value = "总消耗")
+    private Long totalCharge;
+    /**
+     * 封面曝光数
+     */
+    @Excel(name = "封面曝光数", width = 15)
+    @ApiModelProperty(value = "封面曝光数")
+    private Long impression;
+    /**
+     * 素材曝光数
+     */
+    @Excel(name = "素材曝光数", width = 15)
+    @ApiModelProperty(value = "素材曝光数")
+    private Long click;
+    /**
+     * 封面点击数
+     */
+    @Excel(name = "封面点击数", width = 15)
+    @ApiModelProperty(value = "封面点击数")
+    private Long photoClick;
+    /**
+     * 转化数
+     */
+    @Excel(name = "转化数", width = 15)
+    @ApiModelProperty(value = "转化数")
+    private Long unifiedConversion;
+    /**
+     * 转化成本
+     */
+    @Excel(name = "转化成本", width = 15)
+    @ApiModelProperty(value = "转化成本")
+    private java.math.BigDecimal unitfiedConversionCost;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAgent.java

@@ -41,13 +41,13 @@ public class KuaishouReportDailyAgent {
     @Excel(name = "账户ID", width = 15)
     @Excel(name = "账户ID", width = 15)
     @ApiModelProperty(value = "账户ID")
     @ApiModelProperty(value = "账户ID")
     @TableId(type = IdType.INPUT)
     @TableId(type = IdType.INPUT)
-    private java.lang.Integer accountId;
+    private java.lang.Long accountId;
     /**
     /**
      * 快手ID
      * 快手ID
      */
      */
     @Excel(name = "快手ID", width = 15)
     @Excel(name = "快手ID", width = 15)
     @ApiModelProperty(value = "快手ID")
     @ApiModelProperty(value = "快手ID")
-    private java.lang.Integer kid;
+    private java.lang.Long kid;
     /**
     /**
      * 广告主名称
      * 广告主名称
      */
      */

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
+import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 广告组的加速探索报表
+ * @author: jeecg-boot
+ * @date:   2021-02-02
+ * @cersion: V1.0
+ */
+public interface KuaishouGroupExploreMapper extends BaseMapper<KuaishouGroupExplore> {
+
+}

+ 14 - 14
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouDailyAgentMapper.xml

@@ -6,24 +6,24 @@
     <!-- 代理商列表-->
     <!-- 代理商列表-->
     <select id="companyReport" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum">
     <select id="companyReport" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum">
         select
         select
-        date_time as date,  <!-- 日期 -->
-        sum(charged_campaign_count) as costCampaignCount,  <!-- 有消费计划数 -->
-        sum(total_balance_in_yuan) as balance,  <!-- 总余额 -->
-        sum(total_charged_in_yuan) as cost,  <!-- 总消耗 -->
-        sum(real_charged_in_yuan) as xianjinCost,  <!-- 现金消耗 -->
-        sum(total_rebate_real_charged_in_yuan) as fandianCost,  <!-- 后返消耗 -->
-        sum(contract_rebate_real_charged_in_yuan) as kuangfanCost,  <!-- 框返消耗 -->
-        sum(direct_rebate_real_charged_in_yuan) as jiliCost,  <!-- 激励账户消耗 -->
-        sum(credit_real_charged_in_yuan) as xinyongCost,  <!-- 信用账户消耗 -->
-        sum(ad_photo_impression) as fengmianShowCount,  <!-- 封面曝光数 -->
-        sum(ad_photo_click) as fengmianClickCount,  <!-- 封面点击数 -->
-        sum(ad_item_impression) as sucaiShowCount,  <!-- 素材曝光数 -->
-        sum(ad_item_click) as convertCount,  <!-- 行为数 -->
+        date_time as date,
+        sum(charged_campaign_count) as costCampaignCount,
+        sum(total_balance_in_yuan) as balance,
+        sum(total_charged_in_yuan) as cost,
+        sum(real_charged_in_yuan) as xianjinCost,
+        sum(total_rebate_real_charged_in_yuan) as fandianCost,
+        sum(contract_rebate_real_charged_in_yuan) as kuangfanCost,
+        sum(direct_rebate_real_charged_in_yuan) as jiliCost,
+        sum(credit_real_charged_in_yuan) as xinyongCost,
+        sum(ad_photo_impression) as fengmianShowCount,
+        sum(ad_photo_click) as fengmianClickCount,
+        sum(ad_item_impression) as sucaiShowCount,
+        sum(ad_item_click) as convertCount,
         (case when sum(ad_photo_impression) != 0
         (case when sum(ad_photo_impression) != 0
         then sum(ad_photo_click) / sum(ad_photo_impression)
         then sum(ad_photo_click) / sum(ad_photo_impression)
         else 0
         else 0
         end
         end
-        ) as fengmianClickRate,  <!-- 封面点击率 -->
+        ) as fengmianClickRate,
         (
         (
         case when sum(ad_photo_click) != 0
         case when sum(ad_photo_click) != 0
         THEN sum(ad_item_click) / sum(ad_photo_click)
         THEN sum(ad_item_click) / sum(ad_photo_click)

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouGroupExploreMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.mapper.KuaishouGroupExploreMapper">
+
+</mapper>

+ 23 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouGroupExploreService.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 广告组的加速探索报表
+ * @Author: jeecg-boot
+ * @Date:   2021-02-02
+ * @Version: V1.0
+ */
+public interface IKuaishouGroupExploreService extends IService<KuaishouGroupExplore> {
+
+    public Result<Object> unitExploreInfoGet(JSONObject data);
+
+    public Result<Object> unitExploreBudgetUpdate(JSONObject data);
+
+    public Result<Object> unitExploreStatusPause(JSONObject data);
+
+    public Result<Object> querySpeedExploreReport(JSONObject data);
+}

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

@@ -0,0 +1,228 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouGroupExploreMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 广告组的加速探索报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2021-02-02
+ */
+@Slf4j
+@Service
+public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupExploreMapper, KuaishouGroupExplore> implements IKuaishouGroupExploreService {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+
+    /**
+     * 查询加速探索信息
+     *
+     * @param
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> unitExploreInfoGet(JSONObject data) {
+        try {
+            Long accountId = data.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择广告主");
+            }
+            Long unitId = data.getLong("unitId");
+            if (Check.isNull(unitId)) {
+                return Result.error("请选择广告组");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_INFO_GET;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("unit_id", unitId);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return Result.ok(resultJson.getJSONObject("data"));
+                } else {
+                    log.info("查询加速探索信息失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("查询加速探索信息失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("查询加速探索信息失败", e);
+        }
+        return Result.error("查询加速探索信息失败");
+    }
+
+    /**
+     * 广告组的加速探索预算设置
+     *
+     * @param
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> unitExploreBudgetUpdate(JSONObject data) {
+        try {
+            Long accountId = data.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择广告主");
+            }
+            Long unitId = data.getLong("unitId");
+            if (Check.isNull(unitId)) {
+                return Result.error("请选择广告组");
+            }
+            Long exploreBudget = data.getLong("exploreBudget");
+            if (Check.isNull(exploreBudget)) {
+                return Result.error("请填写加速探索预算");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_BUDGET_UPDATE;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("unit_id", unitId);
+            params.put("explore_budget", exploreBudget);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return Result.ok(resultJson.getJSONObject("data"));
+                } else {
+                    log.info("广告组的加速探索预算设置失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("广告组的加速探索预算设置失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("广告组的加速探索预算设置失败", e);
+        }
+        return Result.error("广告组的加速探索预算设置失败");
+    }
+
+    /**
+     * 暂停广告组的加速探索预算接口
+     *
+     * @param
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> unitExploreStatusPause(JSONObject data) {
+        try {
+            Long accountId = data.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择广告主");
+            }
+            Long unitId = data.getLong("unitId");
+            if (Check.isNull(unitId)) {
+                return Result.error("请选择广告组");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_STATUS_PAUSE;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("unit_id", unitId);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return Result.ok(resultJson.getJSONObject("data"));
+                } else {
+                    log.info("暂停广告组的加速探索预算失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("暂停广告组的加速探索预算失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("暂停广告组的加速探索预算失败", e);
+        }
+        return Result.error("暂停广告组的加速探索预算失败");
+    }
+
+    /**
+     * 查询广告组的加速探索报表接口
+     *
+     * @param
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> querySpeedExploreReport(JSONObject data) {
+        try {
+            Long accountId = data.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                return Result.error("请选择广告主");
+            }
+            Long unitId = data.getLong("unitId");
+            if (Check.isNull(unitId)) {
+                return Result.error("请选择广告组");
+            }
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.QUERY_SPEED_EXPLORE_REPORT;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token.getAccessToken());
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+            params.put("advertiser_id", accountId);
+            params.put("unit_id", unitId);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject exploreJson = resultJson.getJSONObject("data");
+                    KuaishouGroupExplore kuaishouGroupExplore = JSONObject.toJavaObject(exploreJson, KuaishouGroupExplore.class);
+                    if (Check.isNull(kuaishouGroupExplore)) {
+                        return Result.error("查询失败,结果为空");
+                    }
+                    QueryWrapper<KuaishouGroupExplore> queryWrapper = new QueryWrapper<>();
+                    queryWrapper.eq("unit_id", kuaishouGroupExplore.getUnitId());
+                    KuaishouGroupExplore one = this.getOne(queryWrapper);
+                    if (!Check.isNull(one)) {
+                        kuaishouGroupExplore.setId(one.getId());
+                    }
+                    kuaishouGroupExplore.setAccountId(accountId);
+                    this.saveOrUpdate(kuaishouGroupExplore);
+                    return Result.ok("添加成功");
+                } else {
+                    log.info("查询广告组的加速探索报表失败,accountId:{},返回信息:{}", accountId, resultJson);
+                    return Result.error("查询广告组的加速探索报表失败," + resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            log.error("查询广告组的加速探索报表失败", e);
+        }
+        return Result.error("查询广告组的加速探索报表失败");
+    }
+
+
+}

+ 196 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/entity/BaseReportBytedanceVideoDaily.java

@@ -0,0 +1,196 @@
+package cn.com.ctop.toutiao.modules.link.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 头条视频报表源数据
+ */
+@Data
+@TableName("base_report_bytedance_video_daily")
+public class BaseReportBytedanceVideoDaily {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**账户id*/
+	private Long accountId;
+	/**md5*/
+	private Long materialId;
+	/**数据起始时间*/
+	private String statDatetime;
+	/**总花费*/
+	private BigDecimal cost;
+	/**点击量*/
+	private Long click;
+	/**应用下载-激活*/
+	private Long active;
+	/**应用下载-安卓下载完成*/
+	private Long downloadFinish;
+	/**应用下载-安卓下载开始*/
+	private Long downloadStart;
+	/**应用下载-安卓安装完成*/
+	private Long installFinish;
+	/**应用下载-注册*/
+	private Long register;
+	/**应用下载-付费数*/
+	private Long payCount;
+	/**应用下载-到达uv*/
+	private Long inAppUv;
+	/**应用下载-详情页到站uv*/
+	private Long inAppDetailUv;
+	/**应用下载-加入购物车*/
+	private Long inAppCart;
+	/**应用下载-提交订单*/
+	private Long inAppOrder;
+	/**应用下载-付费*/
+	private Long inAppPay;
+	/**落地页-电话拨打数*/
+	private Long phone;
+	/**表单提交数*/
+	private Long form;
+	/**落地页-地图搜索*/
+	private Long mapSearch;
+	/**落地页-按钮button*/
+	private Long button;
+	/**落地页-关键页面浏览*/
+	private Long viewMaterial;
+	/**落地页-QQ咨询数*/
+	private Long qq;
+	/**落地页-抽奖数*/
+	private Long lottery;
+	/**落地页-投票*/
+	private Long vote;
+	/**落地页-页面跳转*/
+	private Long redirect;
+	/**落地页-商品购买*/
+	private Long shopping;
+	/**落地页-在线咨询*/
+	private Long consult;
+	/**落地页-微信*/
+	private Long wechat;
+	/**落地页-智能电话确认拨打*/
+	private Long phoneConfirm;
+	/**落地页-智能电话确认接通*/
+	private Long phoneConnect;
+	/**落地页-智能电话有效咨询*/
+	private Long consultEffective;
+	/**视频-总播放*/
+	private Long totalPlay;
+	/**视频-有效播放*/
+	private Long validPlay;
+	/**视频-wifi播放*/
+	private Long wifiPlay;
+	/**视频-播放25%进度率*/
+	private BigDecimal play25FeedBreakRate;
+	/**视频-播放25%进度总数*/
+	private Long play25FeedBreak;
+	/**视频-播放50%进度总数*/
+	private Long play50FeedBreak;
+	/**视频-播放75%进度总数*/
+	private Long play75FeedBreak;
+	/**视频-播放100%进度总数*/
+	private Long play100FeedBreak;
+	/**附加创意-电话按钮*/
+	private Long advancedCreativePhoneClick;
+	/**附加创意-在线咨询*/
+	private Long advancedCreativeCounselClick;
+	/**附加创意-表单提交*/
+	private Long advancedCreativeFormClick;
+	/**互动数据-分享数*/
+	private Long shareMaterial;
+	/**互动数据-评论数*/
+	private Long commentMaterial;
+	/**互动数据-新增关注数*/
+	private Long follow;
+	/**互动数据-主页访问量*/
+	private Long homeVisited;
+	/**互动数据-挑战赛查看数*/
+	private Long iesChallengeClick;
+	/**互动数据-音乐查看数*/
+	private Long iesMusicClick;
+	/**次留数*/
+	private Long nextDayOpen;
+	/**次留率*/
+	private BigDecimal nextDayOpenRate;
+	/**次留成本*/
+	private BigDecimal nextDayOpenCost;
+	/**activePayAmount*/
+	private Long activePayAmount;
+	/**视频数据-有效播放成本*/
+	private BigDecimal validPlayCost;
+	/**附加创意-附加创意卡券领取*/
+	private Long advancedCreativeCouponAddition;
+	/**convertMaterial*/
+	private Long convertMaterial;
+	/**应用下载广告数据-付费成本*/
+	private BigDecimal activePayCost;
+	/**落地页转化数据-下载开始*/
+	private Long download;
+	/**cpc*/
+	private BigDecimal cpc;
+	/**互动数据-POI点击数*/
+	private Long locationClick;
+	/**	视频数据-播完率*/
+	private BigDecimal playOverRate;
+	/**展现数据-点击率*/
+	private BigDecimal ctr;
+	/**cpm*/
+	private BigDecimal cpm;
+	/**视频数据-WiFi播放占比*/
+	private BigDecimal wifiPlayRate;
+	/**互动数据-点赞数*/
+	private Long likeMaterial;
+	/**应用下载广告数据-激活成本*/
+	private BigDecimal activeCost;
+	/**应用下载广告数据-关键行为成本*/
+	private BigDecimal gameAddictionCost;
+	/**应用下载广告数据-关键行为数*/
+	private Long gameAddiction;
+	/**应用下载广告数据-激活率*/
+	private BigDecimal activeRate;
+	/**	应用下载广告数据-关键行为率*/
+	private BigDecimal gameAddictionRate;
+	/**应用下载广告数据-注册率*/
+	private BigDecimal activeRegisterRate;
+	/**应用下载广告数据-安卓下载完成成本*/
+	private BigDecimal downloadFinishCost;
+	/**应用下载广告数据-注册成本*/
+	private BigDecimal activeRegisterCost;
+	/**展示数*/
+	private Long materialShow;
+	/**转化数据-转化率*/
+	private BigDecimal convertRate;
+	/**应用下载广告数据-安卓下载完成率*/
+	private BigDecimal downloadFinishRate;
+	/**应用下载广告数据-安卓安装完成率*/
+	private BigDecimal installFinishRate;
+	/**	落地页转化数据-建站卡券领取*/
+	private Long coupon;
+	/**落地页转化数据-卡券页领取*/
+	private Long couponSinglePage;
+	/**playOver*/
+	private Long playOver;
+	/**应用下载广告数据-安卓下载开始成本*/
+	private BigDecimal downloadStartCost;
+	/**落地页转化数据-短信咨询*/
+	private Long message;
+	/**视频数据-有效播放率*/
+	private BigDecimal validPlayRate;
+	/**视频数据-平均单次播放时长*/
+	private BigDecimal averagePlayTimePerPlay;
+	/**转化数据-转化成本*/
+	private BigDecimal convertCost;
+	/**应用下载广告数据-安卓安装完成成本*/
+	private BigDecimal installFinishCost;
+	/**应用下载广告数据-安卓下载开始率*/
+	private BigDecimal downloadStartRate;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+}

+ 436 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/entity/ETLReportBytedanceVideo.java

@@ -0,0 +1,436 @@
+package cn.com.ctop.toutiao.modules.link.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 头条视频报表ETL
+ */
+@Data
+@TableName("etl_report_bytedance_video")
+public class ETLReportBytedanceVideo {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**materialId*/
+	@Excel(name = "materialId", width = 15)
+    @ApiModelProperty(value = "materialId")
+	private Long materialId;
+
+	private String materialName;
+	/**视频唯一标识*/
+	private String md5;
+
+	private String url;
+
+	private String toutiaoUrl;
+
+	private String coverUrl;
+
+	/**账户id*/
+	@Excel(name = "账户id", width = 15)
+    @ApiModelProperty(value = "账户id")
+	private Long accountId;
+
+	private String accountName;
+	/**项目id*/
+	@Excel(name = "项目id", width = 15)
+    @ApiModelProperty(value = "项目id")
+	private Long projectId;
+	/**项目名称*/
+	@Excel(name = "项目名称", width = 15)
+    @ApiModelProperty(value = "项目名称")
+	private String projectName;
+	/**项目id*/
+	@Excel(name = "项目id", width = 15)
+    @ApiModelProperty(value = "项目id")
+	private Long productId;
+	/**产品名称*/
+	@Excel(name = "产品名称", width = 15)
+    @ApiModelProperty(value = "产品名称")
+	private String productName;
+	/**广告主id*/
+	@Excel(name = "广告主id", width = 15)
+    @ApiModelProperty(value = "广告主id")
+	private String advertiserId;
+	/**广告主名称*/
+	@Excel(name = "广告主名称", width = 15)
+    @ApiModelProperty(value = "广告主名称")
+	private String advertiserName;
+	/**剪辑id*/
+	@Excel(name = "剪辑id", width = 15)
+    @ApiModelProperty(value = "剪辑id")
+	private String clipId;
+	/**剪辑名称*/
+	@Excel(name = "剪辑名称", width = 15)
+    @ApiModelProperty(value = "剪辑名称")
+	private String clipName;
+	/**拍摄id*/
+	@Excel(name = "拍摄id", width = 15)
+    @ApiModelProperty(value = "拍摄id")
+	private String shotId;
+	/**拍摄名称*/
+	@Excel(name = "拍摄名称", width = 15)
+    @ApiModelProperty(value = "拍摄名称")
+	private String shotName;
+	/**编导id*/
+	@Excel(name = "编导id", width = 15)
+    @ApiModelProperty(value = "编导id")
+	private String planId;
+	/**编导名称*/
+	@Excel(name = "编导名称", width = 15)
+    @ApiModelProperty(value = "编导名称")
+	private String planName;
+	/**materialCreateTime*/
+	private String materialCreateTime;
+	/**数据起始时间*/
+	@Excel(name = "数据起始时间", width = 15)
+    @ApiModelProperty(value = "数据起始时间")
+	private String statDatetime;
+	/**点击量*/
+	@Excel(name = "点击量", width = 15)
+    @ApiModelProperty(value = "点击量")
+	private Long click;
+	/**总花费*/
+	@Excel(name = "总花费", width = 15)
+    @ApiModelProperty(value = "总花费")
+	private BigDecimal cost;
+	/**应用下载-激活*/
+	@Excel(name = "应用下载-激活", width = 15)
+    @ApiModelProperty(value = "应用下载-激活")
+	private Long active;
+	/**应用下载-安卓下载完成*/
+	@Excel(name = "应用下载-安卓下载完成", width = 15)
+    @ApiModelProperty(value = "应用下载-安卓下载完成")
+	private Long downloadFinish;
+	/**应用下载-安卓下载开始*/
+	@Excel(name = "应用下载-安卓下载开始", width = 15)
+    @ApiModelProperty(value = "应用下载-安卓下载开始")
+	private Long downloadStart;
+	/**应用下载-安卓安装完成*/
+	@Excel(name = "应用下载-安卓安装完成", width = 15)
+    @ApiModelProperty(value = "应用下载-安卓安装完成")
+	private Long installFinish;
+	/**应用下载-注册*/
+	@Excel(name = "应用下载-注册", width = 15)
+    @ApiModelProperty(value = "应用下载-注册")
+	private Long register;
+	/**应用下载-付费数*/
+	@Excel(name = "应用下载-付费数", width = 15)
+    @ApiModelProperty(value = "应用下载-付费数")
+	private Long payCount;
+	/**应用下载-到达uv*/
+	@Excel(name = "应用下载-到达uv", width = 15)
+    @ApiModelProperty(value = "应用下载-到达uv")
+	private Long inAppUv;
+	/**应用下载-详情页到站uv*/
+	@Excel(name = "应用下载-详情页到站uv", width = 15)
+    @ApiModelProperty(value = "应用下载-详情页到站uv")
+	private Long inAppDetailUv;
+	/**应用下载-加入购物车*/
+	@Excel(name = "应用下载-加入购物车", width = 15)
+    @ApiModelProperty(value = "应用下载-加入购物车")
+	private Long inAppCart;
+	/**应用下载-提交订单*/
+	@Excel(name = "应用下载-提交订单", width = 15)
+    @ApiModelProperty(value = "应用下载-提交订单")
+	private Long inAppOrder;
+	/**应用下载-付费*/
+	@Excel(name = "应用下载-付费", width = 15)
+    @ApiModelProperty(value = "应用下载-付费")
+	private Long inAppPay;
+	/**落地页-电话拨打数*/
+	@Excel(name = "落地页-电话拨打数", width = 15)
+    @ApiModelProperty(value = "落地页-电话拨打数")
+	private Long phone;
+	/**表单提交数*/
+	@Excel(name = "表单提交数", width = 15)
+    @ApiModelProperty(value = "表单提交数")
+	private Long form;
+	/**落地页-地图搜索*/
+	@Excel(name = "落地页-地图搜索", width = 15)
+    @ApiModelProperty(value = "落地页-地图搜索")
+	private Long mapSearch;
+	/**落地页-按钮button*/
+	@Excel(name = "落地页-按钮button", width = 15)
+    @ApiModelProperty(value = "落地页-按钮button")
+	private Long button;
+	/**落地页-关键页面浏览*/
+	@Excel(name = "落地页-关键页面浏览", width = 15)
+    @ApiModelProperty(value = "落地页-关键页面浏览")
+	private Long viewMaterial;
+	/**落地页-QQ咨询数*/
+	@Excel(name = "落地页-QQ咨询数", width = 15)
+    @ApiModelProperty(value = "落地页-QQ咨询数")
+	private Long qq;
+	/**落地页-抽奖数*/
+	@Excel(name = "落地页-抽奖数", width = 15)
+    @ApiModelProperty(value = "落地页-抽奖数")
+	private Long lottery;
+	/**落地页-投票*/
+	@Excel(name = "落地页-投票", width = 15)
+    @ApiModelProperty(value = "落地页-投票")
+	private Long vote;
+	/**落地页-页面跳转*/
+	@Excel(name = "落地页-页面跳转", width = 15)
+    @ApiModelProperty(value = "落地页-页面跳转")
+	private Long redirect;
+	/**落地页-商品购买*/
+	@Excel(name = "落地页-商品购买", width = 15)
+    @ApiModelProperty(value = "落地页-商品购买")
+	private Long shopping;
+	/**落地页-在线咨询*/
+	@Excel(name = "落地页-在线咨询", width = 15)
+    @ApiModelProperty(value = "落地页-在线咨询")
+	private Long consult;
+	/**落地页-微信*/
+	@Excel(name = "落地页-微信", width = 15)
+    @ApiModelProperty(value = "落地页-微信")
+	private Long wechat;
+	/**落地页-智能电话确认拨打*/
+	@Excel(name = "落地页-智能电话确认拨打", width = 15)
+    @ApiModelProperty(value = "落地页-智能电话确认拨打")
+	private Long phoneConfirm;
+	/**落地页-智能电话确认接通*/
+	@Excel(name = "落地页-智能电话确认接通", width = 15)
+    @ApiModelProperty(value = "落地页-智能电话确认接通")
+	private Long phoneConnect;
+	/**落地页-智能电话有效咨询*/
+	@Excel(name = "落地页-智能电话有效咨询", width = 15)
+    @ApiModelProperty(value = "落地页-智能电话有效咨询")
+	private Long consultEffective;
+	/**视频-总播放*/
+	@Excel(name = "视频-总播放", width = 15)
+    @ApiModelProperty(value = "视频-总播放")
+	private Long totalPlay;
+	/**视频-有效播放*/
+	@Excel(name = "视频-有效播放", width = 15)
+    @ApiModelProperty(value = "视频-有效播放")
+	private Long validPlay;
+	/**视频-wifi播放*/
+	@Excel(name = "视频-wifi播放", width = 15)
+    @ApiModelProperty(value = "视频-wifi播放")
+	private Long wifiPlay;
+	/**视频-播放25%进度率*/
+	@Excel(name = "视频-播放25%进度率", width = 15)
+    @ApiModelProperty(value = "视频-播放25%进度率")
+	private BigDecimal play25FeedBreakRate;
+	/**视频-播放25%进度总数*/
+	@Excel(name = "视频-播放25%进度总数", width = 15)
+    @ApiModelProperty(value = "视频-播放25%进度总数")
+	private Long play25FeedBreak;
+	/**视频-播放50%进度总数*/
+	@Excel(name = "视频-播放50%进度总数", width = 15)
+    @ApiModelProperty(value = "视频-播放50%进度总数")
+	private Long play50FeedBreak;
+	/**视频-播放75%进度总数*/
+	@Excel(name = "视频-播放75%进度总数", width = 15)
+    @ApiModelProperty(value = "视频-播放75%进度总数")
+	private Long play75FeedBreak;
+	/**视频-播放100%进度总数*/
+	@Excel(name = "视频-播放100%进度总数", width = 15)
+    @ApiModelProperty(value = "视频-播放100%进度总数")
+	private Long play100FeedBreak;
+	/**附加创意-电话按钮*/
+	@Excel(name = "附加创意-电话按钮", width = 15)
+    @ApiModelProperty(value = "附加创意-电话按钮")
+	private Long advancedCreativePhoneClick;
+	/**附加创意-在线咨询*/
+	@Excel(name = "附加创意-在线咨询", width = 15)
+    @ApiModelProperty(value = "附加创意-在线咨询")
+	private Long advancedCreativeCounselClick;
+	/**附加创意-表单提交*/
+	@Excel(name = "附加创意-表单提交", width = 15)
+    @ApiModelProperty(value = "附加创意-表单提交")
+	private Long advancedCreativeFormClick;
+	/**互动数据-分享数*/
+	@Excel(name = "互动数据-分享数", width = 15)
+    @ApiModelProperty(value = "互动数据-分享数")
+	private Long shareMaterial;
+	/**互动数据-评论数*/
+	@Excel(name = "互动数据-评论数", width = 15)
+    @ApiModelProperty(value = "互动数据-评论数")
+	private Long commentMaterial;
+	/**互动数据-新增关注数*/
+	@Excel(name = "互动数据-新增关注数", width = 15)
+    @ApiModelProperty(value = "互动数据-新增关注数")
+	private Long follow;
+	/**互动数据-主页访问量*/
+	@Excel(name = "互动数据-主页访问量", width = 15)
+    @ApiModelProperty(value = "互动数据-主页访问量")
+	private Long homeVisited;
+	/**互动数据-挑战赛查看数*/
+	@Excel(name = "互动数据-挑战赛查看数", width = 15)
+    @ApiModelProperty(value = "互动数据-挑战赛查看数")
+	private Long iesChallengeClick;
+	/**互动数据-音乐查看数*/
+	@Excel(name = "互动数据-音乐查看数", width = 15)
+    @ApiModelProperty(value = "互动数据-音乐查看数")
+	private Long iesMusicClick;
+	/**次留数*/
+	@Excel(name = "次留数", width = 15)
+    @ApiModelProperty(value = "次留数")
+	private Long nextDayOpen;
+	/**次留率*/
+	@Excel(name = "次留率", width = 15)
+    @ApiModelProperty(value = "次留率")
+	private BigDecimal nextDayOpenRate;
+	/**次留成本*/
+	@Excel(name = "次留成本", width = 15)
+    @ApiModelProperty(value = "次留成本")
+	private BigDecimal nextDayOpenCost;
+	/**activePayAmount*/
+	@Excel(name = "activePayAmount", width = 15)
+    @ApiModelProperty(value = "activePayAmount")
+	private Long activePayAmount;
+	/**视频数据-有效播放成本*/
+	@Excel(name = "视频数据-有效播放成本", width = 15)
+    @ApiModelProperty(value = "视频数据-有效播放成本")
+	private BigDecimal validPlayCost;
+	/**附加创意-附加创意卡券领取*/
+	@Excel(name = "附加创意-附加创意卡券领取", width = 15)
+    @ApiModelProperty(value = "附加创意-附加创意卡券领取")
+	private Long advancedCreativeCouponAddition;
+	/**convertMaterial*/
+	@Excel(name = "convertMaterial", width = 15)
+    @ApiModelProperty(value = "convertMaterial")
+	private Long convertMaterial;
+	/**应用下载广告数据-付费成本*/
+	@Excel(name = "应用下载广告数据-付费成本", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-付费成本")
+	private BigDecimal activePayCost;
+	/**落地页转化数据-下载开始*/
+	@Excel(name = "落地页转化数据-下载开始", width = 15)
+    @ApiModelProperty(value = "落地页转化数据-下载开始")
+	private Long download;
+	/**cpc*/
+	@Excel(name = "cpc", width = 15)
+    @ApiModelProperty(value = "cpc")
+	private BigDecimal cpc;
+	/**互动数据-POI点击数*/
+	@Excel(name = "互动数据-POI点击数", width = 15)
+    @ApiModelProperty(value = "互动数据-POI点击数")
+	private Long locationClick;
+	/**	视频数据-播完率*/
+	@Excel(name = "	视频数据-播完率", width = 15)
+    @ApiModelProperty(value = "	视频数据-播完率")
+	private BigDecimal playOverRate;
+	/**展现数据-点击率*/
+	@Excel(name = "展现数据-点击率", width = 15)
+    @ApiModelProperty(value = "展现数据-点击率")
+	private BigDecimal ctr;
+	/**cpm*/
+	@Excel(name = "cpm", width = 15)
+    @ApiModelProperty(value = "cpm")
+	private BigDecimal cpm;
+	/**视频数据-WiFi播放占比*/
+	@Excel(name = "视频数据-WiFi播放占比", width = 15)
+    @ApiModelProperty(value = "视频数据-WiFi播放占比")
+	private BigDecimal wifiPlayRate;
+	/**互动数据-点赞数*/
+	@Excel(name = "互动数据-点赞数", width = 15)
+    @ApiModelProperty(value = "互动数据-点赞数")
+	private Long likeMaterial;
+	/**应用下载广告数据-激活成本*/
+	@Excel(name = "应用下载广告数据-激活成本", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-激活成本")
+	private BigDecimal activeCost;
+	/**应用下载广告数据-关键行为成本*/
+	@Excel(name = "应用下载广告数据-关键行为成本", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-关键行为成本")
+	private BigDecimal gameAddictionCost;
+	/**应用下载广告数据-关键行为数*/
+	@Excel(name = "应用下载广告数据-关键行为数", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-关键行为数")
+	private Long gameAddiction;
+	/**应用下载广告数据-激活率*/
+	@Excel(name = "应用下载广告数据-激活率", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-激活率")
+	private BigDecimal activeRate;
+	/**	应用下载广告数据-关键行为率*/
+	@Excel(name = "	应用下载广告数据-关键行为率", width = 15)
+    @ApiModelProperty(value = "	应用下载广告数据-关键行为率")
+	private BigDecimal gameAddictionRate;
+	/**应用下载广告数据-注册率*/
+	@Excel(name = "应用下载广告数据-注册率", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-注册率")
+	private BigDecimal activeRegisterRate;
+	/**应用下载广告数据-安卓下载完成成本*/
+	@Excel(name = "应用下载广告数据-安卓下载完成成本", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-安卓下载完成成本")
+	private BigDecimal downloadFinishCost;
+	/**应用下载广告数据-注册成本*/
+	@Excel(name = "应用下载广告数据-注册成本", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-注册成本")
+	private BigDecimal activeRegisterCost;
+	/**materailShow*/
+	@Excel(name = "materailShow", width = 15)
+    @ApiModelProperty(value = "materailShow")
+	private Long materailShow;
+	/**转化数据-转化率*/
+	@Excel(name = "转化数据-转化率", width = 15)
+    @ApiModelProperty(value = "转化数据-转化率")
+	private BigDecimal convertRate;
+	/**应用下载广告数据-安卓下载完成率*/
+	@Excel(name = "应用下载广告数据-安卓下载完成率", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-安卓下载完成率")
+	private BigDecimal downloadFinishRate;
+	/**应用下载广告数据-安卓安装完成率*/
+	@Excel(name = "应用下载广告数据-安卓安装完成率", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-安卓安装完成率")
+	private BigDecimal installFinishRate;
+	/**	落地页转化数据-建站卡券领取*/
+	@Excel(name = "	落地页转化数据-建站卡券领取", width = 15)
+    @ApiModelProperty(value = "	落地页转化数据-建站卡券领取")
+	private Long coupon;
+	/**落地页转化数据-卡券页领取*/
+	@Excel(name = "落地页转化数据-卡券页领取", width = 15)
+    @ApiModelProperty(value = "落地页转化数据-卡券页领取")
+	private Long couponSinglePage;
+	/**playOver*/
+	@Excel(name = "playOver", width = 15)
+    @ApiModelProperty(value = "playOver")
+	private Long playOver;
+	/**应用下载广告数据-安卓下载开始成本*/
+	@Excel(name = "应用下载广告数据-安卓下载开始成本", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-安卓下载开始成本")
+	private BigDecimal downloadStartCost;
+	/**落地页转化数据-短信咨询*/
+	@Excel(name = "落地页转化数据-短信咨询", width = 15)
+    @ApiModelProperty(value = "落地页转化数据-短信咨询")
+	private Long message;
+	/**视频数据-有效播放率*/
+	@Excel(name = "视频数据-有效播放率", width = 15)
+    @ApiModelProperty(value = "视频数据-有效播放率")
+	private BigDecimal validPlayRate;
+	/**视频数据-平均单次播放时长*/
+	@Excel(name = "视频数据-平均单次播放时长", width = 15)
+    @ApiModelProperty(value = "视频数据-平均单次播放时长")
+	private BigDecimal averagePlayTimePerPlay;
+	/**转化数据-转化成本*/
+	@Excel(name = "转化数据-转化成本", width = 15)
+    @ApiModelProperty(value = "转化数据-转化成本")
+	private BigDecimal convertCost;
+	/**应用下载广告数据-安卓安装完成成本*/
+	@Excel(name = "应用下载广告数据-安卓安装完成成本", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-安卓安装完成成本")
+	private BigDecimal installFinishCost;
+	/**应用下载广告数据-安卓下载开始率*/
+	@Excel(name = "应用下载广告数据-安卓下载开始率", width = 15)
+    @ApiModelProperty(value = "应用下载广告数据-安卓下载开始率")
+	private BigDecimal downloadStartRate;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 11 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/BaseReportBytedanceVideoDailyMapper.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.toutiao.modules.link.mapper;
+
+import cn.com.ctop.toutiao.modules.link.entity.BaseReportBytedanceVideoDaily;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 头条视频报表源数据
+ */
+public interface BaseReportBytedanceVideoDailyMapper extends BaseMapper<BaseReportBytedanceVideoDaily> {
+
+}

+ 29 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/ETLReportBytedanceVideoMapper.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.toutiao.modules.link.mapper;
+
+import cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 头条视频报表ETL
+ */
+public interface ETLReportBytedanceVideoMapper extends BaseMapper<ETLReportBytedanceVideo> {
+
+    //根据material_id查询MD5、头条视频链接
+    JSONObject queryVideoInfoByMaterialId(@Param("materialId") Long materialId);
+    //根据MD5查询视频信息
+    JSONObject queryMaterialVideoByMd5(@Param("md5") String md5);
+
+    JSONObject queryMaterialVideoByMd5Old(@Param("md5") String md5);
+
+    //根据MD5查询素材关联人信息
+    JSONObject queryRelatePersonByMd5(@Param("md5") String md5);
+
+    JSONObject queryRelatePersonByMd5Old(@Param("md5") String md5);
+
+    //根据accountId 查询项目、产品、广告主信息
+    JSONObject queryAccountDetailByAccountId(@Param("accountId") Long accountId);
+}

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/BaseReportBytedanceVideoDailyMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.toutiao.modules.link.mapper.BaseReportBytedanceVideoDailyMapper">
+
+</mapper>

+ 109 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/mapper/xml/ETLReportBytedanceVideoMapper.xml

@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.toutiao.modules.link.mapper.ETLReportBytedanceVideoMapper">
+    <select id="queryVideoInfoByMaterialId"  resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            signature AS md5,
+            video_url AS url
+        FROM
+            ctop_bytedance_video_info
+        WHERE
+            material_id = #{materialId}
+        limit 1
+    </select>
+    <select id="queryMaterialVideoByMd5"  resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            `name`  as materialName,
+            url,
+            cover_url coverUrl,
+            create_time as createTime
+        FROM
+            ctop_material_video_info
+        WHERE
+            md5 = #{md5}
+        LIMIT 1
+    </select>
+    <select id="queryMaterialVideoByMd5Old"  resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            material_name as materialName,
+            url,
+            cover_url coverUrl,
+            create_time as createTime
+        FROM
+            ctop_material_info
+        WHERE
+            code = #{md5}
+        LIMIT 1
+    </select>
+    <select id="queryRelatePersonByMd5"  resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            clip_id clipId,
+            clip_name clipaname,
+            shot_id shotId,
+            shot_name shotName,
+            plan_id planId,
+            plan_name planName
+        FROM
+            ctop_material_video_author
+        WHERE
+            video_md5 = #{md5}
+        LIMIT 1
+    </select>
+    <select id="queryRelatePersonByMd5Old"  resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            clip_id clipId,
+            (select realname from sys_user where id=clip_id) as clipName,
+            shot_id shotId,
+            (select realname from sys_user where id=shot_id) as shotName,
+            plan_id planId,
+            (select realname from sys_user where id=plan_id) as planName
+        FROM
+            ctop_material_ascription
+        WHERE
+            code = #{md5}
+        LIMIT 1
+    </select>
+    <select id="queryAccountDetailByAccountId"  resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            t1.advertiser_id as advertiserId,
+            (SELECT `name` from ctop_advertiser where id=t1.advertiser_id limit 1) as advertiserName,
+            project_id as projectId,
+            (SELECT `project_name` from ctop_project where id=t1.project_id limit 1) as projectName,
+            auth_name as accountName
+        FROM
+            ctop_user_allocation t1
+        WHERE
+            account_id = #{accountId}
+        LIMIT 1
+    </select>
+
+    <select id="queryETLData"  resultType="cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo">
+        SELECT
+            t1.*,
+            t3.clip_id clipId,
+            (select realname from sys_user where id=t3.clip_id) as clipName,
+            t3.shot_id shotId,
+            (select realname from sys_user where id=t3.shot_id) as shotName,
+            t3.plan_id planId,
+            (select realname from sys_user where id=t3.plan_id) as planName,
+            t5.advertiser_id as advertiserId,
+            (SELECT `name` from ctop_advertiser where id= t5.advertiser_id limit 1) as advertiserName,
+            t5.project_id as projectId,
+            (SELECT `project_name` from ctop_project where id= t5.project_id limit 1) as projectName,
+            t5.auth_name as accountName,
+            t4.material_name as materialName,
+            t4.url,
+            t4.cover_url coverUrl,
+            t4.create_time as materialCreateTime,
+            t2.signature AS md5,
+            t2.video_url AS toutiaoUrl
+        FROM
+            (SELECT * from base_report_bytedance_video_daily where stat_datetime=#{statDate}) t1
+                LEFT JOIN (select material_id,signature,video_url from ctop_bytedance_video_info where material_id in (SELECT DISTINCT material_id from base_report_bytedance_video_daily where stat_datetime=#{statDate})
+            ) t2 ON t1.material_id = t2.material_id
+                LEFT JOIN ctop_material_ascription t3 on t2.signature=t3.code
+                LEFT JOIN ctop_material_info t4 on t4.code=t2.signature
+                LEFT JOIN (SELECT account_id, advertiser_id,project_id,auth_name from ctop_user_allocation where account_id in (SELECT DISTINCT account_id from base_report_bytedance_video_daily where stat_datetime=#{statDate})) t5 on t1.account_id=t5.account_id
+        GROUP BY t1.id
+    </select>
+</mapper>

+ 11 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/IBaseReportBytedanceVideoDailyService.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.toutiao.modules.link.service;
+
+import cn.com.ctop.toutiao.modules.link.entity.BaseReportBytedanceVideoDaily;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *  头条视频报表源数据
+ */
+public interface IBaseReportBytedanceVideoDailyService extends IService<BaseReportBytedanceVideoDaily> {
+
+}

+ 17 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/IETLReportBytedanceVideoService.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.toutiao.modules.link.service;
+
+import cn.com.ctop.toutiao.modules.link.entity.BaseReportBytedanceVideoDaily;
+import cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * 头条视频报表ETL
+ */
+public interface IETLReportBytedanceVideoService extends IService<ETLReportBytedanceVideo> {
+
+    List<BaseReportBytedanceVideoDaily> listByStatDate(String statDate);
+
+    void cleanETL(String statDate);
+}

+ 15 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/impl/BaseReportBytedanceVideoDailyServiceImpl.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.toutiao.modules.link.service.impl;
+
+import cn.com.ctop.toutiao.modules.link.entity.BaseReportBytedanceVideoDaily;
+import cn.com.ctop.toutiao.modules.link.mapper.BaseReportBytedanceVideoDailyMapper;
+import cn.com.ctop.toutiao.modules.link.service.IBaseReportBytedanceVideoDailyService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 头条视频报表源数据
+ */
+@Service
+public class BaseReportBytedanceVideoDailyServiceImpl extends ServiceImpl<BaseReportBytedanceVideoDailyMapper, BaseReportBytedanceVideoDaily> implements IBaseReportBytedanceVideoDailyService {
+
+}

+ 105 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/link/service/impl/ETLReportBytedanceVideoServiceImpl.java

@@ -0,0 +1,105 @@
+package cn.com.ctop.toutiao.modules.link.service.impl;
+
+import cn.com.ctop.toutiao.modules.link.entity.BaseReportBytedanceVideoDaily;
+import cn.com.ctop.toutiao.modules.link.entity.ETLReportBytedanceVideo;
+import cn.com.ctop.toutiao.modules.link.mapper.ETLReportBytedanceVideoMapper;
+import cn.com.ctop.toutiao.modules.link.service.IBaseReportBytedanceVideoDailyService;
+import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.context.XxlJobHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 头条视频报表ETL
+ */
+@Slf4j
+@Service
+public class ETLReportBytedanceVideoServiceImpl extends ServiceImpl<ETLReportBytedanceVideoMapper, ETLReportBytedanceVideo> implements IETLReportBytedanceVideoService {
+
+    @Autowired
+    IBaseReportBytedanceVideoDailyService baseReportBytedanceVideoDailyService;
+
+    @Autowired
+    ETLReportBytedanceVideoMapper etlReportBytedanceVideoMapper;
+
+    @Override
+    public List<BaseReportBytedanceVideoDaily> listByStatDate(String statDate) {
+        QueryWrapper<BaseReportBytedanceVideoDaily>  queryWrapper= new QueryWrapper<>();
+        queryWrapper.eq("stat_datetime",statDate);
+        return baseReportBytedanceVideoDailyService.list(queryWrapper);
+    }
+
+/*    @Override
+    public void cleanETL(String statDate) {
+        List<BaseReportBytedanceVideoDaily> source = listByStatDate(statDate);
+        if(source.isEmpty()){
+            XxlJobHelper.log("头条数据报表清洗ETL异常,请检查数据源");
+        }
+        List<ETLReportBytedanceVideo> batch = new ArrayList<>();
+        source.forEach(it->{
+            JSONObject videoInfo= etlReportBytedanceVideoMapper.queryVideoInfoByMaterialId(it.getMaterialId());
+            if(null==videoInfo||videoInfo.isEmpty()){
+                XxlJobHelper.log("头条数据报表清洗ETL异常,未关联到video_info,materialId:{}",it.getMaterialId());
+            }else {
+                //TODO 暂时从老数据库查询,新素材库怕同步数据有偏差
+                //JSONObject materialVideo= etlReportBytedanceVideoMapper.queryMaterialVideoByMd5(videoInfo.getString("md5"));
+                JSONObject materialVideo= etlReportBytedanceVideoMapper.queryMaterialVideoByMd5Old(videoInfo.getString("md5"));
+                //JSONObject relatePerson=etlReportBytedanceVideoMapper.queryRelatePersonByMd5(videoInfo.getString("md5"));
+                JSONObject relatePerson=etlReportBytedanceVideoMapper.queryRelatePersonByMd5Old(videoInfo.getString("md5"));
+
+                JSONObject accountDetail=etlReportBytedanceVideoMapper.queryAccountDetailByAccountId(it.getAccountId());
+                ETLReportBytedanceVideo temp = JSONObject.toJavaObject(JSONObject.parseObject(JSON.toJSON(it).toString()),ETLReportBytedanceVideo.class);
+                temp.setMd5(videoInfo.getString("md5"));
+                temp.setToutiaoUrl(videoInfo.getString("url"));
+                if(null!=materialVideo&&!materialVideo.isEmpty()) {
+                    temp.setUrl(materialVideo.getString("url"));
+                    temp.setCoverUrl(materialVideo.getString("coverUrl"));
+                    temp.setMaterialName(materialVideo.getString("materialName"));
+                    temp.setMaterialCreateTime(materialVideo.getDate("createTime").toString());
+                }
+                if(null!=accountDetail&&!accountDetail.isEmpty()){
+                    temp.setAccountName(accountDetail.getString("accountName"));
+                    temp.setProjectId(accountDetail.getLong("projectId"));
+                    temp.setProjectName(accountDetail.getString("projectName"));
+                    temp.setProductId(accountDetail.getLong("productId"));
+                    temp.setProductName(accountDetail.getString("productName"));
+                    temp.setAdvertiserId(accountDetail.getString("advertiserId"));
+                    temp.setAdvertiserName(accountDetail.getString("advertiserName"));
+                }
+                if(null!=relatePerson&&!relatePerson.isEmpty()){
+                    temp.setClipId(relatePerson.getString("clipId"));
+                    temp.setClipName(relatePerson.getString("clipName"));
+                    temp.setShotId(relatePerson.getString("shotId"));
+                    temp.setShotName(relatePerson.getString("shotName"));
+                    temp.setPlanId(relatePerson.getString("planId"));
+                    temp.setPlanName(relatePerson.getString("planName"));
+                }
+                batch.add(temp);
+            }
+            this.saveBatch(batch);
+        });
+    }*/
+
+    @Override
+    public void cleanETL(String statDate) {
+        List<ETLReportBytedanceVideo> etlReportBytedanceVideos = etlReportBytedanceVideoMapper.queryETLData(statDate);
+        if(etlReportBytedanceVideos.isEmpty()){
+            log.warn("{},头条etl报表清洗异常,base数据源为空",statDate);
+            return;
+        }
+        boolean result = this.saveBatch(etlReportBytedanceVideos);
+        if(result)
+            log.info("{},头条etl报表清洗完成,数量:{}",statDate,etlReportBytedanceVideos.size());
+        else
+            log.error("{},头条etl报表清洗失败,请重试",statDate);
+    }
+
+}

+ 25 - 43
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceVideoReportMapper.xml

@@ -3,20 +3,19 @@
 <mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.BytedanceVideoReportMapper">
 <mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.BytedanceVideoReportMapper">
 
 
     <select id="queryVideoReportBy" resultType="com.alibaba.fastjson.JSONObject">
     <select id="queryVideoReportBy" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT * from (SELECT
-        t1.signature,
-        t1.video_url as url,
-        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.clip_id=u.id where t3.material_id=t1.signature limit 1),'') AS clip,
-        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.shot_id=u.id where t3.material_id=t1.signature limit 1),'') AS shot,
-        IFNULL((SELECT u.realname FROM ctop_material_ascription t3 LEFT JOIN sys_user u on t3.plan_id=u.id where t3.material_id=t1.signature limit 1),'') AS plan,
-        (select t2.cover_url from ctop_material_info t2 where t2.code=t1.signature limit 1) AS converUrl,
-        (select t2.material_name from ctop_material_info t2 where t2.code=t1.signature limit 1) AS materialName,
-        (SELECT project_name FROM ctop_project t4 WHERE t4.id = t3.project_id) AS projectName,
-        (select t2.create_time from ctop_material_info t2 where t2.code=t1.signature limit 1) as createTime,
+        SELECT
+        t1.md5 signature,
+        IFNULL(t1.toutiao_url, '') AS url,
+        t1.cover_url AS converUrl,
+        t1.clip_name AS clip,
+        t1.shot_name AS shot,
+        t1.plan_name AS plan,
+        t1.material_name AS materialName,
+        t1.project_name AS projectName,
+        t1.material_create_time AS createTime,
         ${filed}
         ${filed}
         FROM
         FROM
-        ctop_bytedance_video_report_daily t1
-        LEFT JOIN ctop_user_allocation t3 ON t3.account_id=t1.account_id
+        etl_report_bytedance_video t1
         WHERE
         WHERE
         t1.stat_datetime >= #{startDate}
         t1.stat_datetime >= #{startDate}
         AND t1.stat_datetime &lt;= #{endDate}
         AND t1.stat_datetime &lt;= #{endDate}
@@ -27,44 +26,27 @@
                 #{item}
                 #{item}
             </foreach>
             </foreach>
         </if>
         </if>
-        AND t1.video_url is not null
-        GROUP BY t1.signature
-        ) t
-        WHERE (t.clip LIKE '%${clip}%')
-        AND (t.shot LIKE '%${shot}%')
-        AND (t.plan LIKE '%${plan}%')
+        AND (t1.clip_name LIKE '%${clip}%')
+        AND (t1.shot_name LIKE '%${shot}%')
+        AND (t1.plan_name LIKE '%${plan}%')
+        GROUP BY t1.md5
         ORDER BY ${target} ${order}
         ORDER BY ${target} ${order}
     </select>
     </select>
 
 
     <select id="queryVideoDetailBy" resultType="com.alibaba.fastjson.JSONObject">
     <select id="queryVideoDetailBy" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         SELECT
         t1.stat_datetime as statDate,
         t1.stat_datetime as statDate,
-        t1.signature,
-        t1.video_url as url,
-        (select t2.cover_url from ctop_material_info t2 where t2.code=t1.signature limit 1) AS converUrl,
-        (select t2.material_name from ctop_material_info t2 where t2.code=t1.signature limit 1) AS materialName,
-        (
-        SELECT
-        project_name
-        FROM
-        ctop_project t4
-        WHERE
-        t4.id = t3.project_id
-        ) AS projectName,
-        (
-        SELECT
-        advertiser_name
-        FROM
-        ctop_project t4
-        WHERE
-        t4.id = t3.project_id limit 1
-        ) AS advertiserName,
-        (select t2.create_time from ctop_material_info t2 where t2.code=t1.signature limit 1) as createTime,
+        t1.md5 signature,
+        IFNULL(t1.toutiao_url, '') AS url,
+        t1.cover_url AS converUrl,
+        t1.material_name AS materialName,
+        t1.project_name AS projectName,
+        t1.advertiser_name as advertiserName,
+        t1.material_create_time AS createTime,
         ${filed}
         ${filed}
         FROM
         FROM
-        ctop_bytedance_video_report_daily t1
-        LEFT JOIN ctop_user_allocation t3 ON t3.account_id=t1.account_id
-        WHERE t1.signature=#{signature}
+        etl_report_bytedance_video t1
+        WHERE t1.md5=#{signature}
         AND t1.stat_datetime >= #{startDate}
         AND t1.stat_datetime >= #{startDate}
         AND t1.stat_datetime &lt;= #{endDate}
         AND t1.stat_datetime &lt;= #{endDate}
         <if test="accountIds != null">
         <if test="accountIds != null">
@@ -74,7 +56,7 @@
                 #{item}
                 #{item}
             </foreach>
             </foreach>
         </if>
         </if>
-        GROUP BY t1.signature,t1.stat_datetime
+        GROUP BY t1.md5,t1.stat_datetime
         order by t1.stat_datetime desc
         order by t1.stat_datetime desc
     </select>
     </select>
 </mapper>
 </mapper>

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.service;
 package cn.com.ctop.toutiao.modules.report.service;
 
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
@@ -13,4 +14,6 @@ public interface IBytedanceVideoReportService {
     List<JSONObject> getVideoDetailBy(JSONArray accountIds, String startDate, String endDate, String filed, String signature);
     List<JSONObject> getVideoDetailBy(JSONArray accountIds, String startDate, String endDate, String filed, String signature);
 
 
     List<JSONObject> exportExcelReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan);
     List<JSONObject> exportExcelReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan);
+
+    void pullVideoReport(CtopOauthToken oauthToken,String startDate, String endDate,int page);
 }
 }

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

@@ -543,11 +543,6 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             record.setUpdateTime(new Date());
             record.setUpdateTime(new Date());
             recordService.updateById(record);
             recordService.updateById(record);
         }
         }
-//        bytedanceReportMaterialDailyMapper.updateImageReportCode();
-//        bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
-//        bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
-//        bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
-//        bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
         log.info("头条素材报表结束 当前accountId为:{}  {}~{}" , accountId, record.getStartDate(),record.getEndDate());
         log.info("头条素材报表结束 当前accountId为:{}  {}~{}" , accountId, record.getStartDate(),record.getEndDate());
     }
     }
     @Resource
     @Resource

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

@@ -1,22 +1,35 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.toutiao.modules.link.entity.BaseReportBytedanceVideoDaily;
+import cn.com.ctop.toutiao.modules.link.service.IBaseReportBytedanceVideoDailyService;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceVideoReportMapper;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceVideoReportMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoReportService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoReportService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
+@Slf4j
 @Service
 @Service
 public class BytedanceVideoReportServiceImpl implements IBytedanceVideoReportService {
 public class BytedanceVideoReportServiceImpl implements IBytedanceVideoReportService {
 
 
     @Autowired
     @Autowired
     BytedanceVideoReportMapper bytedanceVideoReportMapper;
     BytedanceVideoReportMapper bytedanceVideoReportMapper;
 
 
+    @Autowired
+    IBaseReportBytedanceVideoDailyService baseReportBytedanceVideoDailyService;
+
     @Override
     @Override
     public PageInfo<JSONObject> getVideoReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan, int pageSize, int pageNo) {
     public PageInfo<JSONObject> getVideoReportBy(JSONArray accountIds, String startDate, String endDate, String filed, String target, String order, String clip, String shot, String plan, int pageSize, int pageNo) {
         PageHelper.startPage(pageNo,pageSize);
         PageHelper.startPage(pageNo,pageSize);
@@ -34,4 +47,58 @@ public class BytedanceVideoReportServiceImpl implements IBytedanceVideoReportSer
         return bytedanceVideoReportMapper.queryVideoReportBy(accountIds,startDate,endDate,filed,target,order,clip,shot,plan);
         return bytedanceVideoReportMapper.queryVideoReportBy(accountIds,startDate,endDate,filed,target,order,clip,shot,plan);
     }
     }
 
 
+    @Override
+    public void pullVideoReport(CtopOauthToken oauthToken, String startDate, String endDate, int page) {
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", " application/json");
+        headers.put("Access-Token", oauthToken.getAccessToken());
+
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", oauthToken.getAccountId());
+        param.put("start_date",startDate);
+        param.put("end_date",endDate);
+        param.put("page_size", 200);
+        param.put("page", page);
+
+        JSONObject resultJson = JSONObject.parseObject(HttpUtils.httpGetRequest("https://ad.oceanengine.com/open_api/2/report/video/get/", headers, param));
+        if (Check.isNull(resultJson)) {
+            log.warn("拉取头条视频报表返回结果为空,advertiserId:{}", oauthToken.getAccountId());
+            return;
+        }
+        if(resultJson.getInteger("code")!=0){
+            log.error("拉取头条视频表异常,advertiserId:{},message:{}", oauthToken.getAccountId(),resultJson.getString("message"));
+            return;
+        }
+        JSONObject data = resultJson.getJSONObject("data");
+        if (null == data || data.size() <= 0) {
+            log.error("拉取头条视频表异常,data is null");
+            return;
+        }
+
+        JSONArray list= data.getJSONArray("list");
+        if(list.isEmpty()){
+            log.warn("拉取头条视频表,数据为空advertiserId:{}", oauthToken.getAccountId());
+            return;
+        }
+        List<BaseReportBytedanceVideoDaily> batch =new ArrayList<>();
+        list.forEach(videoReport->{
+            JSONObject videoReportJSONObject= (JSONObject)videoReport;
+            Long materialId= videoReportJSONObject.getJSONObject("dimensions").getLong("material_id");
+            JSONObject metrics= videoReportJSONObject.getJSONObject("metrics");
+            BaseReportBytedanceVideoDaily temp= JSONObject.toJavaObject(metrics,BaseReportBytedanceVideoDaily.class);
+            temp.setMaterialShow(metrics.getLong("show"));
+            temp.setConvertMaterial(metrics.getLong("convert"));
+            temp.setAccountId(oauthToken.getAccountId());
+            temp.setMaterialId(materialId);
+            temp.setStatDatetime(startDate);
+            batch.add(temp);
+        });
+        baseReportBytedanceVideoDailyService.saveBatch(batch);
+
+        if(resultJson.getJSONObject("data").getJSONObject("page_info").getInteger("total_page")>page){
+            pullVideoReport(oauthToken, startDate, endDate, page + 1);
+        }
+    }
+
 }
 }

+ 4 - 4
module-toutiao/src/main/resources/json_template/bytedance_video_report_mapping.json

@@ -4,11 +4,11 @@
     "comment": "消耗"
     "comment": "消耗"
   },
   },
   "showMaterial": {
   "showMaterial": {
-    "filed": "IFNULL(sum(t1.show_material),0) as showMaterial ",
+    "filed": "IFNULL(sum(t1.material_show),0) as showMaterial ",
     "comment": "展示数"
     "comment": "展示数"
   },
   },
   "cpm": {
   "cpm": {
-    "filed": "CASE WHEN sum(t1.cost) / sum(t1.show_material) IS NULL THEN 0 ELSE ROUND((sum(t1.cost) / sum(t1.show_material)) * 1000, 2 ) END AS cpm ",
+    "filed": "CASE WHEN sum(t1.cost) / sum(t1.material_show) IS NULL THEN 0 ELSE ROUND((sum(t1.cost) / sum(t1.material_show)) * 1000, 2 ) END AS cpm ",
     "comment": "平均千次展现费用"
     "comment": "平均千次展现费用"
   },
   },
   "clickMaterial": {
   "clickMaterial": {
@@ -16,7 +16,7 @@
     "comment": "点击数"
     "comment": "点击数"
   },
   },
   "ctr": {
   "ctr": {
-    "filed": "CASE WHEN sum(t1.click) / sum(t1.show_material) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.click) / sum(t1.show_material)) * 100,2),'%') END AS ctr ",
+    "filed": "CASE WHEN sum(t1.click) / sum(t1.material_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.click) / sum(t1.material_show)) * 100,2),'%') END AS ctr ",
     "comment": "点击率"
     "comment": "点击率"
   },
   },
   "cpc": {
   "cpc": {
@@ -32,7 +32,7 @@
     "comment": "转化成本"
     "comment": "转化成本"
   },
   },
   "convertRate": {
   "convertRate": {
-    "filed": "CASE WHEN sum(t1.convert_material) / sum(t1.cost) IS NULL THEN 0 ELSE concat(round(sum(t1.convert_material) / sum(t1.cost)*100,2),'%') end AS convertRate ",
+    "filed": "CASE WHEN sum(t1.convert_material) / sum(t1.material_show) IS NULL THEN 0 ELSE concat(round(sum(t1.convert_material) / sum(t1.material_show)*100,2),'%') end AS convertRate ",
     "comment": "转化率"
     "comment": "转化率"
   },
   },
   "downloadStart": {
   "downloadStart": {