Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

jiequan.bi 4 tahun lalu
induk
melakukan
f083e00a9d
100 mengubah file dengan 3798 tambahan dan 89 penghapusan
  1. 55 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/AiKuaiShouStrategyListPageCtrl.java
  2. 26 14
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouStrategyController.java
  3. 22 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/controller/StrategyController.java
  4. 42 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyMapCreative.java
  5. 41 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyMiddle.java
  6. 37 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetBase.java
  7. 30 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetDetails.java
  8. 40 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTargetUnion.java
  9. 45 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/entity/AiKuaishouStrategyTemplate.java
  10. 23 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaiShouStrategyListPageMapper.java
  11. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyMapCreativeMapper.java
  12. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyMiddleMapper.java
  13. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetBaseMapper.java
  14. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetDetailsMapper.java
  15. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTargetUnionMapper.java
  16. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/AiKuaishouStrategyTemplateMapper.java
  17. 138 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyListPageMapper.xml
  18. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyMapCreativeMapper.xml
  19. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyMiddleMapper.xml
  20. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetBaseMapper.xml
  21. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetDetailsMapper.xml
  22. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTargetUnionMapper.xml
  23. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/mapper/xml/AiKuaishouStrategyTemplateMapper.xml
  24. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaiShouStrategyListPageService.java
  25. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyMapCreativeService.java
  26. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyMiddleService.java
  27. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyService.java
  28. 17 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetBaseService.java
  29. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetDetailsService.java
  30. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTargetUnionService.java
  31. 15 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiKuaishouStrategyTemplateService.java
  32. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/IAiStrategyService.java
  33. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/Test.java
  34. 87 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaiShouStrategyListPageServiceImpl.java
  35. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyMapCreativeServiceImpl.java
  36. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyMiddleServiceImpl.java
  37. 30 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetBaseServiceImpl.java
  38. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetDetailsServiceImpl.java
  39. 18 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTargetUnionServiceImpl.java
  40. 33 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiKuaishouStrategyTemplateServiceImpl.java
  41. 672 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiStrategyServiceImpl.java
  42. 95 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/TestImpl.java
  43. 279 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceVideoEtlInfoController.java
  44. 231 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/KuaishouVideoEtlInfoController.java
  45. 143 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialImageVideoInfoController.java
  46. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  47. 257 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/BytedanceVideoEtlInfoEntity.java
  48. 292 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/KuaishouVideoEtlInfoEntity.java
  49. 22 5
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  50. 4 3
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleAccountThresholdServiceImpl.java
  51. 41 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialImageVideoInfo.java
  52. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CustomDataByAccountMapper.java
  53. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialImageVideoInfoMapper.java
  54. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  55. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialImageVideoInfoMapper.xml
  56. 12 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  57. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageInfoService.java
  58. 14 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageVideoInfoService.java
  59. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java
  60. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  61. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageInfoServiceImpl.java
  62. 18 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageVideoInfoServiceImpl.java
  63. 16 3
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java
  64. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  65. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/LoadFileUtil.java
  66. 25 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCampaignCopyDateJob.java
  67. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEffectVideoJob.java
  68. 267 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouCampaignCopyDataController.java
  69. 5 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java
  70. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java
  71. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java
  72. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java
  73. 159 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouCampaignCopyData.java
  74. 11 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouStrategy.java
  75. 3 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/kuaishoustrategycampaignRel.java
  76. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java
  77. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupMapper.java
  78. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupTargetMapper.java
  79. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupTemplateMapper.java
  80. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouReportDailyMaterialMapper.java
  81. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouCampaignCopyDataMapper.java
  82. 2 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/kuaishoustrategycampaignRelMapper.java
  83. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  84. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  85. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTargetMapper.xml
  86. 11 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupTemplateMapper.xml
  87. 1 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml
  88. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml
  89. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouCampaignCopyDataMapper.xml
  90. 13 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java
  91. 14 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java
  92. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupTargetService.java
  93. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupTemplateService.java
  94. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouImageGetService.java
  95. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  96. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouCampaignCopyDataService.java
  97. 0 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  98. 17 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  99. 28 12
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  100. 0 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTargetServiceImpl.java

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

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

