فهرست منبع

Merge branch 'kuaishou-ai-advertising'

syh 4 سال پیش
والد
کامیت
65e1315286
69فایلهای تغییر یافته به همراه1894 افزوده شده و 57 حذف شده
  1. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 55 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouStrategyListPageCtrl.java
  3. 26 14
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouStrategyController.java
  4. 22 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/StrategyController.java
  5. 42 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyMapCreative.java
  6. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyMiddle.java
  7. 37 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetBase.java
  8. 30 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetDetails.java
  9. 40 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetUnion.java
  10. 45 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTemplate.java
  11. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaiShouStrategyListPageMapper.java
  12. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyMapCreativeMapper.java
  13. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyMiddleMapper.java
  14. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetBaseMapper.java
  15. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetDetailsMapper.java
  16. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetUnionMapper.java
  17. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTemplateMapper.java
  18. 138 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyListPageMapper.xml
  19. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyMapCreativeMapper.xml
  20. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyMiddleMapper.xml
  21. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetBaseMapper.xml
  22. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetDetailsMapper.xml
  23. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetUnionMapper.xml
  24. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTemplateMapper.xml
  25. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaiShouStrategyListPageService.java
  26. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyMapCreativeService.java
  27. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyMiddleService.java
  28. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyService.java
  29. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetBaseService.java
  30. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetDetailsService.java
  31. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetUnionService.java
  32. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTemplateService.java
  33. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiStrategyService.java
  34. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/Test.java
  35. 87 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouStrategyListPageServiceImpl.java
  36. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyMapCreativeServiceImpl.java
  37. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyMiddleServiceImpl.java
  38. 30 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetBaseServiceImpl.java
  39. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetDetailsServiceImpl.java
  40. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetUnionServiceImpl.java
  41. 33 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTemplateServiceImpl.java
  42. 672 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiStrategyServiceImpl.java
  43. 95 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/TestImpl.java
  44. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  45. 18 2
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  46. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CustomDataByAccountMapper.java
  47. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  48. 12 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  49. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageInfoService.java
  50. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  51. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageInfoServiceImpl.java
  52. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  53. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java
  54. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  55. 11 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouStrategy.java
  56. 3 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/kuaishoustrategycampaignRel.java
  57. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java
  58. 2 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/kuaishoustrategycampaignRelMapper.java
  59. 1 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml
  60. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  61. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouImageGetService.java
  62. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  63. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouImageGetServiceImpl.java
  64. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  65. 13 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  66. 14 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  67. 6 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouStrategyServiceImpl.java
  68. 9 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java
  69. 2 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreativeStatistic.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");

+ 55 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouStrategyListPageCtrl.java

@@ -0,0 +1,55 @@
+package org.jeecg.modules.ads.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.ads.service.IAiKuaiShouStrategyListPageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequestMapping("/ai/list")
+@RestController
+public class AiKuaiShouStrategyListPageCtrl {
+
+    @Autowired
+    IAiKuaiShouStrategyListPageService aiKuaiShouStrategyListPageService;
+
+    @PostMapping("/pageStrategy")
+    public Result<PageInfo<JSONObject>> pageStrategy(@RequestBody JSONObject params){
+        Result<PageInfo<JSONObject>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            result.setSuccess(true);
+            result.setResult(aiKuaiShouStrategyListPageService.pageStrategy(params));
+        }
+        return result;
+    }
+
+    @PostMapping("/pageCampaign")
+    public Result<PageInfo<JSONObject>> pageCampaign(@RequestBody JSONObject params){
+        Result<PageInfo<JSONObject>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            result.setSuccess(true);
+            result.setResult(aiKuaiShouStrategyListPageService.pageCampaign(params));
+        }
+        return result;
+    }
+
+    @PostMapping("/pageUnit")
+    public Result<PageInfo<JSONObject>> pageUnit(@RequestBody JSONObject params){
+        Result<PageInfo<JSONObject>> result=new Result<>();
+        if(params.isEmpty()){
+            result.error500("参数为空");
+        }else {
+            result.setSuccess(true);
+            result.setResult(aiKuaiShouStrategyListPageService.pageUnit(params));
+        }
+        return result;
+    }
+}

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

