|
@@ -2,8 +2,8 @@ package org.jeecg.modules.ctop.job;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
-import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
|
+import lombok.SneakyThrows;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.quartz.Job;
|
|
import org.quartz.Job;
|
|
@@ -11,13 +11,14 @@ import org.quartz.JobExecutionContext;
|
|
import org.quartz.JobExecutionException;
|
|
import org.quartz.JobExecutionException;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
-public class KuaishouCreativeLoadJob implements Job {
|
|
|
|
|
|
+public class KuaishouNowDateCreativeJob implements Job {
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -25,30 +26,26 @@ public class KuaishouCreativeLoadJob implements Job {
|
|
|
|
|
|
static ExecutorService executorService = null;
|
|
static ExecutorService executorService = null;
|
|
|
|
|
|
- /**
|
|
|
|
- * 获取全量创意
|
|
|
|
- *
|
|
|
|
- * @param jobExecutionContext
|
|
|
|
- * @throws JobExecutionException
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
|
+
|
|
|
|
+
|
|
Thread thread = new Thread() {
|
|
Thread thread = new Thread() {
|
|
|
|
+ @SneakyThrows
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
- //增加接口的开始和结束日期
|
|
|
|
- Date startDate = DateUtils.addDay(new Date(), -1);
|
|
|
|
- Date endDate = new Date();
|
|
|
|
//1:查询当日数据
|
|
//1:查询当日数据
|
|
- List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_KUAISHOU);
|
|
|
|
- executorService = Executors.newFixedThreadPool(4);
|
|
|
|
|
|
+ Date endDate = DateUtils.getDate();
|
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
|
|
|
|
+ SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date startDate = sim.parse(anotherDay);
|
|
|
|
+ List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
|
|
+ executorService = Executors.newFixedThreadPool(5);
|
|
tokens.forEach(token -> {
|
|
tokens.forEach(token -> {
|
|
executorService.submit(new Runnable() {
|
|
executorService.submit(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
try {
|
|
try {
|
|
- //1:获取全量创意数据
|
|
|
|
kuaishouInterfaceService.getCreativeList(token, startDate, endDate);
|
|
kuaishouInterfaceService.getCreativeList(token, startDate, endDate);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -59,8 +56,11 @@ public class KuaishouCreativeLoadJob implements Job {
|
|
});
|
|
});
|
|
log.info("快手物料数据同步完成");
|
|
log.info("快手物料数据同步完成");
|
|
}
|
|
}
|
|
|
|
+
|
|
};
|
|
};
|
|
thread.start();
|
|
thread.start();
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|