|
@@ -13,8 +13,12 @@ import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.common.module.utils.ResultMapUtils;
|
|
import cn.com.ctop.common.module.utils.ResultMapUtils;
|
|
import cn.com.ctop.common.module.utils.StatusCode;
|
|
import cn.com.ctop.common.module.utils.StatusCode;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
|
|
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.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeStatisticMapper;
|
|
import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
|
|
import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -161,34 +165,110 @@ public class TestController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @GetMapping(value = "/gerCreativeReport")
|
|
|
|
- public void gerCreativeReport() {
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouCampaignService campaignService;
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/getCreativeReportByAccount")
|
|
|
|
+ public void gerCreativeReportByAccount(Long accountId, String startDateStr, String endDateStr) {
|
|
Thread thread = new Thread() {
|
|
Thread thread = new Thread() {
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
|
|
- Date startDate = sim.parse("2020-02-10");
|
|
|
|
- Date endDate = sim.parse("2020-02-11");
|
|
|
|
|
|
+ Date startDate = sim.parse(startDateStr);
|
|
|
|
+ Date endDate = sim.parse(endDateStr);
|
|
//1:查询当日数据
|
|
//1:查询当日数据
|
|
//executorService = Executors.newFixedThreadPool(3);
|
|
//executorService = Executors.newFixedThreadPool(3);
|
|
QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
oauthTokenQueryWrapper.eq("media_id", 2);
|
|
oauthTokenQueryWrapper.eq("media_id", 2);
|
|
- List<CtopOauthToken> ctopOauthTokens = oauthTokenMapper.selectList(oauthTokenQueryWrapper);
|
|
|
|
- for (CtopOauthToken token : ctopOauthTokens) {
|
|
|
|
|
|
+ oauthTokenQueryWrapper.eq("account_id", accountId);
|
|
|
|
+ CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
|
|
+
|
|
|
|
+ System.err.println("创意报表accountId:" + ctopOauthToken.getAccountId());
|
|
|
|
+ QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ campaignQueryWrapper.eq("account_id", accountId);
|
|
|
|
+ List<KuaiShouCampaign> list = campaignService.list(campaignQueryWrapper);
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
|
+ for (KuaiShouCampaign campaign : list) {
|
|
|
|
+ kuaishouInterfaceService.getAdvertiserCreativeReportDailyV2(campaign.getCampaignId(), ctopOauthToken, startDate, endDate);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ thread.start();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserAllocationService userAllocationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private KuaishouReportDailyCreativeStatisticMapper reportDailyCreativeStatisticMapper;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private KuaishouReportDailyCreativeMapper reportDailyCreativeMapper;
|
|
|
|
+
|
|
|
|
+ @GetMapping(value = "/getCreativeReportByProjectId")
|
|
|
|
+ public void getCreativeReportByProjectId(Long projectId) {
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
|
+ String date = DateUtils.getDate("yyyy-MM-dd");
|
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", date, -1);
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date endDate = simpleDateFormat.parse(anotherDay);
|
|
|
|
+ QueryWrapper<UserAllocation> userAllocationQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ userAllocationQueryWrapper.eq("project_id", projectId);
|
|
|
|
+ List<UserAllocation> list = userAllocationService.list(userAllocationQueryWrapper);
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
|
+ for (UserAllocation allocation : list) {
|
|
executorService.submit(new Runnable() {
|
|
executorService.submit(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
- System.err.println("创意报表accountId:" + token.getAccountId());
|
|
|
|
- kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, startDate, endDate);
|
|
|
|
|
|
+ if (!Check.isNull(allocation)) {
|
|
|
|
+
|
|
|
|
+ QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ oauthTokenQueryWrapper.eq("media_id", 2);
|
|
|
|
+ oauthTokenQueryWrapper.eq("account_id", allocation.getAccountId());
|
|
|
|
+ CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
|
|
+ if (!Check.isNull(ctopOauthToken)) {
|
|
|
|
+ deleteMap.put("account_id", allocation.getAccountId());
|
|
|
|
+ deleteMap.put("stat_date", anotherDay);
|
|
|
|
+ reportDailyCreativeStatisticMapper.deleteByMap(deleteMap);
|
|
|
|
+ reportDailyCreativeMapper.deleteByMap(deleteMap);
|
|
|
|
+
|
|
|
|
+ // 1.计划数据
|
|
|
|
+ kuaishouInterfaceService.getCampaignList(ctopOauthToken, null, null);
|
|
|
|
+ // 2:广告组数据
|
|
|
|
+ kuaishouInterfaceService.getGroupList(ctopOauthToken, null, null);
|
|
|
|
+ // 3:创意数据
|
|
|
|
+ kuaishouInterfaceService.getCreativeList(ctopOauthToken, null, null);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ campaignQueryWrapper.eq("account_id", ctopOauthToken.getAccountId());
|
|
|
|
+ List<KuaiShouCampaign> campaigns = campaignService.list(campaignQueryWrapper);
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
|
+ for (KuaiShouCampaign campaign : campaigns) {
|
|
|
|
+ kuaishouInterfaceService.getAdvertiserCreativeReportDailyV2(campaign.getCampaignId(), ctopOauthToken, endDate, endDate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- };
|
|
|
|
- thread.start();
|
|
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -231,9 +311,11 @@ public class TestController {
|
|
public void run() {
|
|
public void run() {
|
|
try {
|
|
try {
|
|
System.err.println("获取创意,accountId:" + token.getAccountId());
|
|
System.err.println("获取创意,accountId:" + token.getAccountId());
|
|
|
|
+ // 1.计划数据
|
|
kuaishouInterfaceService.getCampaignList(token, null, null);
|
|
kuaishouInterfaceService.getCampaignList(token, null, null);
|
|
- //1:获取全量广告组数据
|
|
|
|
|
|
+ // 2:广告组数据
|
|
kuaishouInterfaceService.getGroupList(token, null, null);
|
|
kuaishouInterfaceService.getGroupList(token, null, null);
|
|
|
|
+ // 3:创意数据
|
|
kuaishouInterfaceService.getCreativeList(token, null, null);
|
|
kuaishouInterfaceService.getCreativeList(token, null, null);
|
|
|
|
|
|
Thread.sleep(1 * 200);
|
|
Thread.sleep(1 * 200);
|
|
@@ -271,8 +353,6 @@ public class TestController {
|
|
thread.start();
|
|
thread.start();
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private IUserAllocationService userAllocationService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private IBytedancePlanDailyReportService planDailyReportService;
|
|
private IBytedancePlanDailyReportService planDailyReportService;
|