@@ -1,4 +1,4 @@
-package cn.com.ctop.kuaishou.modules.batch.controller;
+package org.jeecg.modules.ads.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.utils.Check;
@@ -13,23 +13,21 @@ 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.apache.shiro.SecurityUtils;
+import org.checkerframework.checker.units.qual.A;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.ads.service.IAiKuaishouStrategyService;
+import org.jeecg.modules.ads.service.IAiStrategyService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
@@ -57,6 +55,8 @@ import java.util.Map;
 public class KuaishouStrategyController {
     @Autowired
     private IKuaishouStrategyService kuaishouStrategyService;
+    @Autowired
+    private IAiStrategyService strategyService;
 
     /**
      * 分页列表查询
@@ -82,15 +82,12 @@ public class KuaishouStrategyController {
         result.setResult(pageList);
         return result;
     }
-
     /**
      * 添加
      *
-     * @param kuaishouStrategy
+     * @param data
      * @return
      */
-    @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-添加")
-    @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-添加", notes = "kuaishou.modules.batch-优化评估策略表-添加")
     @PostMapping(value = "/add")
     public Result<Object> add(@RequestBody JSONObject data) {
         Result<Object> result = new Result<>();
@@ -98,8 +95,23 @@ public class KuaishouStrategyController {
             if (Check.isNull(data.getLong("accountId"))) {
                 return Result.error(-1, "请选择账户");
             }
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
             KuaishouStrategy strategy = JSONObject.toJavaObject(data, KuaishouStrategy.class);
+            JSONArray appStore = data.getJSONArray("appStore");
+            if(null!=appStore&&!appStore.isEmpty()){
+                strategy.setAppStore(appStore.toJSONString());
+            }
+            JSONArray siteId = data.getJSONArray("siteId");
+            if(null!=siteId&&!siteId.isEmpty()){
+                strategy.setSiteId(siteId.toJSONString());
+            }
+            JSONArray creativeTag = data.getJSONArray("creativeTag");
+            if(null!=creativeTag&&!creativeTag.isEmpty()){
+                strategy.setCreativeTag(creativeTag.toJSONString());
+            }
+            strategy.setCreateBy(user.getId());
             kuaishouStrategyService.save(strategy);
+            strategyService.createCreativeByStrategy(strategy);
             result.success("添加成功!");
         } catch (Exception e) {
             log.error(e.getMessage(), e);
@@ -111,7 +123,7 @@ public class KuaishouStrategyController {
     /**
      * 编辑
      *
-     * @param kuaishouStrategy
+     * @param
      * @return
      */
     @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-编辑")

+ 22 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/StrategyController.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.ads.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@Slf4j
+@RequestMapping("/ctop/strategy")
+public class StrategyController {
+    @PostMapping("previewCreative")
+    public Map<String,Object> previewCreative(@RequestBody JSONObject data){
+        Map<String,Object>result = new HashMap<>();
+        return result;
+    }
+}

+ 42 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyMapCreative.java

@@ -0,0 +1,42 @@
+package org.jeecg.modules.ads.entity;
+
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+/**
+ * 策略创意表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_map_creative")
+public class AiKuaishouStrategyMapCreative {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**账户id*/
+	private Long accountId;
+	/**计划id*/
+	private Long campaignId;
+	/**组id*/
+	private Long unitId;
+	/**创意id*/
+	private Long creativeId;
+	/**策略_定向关联id*/
+	private Long strategyTargetUnionId;
+	/**素材签名*/
+	private String videoSignature;
+	/**策略id*/
+	private Long strategyId;
+	/**是否创建成功*/
+	private Integer createSuccess;
+	/**失败原因*/
+	private String detail;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+}

+ 41 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyMiddle.java

@@ -0,0 +1,41 @@
+package org.jeecg.modules.ads.entity;
+
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 策略_策略模板中间表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_middle")
+public class AiKuaishouStrategyMiddle {
+
+	/**middle_id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**策略id*/
+	private Long strategyId;
+	/**策略模板id*/
+	private Long strategyTemplateId;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+
+	public AiKuaishouStrategyMiddle(Long templateId, Long strategyId) {
+		this.strategyTemplateId = templateId;
+		this.strategyId = strategyId;
+		this.createTime = new Date();
+		this.updateTime = new Date();
+	}
+
+	public AiKuaishouStrategyMiddle() {
+	}
+}

+ 37 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetBase.java

@@ -0,0 +1,37 @@
+package org.jeecg.modules.ads.entity;
+
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 定向基础表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_target_base")
+public class AiKuaishouStrategyTargetBase {
+
+	/**target_base_id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**定向类型:age|devices|用户行为|行业偏好等*/
+	private String targetType;
+	/**定向内容: 24-30|31-40|41-49 等*/
+	private String targetContent;
+	/**状态1可用 0不可用*/
+	private Integer status;
+	/**
+	 * 数据类型
+	 */
+	private String type;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 30 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetDetails.java

@@ -0,0 +1,30 @@
+package org.jeecg.modules.ads.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 智能投放快手定向策略详细信息
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_target_details")
+public class AiKuaishouStrategyTargetDetails {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**策略id*/
+	private Long strategyId;
+	/**定向id*/
+	private Long targetId;
+	/**测试方向: age 、 devices、  用户行为 、 行业偏好 、付费人群包 等*/
+	private String type;
+	/**status*/
+	private Integer status;
+	private Date createTime;
+	private Date updateTime;
+}

+ 40 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetUnion.java

@@ -0,0 +1,40 @@
+package org.jeecg.modules.ads.entity;
+
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 策略_定向中间表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_target_union")
+public class AiKuaishouStrategyTargetUnion {
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**middle_id*/
+	private Long strategyMiddleId;
+	/**定向id*/
+	private Long strategyTargetId;
+	/**实际使用定向内用*/
+	private String actualTargetContent;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+
+	public AiKuaishouStrategyTargetUnion() {
+	}
+
+	public AiKuaishouStrategyTargetUnion(Long strategyMiddleId, Long strategyTargetId, String targetContent) {
+		this.strategyMiddleId = strategyMiddleId;
+		this.strategyTargetId = strategyTargetId;
+		this.actualTargetContent = targetContent;
+	}
+}

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

@@ -0,0 +1,45 @@
+package org.jeecg.modules.ads.entity;
+
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 策略模板表
+ */
+@Data
+@TableName("ctop_ai_kuaishou_strategy_template")
+public class AiKuaishouStrategyTemplate {
+
+	/**策略模板id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**账户id*/
+	private Long accountId;
+	/**策略模板名称*/
+	private String templateName;
+	/**策略类型 1:素材+出价 2:素材+定向  3:时间+出价 */
+	private Integer templateType;
+	/**测试方向*/
+	private String testDirection;
+	/**素材选择方式*/
+	private String materialSelectMethod;
+	/**
+	 * 组内素材组合模式
+	 * single 单视频+不同封面
+	 * mixed  多视频+各自封面
+	 */
+	private String materialFixType;
+	/**状态1可用 0不可用*/
+	private Integer status;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 23 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaiShouStrategyListPageMapper.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.ads.mapper;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+/**
+ *  Created by JQ.bi on 2020.12.16
+ */
+@Mapper
+public interface AiKuaiShouStrategyListPageMapper {
+
+    List<JSONObject> queryStrategyBy(@Param("accountIds") JSONArray accountIds,@Param("strategyName") String strategyName,@Param("strategyState") Integer strategyState,@Param("id") Long id);
+
+    List<JSONObject> queryCampaignByStrategyId(@Param("strategyId") Long strategyId,@Param("campaignName") String campaignName,@Param("campaignId") Long campaignId,@Param("status") Integer status);
+
+    List<JSONObject> queryUnitByCampaignId(@Param("campaignId") Long campaignId,@Param("unitName") String unitName,@Param("unitId") Long unitId,@Param("status") Integer status);
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyMapCreativeMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyMapCreative;
+
+/**
+ * 策略创意表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyMapCreativeMapper extends BaseMapper<AiKuaishouStrategyMapCreative> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyMiddleMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyMiddle;
+
+/**
+ * 策略_策略模板中间表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyMiddleMapper extends BaseMapper<AiKuaishouStrategyMiddle> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetBaseMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetBase;
+
+/**
+ * 定向基础表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyTargetBaseMapper extends BaseMapper<AiKuaishouStrategyTargetBase> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetDetailsMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetDetails;
+
+/**
+ * 智能投放快手定向策略详细信息
+ * @author: jeecg-boot
+ * @date:   2020-12-10
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyTargetDetailsMapper extends BaseMapper<AiKuaishouStrategyTargetDetails> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetUnionMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetUnion;
+
+/**
+ * 策略_定向中间表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyTargetUnionMapper extends BaseMapper<AiKuaishouStrategyTargetUnion> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTemplateMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTemplate;
+
+/**
+ * 策略模板表
+ * @author: jeecg-boot
+ * @date:   2020-12-15
+ * @cersion: V1.0
+ */
+public interface AiKuaishouStrategyTemplateMapper extends BaseMapper<AiKuaishouStrategyTemplate> {
+
+}

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

@@ -0,0 +1,138 @@
+<?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="org.jeecg.modules.ads.mapper.AiKuaiShouStrategyListPageMapper">
+
+    <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
+        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
+        where t1.account_id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        <if test="strategyName != null">
+            AND t1.strategy_name like '%${strategyName}%'
+        </if>
+        <if test="strategyState != null">
+            AND t1.strategy_state=#{strategyState}
+        </if>
+        <if test="id != null">
+            AND t1.id=#{id}
+        </if>
+        order by t1.create_time desc
+    </select>
+
+    <select id="queryCampaignByStrategyId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.campaign_id as campaignId,
+        t1.campaign_name as campaignName,
+        t1.status,
+        t3.id as strategyId,
+        t3.strategy_name as strategyName,
+        IFNULL(sum(t1.charge),0) as cost,
+        IFNULL(sum(t1.photo_show),0) as photoShow,
+        IFNULL(sum(t1.photo_click),0) as photoClick,
+        CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) / sum(t1.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t1.aclick),0) as aclick,
+        IFNULL(sum(t1.bclick),0) as bclick,
+        CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) * 100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) * 1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)), 2) END AS cpc ,
+        IFNULL(sum(t1.activation),0) as active,
+        CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS activeCost ,
+        CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) / sum(t1.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t1.event_register),0) as register,
+        CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ,
+        CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) / sum(t1.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t1.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_report_daily_campaign t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.campaign_id=t2.campaign_id
+        left join ctop_kuaishou_strategy t3 on t2.strategy_id=t3.id
+        where t3.id= #{strategyId}
+        <if test="campaignName != null">
+            and t1.campaign_name like '%${campaignName}}%'
+        </if>
+        <if test="campaignId != null">
+            and t1.campaign_id=#{campaignId}
+        </if>
+        <if test="status != null">
+            AND t1.status=#{status}
+        </if>
+        GROUP BY t1.campaign_id
+        order by t1.create_time desc
+    </select>
+
+    <select id="queryUnitByCampaignId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        t1.campaign_id as campaignId,
+        t1.campaign_name as campaignName,
+        t1.unit_id as unitId,
+        t1.unit_name as unitName,
+        t1.status,
+        t3.id as strategyId,
+        t3.strategy_name as strategyName,
+        IFNULL(sum(t1.charge),0) as cost,
+        IFNULL(sum(t1.photo_show),0) as photoShow,
+        IFNULL(sum(t1.photo_click),0) as photoClick,
+        CASE WHEN sum(t1.photo_click) / sum(t1.photo_show) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.photo_click) / sum(t1.photo_show)) * 100,2),'%') END AS clickRate,
+        IFNULL(sum(t1.aclick),0) as aclick,
+        IFNULL(sum(t1.bclick),0) as bclick,
+        CASE WHEN sum(t1.bclick) / sum(t1.aclick) IS NULL THEN 0 ELSE CONCAT( ROUND((sum(t1.bclick) / sum(t1.aclick)) * 100,2),'%') END AS bClickRate,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_show) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_show)) * 1000, 2 ) END AS cpm ,
+        CASE WHEN sum(t1.charge) / sum(t1.photo_click) IS NULL THEN 0 ELSE ROUND((sum(t1.charge) / sum(t1.photo_click)), 2) END AS cpc ,
+        IFNULL(sum(t1.activation),0) as active,
+        CASE WHEN sum(t1.charge) / sum(t1.activation) IS NULL THEN 0 ELSE sum(t1.charge) / sum(t1.activation) end AS activeCost ,
+        CASE WHEN sum(t1.activation) / sum(t1.download_completed) IS NULL THEN 0 ELSE concat(round(sum(t1.activation) / sum(t1.download_completed)*100,2),'%') end as activeRate ,
+        IFNULL(sum(t1.event_register),0) as register,
+        CASE WHEN sum(t1.charge) / sum(t1.event_register) IS NULL THEN 0 ELSE round(sum(t1.charge)/sum(t1.event_register),3) end as activeRegisterCost ,
+        CASE WHEN sum(t1.event_register) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_register) / sum(t1.activation)*100,2),'%') end as activeRegisterRate ,
+        IFNULL(sum(t1.event_next_day_stay),0) as nextDayOpen,
+        CASE WHEN sum(t1.event_next_day_stay) / sum(t1.activation) IS NULL THEN 0 ELSE concat(round(sum(t1.event_next_day_stay) / sum(t1.activation)*100,2),'%') end as nextDayOpenRate
+        FROM
+        ctop_kuaishou_report_daily_group t1
+        LEFT JOIN ctop_ai_kuaishou_strategy_map_creative t2 on t1.unit_id=t2.unit_id
+        left join ctop_kuaishou_strategy t3 on t2.strategy_id=t3.id
+        where t1.campaign_id= #{campaignId}
+        <if test="unitName != null">
+            and t1.unit_name like '%${unitName}}%'
+        </if>
+        <if test="unitId != null">
+            and t1.unit_id=#{unitId}
+        </if>
+        <if test="status != null">
+            AND t1.status=#{status}
+        </if>
+        GROUP BY t1.unit_id
+        order by t1.create_time desc
+    </select>
+</mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyMapCreativeMapper.xml

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

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyMiddleMapper.xml

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

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetBaseMapper.xml

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

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetDetailsMapper.xml

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

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetUnionMapper.xml

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

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTemplateMapper.xml

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

