|
@@ -1,6 +1,16 @@
|
|
package cn.com.ctop.job.kuaishou.controller;
|
|
package cn.com.ctop.job.kuaishou.controller;
|
|
|
|
|
|
-import cn.com.ctop.job.kuaishou.data.service.*;
|
|
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IAdUnitReportService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IKuaishouAccountReportDailyService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IKuaishouAccountReportHourlyService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IKuaishouCampaignReportDailyService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IKuaishouMaterialVideoReportDailyService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IKuaishouUnitAudienceAgeReportDailyService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IKuaishouUnitReportDailyService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IKuaishouUnitReportHourlyService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IKuaishouVideoListService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.IOauthTokenService;
|
|
|
|
+import cn.com.ctop.job.kuaishou.data.service.impl.AdUnitReportServiceImpl;
|
|
import cn.com.ctop.job.kuaishou.data.utils.Check;
|
|
import cn.com.ctop.job.kuaishou.data.utils.Check;
|
|
import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
|
|
import cn.com.ctop.job.kuaishou.data.utils.DateUtils;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -8,12 +18,21 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.SneakyThrows;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
-
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* zian Y
|
|
* zian Y
|
|
@@ -37,6 +56,10 @@ public class KuaishouController {
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaishouUnitReportHourlyService unitReportHourlyService;
|
|
private IKuaishouUnitReportHourlyService unitReportHourlyService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouAccountReportDailyService kuaishouAccountReportDailyService;
|
|
|
|
+
|
|
|
|
+ private static ExecutorService dailyExecutorService = Executors.newFixedThreadPool(10);
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "根据账户获取视频素材-账户下全部视频素材", notes = "根据账户获取视频素材-账户下全部视频素材")
|
|
@ApiOperation(value = "根据账户获取视频素材-账户下全部视频素材", notes = "根据账户获取视频素材-账户下全部视频素材")
|
|
@@ -56,37 +79,42 @@ public class KuaishouController {
|
|
|
|
|
|
@ApiOperation(value = "根据账户获取视频素材-账户下全部视频素材", notes = "根据账户获取视频素材-账户下全部视频素材")
|
|
@ApiOperation(value = "根据账户获取视频素材-账户下全部视频素材", notes = "根据账户获取视频素材-账户下全部视频素材")
|
|
@GetMapping(value = "/KuaishouUnitAudienceReport")
|
|
@GetMapping(value = "/KuaishouUnitAudienceReport")
|
|
- public void KuaishouUnitAudienceReportJob(String startDate, String endDate) throws Exception {
|
|
|
|
- List<String> allDates = DateUtils.getAllDatesOfTwoTimes(startDate, endDate);
|
|
|
|
-
|
|
|
|
- for (String date : allDates) {
|
|
|
|
- List<Long> accountIds = unitReportDailyService.selectAccountIdsByTime(date);
|
|
|
|
- for (Long accountId : accountIds) {
|
|
|
|
- String token = tokenService.getByAccountId(accountId);
|
|
|
|
- if (Check.isNull(token)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- //广告计划 ID 集
|
|
|
|
- List<JSONObject> campaignArray = unitReportDailyService.selectPlanIdsByAccountIdAndTime(accountId, date);
|
|
|
|
- if (Check.isNull(campaignArray)) {
|
|
|
|
- log.error("未查询到计划ID");
|
|
|
|
|
|
+ public void KuaishouUnitAudienceReportJob(String date) throws Exception {
|
|
|
|
+
|
|
|
|
+ List<JSONObject> tokens = tokenService.getByProjectId(458L); //淘特项目
|
|
|
|
+// String date = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.getNowDate("yyyy-MM-dd"), -1);
|
|
|
|
+ Date enDate = DateUtils.addDay(DateUtils.getNowDate(), -1);
|
|
|
|
+ for (JSONObject t : tokens) {
|
|
|
|
+ Long accountId = t.getLong("accountId");
|
|
|
|
+ String token = t.getString("accessToken");
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ log.error("此账户未获取到相关token,accountId:{}", accountId);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //过期跳过
|
|
|
|
+ if (enDate.after(t.getDate("accessTokenExpiresIn"))) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //广告计划 ID 集
|
|
|
|
+ List<JSONObject> campaignArray = unitReportDailyService.selectPlanIdsByAccountIdAndTime(accountId, date);
|
|
|
|
+ if (Check.isNull(campaignArray)) {
|
|
|
|
+ log.error("未查询到计划ID");
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //广告组 ID 集
|
|
|
|
+ for (JSONObject obj : campaignArray) {
|
|
|
|
+ Long campaignId = obj.getLong("campaignId");
|
|
|
|
+ List<Long> unitIds = unitReportDailyService.selectUnitIdsByAccountIdAndTime(accountId, campaignId, date);
|
|
|
|
+ if (Check.isNull(unitIds)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- //广告组 ID 集
|
|
|
|
- for (JSONObject obj : campaignArray) {
|
|
|
|
- Long campaignId = obj.getLong("campaignId");
|
|
|
|
- List<Long> unitIds = unitReportDailyService.selectUnitIdsByAccountIdAndTime(accountId, campaignId, date);
|
|
|
|
- if (Check.isNull(unitIds)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (unitIds.size() > 59) {
|
|
|
|
- List<List<Long>> unitIdArray = Lists.partition(unitIds, 59);
|
|
|
|
- for (List<Long> list : unitIdArray) {
|
|
|
|
- unitReportDailyService.standardCrowdAnalysisReport(accountId, token, date, campaignId, list);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- unitReportDailyService.standardCrowdAnalysisReport(accountId, token, date, campaignId, unitIds);
|
|
|
|
|
|
+ if (unitIds.size() > 59) {
|
|
|
|
+ List<List<Long>> unitIdArray = Lists.partition(unitIds, 59);
|
|
|
|
+ for (List<Long> list : unitIdArray) {
|
|
|
|
+ unitReportDailyService.standardCrowdAnalysisReport(accountId, token, date, campaignId, list);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ unitReportDailyService.standardCrowdAnalysisReport(accountId, token, date, campaignId, unitIds);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -94,16 +122,119 @@ public class KuaishouController {
|
|
|
|
|
|
@ApiOperation(value = "获取快手当天-广告组信息、组时报", notes = "更新快手当天-广告组信息、组时报")
|
|
@ApiOperation(value = "获取快手当天-广告组信息、组时报", notes = "更新快手当天-广告组信息、组时报")
|
|
@GetMapping(value = "/getKuaishouAdUnitRealTime")
|
|
@GetMapping(value = "/getKuaishouAdUnitRealTime")
|
|
- public void getKuaishouVideoByAccountId(@RequestParam(name="accountId") long accountId) {
|
|
|
|
|
|
+ public void getKuaishouVideoByAccountId(@RequestParam(name = "accountId") long accountId) {
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
String token = tokenService.getByAccountId(accountId);
|
|
String token = tokenService.getByAccountId(accountId);
|
|
//更新 组
|
|
//更新 组
|
|
- adUnitReportService.getAdUnitReport(accountId,token, nowDate, nowDate, 1);
|
|
|
|
|
|
+ adUnitReportService.getAdUnitReport(accountId, token, nowDate, nowDate, 1);
|
|
//更新 组时报
|
|
//更新 组时报
|
|
unitReportHourlyService.getUnitReportHour(accountId, token, nowDate, nowDate, 1);
|
|
unitReportHourlyService.getUnitReportHour(accountId, token, nowDate, nowDate, 1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouUnitReportDailyService unitReportDailyService1;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouMaterialVideoReportDailyService videoReportDailyService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouCampaignReportDailyService campaignReportDailyService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private AdUnitReportServiceImpl reportService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouUnitReportDailyService unitReportDailyService2;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouAccountReportHourlyService kuaishouAccountReportHourlyService;
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/testOne")
|
|
|
|
+ public void testOne(@RequestParam(name = "accountId") long accountId) throws Exception {
|
|
|
|
+// String token = tokenService.getByAccountId(accountId);
|
|
|
|
+// List<String> list = new ArrayList<>();
|
|
|
|
+// list.add("2023-11-10");
|
|
|
|
+// list.add("2023-08-26");
|
|
|
|
+// list.add("2023-08-27");
|
|
|
|
+// String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+// String date = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -4);
|
|
|
|
+// for (String s : list) {
|
|
|
|
+// unitReportDailyService2.getUnitReportDaily(accountId, token, s, s, 1);
|
|
|
|
+ reportService.getAgentReport();
|
|
|
|
+// campaignReportDailyService.getCampaignReportDaily(accountId, token, s, s, 1);
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// videoReportDailyService.getImageReportDaily(accountId, token, date, nowDate, 1);
|
|
|
|
+
|
|
|
|
+// videoListService.getVideosByAccountId(accountId, "2023-11-01", "2023-11-09");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/testAllDate")
|
|
|
|
+ public void testAllDate() throws Exception {
|
|
|
|
+
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+
|
|
|
|
+ String yesterda = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
|
|
|
|
+
|
|
|
|
+ List<Long> accountIds = tokenService.getAllAccountIds();
|
|
|
|
+ for (Long accountId : accountIds) {
|
|
|
|
+ String token = tokenService.getByAccountId(accountId);
|
|
|
|
+ dailyExecutorService.submit(
|
|
|
|
+ new Runnable() {
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Thread.sleep(500);
|
|
|
|
+ kuaishouAccountReportDailyService
|
|
|
|
+ .getAdvertiserReportDaily(accountId, token, "2024-02-16", "2024-02-17", 1);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/testAllHour")
|
|
|
|
+ public void testAllHour() throws Exception {
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ String yesterda = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
|
|
|
|
+
|
|
|
|
+ //获取 两个日期之间的所有 日期
|
|
|
|
+ List<String> dates = DateUtils.getAllDatesOfTwoTimes("2024-02-15", nowDate);
|
|
|
|
+
|
|
|
|
+ List<Long> accountIds = tokenService.getAllAccountIds();
|
|
|
|
|
|
|
|
+ for (String date : dates) {
|
|
|
|
+ for (Long accountId : accountIds) {
|
|
|
|
+ String token = tokenService.getByAccountId(accountId);
|
|
|
|
+ dailyExecutorService.submit(
|
|
|
|
+ new Runnable() {
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Thread.sleep(500);
|
|
|
|
+ kuaishouAccountReportHourlyService
|
|
|
|
+ .getAdvertiserReportHour(accountId, token, date, date, 1);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取原生效果数据整体概览接口(数据概览、分日转化数据分布、转化漏斗)
|
|
|
|
+ *
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @GetMapping(value = "effectNativeChartReport")
|
|
|
|
+ public void effectNativeChartReport(Long accountId) throws Exception {
|
|
|
|
+ String token = tokenService.getByAccountId(Long.valueOf(accountId));
|
|
|
|
+ String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ String beforeYesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -2);
|
|
|
|
+
|
|
|
|
+ kuaishouAccountReportDailyService.effectNativeChartReport(accountId, token, beforeYesterday, beforeYesterday);
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|