|
@@ -1,21 +1,16 @@
|
|
package cn.com.ctop.job.bytedance.handler;
|
|
package cn.com.ctop.job.bytedance.handler;
|
|
|
|
|
|
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.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
-import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
-import cn.com.ctop.toutiao.modules.report.entity.BytedancePlanDailyReport;
|
|
|
|
import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanDailyReportService;
|
|
import cn.com.ctop.toutiao.modules.report.service.IBytedancePlanDailyReportService;
|
|
import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
import cn.com.ctop.toutiao.modules.report.service.IReportService;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -28,17 +23,10 @@ public class BytedancePlanDailyReportLoadJob {
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
@Autowired
|
|
@Autowired
|
|
private IReportService reportService;
|
|
private IReportService reportService;
|
|
- @Autowired
|
|
|
|
- private IUserAllocationService userAllocationService;
|
|
|
|
- @Autowired
|
|
|
|
- private IBytedancePlanDailyReportService planDailyReportService;
|
|
|
|
-
|
|
|
|
|
|
|
|
@XxlJob("bytedancePlanDailyReport")
|
|
@XxlJob("bytedancePlanDailyReport")
|
|
public void execute() throws Exception {
|
|
public void execute() throws Exception {
|
|
Date getDate = DateUtils.addDay(new Date(), -1);
|
|
Date getDate = DateUtils.addDay(new Date(), -1);
|
|
- //次留用
|
|
|
|
- Date getDate2 = DateUtils.addDay(new Date(), -2);
|
|
|
|
//1:查询当日数据
|
|
//1:查询当日数据
|
|
List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
|
|
List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
|
|
if (null == tokens || tokens.isEmpty()) {
|
|
if (null == tokens || tokens.isEmpty()) {
|
|
@@ -47,63 +35,8 @@ public class BytedancePlanDailyReportLoadJob {
|
|
return ;
|
|
return ;
|
|
}
|
|
}
|
|
tokens.forEach(token -> reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY));
|
|
tokens.forEach(token -> reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY));
|
|
- formatZybData(215, getDate);
|
|
|
|
- planDailyReportService.cleanChannelCodeData(112, getDate);
|
|
|
|
- planDailyReportService.cleanChannelCodeData(113, getDate);
|
|
|
|
- planDailyReportService.cleanChannelCodeData(222, getDate);
|
|
|
|
- planDailyReportService.cleanYzData(151);
|
|
|
|
- planDailyReportService.cleanChannelCodeData(235, getDate);
|
|
|
|
- planDailyReportService.cleanChannelCodeData(270, getDate);
|
|
|
|
-
|
|
|
|
//跑次留
|
|
//跑次留
|
|
|
|
+ Date getDate2 = DateUtils.addDay(new Date(), -2);
|
|
tokens.forEach(token -> reportService.getAdvertiserPlanReport(token, getDate2, getDate2, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY));
|
|
tokens.forEach(token -> reportService.getAdvertiserPlanReport(token, getDate2, getDate2, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY));
|
|
}
|
|
}
|
|
-
|
|
|
|
- private void formatZybData(Integer projectId, Date getDate) {
|
|
|
|
- //清洗关于作业帮数据
|
|
|
|
- //1:查询作业帮相关的用户数据
|
|
|
|
- QueryWrapper<UserAllocation> wrapper = new QueryWrapper<>();
|
|
|
|
- wrapper.eq("project_id", projectId);
|
|
|
|
- List<UserAllocation> allocations = userAllocationService.list(wrapper);
|
|
|
|
- if (null != allocations && !allocations.isEmpty()) {
|
|
|
|
- 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.isEmpty()) {
|
|
|
|
- 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);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|