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