|
@@ -0,0 +1,63 @@
|
|
|
+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.IEtlKuaiShouGroupDailyReportService;
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaiShouNewlyService;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+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;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class KuaishouDingPanCleanJob {
|
|
|
+ @Autowired
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private IKuaishouInterfaceService kuaishouInterfaceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEtlKuaiShouGroupDailyReportService etlKuaiShouGroupDailyReportService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IEtlKuaiShouNewlyService newlyService;
|
|
|
+
|
|
|
+
|
|
|
+ static ExecutorService executorService = Executors.newFixedThreadPool(8);
|
|
|
+
|
|
|
+ @XxlJob("cleanNewlyData")
|
|
|
+ public void cleanNewlyData() {
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
+ newlyService.cleanNewlyData(nowDate);
|
|
|
+ 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");
|
|
|
+ tokens.forEach(token -> executorService.submit(() -> etlKuaiShouGroupDailyReportService.getGroupReport(token.getAccountId(), token.getAccessToken(), nowDate, nowDate, 1)));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|