|
@@ -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,121 @@ 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)) {
|
|
|
|
+ log.info("账号id:{}", allocation.getAccountId());
|
|
|
|
+
|
|
|
|
+ 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.计划数据
|
|
|
|
+ log.info("获取计划,账号id:{}", allocation.getAccountId());
|
|
|
|
+ kuaishouInterfaceService.getCampaignList(ctopOauthToken, null, null);
|
|
|
|
+ // 2:广告组数据
|
|
|
|
+ log.info("获取广告组,账号id:{}", allocation.getAccountId());
|
|
|
|
+ kuaishouInterfaceService.getGroupList(ctopOauthToken, null, null);
|
|
|
|
+ // 3:创意数据
|
|
|
|
+ log.info("获取创意,账号id:{}", allocation.getAccountId());
|
|
|
|
+ kuaishouInterfaceService.getCreativeList(ctopOauthToken, null, null);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ campaignQueryWrapper.eq("account_id", ctopOauthToken.getAccountId());
|
|
|
|
+ log.info("获取创意报表,账号id:{}", allocation.getAccountId());
|
|
|
|
+ List<KuaiShouCampaign> campaigns = campaignService.list(campaignQueryWrapper);
|
|
|
|
+ if (!Check.isNull(campaigns)) {
|
|
|
|
+ for (KuaiShouCampaign campaign : campaigns) {
|
|
|
|
+ kuaishouInterfaceService.getAdvertiserCreativeReportDailyV2(campaign.getCampaignId(), ctopOauthToken, endDate, endDate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- };
|
|
|
|
- thread.start();
|
|
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) throws ParseException {
|
|
|
|
+ String date = DateUtils.getDate("yyyy-MM-dd");
|
|
|
|
+ String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", date, -1);
|
|
|
|
+ System.err.println(anotherDay);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -199,49 +290,35 @@ public class TestController {
|
|
oauthTokenQueryWrapper.eq("account_id", accountId);
|
|
oauthTokenQueryWrapper.eq("account_id", accountId);
|
|
oauthTokenQueryWrapper.last("limit 1");
|
|
oauthTokenQueryWrapper.last("limit 1");
|
|
CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
- executorService.submit(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- try {
|
|
|
|
-
|
|
|
|
- kuaishouInterfaceService.getCampaignList(token, null, null);
|
|
|
|
- //1:获取全量广告组数据
|
|
|
|
- kuaishouInterfaceService.getGroupList(token, null, null);
|
|
|
|
-
|
|
|
|
- Thread.sleep(1 * 200);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ try {
|
|
|
|
+ System.err.println("获取计划,广告组:" + accountId);
|
|
|
|
+ kuaishouInterfaceService.getCampaignList(token, null, null);
|
|
|
|
+ //1:获取全量广告组数据
|
|
|
|
+ kuaishouInterfaceService.getGroupList(token, null, null);
|
|
|
|
+ System.err.println("获取计划,广告组:" + accountId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @GetMapping(value = "/gerCreativeByAccount")
|
|
|
|
|
|
+ @GetMapping(value = "/getCreativeByAccount")
|
|
public void gerCreative(Long accountId) {
|
|
public void gerCreative(Long accountId) {
|
|
QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<CtopOauthToken> oauthTokenQueryWrapper = new QueryWrapper<>();
|
|
oauthTokenQueryWrapper.eq("media_id", 2);
|
|
oauthTokenQueryWrapper.eq("media_id", 2);
|
|
oauthTokenQueryWrapper.eq("account_id", accountId);
|
|
oauthTokenQueryWrapper.eq("account_id", accountId);
|
|
oauthTokenQueryWrapper.last("limit 1");
|
|
oauthTokenQueryWrapper.last("limit 1");
|
|
CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
CtopOauthToken token = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
- executorService.submit(new Runnable() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- try {
|
|
|
|
- System.err.println("获取创意,accountId:" + token.getAccountId());
|
|
|
|
- kuaishouInterfaceService.getCampaignList(token, null, null);
|
|
|
|
- //1:获取全量广告组数据
|
|
|
|
- kuaishouInterfaceService.getGroupList(token, null, null);
|
|
|
|
- kuaishouInterfaceService.getCreativeList(token, null, null);
|
|
|
|
|
|
|
|
- Thread.sleep(1 * 200);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ try {
|
|
|
|
+ System.err.println("获取创意,accountId:" + token.getAccountId());
|
|
|
|
+ kuaishouInterfaceService.getCreativeList(token, null, null);
|
|
|
|
+ System.err.println("获取创意结束,accountId:" + token.getAccountId());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -263,16 +340,23 @@ public class TestController {
|
|
oauthTokenQueryWrapper.eq("account_id", accountId);
|
|
oauthTokenQueryWrapper.eq("account_id", accountId);
|
|
CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(oauthTokenQueryWrapper);
|
|
System.err.println("创意报表accountId:" + ctopOauthToken.getAccountId());
|
|
System.err.println("创意报表accountId:" + ctopOauthToken.getAccountId());
|
|
- kuaishouInterfaceService.getAdvertiserCreativeReportDaily(ctopOauthToken, startDate, endDate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ campaignQueryWrapper.eq("account_id", ctopOauthToken.getAccountId());
|
|
|
|
+
|
|
|
|
+ List<KuaiShouCampaign> campaigns = campaignService.list(campaignQueryWrapper);
|
|
|
|
+ if (!Check.isNull(campaigns)) {
|
|
|
|
+ for (KuaiShouCampaign campaign : campaigns) {
|
|
|
|
+ kuaishouInterfaceService.getAdvertiserCreativeReportDailyV2(campaign.getCampaignId(), ctopOauthToken, endDate, endDate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
};
|
|
};
|
|
thread.start();
|
|
thread.start();
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private IUserAllocationService userAllocationService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private IBytedancePlanDailyReportService planDailyReportService;
|
|
private IBytedancePlanDailyReportService planDailyReportService;
|
|
@@ -361,7 +445,6 @@ public class TestController {
|
|
log.info("定时获取头条数据异常:为获取到可用的token");
|
|
log.info("定时获取头条数据异常:为获取到可用的token");
|
|
}
|
|
}
|
|
tokens.forEach(token -> {
|
|
tokens.forEach(token -> {
|
|
- //3:获取广告计划信息数据
|
|
|
|
advertiserDataService.getMaterialList(token);
|
|
advertiserDataService.getMaterialList(token);
|
|
});
|
|
});
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
@@ -446,7 +529,6 @@ public class TestController {
|
|
executorService.submit(new Runnable() {
|
|
executorService.submit(new Runnable() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
- //1: 获取广告主信息数据
|
|
|
|
reportService.getAdvertiserReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
reportService.getAdvertiserReport(token, finalGetDate, finalGetDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -493,12 +575,6 @@ public class TestController {
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
- //清洗关于缘多多数据
|
|
|
|
- planDailyReportService.cleanYddData(113, finalGetDate);
|
|
|
|
- //清洗关于交友数据
|
|
|
|
- planDailyReportService.cleanYddData(112, finalGetDate);
|
|
|
|
- //清洗关于附近约会数据
|
|
|
|
- planDailyReportService.cleanYddData(222, finalGetDate);
|
|
|
|
log.info("头条计划时报数据获取完成");
|
|
log.info("头条计划时报数据获取完成");
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|
|
ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
|