+ 17 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaiShouStrategyListPageService.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.ads.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+
+/**
+ *  Created by JQ.bi on 2020.12.16
+ */
+public interface IAiKuaiShouStrategyListPageService {
+
+    PageInfo<JSONObject> pageStrategy(JSONObject params);
+
+    PageInfo<JSONObject> pageCampaign(JSONObject params);
+
+    PageInfo<JSONObject> pageUnit(JSONObject params);
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyMapCreativeService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyMapCreative;
+
+/**
+ * @Description: 策略创意表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyMapCreativeService extends IService<AiKuaishouStrategyMapCreative> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyMiddleService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyMiddle;
+
+/**
+ * @Description: 策略_策略模板中间表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyMiddleService extends IService<AiKuaishouStrategyMiddle> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTemplate;
+
+/**
+ * @Description: 智能投放策略信息
+ * @Author: jeecg-boot
+ * @Date:   2020-12-10
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyService extends IService<AiKuaishouStrategyTemplate> {
+
+}

+ 17 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetBaseService.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.ads.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetBase;
+
+import java.util.List;
+
+/**
+ * @Description: 定向基础表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyTargetBaseService extends IService<AiKuaishouStrategyTargetBase> {
+
+    List<AiKuaishouStrategyTargetBase> listByType(String testDirection);
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetDetailsService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetDetails;
+
+/**
+ * @Description: 智能投放快手定向策略详细信息
+ * @Author: jeecg-boot
+ * @Date:   2020-12-10
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyTargetDetailsService extends IService<AiKuaishouStrategyTargetDetails> {
+
+}

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetUnionService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ads.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetUnion;
+
+/**
+ * @Description: 策略_定向中间表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyTargetUnionService extends IService<AiKuaishouStrategyTargetUnion> {
+
+}

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTemplateService.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ads.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTemplate;
+
+/**
+ * @Description: 策略模板表
+ * @Author: jeecg-boot
+ * @Date:   2020-12-15
+ * @Version: V1.0
+ */
+public interface IAiKuaishouStrategyTemplateService extends IService<AiKuaishouStrategyTemplate> {
+
+    AiKuaishouStrategyTemplate getOneByParams(String testDirection, Integer status);
+}

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiStrategyService.java

@@ -0,0 +1,7 @@
+package org.jeecg.modules.ads.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+
+public interface IAiStrategyService {
+    void createCreativeByStrategy(KuaishouStrategy strategy);
+}

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

@@ -0,0 +1,5 @@
+package org.jeecg.modules.ads.service;
+
+public interface Test {
+    int f();
+}

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

@@ -0,0 +1,87 @@
+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;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.log4j.Log4j;
+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;
+
+import java.util.List;
+
+@Log4j
+@Service
+public class AiKuaiShouStrategyListPageServiceImpl implements IAiKuaiShouStrategyListPageService {
+
+    @Autowired
+    AiKuaiShouStrategyListPageMapper  aiKuaiShouStrategyListPageMapper;
+
+    @Autowired
+    IUserAllocationService userAllocationService;
+    @Autowired
+    private ISysRoleService sysRoleService;
+
+    @Override
+    public PageInfo<JSONObject> pageStrategy(JSONObject params) {
+        JSONArray accountIds= params.getJSONArray("accountIds");
+        if(null == accountIds||accountIds.isEmpty()){
+            accountIds = null;
+        }
+        String strategyName=params.getString("strategyName");
+        Integer strategyState=params.getInteger("strategyState");
+        Long id=params.getLong("id");
+        int pageNo=params.getInteger("pageNo");
+        int pageSize=params.getInteger("pageSize");
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list=aiKuaiShouStrategyListPageMapper.queryStrategyBy(accountIds,strategyName,strategyState,id);
+        return new PageInfo<>(list);
+    }
+
+    @Override
+    public PageInfo<JSONObject> pageCampaign(JSONObject params) {
+        Long strategyId= params.getLong("strategyId");
+        if(null==strategyId){
+            log.error("参数异常,strategyId is no present");
+            return null;
+        }
+        String campaignName=params.getString("campaignName");
+        Integer status=params.getInteger("status");
+        Long campaignId=params.getLong("campaignId");
+        int pageNo=params.getInteger("pageNo");
+        int pageSize=params.getInteger("pageSize");
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list=aiKuaiShouStrategyListPageMapper.queryCampaignByStrategyId(strategyId,campaignName,campaignId,status);
+        return new PageInfo<>(list);
+    }
+
+    @Override
+    public PageInfo<JSONObject> pageUnit(JSONObject params) {
+        Long campaignId= params.getLong("campaignId");
+        if(null==campaignId){
+            log.error("参数异常,campaignId is no present");
+            return null;
+        }
+        String unitName=params.getString("unitName");
+        Integer status=params.getInteger("status");
+        Long unitId=params.getLong("unitId");
+        int pageNo=params.getInteger("pageNo");
+        int pageSize=params.getInteger("pageSize");
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> list=aiKuaiShouStrategyListPageMapper.queryUnitByCampaignId(campaignId,unitName,unitId,status);
+        return new PageInfo<>(list);
+    }
+
+    private JSONArray listToJSONArray(List<JSONObject> data){
+        JSONArray result=new JSONArray();
+        data.forEach(jsonObject->result.add(jsonObject.getLong("account_id")));
+        return result;
+    }
+}

+ 18 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyMapCreativeServiceImpl.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.ads.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyMapCreative;
+import org.jeecg.modules.ads.mapper.AiKuaishouStrategyMapCreativeMapper;
+import org.jeecg.modules.ads.service.IAiKuaishouStrategyMapCreativeService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 策略创意表
+ * @author jeecg-boot
+ * @date   2020-12-15
+ * @version V1.0
+ */
+@Service
+public class AiKuaishouStrategyMapCreativeServiceImpl extends ServiceImpl<AiKuaishouStrategyMapCreativeMapper, AiKuaishouStrategyMapCreative> implements IAiKuaishouStrategyMapCreativeService {
+
+}

+ 18 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyMiddleServiceImpl.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.ads.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyMiddle;
+import org.jeecg.modules.ads.mapper.AiKuaishouStrategyMiddleMapper;
+import org.jeecg.modules.ads.service.IAiKuaishouStrategyMiddleService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 策略_策略模板中间表
+ * @author jeecg-boot
+ * @date   2020-12-15
+ * @version V1.0
+ */
+@Service
+public class AiKuaishouStrategyMiddleServiceImpl extends ServiceImpl<AiKuaishouStrategyMiddleMapper, AiKuaishouStrategyMiddle> implements IAiKuaishouStrategyMiddleService {
+
+}

+ 30 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetBaseServiceImpl.java

@@ -0,0 +1,30 @@
+package org.jeecg.modules.ads.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetBase;
+import org.jeecg.modules.ads.mapper.AiKuaishouStrategyTargetBaseMapper;
+import org.jeecg.modules.ads.service.IAiKuaishouStrategyTargetBaseService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 定向基础表
+ * @author jeecg-boot
+ * @date   2020-12-15
+ * @version V1.0
+ */
+@Service
+public class AiKuaishouStrategyTargetBaseServiceImpl extends ServiceImpl<AiKuaishouStrategyTargetBaseMapper, AiKuaishouStrategyTargetBase> implements IAiKuaishouStrategyTargetBaseService {
+
+    @Override
+    public List<AiKuaishouStrategyTargetBase> listByType(String testDirection) {
+        QueryWrapper<AiKuaishouStrategyTargetBase>queryWrapper =new QueryWrapper<>();
+        if(null!=testDirection&&!testDirection.trim().equals("")){
+            queryWrapper.eq("target_type",testDirection);
+        }
+        queryWrapper.eq("status",1);
+        return this.list(queryWrapper);
+    }
+}

+ 18 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetDetailsServiceImpl.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.ads.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetDetails;
+import org.jeecg.modules.ads.mapper.AiKuaishouStrategyTargetDetailsMapper;
+import org.jeecg.modules.ads.service.IAiKuaishouStrategyTargetDetailsService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 智能投放快手定向策略详细信息
+ * @author jeecg-boot
+ * @date   2020-12-10
+ * @version V1.0
+ */
+@Service
+public class AiKuaishouStrategyTargetDetailsServiceImpl extends ServiceImpl<AiKuaishouStrategyTargetDetailsMapper, AiKuaishouStrategyTargetDetails> implements IAiKuaishouStrategyTargetDetailsService {
+
+}

+ 18 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetUnionServiceImpl.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.ads.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTargetUnion;
+import org.jeecg.modules.ads.mapper.AiKuaishouStrategyTargetUnionMapper;
+import org.jeecg.modules.ads.service.IAiKuaishouStrategyTargetUnionService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 策略_定向中间表
+ * @author jeecg-boot
+ * @date   2020-12-15
+ * @version V1.0
+ */
+@Service
+public class AiKuaishouStrategyTargetUnionServiceImpl extends ServiceImpl<AiKuaishouStrategyTargetUnionMapper, AiKuaishouStrategyTargetUnion> implements IAiKuaishouStrategyTargetUnionService {
+
+}

+ 33 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTemplateServiceImpl.java

@@ -0,0 +1,33 @@
+package org.jeecg.modules.ads.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTemplate;
+import org.jeecg.modules.ads.mapper.AiKuaishouStrategyTemplateMapper;
+import org.jeecg.modules.ads.service.IAiKuaishouStrategyTemplateService;
+import org.jeecg.modules.ctop.vo.QueryParam;
+import org.springframework.stereotype.Service;
+
+/**
+ * 策略模板表
+ * @author jeecg-boot
+ * @date   2020-12-15
+ * @version V1.0
+ */
+@Service
+public class AiKuaishouStrategyTemplateServiceImpl extends ServiceImpl<AiKuaishouStrategyTemplateMapper, AiKuaishouStrategyTemplate> implements IAiKuaishouStrategyTemplateService {
+
+    @Override
+    public AiKuaishouStrategyTemplate getOneByParams(String templateType, Integer status) {
+        QueryWrapper<AiKuaishouStrategyTemplate> queryWrapper= new QueryWrapper<>();
+        if(null!=templateType&&!"".equals(templateType.trim())){
+            queryWrapper.eq("template_type",templateType);
+        }
+        if(null!=status){
+            queryWrapper.eq("status",status);
+        }
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}

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

@@ -0,0 +1,672 @@
+package org.jeecg.modules.ads.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.entity.MaterialImageInfo;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.IMaterialImageInfoService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ads.entity.*;
+import org.jeecg.modules.ads.service.*;
+import org.slf4j.Logger;
+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;
+
+@Service
+public class AiStrategyServiceImpl implements IAiStrategyService {
+
+    private static final Logger log = LoggerFactory.getLogger(AiStrategyServiceImpl.class);
+
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+    @Autowired
+    private IAiKuaishouStrategyTargetBaseService targetBaseService;
+    @Autowired
+    private IAiKuaishouStrategyTemplateService templateService;
+    @Autowired
+    private IAiKuaishouStrategyMiddleService middleService;
+    @Autowired
+    private IAiKuaishouStrategyTargetUnionService targetUnionService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IAiKuaishouStrategyMapCreativeService mapCreativeService;
+    @Autowired
+    private IMaterialCutFrameService materialCutFrameService;
+    @Autowired
+    private IMaterialImageInfoService materialImageInfoService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IKuaiShouMaterialUploadService materialUploadService;
+    /**
+     *
+     * @param strategy
+     */
+    @Override
+    public void createCreativeByStrategy(KuaishouStrategy strategy){
+        //获取账户id
+        Long accountId = strategy.getAccountId();
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
+        if(null == token){
+            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();
+        //根据策略类型获取策略模板信息
+        AiKuaishouStrategyTemplate strategyTemplate = templateService.getOneByParams(scenes, 1);
+        if(null == strategyTemplate){
+            log.info("策略模板信息获取失败=>testDirection:{}",scenes);
+            return;
+        }
+        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;
+                    }
+                    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);
+                        }
+                    }
+                }
+            }
+        }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());
+        creativeParams.put("unit_id",unitId);
+        creativeParams.put("photo_id",videoItem.getPhotoId());
+        String uuid = UUID.randomUUID().toString();
+        creativeParams.put("creative_name","智能创意-"+uuid+unitCnt+"-"+1);
+        creativeParams.put("creative_material_type",videoItem.getMaterialType());
+        creativeParams.put("action_bar_text","立即下载");
+        creativeParams.put("description","太美了!来电显示设为视频铃声,来电话就开始播放~");
+        // 安卓下载中间页ID
+        JSONArray siteIdArray = JSONArray.parseArray(strategy.getSiteId());
+        if(null == siteIdArray||!siteIdArray.isEmpty()){
+            JSONObject siteObject = siteIdArray.getJSONObject(0);
+            Long appId = siteObject.getLong("appId");
+            Long siteId = siteObject.getLong("siteId");
+            if(null!=siteId){
+                creativeParams.put("site_id",siteId);
+            }
+        }
+        if(null != strategy.getClickTrackUrl()&&!"".equals(strategy.getClickTrackUrl())){
+            creativeParams.put("click_track_url",strategy.getClickTrackUrl());
+        }
+        if(null != strategy.getImpressionUrl()&&!"".equals(strategy.getImpressionUrl())){
+            creativeParams.put("impression_url",strategy.getImpressionUrl());
+        }
+        if(null != strategy.getActionbarClickUrl()&&!"".equals(strategy.getActionbarClickUrl())){
+            creativeParams.put("actionbar_click_url",strategy.getActionbarClickUrl());
+        }
+        if(null!=strategy.getCreativeCategory()){
+            creativeParams.put("creative_category",strategy.getCreativeCategory());
+            creativeParams.put("creative_tag",JSONArray.parseArray(strategy.getCreativeTag()));
+        }
+        return creativeParams;
+    }
+
+    private String getStragyDefDomain(AiKuaishouStrategyTemplate strategyTemplate,KuaishouStrategy strategy){
+        String definitionDomain = null;
+        if (strategyTemplate.getTestDirection().equals("age")){
+            definitionDomain = strategy.getAgesRange();
+        }
+        if (strategyTemplate.getTestDirection().equals("gender")){
+            definitionDomain = strategy.getGender().toString();
+        }
+        if (strategyTemplate.getTestDirection().equals("region")){
+            definitionDomain = strategy.getRegion();
+        }
+        if (strategyTemplate.getTestDirection().equals("operation_system")){
+            definitionDomain = strategy.getPlatformOs().toString();
+        }
+        return definitionDomain;
+    }
+
+    private JSONObject createUnitParams(CtopOauthToken token,Long campaignId,KuaishouStrategy strategy,AiKuaishouStrategyTemplate strategyTemplate,
+                                        AiKuaishouStrategyTargetBase 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() + item.getTargetType() + item.getTargetContent() + 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",strategy.getCpaBid());
+        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();
+        //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 {
+            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 void createCreative(CtopOauthToken token,JSONObject creativeParams,Long campaignId,Long unitId,
+                                KuaishouStrategy strategy,AiKuaishouStrategyTargetUnion targetUnion,int creativeCnt,KuaiShouVideoGet videoGet){
+        creativeParams.put("creative_name",creativeParams.getString("creative_name")+creativeCnt);
+        Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate
+                (token.getAccessToken(), token.getAccountId(), creativeParams,1);
+        Integer creativeCode = (Integer) creativeCreateResult.get("code");
+        String creativeMessage = (String) creativeCreateResult.get("message");
+        if(creativeCode != 0 ){
+            log.info("创意创建失败=>message:{}",creativeMessage);
+            return;
+        }
+        Long creativeId = (Long) creativeCreateResult.get("creativeId");
+        AiKuaishouStrategyMapCreative mapCreative = new AiKuaishouStrategyMapCreative();
+        mapCreative.setAccountId(token.getAccountId());
+        mapCreative.setCampaignId(campaignId);
+        mapCreative.setUnitId(unitId);
+        //TODO 添加
+        mapCreative.setVideoSignature(videoGet.getSignature());
+        mapCreative.setCreativeId(creativeId);
+        mapCreative.setStrategyId(strategy.getId());
+        if(null!=targetUnion){
+            mapCreative.setStrategyTargetUnionId(targetUnion.getId());
+        }
+        mapCreativeService.save(mapCreative);
+    }
+
+    private String getImageToken(String imageUrl, String imageCode, Long accountId,String token){
+        // 根据imageUrl 和 imageCode,获取 imageToken (创建创意用)
+        KuaiShouImageGet imageGet = imageGetService.getOneByParams(null,imageCode);
+        if ((null == imageGet) || ("".equals(imageGet.getImageToken()))){
+            // 如果取不到image_token
+            // 则调用上传url的方法 kuauiShouImageUpload(url, signature, accountId, oauthToken.getAccessToken());
+            return materialUploadService.kuauiShouImageUpload(imageUrl,imageCode,accountId,token);
+        }
+
+        return imageGet.getImageToken();
+    }
+
+    private List<AiKuaishouStrategyTargetBase> splitBasesByDomain(String definitionDomain,
+                                                                  List<AiKuaishouStrategyTargetBase> targetBases) {
+        if(null==definitionDomain){
+            return targetBases;
+        }
+        if(null == targetBases||targetBases.isEmpty()){
+            return null;
+        }
+        String type =  targetBases.get(0).getType();
+        List<AiKuaishouStrategyTargetBase> resultBase = null;
+        //数字
+        if("number".equals(type)){
+            resultBase = targetBases.stream().filter(target -> definitionDomain.equals(target.getTargetContent())).
+                    collect(Collectors.toList());
+        }
+        //数组
+        if("array".equals(type)){
+            resultBase = targetBases.stream().filter(target -> checkContainsEveryOne(definitionDomain,target.getTargetContent())).map(target->{
+                target.setTargetContent(getContainsElement(definitionDomain,target.getTargetContent()));
+                return target;
+            }).collect(Collectors.toList());
+        }
+        return resultBase;
+    }
+
+    /**
+     * 后期需要优化
+     * 判定是否存在交集
+     * @param definitionDomain
+     * @param targetContent
+     * @return
+     */
+    private boolean checkContainsEveryOne(String definitionDomain, String targetContent) {
+        JSONArray definitionDomainArray = JSONArray.parseArray(definitionDomain);
+        JSONArray targetContentArray = JSONArray.parseArray(targetContent);
+        if(definitionDomainArray.size()>=targetContentArray.size()){
+            return checkContains(targetContentArray,definitionDomainArray);
+        }
+        return checkContains(definitionDomainArray,targetContentArray);
+    }
+
+    /**
+     *
+     * @param shortArray
+     * @param longArray
+     * @return
+     */
+    private boolean checkContains(JSONArray shortArray, JSONArray longArray) {
+        for (int i = 0; i < shortArray.size(); i++) {
+            Long s = shortArray.getLong(i);
+            for(int j=0;j<longArray.size();j++){
+                Long l = longArray.getLong(j);
+                if(s.equals(l)){
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * 获取交集元素
+     * @param definitionDomain
+     * @param targetContent
+     * @return
+     */
+    private String getContainsElement(String definitionDomain, String targetContent){
+        JSONArray definitionDomainArray = JSONArray.parseArray(definitionDomain);
+        JSONArray targetContentArray = JSONArray.parseArray(targetContent);
+        return getContainsArray(definitionDomainArray,targetContentArray);
+    }
+
+    private String getContainsArray(JSONArray definitionDomainArray, JSONArray targetContentArray) {
+        log.info("definitionDomainArray:"+definitionDomainArray.toJSONString());
+        log.info("targetContentArray:"+targetContentArray.toJSONString());
+        JSONArray resultArray = new JSONArray();
+        for (int i = 0; i < definitionDomainArray.size(); i++) {
+            Long s = definitionDomainArray.getLong(i);
+            for(int j=0;j<targetContentArray.size();j++){
+                Long l = targetContentArray.getLong(j);
+                if(l.equals(s)){
+                    resultArray.add(l);
+                }
+            }
+        }
+        log.info("result:"+resultArray.toJSONString());
+        return resultArray.toJSONString();
+    }
+}

+ 95 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/TestImpl.java

@@ -0,0 +1,95 @@
+package org.jeecg.modules.ads.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouReportDailyMaterialMapper;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
+import cn.hutool.json.JSON;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.models.auth.In;
+//import jdk.nashorn.internal.parser.JSONParser;
+import org.jeecg.modules.ads.entity.AiKuaishouStrategyTemplate;
+import org.jeecg.modules.ads.mapper.AiKuaishouStrategyTemplateMapper;
+import org.jeecg.modules.ads.service.Test;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class TestImpl implements Test {
+
+    private KuaiShouReportDailyMaterialMapper dailyMaterialMapper;
+    private AiKuaishouStrategyTemplateMapper strategyTemplateMapper;
+    @Override
+    public int f() {
+        return 123;
+    }
+
+    private static int printInt(int a){
+        System.out.println(a);
+        return a;
+    }
+
+    public static String getStrategy(){
+        /**
+         *
+         * [{
+         *     "matGetType":"highQualityMaterial",
+         *     "matNum":5
+         * },
+         *    {
+         *     "matGetType":"highQualityMaterial",
+         *     "matNum":5
+         *     "intervalDays": 7,
+         * }]
+         */
+
+       /* String materialCombinationMode = "{'highQualityMaterial':{'intervalDays':7, 'highQualityMaterialNum':5}, 'newMaterialNum':5}";
+        JSONObject jsonObject = JSONObject.parseObject(materialCombinationMode);
+
+        int intervalDays = (int) jsonObject.getJSONObject("highQualityMaterial").get("intervalDays");
+        int highQualityMaterialNum = (int) jsonObject.getJSONObject("highQualityMaterial").get("highQualityMaterialNum");
+        int newQualityMaterialNum = (int) jsonObject.get("newMaterialNum");*/
+
+        return "213";
+
+
+    }
+
+    public List<String> getMaterialId(){
+        // 获取素材组合方式
+        // 下面这三个字段从前端传给的JSON数据进行解析得到
+//        Long accountId = 7087890L;
+//        Integer strategyType = 1;
+//        List<AiKuaishouStrategyTemplate> StrategyTemplate =
+//                strategyTemplateMapper.getStrategyTemplate(accountId,strategyType);
+//
+//        String materialCombinationMode = StrategyTemplate.get(0).getMaterialCombinationMode();
+//        JSONObject JsonObject = JSONObject.parseObject(materialCombinationMode);
+//        Integer intervalDays = (Integer) JsonObject.getJSONObject("highQualityMaterial").get("intervalDays");
+//        Integer highQualityMaterialNum = (Integer) JsonObject.getJSONObject("highQualityMaterial").get("highQualityMaterialNum");
+//        Integer newQualityMaterialNum = (Integer) JsonObject.get("newMaterialNum");
+//
+//        // 获取优质素材的签名
+//        List<String> materialIds = new ArrayList<>();
+//        List<KuaiShouReportDailyMaterial> highQualityMaterialIds =
+//                        dailyMaterialMapper.getHighQualityMaterialId(accountId,intervalDays,highQualityMaterialNum);
+//        for (KuaiShouReportDailyMaterial item: highQualityMaterialIds){
+//            materialIds.add(item.getSignature());
+//        }
+
+        // 获取最新上线素材的签名
+
+
+
+//        return materialIds;
+
+        return null;
+    }
+
+    public static void main(String[] args) {
+        int getNum = 123;
+        int num = printInt(getNum);
+        System.out.println(num++);
+    }
+
+}

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

@@ -16,6 +16,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -305,6 +306,19 @@ public class UserAllocationController {
         return result;
     }
 
+    @GetMapping(value = "/getAccountIdsByUserId")
+    public Result<List<JSONObject>> getAccountIdsByUserId(String userId) {
+        Result<List<JSONObject>> result = new Result<>();
+        try {
+            List<JSONObject> accountIds = userAllocationService.getAccountIdsByUserId(userId);
+            result.setSuccess(true);
+            result.setResult(accountIds);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success(e.getMessage());
+        }
+        return result;
+    }
 
     /**
      * 分页列表查询

+ 18 - 2
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -376,6 +376,13 @@ public class SampleTest {
             videoReportDailyService.videoInfoList(date, date);
         }
     }
+    @Autowired
+    private org.jeecg.modules.ads.service.Test test;
+
+    @Test
+    public void test(){
+        test.f();
+    }
 
     @Autowired
     private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
@@ -402,11 +409,11 @@ public class SampleTest {
     private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
     @Test
     public void etlBytedanceData(){
-        String dateString = "2020-03-01";
+        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);
+//            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
             kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
         }
     }
@@ -418,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 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/CustomDataByAccountMapper.java

@@ -14,6 +14,10 @@ public interface CustomDataByAccountMapper {
     //快手查询账户日报数据
     JSONObject queryKsAccountData(@Param("accountId") Long accountId,@Param("date") String date);
 
+
+    //快手查询物料日报数据
+    JSONObject queryKsMaterialData(@Param("accountId") Long accountId,@Param("days") Integer days);
+
     //头条查询广告组日报数据
     JSONObject queryByCampaignData(@Param("accountId") Long accountId,@Param("date") String date);
 

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.UserAllocation;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -26,6 +27,8 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
     List<JSONObject> getAccountIdListByUserId(@Param("userId") Long userId);
 
+    List<JSONObject> getAccountIdsByUserId(@Param("userId") String userId);
+
     Long getProjectIdByAccountId(@Param("accountId") Long accountId);
 
     UserAllocation getUserAllocation(@Param("accountId") Long accountId);

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

@@ -63,6 +63,18 @@
     AND t1.account_status = 0
     </select>
 
+    <select id="getAccountIdsByUserId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            account_id,
+            auth_name,
+            project_name
+        FROM
+            ctop_user_allocation
+        WHERE
+            user_id = #{userId}
+          and account_status=0
+    </select>
+
     <select id="getProjectIdByAccountId" resultType="java.lang.Long">
     select  project_id  from  ctop_user_allocation
     where account_id = #{accountId}

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageInfoService.java

@@ -29,4 +29,7 @@ public interface IMaterialImageInfoService extends IService<MaterialImageInfo> {
     void initImageCode(MaterialImageInfo image);
 
     MaterialImageInfo getByCode(String signature);
+
+
+    List<MaterialImageInfo> getListByVideoSignature(String signature);
 }

+ 3 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.UserAllocation;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -33,6 +34,8 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     List<JSONObject> getAccountIdListByUserId(Long userId);
 
+    List<JSONObject> getAccountIdsByUserId(String userId);
+
     List<UserAllocation> getUserAllocations(String mediaId ,int switchType);
 
     JSONObject getSwitchStatusByAccount(Long accountId);

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageInfoServiceImpl.java

@@ -151,4 +151,15 @@ public class MaterialImageInfoServiceImpl extends ServiceImpl<MaterialImageInfoM
         return this.getOne(queryWrapper);
     }
 
+
+    @Override
+    public List<MaterialImageInfo> getListByVideoSignature(String signature) {
+        QueryWrapper<MaterialImageInfo>queryWrapper =new QueryWrapper<>();
+        if(null!=signature&&!signature.trim().equals("")){
+            queryWrapper.eq("video_id",signature);
+        }
+        return this.list(queryWrapper);
+    }
+
+
 }

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -121,6 +122,11 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     }
 
     @Override
+    public List<JSONObject> getAccountIdsByUserId(String userId) {
+        return userAllocationMapper.getAccountIdsByUserId(userId);
+    }
+
+    @Override
     public List<UserAllocation> getUserAllocations(String mediaId, int switchType) {
         QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("media_id", mediaId);

+ 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);
 

+ 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;
 }

+ 11 - 1
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;
 
 /**
@@ -32,6 +33,15 @@ public class KuaishouStrategy {
     @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "id")
     private Long id;
+    private String createBy;
+    private String creativeTag;
+    private Integer creativeCategory;
+    //转化目标最低出价
+    private Long cpaBidMin;
+    //转化目标最高出价
+    private Long cpaBidMax;
+    //出价拆分步长
+    private Long stepSize;
     /**
      * 账户ID
      */
@@ -169,7 +179,7 @@ public class KuaishouStrategy {
      */
     @Excel(name = "转化目标出价", width = 15)
     @ApiModelProperty(value = "转化目标出价")
-    private Integer cpaBid;
+    private Long cpaBid;
     /**
      * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
      */

+ 3 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/kuaishoustrategycampaignRel.java

@@ -1,20 +1,17 @@
 package cn.com.ctop.kuaishou.modules.batch.entity;
 
-import java.io.Serializable;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
+import java.util.Date;
+
 /**
  * 快手-策略和计划启动/关停关系表
  * @author jeecg-boot
@@ -29,7 +26,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
 public class kuaishoustrategycampaignRel {
     
 	/**策略ID*/
-	@TableId(type = IdType.UUID)
+	@TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "策略ID")
 	private Long id;
 	/**策略id*/

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

@@ -33,4 +33,6 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
     KuaiShouReportDailyMaterial getEtlDataByParams(@Param("signature")String signature,@Param("date") String date);
 
     List<KuaiShouReportDailyMaterial> getSignatureByDate(@Param("date")String date);
+
+
 }

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

@@ -1,12 +1,11 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
-import java.util.List;
-
 import cn.com.ctop.kuaishou.modules.batch.entity.kuaishoustrategycampaignRel;
 import com.alibaba.fastjson.JSONObject;
-import org.apache.ibatis.annotations.Param;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * 快手-策略和计划启动/关停关系表
  * @author: jeecg-boot

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

@@ -349,6 +349,5 @@
         and
             stat_date = #{date}
     </select>
-
-
 </mapper>
+

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

@@ -57,4 +57,6 @@
         order by stat_date desc
     </select>
 
+
+
 </mapper>

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

@@ -15,4 +15,6 @@ public interface IKuaiShouImageGetService extends IService<KuaiShouImageGet> {
     void replaceBatch(List<KuaiShouImageGet> imageGets);
 
     String getUrlByCode(String signature);
+
+    KuaiShouImageGet getOneByParams(String url,String code);
 }

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

@@ -19,4 +19,6 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     void getKeyFrame(String token, Long accountId, String md5, String photoId);
 
     List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> stringObjectMap);
+
+    List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer videoAiStatus);
 }

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

