|
@@ -1,9 +1,5 @@
|
|
package org.jeecg.modules.ctop.controller;
|
|
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.entity.*;
|
|
import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
import cn.com.ctop.common.module.service.*;
|
|
import cn.com.ctop.common.module.service.*;
|
|
@@ -16,22 +12,22 @@ 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.IKuaiShouHistoryReportTaskService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
|
|
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.IReportService;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
-import org.jeecg.modules.ctop.job.KuaishouDailyAccountReportLoadJob;
|
|
|
|
-import org.jeecg.modules.ctop.service.ICleanMaterialService;
|
|
|
|
-import org.jeecg.modules.ctop.service.ICreateInternalService;
|
|
|
|
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.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
@@ -45,8 +41,6 @@ import static org.jeecg.common.util.DateUtils.getAnotherDay;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class TestController {
|
|
public class TestController {
|
|
@Autowired
|
|
@Autowired
|
|
- private ICreateInternalService createInternalService;
|
|
|
|
- @Autowired
|
|
|
|
private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
|
|
private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -64,14 +58,9 @@ public class TestController {
|
|
@Autowired
|
|
@Autowired
|
|
private IMaterialImageInfoService iMaterialImageInfoService;
|
|
private IMaterialImageInfoService iMaterialImageInfoService;
|
|
|
|
|
|
- @PostMapping(value = "/create")
|
|
|
|
- public Map<String, Object> authorization(@RequestBody JSONObject jsonObject) {
|
|
|
|
- return createInternalService.createInternal(jsonObject);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@GetMapping(value = "/t")
|
|
@GetMapping(value = "/t")
|
|
public String test() {
|
|
public String test() {
|
|
- Result<String> result = new Result<String>();
|
|
|
|
|
|
+ Result<String> result = new Result<>();
|
|
try {
|
|
try {
|
|
String requestId = UUID.randomUUID().toString();
|
|
String requestId = UUID.randomUUID().toString();
|
|
String img = kuaishouWebInterfaceService.qrLogin(requestId);
|
|
String img = kuaishouWebInterfaceService.qrLogin(requestId);
|
|
@@ -108,38 +97,28 @@ public class TestController {
|
|
|
|
|
|
@GetMapping(value = "/updateCode")
|
|
@GetMapping(value = "/updateCode")
|
|
public String updateCode() {
|
|
public String updateCode() {
|
|
-
|
|
|
|
List<MaterialInfo> list = materialInfoService.list();
|
|
List<MaterialInfo> list = materialInfoService.list();
|
|
for (MaterialInfo info : list) {
|
|
for (MaterialInfo info : list) {
|
|
-
|
|
|
|
-
|
|
|
|
QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
|
|
imageInfoQueryWrapper.eq("video_id", String.valueOf(info.getId()));
|
|
imageInfoQueryWrapper.eq("video_id", String.valueOf(info.getId()));
|
|
MaterialImageInfo updateMaterialImageInfo = new MaterialImageInfo();
|
|
MaterialImageInfo updateMaterialImageInfo = new MaterialImageInfo();
|
|
updateMaterialImageInfo.setVideoId(info.getCode());
|
|
updateMaterialImageInfo.setVideoId(info.getCode());
|
|
iMaterialImageInfoService.update(updateMaterialImageInfo, imageInfoQueryWrapper);
|
|
iMaterialImageInfoService.update(updateMaterialImageInfo, imageInfoQueryWrapper);
|
|
-
|
|
|
|
-
|
|
|
|
QueryWrapper<MaterialTag> tagQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MaterialTag> tagQueryWrapper = new QueryWrapper<>();
|
|
tagQueryWrapper.eq("material_id", String.valueOf(info.getId()));
|
|
tagQueryWrapper.eq("material_id", String.valueOf(info.getId()));
|
|
MaterialTag updateTag = new MaterialTag();
|
|
MaterialTag updateTag = new MaterialTag();
|
|
updateTag.setMaterialId(info.getCode());
|
|
updateTag.setMaterialId(info.getCode());
|
|
tagService.update(updateTag, tagQueryWrapper);
|
|
tagService.update(updateTag, tagQueryWrapper);
|
|
-
|
|
|
|
QueryWrapper<MaterialAscription> materialAscriptionQuery = new QueryWrapper<>();
|
|
QueryWrapper<MaterialAscription> materialAscriptionQuery = new QueryWrapper<>();
|
|
materialAscriptionQuery.eq("material_id", String.valueOf(info.getId()));
|
|
materialAscriptionQuery.eq("material_id", String.valueOf(info.getId()));
|
|
MaterialAscription updateMaterialAscription = new MaterialAscription();
|
|
MaterialAscription updateMaterialAscription = new MaterialAscription();
|
|
updateMaterialAscription.setMaterialId(info.getCode());
|
|
updateMaterialAscription.setMaterialId(info.getCode());
|
|
ascriptionService.update(updateMaterialAscription, materialAscriptionQuery);
|
|
ascriptionService.update(updateMaterialAscription, materialAscriptionQuery);
|
|
-
|
|
|
|
-
|
|
|
|
QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
|
|
parameterQueryWrapper.eq("material_id", String.valueOf(info.getId()));
|
|
parameterQueryWrapper.eq("material_id", String.valueOf(info.getId()));
|
|
MaterialParameter updateMaterialParameter = new MaterialParameter();
|
|
MaterialParameter updateMaterialParameter = new MaterialParameter();
|
|
updateMaterialParameter.setMaterialId(info.getCode());
|
|
updateMaterialParameter.setMaterialId(info.getCode());
|
|
parameterService.update(updateMaterialParameter, parameterQueryWrapper);
|
|
parameterService.update(updateMaterialParameter, parameterQueryWrapper);
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
List<MaterialImageInfo> list1 = iMaterialImageInfoService.list();
|
|
List<MaterialImageInfo> list1 = iMaterialImageInfoService.list();
|
|
for (MaterialImageInfo imageInfo : list1) {
|
|
for (MaterialImageInfo imageInfo : list1) {
|
|
@@ -170,11 +149,8 @@ public class TestController {
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
return "SUCCESS";
|
|
return "SUCCESS";
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -201,7 +177,7 @@ public class TestController {
|
|
|
|
|
|
@GetMapping(value = "/getHistoryData")
|
|
@GetMapping(value = "/getHistoryData")
|
|
public String getHistoryData() {
|
|
public String getHistoryData() {
|
|
- Result<String> result = new Result<String>();
|
|
|
|
|
|
+ Result<String> result = new Result<>();
|
|
try {
|
|
try {
|
|
String endDateStr = DateUtils.getDate("yyyy-MM-dd");
|
|
String endDateStr = DateUtils.getDate("yyyy-MM-dd");
|
|
String startDate = DateUtils.addMonth(endDateStr, -6);
|
|
String startDate = DateUtils.addMonth(endDateStr, -6);
|
|
@@ -224,14 +200,11 @@ public class TestController {
|
|
|
|
|
|
@GetMapping(value = "/getTaskList")
|
|
@GetMapping(value = "/getTaskList")
|
|
public String getTaskList() {
|
|
public String getTaskList() {
|
|
- Result<String> result = new Result<String>();
|
|
|
|
|
|
+ Result<String> result = new Result<>();
|
|
try {
|
|
try {
|
|
- String endDateStr = DateUtils.getDate("yyyy-MM-dd");
|
|
|
|
- String startDate = DateUtils.addMonth(endDateStr, -6);
|
|
|
|
QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
|
|
tokenQueryWrapper.eq("media_id", 2);
|
|
tokenQueryWrapper.eq("media_id", 2);
|
|
historyReportTaskService.getTaskList();
|
|
historyReportTaskService.getTaskList();
|
|
-
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
result.setSuccess(false);
|
|
result.setSuccess(false);
|
|
@@ -249,7 +222,6 @@ public class TestController {
|
|
List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
|
|
List<CtopOauthToken> ctopOauthTokens = tokenMapper.selectList(tokenQueryWrapper);
|
|
for (CtopOauthToken token : ctopOauthTokens) {
|
|
for (CtopOauthToken token : ctopOauthTokens) {
|
|
|
|
|
|
-
|
|
|
|
for (int i = 0; i < 7; i++) {
|
|
for (int i = 0; i < 7; i++) {
|
|
Date getStartDate = DateUtils.addDay(endDate, -i);
|
|
Date getStartDate = DateUtils.addDay(endDate, -i);
|
|
//3:获取广告组信息数据
|
|
//3:获取广告组信息数据
|
|
@@ -349,13 +321,6 @@ public class TestController {
|
|
@Autowired
|
|
@Autowired
|
|
private IUserAllocationService userAllocationService;
|
|
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")
|
|
@GetMapping(value = "/getPlanAndGroupByAccount")
|
|
public void getPlanAndGroupByAccount(Long accountId) {
|
|
public void getPlanAndGroupByAccount(Long accountId) {
|
|
QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
@@ -370,8 +335,6 @@ public class TestController {
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -398,74 +361,6 @@ public class TestController {
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService tokenService;
|
|
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
|
|
@Autowired
|
|
private IByteDanceAdvertiserDataService advertiserDataService;
|
|
private IByteDanceAdvertiserDataService advertiserDataService;
|
|
@@ -475,292 +370,28 @@ public class TestController {
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
//1:查询当日数据
|
|
//1:查询当日数据
|
|
List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
|
|
- if (null == tokens || tokens.size() <= 0) {
|
|
|
|
|
|
+ if (null == tokens || tokens.isEmpty()) {
|
|
log.info("定时获取头条数据异常:为获取到可用的token");
|
|
log.info("定时获取头条数据异常:为获取到可用的token");
|
|
- }
|
|
|
|
- tokens.forEach(token -> {
|
|
|
|
- advertiserDataService.getMaterialList(token);
|
|
|
|
- });
|
|
|
|
- ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
|
- 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);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
- executorService = Executors.newFixedThreadPool(4);
|
|
|
|
- Date finalGetDate = getDate;
|
|
|
|
tokens.forEach(token -> {
|
|
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();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ advertiserDataService.getMaterialList(token);
|
|
});
|
|
});
|
|
- 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);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private IBytedancePlanHourlyReportService planHourlyReportService;
|
|
|
|
|
|
+ private IReportService reportService;
|
|
|
|
|
|
- @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
|
|
@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);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ private IBytedancePlanHourlyReportService planHourlyReportService;
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
@GetMapping(value = "/AccountReportByAccount")
|
|
@GetMapping(value = "/AccountReportByAccount")
|
|
public void AccountReportByAccount(Long accountId, String startDateStr, String endDateStr) {
|
|
public void AccountReportByAccount(Long accountId, String startDateStr, String endDateStr) {
|
|
@@ -853,7 +484,7 @@ public class TestController {
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/KuaishouDailyAccountReportLoadJob")
|
|
@GetMapping(value = "/KuaishouDailyAccountReportLoadJob")
|
|
- public void KuaishouDailyAccountReportLoadJob(){
|
|
|
|
|
|
+ public void KuaishouDailyAccountReportLoadJob() {
|
|
Date getDate = DateUtils.addDay(new Date(), -2);
|
|
Date getDate = DateUtils.addDay(new Date(), -2);
|
|
//1:查询当日数据
|
|
//1:查询当日数据
|
|
List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
|
|
@@ -875,12 +506,4 @@ public class TestController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|