Browse Source

Merge remote-tracking branch 'origin/kuaishou-ai-advertising' into kuaishou-ai-advertising

liyuyi@c-top.com.cn 4 years ago
parent
commit
a3e5b9eb95
67 changed files with 1702 additions and 371 deletions
  1. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 7 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTemplate.java
  3. 29 29
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyListPageMapper.xml
  4. 7 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouStrategyListPageServiceImpl.java
  5. 326 102
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiStrategyServiceImpl.java
  6. 28 8
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  7. 4 3
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleAccountThresholdServiceImpl.java
  8. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  9. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  10. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  11. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java
  12. 51 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountAudienceReportJob.java
  13. 33 11
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAudienceReportJob.java
  14. 22 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEffectVideoJob.java
  15. 31 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  16. 5 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java
  17. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java
  18. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  19. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouStrategy.java
  20. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupTemplateMapper.java
  21. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouStrategyMapper.java
  22. 11 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTemplateMapper.xml
  23. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouStrategyMapper.xml
  24. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  25. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupTemplateService.java
  26. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  27. 11 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouStrategyService.java
  28. 28 41
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  29. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActionBarTextServiceImpl.java
  30. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  31. 149 56
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java
  32. 4 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  33. 0 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  34. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouStrategyServiceImpl.java
  35. 26 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyAccount.java
  36. 1 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyBussiness.java
  37. 9 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java
  38. 2 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreativeStatistic.java
  39. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAccountMapper.java
  40. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyBusinessMapper.java
  41. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyAccountService.java
  42. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyAgeService.java
  43. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyBusinessService.java
  44. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyCityService.java
  45. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyClientService.java
  46. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyGenderService.java
  47. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyProvinceService.java
  48. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyAccountServiceImpl.java
  49. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyAgeServiceImpl.java
  50. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyBusinessServiceImpl.java
  51. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyCityServiceImpl.java
  52. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyClientServiceImpl.java
  53. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyGenderServiceImpl.java
  54. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyProvinceServiceImpl.java
  55. 80 48
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java
  56. 6 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java
  57. 12 14
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouVideoEtlInfoServiceImpl.java
  58. 150 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceVideoEtlInfoController.java
  59. 74 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceVideoEtlInfo.java
  60. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java
  61. 16 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceVideoEtlInfoMapper.java
  62. 34 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml
  63. 8 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceVideoEtlInfoMapper.xml
  64. 4 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceReportMaterialDailyService.java
  65. 18 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceVideoEtlInfoService.java
  66. 11 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportMaterialDailyServiceImpl.java
  67. 179 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceVideoEtlInfoServiceImpl.java

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

@@ -56,6 +56,7 @@ public class ShiroConfig {
         Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
         // 配置不会被拦截的链接 顺序判断
         //登录接口排除
+        filterChainDefinitionMap.put("/ctop/materialInfo/**", "anon");
         filterChainDefinitionMap.put("/sys/mLogin", "anon");
         filterChainDefinitionMap.put("/sys/login", "anon");
         filterChainDefinitionMap.put("/sys/wxlogin", "anon");

+ 7 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTemplate.java

@@ -22,12 +22,18 @@ public class AiKuaishouStrategyTemplate {
 	private Long accountId;
 	/**策略模板名称*/
 	private String templateName;
-	/**策略类型 1:素材+定向  2:时间+出价 3:素材+出价*/
+	/**策略类型 1:素材+出价 2:素材+定向  3:时间+出价 */
 	private Integer templateType;
 	/**测试方向*/
 	private String testDirection;
 	/**素材选择方式*/
 	private String materialSelectMethod;
+	/**
+	 * 组内素材组合模式
+	 * single 单视频+不同封面
+	 * mixed  多视频+各自封面
+	 */
+	private String materialFixType;
 	/**状态1可用 0不可用*/
 	private Integer status;
 	/**createTime*/

+ 29 - 29
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyListPageMapper.xml

@@ -4,35 +4,35 @@
 
     <select id="queryStrategyBy" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-            t1.id,
-            t1.strategy_state as strategyState,
-            t1.strategy_name as strategyName,
-            t1.create_time as createTime,
-            t1.account_id as accountId,
-            '' as status,
-            t1.scenes,
-            t1.budget,
-            IFNULL(sum(t3.charge),0) as cost,
-            IFNULL(sum(t3.photo_show),0) as photoShow,
-            IFNULL(sum(t3.photo_click),0) as photoClick,
-            CASE WHEN sum(t3.photo_click) / sum(t3.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t3.photo_click) / sum(t3.photo_show)) * 100,2),'%') END AS clickRate,
-            IFNULL(sum(t3.aclick),0) as aclick,
-            IFNULL(sum(t3.bclick),0) as bclick,
-            CASE WHEN sum(t3.bclick) / sum(t3.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t3.bclick) / sum(t3.aclick)) * 100,2),'%') END AS bClickRate,
-            CASE WHEN sum(t3.charge) / sum(t3.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t3.charge) / sum(t3.photo_show)) * 1000, 2 ) END AS cpm ,
-            CASE WHEN sum(t3.charge) / sum(t3.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t3.charge) / sum(t3.photo_click)), 2) END AS cpc ,
-            IFNULL(sum(t3.activation),0) as active,
-            CASE WHEN sum(t3.charge) / sum(t3.activation) IS NULL THEN 0 ELSE sum(t3.charge) / sum(t3.activation) end AS activeCost ,
-            CASE WHEN sum(t3.activation) / sum(t3.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t3.activation) / sum(t3.download_completed)*100,2),'%') end as activeRate ,
-            IFNULL(sum(t3.event_register),0) as register,
-            CASE WHEN sum(t3.charge) / sum(t3.event_register) IS NULL THEN 0 ELSE round(sum(t3.charge)/sum(t3.event_register),3) end as activeRegisterCost ,
-            CASE WHEN sum(t3.event_register) / sum(t3.activation) IS NULL THEN 0 ELSE concat(round(sum(t3.event_register) / sum(t3.activation)*100,2),'%') end as activeRegisterRate ,
-            IFNULL(sum(t3.event_next_day_stay),0) as nextDayOpen,
-            CASE WHEN sum(t3.event_next_day_stay) / sum(t3.activation) IS NULL THEN 0 ELSE concat(round(sum(t3.event_next_day_stay) / sum(t3.activation)*100,2),'%') end as nextDayOpenRate
+        t1.id,
+        t1.strategy_state as strategyState,
+        t1.strategy_name as strategyName,
+        t1.create_time as createTime,
+        t1.account_id as accountId,
+        '' as status,
+        t1.scenes,
+        t1.budget,
+        IFNULL(sum(t3.charge),0) as cost,
+        IFNULL(sum(t3.photo_show),0) as photoShow,
+        IFNULL(sum(t3.photo_click),0) as photoClick,
+        CASE WHEN sum(t3.photo_click) / sum(t3.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t3.photo_click) / sum(t3.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t3.aclick),0) as aclick,
+        IFNULL(sum(t3.bclick),0) as bclick,
+        CASE WHEN sum(t3.bclick) / sum(t3.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t3.bclick) / sum(t3.aclick)) * 100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t3.charge) / sum(t3.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t3.charge) / sum(t3.photo_show)) * 1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t3.charge) / sum(t3.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t3.charge) / sum(t3.photo_click)), 2) END AS cpc ,
+        IFNULL(sum(t3.activation),0) as active,
+        CASE WHEN sum(t3.charge) / sum(t3.activation) IS NULL THEN 0 ELSE sum(t3.charge) / sum(t3.activation) end AS activeCost ,
+        CASE WHEN sum(t3.activation) / sum(t3.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t3.activation) / sum(t3.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t3.event_register),0) as register,
+        CASE WHEN sum(t3.charge) / sum(t3.event_register) IS NULL THEN 0 ELSE round(sum(t3.charge)/sum(t3.event_register),3) end as activeRegisterCost ,
+        CASE WHEN sum(t3.event_register) / sum(t3.activation) IS NULL THEN 0 ELSE concat(round(sum(t3.event_register) / sum(t3.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t3.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t3.event_next_day_stay) / sum(t3.activation) IS NULL THEN 0 ELSE concat(round(sum(t3.event_next_day_stay) / sum(t3.activation)*100,2),'%') end as nextDayOpenRate
         FROM
-            ctop_kuaishou_strategy t1
-                LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.id=t2.strategy_id
-                left join ctop_kuaishou_report_daily_campaign t3 on t2.campaign_id=t3.campaign_id
+        ctop_kuaishou_strategy t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.id=t2.strategy_id
+        left join ctop_kuaishou_report_daily_campaign t3 on t2.campaign_id=t3.campaign_id
         where t1.account_id in
         <foreach item="item" index="index" collection="accountIds"
                  open="(" separator="," close=")">
@@ -42,7 +42,7 @@
             AND t1.strategy_name like '%${strategyName}%'
         </if>
         <if test="strategyState != null">
-            AND t1.t1.strategy_state=#{strategyState}
+            AND t1.strategy_state=#{strategyState}
         </if>
         <if test="id != null">
             AND t1.id=#{id}

+ 7 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouStrategyListPageServiceImpl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ads.service.impl;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -10,6 +11,7 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ads.mapper.AiKuaiShouStrategyListPageMapper;
 import org.jeecg.modules.ads.service.IAiKuaiShouStrategyListPageService;
+import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -24,15 +26,14 @@ public class AiKuaiShouStrategyListPageServiceImpl implements IAiKuaiShouStrateg
 
     @Autowired
     IUserAllocationService userAllocationService;
+    @Autowired
+    private ISysRoleService sysRoleService;
 
     @Override
     public PageInfo<JSONObject> pageStrategy(JSONObject params) {
         JSONArray accountIds= params.getJSONArray("accountIds");
-        if(accountIds.isEmpty()){
-            accountIds=listToJSONArray(userAllocationService.getAccountIdsByUserId(((LoginUser) SecurityUtils.getSubject().getPrincipal()).getId()));
-        }
-        if(accountIds.isEmpty()){
-            return null;
+        if(null == accountIds||accountIds.isEmpty()){
+            accountIds = null;
         }
         String strategyName=params.getString("strategyName");
         Integer strategyState=params.getInteger("strategyState");
@@ -74,7 +75,7 @@ public class AiKuaiShouStrategyListPageServiceImpl implements IAiKuaiShouStrateg
         int pageNo=params.getInteger("pageNo");
         int pageSize=params.getInteger("pageSize");
         PageHelper.startPage(pageNo, pageSize);
-        List<JSONObject> list=aiKuaiShouStrategyListPageMapper.queryCampaignByStrategyId(campaignId,unitName,unitId,status);
+        List<JSONObject> list=aiKuaiShouStrategyListPageMapper.queryUnitByCampaignId(campaignId,unitName,unitId,status);
         return new PageInfo<>(list);
     }
 

+ 326 - 102
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiStrategyServiceImpl.java

@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -68,6 +69,12 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             log.info("token获取失败=>accountId:{}",strategy.getAccountId());
             return;
         }
+        //1:获取相应账户下的最新的5条素材信息
+        List<KuaiShouVideoGet> videoGets = videoGetService.getNewVideoByAccountId(accountId,1);
+        if(null == videoGets){
+            log.info("素材获取失败=>accountId:{}",accountId);
+            return;
+        }
         //策略类型
         String scenes = strategy.getScenes();
         //根据策略类型获取策略模板信息
@@ -76,118 +83,330 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             log.info("策略模板信息获取失败=>testDirection:{}",scenes);
             return;
         }
-        //1:获取相应账户下的最新的5条素材信息
-        List<KuaiShouVideoGet> videoGets = videoGetService.getNewVideoByAccountId(accountId,5);
-        if(null == videoGets){
-            log.info("素材获取失败=>accountId:{}",accountId);
-            return;
-        }
-        //2:根据测试方向获取相应的定向拆分数据类型
-        List<AiKuaishouStrategyTargetBase>targetBases = targetBaseService.listByType(strategyTemplate.getTestDirection());
-        if(null == targetBases){
-            log.info("定向拆分信息获取失败=>testDirection:{}",strategyTemplate.getTestDirection());
-            return;
-        }
-        //3:获取相应字段相应的用户定义域
-        String definitionDomain = getStragyDefDomain(strategyTemplate,strategy);
-        System.out.println(definitionDomain);
-        //4:计算定向拆分逻辑
-        List<AiKuaishouStrategyTargetBase>getBases = splitBasesByDomain(definitionDomain,targetBases);
-        if(null == getBases||getBases.isEmpty()){
-            log.info("定向拆分失败=>definitionDomain:{}",definitionDomain);
-            return;
-        }
-        //5、策略--策略模板 关联表,写入数据库
-        AiKuaishouStrategyMiddle strategyMiddle = new AiKuaishouStrategyMiddle(strategyTemplate.getId(),strategy.getId());
-        middleService.save(strategyMiddle);
-
-        //7、一个计划,拼装创建计划的入参json
-        JSONObject campaignParams = new JSONObject();
-        campaignParams.put("advertiser_id",token.getAccountId());
-        Date campaignDate = new Date();
-        String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
-        campaignParams.put("campaign_name",strategy.getStrategyName()+ timestamp);
-        campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
-        campaignParams.put("day_budget",0L);
-        Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
-        Integer code = (Integer) campaignCreateResult.get("code");
-        String message = (String) campaignCreateResult.get("message");
-        if(code != 0 ){
-            log.info("计划创建失败=>message:{}",message);
-            return;
-        }
-        Long campaignId = (Long) campaignCreateResult.get("campaignId");
-        int unitCnt = 0;
-        // 8、根据定向和素材,两层循环 创建组和创意
-        for (AiKuaishouStrategyTargetBase item:getBases) {
-            unitCnt++;
-            // 策略定向拆分数据,写入数据库
-            AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
-            targetUnionService.save(targetUnion);
-            // 选择素材,创建创意
-            for(KuaiShouVideoGet videoItem: videoGets){
-                //拼装广告组参数
-                JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitCnt);
-                Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
-                Integer unitCode = (Integer) unitCreateResult.get("code");
-                String unitMessage = (String) unitCreateResult.get("message");
-                if(unitCode != 0 ){
-                    log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
-                    continue;
-                }
-                Long unitId = (Long) unitCreateResult.get("unitId");
-
-                JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
-                JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
-                // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
-                if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
-                    //直接创建创意
-                    createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,1,videoItem);
-                } else {
-                    // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
-                    // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
-                    List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
-                    List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
-                    // 其他情况下,一个素材搭配15张封面,生成15个创意
-                    if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
-                        log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+        String materialFixType = strategyTemplate.getMaterialFixType();
+        if(scenes.equals("1")){
+            //素材+出价
+            List<Long>getCapbids = splitCapBidByDomain(strategy.getCpaBidMin(),strategy.getCpaBidMax(),strategy.getStepSize());
+            if(null == getCapbids||getCapbids.isEmpty()){
+                log.info("出价范围异常=>start:{};end:{}",strategy.getCpaBidMin().toString(),strategy.getCpaBidMax().toString());
+                return;
+            }
+            //7、一个计划,拼装创建计划的入参json
+            JSONObject campaignParams = new JSONObject();
+            campaignParams.put("advertiser_id",token.getAccountId());
+            Date campaignDate = new Date();
+            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
+            campaignParams.put("campaign_name",strategy.getStrategyName()+ timestamp);
+            campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
+            campaignParams.put("day_budget",0L);
+            Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
+            Integer code = (Integer) campaignCreateResult.get("code");
+            String message = (String) campaignCreateResult.get("message");
+            if(code != 0 ){
+                log.info("计划创建失败=>message:{}",message);
+                return;
+            }
+            Long campaignId = (Long) campaignCreateResult.get("campaignId");
+            int unitCnt = 1;
+            // 8、根据定向和素材,两层循环 创建组和创意
+            for (Long item:getCapbids) {
+                //判定素材搭配方式
+                if(null!=materialFixType&&materialFixType.trim().equals("single")){
+                    // 选择素材,创建创意
+                    for(KuaiShouVideoGet videoItem: videoGets){
+                        //拼装广告组参数
+                        JSONObject unitParams = createUnitParams(token,campaignId,strategy,item,timestamp,unitCnt);
+                        Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                        Integer unitCode = (Integer) unitCreateResult.get("code");
+                        String unitMessage = (String) unitCreateResult.get("message");
+                        if(unitCode != 0 ){
+                            log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
+                            continue;
+                        }
+                        Long unitId = (Long) unitCreateResult.get("unitId");
+                        JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
+                        JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
+                        // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
+                        if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
+                            //直接创建创意
+                            createCreative(token,creativeParams,campaignId,unitId,strategy,null,1,videoItem);
+                        } else {
+                            // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
+                            // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
+                            List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                            List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
+                            // 其他情况下,一个素材搭配15张封面,生成15个创意
+                            if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
+                                log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+                                continue;
+                            }
+                            createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,15,null);
+                        }
+                    }
+                }else{
+                    //混搭素材逻辑
+                    JSONObject unitParams = createUnitParams(token,campaignId,strategy,item,timestamp,unitCnt);
+                    Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                    Integer unitCode = (Integer) unitCreateResult.get("code");
+                    String unitMessage = (String) unitCreateResult.get("message");
+                    if(unitCode != 0 ){
+                        log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
                         continue;
                     }
-                    int creativeCnt = 1;
-                    if (null!=orgFrameList&&!orgFrameList.isEmpty()) {
-                        for (int i = 0; i < orgFrameList.size(); i++) {
-                            System.out.println(creativeCnt);
-                            String imageCode = orgFrameList.get(i).getCode();
-                            String imageUrl = orgFrameList.get(i).getUrl();
-                            String imageToken = getImageToken(imageUrl,imageCode,accountId,token.getAccessToken());
-                            creativeParams.put("image_token",imageToken);
-                            createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,creativeCnt,videoItem);
-                            creativeCnt++;
-                            if (creativeCnt > 15) {
-                                break;
+                    Long unitId = (Long) unitCreateResult.get("unitId");
+                    // 选择素材,创建创意
+                    for(KuaiShouVideoGet videoItem: videoGets){
+                        //拼装广告组参数
+                        JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
+                        JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
+                        // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
+                        if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
+                            //直接创建创意
+                            createCreative(token,creativeParams,campaignId,unitId,strategy,null,1,videoItem);
+                        } else {
+                            // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
+                            // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
+                            List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                            List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
+                            // 其他情况下,一个素材搭配15张封面,生成15个创意
+                            if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
+                                log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+                                continue;
                             }
+                            createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,1,null);
                         }
                     }