@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouImageGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -38,4 +39,19 @@ public class KuaiShouImageGetServiceImpl extends ServiceImpl<KuaiShouImageGetMap
 
     }
 
+
+    @Override
+    public KuaiShouImageGet getOneByParams(String url,String code) {
+        QueryWrapper<KuaiShouImageGet> queryWrapper= new QueryWrapper<>();
+        if(null!=url&&!"".equals(url.trim())){
+            queryWrapper.eq("url",url);
+        }
+        if(null!=code&&!"".equals(code.trim())){
+            queryWrapper.eq("signature",code);
+        }
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+
 }

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

@@ -281,7 +281,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
                 if (code == 0) {
-
                     QueryWrapper<KuaiShouCampaign> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("campaign_id", campaignId);
                     queryWrapper.eq("account_id", advertiserId);
@@ -300,7 +299,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     if (i > 0) {
                         log.info("修改广告计划状态本地记录添加成功,campaignId:{}", campaignId);
                     }
-
                     if (putStatus == 3) {
                         Map<String, Object> deleteMap = new HashMap<>();
                         deleteMap.put("account_id", advertiserId);
@@ -324,7 +322,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                 returnMap.put("success", false);
                 returnMap.put("message", "修改广告组预算返回结果为空");
             }
-
         } catch (Exception e) {
             log.error("修改广告计划状态异常,advertiserId:{},campaignId:{}", advertiserId, campaignId);
             e.printStackTrace();
@@ -332,7 +329,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             returnMap.put("success", false);
             returnMap.put("message", "修改广告计划状态算异常");
         }
