|
@@ -12,6 +12,7 @@ import org.quartz.JobExecutionException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -27,8 +28,11 @@ public class KuaishouDailyLoadFileJob implements Job {
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
static ExecutorService executorService = null;
|
|
|
+ static CountDownLatch countDownLatch = null;
|
|
|
@Autowired
|
|
|
private IKuaiShouDailyReportTaskService dailyReportTaskService;
|
|
|
+ @Autowired
|
|
|
+ private IKuaiShouDailyReportTaskService kuaiShouDailyReportTaskService;
|
|
|
|
|
|
@Override
|
|
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
@@ -44,14 +48,28 @@ public class KuaishouDailyLoadFileJob implements Job {
|
|
|
return;
|
|
|
}
|
|
|
executorService = Executors.newFixedThreadPool(3);
|
|
|
+ countDownLatch = new CountDownLatch(tokens.size());
|
|
|
for (CtopOauthToken token : tokens) {
|
|
|
executorService.submit(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate);
|
|
|
+ try {
|
|
|
+ dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ countDownLatch.countDown();
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ try {
|
|
|
+ countDownLatch.await();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ kuaiShouDailyReportTaskService.formatCreativeDailyReportData(null, nowDate);
|
|
|
+ executorService.shutdown();
|
|
|
}
|
|
|
};
|
|
|
thread.start();
|