|
@@ -1,7 +1,9 @@
|
|
package org.jeecg.modules.ctop.controller;
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
import cn.com.ctop.bytedance.entity.BytedancePlanDailyReport;
|
|
import cn.com.ctop.bytedance.entity.BytedancePlanDailyReport;
|
|
|
|
+import cn.com.ctop.bytedance.entity.BytedancePlanHourlyReport;
|
|
import cn.com.ctop.bytedance.service.IBytedancePlanDailyReportService;
|
|
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.bytedance.service.IReportService;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.*;
|
|
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;
|
|
|
|
|
|
@@ -424,16 +427,8 @@ public class TestController {
|
|
public void run() {
|
|
public void run() {
|
|
//1: 获取广告主信息数据
|
|
//1: 获取广告主信息数据
|
|
reportService.getAdvertiserReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
reportService.getAdvertiserReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
- //2:获取广告组信息数据
|
|
|
|
- //reportService.getAdvertiserCampaignReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
|
- //3:获取广告计划信息数据
|
|
|
|
- //reportService.getAdvertiserPlanReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
|
- //4: 获取广告创意信息数据
|
|
|
|
- //reportService.getAdvertiserCreativeReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
});
|
|
});
|
|
-
|
|
|
|
});
|
|
});
|
|
log.info("头条时报数据获取结束");
|
|
log.info("头条时报数据获取结束");
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
@@ -517,4 +512,115 @@ public class TestController {
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
return result;
|
|
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();
|
|
|
|
+ }
|
|
|
|
+ //清洗关于缘多多数据
|
|
|
|
+ formatData(113, finalGetDate);
|
|
|
|
+ //清洗关于交友数据
|
|
|
|
+ formatData(112, finalGetDate);
|
|
|
|
+ //清洗关于附近约会数据
|
|
|
|
+ formatData(222, finalGetDate);
|
|
|
|
+ log.info("头条计划时报数据获取完成");
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void formatData(Integer projectId, Date finalGetDate) {
|
|
|
|
+ QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("project_id", projectId);
|
|
|
|
+ List<UserAllocation> fjyhAllocations = userAllocationService.list(queryWrapper);
|
|
|
|
+ if (null != fjyhAllocations && fjyhAllocations.size() > 0) {
|
|
|
|
+ fjyhAllocations.forEach(allocation -> {
|
|
|
|
+ //根据accountId和时间,查询相关的时报报表信息
|
|
|
|
+ QueryWrapper<BytedancePlanHourlyReport> accountWrapper = new QueryWrapper<>();
|
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ String dateString = dateFormat.format(finalGetDate);
|
|
|
|
+ accountWrapper.eq("advertiser_id", allocation.getAccountId())
|
|
|
|
+ .eq("stat_datetime", dateString)
|
|
|
|
+ ;
|
|
|
|
+ List<BytedancePlanHourlyReport> bytedancePlanHourlyReports = planHourlyReportService.list(accountWrapper);
|
|
|
|
+ if (null != bytedancePlanHourlyReports && bytedancePlanHourlyReports.size() > 0) {
|
|
|
|
+ bytedancePlanHourlyReports.forEach(report -> {
|
|
|
|
+ String adName = report.getAdName();
|
|
|
|
+ String[] tags = adName.split("-");
|
|
|
|
+ report.setChannelCode(tags[0]);
|
|
|
|
+ planHourlyReportService.updateById(report);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IBytedancePlanHourlyReportService planHourlyReportService;
|
|
|
|
+
|
|
|
|
+ @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;
|
|
|
|
+ }
|
|
}
|
|
}
|