-
         return returnMap;
     }
 
@@ -375,8 +371,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     } else {
                         groupService.getGroupByUnitId(token, advertiserId, unitId);
                     }
-
-
                 } else {
                     log.error("修改广告组状态失败,advertiserId:{},unitId:{},返回信息:{}", advertiserId, unitId, resultJson);
                     returnMap.put("code", -1);
@@ -389,7 +383,6 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                 returnMap.put("success", false);
                 returnMap.put("message", "修改广告组预算返回结果为空");
             }
-
         } catch (Exception e) {
             log.error("修改广告组状态异常,advertiserId:{},unitId:{}", advertiserId, unitId);
             e.printStackTrace();

+ 13 - 3
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;
 
@@ -123,4 +120,17 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
     public List<KuaiShouVideoGetVo> getVideoList(Map<String, Object> requestMap) {
         return videoGetMapper.getVideoList(requestMap);
     }
+
+    @Override
+    public List<KuaiShouVideoGet> getNewVideoByAccountId(Long accountId,Integer aiStatus) {
+        QueryWrapper<KuaiShouVideoGet>queryWrapper = new QueryWrapper<>();
+        if(null!=accountId&&accountId!=0){
+            queryWrapper.eq("account_id",accountId);
+        }
+        if(null!=aiStatus&&aiStatus!=0){
+            queryWrapper.eq("ai_status",aiStatus);
+        }
+        queryWrapper.orderByDesc("stat_date");
+        return this.list(queryWrapper);
+    }
 }