-
-                    if ((null!=cutFrameList&&!cutFrameList.isEmpty()) && (creativeCnt<=15)){
-                        for (int i = 0; i < cutFrameList.size(); i++) {
-                            System.out.println(creativeCnt);
-                            String imageCode = cutFrameList.get(i).getSignature();
-                            String imageUrl = cutFrameList.get(i).getUrl();
-                            String imageToken = getImageToken(imageUrl,imageCode,accountId,token.getAccessToken());
-                            creativeParams.put("image_token",imageToken);
-                            createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,creativeCnt,videoItem);
-                            creativeCnt ++;
-                            if (creativeCnt > 15) {
-                                break;
+                }
+            }
+        }else if(scenes.equals(2)){
+            //素材+定向
+            //2:根据测试方向获取相应的定向拆分数据类型
+            List<AiKuaishouStrategyTargetBase>targetBases = targetBaseService.listByType(strategyTemplate.getTestDirection());
+            if(null == targetBases){
+                log.info("定向拆分信息获取失败=>testDirection:{}",strategyTemplate.getTestDirection());
+                return;
+            }
+            //3:获取相应字段相应的用户定义域
+            String definitionDomain = getStragyDefDomain(strategyTemplate,strategy);
+            //4:计算定向拆分逻辑
+            List<AiKuaishouStrategyTargetBase>getBases = splitBasesByDomain(definitionDomain,targetBases);
+            if(null == getBases||getBases.isEmpty()){
+                log.info("定向拆分失败=>definitionDomain:{}",definitionDomain);
+                return;
+            }
+            //5、策略--策略模板 关联表,写入数据库
+            AiKuaishouStrategyMiddle strategyMiddle = new AiKuaishouStrategyMiddle(strategyTemplate.getId(),strategy.getId());
+            middleService.save(strategyMiddle);
+            //7、一个计划,拼装创建计划的入参json
+            JSONObject campaignParams = new JSONObject();
+            campaignParams.put("advertiser_id",token.getAccountId());
+            Date campaignDate = new Date();
+            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
+            campaignParams.put("campaign_name",strategy.getStrategyName()+ timestamp);
+            campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
+            campaignParams.put("day_budget",0L);
+            Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
+            Integer code = (Integer) campaignCreateResult.get("code");
+            String message = (String) campaignCreateResult.get("message");
+            if(code != 0 ){
+                log.info("计划创建失败=>message:{}",message);
+                return;
+            }
+            Long campaignId = (Long) campaignCreateResult.get("campaignId");
+            int unitCnt = 0;
+            // 8、根据定向和素材,两层循环 创建组和创意
+            for (AiKuaishouStrategyTargetBase item:getBases) {
+                unitCnt++;
+                if(null!=materialFixType&&materialFixType.trim().equals("single")){
+                    // 策略定向拆分数据,写入数据库
+                    AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
+                    targetUnionService.save(targetUnion);
+                    // 选择素材,创建创意
+                    for(KuaiShouVideoGet videoItem: videoGets){
+                        //拼装广告组参数
+                        JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitCnt);
+                        Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                        Integer unitCode = (Integer) unitCreateResult.get("code");
+                        String unitMessage = (String) unitCreateResult.get("message");
+                        if(unitCode != 0 ){
+                            log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
+                            continue;
+                        }
+                        Long unitId = (Long) unitCreateResult.get("unitId");
+                        JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
+                        JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
+                        // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
+                        if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
+                            //直接创建创意
+                            createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,1,videoItem);
+                        } else {
+                            // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
+                            // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
+                            List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                            List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
+                            // 其他情况下,一个素材搭配15张封面,生成15个创意
+                            if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
+                                log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+                                continue;
                             }
+                            createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,15,targetUnion);
                         }
                     }
+                }else{
+                    // 策略定向拆分数据,写入数据库
+                    AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
+                    targetUnionService.save(targetUnion);
+                    // 选择素材,创建创意
+                    for(KuaiShouVideoGet videoItem: videoGets){
+                        //拼装广告组参数
+                        JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitCnt);
+                        Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
+                        Integer unitCode = (Integer) unitCreateResult.get("code");
+                        String unitMessage = (String) unitCreateResult.get("message");
+                        if(unitCode != 0 ){
+                            log.info("组创建失败=>accountId:{};message:{}",accountId,unitMessage);
+                            continue;
+                        }
+                        Long unitId = (Long) unitCreateResult.get("unitId");
+                        JSONObject creativeParams = creativeParams(token,unitId,videoItem,unitCnt,strategy);
+                        JSONArray sceneIdJsonArray = JSONArray.parseArray(strategy.getSceneId());
+                        // 如果广告位只包含 上下滑大屏广告(6),则一个素材搭配1张封面,生成1个创意
+                        if (sceneIdJsonArray.contains(6) && sceneIdJsonArray.size() == 1){
+                            //直接创建创意
+                            createCreative(token,creativeParams,campaignId,unitId,strategy,targetUnion,1,videoItem);
+                        } else {
+                            // 素材自带的封面 ctop_material_image_info 内部素材的自带封面,素造的没有
+                            // 素材的智能抽帧封面 ctop_material_cut_frame 其中素造的为8张封面,内部的为15张封面
+                            List<MaterialCutFrame> cutFrameList = materialCutFrameService.getListByVideoSignature(videoItem.getSignature());
+                            List<MaterialImageInfo> orgFrameList = materialImageInfoService.getListByVideoSignature(videoItem.getSignature());
+                            // 其他情况下,一个素材搭配15张封面,生成15个创意
+                            if ((null == cutFrameList||cutFrameList.isEmpty())&&(null == orgFrameList|| orgFrameList.isEmpty())){
+                                log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
+                                continue;
+                            }
+                            createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,1,targetUnion);
+                        }
+                    }
+                }
+            }
+        }
+
+    }
+
+    private void createCreativeByImage(List<MaterialCutFrame> cutFrameList,List<MaterialImageInfo> orgFrameList,CtopOauthToken token,JSONObject creativeParams,Long campaignId,Long unitId,KuaishouStrategy strategy,KuaiShouVideoGet videoItem,int imageNumber,AiKuaishouStrategyTargetUnion targetUnion){
+        int creativeCnt  = 1;
+        if (null!=orgFrameList&&!orgFrameList.isEmpty()) {
+            for (int i = 0; i < orgFrameList.size(); i++) {
+                String imageCode = orgFrameList.get(i).getCode();
+                String imageUrl = orgFrameList.get(i).getUrl();
+                String imageToken = getImageToken(imageUrl,imageCode,token.getAccountId(),token.getAccessToken());
+                creativeParams.put("image_token",imageToken);
+                createCreative(token,creativeParams,campaignId,unitId,strategy,null,creativeCnt,videoItem);
+                creativeCnt++;
+                if (creativeCnt > imageNumber) {
+                    break;
+                }
+            }
+        }
+
+        if ((null!=cutFrameList&&!cutFrameList.isEmpty()) && (creativeCnt<=15)){
+            for (int i = 0; i < cutFrameList.size(); i++) {
+                String imageCode = cutFrameList.get(i).getSignature();
+                String imageUrl = cutFrameList.get(i).getUrl();
+                String imageToken = getImageToken(imageUrl,imageCode,token.getAccountId(),token.getAccessToken());
+                creativeParams.put("image_token",imageToken);
+                createCreative(token,creativeParams,campaignId,unitId,strategy,null,creativeCnt,videoItem);
+                creativeCnt ++;
+                if (creativeCnt > imageNumber) {
+                    break;
                 }
             }
         }
     }
 
