yumeng 3 年之前
父节点
当前提交
09ee2f1cf0

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

@@ -25,7 +25,7 @@ public class AiKuaishouCreateCreativeController {
     private IAiKuaishouCreateCreativeService createCreativeService;
     @Autowired
     private IAiKuaishouAdvertiserStrategyService strategyService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
     static ExecutorService kuaishouCustomCreativeSupplementExecutorService = Executors.newFixedThreadPool(3);
     static ExecutorService kuaishouProgramCreativeAutoService = Executors.newFixedThreadPool(2);
     static ExecutorService kuaishouProgramTopCreativeAutoService = Executors.newFixedThreadPool(3);
@@ -53,10 +53,7 @@ public class AiKuaishouCreateCreativeController {
                 log.error("组创建超限,accountId:{}", strategy.getAccountId());
                 throw new Exception("今日组创建已超限");
             }
-
-            executorService.submit(() ->
-                    createCreativeService.customCreativeLimit(strategy)
-            );
+            createCreativeService.customCreativeLimit(strategy);
             returnJson.put("code", 0);
             returnJson.put("message", "异步创建中");
         } catch (Exception e) {

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

@@ -5,7 +5,7 @@ import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import java.text.ParseException;
 
 public interface IAiKuaishouCreateCreativeService {
-    Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt);
+    Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt,String startTime,String endTime);
 
     void autoCreateProgramCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt);
 

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

@@ -34,6 +34,8 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @Slf4j
 @Service
@@ -80,7 +82,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      * @param videoCnt   视频数量
      */
     @Override
-    public Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt) {
+    public Long autoCreateCreative(AiKuaishouAdvertiserStrategy strategy, Integer createType, Long videoCnt, String startTime, String endTime) {
         String strategyUuid = UUID.randomUUID().toString();
         strategy.setUnitType(4);
         Long accountId = strategy.getAccountId();
@@ -91,11 +93,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         //1:获取视频信息
         kuaishouInterfaceService.getVideoList(token, DateUtils.date2Str(), DateUtils.date2Str());
-        Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + createType.toString());
-        Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + createType.toString());
-        Long now = System.currentTimeMillis();
-        String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
-        String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
+
 
         //2:判定账户是否单一应用
         Integer singleAppid = strategy.getSingleAppid();
@@ -778,20 +776,38 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (remindCnt >= 1) {
             log.info("{}组创建不足,剩余需要创建个数{},使用历史遗漏素材创建", strategy.getAccountId(), remindCnt);
             //优先创建历史遗漏素材
-            remindCnt = this.autoCreateCreative(strategy, 3, remindCnt);
+
+            Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + 3);
+            Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + 3);
+            Long now = System.currentTimeMillis();
+            String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
+            String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
+            remindCnt = this.autoCreateCreative(strategy, 3, remindCnt, startTime, endTime);
         }
         if (remindCnt >= 1) {
             log.info("{}组创建不足,剩余需要创建个数{},使用高质量素材创建", strategy.getAccountId(), remindCnt);
             //高质量素材
-            remindCnt = this.autoCreateCreative(strategy, 2, remindCnt);
+            Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + 2);
+            Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + 2);
+            Long now = System.currentTimeMillis();
+            String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
+            String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
+            remindCnt = this.autoCreateCreative(strategy, 2, remindCnt, startTime, endTime);
         }
         if (remindCnt >= 1) {
             //历史打捞素材
             log.info("{}组创建不足,剩余需要创建个数{},使用历史打捞素材创建", strategy.getAccountId(), remindCnt);
-            this.autoCreateCreative(strategy, 4, remindCnt);
+            Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + 4);
+            Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + 4);
+            Long now = System.currentTimeMillis();
+            String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
+            String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
+            this.autoCreateCreative(strategy, 4, remindCnt, startTime, endTime);
         }
     }
 
+    static ExecutorService executorService = Executors.newFixedThreadPool(3);
+
     @Override
     public void customCreativeLimit(AiKuaishouAdvertiserStrategy strategy) {
         Long unitNum = strategy.getCustomUnitCnt();
@@ -810,7 +826,15 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         long remindCnt = unitNum - unitCreateCnt;
         if (remindCnt >= 1) {
             log.info("{}组创建不足,剩余需要创建个数{},开始上新素材创建", strategy.getAccountId(), remindCnt);
-            this.autoCreateCreative(strategy, 1, remindCnt);
+            Long timeStart = KuaishouCreativeMatTypeEnum.getStartTimeByType(strategy.getUnitType().toString() + 1);
+            Long timeEnd = KuaishouCreativeMatTypeEnum.getEndTimeByType(strategy.getUnitType().toString() + 1);
+            Long now = System.currentTimeMillis();
+            String startTime = DateUtils.formatDateTime(now + timeStart * 60 * 1000L);
+            String endTime = DateUtils.formatDateTime(now + timeEnd * 60 * 1000L);
+            executorService.submit(() ->
+                    autoCreateCreative(strategy, 1, remindCnt, startTime, endTime)
+            );
+
         }
     }