Przeglądaj źródła

Merge branch 'test'

zhaoxian 3 lat temu
rodzic
commit
6b7ab7a080
41 zmienionych plików z 1540 dodań i 704 usunięć
  1. 15 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/Project.java
  2. 9 8
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml
  3. 3 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java
  4. 60 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoDoController.java
  5. 79 8
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoStrategyController.java
  6. 4 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoTargetController.java
  7. 14 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoStrategy.java
  8. 8 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoVideo.java
  9. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoTargetMapper.java
  10. 7 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoVideoMapper.java
  11. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoTargetMapper.xml
  12. 63 30
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoVideoMapper.xml
  13. 7 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoDoService.java
  14. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoTargetService.java
  15. 4 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoVideoService.java
  16. 624 264
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java
  17. 9 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoTargetServiceImpl.java
  18. 12 14
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoVideoServiceImpl.java
  19. 37 33
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  20. 2 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroupTemplate.java
  21. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java
  22. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouAppListMapper.xml
  23. 27 19
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  24. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java
  25. 0 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java
  26. 6 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCampaignServiceImpl.java
  27. 116 76
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  28. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  29. 322 134
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  30. 3 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/WarningOperationServiceImpl.java
  31. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelCreateStrategyMapper.xml
  32. 3 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml
  33. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java
  34. 21 28
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java
  35. 2 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/DocumentLibraryMapper.java
  36. 2 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/xml/DocumentLibraryMapper.xml
  37. 18 12
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/impl/DocumentLibraryServiceImpl.java
  38. 17 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java
  39. 5 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  40. 20 27
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  41. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java