+    private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, KuaishouStrategy strategy, Long item, String timestamp, int unitCnt) {
+        // 拼装创建组的入参 json
+        JSONObject unitParams = new JSONObject();
+        unitParams.put("advertiser_id",token.getAccountId());
+        unitParams.put("campaign_id",campaignId);
+        String uuid = UUID.randomUUID().toString();
+        unitParams.put("unit_name", strategy.getStrategyName() + "cpaBid-" + item.toString()+"-" + uuid + unitCnt);
+        unitParams.put("bid_type",10);
+        unitParams.put("ocpx_action_type",180);
+
+        if(null!=strategy.getUseAppMarket()&&!"".equals(strategy.getUseAppMarket())){
+            unitParams.put("use_app_market",Integer.parseInt(strategy.getUseAppMarket()));
+        }
+        if(null!=strategy.getAppStore()&&!"".equals(strategy.getAppStore())){
+            unitParams.put("app_store",JSONArray.parseArray(strategy.getAppStore()));
+        }
+
+        // 在本策略中,都是 OCPM 的出价方式
+        unitParams.put("cpa_bid",item);
+        unitParams.put("ocpx_action_type",strategy.getOcpxActionType());
+        unitParams.put("deep_conversion_type",strategy.getDeepConversionType());
+        unitParams.put("deep_conversion_bid",strategy.getDeepConversionBid());
+        unitParams.put("scene_id",JSONArray.parseArray(strategy.getSceneId()));
+        unitParams.put("unit_type",4);
+
+        // 格式为yyyy-MM-dd,需大于等于当前时间
+        unitParams.put("begin_time",DateUtils.formatDate(new Date()));
+        if(null!=strategy.getConvertId()){
+            unitParams.put("convert_id",strategy.getConvertId());
+        }
+        // 当计划类型是3/4/5时必填
+        if(null!=strategy.getUrl()&&!"".equals(strategy.getUrl())){
+            unitParams.put("url",strategy.getUrl());
+        }
+        JSONArray appIds = JSONArray.parseArray(strategy.getAppIds());
+        //TODO 先只做单appId的逻辑
+        if(null!=appIds&&!appIds.isEmpty()){
+            unitParams.put("app_id",appIds.getLong(0));
+        }
+        unitParams.put("show_mode",2);
+        unitParams.put("speed",1);
+        // 设置定向内容
+        JSONObject targetJsonObject = new JSONObject();
+        targetJsonObject.put("region",JSONArray.parseArray(strategy.getRegion()));
+        targetJsonObject.put("ages_range",JSONArray.parseArray(strategy.getAgesRange()));
+        targetJsonObject.put("gender",strategy.getGender());
+        targetJsonObject.put("platform_os",strategy.getPlatformOs());
+        JSONArray population = JSONArray.parseArray(strategy.getPopulation());
+        if(null!=population&&!population.isEmpty()){
+            targetJsonObject.put("population",population);
+        }
+        JSONArray excludePopulation = JSONArray.parseArray(strategy.getExcludePopulation());
+        if(null!=excludePopulation&&!excludePopulation.isEmpty()){
+            targetJsonObject.put("paid_audience",excludePopulation);
+        }
+
+        unitParams.put("target",targetJsonObject);
+        return unitParams;
+    }
+
+    private static List<Long> splitCapBidByDomain(Long cpaBidMin, Long cpaBidMax, Long stepSize) {
+        List<Long>result = new ArrayList<>();
+        if(cpaBidMin>cpaBidMax){
+            return result;
+        }
+        if(cpaBidMin.equals(cpaBidMax)){
+            result.add(cpaBidMin);
+            return result;
+        }
+        if(cpaBidMin<cpaBidMax){
+            result.add(cpaBidMin);
+            result.add(cpaBidMax);
+            while (cpaBidMin<cpaBidMax){
+                cpaBidMin+=stepSize;
+                if(cpaBidMin>= cpaBidMax){
+                    return result;
+                }
+                result.add(cpaBidMin);
+            }
+        }
+        return result;
+    }
+
     private JSONObject creativeParams(CtopOauthToken token,Long unitId,KuaiShouVideoGet videoItem,int unitCnt,KuaishouStrategy strategy){
         JSONObject creativeParams = new JSONObject();
         creativeParams.put("advertiser_id",token.getAccountId());
@@ -197,8 +416,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         creativeParams.put("creative_name","智能创意-"+uuid+unitCnt+"-"+1);
         creativeParams.put("creative_material_type",videoItem.getMaterialType());
         creativeParams.put("action_bar_text","立即下载");
-        //TODO 广告语
-        creativeParams.put("description","测试广告语");
+        creativeParams.put("description","太美了!来电显示设为视频铃声,来电话就开始播放~");
         // 安卓下载中间页ID
         JSONArray siteIdArray = JSONArray.parseArray(strategy.getSiteId());
         if(null == siteIdArray||!siteIdArray.isEmpty()){
@@ -286,24 +504,28 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         unitParams.put("speed",1);
         // 设置定向内容
         JSONObject targetJsonObject = new JSONObject();
+        //TODO 34
         if (strategyTemplate.getTestDirection().equals("region")){
             targetJsonObject.put("region",JSONArray.parseArray(item.getTargetContent()));
         } else {
             targetJsonObject.put("region",JSONArray.parseArray(strategy.getRegion()));
         }
 
+        //TODO 5
         if (strategyTemplate.getTestDirection().equals("age")){
             targetJsonObject.put("ages_range",JSONArray.parseArray(item.getTargetContent()));
         } else{
             targetJsonObject.put("ages_range",JSONArray.parseArray(strategy.getAgesRange()));
         }
 
+        //TODO 3
         if (strategyTemplate.getTestDirection().equals("gender")){
             targetJsonObject.put("gender",item.getTargetContent());
         } else {
             targetJsonObject.put("gender",strategy.getGender());
         }
 
+        //TODO
         if (strategyTemplate.getTestDirection().equals("operation_system")){
             targetJsonObject.put("platform_os",item.getTargetContent());
         } else {
@@ -341,7 +563,9 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         mapCreative.setVideoSignature(videoGet.getSignature());
         mapCreative.setCreativeId(creativeId);
         mapCreative.setStrategyId(strategy.getId());
-        mapCreative.setStrategyTargetUnionId(targetUnion.getId());
+        if(null!=targetUnion){
+            mapCreative.setStrategyTargetUnionId(targetUnion.getId());
+        }
         mapCreativeService.save(mapCreative);
     }
 

+ 28 - 8
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -22,10 +22,7 @@ import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatUserListService;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
-import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
-import cn.com.ctop.toutiao.modules.report.service.IBytedanceFundDailyService;
-import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
-import cn.com.ctop.toutiao.modules.report.service.IReportService;
+import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -396,14 +393,28 @@ public class SampleTest {
         ruleKuaiShouPlanService.cleanRuleDataTarget(token.getAccountId(), 1);
     }
     @Autowired
-    private IKuaishouVideoEtlInfoService etlInfoService;
+    private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
     @Test
     public void etlKuaishouData(){
-        String dateString = "2020-05-25";
+        String dateString = "2020-08-29";
         Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
-        for(int i=0;i<=277;i++){
+        for(int i=0;i<=185;i++){
             Date getDate = DateUtils.addDay(startDate,i);
-            etlInfoService.etlKuaishouVideoInfo(getDate);
+            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
+//            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
+        }
+    }
+
+    @Autowired
+    private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
+    @Test
+    public void etlBytedanceData(){
+        String dateString = "2020-08-30";
+        Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
+        for(int i=0;i<=310;i++){
+            Date getDate = DateUtils.addDay(startDate,i);
+//            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
+            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
         }
     }
 
@@ -414,4 +425,13 @@ public class SampleTest {
             reportService.getAdvertiserReport(token,DateUtils.addDay(new Date(),-i),DateUtils.addDay(new Date(),-i),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         }
     }
+
+    @Test
+    public void loadKuaishouVideo(){
+        String endDate = DateUtils.getNowDate("yyyy-MM-dd");
+        CtopOauthToken token = tokenService.getTokenByAccountId(9718688L);
+//        kuaishouInterfaceService.getVideoList(token, endDate, endDate);
+        kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
+    }
+
 }

+ 4 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleAccountThresholdServiceImpl.java

@@ -102,11 +102,12 @@ public class RuleAccountThresholdServiceImpl extends ServiceImpl<RuleAccountThre
                         continue;
                     }
                     String threshold = ruleJson.getString("threshold");
+                    RuleAccountThreshold updateThreshold = new RuleAccountThreshold();
                     if (Check.isNull(threshold)) {
-                        continue;
+                        updateThreshold.setThreshold("");
+                    } else {
+                        updateThreshold.setThreshold(threshold);
                     }
-                    RuleAccountThreshold updateThreshold = new RuleAccountThreshold();
-                    updateThreshold.setThreshold(threshold);
                     QueryWrapper<RuleAccountThreshold> updateQueryWrapper = new QueryWrapper();
                     updateQueryWrapper.eq("account_id", accountId);
                     updateQueryWrapper.eq("rule_id", ruleId);

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -36,4 +36,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     JSONObject getSwitchStatusByAccount(@Param("accountId") Long accountId);
 
     List<Long>  queryAccountsByDeleteComment();
+
+    String getCompanyNameByUserId(@Param("planId") String planId);
 }

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -107,6 +107,9 @@
           AND account_status = 0
           AND delete_comment = 0
     </select>
+    <select id="getCompanyNameByUserId" resultType="java.lang.String">
+        select company_name from user_company where user_id = #{planId} limit 1
+    </select>
 
 
 </mapper>

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -142,6 +142,7 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
                 log.error("查询token信息返回结果为空,accountId:{}", accountId);
                 return;
             }
+            XxlJobHelper.log("刷新token,入參:{},token:{}", param,headers);
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             log.info("快手刷新token返回结果:{}", refreshToken);

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