@@ -0,0 +1,279 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.metadata.Sheet;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.excelutil.entity.BytedanceVideoEtlInfoEntity;
+import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.*;
+
+/**
+ * 头条视频信息清洗
+ * @author jeecg-boot
+ * @date   2020-12-25
+ * @version V1.0
+ */
+@Slf4j
+@RestController
+@RequestMapping("/ctop/bytedanceVideoEtlInfo")
+public class BytedanceVideoEtlInfoController {
+	@Autowired
+	private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param bytedanceVideoEtlInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceVideoEtlInfo>> queryPageList(BytedanceVideoEtlInfo bytedanceVideoEtlInfo,
+															  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															  HttpServletRequest req) {
+		Result<IPage<BytedanceVideoEtlInfo>> result = new Result<>();
+		String type = bytedanceVideoEtlInfo.getType();
+		bytedanceVideoEtlInfo.setType(null);
+		String startDate = bytedanceVideoEtlInfo.getStartDate();
+		bytedanceVideoEtlInfo.setStartDate(null);
+		String endDate = bytedanceVideoEtlInfo.getEndDate();
+		bytedanceVideoEtlInfo.setEndDate(null);
+		QueryWrapper<BytedanceVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceVideoEtlInfo, req.getParameterMap());
+		if(null!=type&&!type.equals("")){
+			if(type.trim().equals("valid")){
+				//有效
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.gt("effect_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.lt("effect_date",startDate);
+				}
+				queryWrapper.lt("effect_day_num",7);
+			}else if(type.trim().equals("hot")){
+				//爆款
+				if(null!=startDate&&!"faddish_date".equals(startDate.trim())){
+					queryWrapper.gt("",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.lt("faddish_date",startDate);
+				}
+				queryWrapper.lt("faddish_day_num",30);
+			}else {
+				//上线
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.gt("state_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.lt("state_date",startDate);
+				}
+			}
+		}
+		queryWrapper.orderByDesc("total_cost");
+		Page<BytedanceVideoEtlInfo> page = new Page<BytedanceVideoEtlInfo>(pageNo, pageSize);
+		IPage<BytedanceVideoEtlInfo> pageList = bytedanceVideoEtlInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param bytedanceVideoEtlInfo
+	 * @return
+	 */
+	@PostMapping(value = "/add")
+	public Result<BytedanceVideoEtlInfo> add(@RequestBody BytedanceVideoEtlInfo bytedanceVideoEtlInfo) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		try {
+			bytedanceVideoEtlInfoService.save(bytedanceVideoEtlInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param bytedanceVideoEtlInfo
+	 * @return
+	 */
+	@PutMapping(value = "/edit")
+	public Result<BytedanceVideoEtlInfo> edit(@RequestBody BytedanceVideoEtlInfo bytedanceVideoEtlInfo) {
+		Result<BytedanceVideoEtlInfo> result = new Result<BytedanceVideoEtlInfo>();
+		BytedanceVideoEtlInfo bytedanceVideoEtlInfoEntity = bytedanceVideoEtlInfoService.getById(bytedanceVideoEtlInfo.getId());
+		if(bytedanceVideoEtlInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceVideoEtlInfoService.updateById(bytedanceVideoEtlInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@GetMapping(value = "/queryById")
+	public Result<BytedanceVideoEtlInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		BytedanceVideoEtlInfo bytedanceVideoEtlInfo = bytedanceVideoEtlInfoService.getById(id);
+		if(bytedanceVideoEtlInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceVideoEtlInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @PostMapping(value = "/exportXls")
+  public void exportXls(BytedanceVideoEtlInfo bytedanceVideoEtlInfo,
+								HttpServletRequest request, HttpServletResponse response)throws Exception {
+      // Step.1 组装查询条件
+	  String type = bytedanceVideoEtlInfo.getType();
+	  bytedanceVideoEtlInfo.setType(null);
+	  String startDate = bytedanceVideoEtlInfo.getStartDate();
+	  bytedanceVideoEtlInfo.setStartDate(null);
+	  String endDate = bytedanceVideoEtlInfo.getEndDate();
+	  bytedanceVideoEtlInfo.setEndDate(null);
+	  QueryWrapper<BytedanceVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceVideoEtlInfo, request.getParameterMap());
+	  if(null!=type&&!type.equals("")){
+		  if(type.trim().equals("valid")){
+			  //有效
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.gt("effect_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.lt("effect_date",startDate);
+			  }
+			  queryWrapper.lt("effect_day_num",7);
+		  }else if(type.trim().equals("hot")){
+			  //爆款
+			  if(null!=startDate&&!"faddish_date".equals(startDate.trim())){
+				  queryWrapper.gt("",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.lt("faddish_date",startDate);
+			  }
+			  queryWrapper.lt("faddish_day_num",30);
+		  }else {
+			  //上线
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.gt("state_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.lt("state_date",startDate);
+			  }
+		  }
+	  }
+	  queryWrapper.orderByDesc("total_cost");
+	  List<BytedanceVideoEtlInfo> pageList = bytedanceVideoEtlInfoService.list(queryWrapper);
+
+	  //查询总的消耗信息
+	  SheetInfoVo totalSheetVo = new SheetInfoVo<BytedanceVideoEtlInfoEntity>();
+	  List<BytedanceVideoEtlInfoEntity> details = new ArrayList<>();
+	  if(null!=pageList&&!pageList.isEmpty()){
+		pageList.forEach(etlInfo->{
+			details.add(new BytedanceVideoEtlInfoEntity(etlInfo));
+		});
+		totalSheetVo.setDetails(details);
+	  }
+	  totalSheetVo.setSheetName("头条视频数据统计列表");
+	  OutputStream outputStream = response.getOutputStream();
+	  String date = DateUtils.formatDate(new Date());
+	  HttpUtils.setResponseHeader(response, "头条视频数据统计列表" + date + ".xlsx");
+	  ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
+
+	  Sheet sheet = new Sheet(1, 0, BytedanceVideoEtlInfoEntity.class);
+	  sheet.setSheetName(totalSheetVo.getSheetName());
+	  excelWriter.write(totalSheetVo.getDetails(), sheet);
+	  excelWriter.finish();
+	  outputStream.flush();
+	  outputStream.close();
+  }
+
+  /**
+      * 通过excel导入数据
+   *
+   * @param request
+   * @param response
+   * @return
+   */
+  @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+  public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+          MultipartFile file = entity.getValue();
+          ImportParams params = new ImportParams();
+          params.setTitleRows(2);
+          params.setHeadRows(1);
+          params.setNeedSave(true);
+          try {
+              List<BytedanceVideoEtlInfo> listBytedanceVideoEtlInfos = ExcelImportUtil.importExcel(file.getInputStream(), BytedanceVideoEtlInfo.class, params);
+              bytedanceVideoEtlInfoService.saveBatch(listBytedanceVideoEtlInfos);
+              return Result.ok("文件导入成功!数据行数:" + listBytedanceVideoEtlInfos.size());
+          } catch (Exception e) {
+              log.error(e.getMessage(),e);
+              return Result.error("文件导入失败:"+e.getMessage());
+          } finally {
+              try {
+                  file.getInputStream().close();
+              } catch (IOException e) {
+                  e.printStackTrace();
+              }
+          }
+      }
+      return Result.ok("文件导入失败!");
+  }
+
+}

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

@@ -0,0 +1,231 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoEtlInfo;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.metadata.Sheet;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.excelutil.entity.BytedanceVideoEtlInfoEntity;
+import org.jeecg.modules.excelutil.entity.KuaishouVideoEtlInfoEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+ /**
+ * 快手视频信息清洗
+ * @author jeecg-boot
+ * @date   2020-12-25
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="快手视频信息清洗")
+@RestController
+@RequestMapping("/ctop/kuaishouVideoEtlInfo")
+public class KuaishouVideoEtlInfoController {
+	@Autowired
+	private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param kuaishouVideoEtlInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@GetMapping(value = "/list")
+	public Result<IPage<KuaishouVideoEtlInfo>> queryPageList(KuaishouVideoEtlInfo kuaishouVideoEtlInfo,
+															 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															 HttpServletRequest req) {
+		Result<IPage<KuaishouVideoEtlInfo>> result = new Result<>();
+		String type = kuaishouVideoEtlInfo.getType();
+		kuaishouVideoEtlInfo.setType(null);
+		String startDate = kuaishouVideoEtlInfo.getStartDate();
+		kuaishouVideoEtlInfo.setStartDate(null);
+		String endDate = kuaishouVideoEtlInfo.getEndDate();
+		kuaishouVideoEtlInfo.setEndDate(null);
+		QueryWrapper<KuaishouVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouVideoEtlInfo, req.getParameterMap());
+		if(null!=type&&!type.equals("")){
+			if(type.trim().equals("valid")){
+				//有效
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.gt("effect_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.lt("effect_date",startDate);
+				}
+				queryWrapper.lt("effect_day_num",7);
+			}else if(type.trim().equals("hot")){
+				//爆款
+				if(null!=startDate&&!"faddish_date".equals(startDate.trim())){
+					queryWrapper.gt("",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.lt("faddish_date",startDate);
+				}
+				queryWrapper.lt("faddish_day_num",30);
+			}else {
+				//上线
+				if(null!=startDate&&!"".equals(startDate.trim())){
+					queryWrapper.gt("state_date",startDate);
+				}
+				if(null!=endDate&&!"".equals(endDate.trim())){
+					queryWrapper.lt("state_date",startDate);
+				}
+			}
+		}
+		queryWrapper.orderByDesc("total_cost");
+		Page<KuaishouVideoEtlInfo> page = new Page<KuaishouVideoEtlInfo>(pageNo, pageSize);
+		IPage<KuaishouVideoEtlInfo> pageList = kuaishouVideoEtlInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param kuaishouVideoEtlInfo
+	 * @return
+	 */
+	@PostMapping(value = "/add")
+	public Result<KuaishouVideoEtlInfo> add(@RequestBody KuaishouVideoEtlInfo kuaishouVideoEtlInfo) {
+		Result<KuaishouVideoEtlInfo> result = new Result<>();
+		try {
+			kuaishouVideoEtlInfoService.save(kuaishouVideoEtlInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param kuaishouVideoEtlInfo
+	 * @return
+	 */
+	@PutMapping(value = "/edit")
+	public Result<KuaishouVideoEtlInfo> edit(@RequestBody KuaishouVideoEtlInfo kuaishouVideoEtlInfo) {
+		Result<KuaishouVideoEtlInfo> result = new Result<KuaishouVideoEtlInfo>();
+		KuaishouVideoEtlInfo kuaishouVideoEtlInfoEntity = kuaishouVideoEtlInfoService.getById(kuaishouVideoEtlInfo.getId());
+		if(kuaishouVideoEtlInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = kuaishouVideoEtlInfoService.updateById(kuaishouVideoEtlInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@GetMapping(value = "/queryById")
+	public Result<KuaishouVideoEtlInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<KuaishouVideoEtlInfo> result = new Result<>();
+		KuaishouVideoEtlInfo kuaishouVideoEtlInfo = kuaishouVideoEtlInfoService.getById(id);
+		if(kuaishouVideoEtlInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(kuaishouVideoEtlInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @PostMapping(value = "/exportXls")
+  public void exportXls(KuaishouVideoEtlInfo kuaishouVideoEtlInfo,
+								HttpServletRequest request, HttpServletResponse response) throws Exception{
+	  // Step.1 组装查询条件
+	  // Step.1 组装查询条件
+	  String type = kuaishouVideoEtlInfo.getType();
+	  kuaishouVideoEtlInfo.setType(null);
+	  String startDate = kuaishouVideoEtlInfo.getStartDate();
+	  kuaishouVideoEtlInfo.setStartDate(null);
+	  String endDate = kuaishouVideoEtlInfo.getEndDate();
+	  kuaishouVideoEtlInfo.setEndDate(null);
+	  QueryWrapper<KuaishouVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouVideoEtlInfo, request.getParameterMap());
+	  if(null!=type&&!type.equals("")){
+		  if(type.trim().equals("valid")){
+			  //有效
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.gt("effect_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.lt("effect_date",startDate);
+			  }
+			  queryWrapper.lt("effect_day_num",7);
+		  }else if(type.trim().equals("hot")){
+			  //爆款
+			  if(null!=startDate&&!"faddish_date".equals(startDate.trim())){
+				  queryWrapper.gt("",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.lt("faddish_date",startDate);
+			  }
+			  queryWrapper.lt("faddish_day_num",30);
+		  }else {
+			  //上线
+			  if(null!=startDate&&!"".equals(startDate.trim())){
+				  queryWrapper.gt("state_date",startDate);
+			  }
+			  if(null!=endDate&&!"".equals(endDate.trim())){
+				  queryWrapper.lt("state_date",startDate);
+			  }
+		  }
+	  }
+	  queryWrapper.orderByDesc("total_cost");
+	  List<KuaishouVideoEtlInfo> pageList = kuaishouVideoEtlInfoService.list(queryWrapper);
+
+	  //查询总的消耗信息
+	  SheetInfoVo totalSheetVo = new SheetInfoVo<KuaishouVideoEtlInfoEntity>();
+	  List<KuaishouVideoEtlInfoEntity> details = new ArrayList<>();
+	  if(null!=pageList&&!pageList.isEmpty()){
+		  pageList.forEach(etlInfo->{
+			  details.add(new KuaishouVideoEtlInfoEntity(etlInfo));
+		  });
+		  totalSheetVo.setDetails(details);
+	  }
+	  totalSheetVo.setSheetName("头条视频数据统计列表");
+	  OutputStream outputStream = response.getOutputStream();
+	  String date = DateUtils.formatDate(new Date());
+	  HttpUtils.setResponseHeader(response, "头条视频数据统计列表" + date + ".xlsx");
+	  ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
+
+	  Sheet sheet = new Sheet(1, 0, KuaishouVideoEtlInfoEntity.class);
+	  sheet.setSheetName(totalSheetVo.getSheetName());
+	  excelWriter.write(totalSheetVo.getDetails(), sheet);
+	  excelWriter.finish();
+	  outputStream.flush();
+	  outputStream.close();
+  }
+}

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

@@ -0,0 +1,143 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.entity.MaterialImageVideoInfo;
+import cn.com.ctop.common.module.service.IMaterialImageVideoInfoService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+/**
+ * 视频封面关联表信息
+ * @author jeecg-boot
+ * @date   2020-12-17
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="视频封面关联表信息")
+@RestController
+@RequestMapping("/com.cn/materialImageVideoInfo")
+public class MaterialImageVideoInfoController {
+	@Autowired
+	private IMaterialImageVideoInfoService materialImageVideoInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param materialImageVideoInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@GetMapping(value = "/list")
+	public Result<IPage<MaterialImageVideoInfo>> queryPageList(MaterialImageVideoInfo materialImageVideoInfo,
+															   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															   HttpServletRequest req) {
+		Result<IPage<MaterialImageVideoInfo>> result = new Result<>();
+		QueryWrapper<MaterialImageVideoInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialImageVideoInfo, req.getParameterMap());
+		Page<MaterialImageVideoInfo> page = new Page<MaterialImageVideoInfo>(pageNo, pageSize);
+		IPage<MaterialImageVideoInfo> pageList = materialImageVideoInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param materialImageVideoInfo
+	 * @return
+	 */
+	@PostMapping(value = "/add")
+	public Result<MaterialImageVideoInfo> add(@RequestBody MaterialImageVideoInfo materialImageVideoInfo) {
+		Result<MaterialImageVideoInfo> result = new Result<>();
+		try {
+			materialImageVideoInfoService.save(materialImageVideoInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param materialImageVideoInfo
+	 * @return
+	 */
+	@PutMapping(value = "/edit")
+	public Result<MaterialImageVideoInfo> edit(@RequestBody MaterialImageVideoInfo materialImageVideoInfo) {
+		Result<MaterialImageVideoInfo> result = new Result<MaterialImageVideoInfo>();
+		MaterialImageVideoInfo materialImageVideoInfoEntity = materialImageVideoInfoService.getById(materialImageVideoInfo.getId());
+		if(materialImageVideoInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = materialImageVideoInfoService.updateById(materialImageVideoInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			materialImageVideoInfoService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<MaterialImageVideoInfo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<MaterialImageVideoInfo> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.materialImageVideoInfoService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@GetMapping(value = "/queryById")
+	public Result<MaterialImageVideoInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<MaterialImageVideoInfo> result = new Result<>();
+		MaterialImageVideoInfo materialImageVideoInfo = materialImageVideoInfoService.getById(id);
+		if(materialImageVideoInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(materialImageVideoInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

+ 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;
+    }
 
     /**
      * 分页列表查询

+ 257 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/BytedanceVideoEtlInfoEntity.java

@@ -0,0 +1,257 @@
+package org.jeecg.modules.excelutil.entity;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+import java.math.BigDecimal;
+
+public class BytedanceVideoEtlInfoEntity extends BaseRowModel {
+    /**视频唯一标识*/
+    @ExcelProperty(value = "视频唯一标识", index = 1)
+    private String videoCode;
+    /**初次产生消耗时间*/
+    @ExcelProperty(value = "视频上线时间", index = 2)
+    private String stateDate;
+    /**url*/
+    @ExcelProperty(value = "视频链接", index = 3)
+    private String url;
+    /**coverUrl*/
+    @ExcelProperty(value = "封面链接", index = 4)
+    private String coverUrl;
+    /**companyName*/
+    @ExcelProperty(value = "所属公司", index = 5)
+    private String companyName;
+    /**planName*/
+    @ExcelProperty(value = "编导名称", index = 6)
+    private String planName;
+    /**clipName*/
+    @ExcelProperty(value = "剪辑名称", index = 7)
+    private String clipName;
+    /**shotName*/
+    @ExcelProperty(value = "拍摄名称", index = 8)
+    private String shotName;
+    /**singleWeekCost*/
+    @ExcelProperty(value = "上线一周消耗", index = 9)
+    private BigDecimal singleWeekCost;
+    /**twoWeekCost*/
+    @ExcelProperty(value = "上线两周消耗", index = 10)
+    private BigDecimal twoWeekCost;
+    /**fourWeekCost*/
+    @ExcelProperty(value = "上线四周消耗", index = 11)
+    private BigDecimal fourWeekCost;
+    /**总消耗*/
+    @ExcelProperty(value = "总消耗", index = 12)
+    private BigDecimal totalCost;
+    /**clickNum*/
+    @ExcelProperty(value = "封面点击数", index = 13)
+    private Long clickNum;
+    /**showNum*/
+    @ExcelProperty(value = "素材曝光数", index = 14)
+    private Long showNum;
+    /**activeNum*/
+    @ExcelProperty(value = "有效数", index = 15)
+    private Long activeNum;
+    /**convertNum*/
+    @ExcelProperty(value = "转化数", index = 16)
+    private Long convertNum;
+    /**effectDate*/
+    @ExcelProperty(value = "达成有效日期", index = 17)
+    private String effectDate;
+    /**faddishDate*/
+    @ExcelProperty(value = "达成爆款日期", index = 18)
+    private String faddishDate;
+    /**effectDayNum*/
+    @ExcelProperty(value = "达成有效天数", index = 19)
+    private Integer effectDayNum;
+    /**faddishDayNum*/
+    @ExcelProperty(value = "达成爆款天数", index = 20)
+    private Integer faddishDayNum;
+
+    public BytedanceVideoEtlInfoEntity(BytedanceVideoEtlInfo etlInfo) {
+        this.videoCode = etlInfo.getVideoCode();
+        this.stateDate = etlInfo.getStateDate();
+        this.url = etlInfo.getUrl();
+        this.coverUrl = etlInfo.getCoverUrl();
+        this.companyName = etlInfo.getCompanyName();
+        this.planName = etlInfo.getPlanName();
+        this.clipName = etlInfo.getClipName();
+        this.shotName = etlInfo.getShotName();
+        this.singleWeekCost = etlInfo.getSingleWeekCost();
+        this.twoWeekCost = etlInfo.getTwoWeekCost();
+        this.fourWeekCost = etlInfo.getFourWeekCost();
+        this.totalCost = etlInfo.getTotalCost();
+        this.clickNum = etlInfo.getClickNum();
+        this.showNum = etlInfo.getShowNum();
+        this.activeNum = etlInfo.getActiveNum();
+        this.convertNum = etlInfo.getConvertNum();
+        this.effectDate = etlInfo.getEffectDate();
+        this.faddishDate = etlInfo.getFaddishDate();
+        this.effectDayNum = etlInfo.getEffectDayNum();
+        this.faddishDayNum = etlInfo.getFaddishDayNum();
+    }
+
+    public BytedanceVideoEtlInfoEntity() {
+
+    }
+
+    public String getVideoCode() {
+        return videoCode;
+    }
+
+    public void setVideoCode(String videoCode) {
+        this.videoCode = videoCode;
+    }
+
+    public String getStateDate() {
+        return stateDate;
+    }
+
+    public void setStateDate(String stateDate) {
+        this.stateDate = stateDate;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getCoverUrl() {
+        return coverUrl;
+    }
+
+    public void setCoverUrl(String coverUrl) {
+        this.coverUrl = coverUrl;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getPlanName() {
+        return planName;
+    }
+
+    public void setPlanName(String planName) {
+        this.planName = planName;
+    }
+
+    public String getClipName() {
+        return clipName;
+    }
+
+    public void setClipName(String clipName) {
+        this.clipName = clipName;
+    }
+
+    public String getShotName() {
+        return shotName;
+    }
+
+    public void setShotName(String shotName) {
+        this.shotName = shotName;
+    }
+
+    public BigDecimal getSingleWeekCost() {
+        return singleWeekCost;
+    }
+
+    public void setSingleWeekCost(BigDecimal singleWeekCost) {
+        this.singleWeekCost = singleWeekCost;
+    }
+
+    public BigDecimal getTwoWeekCost() {
+        return twoWeekCost;
+    }
+
+    public void setTwoWeekCost(BigDecimal twoWeekCost) {
+        this.twoWeekCost = twoWeekCost;
+    }
+
+    public BigDecimal getFourWeekCost() {
+        return fourWeekCost;
+    }
+
+    public void setFourWeekCost(BigDecimal fourWeekCost) {
+        this.fourWeekCost = fourWeekCost;
+    }
+
+    public BigDecimal getTotalCost() {
+        return totalCost;
+    }
+
+    public void setTotalCost(BigDecimal totalCost) {
+        this.totalCost = totalCost;
+    }
+
+    public Long getClickNum() {
+        return clickNum;
+    }
+
+    public void setClickNum(Long clickNum) {
+        this.clickNum = clickNum;
+    }
+
+    public Long getShowNum() {
+        return showNum;
+    }
+
+    public void setShowNum(Long showNum) {
+        this.showNum = showNum;
+    }
+
+    public Long getActiveNum() {
+        return activeNum;
+    }
+
+    public void setActiveNum(Long activeNum) {
+        this.activeNum = activeNum;
+    }
+
+    public Long getConvertNum() {
+        return convertNum;
+    }
+
+    public void setConvertNum(Long convertNum) {
+        this.convertNum = convertNum;
+    }
+
+    public String getEffectDate() {
+        return effectDate;
+    }
+
+    public void setEffectDate(String effectDate) {
+        this.effectDate = effectDate;
+    }
+
+    public String getFaddishDate() {
+        return faddishDate;
+    }
+
+    public void setFaddishDate(String faddishDate) {
+        this.faddishDate = faddishDate;
+    }
+
+    public Integer getEffectDayNum() {
+        return effectDayNum;
+    }
+
+    public void setEffectDayNum(Integer effectDayNum) {
+        this.effectDayNum = effectDayNum;
+    }
+
+    public Integer getFaddishDayNum() {
+        return faddishDayNum;
+    }
+
+    public void setFaddishDayNum(Integer faddishDayNum) {
+        this.faddishDayNum = faddishDayNum;
+    }
+}

+ 292 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/KuaishouVideoEtlInfoEntity.java

@@ -0,0 +1,292 @@
+package org.jeecg.modules.excelutil.entity;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+import java.math.BigDecimal;
+
+public class KuaishouVideoEtlInfoEntity extends BaseRowModel {
+    /**
+     * 视频唯一标识
+     */
+    @ExcelProperty(value = "视频唯一标识", index = 1)
+    private String videoCode;
+    /**
+     * 初次产生消耗时间
+     */
+    @ExcelProperty(value = "视频上线时间", index = 2)
+    private String stateDate;
+    /**
+     * url
+     */
+    @ExcelProperty(value = "视频链接", index = 3)
+    private String url;
+    /**
+     * coverUrl
+     */
+    @ExcelProperty(value = "封面链接", index = 4)
+    private String coverUrl;
+    /**
+     * companyName
+     */
+    @ExcelProperty(value = "所属公司", index = 5)
+    private String companyName;
+    /**
+     * planName
+     */
+    @ExcelProperty(value = "编导名称", index = 5)
+    private String planName;
+    /**
+     * clipName
+     */
+    @ExcelProperty(value = "剪辑名称", index = 7)
+    private String clipName;
+    /**
+     * shotName
+     */
+    @ExcelProperty(value = "拍摄名称", index = 8)
+    private String shotName;
+    /**
+     * singleWeekCost
+     */
+    @ExcelProperty(value = "上线一周消耗", index = 9)
+    private BigDecimal singleWeekCost;
+    /**
+     * twoWeekCost
+     */
+    @ExcelProperty(value = "上线两周消耗", index = 10)
+    private BigDecimal twoWeekCost;
+    /**
+     * fourWeekCost
+     */
+    @ExcelProperty(value = "上线四周消耗", index = 11)
+    private BigDecimal fourWeekCost;
+    /**
+     * 总消耗
+     */
+    @ExcelProperty(value = "总消耗", index = 12)
+    private BigDecimal totalCost;
+    /**
+     * clickNum
+     */
+    @ExcelProperty(value = "封面曝光数", index = 13)
+    private Long photoShow;
+    @ExcelProperty(value = "封面点击数", index = 14)
+    private Long photoClick;
+    @ExcelProperty(value = "素材曝光数", index = 15)
+    private Long aclick;
+    /**
+     * convertNum
+     */
+    @ExcelProperty(value = "行为数", index = 16)
+    private Long bclick;
+    /**
+     * effectDate
+     */
+    @ExcelProperty(value = "达成有效日期", index = 17)
+    private String effectDate;
+    /**
+     * faddishDate
+     */
+    @ExcelProperty(value = "达成爆款日期", index = 18)
+    private String faddishDate;
+    /**
+     * effectDayNum
+     */
+    @ExcelProperty(value = "达成有效天数", index = 19)
+    private Integer effectDayNum;
+    /**
+     * faddishDayNum
+     */
+    @ExcelProperty(value = "达成爆款天数", index = 20)
+    private Integer faddishDayNum;
+
+    public KuaishouVideoEtlInfoEntity(KuaishouVideoEtlInfo etlInfo) {
+        this.videoCode = etlInfo.getVideoCode();
+        this.stateDate = etlInfo.getStateDate();
+        this.url = etlInfo.getUrl();
+        this.coverUrl = etlInfo.getCoverUrl();
+        this.companyName = etlInfo.getCompanyName();
+        this.planName = etlInfo.getPlanName();
+        this.clipName = etlInfo.getClipName();
+        this.shotName = etlInfo.getShotName();
+        this.singleWeekCost = etlInfo.getSingleWeekCost();
+        this.twoWeekCost = etlInfo.getTwoWeekCost();
+        this.fourWeekCost = etlInfo.getFourWeekCost();
+        this.totalCost = etlInfo.getTotalCost();
+        this.photoClick = etlInfo.getPhotoClick();
+        this.photoShow = etlInfo.getPhotoShow();
+        this.aclick = etlInfo.getAclick();
+        this.bclick = etlInfo.getBclick();
+        this.effectDate = etlInfo.getEffectDate();
+        this.faddishDate = etlInfo.getFaddishDate();
+        this.effectDayNum = etlInfo.getEffectDayNum();
+        this.faddishDayNum = etlInfo.getFaddishDayNum();
+    }
+
+    public KuaishouVideoEtlInfoEntity() {
+
+    }
+
+    public String getVideoCode() {
+        return videoCode;
+    }
+
+    public void setVideoCode(String videoCode) {
+        this.videoCode = videoCode;
+    }
+
+    public String getStateDate() {
+        return stateDate;
+    }
+
+    public void setStateDate(String stateDate) {
+        this.stateDate = stateDate;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getCoverUrl() {
+        return coverUrl;
+    }
+
+    public void setCoverUrl(String coverUrl) {
+        this.coverUrl = coverUrl;
+    }
+
+    public String getCompanyName() {
+        return companyName;
+    }
+
+    public void setCompanyName(String companyName) {
+        this.companyName = companyName;
+    }
+
+    public String getPlanName() {
+        return planName;
+    }
+
+    public void setPlanName(String planName) {
+        this.planName = planName;
+    }
+
+    public String getClipName() {
+        return clipName;
+    }
+
+    public void setClipName(String clipName) {
+        this.clipName = clipName;
+    }
+
+    public String getShotName() {
+        return shotName;
+    }
+
+    public void setShotName(String shotName) {
+        this.shotName = shotName;
+    }
+
+    public BigDecimal getSingleWeekCost() {
+        return singleWeekCost;
+    }
+
+    public void setSingleWeekCost(BigDecimal singleWeekCost) {
+        this.singleWeekCost = singleWeekCost;
+    }
+
+    public BigDecimal getTwoWeekCost() {
+        return twoWeekCost;
+    }
+
+    public void setTwoWeekCost(BigDecimal twoWeekCost) {
+        this.twoWeekCost = twoWeekCost;
+    }
+
+    public BigDecimal getFourWeekCost() {
+        return fourWeekCost;
+    }
+
+    public void setFourWeekCost(BigDecimal fourWeekCost) {
+        this.fourWeekCost = fourWeekCost;
+    }
+
+    public BigDecimal getTotalCost() {
+        return totalCost;
+    }
+
+    public void setTotalCost(BigDecimal totalCost) {
+        this.totalCost = totalCost;
+    }
+
+    public Long getPhotoShow() {
+        return photoShow;
+    }
+
+    public void setPhotoShow(Long photoShow) {
+        this.photoShow = photoShow;
+    }
+
+    public Long getPhotoClick() {
+        return photoClick;
+    }
+
+    public void setPhotoClick(Long photoClick) {
+        this.photoClick = photoClick;
+    }
+
+    public Long getAclick() {
+        return aclick;
+    }
+
+    public void setAclick(Long aclick) {
+        this.aclick = aclick;
+    }
+
+    public Long getBclick() {
+        return bclick;
+    }
+
+    public void setBclick(Long bclick) {
+        this.bclick = bclick;
+    }
+
+    public String getEffectDate() {
+        return effectDate;
+    }
+
+    public void setEffectDate(String effectDate) {
+        this.effectDate = effectDate;
+    }
+
+    public String getFaddishDate() {
+        return faddishDate;
+    }
+
+    public void setFaddishDate(String faddishDate) {
+        this.faddishDate = faddishDate;
+    }
+
+    public Integer getEffectDayNum() {
+        return effectDayNum;
+    }
+
+    public void setEffectDayNum(Integer effectDayNum) {
+        this.effectDayNum = effectDayNum;
+    }
+
+    public Integer getFaddishDayNum() {
+        return faddishDayNum;
+    }
+
+    public void setFaddishDayNum(Integer faddishDayNum) {
+        this.faddishDayNum = faddishDayNum;
+    }
+}

+ 22 - 5
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;
@@ -389,11 +396,12 @@ public class SampleTest {
     private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
     @Test
     public void etlKuaishouData(){
-        String dateString = "2020-01-01";
+        String dateString = "2020-08-29";
         Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
-        for(int i=0;i<=365;i++){
+        for(int i=0;i<=185;i++){
             Date getDate = DateUtils.addDay(startDate,i);
             kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
+//            bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
         }
     }
 
@@ -401,12 +409,12 @@ public class SampleTest {
     private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
     @Test
     public void etlBytedanceData(){
-        String dateString = "2020-01-01";
+        String dateString = "2020-07-01";
         Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
-        for(int i=0;i<=365;i++){
+        for(int i=0;i<=310;i++){
             Date getDate = DateUtils.addDay(startDate,i);
             bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
-            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
+//            kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
         }
     }
 
@@ -417,4 +425,13 @@ public class SampleTest {
             reportService.getAdvertiserReport(token,DateUtils.addDay(new Date(),-i),DateUtils.addDay(new Date(),-i),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         }
     }
+
+    @Test
+    public void loadKuaishouVideo(){
+        String endDate = DateUtils.getNowDate("yyyy-MM-dd");
+        CtopOauthToken token = tokenService.getTokenByAccountId(9718688L);
+//        kuaishouInterfaceService.getVideoList(token, endDate, endDate);
+        kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
+    }
+
 }

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

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

+ 41 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialImageVideoInfo.java

@@ -0,0 +1,41 @@
+package cn.com.ctop.common.module.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;
+
+/**
+ * 视频封面关联表信息
+ * @author jeecg-boot
+ * @date   2020-12-17
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_material_image_video_info")
+public class MaterialImageVideoInfo {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private java.lang.Long id;
+	/**视频md5码*/
+	@Excel(name = "视频md5码", width = 15)
+	private java.lang.String videoCode;
+	/**封面md5码*/
+	@Excel(name = "封面md5码", width = 15)
+	private java.lang.String coverCode;
+	/**createTime*/
+	private java.util.Date createTime;
+	/**updateTime*/
+	private java.util.Date updateTime;
+}

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

+ 14 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialImageVideoInfoMapper.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.MaterialImageVideoInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 视频封面关联表信息
+ * @author: jeecg-boot
+ * @date:   2020-12-17
+ * @cersion: V1.0
+ */
+public interface MaterialImageVideoInfoMapper extends BaseMapper<MaterialImageVideoInfo> {
+
+}

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

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialImageVideoInfoMapper.xml

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

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

+ 14 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialImageVideoInfoService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.MaterialImageVideoInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 视频封面关联表信息
+ * @Author: jeecg-boot
+ * @Date:   2020-12-17
+ * @Version: V1.0
+ */
+public interface IMaterialImageVideoInfoService extends IService<MaterialImageVideoInfo> {
+
+}

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java

@@ -81,4 +81,6 @@ public interface IMessageTemplate {
      * @return
      */
     String getKuaiShouBidMessage(String projectName, Long advertiserId, Long unitId, String unit_name);
+
+    String getCopyCampaignMessage(String oldName, String state);
 }

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

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialImageVideoInfoServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.MaterialImageVideoInfo;
+import cn.com.ctop.common.module.mapper.MaterialImageVideoInfoMapper;
+import cn.com.ctop.common.module.service.IMaterialImageVideoInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 视频封面关联表信息
+ * @author jeecg-boot
+ * @date   2020-12-17
+ * @version V1.0
+ */
+@Service
+public class MaterialImageVideoInfoServiceImpl extends ServiceImpl<MaterialImageVideoInfoMapper, MaterialImageVideoInfo> implements IMaterialImageVideoInfoService {
+
+}

+ 16 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java

@@ -5,9 +5,6 @@ import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.stereotype.Service;
 
-import java.util.Arrays;
-import java.util.List;
-
 @Service
 public class MessageTemplateImpl implements IMessageTemplate {
 
@@ -195,4 +192,20 @@ public class MessageTemplateImpl implements IMessageTemplate {
         return text.toString();
     }
 
+    @Override
+    public String getCopyCampaignMessage(String oldName, String state) {
+        StringBuilder text = new StringBuilder();
+        if ("2".equals(state)) {
+            text.append("广告计划复制成功通知").append("<br/>")
+                    .append("您复制的广告计划:").append(oldName).append("<br/>")
+                    .append("现已复制完成,请知悉");
+        } else {
+            text.append("广告计划复制失败预警").append("<br/>")
+                    .append("您复制的广告计划:").append(oldName).append("<br/>")
+                    .append("复制失败,请您联系管理员或重新执行复制操作!").append("<br/>");
+        }
+        return text.toString();
+    }
+
+
 }

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

+ 25 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCampaignCopyDateJob.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouCampaignCopyDataService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 定时复制广告计划下的组+创意
+ *
+ * @param
+ * @author ZHAOXA
+ * @return
+ * @throws
+ */
+@Component
+public class KuaishouCampaignCopyDateJob {
+    @Autowired
+    private IKuaishouCampaignCopyDataService kuaishouCampaignCopyDataService;
+
+    @XxlJob("kuaishouCampaignCopyDateJob")
+    public void execute() throws Exception {
+        kuaishouCampaignCopyDataService.batchCopyCampaign();
+    }
+}

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

@@ -14,7 +14,7 @@ public class KuaishouEffectVideoJob {
     @Autowired
     private IKuaishouVideoEtlInfoService etlInfoService;
 
-    @XxlJob("kuaishouGroupDailyReportJob")
+    @XxlJob("kuaishouEffectVideoJob")
     public void execute() throws ParseException {
         Date getDate = DateUtils.addDay(new Date(),-1);
         etlInfoService.etlKuaishouVideoInfo(getDate);

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

@@ -0,0 +1,267 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouCampaignCopyData;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouCampaignCopyDataService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+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.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 待复制广告计划数据
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-22
+ */
+@Slf4j
+@Api(tags = "待复制广告计划数据")
+@RestController
+@RequestMapping("/kuaishouCampaignCopyData")
+public class KuaishouCampaignCopyDataController {
+    @Autowired
+    private IKuaishouCampaignCopyDataService kuaishouCampaignCopyDataService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouCampaignCopyData
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-分页列表查询")
+    @ApiOperation(value = "待复制广告计划数据-分页列表查询", notes = "待复制广告计划数据-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouCampaignCopyData>> queryPageList(KuaishouCampaignCopyData kuaishouCampaignCopyData,
+                                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                 HttpServletRequest req) {
+        Result<IPage<KuaishouCampaignCopyData>> result = new Result<>();
+        QueryWrapper<KuaishouCampaignCopyData> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCampaignCopyData, req.getParameterMap());
+        Page<KuaishouCampaignCopyData> page = new Page<KuaishouCampaignCopyData>(pageNo, pageSize);
+        IPage<KuaishouCampaignCopyData> pageList = kuaishouCampaignCopyDataService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouCampaignCopyData
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-添加")
+    @ApiOperation(value = "待复制广告计划数据-添加", notes = "待复制广告计划数据-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouCampaignCopyData> add(@RequestBody JSONObject data) {
+        Result<KuaishouCampaignCopyData> result = new Result<>();
+        try {
+            KuaishouCampaignCopyData kuaishouCampaignCopyData = JSONObject.toJavaObject(data, KuaishouCampaignCopyData.class);
+            if (Check.isNull(kuaishouCampaignCopyData.getCreaterId())) {
+                LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+                if (!Check.isNull(sysUser)) {
+                    kuaishouCampaignCopyData.setCreaterId(sysUser.getId());
+                }
+            }
+            kuaishouCampaignCopyDataService.save(kuaishouCampaignCopyData);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouCampaignCopyData
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-编辑")
+    @ApiOperation(value = "待复制广告计划数据-编辑", notes = "待复制广告计划数据-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouCampaignCopyData> edit(@RequestBody KuaishouCampaignCopyData kuaishouCampaignCopyData) {
+        Result<KuaishouCampaignCopyData> result = new Result<KuaishouCampaignCopyData>();
+        KuaishouCampaignCopyData kuaishouCampaignCopyDataEntity = kuaishouCampaignCopyDataService.getById(kuaishouCampaignCopyData.getId());
+        if (kuaishouCampaignCopyDataEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouCampaignCopyDataService.updateById(kuaishouCampaignCopyData);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-通过id删除")
+    @ApiOperation(value = "待复制广告计划数据-通过id删除", notes = "待复制广告计划数据-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouCampaignCopyDataService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-批量删除")
+    @ApiOperation(value = "待复制广告计划数据-批量删除", notes = "待复制广告计划数据-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouCampaignCopyData> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouCampaignCopyData> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouCampaignCopyDataService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "待复制广告计划数据-通过id查询")
+    @ApiOperation(value = "待复制广告计划数据-通过id查询", notes = "待复制广告计划数据-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouCampaignCopyData> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouCampaignCopyData> result = new Result<>();
+        KuaishouCampaignCopyData kuaishouCampaignCopyData = kuaishouCampaignCopyDataService.getById(id);
+        if (kuaishouCampaignCopyData == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouCampaignCopyData);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouCampaignCopyData> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouCampaignCopyData kuaishouCampaignCopyData = JSON.parseObject(deString, KuaishouCampaignCopyData.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouCampaignCopyData, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouCampaignCopyData> pageList = kuaishouCampaignCopyDataService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "待复制广告计划数据列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouCampaignCopyData.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("待复制广告计划数据列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouCampaignCopyData> listKuaishouCampaignCopyDatas = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouCampaignCopyData.class, params);
+                kuaishouCampaignCopyDataService.saveBatch(listKuaishouCampaignCopyDatas);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouCampaignCopyDatas.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

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

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

@@ -187,4 +187,8 @@ public class KuaiShouGroup {
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "修改时间")
     private Date updateTime;
+
+    @TableField(exist = false)
+    private KuaiShouGroupTarget target;
+
 }

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

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

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

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

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

@@ -0,0 +1,159 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 待复制广告计划数据
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-22
+ */
+@Data
+@TableName("ctop_kuaishou_campaign_copy_data")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_campaign_copy_data对象", description = "待复制广告计划数据")
+public class KuaishouCampaignCopyData {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 被复制的计划ID
+     */
+    @Excel(name = "被复制的计划ID", width = 15)
+    @ApiModelProperty(value = "被复制的计划ID")
+    private Long oldCampaignId;
+
+    /**
+     * 被复制的计划名称
+     */
+    private String oldCampaignName;
+
+    /**
+     * 创建者ID
+     */
+    private String createrId;
+    /**
+     * 新计划ID
+     */
+    @Excel(name = "新计划ID", width = 15)
+    @ApiModelProperty(value = "新计划ID")
+    private Long newCampaignId;
+    /**
+     * 投放方式  0:未知, 1:正常投
+     */
+    @Excel(name = "投放方式  0:未知, 1:正常投", width = 15)
+    @ApiModelProperty(value = "投放方式  0:未知, 1:正常投")
+    private Integer speed;
+    /**
+     * '状态:1待复制,2成功,3失败'
+     */
+    private String state;
+    /**
+     * 状态详情
+     */
+    private String stateDetail;
+    /**
+     * 单日预算
+     */
+    @Excel(name = "单日预算", width = 15)
+    @ApiModelProperty(value = "单日预算")
+    private Long dayBudget;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "定向模板id", width = 15)
+    @ApiModelProperty(value = "定向模板id")
+    private String templateId;
+    /**
+     * 投放开始时间
+     */
+    @Excel(name = "投放开始时间", width = 15)
+    @ApiModelProperty(value = "投放开始时间")
+    private String beginTime;
+    /**
+     * 投放结束时间
+     */
+    @Excel(name = "投放结束时间", width = 15)
+    @ApiModelProperty(value = "投放结束时间")
+    private String endTime;
+    /**
+     * 投放时段
+     */
+    @Excel(name = "投放时段", width = 15)
+    @ApiModelProperty(value = "投放时段")
+    private Object scheduleTime;
+    /**
+     * 出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)
+     */
+    @Excel(name = "出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)", width = 15)
+    @ApiModelProperty(value = "出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)")
+    private Integer bidType;
+    /**
+     * 封面点击出价
+     */
+    @Excel(name = "封面点击出价", width = 15)
+    @ApiModelProperty(value = "封面点击出价")
+    private Long bid;
+    /**
+     * 转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。
+     */
+    @Excel(name = "转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。", width = 15)
+    @ApiModelProperty(value = "转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。")
+    private Integer ocpxActionType;
+    /**
+     * 转化目标出价
+     */
+    @Excel(name = "转化目标出价", width = 15)
+    @ApiModelProperty(value = "转化目标出价")
+    private Long cpaBid;
+    /**
+     * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
+     */
+    @Excel(name = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无", width = 15)
+    @ApiModelProperty(value = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无")
+    private Integer deepConversionType;
+    /**
+     * 深度转化目标出价
+     */
+    @Excel(name = "深度转化目标出价", width = 15)
+    @ApiModelProperty(value = "深度转化目标出价")
+    private Long deepConversionBid;
+    /**
+     * 广告位 1:优选广告位;
+     */
+    @Excel(name = "广告位 1:优选广告位;", width = 15)
+    @ApiModelProperty(value = "广告位 1:优选广告位;")
+    private String sceneId;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

+ 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*/

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

@@ -22,4 +22,8 @@ public interface KuaiShouCreativeMapper extends BaseMapper<KuaiShouCreative> {
     Integer getCreateCount(Long accountId, String startTime);
 
     List<JSONObject> checkZombieProject(String date);
+
+    void delAllCreativesByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
+
+    List<KuaiShouCreative> queryCreativeInfoByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
 }

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

@@ -24,4 +24,8 @@ public interface KuaiShouGroupMapper extends BaseMapper<KuaiShouGroup> {
     List<KuaiShouGroup> queryByMap(Map<String, Object> map);
 
     List<KuaiShouGroup> queryUnitInfoByAccountId(Long accountId);
+
+    void delAllGroupByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
+
+    List<KuaiShouGroup> queryUnitInfoByCampaignId(@Param("accountId") Long accountId, @Param("campaignId") Long campaignId);
 }

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

@@ -16,4 +16,8 @@ import java.util.List;
 public interface KuaiShouGroupTargetMapper extends BaseMapper<KuaiShouGroupTarget> {
 
     void replaceBatch(@Param("targets") List<KuaiShouGroupTarget> targets);
+
+    void deleteByUnitIds(@Param("unitIds") List<Long> unitIds);
+
+    KuaiShouGroupTarget queryTargetInfoByunitId(@Param("accountId") Long accountId, @Param("unitId") Long unitId);
 }

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

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

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/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);
+
+
 }

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouCampaignCopyData;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 待复制广告计划数据
+ *
+ * @author: jeecg-boot
+ * @date: 2020-12-22
+ * @cersion: V1.0
+ */
+public interface KuaishouCampaignCopyDataMapper extends BaseMapper<KuaishouCampaignCopyData> {
+
+}

+ 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

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

@@ -127,4 +127,18 @@
         AND t1. STATUS = 42
         and t1.put_status = 1
     </select>
+
+    <delete id="delAllCreativesByCampaignId" parameterType="java.lang.Long">
+        delete from ctop_kuaishou_creative WHERE account_id = #{accountId}
+        AND campaign_id = #{campaignId}
+    </delete>
+
+    <select id="queryCreativeInfoByCampaignId" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative">
+        SELECT
+        *
+        FROM ctop_kuaishou_creative
+        WHERE account_id = #{accountId}
+         AND campaign_id = #{campaignId}
+    </select>
+
 </mapper>

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

@@ -118,4 +118,17 @@
         WHERE account_id = #{accountId}
     </select>
 
+    <select id="queryUnitInfoByCampaignId" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup">
+        SELECT
+        *
+        FROM ctop_kuaishou_group
+        WHERE account_id = #{accountId}
+         AND campaign_id = #{campaignId}
+    </select>
+
+    <delete id="delAllGroupByCampaignId" parameterType="java.lang.Long">
+       delete from ctop_kuaishou_group WHERE account_id = #{accountId}
+        AND campaign_id = #{campaignId}
+    </delete>
+
 </mapper>

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

@@ -67,4 +67,20 @@
         </foreach>
     </insert>
 
+    <delete id="deleteByUnitIds" parameterType="java.lang.Long">
+        delete from ctop_kuaishou_group_target WHERE account_id = #{accountId}
+        AND campaign_id in
+        <foreach item="id" collection="unitIds" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+
+    <select id="queryTargetInfoByunitId" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget">
+        SELECT
+        *
+        FROM ctop_kuaishou_group_target
+        WHERE account_id = #{accountId}
+         AND unit_id = #{unitId}
+    </select>
 </mapper>

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

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

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

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

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

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

@@ -3,7 +3,6 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import com.baomidou.mybatisplus.extension.service.IService;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -37,10 +36,23 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
 
     /**
      * 获取当前创意创建数
+     *
      * @param accountId
      * @param startTime
      * @return
      */
 
     Integer getCreateCount(Long accountId, String startTime);
+
+    /**
+     * 按广告系列ID删除所有广告素材
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void delAllCreativesByCampaignId(Long accountId, Long campaignId);
+
+    List<KuaiShouCreative> queryCreativeInfoByCampaignId(Long accountId, Long campaignId);
 }

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

@@ -1,7 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
-import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -21,4 +20,18 @@ public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
     void getCreativeByUnit(String accessToken, Long accountId, Long unitId);
 
     List<KuaiShouGroup> queryUnitInfoByAccountId(Long accountId);
+
+    /**
+     * 根据计划Id删除全部广告组
+     *
+     * @param
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    void delAllGroupByCampaignId(Long accountId, Long campaignId);
+
+    void getGroupListByPage(String accessToken, Long accountId, Long campaignId, int page);
+
+    List<KuaiShouGroup> queryUnitInfoByCampaignId(Long accountId, Long campaignId);
 }

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

@@ -3,6 +3,8 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTarget;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * 快手-定向信息
  *
@@ -12,4 +14,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaiShouGroupTargetService extends IService<KuaiShouGroupTarget> {
 
+    void deleteByUnitIds(List<Long> unitIds);
+
+    KuaiShouGroupTarget queryTargetInfoByunitId(Long accountId, Long unitId);
 }

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

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

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

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouCampaignCopyData;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 待复制广告计划数据
+ * @Author: jeecg-boot
+ * @Date: 2020-12-22
+ * @Version: V1.0
+ */
+public interface IKuaishouCampaignCopyDataService extends IService<KuaishouCampaignCopyData> {
+
+    void batchCopyCampaign();
+}

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

@@ -1860,39 +1860,29 @@ public class BatchServiceImpl implements IBatchService {
         if (Check.isNull(requestJson)) {
             throw new Exception("入参为空");
         }
-
-
         JSONObject creativeJson = new JSONObject();
         creativeJson.put("advertiser_id", token.getAccountId());
-
         Long creativeId = requestJson.getLong("creativeId");
         if (Check.isNull(creativeId)) {
             throw new Exception("请选择广告创意");
         }
         creativeJson.put("creative_id", creativeId);
-
-
         // 创意名称
         if (!Check.isNull(requestJson.get("creativeName"))) {
             creativeJson.put("creative_name", requestJson.get("creativeName"));
         }
-
         //封面
         if (!Check.isNull(requestJson.get("photoId"))) {
             creativeJson.put("photo_id", requestJson.get("photoId"));
         }
-
         // 视频id
         if (!Check.isNull(requestJson.get("imageToken"))) {
             creativeJson.put("image_token", requestJson.get("imageToken"));
         }
-
         // 行动号召按钮
         if (!Check.isNull(requestJson.get("actionBarText"))) {
             creativeJson.put("action_bar_text", requestJson.get("actionBarText"));
         }
-
-
         // 广告语
         if (!Check.isNull(requestJson.get("description"))) {
             creativeJson.put("description", requestJson.getString("description").trim());
@@ -1901,7 +1891,6 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.get("stickerTitle"))) {
             creativeJson.put("sticker_title", requestJson.get("stickerTitle"));
         }
-
         // 贴纸样式
         if (!Check.isNull(requestJson.get("overlayType"))) {
             creativeJson.put("overlay_type", requestJson.get("overlayType"));
@@ -1910,18 +1899,15 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.get("clickTrackUrl"))) {
             creativeJson.put("click_track_url", requestJson.get("clickTrackUrl"));
         }
-
         // 后贴片 第三方检测链接
         if (!Check.isNull(requestJson.get("adPhotoPlayedT3sUrl"))) {
             creativeJson.put("ad_photo_played_t3s_url", requestJson.get("adPhotoPlayedT3sUrl"));
         }
-
         // 后贴片 第三方检测链接
         if (!Check.isNull(requestJson.get("impressionUrl"))) {
             creativeJson.put("impression_url", requestJson.get("impressionUrl"));
         }
         JSONObject returnJson = updateService.updateCreative(token.getAccessToken(), creativeJson);
-
         return returnJson;
     }
 
@@ -1935,14 +1921,12 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONObject getWhiteList(Long accountId, String accessToken) {
-
         String url = "https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/white_list";
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", accessToken);
         Map<String, Object> param = new HashMap<String, Object>();
         param.put("advertiser_id", accountId);
-
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         log.info("获取联盟白名单,accountId:{},data:{}", accountId, resultJson);
@@ -1951,7 +1935,6 @@ public class BatchServiceImpl implements IBatchService {
             if (code == 0) {
                 return resultJson.getJSONObject("data");
             }
-
         }
         return null;
     }
@@ -1997,7 +1980,6 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONArray getCreativeCategory(Long accountId, String accessToken) {
-
         try {
             String url = "https://ad.e.kuaishou.com/rest/openapi/v1/creative/creative_category/list";
             Map<String, String> headers = new HashMap<String, String>();
@@ -2038,7 +2020,6 @@ public class BatchServiceImpl implements IBatchService {
 
 
     private JSONArray getSecond(String categoryId, JSONArray details) {
-
         JSONArray secondArr = new JSONArray();
         for (int i = 0; i < details.size(); i++) {
             JSONObject secondJson = details.getJSONObject(i);
@@ -2060,7 +2041,6 @@ public class BatchServiceImpl implements IBatchService {
             if (categoryId.equals(parent_id)) {
                 thirdArr.add(thirdJson);
             }
-
         }
         return thirdArr;
     }

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

@@ -17,7 +17,10 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 快手-创意信息
@@ -75,8 +78,6 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
 
     @Override
     public void syncCreative(Long accountId, String accessToken, Long campaignId, Integer page) {
-
-
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", " application/json");
@@ -86,7 +87,7 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
         if (!Check.isNull(campaignId)) {
             param.put("campaign_id", campaignId);
         }
-        param.put("page_size", 200);
+        param.put("page_size", 500);
         param.put("page", page);
 
         String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
@@ -186,4 +187,16 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
     public Integer getCreateCount(Long accountId, String startTime) {
         return kuaiShouCreativeMapper.getCreateCount(accountId, startTime);
     }
+
+    @Override
+    public void delAllCreativesByCampaignId(Long accountId, Long campaignId) {
+        kuaiShouCreativeMapper.delAllCreativesByCampaignId(accountId, campaignId);
+    }
+
+    @Override
+    public List<KuaiShouCreative> queryCreativeInfoByCampaignId(Long accountId, Long campaignId) {
+        return kuaiShouCreativeMapper.queryCreativeInfoByCampaignId(accountId,campaignId);
+    }
+
+
 }

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

@@ -80,8 +80,8 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
 
     }
 
-
-    private void getGroupListByPage(String accessToken, Long accountId, Long campaignId, int page) {
+    @Override
+    public void getGroupListByPage(String accessToken, Long accountId, Long campaignId, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
         JSONObject param = new JSONObject();
         param.put("advertiser_id", accountId);
@@ -112,6 +112,11 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
         getGroupListByPage(accessToken, accountId, campaignId, page + 1);
     }
 
+    @Override
+    public List<KuaiShouGroup> queryUnitInfoByCampaignId(Long accountId, Long campaignId) {
+        return groupMapper.queryUnitInfoByCampaignId(accountId, campaignId);
+    }
+
 
     @Override
     public void getGroupByUnitId(String accessToken, Long accountId, Long unitId) {
@@ -266,6 +271,11 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
         return groupMapper.queryUnitInfoByAccountId(accountId);
     }
 
+    @Override
+    public void delAllGroupByCampaignId(Long accountId, Long campaignId) {
+        groupMapper.delAllGroupByCampaignId(accountId, campaignId);
+    }
+
     static ExecutorService executorBidTypeService = Executors.newFixedThreadPool(20);
     static ExecutorService executorMaxBidService = Executors.newFixedThreadPool(5);
     @Autowired
@@ -278,7 +288,7 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
         String bidTypeStr = json.getString("bidType"); // 出价方式
         JSONArray bidTypeArr = JSONArray.parseArray(bidTypeStr);
         String ocpxActionTypeStr = json.getString("ocpxActionType"); // 优化目标
-        JSONArray bidArr = JSONArray.parseArray(ocpxActionTypeStr);
+        JSONArray ocpxArr = JSONArray.parseArray(ocpxActionTypeStr);
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();
             List<KuaiShouAppInfo> appInfos = new ArrayList<>();
@@ -298,14 +308,6 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                     Integer put_status = detail.getInteger("put_status");
                     if (put_status == 1) { // 组状态为 投放中的
                         if (status != 15) { // 广告组状态为非暂停
-                            Boolean ocpxTrueOrFalse = false;
-                            for (int j = 0; j < bidArr.size(); j++) {
-                                Integer ocpxActionType = (Integer) bidArr.get(j);
-                                if (ocpxActionType.equals(ocpx_action_type)) {
-                                    ocpxTrueOrFalse = true;
-                                    break;
-                                }
-                            }
                             Boolean bidTypeTrueOrFalse = false;
                             for (int j = 0; j < bidTypeArr.size(); j++) {
                                 Integer bidType = (Integer) bidTypeArr.get(j);
@@ -314,6 +316,21 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                                     break;
                                 }
                             }
+
+                            Boolean ocpxTrueOrFalse = false;
+                            if (ocpx_action_type == 0) {
+                                ocpxTrueOrFalse = true;
+                            } else {
+                                for (int j = 0; j < ocpxArr.size(); j++) {
+                                    Integer ocpxActionType = (Integer) ocpxArr.get(j);
+                                    if (ocpxActionType.equals(ocpx_action_type)) {
+                                        ocpxTrueOrFalse = true;
+                                        break;
+                                    }
+                                }
+                            }
+
+
                             if (!bidTypeTrueOrFalse || !ocpxTrueOrFalse) { // 出价方式设置非法
                                 if (day_budget > 500 * 1000 || day_budget == 0) { // 预算大于500 或者不限制预算 需要发送通知 并且进行暂停操作
                                     executorBidTypeService.submit(new Runnable() {
@@ -335,7 +352,6 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                         }
                     }
 
-
                     KuaiShouGroup group = new KuaiShouGroup();
                     group.setId("" + advertiserId + unitId);
                     group.setAccountId(advertiserId);

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


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini