|
@@ -1,9 +1,5 @@
|
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
-import cn.com.ctop.bytedance.entity.BytedancePlanDailyReport;
|
|
|
-import cn.com.ctop.bytedance.service.IBytedancePlanDailyReportService;
|
|
|
-import cn.com.ctop.bytedance.service.IBytedancePlanHourlyReportService;
|
|
|
-import cn.com.ctop.bytedance.service.IReportService;
|
|
|
import cn.com.ctop.common.module.entity.*;
|
|
|
import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
|
import cn.com.ctop.common.module.service.*;
|
|
@@ -16,21 +12,25 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskServic
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
|
|
|
-import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
|
|
|
+import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanDailyReportService;
|
|
|
+import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanHourlyReportService;
|
|
|
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
|
|
|
+import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
-import org.jeecg.modules.ctop.service.ICleanMaterialService;
|
|
|
-import org.jeecg.modules.ctop.service.ICreateInternalService;
|
|
|
+import org.quartz.JobExecutionException;
|
|
|
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.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
@@ -44,8 +44,6 @@ import static org.jeecg.common.util.DateUtils.getAnotherDay;
|
|
|
@Slf4j
|
|
|
public class TestController {
|
|
|
@Autowired
|
|
|
- private ICreateInternalService createInternalService;
|
|
|
- @Autowired
|
|
|
private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
|
|
|
|
|
|
@Autowired
|
|
@@ -62,15 +60,12 @@ public class TestController {
|
|
|
private IMaterialTagService tagService;
|
|
|
@Autowired
|
|
|
private IMaterialImageInfoService iMaterialImageInfoService;
|
|
|
-
|
|
|
- @PostMapping(value = "/create")
|
|
|
- public Map<String, Object> authorization(@RequestBody JSONObject jsonObject) {
|
|
|
- return createInternalService.createInternal(jsonObject);
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IBytedanceReportService bytedanceReportService;
|
|
|
|
|
|
@GetMapping(value = "/t")
|
|
|
public String test() {
|
|
|
- Result<String> result = new Result<String>();
|
|
|
+ Result<String> result = new Result<>();
|
|
|
try {
|
|
|
String requestId = UUID.randomUUID().toString();
|
|
|
String img = kuaishouWebInterfaceService.qrLogin(requestId);
|
|
@@ -97,48 +92,187 @@ public class TestController {
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService oauthTokenService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IMaterialCutFrameService cutFrameService;
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/getAccountList")
|
|
|
+ public void getAccountList(String startDate, String endDate) throws JobExecutionException {
|
|
|
+ Thread thread = new Thread() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ try {
|
|
|
+ Date start = sim.parse(startDate);
|
|
|
+ Date end = sim.parse(endDate);
|
|
|
+ //1:查询当日数据
|
|
|
+ List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
|
+ if (null == tokens || tokens.size() <= 0) {
|
|
|
+ log.info("定时获取快手数据异常:未获取到可用的token");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ executorService = Executors.newFixedThreadPool(3);
|
|
|
+ tokens.forEach(token -> {
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ //1: 获取广告主信息数据
|
|
|
+ kuaishouInterfaceService.getAdvertiserReportDaily(token, start, end);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+ thread.start();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/getVideo")
|
|
|
+ public String getVideo(String startDate, String endDate) throws IOException {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+
|
|
|
+ Thread thread = new Thread() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+
|
|
|
+
|
|
|
+ QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
|
|
|
+ tokenQueryWrapper.eq("media_id", 2);
|
|
|
+ List<CtopOauthToken> list = tokenService.list(tokenQueryWrapper);
|
|
|
+
|
|
|
+ executorService = Executors.newFixedThreadPool(8);
|
|
|
+ list.forEach(token -> {
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ //获取全量视频素材数据
|
|
|
+ kuaishouInterfaceService.getVideoList(token, null, null);
|
|
|
+ // 获取图片信息数据
|
|
|
+ // kuaishouInterfaceService.getImageList(token, startDate, endDate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ log.info("快手物料数据同步完成");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ thread.start();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return "Success";
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/createCutTask")
|
|
|
+ public String createCutTask(String startDate, String endDate) throws IOException {
|
|
|
+
|
|
|
+ List<MaterialInfo> materialInfos = materialInfoService.getListByDate(startDate, endDate);
|
|
|
+ if (!Check.isNull(materialInfos)) {
|
|
|
+ for (MaterialInfo materialInfo : materialInfos) {
|
|
|
+ if (!Check.isNull(materialInfo)) {
|
|
|
+ String code = materialInfo.getCode();
|
|
|
+ QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
|
|
|
+ parameterQueryWrapper.eq("material_id", code);
|
|
|
+ parameterQueryWrapper.last("limit 1");
|
|
|
+ MaterialParameter materialParameter = parameterService.getOne(parameterQueryWrapper);
|
|
|
+ if (!Check.isNull(materialParameter)) {
|
|
|
+ cutFrameService.getCutFrame(materialInfo.getUrl(), code, materialParameter.getSecond(), materialParameter.getHeight(), materialParameter.getWidth());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return "Success";
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@GetMapping(value = "/getToken")
|
|
|
- public String getToken(Long accountId, String refreshToken, Integer agentType) {
|
|
|
- oauthTokenService.getKuaiShouRefreshToken(accountId, refreshToken, agentType);
|
|
|
+ public String getToken(Long accountId, String token, String refreshToken, Integer agentType) {
|
|
|
+ oauthTokenService.getKuaiShouRefreshToken(accountId, token, refreshToken, agentType);
|
|
|
return "Success";
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @GetMapping(value = "/getAccountReport")
|
|
|
+ public String getAccountReport(Long accountId, String startDate, String endDate) throws ParseException {
|
|
|
+ QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
|
+ oauthTokenQueryWrapper.eq("media_id", 2);
|
|
|
+ oauthTokenQueryWrapper.eq("account_id", accountId);
|
|
|
+ oauthTokenQueryWrapper.last("limit 1");
|
|
|
+ CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
|
+ SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date1 = sim.parse(startDate);
|
|
|
+ Date date2 = sim.parse(endDate);
|
|
|
+ kuaishouInterfaceService.getAdvertiserReportDaily(token, date1, date2);
|
|
|
+ return "Success";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/getAccountReportList")
|
|
|
+ public String getAccountReportList(String startDate, String endDate) {
|
|
|
+ Result<String> result = new Result<>();
|
|
|
+ try {
|
|
|
+ SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date1 = sim.parse(startDate);
|
|
|
+ Date date2 = sim.parse(endDate);
|
|
|
+
|
|
|
+ QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
|
|
|
+ tokenQueryWrapper.eq("media_id", 2);
|
|
|
+ List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(tokenQueryWrapper);
|
|
|
+ if (!Check.isNull(ctopOauthTokens)) {
|
|
|
+ for (CtopOauthToken token : ctopOauthTokens) {
|
|
|
+ kuaishouInterfaceService.getAdvertiserReportDaily(token, date1, date2);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ result.setSuccess(false);
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@GetMapping(value = "/updateCode")
|
|
|
public String updateCode() {
|
|
|
-
|
|
|
List<MaterialInfo> list = materialInfoService.list();
|
|
|
for (MaterialInfo info : list) {
|
|
|
-
|
|
|
-
|
|
|
QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
|
|
|
imageInfoQueryWrapper.eq("video_id", String.valueOf(info.getId()));
|
|
|
MaterialImageInfo updateMaterialImageInfo = new MaterialImageInfo();
|
|
|
updateMaterialImageInfo.setVideoId(info.getCode());
|
|
|
iMaterialImageInfoService.update(updateMaterialImageInfo, imageInfoQueryWrapper);
|
|
|
-
|
|
|
-
|
|
|
QueryWrapper<MaterialTag> tagQueryWrapper = new QueryWrapper<>();
|
|
|
tagQueryWrapper.eq("material_id", String.valueOf(info.getId()));
|
|
|
MaterialTag updateTag = new MaterialTag();
|
|
|
updateTag.setMaterialId(info.getCode());
|
|
|
tagService.update(updateTag, tagQueryWrapper);
|
|
|
-
|
|
|
QueryWrapper<MaterialAscription> materialAscriptionQuery = new QueryWrapper<>();
|
|
|
materialAscriptionQuery.eq("material_id", String.valueOf(info.getId()));
|
|
|
MaterialAscription updateMaterialAscription = new MaterialAscription();
|
|
|
updateMaterialAscription.setMaterialId(info.getCode());
|
|
|
ascriptionService.update(updateMaterialAscription, materialAscriptionQuery);
|
|
|
-
|
|
|
-
|
|
|
QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
|
|
|
parameterQueryWrapper.eq("material_id", String.valueOf(info.getId()));
|
|
|
MaterialParameter updateMaterialParameter = new MaterialParameter();
|
|
|
updateMaterialParameter.setMaterialId(info.getCode());
|
|
|
parameterService.update(updateMaterialParameter, parameterQueryWrapper);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
List<MaterialImageInfo> list1 = iMaterialImageInfoService.list();
|
|
|
for (MaterialImageInfo imageInfo : list1) {
|
|
@@ -169,11 +303,8 @@ public class TestController {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
return "SUCCESS";
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -200,7 +331,7 @@ public class TestController {
|
|
|
|
|
|
@GetMapping(value = "/getHistoryData")
|
|
|
public String getHistoryData() {
|
|
|
- Result<String> result = new Result<String>();
|
|
|
+ Result<String> result = new Result<>();
|
|
|
try {
|
|
|
String endDateStr = DateUtils.getDate("yyyy-MM-dd");
|
|
|
String startDate = DateUtils.addMonth(endDateStr, -6);
|
|
@@ -223,14 +354,11 @@ public class TestController {
|
|
|
|
|
|
@GetMapping(value = "/getTaskList")
|
|
|
public String getTaskList() {
|
|
|
- Result<String> result = new Result<String>();
|
|
|
+ Result<String> result = new Result<>();
|
|
|
try {
|
|
|
- String endDateStr = DateUtils.getDate("yyyy-MM-dd");
|
|
|
- String startDate = DateUtils.addMonth(endDateStr, -6);
|
|
|
QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
|
|
|
tokenQueryWrapper.eq("media_id", 2);
|
|
|
historyReportTaskService.getTaskList();
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
result.setSuccess(false);
|
|
@@ -248,7 +376,6 @@ public class TestController {
|
|
|
List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
|
|
|
for (CtopOauthToken token : ctopOauthTokens) {
|
|
|
|
|
|
-
|
|
|
for (int i = 0; i < 7; i++) {
|
|
|
Date getStartDate = DateUtils.addDay(endDate, -i);
|
|
|
//3:获取广告组信息数据
|
|
@@ -348,13 +475,6 @@ public class TestController {
|
|
|
@Autowired
|
|
|
private IUserAllocationService userAllocationService;
|
|
|
|
|
|
-
|
|
|
- public static void main(String[] args) throws ParseException {
|
|
|
- String date = DateUtils.getDate("yyyy-MM-dd");
|
|
|
- String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", date, -1);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@GetMapping(value = "/getPlanAndGroupByAccount")
|
|
|
public void getPlanAndGroupByAccount(Long accountId) {
|
|
|
QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
@@ -369,8 +489,6 @@ public class TestController {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -397,74 +515,6 @@ public class TestController {
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
|
|
|
- @GetMapping("loadBytedanceData")
|
|
|
- public Map<String, Object> formatZybData(String date) {
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- Date getDate = null;
|
|
|
- try {
|
|
|
- getDate = simpleDateFormat.parse(date);
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- //1:查询当日数据
|
|
|
- QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("project_id", 215);
|
|
|
- List<UserAllocation> allocations = userAllocationService.list(queryWrapper);
|
|
|
- if (null == allocations || allocations.size() <= 0) {
|
|
|
- log.info("定时获取头条数据异常:获取用户信息失败");
|
|
|
- }
|
|
|
- Date finalGetDate = getDate;
|
|
|
-
|
|
|
- allocations.forEach(allocation -> {
|
|
|
- //3:获取广告计划信息数据
|
|
|
- CtopOauthToken token = oauthTokenMapper.selectByAccountId(allocation.getAccountId());
|
|
|
- reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
- });
|
|
|
-
|
|
|
- //清洗关于作业帮数据
|
|
|
- //1:查询作业帮相关的用户数据
|
|
|
- allocations.forEach(allocation -> {
|
|
|
- //根据accountId和时间,查询相关的日报表信息
|
|
|
- QueryWrapper<BytedancePlanDailyReport> reportQueryWrapper = new QueryWrapper<>();
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String dateString = dateFormat.format(finalGetDate) + " 00:00:00";
|
|
|
- queryWrapper.eq("advertiser_id", allocation.getAccountId())
|
|
|
- .eq("stat_datetime", dateString)
|
|
|
- ;
|
|
|
- List<BytedancePlanDailyReport> bytedancePlanDailyReports = planDailyReportService.list(reportQueryWrapper);
|
|
|
- if (null != bytedancePlanDailyReports && bytedancePlanDailyReports.size() > 0) {
|
|
|
- bytedancePlanDailyReports.forEach(report -> {
|
|
|
- String adName = report.getAdName();
|
|
|
- String[] tags = adName.split("-");
|
|
|
- report.setAdsense(tags[1]);
|
|
|
- report.setPlanCode(tags[2]);
|
|
|
- String materialName = tags[3];
|
|
|
- report.setMaterialName(materialName);
|
|
|
- if (materialName.contains("其他")) {
|
|
|
- report.setMaterialType("其他");
|
|
|
- } else if (materialName.contains("图片轮播")) {
|
|
|
- report.setMaterialType("图片轮播");
|
|
|
- } else if (materialName.contains("大字报")) {
|
|
|
- report.setMaterialType("大字报");
|
|
|
- } else if (materialName.contains("文字动画")) {
|
|
|
- report.setMaterialType("文字动画");
|
|
|
- } else if (materialName.contains("采访形式")) {
|
|
|
- report.setMaterialType("采访形式");
|
|
|
- } else if (materialName.contains("剧情")) {
|
|
|
- report.setMaterialType("剧情");
|
|
|
- } else if (materialName.contains("口播")) {
|
|
|
- report.setMaterialType("口播");
|
|
|
- } else {
|
|
|
- report.setMaterialType("其他");
|
|
|
- }
|
|
|
- planDailyReportService.updateById(report);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
- return result;
|
|
|
- }
|
|
|
|
|
|
@Autowired
|
|
|
private IByteDanceAdvertiserDataService advertiserDataService;
|
|
@@ -474,8 +524,10 @@ public class TestController {
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
//1:查询当日数据
|
|
|
List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
- if (null == tokens || tokens.size() <= 0) {
|
|
|
+ if (null == tokens || tokens.isEmpty()) {
|
|
|
log.info("定时获取头条数据异常:为获取到可用的token");
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
|
+ return result;
|
|
|
}
|
|
|
tokens.forEach(token -> {
|
|
|
advertiserDataService.getMaterialList(token);
|
|
@@ -484,282 +536,13 @@ public class TestController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- @GetMapping("formatZybData")
|
|
|
- public Map<String, Object> formatZybData() {
|
|
|
- //清洗关于作业帮数据
|
|
|
- //1:查询作业帮相关的用户数据
|
|
|
- QueryWrapper<UserAllocation> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("project_id", 215);
|
|
|
- List<UserAllocation> allocations = userAllocationService.list(wrapper);
|
|
|
- if (null != allocations && allocations.size() > 0) {
|
|
|
- allocations.forEach(allocation -> {
|
|
|
- //根据accountId和时间,查询相关的日报表信息
|
|
|
- QueryWrapper<BytedancePlanDailyReport> queryWrapper = new QueryWrapper<>();
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
-// String dateString = dateFormat.format(getDate)+" 00:00:00";
|
|
|
- queryWrapper.eq("advertiser_id", allocation.getAccountId())
|
|
|
-// .eq("stat_datetime",dateString)
|
|
|
- ;
|
|
|
- List<BytedancePlanDailyReport> bytedancePlanDailyReports = planDailyReportService.list(queryWrapper);
|
|
|
- if (null != bytedancePlanDailyReports && bytedancePlanDailyReports.size() > 0) {
|
|
|
- bytedancePlanDailyReports.forEach(report -> {
|
|
|
- String adName = report.getAdName();
|
|
|
- String[] tags = adName.split("-");
|
|
|
- report.setAdsense(tags[1]);
|
|
|
- report.setPlanCode(tags[2]);
|
|
|
- String materialName = tags[3];
|
|
|
- report.setMaterialName(materialName);
|
|
|
- if (materialName.contains("其他")) {
|
|
|
- report.setMaterialType("其他");
|
|
|
- } else if (materialName.contains("图片轮播")) {
|
|
|
- report.setMaterialType("图片轮播");
|
|
|
- } else if (materialName.contains("大字报")) {
|
|
|
- report.setMaterialType("大字报");
|
|
|
- } else if (materialName.contains("文字动画")) {
|
|
|
- report.setMaterialType("文字动画");
|
|
|
- } else if (materialName.contains("采访形式")) {
|
|
|
- report.setMaterialType("采访形式");
|
|
|
- } else if (materialName.contains("剧情")) {
|
|
|
- report.setMaterialType("剧情");
|
|
|
- } else if (materialName.contains("口播")) {
|
|
|
- report.setMaterialType("口播");
|
|
|
- } else {
|
|
|
- report.setMaterialType("其他");
|
|
|
- }
|
|
|
- planDailyReportService.updateById(report);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
@Autowired
|
|
|
private IReportService reportService;
|
|
|
|
|
|
- @GetMapping("bytedanceHourReport")
|
|
|
- public Map<String, Object> bytedanceHourReport() {
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- log.info("头条时报数据获取开始");
|
|
|
- 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);
|
|
|
- }
|
|
|
- //1:查询当日数据
|
|
|
- List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
- if (null == tokens || tokens.size() <= 0) {
|
|
|
- log.info("定时获取头条小时数据异常:未获取到可用的token");
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
|
- return result;
|
|
|
- }
|
|
|
- executorService = Executors.newFixedThreadPool(4);
|
|
|
- Date finalGetDate = getDate;
|
|
|
- tokens.forEach(token -> {
|
|
|
- executorService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- reportService.getAdvertiserReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- log.info("头条时报数据获取结束");
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- //线程计数器
|
|
|
- static CountDownLatch countDownLatch = null;
|
|
|
-
|
|
|
- @GetMapping("getHourLyYddData")
|
|
|
- public Map<String, Object> getData() {
|
|
|
- log.info("头条时报数据获取开始");
|
|
|
- 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);
|
|
|
- }
|
|
|
- //1:查询当日计划时报数据
|
|
|
- List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
- Date finalGetDate = getDate;
|
|
|
- executorService = Executors.newFixedThreadPool(10);
|
|
|
- countDownLatch = new CountDownLatch(tokens.size());
|
|
|
- tokens.forEach(token -> {
|
|
|
- //1:获取当日广告计划数据
|
|
|
- executorService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- try {
|
|
|
- reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- countDownLatch.countDown();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- try {
|
|
|
- countDownLatch.await();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- log.info("头条计划时报数据获取完成");
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("formatYzData")
|
|
|
- public Map<String, Object> formatYzData() {
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- planDailyReportService.cleanYzData(151);
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
- return result;
|
|
|
- }
|
|
|
|
|
|
@Autowired
|
|
|
private IBytedancePlanHourlyReportService planHourlyReportService;
|
|
|
|
|
|
- @GetMapping("loadCreativeData")
|
|
|
- public Map<String, Object> loadCreaticeData() {
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
- log.info("头条创意素材数据开始获取");
|
|
|
- //查询当日数据
|
|
|
- if (null == tokens || tokens.size() <= 0) {
|
|
|
- log.info("定时获取头条数据异常:wei获取到可用的token");
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SERVER_ERROR);
|
|
|
- return result;
|
|
|
- }
|
|
|
- executorService = Executors.newFixedThreadPool(20);
|
|
|
- countDownLatch = new CountDownLatch(tokens.size());
|
|
|
- tokens.forEach(token -> {
|
|
|
- executorService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // 获取广告创意信息数据
|
|
|
- try {
|
|
|
- advertiserDataService.getAdvertiserCreative(token, null);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- countDownLatch.countDown();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- try {
|
|
|
- countDownLatch.await();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- log.info("头条创意素材数据获取完成");
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("loadCreaticeReportData")
|
|
|
- public Map<String, Object> loadCreaticeReportData() {
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
- for (int i = 51; i < 180; i++) {
|
|
|
- Date getDate = DateUtils.addDay(new Date(), -i);
|
|
|
- log.info(DateUtils.formatDate(getDate) + "头条创意日报数据开始获取");
|
|
|
- //查询当日数据
|
|
|
- if (null == tokens || tokens.size() <= 0) {
|
|
|
- log.info("定时获取头条数据异常:为获取到可用的token");
|
|
|
- continue;
|
|
|
- }
|
|
|
- executorService = Executors.newFixedThreadPool(10);
|
|
|
- countDownLatch = new CountDownLatch(tokens.size());
|
|
|
- tokens.forEach(token -> {
|
|
|
- executorService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- //获取广告创意日报信息数据
|
|
|
- try {
|
|
|
- reportService.getAdvertiserCreativeReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- countDownLatch.countDown();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- try {
|
|
|
- countDownLatch.await();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- log.info(DateUtils.formatDate(getDate) + "头条创意日报数据获取完成");
|
|
|
- }
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("loadVideoData")
|
|
|
- public Map<String, Object> loadVideoData() {
|
|
|
- log.info("素材数据获取开始");
|
|
|
- //1:查询当日计划时报数据
|
|
|
- List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
|
- executorService = Executors.newFixedThreadPool(10);
|
|
|
- countDownLatch = new CountDownLatch(tokens.size());
|
|
|
- tokens.forEach(token -> {
|
|
|
- //1:获取当日广告计划数据
|
|
|
- executorService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- try {
|
|
|
- advertiserDataService.getMaterialList(token);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- countDownLatch.countDown();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- try {
|
|
|
- countDownLatch.await();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- log.info("头条素材数据获取完成");
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ICleanMaterialService cleanMaterialService;
|
|
|
-
|
|
|
- @GetMapping("testReport")
|
|
|
- public void testReport() {
|
|
|
- List<String> signatureList = cleanMaterialService.getSignature();
|
|
|
- if (Check.isNull(signatureList)) {
|
|
|
- log.error("素材数据获取为空");
|
|
|
- return;
|
|
|
- }
|
|
|
- executorService = Executors.newFixedThreadPool(5);
|
|
|
- for (int i = 0; i < signatureList.size(); i++) {
|
|
|
- String signature = signatureList.get(i);
|
|
|
- executorService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- cleanMaterialService.calculationReport(signature);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
@GetMapping(value = "/AccountReportByAccount")
|
|
|
public void AccountReportByAccount(Long accountId, String startDateStr, String endDateStr) {
|
|
@@ -851,5 +634,50 @@ public class TestController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @GetMapping(value = "/KuaishouDailyAccountReportLoadJob")
|
|
|
+ public void KuaishouDailyAccountReportLoadJob() {
|
|
|
+ Date getDate = DateUtils.addDay(new Date(), -2);
|
|
|
+ //1:查询当日数据
|
|
|
+ List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
|
+ if (null == tokens || tokens.size() <= 0) {
|
|
|
+ log.info("定时获取快手数据异常:未获取到可用的token");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ executorService = Executors.newFixedThreadPool(3);
|
|
|
+ tokens.forEach(token -> {
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ //1: 获取广告主信息数据
|
|
|
+ kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping(value = "/BytedanceDailyAsyncJob")
|
|
|
+ public void BytedanceDailyAsyncJob() {
|
|
|
+ String startDate = "2020-06-01";
|
|
|
+ Date getDate = DateUtils.addDay(new Date(), -1);
|
|
|
+ String endDate = DateUtils.formatDate(getDate);
|
|
|
+ endDate = "2020-06-02";
|
|
|
+ log.info("头条广告计划异步任务开始执行,跑的是" + startDate + "~" + endDate + "的数据");
|
|
|
+
|
|
|
+ List<CtopOauthToken> tokens = tokenService.getToutiaoTokenByCreateTime(endDate);
|
|
|
+ if (null == tokens || tokens.size() <= 0) {
|
|
|
+ log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //1.创意 2.广告主 3.广告组 4.广告计划
|
|
|
+ for (CtopOauthToken token : tokens) {
|
|
|
+ bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 1);
|
|
|
+ bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 2);
|
|
|
+ bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 3);
|
|
|
+ bytedanceReportService.bytedanceAsyncTaskCreate(startDate, endDate, token, 4);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|