@@ -19,7 +19,6 @@ public class LoadFileUtil {
      */
     public static String downLoadFromUrl(String urlStr, String savePath) {
         try {
-
             String fileName = AesEncryptUtil.getUrlDecoderString(urlStr.substring(urlStr.lastIndexOf("/") + 1));
             URL url = new URL(urlStr);
 

+ 51 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountAudienceReportJob.java

@@ -0,0 +1,51 @@
+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.report.service.IKuaishouAudienceReportDailyService;
+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;
+
+/**
+ * 快手广告主分天数据
+ *
+ * @author syh
+ */
+@Component
+public class KuaishouDailyAccountAudienceReportJob {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+
+    @XxlJob("kuaishouAccountAudienceReportJob")
+    public void execute() throws Exception {
+        //查询两天前数据  策略
+        String date = DateUtils.getLastDay(DateUtils.date2Str(), 2);
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到可用的token");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        int page = 1;
+        int pageSize = 2000;
+        tokens.forEach(token -> executorService.submit(() -> {
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "province", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "city", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "gender", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "ageSegment", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "clientId", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "businessInterestTags", null, null, page, pageSize);
+        }));
+    }
+}

+ 33 - 11
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAudienceReportJob.java

@@ -2,9 +2,10 @@ 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.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
@@ -12,6 +13,7 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -29,6 +31,8 @@ public class KuaishouDailyAudienceReportJob {
     private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
     @Autowired
     private IKuaiShouGroupService kuaiShouGroupService;
+    @Autowired
+    private IKuaishouStrategyService kuaishouStrategyService;
 
     static ExecutorService executorService = Executors.newFixedThreadPool(6);
 
@@ -42,16 +46,34 @@ public class KuaishouDailyAudienceReportJob {
             XxlJobHelper.handleFail();
             return;
         }
-        int page = 1;
-        int pageSize = 2000;
-        tokens.forEach(token -> executorService.submit(() -> {
-            getAudienceReportData(token, date, "province", page, pageSize);
-            getAudienceReportData(token, date, "city", page, pageSize);
-            getAudienceReportData(token, date, "gender", page, pageSize);
-            getAudienceReportData(token, date, "ageSegment", page, pageSize);
-            getAudienceReportData(token, date, "clientId", page, pageSize);
-            getAudienceReportData(token, date, "businessInterestTags", page, pageSize);
-        }));
+        //查询有效策略的账户ID
+        List<Long> accountIds = kuaishouStrategyService.queryActiveAccount();
+        if (Check.isNull(accountIds) || accountIds.size() == 0) {
+            XxlJobHelper.log("定时获取人群分析报表数据异常:为获取到有效策略账户信息");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        //筛选出有效账户,获取该账户的组级人群报表数据
+        List<CtopOauthToken> activeTokens = new ArrayList<>();
+        for (Long accountId : accountIds) {
+            for (CtopOauthToken token : tokens) {
+                if (token.getAccountId() - accountId == 0) {
+                    activeTokens.add(token);
+                }
+            }
+        }
+        if (!Check.isNull(activeTokens) && activeTokens.size() > 0) {
+            int page = 1;
+            int pageSize = 2000;
+            activeTokens.forEach(token -> executorService.submit(() -> {
+                getAudienceReportData(token, date, "province", page, pageSize);
+                getAudienceReportData(token, date, "city", page, pageSize);
+                getAudienceReportData(token, date, "gender", page, pageSize);
+                getAudienceReportData(token, date, "ageSegment", page, pageSize);
+                getAudienceReportData(token, date, "clientId", page, pageSize);
+                getAudienceReportData(token, date, "businessInterestTags", page, pageSize);
+            }));
+        }
     }
 
     private void getAudienceReportData(CtopOauthToken token, String date, String type, Integer page, Integer pageSize) {

+ 22 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEffectVideoJob.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
+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.text.ParseException;
+import java.util.Date;
+
+@Component
+public class KuaishouEffectVideoJob {
+    @Autowired
+    private IKuaishouVideoEtlInfoService etlInfoService;
+
+    @XxlJob("kuaishouEffectVideoJob")
+    public void execute() throws ParseException {
+        Date getDate = DateUtils.addDay(new Date(),-1);
+        etlInfoService.etlKuaishouVideoInfo(getDate);
+    }
+}

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

@@ -2409,4 +2409,35 @@ public class BatchController {
     }
 
 
+    /**
+     * 获取创意标签白名单
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getCategoryWhite")
+    public Result<JSONObject> getCategoryWhite(Long accountId) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject data = batchService.getCategoryWhite(accountId, oauthToken.getAccessToken());
+            result.setSuccess(true);
+            result.setResult(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setResult(null);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
 }

+ 5 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java

@@ -47,9 +47,13 @@ public class MaterialRefuseController {
                                                              HttpServletRequest req) {
         Result<IPage<KuaiShouCreative>> result = new Result<>();
         try {
-
+            String creativeName = creative.getCreativeName();
+            creative.setCreativeName(null);
             QueryWrapper<KuaiShouCreative> queryWrapper = QueryGenerator.initQueryWrapper(creative, req.getParameterMap());
             queryWrapper.eq("status", 42);
+            if (!Check.isNull(creativeName)) {
+                queryWrapper.like("creative_name", creativeName);
+            }
             queryWrapper.orderByDesc("creative_create_time");
             Page<KuaiShouCreative> page = new Page<KuaiShouCreative>(pageNo, pageSize);
             IPage<KuaiShouCreative> pageList = creativeService.page(page, queryWrapper);
@@ -247,19 +251,14 @@ public class MaterialRefuseController {
                 newString = sMo.replace(';', ';');
             } else if (sMo.contains("!")) {
                 newString = sMo.replace("!", "!");
-
             } else if (sMo.contains("?")) {
                 newString = sMo.replace('?', '?');
-
             } else if (sMo.contains(":")) {
                 newString = sMo.replace(':', ':');
-
             } else if (sMo.contains("“")) {
                 newString = sMo.replace('“', '"');
-
             } else if (sMo.contains("”")) {
                 newString = sMo.replace('”', '"');
-
             } else if (sMo.contains("<")) {
                 newString = sMo.replace('>', '》').replace('<', '《');
             } else if (sMo.contains(",")) {
@@ -270,16 +269,12 @@ public class MaterialRefuseController {
                 newString = sMo.replace(';', ';');
             } else if (sMo.contains("!")) {
                 newString = sMo.replace("!", "!");
-
             } else if (sMo.contains("?")) {
                 newString = sMo.replace('?', '?');
-
             } else if (sMo.contains(":")) {
                 newString = sMo.replace(':', ':');
-
             } else if (sMo.contains(""")) {
                 newString = sMo.replace('"', '“');
-
             } else if (sMo.contains(""")) {
                 newString = sMo.replace('"', '”');
             } else if (sMo.contains("《")) {

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

@@ -214,7 +214,8 @@ public class KuaiShouGroupTemplate {
     private Integer createCreativeCount;
     private Integer creativeStatus;
     private String creativeReviewDetail;
-
+    private Integer createType;
+    private String photoIds;
 
     /**
      * 创建时间

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

@@ -100,4 +100,5 @@ public class KuaiShouVideoGet {
     private Integer channelType;
     private Integer status;
     private Long userId;
+    private Integer aiStatus;
 }

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

@@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -35,6 +36,12 @@ public class KuaishouStrategy {
     private String createBy;
     private String creativeTag;
     private Integer creativeCategory;
+    //转化目标最低出价
+    private Long cpaBidMin;
+    //转化目标最高出价
+    private Long cpaBidMax;
+    //出价拆分步长
+    private Long stepSize;
     /**
      * 账户ID
      */

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

@@ -23,4 +23,6 @@ public interface KuaiShouGroupTemplateMapper extends BaseMapper<KuaiShouGroupTem
     Integer getApiCreateCount(@Param("accountId") Long accountId, @Param("date") String date);
 
     JSONObject getUrlByPhotoId(@Param("photoId") Long photoId);
+
+    JSONObject getImageJsonByMd5(String md5);
 }

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

@@ -16,4 +16,6 @@ import java.util.List;
 public interface KuaishouStrategyMapper extends BaseMapper<KuaishouStrategy> {
 
     List<JSONObject> queryPlanIdsByStrategyId(Long id);
+
+    List<Long> queryActiveAccount();
 }

+ 11 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTemplateMapper.xml

@@ -18,8 +18,18 @@
       url as 'url'
       from ctop_material_cut_frame
       where video_signature = #{md5}
-      limit 6
+       ORDER BY RAND() LIMIT 6
     </select>
+    <select id="getImageJsonByMd5" resultType="com.alibaba.fastjson.JSONObject">
+      select
+      signature as 'md5',
+      url as 'url'
+      from ctop_material_cut_frame
+      where video_signature = #{md5}
+       ORDER BY RAND() LIMIT 1
+    </select>
+
+
     <select id="getApiCreateCount" resultType="java.lang.Integer">
     select count(1)
     from

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouStrategyMapper.xml

@@ -10,4 +10,10 @@
           from ctop_ai_kuaishou_strategy_map_creative
          where strategy_id = #{id}
     </select>
+
+    <select id="queryActiveAccount" resultType="java.lang.Long">
+        SELECT account_id FROM ctop_kuaishou_strategy
+        WHERE strategy_state = 1
+        GROUP BY account_id
+    </select>
 </mapper>

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

@@ -172,4 +172,12 @@ public interface IBatchService {
 
     Map<String, Object> batchCreateCreative(JSONObject requestJson) throws Exception;
 
+    /**
+     * 获取创意分类白名单
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONObject getCategoryWhite(Long accountId, String accessToken);
 }

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

@@ -33,4 +33,6 @@ public interface IKuaiShouGroupTemplateService extends IService<KuaiShouGroupTem
     JSONObject getUrlByPhotoId(Long photoId);
 
     void createCreative(String accessToken, Long unitId, KuaiShouGroupTemplate template);
+
+    JSONObject getUnionJson(Long templateId);
 }

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

@@ -20,5 +20,5 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
 
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> stringObjectMap);
 
-    List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoNums);
+    List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoAiStatus);
 }

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

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -35,4 +36,14 @@ public interface IKuaishouStrategyService extends IService<KuaishouStrategy> {
      * @author ZHAOXA
      */
     Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data);
+
+    /**
+     * 查询有效策略的账户
+     *
+     * @param
+     * @return java.util.List<java.lang.Long>
+     * @throws
+     * @author ZHAOXA
+     */
+    List<Long> queryActiveAccount();
 }

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

@@ -788,9 +788,7 @@ public class BatchServiceImpl implements IBatchService {
                     } else {
                         unitJson.put("begin_time", group.getBeginTime());
                     }
-
                 }
-
                 // 优先从系统应用商店下载
                 if (!Check.isNull(group.getUseAppMarket())) {
                     unitJson.put("use_app_market", group.getUseAppMarket());
@@ -836,8 +834,6 @@ public class BatchServiceImpl implements IBatchService {
                 if (!Check.isNull(group.getSpeed())) {
                     unitJson.put("speed", group.getSpeed());
                 }
-
-
                 QueryWrapper<KuaiShouGroupTarget> targetQueryWrapper = new QueryWrapper<>();
                 targetQueryWrapper.eq("account_id", group.getAccountId());
                 targetQueryWrapper.eq("unit_id", group.getUnitId());
@@ -966,8 +962,6 @@ public class BatchServiceImpl implements IBatchService {
 
                     unitJson.put("target", targetJson);
                 }
-
-
                 // 出价
                 if (!Check.isNull(group.getBid())) {
                     unitJson.put("bid", group.getBid());
@@ -1194,7 +1188,6 @@ public class BatchServiceImpl implements IBatchService {
                         creativeJson.put("site_id", creative.getSiteId());
                     }
 
-
                     if (creativeMaterialType == 4) {
                         creativeJson.put("image_tokens", JSONArray.parseArray(creative.getImageTokens()));
                         creativeJson.put("short_slogan", creative.getShortSlogan());
@@ -1214,8 +1207,6 @@ public class BatchServiceImpl implements IBatchService {
                             creativeJson.put("click_track_url", click_track_url);
                         }
                     }
-
-
                 }
                 // 安卓下载中间页
                 Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson, 1);
@@ -1279,12 +1270,10 @@ public class BatchServiceImpl implements IBatchService {
         if (Check.isNull(oauthToken)) {
             throw new Exception("未获取到账户信息");
         }
-
         Long unitId = requestJson.getLong("unitId");
         if (Check.isNull(unitId)) {
             throw new Exception("请选择广告组");
         }
-
         JSONObject creativeJson = new JSONObject();
         creativeJson.put("advertiser_id", accountId);
         creativeJson.put("unit_id", unitId);
@@ -1296,18 +1285,14 @@ public class BatchServiceImpl implements IBatchService {
         String site_id = requestJson.getString("siteId");
         Integer creativeCategory = requestJson.getInteger("creativeCategory");// 创意分类
         JSONArray creativeTag = requestJson.getJSONArray("creativeTag");
-
         JSONObject returnJson = new JSONObject();
         JSONArray successArr = new JSONArray();
         JSONArray failArr = new JSONArray();
         JSONArray dataJsons = requestJson.getJSONArray("dataJson");
-
         Integer content = requestJson.getInteger("content");
-
         if (!Check.isNull(dataJsons)) {
             for (int i = 0; i < dataJsons.size(); i++) {
                 JSONObject dataJson = dataJsons.getJSONObject(i);
-
                 String creativeMaterialType = dataJson.getString("creativeMaterialType");
                 String shortSlogan = dataJson.getString("shortSlogan");
                 String overlayType = dataJson.getString("overlayType");
@@ -1436,19 +1421,13 @@ public class BatchServiceImpl implements IBatchService {
         creativeJson.put("unit_id", unitId);
         String click_track_url = requestJson.getString("clickTrackUrl");
         String actionbar_click_url = requestJson.getString("actionbarClickUrl");
-
-
         // 素材类型
-
         String action_bar_text = requestJson.getString("actionBarText");
         String site_id = requestJson.getString("siteId");
         Integer creativeCategory = requestJson.getInteger("creativeCategory");// 创意分类
         JSONArray creativeTag = requestJson.getJSONArray("creativeTag");
-
-
         JSONArray dataJsons = requestJson.getJSONArray("dataJson");
         Integer content = requestJson.getInteger("content");
-
         if (!Check.isNull(dataJsons)) {
             JSONArray creatives = new JSONArray();
             for (int i = 0; i < dataJsons.size(); i++) {
@@ -1539,6 +1518,34 @@ public class BatchServiceImpl implements IBatchService {
         return returnUnitMap;
     }
 
+    @Override
+    public JSONObject getCategoryWhite(Long accountId, String accessToken) {
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/white_list";
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", accessToken);
+            Map<String, Object> param = new HashMap<String, Object>();
+            param.put("advertiser_id", accountId);
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        return data;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+
+
+    }
+
 
     /**
      * 获取创意信息
@@ -1853,39 +1860,29 @@ public class BatchServiceImpl implements IBatchService {
         if (Check.isNull(requestJson)) {
             throw new Exception("入参为空");
         }
-
-
         JSONObject creativeJson = new JSONObject();
         creativeJson.put("advertiser_id", token.getAccountId());
-
         Long creativeId = requestJson.getLong("creativeId");
         if (Check.isNull(creativeId)) {
             throw new Exception("请选择广告创意");
         }
         creativeJson.put("creative_id", creativeId);
-
-
         // 创意名称
         if (!Check.isNull(requestJson.get("creativeName"))) {
             creativeJson.put("creative_name", requestJson.get("creativeName"));
         }
-
         //封面
         if (!Check.isNull(requestJson.get("photoId"))) {
             creativeJson.put("photo_id", requestJson.get("photoId"));
         }
-
         // 视频id
         if (!Check.isNull(requestJson.get("imageToken"))) {
             creativeJson.put("image_token", requestJson.get("imageToken"));
         }
-
         // 行动号召按钮
         if (!Check.isNull(requestJson.get("actionBarText"))) {
             creativeJson.put("action_bar_text", requestJson.get("actionBarText"));
         }
-
-
         // 广告语
         if (!Check.isNull(requestJson.get("description"))) {
             creativeJson.put("description", requestJson.getString("description").trim());
@@ -1894,7 +1891,6 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.get("stickerTitle"))) {
             creativeJson.put("sticker_title", requestJson.get("stickerTitle"));
         }
-
         // 贴纸样式
         if (!Check.isNull(requestJson.get("overlayType"))) {
             creativeJson.put("overlay_type", requestJson.get("overlayType"));
@@ -1903,18 +1899,15 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.get("clickTrackUrl"))) {
             creativeJson.put("click_track_url", requestJson.get("clickTrackUrl"));
         }
-
         // 后贴片 第三方检测链接
         if (!Check.isNull(requestJson.get("adPhotoPlayedT3sUrl"))) {
             creativeJson.put("ad_photo_played_t3s_url", requestJson.get("adPhotoPlayedT3sUrl"));
         }
-
         // 后贴片 第三方检测链接
         if (!Check.isNull(requestJson.get("impressionUrl"))) {
             creativeJson.put("impression_url", requestJson.get("impressionUrl"));
         }
         JSONObject returnJson = updateService.updateCreative(token.getAccessToken(), creativeJson);
-
         return returnJson;
     }
 
@@ -1928,14 +1921,12 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONObject getWhiteList(Long accountId, String accessToken) {
-
         String url = "https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/white_list";
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", accessToken);
         Map<String, Object> param = new HashMap<String, Object>();
         param.put("advertiser_id", accountId);
-
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         log.info("获取联盟白名单,accountId:{},data:{}", accountId, resultJson);
@@ -1944,7 +1935,6 @@ public class BatchServiceImpl implements IBatchService {
             if (code == 0) {
                 return resultJson.getJSONObject("data");
             }
-
         }
         return null;
     }
@@ -1990,7 +1980,6 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONArray getCreativeCategory(Long accountId, String accessToken) {
-
         try {
             String url = "https://ad.e.kuaishou.com/rest/openapi/v1/creative/creative_category/list";
             Map<String, String> headers = new HashMap<String, String>();
@@ -2031,7 +2020,6 @@ public class BatchServiceImpl implements IBatchService {
 
 
     private JSONArray getSecond(String categoryId, JSONArray details) {
-
         JSONArray secondArr = new JSONArray();
         for (int i = 0; i < details.size(); i++) {
             JSONObject secondJson = details.getJSONObject(i);
@@ -2053,7 +2041,6 @@ public class BatchServiceImpl implements IBatchService {
             if (categoryId.equals(parent_id)) {
                 thirdArr.add(thirdJson);
             }
-
         }
         return thirdArr;
     }

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

@@ -67,6 +67,9 @@ public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouAction
                     Integer campaign_type = data.getInteger("campaign_type");
                     JSONArray action_bar_text = data.getJSONArray("action_bar_text");
                     if (!Check.isNull(action_bar_text)) {
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("type", campaign_type);
+                        actionBarTextMapper.deleteByMap(deleteMap);
                         for (int j = 0; j < action_bar_text.size(); j++) {
                             String actionBarText = action_bar_text.getString(j);
                             KuaiShouActionBarText kuaiShouActionBarText = new KuaiShouActionBarText();

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

@@ -86,7 +86,7 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
         if (!Check.isNull(campaignId)) {
             param.put("campaign_id", campaignId);
         }
-        param.put("page_size", 200);
+        param.put("page_size", 500);
         param.put("page", page);
 
         String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);

+ 149 - 56
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java

@@ -72,11 +72,21 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         if (Check.isNull(photoArr)) {
             throw new Exception("请选择需要创建的视频");
         }
-        if (createCount != photoArr.size()) {
-            throw new Exception("视频数量必须和创建数量保持一致");
+
+        Integer createType = requestJson.getInteger("createType"); // 创建类型 0 单品 1 混搭
+        if (Check.isNull(createType)) {
+            throw new Exception("请选择创意创建方式混搭、单品");
+        }
+
+        if (createType == 0 && createCount != photoArr.size()) {
+            throw new Exception("单品视频数量必须和创建数量保持一致");
         }
-        JSONObject returnJson = new JSONObject();
 
+        if (createType == 1 && createCount * 15 != photoArr.size()) {
+            throw new Exception("混搭视频数量必须和创建数量保持倍数关系");
+        }
+
+        JSONObject returnJson = new JSONObject();
         String userId = requestJson.getString("userId");
         String unitName = requestJson.getString("unitName");
         Long template_id = requestJson.getLong("templateId");
@@ -109,16 +119,27 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         String description = requestJson.getString("description");
         Long site_id = requestJson.getLong("siteId");
 
+
         List<KuaiShouGroupTemplate> templates = new ArrayList<>();
         for (int i = 0; i < createCount; i++) {
-            Long photoId = photoArr.getLong(i);
-            String name = unitName + "_" + i;
             KuaiShouGroupTemplate template = new KuaiShouGroupTemplate();
+            template.setCreateType(createType);
+            if (createType == 0) { // 创建方式为单品
+                Long photoId = photoArr.getLong(i);
+                template.setPhotoId(photoId);
+            } else if (createType == 1) { // 创建方式为混搭
+                JSONArray photoIds = getPhotoIds(photoArr, i);
+                if (Check.isNull(photoIds)) {
+                    log.error("根据下标未获取到详细信息");
+                    continue;
+                }
+                template.setPhotoIds(photoIds.toJSONString());
+            }
+            String name = unitName + "_" + i;
             template.setAccountId(accountId);
             template.setUserId(userId);
             template.setCampaignId(campaignId);
             template.setUnitName(name);
-            template.setPhotoId(photoId);
             if (!Check.isNull(template_id)) {
                 template.setTemplateId(template_id);
             }
@@ -227,6 +248,29 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
     }
 
 
+    private JSONArray getPhotoIds(JSONArray photoArr, Integer index) {
+        JSONArray array = new JSONArray();
+        Integer minIndex;
+        Integer maxIndex;
+        if (index == 0) {
+            maxIndex = (index + 1) * 15 - 1;
+            minIndex = index;
+        } else {
+            maxIndex = (index + 1) * 15 - 1;
+            minIndex = index * 15;
+        }
+        for (int i = 0; i < photoArr.size(); i++) {
+            if (minIndex > maxIndex) {
+                break;
+            }
+            Long photoId = photoArr.getLong(minIndex);
+            array.add(photoId);
+            minIndex++;
+        }
+        return array;
+    }
+
+
     /**
      * 创建组
      */
@@ -235,7 +279,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         QueryWrapper<KuaiShouGroupTemplate> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("task_status", 0);
         queryWrapper.orderByAsc("create_time");
-        queryWrapper.last("limit 30");
+        queryWrapper.last("limit 45");
         List<KuaiShouGroupTemplate> list = this.list(queryWrapper);
         if (Check.isNull(list)) {
             log.error("暂未未创建的组");
@@ -384,7 +428,8 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
      *
      * @return
      */
-    private JSONObject getUnionJson(Long templateId) {
+    @Override
+    public JSONObject getUnionJson(Long templateId) {
         JSONObject returnJson = new JSONObject();
         QueryWrapper<KuaishouTemplateTarget> targetQueryWrapper = new QueryWrapper<>();
         targetQueryWrapper.eq("template_id", templateId);
@@ -489,7 +534,6 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         return groupTemplateMapper.getUrlByPhotoId(photoId);
     }
 
-
     /**
      * 创建创意
      *
@@ -504,17 +548,6 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         updateTemplate.setCreativeStatus(1);
         updateTemplate.setCreativeReviewDetail("创意创建中");
         this.updateById(updateTemplate);
-        Long photoId = template.getPhotoId();
-        JSONObject md5Json = groupTemplateMapper.getMd5ByPhotoId(photoId);
-        if (Check.isNull(md5Json)) {
-            log.error("未获取到素材详细信息,accountId:{},unitId:{}", template.getAccountId(), unitId);
-            updateTemplate.setCreativeStatus(3);
-            updateTemplate.setCreativeReviewDetail("未获取到素材信息");
-            this.updateById(updateTemplate);
-            return;
-        }
-        String md5 = md5Json.getString("md5");
-        List<JSONObject> imageList = groupTemplateMapper.getImageListByMd5(md5);
         JSONObject createJson = new JSONObject();
         createJson.put("unit_id", unitId);
         if (!Check.isNull(template.getClickTrackUrl())) {
@@ -529,51 +562,91 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         if (!Check.isNull(template.getCreativeTag())) {
             createJson.put("creative_tag", JSONArray.parseArray(template.getCreativeTag()));
         }
-        Integer materialType = md5Json.getInteger("materialType");
+
         JSONArray creatives = new JSONArray();
-        if (Check.isNull(imageList)) {
-            JSONObject json = new JSONObject();
-            json.put("creative_name", template.getCreativeName());
-            json.put("photo_id", template.getPhotoId());
-            json.put("creative_material_type", materialType);
-            json.put("action_bar_text", template.getActionBarText());
-            json.put("description", template.getDescription());
-            if (Check.isNull(template.getSiteId())) {
-                json.put("site_id", template.getSiteId());
-            }
-            creatives.add(json);
-        } else {
-            for (int i = 0; i < imageList.size(); i++) {
-                JSONObject imageJson = imageList.get(i);
-                if (Check.isNull(imageJson)) {
-                    continue;
-                }
+        Integer createType = template.getCreateType();
+        if (createType == 0) { // 单品
+            Long photoId = template.getPhotoId();
+            JSONObject videoMd5Json = groupTemplateMapper.getMd5ByPhotoId(photoId);
+            if (Check.isNull(videoMd5Json)) {
+                log.error("未获取到素材详细信息,accountId:{},unitId:{}", template.getAccountId(), unitId);
+                updateTemplate.setCreativeStatus(3);
+                updateTemplate.setCreativeReviewDetail("未获取到素材信息");
+                this.updateById(updateTemplate);
+                return;
+            }
+            Integer materialType = videoMd5Json.getInteger("materialType");
+            String videoMd5 = videoMd5Json.getString("md5");
+            List<JSONObject> imageList = groupTemplateMapper.getImageListByMd5(videoMd5);
+            if (Check.isNull(imageList)) {
                 JSONObject json = new JSONObject();
-                String signature = imageJson.getString("md5");
-                String imageToken = null;
-                if (!Check.isNull(signature)) {
-                    QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
-                    queryWrapper.eq("account_id", template.getAccountId());
-                    queryWrapper.eq("signature", signature);
-                    queryWrapper.last("limit 1");
-                    KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
-                    if (!Check.isNull(imageGet)) {
-                        imageToken = imageGet.getImageToken();
-                    } else {
-                        String url = imageJson.getString("url");
-                        imageToken = uploadService.kuauiShouImageUpload(url, signature, template.getAccountId(), accessToken);
+                json.put("creative_name", template.getCreativeName());
+                json.put("photo_id", template.getPhotoId());
+                json.put("creative_material_type", materialType);
+                json.put("action_bar_text", template.getActionBarText());
+                json.put("description", template.getDescription());
+                if (!Check.isNull(template.getSiteId())) {
+                    json.put("site_id", template.getSiteId());
+                }
+                creatives.add(json);
+            } else {
+                for (int i = 0; i < imageList.size(); i++) {
+                    JSONObject imageJson = imageList.get(i);
+                    if (Check.isNull(imageJson)) {
+                        continue;
+                    }
+                    JSONObject json = new JSONObject();
+                    String imageMd5 = imageJson.getString("md5");
+                    String imageToken = getImageToken(imageMd5, template.getAccountId(), accessToken, imageJson.getString("url"));
+                    if (Check.isNull(imageToken)) {
+                        continue;
                     }
+                    json.put("image_token", imageToken);
+                    json.put("creative_name", template.getCreativeName() + "_" + i);
+                    json.put("photo_id", template.getPhotoId());
+                    json.put("creative_material_type", materialType);
+                    json.put("action_bar_text", template.getActionBarText());
+                    json.put("description", template.getDescription());
+                    if (!Check.isNull(template.getSiteId())) {
+                        json.put("site_id", template.getSiteId());
+                    }
+                    creatives.add(json);
                 }
-                if (Check.isNull(imageToken)) {
-                    continue;
+            }
+        } else if (createType == 1) {  // 混搭
+            JSONArray array = JSONArray.parseArray(template.getPhotoIds());
+            if (Check.isNull(array)) {
+                updateTemplate.setCreativeStatus(3);
+                updateTemplate.setCreativeReviewDetail("未获取到混搭素材信息");
+                this.updateById(updateTemplate);
+                return;
+            }
+            for (int i = 0; i < array.size(); i++) {
+                Long photoId = array.getLong(i);
+                JSONObject videoJson = groupTemplateMapper.getMd5ByPhotoId(photoId);
+                if (Check.isNull(videoJson)) {
+                    log.error("未获取到素材详细信息,accountId:{},unitId:{}", template.getAccountId(), unitId);
+                    updateTemplate.setCreativeStatus(3);
+                    updateTemplate.setCreativeReviewDetail("未获取到素材信息");
+                    this.updateById(updateTemplate);
+                    return;
+                }
+                String videoMd5 = videoJson.getString("md5");
+                Integer materialType = videoJson.getInteger("materialType");
+                JSONObject json = new JSONObject();
+                JSONObject imageJson = groupTemplateMapper.getImageJsonByMd5(videoMd5);
+                if (!Check.isNull(imageJson)) {
+                    String imageToken = getImageToken(imageJson.getString("md5"), template.getAccountId(), accessToken, imageJson.getString("url"));
+                    if (!Check.isNull(imageToken)) {
+                        json.put("image_token", imageToken);
+                    }
                 }
-                json.put("image_token", imageToken);
                 json.put("creative_name", template.getCreativeName() + "_" + i);
-                json.put("photo_id", template.getPhotoId());
+                json.put("photo_id", photoId);
                 json.put("creative_material_type", materialType);
                 json.put("action_bar_text", template.getActionBarText());
                 json.put("description", template.getDescription());
-                if (Check.isNull(template.getSiteId())) {
+                if (!Check.isNull(template.getSiteId())) {
                     json.put("site_id", template.getSiteId());
                 }
                 creatives.add(json);
@@ -592,4 +665,24 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         }
         this.updateById(updateTemplate);
     }
+
+
+    private String getImageToken(String md5, Long accountId, String accessToken, String url) {
+
+        String imageToken = null;
+        QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("signature", md5);
+        queryWrapper.last("limit 1");
+        KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
+        if (!Check.isNull(imageGet)) {
+            imageToken = imageGet.getImageToken();
+        } else {
+            imageToken = uploadService.kuauiShouImageUpload(url, md5, accountId, accessToken);
+        }
+
+
+        return imageToken;
+
+    }
 }

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

@@ -38,9 +38,6 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     private KuaiShouVideoGetMapper videoGetMapper;
     @Autowired
     private IMaterialCutFrameService materialCutFrameService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(15);
-
-
     @Value("${oss.replace.download}")
     private String downloadUrl;
 
@@ -125,17 +122,15 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     }
 
     @Override
-    public List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoNums) {
+    public List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer aiStatus) {
         QueryWrapper<KuaiShouVideoGet>queryWrapper = new QueryWrapper<>();
         if(null!=accountId&&accountId!=0){
             queryWrapper.eq("account_id",accountId);
         }
-        queryWrapper.orderByDesc("stat_date");
-        if(null!=videoNums&&videoNums!=0){
-            queryWrapper.last("limit "+videoNums);
-        }else {
-            queryWrapper.last("limit 10");
+        if(null!=aiStatus&&aiStatus!=0){
+            queryWrapper.eq("ai_status",aiStatus);
         }
+        queryWrapper.orderByDesc("stat_date");
         return this.list(queryWrapper);
     }
 }

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

@@ -753,14 +753,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             detailJson.put("photo_like", like);
             var creative = JSONObject.toJavaObject(detailJson, KuaishouReportDailyCreative.class);
             creative.setAccountId(token.getAccountId());
-            creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
             // 取得MD5
             String signature = creativeService.getCodeByCreativeId(creative.getCreativeId());
             if (!Check.isNull(signature)) {
                 creative.setSignature(signature);
             }
-            KuaishouReportDailyCreativeStatistic statistic = setDailyStatistic(creative, token);
-            dailyCreativeStatisticService.saveOrUpdate(statistic);
             dailyCreativeService.saveOrUpdate(creative);
         }
         getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, creativeIds, page + 1);
@@ -817,7 +814,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             List<KuaishouReportDailyCreative> dailyCreatives = kuaishouResult.getData().getDetails();
             dailyCreatives.forEach((creative) -> {
                 creative.setAccountId(advertiserId);
-                creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
                 dailyCreativeService.saveOrUpdate(creative);
             });
         } catch (Exception e) {

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

@@ -147,6 +147,11 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
         return kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), planJson);
     }
 
+    @Override
+    public List<Long> queryActiveAccount() {
+        return kuaishouStrategyMapper.queryActiveAccount();
+    }
+
     public JSONArray createGroupLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
         JSONArray resultArr = new JSONArray();
         JSONArray groupInfo = data.getJSONArray("groupInfo");

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

@@ -0,0 +1,26 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Data
+@TableName("ctop_kuaishou_audience_report_daily_account")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_audience_report_daily_account对象", description = "年龄人群分析报表")
+public class KuaishouAudienceReportDailyAccount extends KuaishouAudienceReportDaily {
+    /**
+     * province: 省级地域分布,city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布,clientId: 系统分布,businessInterestTags: 商业兴趣分布
+     */
+    private java.lang.String audienceType;
+}

+ 1 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyBussiness.java

@@ -1,18 +1,10 @@
 package cn.com.ctop.kuaishou.modules.report.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;
 
 /**
  * 商业兴趣人群分析报表
@@ -26,5 +18,5 @@ import java.util.Date;
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 @ApiModel(value = "ctop_kuaishou_audience_report_daily_business对象", description = "商业兴趣人群分析报表")
-public class KuaishouAudienceReportDailyBussiness extends KuaishouAudienceReportDaily {
+public class KuaishouAudienceReportDailyBusiness extends KuaishouAudienceReportDaily {
 }

+ 9 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -14,11 +15,15 @@ import java.util.Date;
 @TableName("ctop_kuaishou_report_daily_creative")
 public class KuaishouReportDailyCreative implements Serializable {
     private static final long serialVersionUID = 1L;
-    @TableId
-    private String id;
+    @TableId(type = IdType.AUTO)
+    private Long id;
     private Long accountId;
     @JsonProperty("creative_id")
     private Long creativeId;
+    private Long  unitId;
+    private String unitName;
+    private Long campaignId;
+    private String campaignName;
 
     @JsonProperty("stat_date")
     private String statDate;
@@ -34,9 +39,9 @@ public class KuaishouReportDailyCreative implements Serializable {
     @JsonProperty
     private Long bclick;
     @JsonProperty
-    private Long share;
+    private Long photoShare;
     @JsonProperty
-    private Long comment;
+    private Long photoComment;
     @JsonProperty
     private Long photoLike;
     @JsonProperty

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

@@ -394,7 +394,6 @@ public class KuaishouReportDailyCreativeStatistic {
     private String url;
 
     public KuaishouReportDailyCreativeStatistic(KuaishouReportDailyCreative creative) {
-        this.id = creative.getId();
         this.accountId = creative.getAccountId();
         this.creativeId = creative.getCreativeId();
         this.statDate = creative.getStatDate();
@@ -431,8 +430,8 @@ public class KuaishouReportDailyCreativeStatistic {
         this.eventPayFirstDay = creative.getEventPayFirstDay();
         this.photoClickCost = creative.getPhotoClickCost();
         this.actionCost = creative.getActionCost();
-        this.share = creative.getShare();
-        this.comment = creative.getComment();
+        this.share = creative.getPhotoShare();
+        this.comment = creative.getPhotoComment();
         this.photoLike = creative.getPhotoLike();
         this.follow = creative.getFollow();
         this.report = creative.getReport();

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

@@ -0,0 +1,16 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 人群分析报表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-12-03
+ * @cersion: V1.0
+ */
+public interface KuaishouAudienceReportDailyAccountMapper extends BaseMapper<KuaishouAudienceReportDailyAccount> {
+
+}

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

@@ -1,7 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBussiness;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -14,7 +14,7 @@ import java.util.List;
  * @date: 2020-12-03
  * @cersion: V1.0
  */
-public interface KuaishouAudienceReportDailyBusinessMapper extends BaseMapper<KuaishouAudienceReportDailyBussiness> {
+public interface KuaishouAudienceReportDailyBusinessMapper extends BaseMapper<KuaishouAudienceReportDailyBusiness> {
 
     List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
 

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyAccountService extends IService<KuaishouAudienceReportDailyAccount> {
+
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyAgeService extends IService<KuaishouAudienceReportDailyAge> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyBusinessService extends IService<KuaishouAudienceReportDailyBusiness> {
+
+}

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

@@ -0,0 +1,13 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyCity;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyCityService extends IService<KuaishouAudienceReportDailyCity> {
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyClient;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyClientService extends IService<KuaishouAudienceReportDailyClient> {
+
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyGenderService extends IService<KuaishouAudienceReportDailyGender> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyProvince;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyProvinceService extends IService<KuaishouAudienceReportDailyProvince> {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAccountMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAccountService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyAccountServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyAccountMapper, KuaishouAudienceReportDailyAccount> implements IKuaishouAudienceReportDailyAccountService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAgeMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAgeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyAgeServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyAgeMapper, KuaishouAudienceReportDailyAge> implements IKuaishouAudienceReportDailyAgeService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyBusinessMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyBusinessService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyBusinessServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyBusinessMapper, KuaishouAudienceReportDailyBusiness> implements IKuaishouAudienceReportDailyBusinessService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyCity;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyCityMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyCityService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyCityServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyCityMapper, KuaishouAudienceReportDailyCity> implements IKuaishouAudienceReportDailyCityService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyClient;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyClientMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyClientService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyClientServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyClientMapper, KuaishouAudienceReportDailyClient> implements IKuaishouAudienceReportDailyClientService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyGenderMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyGenderServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyGenderMapper, KuaishouAudienceReportDailyGender> implements IKuaishouAudienceReportDailyGenderService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyProvince;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyProvinceMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyProvinceService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyProvinceServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyProvinceMapper, KuaishouAudienceReportDailyProvince> implements IKuaishouAudienceReportDailyProvinceService {
+
+}

+ 80 - 48
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java

@@ -7,8 +7,9 @@ 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.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBussiness;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyCity;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyClient;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
@@ -20,6 +21,13 @@ import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyCli
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyGenderMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyProvinceMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAccountService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAgeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyBusinessService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyCityService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyClientService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyProvinceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -28,9 +36,11 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -61,6 +71,20 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
     @Autowired
     private KuaishouAudienceReportDailyGenderMapper genderMapper;
     @Autowired
+    private IKuaishouAudienceReportDailyAccountService dailyAccountService;
+    @Autowired
+    private IKuaishouAudienceReportDailyProvinceService dailyProvinceService;
+    @Autowired
+    private IKuaishouAudienceReportDailyGenderService dailyGenderService;
+    @Autowired
+    private IKuaishouAudienceReportDailyClientService dailyClientService;
+    @Autowired
+    private IKuaishouAudienceReportDailyCityService dailyCityService;
+    @Autowired
+    private IKuaishouAudienceReportDailyBusinessService dailyBusinessService;
+    @Autowired
+    private IKuaishouAudienceReportDailyAgeService dailyAgeService;
+    @Autowired
     private ICtopOauthTokenService tokenService;
     private String urlPath = PropertiesUtils.getConfig("kuaishou_api_url");
 
@@ -183,20 +207,32 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                     JSONObject datas = resultJson.getJSONObject("data");
                     JSONArray details = datas.getJSONArray("details");
                     if (!Check.isNull(details)) {
-                        for (int i = 0; i < details.size(); i++) {
-                            JSONObject obj = details.getJSONObject(i);
-                            if ("province".equals(type)) {
-                                KuaishouAudienceReportDailyProvince entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyProvince.class);
+                        //账户级数据
+                        if (Check.isNull(plan) && Check.isNull(unit)) {
+                            List<KuaishouAudienceReportDailyAccount> list = new ArrayList<>();
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject obj = details.getJSONObject(i);
+                                KuaishouAudienceReportDailyAccount entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyAccount.class);
                                 entity.setPhotoLike(obj.getLong("like"));
                                 entity.setComments(obj.getLong("comment"));
                                 entity.setPhotoShow(obj.getLong("show"));
                                 entity.setShares(obj.getString("share"));
                                 entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                provinceMapper.insert(entity);
-                            } else if ("city".equals(type)) {
-                                KuaishouAudienceReportDailyCity entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyCity.class);
+                                entity.setAudienceType(type);
+                                list.add(entity);
+                            }
+                            dailyAccountService.saveBatch(list);
+                        } else {
+                            List<KuaishouAudienceReportDailyProvince> provinceList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyCity> cityList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyGender> genderList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyAge> ageList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyClient> clientList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyBusiness> businessList = new ArrayList<>();
+                            //组级
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject obj = details.getJSONObject(i);
+                                KuaishouAudienceReportDaily entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDaily.class);
                                 entity.setPhotoLike(obj.getLong("like"));
                                 entity.setComments(obj.getLong("comment"));
                                 entity.setPhotoShow(obj.getLong("show"));
@@ -204,47 +240,44 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                                 entity.setAccountId(Long.valueOf(token.getAccountId()));
                                 entity.setPlanId(plan);
                                 entity.setUnitId(unit);
-                                cityMapper.insert(entity);
+                                if ("province".equals(type)) {
+                                    KuaishouAudienceReportDailyProvince provinceEntity = new KuaishouAudienceReportDailyProvince();
+                                    BeanUtils.copyProperties(entity, provinceEntity);
+                                    provinceList.add(provinceEntity);
+                                } else if ("city".equals(type)) {
+                                    KuaishouAudienceReportDailyCity cityEntity = new KuaishouAudienceReportDailyCity();
+                                    BeanUtils.copyProperties(entity, cityEntity);
+                                    cityList.add(cityEntity);
+                                } else if ("gender".equals(type)) {
+                                    KuaishouAudienceReportDailyGender genderEntity = new KuaishouAudienceReportDailyGender();
+                                    BeanUtils.copyProperties(entity, genderEntity);
+                                    genderList.add(genderEntity);
+                                } else if ("ageSegment".equals(type)) {
+                                    KuaishouAudienceReportDailyAge ageEntity = new KuaishouAudienceReportDailyAge();
+                                    BeanUtils.copyProperties(entity, ageEntity);
+                                    ageList.add(ageEntity);
+                                } else if ("clientId".equals(type)) {
+                                    KuaishouAudienceReportDailyClient clientEntity = new KuaishouAudienceReportDailyClient();
+                                    BeanUtils.copyProperties(entity, clientEntity);
+                                    clientList.add(clientEntity);
+                                } else if ("businessInterestTags".equals(type)) {
+                                    KuaishouAudienceReportDailyBusiness bussinessEntity = new KuaishouAudienceReportDailyBusiness();
+                                    BeanUtils.copyProperties(entity, bussinessEntity);
+                                    businessList.add(bussinessEntity);
+                                }
+                            }
+                            if ("province".equals(type)) {
+                                dailyProvinceService.saveBatch(provinceList);
+                            } else if ("city".equals(type)) {
+                                dailyCityService.saveBatch(cityList);
                             } else if ("gender".equals(type)) {
-                                KuaishouAudienceReportDailyGender entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyGender.class);
-                                entity.setPhotoLike(obj.getLong("like"));
-                                entity.setComments(obj.getLong("comment"));
-                                entity.setPhotoShow(obj.getLong("show"));
-                                entity.setShares(obj.getString("share"));
-                                entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                genderMapper.insert(entity);
+                                dailyGenderService.saveBatch(genderList);
                             } else if ("ageSegment".equals(type)) {
-                                KuaishouAudienceReportDailyAge entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyAge.class);
-                                entity.setPhotoLike(obj.getLong("like"));
-                                entity.setComments(obj.getLong("comment"));
-                                entity.setPhotoShow(obj.getLong("show"));
-                                entity.setShares(obj.getString("share"));
-                                entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                ageMapper.insert(entity);
+                                dailyAgeService.saveBatch(ageList);
                             } else if ("clientId".equals(type)) {
-                                KuaishouAudienceReportDailyClient entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyClient.class);
-                                entity.setPhotoLike(obj.getLong("like"));
-                                entity.setComments(obj.getLong("comment"));
-                                entity.setPhotoShow(obj.getLong("show"));
-                                entity.setShares(obj.getString("share"));
-                                entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                clientMapper.insert(entity);
+                                dailyClientService.saveBatch(clientList);
                             } else if ("businessInterestTags".equals(type)) {
-                                KuaishouAudienceReportDailyBussiness entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyBussiness.class);
-                                entity.setPhotoLike(obj.getLong("like"));
-                                entity.setComments(obj.getLong("comment"));
-                                entity.setPhotoShow(obj.getLong("show"));
-                                entity.setShares(obj.getString("share"));
-                                entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                bussinessMapper.insert(entity);
+                                dailyBusinessService.saveBatch(businessList);
                             }
                         }
                     }
@@ -255,6 +288,5 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
         } catch (Exception e) {
             log.error("插入人群分析报表数据异常,数据维度:{}", type, e);
         }
-        log.info("use time :{} ms", (System.currentTimeMillis() - start));
     }
 }

+ 6 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java

@@ -88,9 +88,9 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
         ChromeOptions chromeOptions = new ChromeOptions();
 //        chromeOptions.addArguments("--headless");
 //        chromeOptions.addArguments("--no-sandbox");
-//        chromeOptions.addArguments("--disable-dev-shm-usage");
-//        chromeOptions.addArguments("--incognito");
-//        chromeOptions.addArguments("--disable-gpu");
+        chromeOptions.addArguments("--disable-dev-shm-usage");
+        chromeOptions.addArguments("--incognito");
+        chromeOptions.addArguments("--disable-gpu");
         chromeOptions.addArguments("--window-size=1920,1080");
         chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
         chromeOptions.setAcceptInsecureCerts(true);
@@ -102,12 +102,12 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
             //获取登录页面
             webDriver.get(url);
             Thread.sleep(3000L);
-            WebElement accountElement = webDriver.findElement(By.xpath("//div[@class='phone ']/input[@type='text']"));
+            WebElement accountElement = webDriver.findElement(By.xpath("//div[contains(@class,'component-input-container')]/input[@type='text']"));
             accountElement.sendKeys("17718376864");
             Thread.sleep(3000L);
-            WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
+            WebElement passwordElement = webDriver.findElement(By.xpath("//div[contains(@class,'component-input-container')]/input[@type='password']"));
             passwordElement.sendKeys("yehcbost85567");
-            WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
+            WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='btn-container']/button[contains(@class,'submit')]"));
             Thread.sleep(3000L);
             //点击登录
             loginElement.click();

+ 12 - 14
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouVideoEtlInfoServiceImpl.java

@@ -39,7 +39,7 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
     private KuaishouVideoEtlInfoMapper kuaishouVideoEtlInfoMapper;
     @Autowired
     private IKuaiShouReportDailyMaterialService dailyMaterialService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(50);
+    static ExecutorService executorService = Executors.newFixedThreadPool(100);
     @Override
     public void etlKuaishouVideoInfo(Date getDate) {
         String date = DateUtils.formatDate(getDate);
@@ -98,13 +98,13 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
                                 }
                             }
                             //计算投放总天数
-                            if(days == 7){
+                            if(days <= 7){
                                 etlInfo.setSingleWeekCost(nowData.getCharge());
                             }
-                            if(days == 14){
+                            if(days <= 14){
                                 etlInfo.setTwoWeekCost(nowData.getCharge());
                             }
-                            if(days == 28){
+                            if(days <= 28){
                                 etlInfo.setFourWeekCost(nowData.getCharge());
                             }
                             //计算是否有效,爆款
@@ -115,14 +115,13 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
                             }
                             if(totalCost.compareTo(new BigDecimal("100000"))>0){
                                 //此刻成为爆款
-                                etlInfo.setEffectDate(date);
-                                etlInfo.setEffectDayNum(days);
+                                etlInfo.setFaddishDate(date);
+                                etlInfo.setFaddishDayNum(days);
                             }
                             etlInfo.setCreateTime(new Date());
                             etlInfo.setUpdateTime(new Date());
                             this.save(etlInfo);
                         }else{
-                            BigDecimal totalCost = etlInfo.getTotalCost();
                             //只需要更新汇总数据
                             etlInfo.setTotalCost(nowData.getCharge());
                             etlInfo.setAclick(nowData.getAclick());
@@ -130,14 +129,15 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
                             etlInfo.setPhotoClick(nowData.getPhotoClick());
                             etlInfo.setPhotoShow(nowData.getPhotoShow());
                             etlInfo.setUpdateTime(new Date());
+                            BigDecimal totalCost = etlInfo.getTotalCost();
                             //计算投放总天数
-                            if(days == 7){
+                            if(days <= 7){
                                 etlInfo.setSingleWeekCost(nowData.getCharge());
                             }
-                            if(days == 14){
+                            if(days <= 14){
                                 etlInfo.setTwoWeekCost(nowData.getCharge());
                             }
-                            if(days == 28){
+                            if(days <= 28){
                                 etlInfo.setFourWeekCost(nowData.getCharge());
                             }
                             if(null == etlInfo.getEffectDayNum()){
@@ -150,8 +150,8 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
                             if(null == etlInfo.getFaddishDayNum()){
                                 if(totalCost.compareTo(new BigDecimal("100000"))>0){
                                     //此刻成为爆款
-                                    etlInfo.setEffectDate(date);
-                                    etlInfo.setEffectDayNum(days);
+                                    etlInfo.setFaddishDate(date);
+                                    etlInfo.setFaddishDayNum(days);
                                 }
                             }
                             this.updateById(etlInfo);
@@ -175,8 +175,6 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
 
     @Autowired
     private IMaterialAscriptionService materialAscriptionService;
-    @Autowired
-    private IMaterialInfoService materialInfoService;
     @Override
     public KuaishouVideoEtlInfo getBySignature(String signature) {
         QueryWrapper<KuaishouVideoEtlInfo> queryWrapper = new QueryWrapper<>();

+ 150 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceVideoEtlInfoController.java

@@ -0,0 +1,150 @@
+package cn.com.ctop.toutiao.modules.report.controller;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+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.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+ /**
+ * 头条视频数据清洗信息
+ * @author jeecg-boot
+ * @date   2020-12-21
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="头条视频数据清洗信息")
+@RestController
+@RequestMapping("/ctop/bytedanceVideoEtlInfo")
+public class BytedanceVideoEtlInfoController {
+	@Autowired
+	private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param bytedanceVideoEtlInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-分页列表查询", notes="头条视频数据清洗信息-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceVideoEtlInfo>> queryPageList(BytedanceVideoEtlInfo bytedanceVideoEtlInfo,
+															  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															  HttpServletRequest req) {
+		Result<IPage<BytedanceVideoEtlInfo>> result = new Result<>();
+		QueryWrapper<BytedanceVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceVideoEtlInfo, req.getParameterMap());
+		Page<BytedanceVideoEtlInfo> page = new Page<BytedanceVideoEtlInfo>(pageNo, pageSize);
+		IPage<BytedanceVideoEtlInfo> pageList = bytedanceVideoEtlInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param bytedanceVideoEtlInfo
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-添加", notes="头条视频数据清洗信息-添加")
+	@PostMapping(value = "/add")
+	public Result<BytedanceVideoEtlInfo> add(@RequestBody BytedanceVideoEtlInfo bytedanceVideoEtlInfo) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		try {
+			bytedanceVideoEtlInfoService.save(bytedanceVideoEtlInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param bytedanceVideoEtlInfo
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-编辑", notes="头条视频数据清洗信息-编辑")
+	@PutMapping(value = "/edit")
+	public Result<BytedanceVideoEtlInfo> edit(@RequestBody BytedanceVideoEtlInfo bytedanceVideoEtlInfo) {
+		Result<BytedanceVideoEtlInfo> result = new Result<BytedanceVideoEtlInfo>();
+		BytedanceVideoEtlInfo bytedanceVideoEtlInfoEntity = bytedanceVideoEtlInfoService.getById(bytedanceVideoEtlInfo.getId());
+		if(bytedanceVideoEtlInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceVideoEtlInfoService.updateById(bytedanceVideoEtlInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-通过id删除", notes="头条视频数据清洗信息-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			bytedanceVideoEtlInfoService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-批量删除", notes="头条视频数据清洗信息-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<BytedanceVideoEtlInfo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.bytedanceVideoEtlInfoService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-通过id查询", notes="头条视频数据清洗信息-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<BytedanceVideoEtlInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		BytedanceVideoEtlInfo bytedanceVideoEtlInfo = bytedanceVideoEtlInfoService.getById(id);
+		if(bytedanceVideoEtlInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceVideoEtlInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

+ 74 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceVideoEtlInfo.java

@@ -0,0 +1,74 @@
+package cn.com.ctop.toutiao.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 头条视频数据清洗信息
+ * @author jeecg-boot
+ * @date   2020-12-21
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_video_etl_info")
+public class BytedanceVideoEtlInfo {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**视频唯一标识*/
+	private String videoCode;
+	/**初次产生消耗时间*/
+	private String stateDate;
+	/**url*/
+	private String url;
+	/**coverUrl*/
+	private String coverUrl;
+	/**companyName*/
+	private String companyName;
+	/**planId*/
+	private String planId;
+	/**planName*/
+	private String planName;
+	/**clipId*/
+	private String clipId;
+	/**clipName*/
+	private String clipName;
+	/**shotId*/
+	private String shotId;
+	/**shotName*/
+	private String shotName;
+	/**singleWeekCost*/
+	private BigDecimal singleWeekCost;
+	/**twoWeekCost*/
+	private BigDecimal twoWeekCost;
+	/**fourWeekCost*/
+	private BigDecimal fourWeekCost;
+	/**总消耗*/
+	private BigDecimal totalCost;
+	/**clickNum*/
+	private Long clickNum;
+	/**showNum*/
+	private Long showNum;
+	/**activeNum*/
+	private Long activeNum;
+	/**convertNum*/
+	private Long convertNum;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+	/**effectDate*/
+	private String effectDate;
+	/**faddishDate*/
+	private String faddishDate;
+	/**effectDayNum*/
+	private Integer effectDayNum;
+	/**faddishDayNum*/
+	private Integer faddishDayNum;
+}

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

@@ -6,6 +6,7 @@ import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportVideoMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -58,4 +59,8 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
                                                               @Param("code")String code,
                                                               @Param("order")String order,
                                                               @Param("target")String target);
+
+    List<BytedanceVideoEtlInfo> getSignatureByDate(@Param(value = "date") String date);
+
+    BytedanceVideoEtlInfo getEtlDataByParams(@Param("signature")String signature, @Param("date")String date);
 }

+ 16 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceVideoEtlInfoMapper.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.toutiao.modules.report.mapper;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 头条视频数据清洗信息
+ * @author: jeecg-boot
+ * @date:   2020-12-21
+ * @cersion: V1.0
+ */
+public interface BytedanceVideoEtlInfoMapper extends BaseMapper<BytedanceVideoEtlInfo> {
+
+    BytedanceVideoEtlInfo getBySignature(@Param(value = "signature") String signature);
+}

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

@@ -416,6 +416,40 @@ where a.plane_id is not null and a.plane_name is null
         </if>
         group by report.material_id)a order by a.${target} ${order}
     </select>
+    <select id="getSignatureByDate"
+            resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo">
+        select
+            distinct signature as 'video_code'
+        from
+        ctop_bytedance_report_material_daily report
+        left join ctop_bytedance_video_info video on video.material_id = report.material_id and video.account_id = report.account_id
+        where
+            video.signature is not null
+        and
+            video.signature != ''
+        and
+            report.stat_datetime = #{date}
+    </select>
+    <select id="getEtlDataByParams"
+            resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo">
+        select
+        video.signature as 'video_code',
+        '' as cover_url,
+        video.video_url as url,
+        min(report.stat_datetime)as 'state_date',
+        sum(report.cost)as 'total_cost',
+        sum(report.click)as 'click_num',
+        sum(report.active)as 'active_num',
+        sum(report.show_material)as 'show_num',
+        sum(report.convert_material)as 'convert_num'
+        from ctop_bytedance_report_material_daily report
+        left join ctop_bytedance_video_info video on report.account_id = video.account_id and video.material_id = report.material_id
+        where
+            video.signature = #{signature}
+        and
+            report.stat_datetime&lt;= #{date}
+        group by video.signature;
+    </select>
 
     <insert id="replaceIntoVideoMaterialBatch">
         REPLACE INTO ctop_bytedance_report_video_material_daily

+ 8 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceVideoEtlInfoMapper.xml

@@ -0,0 +1,8 @@
+<?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.report.mapper.BytedanceVideoEtlInfoMapper">
+
+    <select id="getBySignature" resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo">
+
+    </select>
+</mapper>

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

@@ -2,6 +2,7 @@ package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -15,4 +16,7 @@ import java.util.List;
 public interface IBytedanceReportMaterialDailyService extends IService<BytedanceReportMaterialDaily> {
     List<BytedanceReportMaterialDaily> getListByParams(String date);
     List<BytedanceVideoVo> getVideoVoByDate(String date);
+    List<BytedanceVideoEtlInfo> getSignatureByDate(String date);
+
+    BytedanceVideoEtlInfo getEtlDataByParams(String signature, String date);
 }

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.toutiao.modules.report.service;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Date;
+
+/**
+ * @Description: 头条视频数据清洗信息
+ * @Author: jeecg-boot
+ * @Date:   2020-12-21
+ * @Version: V1.0
+ */
+public interface IBytedanceVideoEtlInfoService extends IService<BytedanceVideoEtlInfo> {
+    void etlBytedanceVideoInfo(Date date);
+
+    BytedanceVideoEtlInfo getBySignature(String signature);
+}

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

@@ -2,6 +2,7 @@ package cn.com.ctop.toutiao.modules.report.service.impl;
 
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportMaterialDailyService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -39,5 +40,15 @@ public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<Bytedan
         return bytedanceReportMaterialDailyMapper.getVideoVoByDate(date);
     }
 
+    @Override
+    public List<BytedanceVideoEtlInfo> getSignatureByDate(String date) {
+        return bytedanceReportMaterialDailyMapper.getSignatureByDate(date);
+    }
+
+    @Override
+    public BytedanceVideoEtlInfo getEtlDataByParams(String signature, String date) {
+        return bytedanceReportMaterialDailyMapper.getEtlDataByParams(signature,date);
+    }
+
 
 }

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

@@ -0,0 +1,179 @@
+package cn.com.ctop.toutiao.modules.report.service.impl;
+
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.IMaterialAscriptionService;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.mapper.BytedanceVideoEtlInfoMapper;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportMaterialDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+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.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 头条视频数据清洗信息
+ * @author jeecg-boot
+ * @date   2020-12-21
+ * @version V1.0
+ */
+@Slf4j
+@Service
+public class BytedanceVideoEtlInfoServiceImpl extends ServiceImpl<BytedanceVideoEtlInfoMapper, BytedanceVideoEtlInfo> implements IBytedanceVideoEtlInfoService {
+    @Autowired
+    private IBytedanceReportMaterialDailyService materialDailyService;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    static ExecutorService executorService = Executors.newFixedThreadPool(100);
+    @Autowired
+    private IMaterialAscriptionService materialAscriptionService;
+    @Override
+    public void etlBytedanceVideoInfo(Date getDate) {
+        String date = DateUtils.formatDate(getDate);
+        //1:查询单当日视频信息
+        List<BytedanceVideoEtlInfo> materials = materialDailyService.getSignatureByDate(date);
+        if(null!=materials&&!materials.isEmpty()){
+            CountDownLatch countDownLatch= new CountDownLatch(materials.size());
+            materials.forEach(material->{
+                executorService.submit(()->{
+                    try {
+                        if(null == material.getVideoCode()||material.getVideoCode().trim().equals("")){
+                            return;
+                        }
+                        String signature = material.getVideoCode();
+                        BytedanceVideoEtlInfo etlInfo = this.getBySignature(signature);
+                        BytedanceVideoEtlInfo nowData = materialDailyService.getEtlDataByParams(signature,date);
+                        String minDate = nowData.getStateDate();
+                        Integer days = DateUtils.getdaysOfTwoDate(minDate,date);
+                        if(null == etlInfo){
+                            //第一次查询的数据
+                            etlInfo = nowData;
+                            BigDecimal totalCost = etlInfo.getTotalCost();
+                            JSONObject ascription =  materialAscriptionService.getDetailByCode(signature);
+                            String planId = null;
+                            if(null!=ascription){
+                                planId = ascription.getString("planId");
+                                if(null!=planId&&!planId.trim().equals("")){
+                                    etlInfo.setPlanId(planId);
+                                }
+                                String planName =  ascription.getString("planName");
+                                if(null!=planName&&!planName.trim().equals("")){
+                                    etlInfo.setPlanName(planName);
+                                }
+                                String clipId = ascription.getString("clipId");
+                                if(null!=clipId&&!clipId.trim().equals("")){
+                                    etlInfo.setClipId(clipId);
+                                }
+                                String clipName = ascription.getString("clipName");
+                                if(null!=clipName&&!clipName.trim().equals("")){
+                                    etlInfo.setClipName(clipName);
+                                }
+                                String shotId = ascription.getString("shotId");
+                                if(null!=shotId&&!shotId.trim().equals("")){
+                                    etlInfo.setShotId(shotId);
+                                }
+                                String shotName = ascription.getString("shotName");
+                                if(null!=shotName&&!shotName.trim().equals("")){
+                                    etlInfo.setShotName(shotName);
+                                }
+                            }
+                            if(null!=planId){
+                                String companyName = userAllocationMapper.getCompanyNameByUserId(planId);
+                                if (null!=companyName&&!companyName.trim().equals("")){
+                                    etlInfo.setCompanyName(companyName);
+                                }
+                            }
+                            //计算投放总天数
+                            if(days <= 7){
+                                etlInfo.setSingleWeekCost(nowData.getTotalCost());
+                            }
+                            if(days <= 14){
+                                etlInfo.setTwoWeekCost(nowData.getTotalCost());
+                            }
+                            if(days <= 28){
+                                etlInfo.setFourWeekCost(nowData.getTotalCost());
+                            }
+                            //计算是否有效,爆款
+                            if(totalCost.compareTo(new BigDecimal("5000"))>0){
+                                //此刻成为有效
+                                etlInfo.setEffectDate(date);
+                                etlInfo.setEffectDayNum(days);
+                            }
+                            if(totalCost.compareTo(new BigDecimal("100000"))>0){
+                                //此刻成为爆款
+                                etlInfo.setFaddishDate(date);
+                                etlInfo.setFaddishDayNum(days);
+                            }
+                            etlInfo.setCreateTime(new Date());
+                            etlInfo.setUpdateTime(new Date());
+                            this.save(etlInfo);
+                        }else{
+                            //只需要更新汇总数据
+                            etlInfo.setTotalCost(nowData.getTotalCost());
+                            BigDecimal totalCost = etlInfo.getTotalCost();
+                            etlInfo.setClickNum(nowData.getClickNum());
+                            etlInfo.setShowNum(nowData.getShowNum());
+                            etlInfo.setActiveNum(nowData.getActiveNum());
+                            etlInfo.setConvertNum(nowData.getConvertNum());
+                            etlInfo.setUpdateTime(new Date());
+                            //计算投放总天数
+                            if(days <= 7){
+                                etlInfo.setSingleWeekCost(nowData.getTotalCost());
+                            }
+                            if(days <= 14){
+                                etlInfo.setTwoWeekCost(nowData.getTotalCost());
+                            }
+                            if(days <= 28){
+                                etlInfo.setFourWeekCost(nowData.getTotalCost());
+                            }
+                            if(null == etlInfo.getEffectDayNum()){
+                                if(totalCost.compareTo(new BigDecimal("5000"))>0){
+                                    //此刻成为有效
+                                    etlInfo.setEffectDate(date);
+                                    etlInfo.setEffectDayNum(days);
+                                }
+                            }
+                            if(null == etlInfo.getFaddishDayNum()){
+                                if(totalCost.compareTo(new BigDecimal("100000"))>0){
+                                    //此刻成为爆款
+                                    etlInfo.setFaddishDate(date);
+                                    etlInfo.setFaddishDayNum(days);
+                                }
+                            }
+                            this.updateById(etlInfo);
+                        }
+                    }catch (Exception e){
+
+                    }finally {
+                        countDownLatch.countDown();
+                    }
+                });
+            });
+
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            log.info("{}数据获取完成",date);
+        }
+    }
+
+    @Override
+    public BytedanceVideoEtlInfo getBySignature(String signature) {
+        QueryWrapper<BytedanceVideoEtlInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("video_code",signature).last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}