|
|
@@ -0,0 +1,79 @@
|
|
|
+package cn.com.ctop.job.bytedance.handler;
|
|
|
+
|
|
|
+import cn.com.ctop.job.bytedance.data.mapper.BytedanceCdpProjectMapper;
|
|
|
+import cn.com.ctop.job.bytedance.data.service.IBytedanceCdpProjectService;
|
|
|
+import cn.com.ctop.job.bytedance.data.service.ICustomReportService;
|
|
|
+import cn.com.ctop.job.bytedance.data.utils.DateUtils;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 全域
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class BytedanceUniProjectJob {
|
|
|
+ @Autowired
|
|
|
+ private BytedanceCdpProjectMapper bytedanceCdpProjectMapper;
|
|
|
+ @Autowired
|
|
|
+ private ICustomReportService customReportService;
|
|
|
+ @Autowired
|
|
|
+ private IBytedanceCdpProjectService cdpProjectService;
|
|
|
+ private static final ExecutorService projectExecutorService = Executors.newFixedThreadPool(6);
|
|
|
+
|
|
|
+ @XxlJob("yesterdayUniReportDaily")
|
|
|
+ public void getYesterdayUniReportDaily() {
|
|
|
+ String yesterday = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
|
|
|
+ List<JSONObject> jsonObjects = bytedanceCdpProjectMapper.queryUniCostAdvertiserIds(yesterday.replace("-", ""), yesterday.replace("-", ""));
|
|
|
+ for (JSONObject jsonObject : jsonObjects) {
|
|
|
+ Long advertiserId = jsonObject.getLong("advertiser_id");
|
|
|
+ String access_token = jsonObject.getString("access_token");
|
|
|
+ projectExecutorService.submit(() -> customReportService.getCustomReport("uni_project_daily", advertiserId, access_token, yesterday, yesterday, 1, null));
|
|
|
+ projectExecutorService.submit(() -> customReportService.getCustomReport("uni_project_material_daily", advertiserId, access_token, yesterday, yesterday, 1, null));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @XxlJob("yesterdayUniProjectList")
|
|
|
+ public void getYesterdayUniProjectList() {
|
|
|
+ String yesterday = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
|
|
|
+ List<JSONObject> jsonObjects = bytedanceCdpProjectMapper.queryUniCostProjectIds(yesterday.replace("-", ""), yesterday.replace("-", ""));
|
|
|
+ HashSet<Long> submitAdvertiserIds = new HashSet<>();
|
|
|
+ for (JSONObject jsonObject : jsonObjects) {
|
|
|
+ Long advertiserId = jsonObject.getLong("advertiser_id");
|
|
|
+ Long projectId = jsonObject.getLong("cdp_project_id");
|
|
|
+ projectExecutorService.submit(() -> cdpProjectService.getOcProjectMaterial("OTHER", advertiserId, projectId, null, 1));
|
|
|
+ if (!submitAdvertiserIds.contains(advertiserId)) {
|
|
|
+ submitAdvertiserIds.add(advertiserId);
|
|
|
+ projectExecutorService.submit(() -> cdpProjectService.getUniProjectList(advertiserId, null, null, null, null, null, 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @XxlJob("todayUniProjectList")
|
|
|
+ public void getTodayUniProjectList() {
|
|
|
+ String today = DateUtils.getToday();
|
|
|
+ List<JSONObject> jsonObjects = bytedanceCdpProjectMapper.queryUniCostProjectIds(today.replace("-", ""), today.replace("-", ""));
|
|
|
+ HashSet<Long> submitAdvertiserIds = new HashSet<>();
|
|
|
+ for (JSONObject jsonObject : jsonObjects) {
|
|
|
+ Long advertiserId = jsonObject.getLong("advertiser_id");
|
|
|
+ Long projectId = jsonObject.getLong("cdp_project_id");
|
|
|
+ projectExecutorService.submit(() -> cdpProjectService.getOcProjectMaterial("OTHER", advertiserId, projectId, null, 1));
|
|
|
+ if (!submitAdvertiserIds.contains(advertiserId)) {
|
|
|
+ submitAdvertiserIds.add(advertiserId);
|
|
|
+ projectExecutorService.submit(() -> cdpProjectService.getUniProjectList(advertiserId, null, null, null, null, null, 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|