+ 15 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/entity/Project.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.common.module.entity;
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -116,9 +117,15 @@ public class Project {
     private Date updateTime;
 
 
+    //优化目标出价类型
     private String bidType;
+
+    //转化目标
     private String ocpxActionType;
 
+    //深度转化目标
+    private String deepConversionType;
+
     @TableField(exist = false)
     private String responsibleId_dictText; // 运营负责人
 
@@ -135,4 +142,12 @@ public class Project {
     private Integer needExamine;
     @TableField(exist = false)
     private String supplierCode_dictText;
+
+    //转化目标
+    @TableField(exist = false)
+    private JSONArray ocpxActionTypeArray;
+
+    //深度转化目标
+    @TableField(exist = false)
+    private JSONArray deepConversionTypeArray;
 }

+ 9 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml

@@ -16,14 +16,15 @@
     </select>
 
     <select id="getWarningInfoByProjectId" resultType="com.alibaba.fastjson.JSONObject">
-     select
-     id projectId,
-     project_name projectName,
-     max_bid maxBid,
-     bid_type bidType,
-     ocpx_action_type ocpxActionType
-     from ctop_project
-     where id = #{projectId}
+        select
+            id projectId,
+            project_name projectName,
+            max_bid maxBid,
+            bid_type bidType,
+            ocpx_action_type ocpxActionType,
+            deep_conversion_type deepConversionType
+        from ctop_project
+        where id = #{projectId}
     </select>
 
     <select id="querySupplierCodeById" resultType="java.lang.String">

+ 3 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/utils/StatusCode.java

@@ -69,7 +69,9 @@ public enum StatusCode {
     KUAISHOU_CRAWLER_APP_TASK_END("爬虫任务运行结束", 1, true),
     KUAISHOU_CRAWLER_APP_JOB_StART("任务开始执行开始", 0, true),
     KUAISHOU_CRAWLER_APP_JOB_END("任务运行结束", 1, true),
-    MODEL_VIDEO_NOT_EXIST("模板视频不存在或者已经被删除", 0, false);
+    MODEL_VIDEO_NOT_EXIST("模板视频不存在或者已经被删除", 0, false),
+
+    KUAISHOU_AUTO_STRATEGY_UPDATE("修改失败,该账户新版自动投放策略已运行", 500, false);
     private String desc;
     private int code;
     private boolean flag;

+ 60 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoDoController.java

@@ -28,7 +28,65 @@ public class AiKuaishouAccountAutoDoController {
     static ExecutorService programService = Executors.newFixedThreadPool(8);
 
     /**
-     * 创建自定义广告创意
+     * 创建自定义上新广告创意 、频率 20分钟/次
+     */
+    @GetMapping(value = "/createCustomUpNewCreative")
+    public JSONObject createCustomUpNewCreative(String id) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("主键id不能为空");
+            }
+            AiKuaishouAccountAutoStrategy strategy = strategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Boolean unitOverrun = autoDoService.getUnitOverrun(strategy.getAccountId());
+            if (unitOverrun) {
+                log.error("****** 广告组创建超限,accountId:{}", strategy.getAccountId());
+                throw new Exception("今日广告组创建已超限");
+            }
+            customService.submit(() -> autoDoService.createCustomUpNewCreative(strategy));
+            returnJson.put("code", 0);
+            returnJson.put("message", "异步创建中");
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 每日补充创建创意 、频率 每天22点05分钟执行1次
+     */
+    @GetMapping(value = "/supplementTodayCreatives")
+    public JSONObject supplementTodayCreatives(String id) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(id)) {
+                throw new Exception("主键id不能为空");
+            }
+            AiKuaishouAccountAutoStrategy strategy = strategyService.getById(id);
+            if (Check.isNull(strategy)) {
+                throw new Exception("根据id获取详细信息为空");
+            }
+            Boolean unitOverrun = autoDoService.getUnitOverrun(strategy.getAccountId());
+            if (unitOverrun) {
+                log.error("****** 广告组创建超限,accountId:{}", strategy.getAccountId());
+                throw new Exception("今日广告组创建已超限");
+            }
+            customService.submit(() -> autoDoService.supplementTodayCreatives(strategy));
+            returnJson.put("code", 0);
+            returnJson.put("message", "异步创建中");
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+    /**
+     * 创建自定义非上新广告创意 、频率 60分钟/次
      */
     @GetMapping(value = "/createCustomCreative")
     public JSONObject createCustomCreative(String id) {
@@ -58,7 +116,7 @@ public class AiKuaishouAccountAutoDoController {
     }
 
     /**
-     * 创建程序化广告创意
+     * 创建程序化广告创意 频率 60分钟/次
      */
     @GetMapping(value = "/createProgramCreative")
     public JSONObject createProgramCreative(String id) {

+ 79 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoStrategyController.java

@@ -20,6 +20,8 @@ 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.RedisUtil;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -31,7 +33,6 @@ 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;
@@ -48,6 +49,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -81,6 +83,9 @@ public class AiKuaishouAccountAutoStrategyController {
     @Autowired
     private IAiKuaishouAdvertiserStrategyService aiKuaishouAdvertiserStrategyService;
 
+    @Autowired
+    private RedisUtil redisUtil;
+
     /**
      * 分页列表查询
      *
@@ -96,7 +101,7 @@ public class AiKuaishouAccountAutoStrategyController {
                                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                          HttpServletRequest req) {
         Result<PageInfo<AiKuaishouAccountAutoStrategy>> result = new Result<>();
-        if(Check.isNull(aiKuaishouAccountAutoStrategy.getUserId())){
+        if (Check.isNull(aiKuaishouAccountAutoStrategy.getUserId())) {
             result.setSuccess(false);
             result.setMessage("请选择用户");
             return result;
@@ -109,6 +114,7 @@ public class AiKuaishouAccountAutoStrategyController {
         PageInfo<AiKuaishouAccountAutoStrategy> pageInfo = aiKuaishouAccountAutoStrategyService.queryList(aiKuaishouAccountAutoStrategy);
         List<AiKuaishouAccountAutoStrategy> list = pageInfo.getList();
         List<AiKuaishouAccountAutoStrategy> setData = new ArrayList<>();
+        String date = DateUtils.formatDate(new Date());
         if (null != list && !list.isEmpty()) {
             list.forEach(record -> {
                 Long accountId = record.getAccountId();
@@ -116,6 +122,14 @@ public class AiKuaishouAccountAutoStrategyController {
                 if (null != allocation) {
                     record.setAuthName(allocation.getAuthName());
                 }
+                String customkey = date + "_auto_custom_cnt_" + accountId;
+                Integer customUnitCnt = (Integer) redisUtil.get(customkey);
+                customUnitCnt = Check.isNull(customUnitCnt) ? 0 : customUnitCnt;
+                record.setCustomCreatedUnitCnt(customUnitCnt);
+                String programkey = date + "_auto_program_cnt_" + accountId;
+                Integer programUnitCnt = (Integer) redisUtil.get(programkey);
+                programUnitCnt = Check.isNull(programUnitCnt) ? 0 : programUnitCnt;
+                record.setProgramCreatedUnitCnt(programUnitCnt);
             });
         }
         pageInfo.setList(list);
@@ -135,16 +149,18 @@ public class AiKuaishouAccountAutoStrategyController {
         }
         if (type == 1) {
             AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(accountId);
-            if (null != getEntity) {
-                return Result.error("该账户旧版自动投放配置信息已存在,请删除后再创建");
+            if (null != getEntity && getEntity.getStatus() == 1) {
+                return Result.error("该账户旧版自动投放策略已启动,请关闭后再创建");
             }
+
         } else {
             QueryWrapper<AiKuaishouAccountAutoStrategy> queryWrapper = new QueryWrapper();
             queryWrapper.eq("account_id", accountId).last("limit 1");
             AiKuaishouAccountAutoStrategy one = aiKuaishouAccountAutoStrategyService.getOne(queryWrapper);
-            if (null != one) {
-                return Result.error("该账户重构版自动投放配置信息已存在,请删除后再创建");
+            if (null != one && one.getStatus() == 1) {
+                return Result.error("该账户重构版自动投放策略已启动,请关闭后再创建");
             }
+
         }
         return Result.ok("success");
     }
@@ -205,7 +221,7 @@ public class AiKuaishouAccountAutoStrategyController {
      * @return
      */
     @ApiOperation(value = "自动投放重构-账户策略表-编辑", notes = "自动投放重构-账户策略表-编辑")
-    @PutMapping(value = "/edit")
+    @PostMapping(value = "/edit")
     public Result<AiKuaishouAccountAutoStrategy> edit(@RequestBody AiKuaishouAccountAutoStrategy aiKuaishouAccountAutoStrategy) {
         Result<AiKuaishouAccountAutoStrategy> result = new Result<AiKuaishouAccountAutoStrategy>();
         AiKuaishouAccountAutoStrategy aiKuaishouAccountAutoStrategyEntity = aiKuaishouAccountAutoStrategyService.getById(aiKuaishouAccountAutoStrategy.getId());
@@ -213,7 +229,7 @@ public class AiKuaishouAccountAutoStrategyController {
             result.error500("未找到对应实体");
         } else {
             Integer singleAppId = aiKuaishouAccountAutoStrategy.getSingleAppid();
-            if (aiKuaishouAccountAutoStrategy.getCampaignType() == 2 || aiKuaishouAccountAutoStrategy.getCampaignType() == 7) {
+            if (aiKuaishouAccountAutoStrategyEntity.getCampaignType() == 2 || aiKuaishouAccountAutoStrategyEntity.getCampaignType() == 7) {
                 if (null != singleAppId && singleAppId == 1) {
                     Long appId = Long.valueOf(JSONArray.parseArray(aiKuaishouAccountAutoStrategy.getAppIdArray()).getString(0));
                     aiKuaishouAccountAutoStrategy.setAppId(appId);
@@ -230,6 +246,61 @@ public class AiKuaishouAccountAutoStrategyController {
     }
 
     /**
+     * 编辑
+     *
+     * @param aiKuaishouAccountAutoStrategy
+     * @return
+     */
+    @PostMapping(value = "/updateAppUrl")
+    public Result<AiKuaishouAccountAutoStrategy> updateAppUrl(@RequestBody AiKuaishouAccountAutoStrategy strategy) {
+        Result<AiKuaishouAccountAutoStrategy> result = new Result<AiKuaishouAccountAutoStrategy>();
+        if (Check.isNull(strategy.getAccountId())) {
+            result.error500("缺少账户数据");
+            return result;
+        }
+        QueryWrapper<AiKuaishouAccountAutoStrategy> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", strategy.getAccountId()).last("limit 1");
+        AiKuaishouAccountAutoStrategy one = aiKuaishouAccountAutoStrategyService.getOne(queryWrapper);
+        if (one == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = aiKuaishouAccountAutoStrategyService.update(strategy, queryWrapper);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 修改状态
+     *
+     * @return
+     */
+    @PostMapping(value = "/updateState")
+    public Result<AiKuaishouAccountAutoStrategy> updateState(@RequestBody AiKuaishouAccountAutoStrategy strategy) {
+        Result<AiKuaishouAccountAutoStrategy> result = new Result<AiKuaishouAccountAutoStrategy>();
+        AiKuaishouAccountAutoStrategy entity = aiKuaishouAccountAutoStrategyService.getById(strategy.getId());
+        if (entity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            AiKuaishouAdvertiserStrategy getEntity = aiKuaishouAdvertiserStrategyService.getByAccountId(entity.getAccountId());
+            if (null != getEntity && getEntity.getStatus() == strategy.getStatus() && strategy.getStatus() == 1) {
+                result.error500("修改失败,该账户旧版自动投放策略已运行");
+            } else {
+                boolean ok = aiKuaishouAccountAutoStrategyService.updateById(strategy);
+                if (ok) {
+                    result.success("修改成功!");
+                }
+            }
+        }
+
+        return result;
+    }
+
+    /**
      * 通过id删除
      *
      * @param id

+ 4 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaishouAccountAutoTargetController.java

@@ -65,13 +65,13 @@ public class AiKuaishouAccountAutoTargetController {
      */
     @ApiOperation(value = "自动投放重构-本地定向表-分页列表查询", notes = "自动投放重构-本地定向表-分页列表查询")
     @GetMapping(value = "/list")
-    public Result<Object> queryPageList(Long accountId, String targetName, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+    public Result<Object> queryPageList(Long accountId, String targetName,Integer platformOs, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
-            if (Check.isNull(accountId)) {
-                return Result.error("请选择账户");
+            if (Check.isNull(accountId)||Check.isNull(platformOs)) {
+                return Result.error("缺少参数");
             }
-            return aiKuaishouAccountAutoTargetService.queryPageList(accountId, targetName, pageNo, pageSize);
+            return aiKuaishouAccountAutoTargetService.queryPageList(accountId, targetName,platformOs, pageNo, pageSize);
         } catch (Exception e) {
             log.error("查询异常,", e.getMessage());
             e.printStackTrace();

+ 14 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoStrategy.java

@@ -335,10 +335,10 @@ public class AiKuaishouAccountAutoStrategy {
     @ApiModelProperty(value = "创意标签")
     private String creativeTag;
     /**
-     * 物料关联的封面个数
+     * 自定义创意数量
      */
-    @Excel(name = "物料关联的封面个数", width = 15)
-    @ApiModelProperty(value = "物料关联的封面个数")
+    @Excel(name = "自定义创意数量", width = 15)
+    @ApiModelProperty(value = "自定义创意数量")
     private Integer imageCnt;
     /**
      * 程序化创意2.0-是否开启智能抽帧
@@ -375,7 +375,7 @@ public class AiKuaishouAccountAutoStrategy {
      */
     @Excel(name = "深度转化出价", width = 15)
     @ApiModelProperty(value = "深度转化出价")
-    private BigDecimal deepConversionBid;
+    private String deepConversionBid;
     /**
      * 是否创建程序化创意
      */
@@ -491,4 +491,14 @@ public class AiKuaishouAccountAutoStrategy {
 
     @TableField(exist = false)
     private String authName;
+
+    @TableField(exist = false)
+    private int customCreatedUnitCnt;
+
+    @TableField(exist = false)
+    private int programCreatedUnitCnt;
+
+    //待建广告组数
+    @TableField(exist = false)
+    private int toBeBuiltCnt;
 }

+ 8 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaishouAccountAutoVideo.java

@@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.google.common.base.Objects;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -24,6 +25,7 @@ import java.util.Date;
  * @date 2021-10-20
  */
 @Data
+@AllArgsConstructor
 @TableName("ctop_ai_kuaishou_account_auto_video")
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
@@ -75,8 +77,8 @@ public class AiKuaishouAccountAutoVideo {
     /**
      * 使用时间
      */
-    @Excel(name = "使用时间", width = 15)
-    @ApiModelProperty(value = "使用时间")
+    @Excel(name = "素材创建时间", width = 15)
+    @ApiModelProperty(value = "素材创建时间")
     private String statDate;
     /**
      * MD5值
@@ -123,6 +125,10 @@ public class AiKuaishouAccountAutoVideo {
     @TableField(exist = false)
     private Long campaignId;
 
+    public AiKuaishouAccountAutoVideo() {
+
+    }
+
     @Override
     public boolean equals(Object o) {
         if (this == o) {

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoTargetMapper.java

@@ -15,7 +15,7 @@ import java.util.List;
  */
 public interface AiKuaishouAccountAutoTargetMapper extends BaseMapper<AiKuaishouAccountAutoTarget> {
 
-    List<AiKuaishouAccountAutoTarget> queryPageList(@Param("accountId") Long accountId, @Param("targetName") String targetName);
+    List<AiKuaishouAccountAutoTarget> queryPageList(@Param("accountId") Long accountId, @Param("targetName") String targetName,@Param("platformOs") Integer platformOs);
 
     List<AiKuaishouAccountAutoTarget> getAutoTargetByIds(@Param("ids") List<String> list);
 }

+ 7 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAccountAutoVideoMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.ai.mapper;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,17 +18,19 @@ public interface AiKuaishouAccountAutoVideoMapper extends BaseMapper<AiKuaishouA
 
     void insertBatch(@Param("videoGetList") List<AiKuaishouAccountAutoVideo> videoGetList);
 
-    List<AiKuaishouAccountAutoVideo> getUpNewVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt, @Param("statDate") String statDate, @Param("createType") String createType);
+    List<AiKuaishouAccountAutoVideo> getUpNewVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword")  List<String>  keyword, @Param("videoCnt") Integer videoCnt, @Param("statDate") String statDate, @Param("createType") String createType);
 
-    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt, @Param("createType") String createType);
+    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword")  List<String>  keyword, @Param("videoCnt") Integer videoCnt, @Param("createType") String createType, @Param("statDate") String statDate);
 
-    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword") String keyword, @Param("videoCnt") Integer videoCnt);
+    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(@Param("accountId") Long accountId, @Param("channelType") Integer channelType, @Param("keyword")  List<String>  keyword, @Param("videoCnt") Integer videoCnt, @Param("statDate") String statDate);
 
-    List<AiKuaishouAccountAutoVideo> getZeroVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt);
+    List<AiKuaishouAccountAutoVideo> getZeroVideoByParams(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, @Param("statDate") String date);
 
     Integer getAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType);
 
     void addAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType, @Param("usageTimes") Integer usageTimes, @Param("date") String date);
 
     void updateAutoVideoUsed(@Param("accountId") Long accountId, @Param("signature") String signature, @Param("videoType") Integer videoType, @Param("createType") String createType, @Param("usageTimes") Integer usageTimes, @Param("date") String date);
+
+    List<String> selectBatchByPhotoIds(@Param("details") JSONArray details, @Param("statDate") String statDate, @Param("accountId") Long accountId);
 }

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoTargetMapper.xml

@@ -8,8 +8,9 @@
         FROM ctop_ai_kuaishou_account_auto_target
         where account_id = #{accountId}
         <if test="targetName != null">
-            and target_name = #{targetName}
+            and target_name LIKE CONCAT(CONCAT('%', #{targetName}), '%')
         </if>
+        AND (platform_os =0 or platform_os = #{platformOs})
         order by create_time desc
     </select>
 

+ 63 - 30
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAccountAutoVideoMapper.xml

@@ -5,25 +5,27 @@
     <insert id="insertBatch">
         replace into ctop_ai_kuaishou_account_auto_video(
         account_id,
+        custom_status,
+        program_status,
         photo_id,
-        status,
+        photo_name,
         material_type,
-        stat_date,
         channel_type,
-        signature,
-        photo_name
+        stat_date,
+        signature
         )
         values
         <foreach collection="videoGetList" item="video" separator=",">
             (
             #{video.accountId},
+            #{video.customStatus},
+            #{video.programStatus},
             #{video.photoId},
-            #{video.status},
+            #{video.photoName},
             #{video.materialType},
-            #{video.statDate},
             #{video.channelType},
-            #{video.signature},
-            #{video.photoName}
+            #{video.statDate},
+            #{video.signature}
             )
         </foreach>
     </insert>
@@ -32,20 +34,24 @@
     <select id="getUpNewVideos" resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo">
         SELECT * FROM ctop_ai_kuaishou_account_auto_video
         WHERE account_id = #{accountId}
-        <if test="createType ==custom">
+        <if test="createType == 'custom' ">
             AND custom_status = 1
         </if>
-        <if test="createType ==program">
+        <if test="createType == 'program'">
             AND program_status = 1
         </if>
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             AND channel_type = #{channelType}
         </if>
         <if test="statDate!=null">
             AND stat_date = #{statDate}
         </if>
-        <if test="keyword != null and keyword != '' ">
-            AND photo_name LIKE concat(#{keyword},'%')
+        <if test="keyword != null and keyword.size>0 ">
+            AND
+            <foreach item="item" index="index" collection="keyword"
+                     open="(" separator="OR" close=")">
+                photo_name LIKE concat(#{item},'%')
+            </foreach>
         </if>
         LIMIT #{videoCnt}
     </select>
@@ -54,15 +60,19 @@
         SELECT * FROM ctop_ai_kuaishou_account_auto_video
         WHERE custom_status = 1
         AND account_id = #{accountId}
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             AND channel_type = #{channelType}
         </if>
         <if test="statDate!=null">
             AND stat_date &lt; #{statDate}
             AND stat_date &gt;= DATE_SUB(#{statDate},INTERVAL 7 day)
         </if>
-        <if test="keyword != null and keyword != '' ">
-            AND photo_name LIKE concat(#{keyword},'%')
+        <if test="keyword != null and keyword.size>0 ">
+            AND
+            <foreach item="item" index="index" collection="keyword"
+                     open="(" separator="OR" close=")">
+                photo_name LIKE concat(#{item},'%')
+            </foreach>
         </if>
         LIMIT #{videoCnt}
     </select>
@@ -76,31 +86,35 @@
         channel_type,
         material_type
         from ctop_material_top_cost
-        where t1.account_id = #{accountId}
+        where account_id = #{accountId}
         and md5 not in
         (
         SELECT signature FROM ctop_ai_kuaishou_account_auto_video_used
         WHERE account_id =#{accountId}
         AND video_type = 2
-        AND usage_times &lt;= 5
+        AND usage_times &gt;= 5
         <if test="createType !=null">
             AND create_type = #{createType}
         </if>
         AND stat_date &gt;= DATE_SUB(#{statDate},INTERVAL 7 day)
         group by signature
         )
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             and channel_type = #{channelType}
         </if>
-        <if test="keyword != null and keyword != '' ">
-            and material_name like concat(#{keyword},'%')
+        <if test="keyword != null and keyword.size>0 ">
+            AND
+            <foreach item="item" index="index" collection="keyword"
+                     open="(" separator="OR" close=")">
+                material_name LIKE concat(#{item},'%')
+            </foreach>
         </if>
         group by signature
-        ORDER BY t2.7day_cost DESC
+        ORDER BY 7day_cost DESC
         LIMIT #{videoCnt}
     </select>
 
-    <select id="getHistoryCatchVideos" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet">
+    <select id="getHistoryCatchVideos" resultType="cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoVideo">
         select
         account_id,
         md5 as 'signature',
@@ -108,26 +122,30 @@
         material_name as 'photoName',
         channel_type,
         material_type
-        from ctop_material_top_cost
-        where t1.account_id = #{accountId}
+        from ctop_history_material_catch
+        where account_id = #{accountId}
         and md5 not in
         (
         SELECT signature FROM ctop_ai_kuaishou_account_auto_video_used
         WHERE account_id =#{accountId}
         AND video_type = 4
         AND create_type = 'custom'
-        AND usage_times &lt;= 2
+        AND usage_times &gt;= 2
         AND stat_date &gt;= DATE_SUB(#{statDate},INTERVAL 60 day)
         group by signature
         )
-        <if test="channelType!=null">
+        <if test="channelType!=null and channelType!=2">
             and channel_type = #{channelType}
         </if>
-        <if test="keyword != null and keyword != '' ">
-            and material_name like concat(#{keyword},'%')
+        <if test="keyword != null and keyword.size>0 ">
+            AND
+            <foreach item="item" index="index" collection="keyword"
+                     open="(" separator="OR" close=")">
+                material_name LIKE concat(#{item},'%')
+            </foreach>
         </if>
         group by signature
-        ORDER BY t2.sum_cost DESC
+        ORDER BY sum_cost DESC
         LIMIT #{videoCnt}
     </select>
 
@@ -172,4 +190,19 @@
           AND video_type = #{videoType}
           AND create_type = #{createType}
     </update>
+
+    <select id="selectBatchByPhotoIds" resultType="java.lang.String">
+        SELECT photo_id
+        FROM ctop_ai_kuaishou_account_auto_video
+        WHERE account_id = #{accountId}
+        AND stat_date = #{statDate}
+        <if test="details!=null">
+            AND photo_id in
+            <foreach item="item" collection="details"
+                     open="(" separator="," close=")">
+                #{item.photo_id}
+            </foreach>
+        </if>
+    </select>
+
 </mapper>

+ 7 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoDoService.java

@@ -2,11 +2,12 @@ package cn.com.ctop.kuaishou.modules.ai.service;
 
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoStrategy;
 
-import java.text.ParseException;
-
 public interface IAiKuaishouAccountAutoDoService {
 
-    //创建自定义广告创意
+    //创建自定义上新广告创意
+    void createCustomUpNewCreative(AiKuaishouAccountAutoStrategy strategy);
+
+    //创建自定义非上新广告创意
     void createCustomCreative(AiKuaishouAccountAutoStrategy strategy);
 
     //创建程序化广告创意
@@ -15,4 +16,7 @@ public interface IAiKuaishouAccountAutoDoService {
     // 组创建是否超限
     Boolean getUnitOverrun(Long accountId);
 
+    //每日补齐创建
+    void supplementTodayCreatives(AiKuaishouAccountAutoStrategy strategy);
+
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoTargetService.java

@@ -16,7 +16,7 @@ import java.util.List;
  */
 public interface IAiKuaishouAccountAutoTargetService extends IService<AiKuaishouAccountAutoTarget> {
 
-    Result<Object> queryPageList(Long accountId, String targetName, Integer pageNo, Integer pageSize);
+    Result<Object> queryPageList(Long accountId, String targetName,Integer platformOs, Integer pageNo, Integer pageSize);
 
     Result<Object> addLocalTarget(JSONObject requestJson);
 

+ 4 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAccountAutoVideoService.java

@@ -15,16 +15,16 @@ import java.util.List;
 public interface IAiKuaishouAccountAutoVideoService extends IService<AiKuaishouAccountAutoVideo> {
 
     // 获取上新素材(自动投放账户级重构)
-    List<AiKuaishouAccountAutoVideo> getUpNewVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType);
+    List<AiKuaishouAccountAutoVideo> getUpNewVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate, String createType);
 
     //获取7天高质量 (自动投放账户级重构)
-    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType);
+    List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate, String createType);
 
     //获取遗漏素材:7天内未被创建过的素材(自动投放账户级重构)
-    List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate);
+    List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate);
 
     //历史素材打捞(自动投放账户级重构)
-    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate);
+    List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate);
 
     void insertAutoVideo(Long accountId);
 

Plik diff jest za duży
+ 624 - 264
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoDoServiceImpl.java


+ 9 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoTargetServiceImpl.java

@@ -29,9 +29,9 @@ public class AiKuaishouAccountAutoTargetServiceImpl extends ServiceImpl<AiKuaish
     private AiKuaishouAccountAutoTargetMapper accountAutoTargetMapper;
 
     @Override
-    public Result<Object> queryPageList(Long accountId, String targetName, Integer pageNo, Integer pageSize) {
+    public Result<Object> queryPageList(Long accountId, String targetName,Integer platformOs, Integer pageNo, Integer pageSize) {
         PageHelper.startPage(pageNo, pageSize);
-        List<AiKuaishouAccountAutoTarget> list = accountAutoTargetMapper.queryPageList(accountId, targetName);
+        List<AiKuaishouAccountAutoTarget> list = accountAutoTargetMapper.queryPageList(accountId, targetName,platformOs);
         return Result.ok(new PageInfo<>(list));
     }
 
@@ -62,12 +62,18 @@ public class AiKuaishouAccountAutoTargetServiceImpl extends ServiceImpl<AiKuaish
         wrapper.eq("target_name", requestJson.getString("targetName")).last("limit 1");
         AiKuaishouAccountAutoTarget one = this.getOne(wrapper);
         if (!Check.isNull(one) && one.getId() - requestJson.getLong("id") != 0) {
-            return Result.ok("账户下定向包名重复");
+            return Result.error("账户下定向包名重复");
         }
         AiKuaishouAccountAutoTarget target = JSONObject.toJavaObject(requestJson, AiKuaishouAccountAutoTarget.class);
         if (!Check.isNull(requestJson.getJSONArray("keyword"))) {
             target.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
         }
+        if (!Check.isNull(target.getMax()) && target.getMax() == -1) {
+            target.setMax(null);
+        }
+        if (!Check.isNull(target.getMin()) && target.getMin() == -1) {
+            target.setMin(null);
+        }
         boolean update = this.saveOrUpdate(target);
         if (update) {
             return Result.ok("修改成功");

+ 12 - 14
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAccountAutoVideoServiceImpl.java

@@ -43,23 +43,23 @@ public class AiKuaishouAccountAutoVideoServiceImpl extends ServiceImpl<AiKuaisho
     private ICtopOauthTokenService tokenService;
 
     @Override
-    public List<AiKuaishouAccountAutoVideo> getUpNewVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType) {
+    public List<AiKuaishouAccountAutoVideo> getUpNewVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate, String createType) {
         return autoVideoMapper.getUpNewVideos(accountId, channelType, keyword, videoCnt, statDate, createType);
     }
 
     @Override
-    public List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate, String createType) {
-        return autoVideoMapper.getHistoryTopVideos(accountId, channelType, keyword, videoCnt, createType);
+    public List<AiKuaishouAccountAutoVideo> getHistoryTopVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate, String createType) {
+        return autoVideoMapper.getHistoryTopVideos(accountId, channelType, keyword, videoCnt, createType, statDate);
     }
 
     @Override
-    public List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate) {
-        return autoVideoMapper.getZeroVideoByParams(accountId, channelType, keyword, videoCnt);
+    public List<AiKuaishouAccountAutoVideo> getMissVideoByParams(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate) {
+        return autoVideoMapper.getZeroVideoByParams(accountId, channelType, keyword, videoCnt, statDate);
     }
 
     @Override
-    public List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType, String keyword, Integer videoCnt, String statDate) {
-        return autoVideoMapper.getHistoryCatchVideos(accountId, channelType, keyword, videoCnt);
+    public List<AiKuaishouAccountAutoVideo> getHistoryCatchVideos(Long accountId, Integer channelType,  List<String>  keyword, Integer videoCnt, String statDate) {
+        return autoVideoMapper.getHistoryCatchVideos(accountId, channelType, keyword, videoCnt, statDate);
     }
 
 
@@ -118,25 +118,23 @@ public class AiKuaishouAccountAutoVideoServiceImpl extends ServiceImpl<AiKuaisho
             }
 
             List<AiKuaishouAccountAutoVideo> videoGetList = new ArrayList<>();
+
+            Long accountId = token.getAccountId();
+            List<String> photoIds = autoVideoMapper.selectBatchByPhotoIds(details, date, accountId);
             for (int i = 0; i < details.size(); i++) {
                 JSONObject detailJson = details.getJSONObject(i);
                 if (Check.isNull(detailJson)) {
                     continue;
                 }
                 String photoId = detailJson.getString("photo_id");
-                Long accountId = token.getAccountId();
-                QueryWrapper<AiKuaishouAccountAutoVideo> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("photo_id", photoId);
-                queryWrapper.eq("account_id", accountId).last("limit 1");
-                AiKuaishouAccountAutoVideo one = this.getOne(queryWrapper);
-                if (!Check.isNull(one)) {
+                if (!Check.isNull(photoIds) && photoIds.contains(photoId)) {
                     continue;
                 }
                 AiKuaishouAccountAutoVideo videoGet = new AiKuaishouAccountAutoVideo();
                 videoGet.setAccountId(accountId);
                 videoGet.setPhotoId(photoId);
                 videoGet.setPhotoName(detailJson.getString("photo_name"));
-                videoGet.setStatDate(date);
+                videoGet.setStatDate(DateUtils.formatDate(detailJson.getDate("create_time"), DateUtils.WEB_FORMAT));
                 String signature = detailJson.getString("signature");
                 videoGet.setSignature(signature);
                 Integer source = detailJson.getInteger("source");

+ 37 - 33
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -8,14 +8,35 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
-import cn.com.ctop.kuaishou.modules.ai.entity.*;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCampaignLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouCreativeLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouUnitLevelOperationRecord;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaiShouAppMultipleBids;
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
-import cn.com.ctop.kuaishou.modules.ai.service.*;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCampaignLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreativeLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouUnitLevelOperationRecordService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 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.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import cn.com.ctop.kuaishou.modules.channel.service.IKuaishouChannelService;
@@ -33,7 +54,14 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.text.ParseException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
 
 @Slf4j
 @Service
@@ -299,9 +327,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 }
                 newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
                 if (null == newCampaignId) {
-                    if (!Check.isNull(channel)) {
-                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                    }
                     return videoCnt;
                 }
                 if (useChannel == 1) {
@@ -312,9 +337,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             if ("account".equals(level)) {
                                 usedchannel = channel;
                             } else {
-                                if (!Check.isNull(channel)) {
-                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                                }
                                 return videoCnt;
                             }
                         }
@@ -389,9 +411,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     if (unitCode != 0) {
                         log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        if (!Check.isNull(usedchannel)) {
-                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                        }
                         continue;
                     }
                     Long unitId = (Long) unitCreateResult.get("unitId");
@@ -399,7 +418,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     videoCnt--;
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
                     }
                     JSONObject creativeParams = creativeParams(token, unitId, videoItem, strategy, usedchannel);//TODO 添加素材
                     createCreativeByImage(cutFrameList, token, creativeParams, newCampaignId, unitId, videoItem, strategy.getImageCnt(), strategy, strategyUuid, null);
@@ -411,9 +430,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("创建自定义广告组异常", e);
-                if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
             }
         }
         return videoCnt;
@@ -667,9 +683,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 }
                 newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
                 if (null == newCampaignId) {
-                    if (!Check.isNull(channel)) {
-                        channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                    }
                     return;
                 }
                 if (useChannel == 1) {
@@ -680,9 +693,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             if ("account".equals(level)) {
                                 usedchannel = channel;
                             } else {
-                                if (!Check.isNull(channel)) {
-                                    channelService.callBackUpdateChannelRel(level, channel.getChannelCode(), accountId, newCampaignId, null, 0);
-                                }
                                 return;
                             }
                         }
@@ -761,16 +771,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     if (unitCode != 0) {
                         log.info("组创建失败=>accountId:{};message:{}", accountId, unitMessage);
                         unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
-                        if (!Check.isNull(usedchannel)) {
-                            channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                        }
                         continue;
                     }
                     Long unitId = (Long) unitCreateResult.get("unitId");
                     unitLevelOperationRecord.setUnitId(unitId);
                     unitLevelOperationRecordService.saveOrUpdate(unitLevelOperationRecord);
                     if (!Check.isNull(usedchannel)) {
-                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId, 1);
+                        channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, unitId);
                     }
                     JSONObject creativeParams = programCreativeParams(token, unitId, splitVideos.get(j - 1), strategy, j, null, usedchannel);
                     createProgramCreative(token, creativeParams, strategy);
@@ -778,9 +785,6 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             } catch (Exception e) {
                 e.printStackTrace();
                 log.error("创建程序化广告组异常", e);
-                if (!Check.isNull(usedchannel)) {
-                    channelService.callBackUpdateChannelRel(level, usedchannel.getChannelCode(), accountId, newCampaignId, null, 0);
-                }
             }
         }
 
@@ -801,7 +805,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         Long unitNum = customUnitCnt * hour / 20;
         log.info("{}当前时间内需要创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
@@ -834,7 +838,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         log.info("{}当天可创建组总数:{}", strategy.getAccountId(), unitNum);
         //查询当前账户创建自定义类型组数量
-        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(),4);
+        int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId(), 4);
         log.info("{}截止目前创建组总数:{}", strategy.getAccountId(), unitCreateCnt);
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
@@ -1132,7 +1136,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         campaignId = (Long) campaignCreateResult.get("campaignId");
         if (!Check.isNull(channel)) {
-            channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null, 1);
+            channelService.callBackUpdateChannelRel("plan", channel.getChannelCode(), token.getAccountId(), campaignId, null);
         }
         record.setCampaignId(campaignId);
         aiKuaishouCampaignLevelOperationRecordService.saveOrUpdate(record);

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

@@ -192,8 +192,8 @@ public class KuaiShouGroupTemplate {
     /**
      * 0:未提交 1:创建成功 2:创建失败
      */
-    @Excel(name = "0:未提交 1:创建成功 2:创建失败", width = 15)
-    @ApiModelProperty(value = "0:未提交 1:创建成功 2:创建失败")
+    @Excel(name = "0:未提交 1:创建中 2:创建成功  3:创建失败", width = 15)
+    @ApiModelProperty(value = "0:未提交 1:创建中 2:创建成功  3:创建失败")
     private Integer taskStatus;
     /**
      * 失败原因

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -25,4 +26,6 @@ public interface KuaiShouCampaignMapper extends BaseMapper<KuaiShouCampaign> {
     Long getCampaignIdByAccountAndName(@Param("accountId") Long accountId, @Param("name") String replaceString);
 
     Long getCampaignIdByAccountAndNameAndDate(@Param("accountId") Long accountId, @Param("name") String replaceString, @Param("nowDate") String nowDate);
+
+    List<JSONObject> getCampaignIdsByParameters(@Param("accountId") Long accountId, @Param("typeName") String typeName, @Param("nowDate") String nowDate);
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouAppListMapper.xml

@@ -34,7 +34,7 @@
     </insert>
 
     <select id="getAppNames" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList">
-        SELECT account_id,app_id,app_version,app_name,package_name
+        SELECT account_id,app_id,app_version,app_name,package_name,platform
         FROM ctop_kuaishou_app_list
         WHERE app_id IN
         <foreach collection="appIds" item="item" separator=","

+ 27 - 19
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml

@@ -36,38 +36,46 @@
 
     <select id="queryIdsByPutStatus" resultType="java.lang.Long">
         SELECT campaign_id
-        FROM
-        ctop_kuaishou_campaign
+        FROM ctop_kuaishou_campaign
         WHERE account_id = #{accountId}
-        AND put_status = #{putStatus}
+          AND put_status = #{putStatus}
     </select>
     <select id="queryCampaignIdByAccountId" resultType="java.lang.Long">
         SELECT campaign_id
-        FROM
-        ctop_kuaishou_campaign
+        FROM ctop_kuaishou_campaign
         WHERE account_id = #{accountId}
     </select>
     <select id="getNewDataByAccountIdAndDate" resultType="java.lang.Integer">
-     select
-     count(1)
-     from ctop_kuaishou_campaign
-     where account_id = #{accountId}
-     and DATE_FORMAT(put_create_time,'%Y-%m-%d') = #{statDate}
+        select count(1)
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and DATE_FORMAT(put_create_time, '%Y-%m-%d') = #{statDate}
     </select>
     <select id="getCampaignIdByAccountAndName" resultType="java.lang.Long">
-        select campaign_id  from  ctop_kuaishou_campaign where  account_id = #{accountId}
-        and campaign_name like CONCAT('%',CONCAT(#{name},'%'))
-        order by put_create_time DESC
-        limit 1
+        select campaign_id
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and campaign_name like CONCAT('%', CONCAT(#{name}, '%'))
+        order by put_create_time DESC limit 1
 
 
     </select>
     <select id="getCampaignIdByAccountAndNameAndDate" resultType="java.lang.Long">
-          select campaign_id  from  ctop_kuaishou_campaign where  account_id = #{accountId}
-        and campaign_name like CONCAT('%',CONCAT(#{name},'%'))
-        and put_create_time &gt;= #{nowDate}
-        order by put_create_time DESC
-        limit 1
+        select campaign_id
+        from ctop_kuaishou_campaign
+        where account_id = #{accountId}
+          and campaign_name like CONCAT('%', CONCAT(#{name}, '%'))
+          and put_create_time &gt;= #{nowDate}
+        order by put_create_time DESC limit 1
 
     </select>
+
+    <select id="getCampaignIdsByParameters" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT campaign_id as 'campaignId',
+               (SELECT COUNT(1) FROM ctop_kuaishou_group WHERE campaign_id = t.campaign_id) AS 'count'
+        FROM ctop_kuaishou_campaign t
+        WHERE account_id = #{accountId}
+          AND campaign_name LIKE CONCAT('%', CONCAT(#{typeName}, '%'))
+          AND put_create_time &gt;= #{nowDate}
+    </select>
 </mapper>

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCampaignService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -27,4 +28,6 @@ public interface IKuaiShouCampaignService extends IService<KuaiShouCampaign> {
     Long getCampaignIdByAccountAndName(Long accountId, String replaceString);
 
     Long getCampaignIdByAccountAndNameAndDate(Long accountId, String replaceString, String nowDate);
+
+    List<JSONObject> getCampaignIdsByParameters(Long accountId, String typeName, String nowDate);
 }

+ 0 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java

@@ -500,9 +500,7 @@ public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
                         };
                         thread2.start();
                     }
-
                 } else {
-
                     if (code == 500000 && count <= 4) {
                         adUnitCreate(requestJson, count + 1);
                     }

+ 6 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCampaignServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 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;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -91,4 +92,9 @@ public class KuaiShouCampaignServiceImpl extends ServiceImpl<KuaiShouCampaignMap
         return campaignMapper.getCampaignIdByAccountAndNameAndDate(accountId, replaceString, nowDate);
     }
 
+    @Override
+    public List<JSONObject> getCampaignIdsByParameters(Long accountId, String typeName, String nowDate) {
+        return campaignMapper.getCampaignIdsByParameters(accountId, typeName, nowDate);
+    }
+
 }

+ 116 - 76
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -332,11 +332,41 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
     private void addGroupV2(Long advertiserId, JSONArray details) {
 
         JSONObject json = warningOperationService.getBidTypeAndMaxBid(advertiserId);
-        Long maxBid = json.getLong("maxBid");// 最高出价
-        String bidTypeStr = json.getString("bidType"); // 出价方式
-        JSONArray bidTypeArr = JSONArray.parseArray(bidTypeStr);
-        String ocpxActionTypeStr = json.getString("ocpxActionType"); // 优化目标
-        JSONArray ocpxArr = JSONArray.parseArray(ocpxActionTypeStr);
+        if (Check.isNull(json) || Check.isNull(details)) {
+            return;
+        }
+
+        // 最高出价
+        Long maxBid = json.getLong("maxBid");
+
+        //优化目标集
+        List<Integer> bidList = null;
+        String bidTypeStr = json.getString("bidType");
+        if (!Check.isNull(bidTypeStr)) {
+            bidList = JSONArray.parseArray(bidTypeStr, Integer.class);
+        }
+
+        //转化目标map
+        Map<Integer, Long> ocpxMap = new HashMap<>();
+        String ocpxTypeStr = json.getString("ocpxActionType");
+        if (!Check.isNull(ocpxTypeStr)) {
+            JSONArray ocpxArr = JSONArray.parseArray(ocpxTypeStr);
+            for (int i = 0; i < ocpxArr.size(); i++) {
+                JSONObject obj = ocpxArr.getJSONObject(i);
+                ocpxMap.put(obj.getInteger("ocpxCode"), obj.getLong("maxValue"));
+            }
+        }
+
+        //深度转化目标map
+        Map<Integer, Long> deepMap = new HashMap<>();
+        String deepTypeStr = json.getString("deepConversionType");
+        if (!Check.isNull(deepTypeStr)) {
+            JSONArray deepArr = JSONArray.parseArray(deepTypeStr);
+            for (int i = 0; i < deepArr.size(); i++) {
+                JSONObject obj = deepArr.getJSONObject(i);
+                ocpxMap.put(obj.getInteger("deepCode"), obj.getLong("deepValue"));
+            }
+        }
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();
             List<KuaiShouAppInfo> appInfos = new ArrayList<>();
@@ -345,98 +375,108 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
             for (int i = 0; i < details.size(); i++) {
                 JSONObject detail = JSONObject.parseObject(details.get(i).toString());
                 if (!Check.isNull(detail)) {
-                    Integer bid_type = detail.getInteger("bid_type");
+                    //优化目标
+                    Integer bidType = detail.getInteger("bid_type");
+                    //优化出价(只有单击时,才有值)
                     Long bid = detail.getLong("bid");
-                    Long cpa_bid = detail.getLong("cpa_bid");
-                    Long day_budget = detail.getLong("day_budget");
-                    Integer ocpx_action_type = detail.getInteger("ocpx_action_type");
+                    //转化目标
+                    Integer ocpxActionType = detail.getInteger("ocpx_action_type");
+                    //转化目标出价
+                    Long cpaBid = detail.getLong("cpa_bid");
+                    //深度转化目标
+                    Integer deepConversionType = detail.getInteger("deep_conversion_type");
+                    //深度转化目标出价
+                    Long deepConversionBid = detail.getLong("deep_conversion_bid");
+                    //单日预算
+                    Long dayBudget = detail.getLong("day_budget");
+                    //组ID
                     Long unitId = detail.getLong("unit_id");
-                    String unit_name = detail.getString("unit_name");
+                    //组名称
+                    String unitName = detail.getString("unit_name");
+                    //状态
                     Integer status = detail.getInteger("status");
-                    Integer put_status = detail.getInteger("put_status");
-                    if (put_status == 1) { // 组状态为 投放中的
-                        if (status != 15) { // 广告组状态为非暂停
-                            Boolean bidTypeTrueOrFalse = false;
-                            for (int j = 0; j < bidTypeArr.size(); j++) {
-                                Integer bidType = (Integer) bidTypeArr.get(j);
-                                if (bidType.equals(bid_type)) {
-                                    bidTypeTrueOrFalse = true;
-                                    break;
+                    //投放状态
+                    Integer putStatus = detail.getInteger("put_status");
+                    if (putStatus == 1 && status != 15) { // 组状态为 投放中的 and 广告组状态为非暂停
+                        Boolean typeFalg = true;
+                        Boolean bidFalg = true;
+
+                        //优化目标
+                        if (!bidList.isEmpty()) {
+                            if (!bidList.contains(bidType)) {
+                                //项目不包含该优化目标,则关停
+                                typeFalg = false;
+                            } else if (bidType == 2 && bid > maxBid) {
+                                //若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
+                                bidFalg = false;
+                            }
+                        }
+                        //转化目标
+                        if (!Check.isNull(ocpxActionType) && ocpxActionType != 0) {
+                            //!=0是设置过转化目标
+                            if (!Check.isNullMap(ocpxMap)) {
+                                Long ocpxBid = ocpxMap.get(ocpxActionType);
+                                if (Check.isNull(ocpxBid)) {
+                                    if (ocpxActionType == 2 && dayBudget != 0 && dayBudget <= 500 * 1000) {
+                                        // 转化目标为2行为数,并且预算小于等于500且不是不限,则允许启动
+                                        typeFalg = true;
+                                    }else{
+                                        //通过key未获取值,说明不包含该目标,进行关停
+                                        typeFalg = false;
+                                    }
+                                } else {
+                                    if (cpaBid > ocpxBid) {
+                                        //组转化出价 大于 项目设置最大转化出价,则关停
+                                        bidFalg = false;
+                                    }
                                 }
+                            }else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
+                                // 转化目标为2行为数,并且预算大于500 或者不限,则关停
+                                typeFalg = false;
                             }
+                        }
 
-                            Boolean ocpxTrueOrFalse = false;
-                            if (ocpx_action_type == 0) {
-                                ocpxTrueOrFalse = true;
+                        //转化目标
+                        if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !Check.isNullMap(ocpxMap)) {
+                            Long deepBid = deepMap.get(deepConversionType);
+                            if (Check.isNull(deepBid)) {
+                                //通过key未获取值,说明不包含该目标,进行关停
+                                typeFalg = false;
                             } 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 (deepConversionBid > deepBid) {
+                                    //组深度转化出价 大于 项目设置最大转化出价,则关停
+                                    bidFalg = false;
                                 }
                             }
+                        }
 
-
-                            if (!bidTypeTrueOrFalse || !ocpxTrueOrFalse) { // 出价方式设置非法
-                                if (day_budget > 500 * 1000 || day_budget == 0) { // 预算大于500 或者不限制预算 需要发送通知 并且进行暂停操作
-                                    executorBidTypeService.submit(new Runnable() {
-                                        @Override
-                                        public void run() {
-                                            warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
-                                        }
-                                    });
+                        if (!typeFalg) { // 出价方式设置非法
+                            executorBidTypeService.submit(new Runnable() {
+                                @Override
+                                public void run() {
+                                    warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unitName);
                                 }
-                            }
-                            if (bid > maxBid || cpa_bid > maxBid) {
-                                executorMaxBidService.submit(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
-                                    }
-                                });
-                            }
+                            });
+                        }
+                        if (!bidFalg) {
+                            executorMaxBidService.submit(new Runnable() {
+                                @Override
+                                public void run() {
+                                    warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unitName);
+                                }
+                            });
                         }
                     }
 
-                    KuaiShouGroup group = new KuaiShouGroup();
+                    KuaiShouGroup group = JSONObject.parseObject(detail.toJSONString(), KuaiShouGroup.class);
                     group.setId("" + advertiserId + unitId);
                     group.setAccountId(advertiserId);
-                    group.setCampaignId(detail.getLong("campaign_id"));
-                    group.setUnitId(unitId);
-                    group.setUnitName(unit_name);
-                    group.setStatus(status);
-                    group.setPutStatus(put_status);
-                    group.setCreateChannel(detail.getInteger("create_channel"));
-                    group.setReviewDetail(detail.getString("review_detail"));
-                    group.setBidType(bid_type);
-                    group.setBid(bid);
-                    group.setCpaBid(detail.getLong("cpa_bid"));
-                    group.setOcpxActionType(ocpx_action_type);
-                    group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
-                    group.setDeepConversionBid(detail.getLong("deep_conversion_bid"));
-                    group.setDayBudget(detail.getLong("day_budget"));
-                    group.setSpeed(detail.getInteger("speed"));
-                    group.setBeginTime(detail.getString("begin_time"));
-                    group.setEndTime(detail.getString("end_time"));
-                    group.setScheduleTime(detail.getString("schedule_time"));
-                    group.setSceneId(detail.getJSONArray("scene_id") + "");
-                    group.setShowMode(detail.getInteger("show_mode"));
-                    group.setUnitType(detail.getInteger("unit_type"));
-                    group.setUrlType(detail.getInteger("url_type"));
-                    group.setUrl(detail.getString("url"));
-                    group.setSchemaUri(detail.getString("schema_uri"));
-                    group.setAppId(detail.getLong("app_id"));
-                    group.setAppIconUrl(detail.getString("app_icon_url"));
                     group.setGroupCreateTime(detail.getString("create_time"));
                     group.setGroupUpdateTime(detail.getString("update_time"));
-                    group.setConvertId(detail.getLong("convert_id"));
-                    group.setUseAppMarket(detail.getInteger("use_app_market"));
-                    group.setAppStore(detail.getJSONArray("app_store") + "");
                     group.setCreateTime(new Date());
                     group.setUpdateTime(new Date());
                     groups.add(group);
+
                     // 添加应用信息
                     JSONObject diverseJson = detail.getJSONObject("diverse_data");
                     if (!Check.isNull(diverseJson)) {

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -381,10 +381,10 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                         deleteMap.put("account_id", advertiserId);
                         deleteMap.put("unit_id", unitId);
                         groupMapper.deleteByMap(deleteMap);
+                        log.info("删除成功,accountId:{}。unitId:{}", advertiserId, unitId);
                     } else {
                         groupService.getGroupByUnitId(token, advertiserId, unitId);
                     }
-                    log.info("删除成功,accountId:{}。unitId:{}", advertiserId, unitId);
                 } else {
                     log.error("修改广告组状态失败,advertiserId:{},unitId:{},返回信息:{}", advertiserId, unitId, resultJson);
                     returnMap.put("code", -1);

+ 322 - 134
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -8,18 +8,68 @@ import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
 import cn.com.ctop.common.module.service.IOauthConfigService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
-import cn.com.ctop.common.module.utils.*;
-import cn.com.ctop.kuaishou.modules.ai.service.*;
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.JsonUtil;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiCreativeLimitService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAccountCreativeOverrunInfoService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouLandpagePackageService;
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouPopulationGroupService;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListChildren;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListParent;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouPopulation;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAdvertiserBaseInfoMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListChildrenMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListParentMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyFlowsService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouOverRunSendMessageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+import cn.com.ctop.kuaishou.modules.batch.service.IWarningOperationService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
-import cn.com.ctop.kuaishou.modules.report.entity.*;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
-import cn.com.ctop.kuaishou.modules.report.service.*;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyAccountService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -54,7 +104,11 @@ import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -165,6 +219,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
         if (null == details || details.size() <= 0) {
+            log.error("快手时报返回详情为空,accountId:{}", token.getAccountId());
             return;
         }
         List<KuaishouReportHourlyAccount> addList = new ArrayList<>();
@@ -181,6 +236,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             addList.add(kuaishouReportHourlyAccount);
         }
         hourlyAccountService.replaceBatch(addList);
+        log.info("获取账户时报数据完成,accountId:{}", token.getAccountId());
     }
 
 
@@ -222,9 +278,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
                 return;
             }
-            Boolean doGet = true;
-            if (details.size() < page_size) {
-                doGet = false;
+            Boolean toGet = false;
+            if (details.size() >= page_size) {
+                toGet = true;
             }
 
             List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
@@ -270,16 +326,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             if (!Check.isNull(videoGetList)) {
                 videoGetService.replaceBatch(videoGetList);
             }
-            if (doGet) {
+
+            if (toGet) {
                 getVideoListByPage(token, startDate, endDate, page + 1);
             }
-
         } catch (Exception e) {
             e.printStackTrace();
         }
 
     }
 
+
     private void getCut(String token, Long accountId, String signature, String photo_id) {
         cutExecutorService.submit(new Runnable() {
             @Override
@@ -290,6 +347,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
+
     @Override
     public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate, String reportDims) {
         try {
@@ -978,7 +1036,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     }
 
                 } else {
-                    if (code == 400001 && "/rest/openapi/v2/ad_unit/create调用已超日限,次日可恢复调用".equals(resultJson.getString("message"))) {
+                    if (code == 400001 && resultJson.getString("message").equals("/rest/openapi/v2/ad_unit/create调用已超日限,次日可恢复调用")) {
                         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                         String key = advertiserId + "_" + nowDate + "unit_create_overrun";
                         redisUtil.set(key, 1, 60 * 60 * 24);
@@ -1197,6 +1255,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
+    @Autowired
+    IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
     private void getGroupListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
         JSONObject param = new JSONObject();
@@ -1227,128 +1288,163 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             return;
         }
         addGroup(token.getAccountId(), details);
+        //   ruleKuaiShouPlanService.insertTarget(token.getAccountId(), details);
         getGroupListByPage(token, startDate, endDate, page + 1);
     }
 
     static ExecutorService executorBidTypeService = Executors.newFixedThreadPool(20);
     static ExecutorService executorMaxBidService = Executors.newFixedThreadPool(5);
 
-    private void addGroup(Long advertiserId, JSONArray details) {
-        JSONObject json = warningOperationService.getBidTypeAndMaxBid(advertiserId);
-        Long maxBid = json.getLong("maxBid");// 最高出价
-        String bidTypeStr = json.getString("bidType"); // 出价方式
-        JSONArray bidTypeArr = JSONArray.parseArray(bidTypeStr);
-        String ocpxActionTypeStr = json.getString("ocpxActionType"); // 优化目标
-        JSONArray ocpxArr = JSONArray.parseArray(ocpxActionTypeStr);
-        if (!Check.isNull(details)) {
-            List<KuaiShouGroup> groups = new ArrayList<>();
-            for (int i = 0; i < details.size(); i++) {
-                JSONObject detail = JSONObject.parseObject(details.get(i).toString());
-                if (!Check.isNull(detail)) {
-                    Integer bid_type = detail.getInteger("bid_type");
-                    Long bid = detail.getLong("bid");
-                    Long cpa_bid = detail.getLong("cpa_bid");
-                    Long day_budget = detail.getLong("day_budget");
-                    Integer ocpx_action_type = detail.getInteger("ocpx_action_type");
-                    Long unitId = detail.getLong("unit_id");
-                    String unit_name = detail.getString("unit_name");
-                    Integer status = detail.getInteger("status");
-                    Integer put_status = detail.getInteger("put_status");
-                    if (put_status == 1) { // 组状态为 投放中的
-                        if (status != 15) { // 广告组状态为非暂停
-                            Boolean bidTypeTrueOrFalse = false;
-                            for (int j = 0; j < bidTypeArr.size(); j++) {
-                                Integer bidType = (Integer) bidTypeArr.get(j);
-                                if (bidType.equals(bid_type)) {
-                                    bidTypeTrueOrFalse = true;
-                                    break;
+    private void addGroup(Long accountId, JSONArray details) {
+        JSONObject project = warningOperationService.getBidTypeAndMaxBid(accountId);
+        if (Check.isNull(project) || Check.isNull(details)) {
+            return;
+        }
+
+        // 最高出价
+        Long maxBid = project.getLong("maxBid");
+
+        //优化目标集
+        List<Integer> bidList = null;
+        String bidTypeStr = project.getString("bidType");
+        if (!Check.isNull(bidTypeStr)) {
+            bidList = JSONArray.parseArray(bidTypeStr, Integer.class);
+        }
+
+        //转化目标map
+        Map<Integer, Long> ocpxMap = new HashMap<>();
+        String ocpxTypeStr = project.getString("ocpxActionType");
+        if (!Check.isNull(ocpxTypeStr)) {
+            JSONArray ocpxArr = JSONArray.parseArray(ocpxTypeStr);
+            for (int i = 0; i < ocpxArr.size(); i++) {
+                JSONObject obj = ocpxArr.getJSONObject(i);
+                ocpxMap.put(obj.getInteger("ocpxCode"), obj.getLong("maxValue"));
+            }
+        }
+
+        //深度转化目标map
+        Map<Integer, Long> deepMap = new HashMap<>();
+        String deepTypeStr = project.getString("deepConversionType");
+        if (!Check.isNull(deepTypeStr)) {
+            JSONArray deepArr = JSONArray.parseArray(deepTypeStr);
+            for (int i = 0; i < deepArr.size(); i++) {
+                JSONObject obj = deepArr.getJSONObject(i);
+                ocpxMap.put(obj.getInteger("deepCode"), obj.getLong("deepValue"));
+            }
+        }
+        List<KuaiShouGroup> groups = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detail = JSONObject.parseObject(details.get(i).toString());
+            if (!Check.isNull(detail)) {
+                //优化目标
+                Integer bidType = detail.getInteger("bid_type");
+                //优化出价(只有单击时,才有值)
+                Long bid = detail.getLong("bid");
+                //转化目标
+                Integer ocpxActionType = detail.getInteger("ocpx_action_type");
+                //转化目标出价
+                Long cpaBid = detail.getLong("cpa_bid");
+                //深度转化目标
+                Integer deepConversionType = detail.getInteger("deep_conversion_type");
+                //深度转化目标出价
+                Long deepConversionBid = detail.getLong("deep_conversion_bid");
+                //单日预算
+                Long dayBudget = detail.getLong("day_budget");
+                //组ID
+                Long unitId = detail.getLong("unit_id");
+                //组名称
+                String unitName = detail.getString("unit_name");
+                //状态
+                Integer status = detail.getInteger("status");
+                //投放状态
+                Integer putStatus = detail.getInteger("put_status");
+                if (putStatus == 1 && status != 15) { // 组状态为 投放中的 and 广告组状态为非暂停
+                    Boolean typeFalg = true;
+                    Boolean bidFalg = true;
+
+                    //优化目标
+                    if (!bidList.isEmpty()) {
+                        if (!bidList.contains(bidType)) {
+                            //项目不包含该优化目标,则关停
+                            typeFalg = false;
+                        } else if (bidType == 2 && bid > maxBid) {
+                            //若优化目标为2点击数,并且广告组出价大于项目设置最大出价,则关停
+                            bidFalg = false;
+                        }
+                    }
+                    //转化目标
+                    if (!Check.isNull(ocpxActionType) && ocpxActionType != 0) {
+                        //!=0是设置过转化目标
+                        if (!Check.isNullMap(ocpxMap)) {
+                            Long ocpxBid = ocpxMap.get(ocpxActionType);
+                            if (Check.isNull(ocpxBid)) {
+                                if (ocpxActionType == 2 && dayBudget != 0 && dayBudget <= 500 * 1000) {
+                                    // 转化目标为2行为数,并且预算小于等于500且不是不限,则允许启动
+                                    typeFalg = true;
+                                }else{
+                                //通过key未获取值,说明不包含该目标,进行关停
+                                typeFalg = false;
                                 }
-                            }
-                            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 (cpaBid > ocpxBid) {
+                                    //组转化出价 大于 项目设置最大转化出价,则关停
+                                    bidFalg = false;
                                 }
                             }
+                        }else if (ocpxActionType == 2 && (dayBudget == 0 || dayBudget > 500 * 1000)) {
+                            // 转化目标为2行为数,并且预算大于500 或者不限,则关停
+                            typeFalg = false;
+                        }
+                    }
 
-
-                            if (!bidTypeTrueOrFalse || !ocpxTrueOrFalse) { // 出价方式设置非法
-                                if (day_budget > 500 * 1000 || day_budget == 0) { // 预算大于500 或者不限制预算 需要发送通知 并且进行暂停操作
-                                    executorBidTypeService.submit(new Runnable() {
-                                        @Override
-                                        public void run() {
-                                            warningOperationService.kuaiShouWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
-                                        }
-                                    });
-                                }
-                            }
-                            if (bid > maxBid || cpa_bid > maxBid) {
-                                executorMaxBidService.submit(new Runnable() {
-                                    @Override
-                                    public void run() {
-                                        warningOperationService.kuaiShouBidWarningOperation(json.getLong("projectId"), json.getString("projectName"), advertiserId, unitId, unit_name);
-                                    }
-                                });
+                    //转化目标
+                    if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !Check.isNullMap(ocpxMap)) {
+                        Long deepBid = deepMap.get(deepConversionType);
+                        if (Check.isNull(deepBid)) {
+                            //通过key未获取值,说明不包含该目标,进行关停
+                            typeFalg = false;
+                        } else {
+                            if (deepConversionBid > deepBid) {
+                                //组深度转化出价 大于 项目设置最大转化出价,则关停
+                                bidFalg = false;
                             }
                         }
                     }
 
-                    KuaiShouGroup group = new KuaiShouGroup();
-                    group.setId("" + advertiserId + unitId);
-                    group.setAccountId(advertiserId);
-                    group.setCampaignId(detail.getLong("campaign_id"));
-                    group.setUnitId(unitId);
-                    group.setUnitName(unit_name);
-                    group.setStatus(status);
-                    group.setPutStatus(put_status);
-                    group.setStudyStatus(detail.getInteger("study_status"));
-                    group.setCreateChannel(detail.getInteger("create_channel"));
-                    group.setReviewDetail(detail.getString("review_detail"));
-                    group.setBidType(bid_type);
-                    group.setBid(bid);
-                    group.setStudyStatus(detail.getInteger("study_status"));
-                    group.setCpaBid(cpa_bid);
-                    group.setOcpxActionType(ocpx_action_type);
-                    group.setDeepConversionType(detail.getInteger("deep_conversion_type"));
-                    group.setDeepConversionBid(detail.getLong("deep_conversion_bid"));
-                    group.setDayBudget(day_budget);
-                    group.setSpeed(detail.getInteger("speed"));
-                    group.setBeginTime(detail.getString("begin_time"));
-                    group.setEndTime(detail.getString("end_time"));
-                    group.setScheduleTime(detail.getString("schedule_time"));
-                    group.setSceneId(detail.getJSONArray("scene_id") + "");
-                    group.setShowMode(detail.getInteger("show_mode"));
-                    group.setUnitType(detail.getInteger("unit_type"));
-                    group.setUrlType(detail.getInteger("url_type"));
-                    group.setUrl(detail.getString("url"));
-                    group.setSchemaUri(detail.getString("schema_uri"));
-                    group.setAppId(detail.getLong("app_id"));
-                    group.setAppIconUrl(detail.getString("app_icon_url"));
-                    group.setGroupCreateTime(detail.getString("create_time"));
-                    group.setGroupUpdateTime(detail.getString("update_time"));
-                    group.setConvertId(detail.getLong("convert_id"));
-                    group.setUseAppMarket(detail.getInteger("use_app_market"));
-                    group.setAppStore(detail.getJSONArray("app_store") + "");
-                    group.setCreateTime(new Date());
-                    group.setUpdateTime(new Date());
-                    groups.add(group);
-                    // 添加应用信息
-                }
-            }
-            if (!Check.isNull(groups)) {
-                try {
-                    Thread.sleep(200L);
-                    groupMapper.replaceBatch(groups);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
+                    if (!typeFalg) { // 出价方式设置非法
+                        executorBidTypeService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                warningOperationService.kuaiShouWarningOperation(project.getLong("projectId"), project.getString("projectName"), accountId, unitId, unitName);
+                            }
+                        });
+                    }
+                    if (!bidFalg) {
+                        executorMaxBidService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                warningOperationService.kuaiShouBidWarningOperation(project.getLong("projectId"), project.getString("projectName"), accountId, unitId, unitName);
+                            }
+                        });
+                    }
                 }
 
+                KuaiShouGroup group = JSONObject.parseObject(detail.toJSONString(), KuaiShouGroup.class);
+                group.setId("" + accountId + unitId);
+                group.setAccountId(accountId);
+                group.setGroupCreateTime(detail.getString("create_time"));
+                group.setGroupUpdateTime(detail.getString("update_time"));
+                group.setCreateTime(new Date());
+                group.setUpdateTime(new Date());
+                groups.add(group);
+            }
+        }
+        if (!Check.isNull(groups)) {
+            try {
+                Thread.sleep(200L);
+                groupMapper.replaceBatch(groups);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
             }
         }
     }
@@ -1901,13 +1997,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNullMap(dataJson)) {
                         JSONObject returnJson = new JSONObject();
-                        returnJson.put("isAdWatch5times", dataJson.getInteger("is_ad_watch_5_times"));
-                        returnJson.put("isAdWatch20times", dataJson.getInteger("is_ad_watch_20_times"));
-                        returnJson.put("isAdWatch10Times", dataJson.getInteger("is_ad_watch_10_times"));
-                        returnJson.put("isSevenDayRoi", dataJson.getInteger("is_seven_day_roi"));
-                        returnJson.put("isAppointJumpClick", dataJson.getInteger("is_appoint_jump_click"));
-                        returnJson.put("isEventWeekPayTimes", dataJson.getInteger("is_event_week_pay_times"));
-                        returnJson.put("isAppointForm", dataJson.getInteger("is_appoint_form"));
                         returnJson.put("isActivate", dataJson.getInteger("is_activate"));
                         returnJson.put("isFormSubmit", dataJson.getInteger("is_form_submit"));
                         returnJson.put("isCreditGrant", dataJson.getInteger("is_credit_grant"));
@@ -1921,8 +2010,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnJson.put("isAppInvoked", dataJson.getInteger("is_app_invoked"));
                         returnJson.put("isMultiConversion", dataJson.getInteger("is_multi_conversion"));
                         returnJson.put("isAdWatchTimes", dataJson.getInteger("is_ad_watch_times"));
+                        returnJson.put("isAppInvoked", dataJson.getInteger("is_app_invoked"));
+                        returnJson.put("isMultiConversion", dataJson.getInteger("is_multi_conversion"));
+                        returnJson.put("isAdWatchTimes", dataJson.getInteger("is_ad_watch_times"));
                         returnJson.put("isOrderPaied", dataJson.getInteger("is_order_paied"));
-                        returnJson.put("isKeyAction", dataJson.getInteger("is_key_action"));
 
                         JSONArray deep_conversion_types = dataJson.getJSONArray("deep_conversion_types");
                         JSONArray deepConversionTypes = new JSONArray();
@@ -2080,15 +2171,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 if (code == 0) {
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
-                        JSONArray addCreativeIds = dataJson.getJSONArray("add_creative_ids");
-                        if (!Check.isNull(addCreativeIds)) {
+                        JSONArray add_creative_ids = dataJson.getJSONArray("add_creative_ids");
+                        if (!Check.isNull(add_creative_ids)) {
                             Thread thread = new Thread() {
                                 @Override
                                 public void run() {
                                     try {
                                         Thread.sleep(100);
-                                        getCreativeByCreativeIds(accessToken, advertiserId, addCreativeIds);
-                                        createLandPageAndUnit(requestJson, addCreativeIds);
+                                        getCreativeByCreativeIds(accessToken, advertiserId, add_creative_ids);
+                                        createLandPageAndUnit(requestJson, add_creative_ids);
                                     } catch (InterruptedException e) {
                                         e.printStackTrace();
                                     }
@@ -2102,8 +2193,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnMap.put("code", 0);
                         returnMap.put("message", "success");
                         returnMap.put("success", true);
-                        returnMap.put("count", addCreativeIds.size());
-                        returnMap.put("ids",addCreativeIds);
+                        returnMap.put("count", add_creative_ids.size());
+                        returnMap.put("ids", add_creative_ids);
                     }
                 } else {
                     if (code == 500000 && count <= 4) {
@@ -2868,6 +2959,97 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     private IKuaiShouVideoGetService videoGetService;
     static ExecutorService suZhaoService = Executors.newFixedThreadPool(15);
 
+   /* @Override
+    public void getSuZaoList(String token, Long accountId, int page, String startDate, String endDate) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/ad_creator/video/list";
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<String, Object>();
+        param.put("advertiser_id", accountId);
+        param.put("page", page);
+        param.put("page_size", 200);
+        if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+            param.put("start_date", startDate);
+            param.put("end_date", endDate);
+        }
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        System.err.println(resultJson);
+        if (Check.isNull(resultJson)) {
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手素造列表数据异常:{},accountId:{}", message, accountId);
+            return;
+        }
+        JSONObject dataJson = resultJson.getJSONObject("data");
+        if (Check.isNull(dataJson)) {
+            return;
+        }
+
+
+        JSONArray details = dataJson.getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+
+        List<KuaiShouVideoGet> videoGetList = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = details.getJSONObject(i);
+            if (Check.isNull(detailJson)) {
+                continue;
+            }
+            KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
+            String photo_id = detailJson.getString("photo_id");
+            videoGet.setId(accountId + photo_id);
+            videoGet.setAccountId(accountId);
+            videoGet.setCoverUrl(detailJson.getString("cover_url"));
+            videoGet.setPhotoId(photo_id);
+            videoGet.setPhotoName(detailJson.getString("photo_name"));
+            videoGet.setStatDate(detailJson.getDate("upload_time"));
+            String signature = detailJson.getString("signature");
+            videoGet.setSignature(signature);
+            Integer source = detailJson.getInteger("source");
+            if (source == 2) {
+                videoGet.setChannelType(1);
+            } else {
+                videoGet.setChannelType(0);
+            }
+            Integer new_status = detailJson.getInteger("new_status");
+            if (new_status == 1) {
+                videoGet.setStatus(0);
+            } else {
+                videoGet.setStatus(1);
+            }
+            videoGet.setUrl(detailJson.getString("url"));
+            Integer width = detailJson.getInteger("width");
+            videoGet.setWidth(width);
+            Integer height = detailJson.getInteger("height");
+            videoGet.setHeight(height);
+            Integer type = MaterialEnum.getTypeBySize(width, height);
+            if (!Check.isNull(type)) {
+                videoGet.setMaterialType(type);
+            }
+            videoGetList.add(videoGet);
+            Thread thread = new Thread() {
+                @Override
+                public void run() {
+                    videoGetService.getKeyFrame(token, accountId, signature, photo_id);
+                }
+            };
+            thread.start();
+        }
+        if (!Check.isNull(videoGetList)) {
+            videoGetService.replaceBatch(videoGetList);
+        }
+
+        getSuZaoList(token, accountId, page + 1, startDate, endDate);
+
+    }*/
+
     @Autowired
     private IMaterialCutFrameService cutFrameService;
     private static ExecutorService executorService = Executors.newFixedThreadPool(10);
@@ -2884,6 +3066,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             JSONObject param = new JSONObject();
             param.put("advertiser_id", accountId);
             param.put("page_size", 200);
+
+           /* Map<String, Object> deleteMap = new HashMap<>();
+            deleteMap.put("account_id", accountId);
+            deleteMap.put("campaign_id", campaignId);
+            creativeService.removeByMap(deleteMap);*/
             QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
             groupQueryWrapper.eq("account_id", accountId);
             groupQueryWrapper.eq("campaign_id", campaignId);
@@ -2998,6 +3185,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             e.printStackTrace();
 
         }
+
+
     }
 
     /**
@@ -3182,7 +3371,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                             appList.setAppId(dataJson.getLong("app_id"));
                             appList.setAppVersion(dataJson.getString("app_version"));
                             appList.setAppName(dataJson.getString("app_name"));
-                            appList.setAppPrivacyUrl(dataJson.getString("app_privacy_url"));
                             appList.setAppIconUrl(dataJson.getString("app_icon_url"));
                             appList.setImageToken(dataJson.getString("image_token"));
                             appList.setPackageName(dataJson.getString("package_name"));

+ 3 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/WarningOperationServiceImpl.java

@@ -68,7 +68,7 @@ public class WarningOperationServiceImpl implements IWarningOperationService {
         warningOperationLog.setUserId(userId);
         warningOperationLog.setWarningType(1);
         warningOperationLogService.save(warningOperationLog);
-        log.info("暂停组成功,accountId:{},unitId:{}", advertiserId, unitId);
+        log.info("出价方式预警,暂停组成功,accountId:{},unitId:{}", advertiserId, unitId);
         try {
             String text = messageTemplate.getKuaiShouBidTypeMessage(projectName, advertiserId, unitId, unit_name);
 
@@ -97,6 +97,7 @@ public class WarningOperationServiceImpl implements IWarningOperationService {
         try {
             String text = messageTemplate.getKuaiShouBidMessage(projectName, advertiserId, unitId, unit_name);
             sendMessageService.sendMessage(userId, text);
+
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -111,6 +112,7 @@ public class WarningOperationServiceImpl implements IWarningOperationService {
         warningOperationLog.setUserId(userId);
         warningOperationLog.setWarningType(2);
         warningOperationLogService.save(warningOperationLog);
+        log.info("出价过高预警,暂停组成功,accountId:{},unitId:{}", advertiserId, unitId);
 
     }
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelCreateStrategyMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.channel.mapper.KuaishouChannelCreateStrategyMapper">
 
     <select id="queryAllIdByAccountId" resultType="java.lang.Long">
-        SELECT *
+        SELECT id
         FROM (SELECT id
               FROM ctop_kuaishou_channel_create_strategy
               WHERE account_id = #{accountId}

+ 3 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml

@@ -198,7 +198,7 @@
         WHERE t1.strategy_id IN
         <foreach collection="strategys" item="item" separator=","
                  open="(" close=")">
-            #{item.id}
+            #{item}
         </foreach>
             AND t1.state = 1
             AND t1.channel_state = 1
@@ -206,21 +206,20 @@
             AND is_cycle = 1
           </if>
             AND app_id in (
-                SELECT app_id FROM ctop_kuaishou_channel_app_info where app_name = #{appName}
+                SELECT DISTINCT app_id FROM ctop_kuaishou_channel_app_info where app_name = #{appName}  and app_id is not null
             )
             AND t1.usage_times = #{usageTimes}
             and t1.usage_level = #{usageLevel}
             ORDER BY t1.create_time,t1.channel_number
     </select>
 
-
     <select id="queryUsedLevel" resultType="java.lang.Integer">
         SELECT usage_times
         FROM `ctop_kuaishou_channel`
         where strategy_id in
         <foreach collection="strategys" item="item" separator=","
                  open="(" close=")">
-            #{item.id}
+            #{item}
         </foreach>
         AND state = 1
         group by usage_times

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java

@@ -32,7 +32,7 @@ public interface IKuaishouChannelService extends IService<KuaishouChannel> {
 
     Result<Object> queryChannelLevel(JSONObject request);
 
-    void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId, Integer state);
+    void callBackUpdateChannelRel(String level, String channelCode, Long accoountId, Long planId, Long groupId);
 
     KuaishouChannel queryUsedChannel(Long accountId, Long newCampaignId, String level);
 

+ 21 - 28
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java

@@ -1000,7 +1000,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
 
     @Override
     public void callBackUpdateChannelRel(String level, String channelCode, Long accountId, Long planId, Long
-            groupId, Integer state) {
+            groupId) {
         try {
             QueryWrapper<KuaishouChannel> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("account_id", accountId);
@@ -1008,33 +1008,26 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             KuaishouChannel one = this.getOne(queryWrapper);
             if (!Check.isNull(one)) {
                 one.setUpdateTime(new Date());
-                if (0 == state) {
-                    this.saveOrUpdate(one);
-                } else {
-                    QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
-                    relqueryWrapper.eq("account_id", accountId);
-                    relqueryWrapper.eq("channel_code", channelCode).orderByAsc("create_time").last("limit 1");
-                    KuaishouChannelRel rel = channelRelService.getOne(relqueryWrapper);
-                    if (!Check.isNull(rel)) {
-                        if (!Check.isNull(rel.getCampaignId())) {
-                            rel.setId(null);
-                        }
-                        rel.setCampaignId(planId);
-                        rel.setUnitId(groupId);
-                        rel.setUpdateTime(new Date());
-                        channelRelService.save(rel);
-                        if ("plan".equals(level)) {
-                            Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
-                            one.setUsageTimes(usageTimes);
-//                            if (usageTimes > one.getHaveCycleTimes()) {
-//                                one.setHaveCycleTimes(usageTimes);
-//                            }
-                            this.saveOrUpdate(one);
-                        } else if ("group".equals(level)) {
-                            Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
-                            one.setUsageTimes(usageTimes);
-                            this.saveOrUpdate(one);
-                        }
+                QueryWrapper<KuaishouChannelRel> relqueryWrapper = new QueryWrapper<>();
+                relqueryWrapper.eq("account_id", accountId);
+                relqueryWrapper.eq("channel_code", channelCode).orderByAsc("create_time").last("limit 1");
+                KuaishouChannelRel rel = channelRelService.getOne(relqueryWrapper);
+                if (!Check.isNull(rel)) {
+                    if (!Check.isNull(rel.getCampaignId())) {
+                        rel.setId(null);
+                    }
+                    rel.setCampaignId(planId);
+                    rel.setUnitId(groupId);
+                    rel.setUpdateTime(new Date());
+                    channelRelService.save(rel);
+                    if ("plan".equals(level)) {
+                        Integer usageTimes = channelRelService.queryUsePlanCount(accountId, channelCode);
+                        one.setUsageTimes(usageTimes);
+                        this.saveOrUpdate(one);
+                    } else if ("group".equals(level)) {
+                        Integer usageTimes = channelRelService.queryUseGroupCount(accountId, channelCode);
+                        one.setUsageTimes(usageTimes);
+                        this.saveOrUpdate(one);
                     }
                 }
             }

+ 2 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/DocumentLibraryMapper.java

@@ -23,7 +23,8 @@ public interface DocumentLibraryMapper {
 
     List<String> getDataByAccountId(@Param("accountId") String accountId, @Param("copyWriterId") String copyWriterId);
 
-    List<Map<String,String>> getDocumentByAccountId(@Param("accountId") String accountId, @Param("copyWriterId") String copyWriterId);
+    List<Map<String, String>> getDocumentByAccountId(@Param("accountId") String accountId, @Param("copyWriterId") String copyWriterId);
 
     void insertBatch(@Param("list") List<DocumentLibraryInfo> list);
+
 }

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/mapper/xml/DocumentLibraryMapper.xml

@@ -4,12 +4,12 @@
 
 
     <insert id="saveDocumentLibrary" parameterType="cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo">
-        insert into ctop_document_library (copy_writer_id,copy_writer,account_id,status,create_time) values
+        replace into ctop_document_library (copy_writer_id,copy_writer,account_id,status,create_time) values
         (#{copyWriterId},#{copyWriter},#{accountId},#{status},#{createTime})
     </insert>
 
     <insert id="insertBatch" parameterType="cn.com.ctop.kuaishou.modules.document.entity.DocumentLibraryInfo">
-        insert into ctop_document_library
+        replace into ctop_document_library
         (copy_writer_id,copy_writer,account_id,status,create_time)
         values
         <foreach collection="list" item="video" separator=",">

+ 18 - 12
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/document/service/impl/DocumentLibraryServiceImpl.java

@@ -17,6 +17,7 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.MD5Util;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -61,20 +62,25 @@ public class DocumentLibraryServiceImpl implements DocumentLibraryService {
             return result;
         }
         try {
-            if (accountIds != null && !documentList.isEmpty() && !accountIds.isEmpty()) {
+            if (accountIds != null && !documentList.isEmpty() && accountIds != null && !accountIds.isEmpty()) {
 
+                List<DocumentLibraryInfo> list = new ArrayList<>();
                 for (String docu : documentList) {
-                    DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
-                    documentLibraryInfo.setCopyWriter(docu);
-                    documentLibraryInfo.setCopyWriterId(UUID.randomUUID().toString());
-                    documentLibraryInfo.setCreateTime(formatter.format(new Date()));
-                    documentLibraryInfo.setStatus(0);
                     if (docu != null && docu != "" && docu.length() <= 30) {
                         for (String accountId : accountIds) {
+                            DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
+                            documentLibraryInfo.setCopyWriter(docu);
+                            documentLibraryInfo.setCreateTime(formatter.format(new Date()));
+                            documentLibraryInfo.setStatus(0);
                             documentLibraryInfo.setAccountId(accountId);
-                            documentLibraryMapper.saveDocumentLibrary(documentLibraryInfo);
+                            documentLibraryInfo.setCopyWriterId(MD5Util.getMd5(accountId + docu));
+                            list.add(documentLibraryInfo);
                         }
                     }
+
+                    if (list.size() > 0) {
+                        documentLibraryMapper.insertBatch(list);
+                    }
                 }
             }
             result.success("添加成功");
@@ -238,7 +244,7 @@ public class DocumentLibraryServiceImpl implements DocumentLibraryService {
         }
         ExportExcelUtils eeu = new ExportExcelUtils();
         JSONArray array = new JSONArray();
-        for (int i = 1; i <= rows + 1; i++) {
+        for (int i = 0; i <= rows + 1; i++) {
             Row row = sheet.getRow(i);
             if (row != null) {
                 String value = eeu.getCellValue(row.getCell(0));
@@ -252,20 +258,20 @@ public class DocumentLibraryServiceImpl implements DocumentLibraryService {
     }
 
     @Override
-    public void insertBatch(String description,Long accountId) {
+    public void insertBatch(String description, Long accountId) {
         JSONArray array = JSONArray.parseArray(description);
         List<DocumentLibraryInfo> list = new ArrayList<>();
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         for (int i = 0; i < array.size(); i++) {
             DocumentLibraryInfo documentLibraryInfo = new DocumentLibraryInfo();
-            documentLibraryInfo.setCopyWriter(array.getString(i).trim());
-            documentLibraryInfo.setCopyWriterId(UUID.randomUUID().toString());
+            String copyWriter = array.getString(i).trim();
+            documentLibraryInfo.setCopyWriter(copyWriter);
+            documentLibraryInfo.setCopyWriterId(MD5Util.getMd5(accountId + copyWriter));
             documentLibraryInfo.setCreateTime(formatter.format(new Date()));
             documentLibraryInfo.setStatus(0);
             documentLibraryInfo.setAccountId(accountId.toString());
             list.add(documentLibraryInfo);
         }
-
         documentLibraryMapper.insertBatch(list);
     }
 }

+ 17 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AiKuaishouAdvertiserStrategyController.java

@@ -6,12 +6,16 @@ import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountAutoStrategy;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountAutoStrategyService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
 import cn.com.ctop.kuaishou.modules.ai.service.IKuaiShouAppMultipleBidsService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouVideoRelateCreativesService;
+import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelItems;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -55,6 +59,9 @@ public class AiKuaishouAdvertiserStrategyController {
     @Autowired
     private IKuaiShouAppMultipleBidsService kuaiShouAppMultipleBidsService;
 
+    @Autowired
+    private IAiKuaishouAccountAutoStrategyService aiKuaishouAccountAutoStrategyService;
+
     /**
      * 分页列表查询
      *
@@ -66,9 +73,9 @@ public class AiKuaishouAdvertiserStrategyController {
      */
     @GetMapping(value = "/list")
     public Result<PageInfo<AiKuaishouAdvertiserStrategy>> queryPageList(AiKuaishouAdvertiserStrategy aiKuaishouAdvertiserStrategy,
-                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                      HttpServletRequest req) {
+                                                                        @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                        HttpServletRequest req) {
         Result<PageInfo<AiKuaishouAdvertiserStrategy>> result = new Result<>();
         String roleCode = sysRoleService.getRoleCodeByUserId(aiKuaishouAdvertiserStrategy.getUserId());
         if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
@@ -188,6 +195,13 @@ public class AiKuaishouAdvertiserStrategyController {
         if (status != 0) {
             status = 1;
         }
+        QueryWrapper<AiKuaishouAccountAutoStrategy> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", aiKuaishouAdvertiserStrategyEntity.getAccountId()).last("limit 1");
+        AiKuaishouAccountAutoStrategy one = aiKuaishouAccountAutoStrategyService.getOne(queryWrapper);
+        if (null != one && one.getStatus() == status && status == 1) {
+            ResultMapUtils.setResultMap(result, StatusCode.KUAISHOU_AUTO_STRATEGY_UPDATE);
+            return result;
+        }
         aiKuaishouAdvertiserStrategyEntity.setStatus(status);
         aiKuaishouAdvertiserStrategyService.updateById(aiKuaishouAdvertiserStrategyEntity);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);

+ 5 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.mapper.ProjectMapper;
 import cn.com.ctop.common.module.mapper.UserCompanyMapper;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.Check;
+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;
@@ -305,7 +306,8 @@ public class ProjectController {
 
     @ApiOperation(value = "项目-添加", notes = "项目-添加")
     @PostMapping(value = "/add")
-    public Result<Project> add(@RequestBody Project project) {
+    public Result<Project> add(@RequestBody JSONObject data) {
+        Project project = JSONObject.parseObject(data.toJSONString(), Project.class);
         Result<Project> result = new Result<>();
         try {
          /*   String advertiserId = project.getAdvertiserId();
@@ -372,7 +374,8 @@ public class ProjectController {
      */
     @ApiOperation(value = "项目-编辑", notes = "项目-编辑")
     @PutMapping(value = "/edit")
-    public Result<Project> edit(@RequestBody Project project) {
+    public Result<Project> edit(@RequestBody JSONObject data) {
+        Project project = JSONObject.parseObject(data.toJSONString(), Project.class);
         Result<Project> result = new Result<>();
         SysUser sysUser = sysUserService.getById(project.getResponsibleId());
         if (!Check.isNull(sysUser)) {

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

@@ -1,4 +1,4 @@
-/*
+
 package org.jeecg.modules.ctop.controller;
 
 import cn.com.ctop.common.module.entity.*;
@@ -37,6 +37,8 @@ import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Param;
@@ -58,11 +60,9 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
-
-*/
 /**
  * @author jeecg-boot
- *//*
+ */
 
 @RestController
 @RequestMapping("/test")
@@ -993,22 +993,7 @@ public class TestController {
 
     }
 
-    @GetMapping("checkFile")
-    public Map<String, Object> checkFile() {
-        String nowDate = DateUtils.getDate("yyyy-MM-dd");
-        String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -1);
-        //  查询快手token
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
-        if (null == tokens || tokens.size() <= 0) {
-            log.info("定时获取快手数据异常:未获取到可用的token");
-        }
-        for (CtopOauthToken token : tokens) {
-            dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate);
-        }
-        Map<String, Object> result = new HashMap<>();
-        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
-        return result;
-    }
+
 
 
     @GetMapping("loadBytedanceHistoryData")
@@ -1128,7 +1113,6 @@ public class TestController {
     }
 
 
-
     @GetMapping("/bytedance/effectVideo/get")
     public Map<String, Object> effectVideoGet(String date) {
         Map<String, Object> result = new HashMap<>();
@@ -1313,7 +1297,7 @@ public class TestController {
         return result;
     }
 
-    */
+
 /**
      * 勿动勿删,煜一人群报表数据拉取接口。
      *
@@ -1357,22 +1341,23 @@ public class TestController {
     static CountDownLatch countDownLatch = null;
     @Resource
     AiKuaishouUnitLevelOperationRecordMapper kuaishouUnitLevelOperationRecordMapper;
+
     @GetMapping(value = "/getAudienceDataNew")
-    public void getAudienceData(@RequestParam(required = false,defaultValue = "2019-01-01") String date) throws Exception {
+    public void getAudienceData(@RequestParam(required = false, defaultValue = "2019-01-01") String date) throws Exception {
         int page = 1;
         int pageSize = 2000;
-        if(date.equals("2019-01-01")){
+        if (date.equals("2019-01-01")) {
             date = DateUtils.formatDate(DateUtils.addDay(DateUtils.getNowDate(), -1), "yyyy-MM-dd");
         }
         List<CtopOauthToken> tokens = tokenService.getByProjectId(458L);    //淘特项目
         for (CtopOauthToken token : tokens) {
             Date startDate = DateUtils.addDay(DateUtils.getNowDate(), -1);
-            if(startDate.after(token.getAccessTokenExpiresIn())){   //过期跳过
+            if (startDate.after(token.getAccessTokenExpiresIn())) {   //过期跳过
                 continue;
             }
             Date enDate = DateUtils.addDay(startDate, -30);
             List<AiKuaishouUnitLevelOperationRecord> planIdsAndUnitIds = kuaishouUnitLevelOperationRecordMapper.selectAllByAccountIdAndDate(token.getAccountId(), enDate, startDate);
-            if(Check.isNull(planIdsAndUnitIds)){
+            if (Check.isNull(planIdsAndUnitIds)) {
                 continue;
             }
             countDownLatch = new CountDownLatch(planIdsAndUnitIds.size());
@@ -1493,5 +1478,13 @@ public class TestController {
             log.info("数据更新完成");
         }
     }
-}
 */
+    @GetMapping("checkUnitBid")
+    public Result checkUnitBid(Long accountId) throws Exception {
+        Date nowDate = new Date();
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        kuaishouInterfaceService.getGroupList(token, nowDate, nowDate);
+        return Result.ok("success");
+    }
+}
+

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/TransferAccountServiceImpl.java

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.service.ISupplierListService;
 import cn.com.ctop.common.module.service.ISysUserService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.ctop.entity.TransferAccount;
@@ -136,6 +137,12 @@ public class TransferAccountServiceImpl extends ServiceImpl<TransferAccountMappe
             if (!Check.isNullMap(supplierMap)) {
                 project.setSupplierCode_dictText(supplierMap.get(project.getSupplierCode()));
             }
+            if (!Check.isNull(project.getOcpxActionType())&&!project.getOcpxActionType().isEmpty()) {
+                project.setOcpxActionTypeArray(JSONArray.parseArray(project.getOcpxActionType()));
+            }
+            if (!Check.isNull(project.getDeepConversionType())&&!project.getDeepConversionType().isEmpty()) {
+                project.setDeepConversionTypeArray(JSONArray.parseArray(project.getDeepConversionType()));
+            }
         }
         return records;
     }