|
@@ -2,7 +2,7 @@ package cn.com.ctop.job.kuaishou.handler;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouAccountMaterialOverviewService;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouGroupDailyReportService;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouNewlyService;
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
@@ -11,8 +11,6 @@ import org.jeecg.common.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
@@ -22,42 +20,66 @@ public class KuaishouDingPanCleanJob {
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
@Autowired
|
|
|
- private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private IEtlKuaiShouGroupDailyReportService etlKuaiShouGroupDailyReportService;
|
|
|
+ @Autowired
|
|
|
+ private IEtlKuaiShouAccountMaterialOverviewService accountMaterialOverviewService;
|
|
|
|
|
|
@Autowired
|
|
|
private IEtlKuaiShouNewlyService newlyService;
|
|
|
|
|
|
|
|
|
static ExecutorService executorService = Executors.newFixedThreadPool(8);
|
|
|
+ static ExecutorService materialExecutorService = Executors.newFixedThreadPool(8);
|
|
|
|
|
|
@XxlJob("cleanNewlyData")
|
|
|
public void cleanNewlyData() {
|
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
- newlyService.cleanNewlyData(nowDate);
|
|
|
+ String yesterdayDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
|
|
|
+ newlyService.cleanNewlyData(yesterdayDate);
|
|
|
XxlJobHelper.log("快手清洗上新计划数据完成");
|
|
|
}
|
|
|
|
|
|
|
|
|
@XxlJob("cleanGroupReport")
|
|
|
public void cleanGroupReport() throws Exception {
|
|
|
- Date getDate = new Date();
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
|
|
|
- String hour = simpleDateFormat.format(getDate);
|
|
|
- if (null != hour && "00".equals(hour)) {
|
|
|
- getDate = DateUtils.addDay(getDate, -1);
|
|
|
+ List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
|
+ if (null == tokens || tokens.isEmpty()) {
|
|
|
+ XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
|
|
|
+ XxlJobHelper.handleFail();
|
|
|
+ return;
|
|
|
}
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
+ for (CtopOauthToken token : tokens) {
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ etlKuaiShouGroupDailyReportService.getGroupReport(token.getAccountId(), token.getAccessToken(), nowDate, nowDate, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ @XxlJob("cleanAccountMaterialOverview")
|
|
|
+ public void cleanAccountMaterialOverview() throws Exception {
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
+ String yesterdayDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
|
|
|
List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
|
if (null == tokens || tokens.isEmpty()) {
|
|
|
XxlJobHelper.log("定时获取快手数据异常:未获取到可用的token");
|
|
|
XxlJobHelper.handleFail();
|
|
|
return;
|
|
|
}
|
|
|
- String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
- tokens.forEach(token -> executorService.submit(() -> etlKuaiShouGroupDailyReportService.getGroupReport(token.getAccountId(), token.getAccessToken(), nowDate, nowDate, 1)));
|
|
|
+ for (CtopOauthToken token : tokens) {
|
|
|
+ materialExecutorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ accountMaterialOverviewService.cleanAccountMaterialOverview(token.getAccountId(), yesterdayDate);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|