+ 14 - 6
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) {
@@ -1019,8 +1015,20 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     returnMap.put("campaignId", campaignId);
                     returnMap.put("success", true);
                     // 创建成功 拉取广告组信息
-                    Thread.sleep(500);
-                    getCampaign(accessToken, advertiserId, campaignId);
+
+                    Thread thread = new Thread(){
+                        @Override
+                        public void run(){
+                            try {
+                                Thread.sleep(500);
+                            } catch (InterruptedException e) {
+                                e.printStackTrace();
+                            }
+                            getCampaign(accessToken, advertiserId, campaignId);
+                        }
+                    };
+                    thread.start();
+
                 } else {
                     log.error("创建广告计划失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
                     returnMap.put("code", -1);

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

@@ -7,11 +7,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
 import cn.com.ctop.kuaishou.modules.batch.entity.kuaishoustrategycampaignRel;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouStrategyMapper;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
+import cn.com.ctop.kuaishou.modules.batch.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -90,6 +86,11 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
             }
             if (flag) {
                 obj.put(id.toString(), true);
+                QueryWrapper<KuaishouStrategy> strategyWrapper = new QueryWrapper<>();
+                strategyWrapper.eq("id", id);
+                KuaishouStrategy strategy = new KuaishouStrategy();
+                strategy.setStrategyState(data.getString("state"));
+                kuaishouStrategyMapper.update(strategy, strategyWrapper);
             } else {
                 obj.put(id.toString(), false);
             }

+ 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();