|
@@ -6,12 +6,13 @@ import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.service.IBindAccountLoginService;
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCommentService;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
|
|
|
-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.entity.KuaiShouVideoGet;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.*;
|
|
|
import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
|
|
@@ -21,7 +22,9 @@ import cn.com.ctop.oa.modules.service.IWechatNoListService;
|
|
|
import cn.com.ctop.oa.modules.service.IWechatUserListService;
|
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
|
|
|
import cn.com.ctop.toutiao.modules.report.service.*;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.catalina.User;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
@@ -35,6 +38,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
@@ -53,33 +57,44 @@ public class SampleTest {
|
|
|
@Autowired
|
|
|
private IByteDanceAdvertiserDataService advertiserDataService;
|
|
|
@Autowired
|
|
|
- private IKuaiShouHistoryReportTaskService kuaiShouHistoryReportTaskService;
|
|
|
- @Autowired
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
@Autowired
|
|
|
- private IKuaishouInterfaceService iKuaishouInterfaceService;
|
|
|
+ private IKuaiShouVideoGetService videoGetService;
|
|
|
+ @Autowired
|
|
|
+ private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
|
|
|
+ @Autowired
|
|
|
+ private IBindAccountLoginService bindAccountLoginService;
|
|
|
+ @Autowired
|
|
|
+ private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
|
|
|
+
|
|
|
|
|
|
@Test
|
|
|
public void loadBytedanceCreativeData() throws ParseException {
|
|
|
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- Date parse = simpleDateFormat.parse("2020-12-11");
|
|
|
- CtopOauthToken tokenByAccountId = oauthTokenService.getTokenByAccountId(5982133L);
|
|
|
- iKuaishouInterfaceService.getAdvertiserGroupReportDaily(tokenByAccountId, parse, parse);
|
|
|
-
|
|
|
- /* QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("media_id", 2);
|
|
|
- List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
|
|
|
- for (CtopOauthToken token : list) {
|
|
|
- kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-20", "2020-09-20", "daily");
|
|
|
- }*/
|
|
|
+ List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
|
|
|
+ if (!Check.isNull(KuaiShouVideoGets)) {
|
|
|
+ JSONArray dateList = new JSONArray();
|
|
|
+ JSONArray photoIds = new JSONArray();
|
|
|
+ Map<String, Object> statdateMap = new HashMap<>();
|
|
|
+ int count = 0;
|
|
|
+ for (KuaiShouVideoGet video : KuaiShouVideoGets) {
|
|
|
+ count++;
|
|
|
+ if (count < 10) {
|
|
|
+ photoIds.add(video.getPhotoId());
|
|
|
+ statdateMap.put(video.getPhotoId(), video.getStatDate());
|
|
|
+ } else {
|
|
|
+ photoIds.add(video.getPhotoId());
|
|
|
+ statdateMap.put(video.getPhotoId(), video.getStatDate());
|
|
|
+ dateList.add(photoIds);
|
|
|
+ photoIds = new JSONArray();
|
|
|
+ count = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dateList.add(photoIds);
|
|
|
+ kuaishouVideoRelateCreativesService.videoRelateCreatives(9743746L, dateList, statdateMap);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- private IBindAccountLoginService bindAccountLoginService;
|
|
|
- @Autowired
|
|
|
- private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
|
|
|
-
|
|
|
@Test
|
|
|
public void loadKuaishouCookie() {
|
|
|
List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
|
|
@@ -245,9 +260,13 @@ public class SampleTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testData11(){
|
|
|
- CtopOauthToken token =tokenService.getTokenByAccountId(1683711016125448L);
|
|
|
- reportService.getAdvertiserPlanRuleData(token,new Date(),new Date(), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ public void testData11() {
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
|
|
|
+ int dimeDiff = 5;
|
|
|
+ Date now = new Date();
|
|
|
+ String startTime = DateUtils.formatDate("2021-01-11 18:25:00");
|
|
|
+ String endTime = DateUtils.formatDate(now, "2021-01-11 18:35:00");
|
|
|
+ kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime, endTime);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -371,46 +390,39 @@ public class SampleTest {
|
|
|
|
|
|
@Test
|
|
|
public void execute() {
|
|
|
- String accountIds = "1675239584963662,1676540490482759,1675237415468045";
|
|
|
- String[] arrays = accountIds.split(",");
|
|
|
- for(int i=0;i<arrays.length;i++){
|
|
|
- Long accountId = Long.parseLong(arrays[i]);
|
|
|
- CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
- load12Data(token);
|
|
|
+ List<UserAllocation> allocations = allocationService.getByMediaId("3");
|
|
|
+ for (UserAllocation allocation:allocations) {
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
|
|
|
+// load12Data(token);
|
|
|
load12AccountData(token);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Test
|
|
|
- public void loadBytedanceData(){
|
|
|
- String accountIds = "1676540490482759";
|
|
|
- String[] arrays = accountIds.split(",");
|
|
|
- for(int i=0;i<arrays.length;i++){
|
|
|
- Long accountId = Long.parseLong(arrays[i]);
|
|
|
- CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
- load12Data(token);
|
|
|
- }
|
|
|
+ private void load12AccountData(CtopOauthToken token) {
|
|
|
+ reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-10-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-10-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-11-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-11-30", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-12-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
}
|
|
|
|
|
|
- private void load12AccountData(CtopOauthToken token){
|
|
|
- reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-01","yyyy-MM-dd"), DateUtils.parseDate("2020-12-11","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
- reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-11","yyyy-MM-dd"), DateUtils.parseDate("2020-12-21","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
- reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-21","yyyy-MM-dd"), DateUtils.parseDate("2020-12-31","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ private void load12Data(CtopOauthToken token) {
|
|
|
+// bytedanceReportService.bytedanceMaterialReport(token, "2020-10-01", "2020-10-05");
|
|
|
+// bytedanceReportService.bytedanceMaterialReport(token, "2020-10-06", "2020-10-10");
|
|
|
+// bytedanceReportService.bytedanceMaterialReport(token, "2020-10-11", "2020-10-15");
|
|
|
+// bytedanceReportService.bytedanceMaterialReport(token, "2020-10-16", "2020-10-20");
|
|
|
+// bytedanceReportService.bytedanceMaterialReport(token, "2020-10-21", "2020-10-25");
|
|
|
+// bytedanceReportService.bytedanceMaterialReport(token, "2020-10-26", "2020-10-31");
|
|
|
+ bytedanceReportService.bytedanceMaterialReport(token, "2020-10-03", "2020-10-04");
|
|
|
}
|
|
|
|
|
|
- private void load12Data(CtopOauthToken token){
|
|
|
- bytedanceReportService.bytedanceMaterialReport(token, "2020-12-01", "2020-12-11");
|
|
|
- bytedanceReportService.bytedanceMaterialReport(token, "2020-12-11", "2020-12-21");
|
|
|
- bytedanceReportService.bytedanceMaterialReport(token, "2020-12-21", "2020-12-31");
|
|
|
- }
|
|
|
@Autowired
|
|
|
private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
|
|
|
+
|
|
|
@Test
|
|
|
- public void etlKuaishouData(){
|
|
|
- String dateString = "2020-12-31";
|
|
|
- Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
|
|
|
- for(int i=0;i<=10;i++){
|
|
|
- Date getDate = DateUtils.addDay(startDate,i);
|
|
|
+ public void etlKuaishouData() {
|
|
|
+ String dateString = "2021-01-05";
|
|
|
+ Date startDate = DateUtils.parseDate(dateString, "yyyy-MM-dd");
|
|
|
+ for (int i = 0; i <= 10; i++) {
|
|
|
+ Date getDate = DateUtils.addDay(startDate, i);
|
|
|
kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
|
|
|
bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
|
|
|
}
|
|
@@ -420,43 +432,69 @@ public class SampleTest {
|
|
|
private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
|
|
|
|
|
|
@Test
|
|
|
- public void loadBytedanceVideo(){
|
|
|
+ public void loadBytedanceVideo() {
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(1673731601820686L);
|
|
|
- for(int i=15;i<60;i++){
|
|
|
- reportService.getAdvertiserReport(token,DateUtils.addDay(new Date(),-i),DateUtils.addDay(new Date(),-i),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
+ for (int i = 15; i < 60; i++) {
|
|
|
+ reportService.getAdvertiserReport(token, DateUtils.addDay(new Date(), -i), DateUtils.addDay(new Date(), -i), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void loadKuaishouVideo(){
|
|
|
+ public void loadKuaishouVideo() {
|
|
|
Date date = new Date();
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
|
|
|
// kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
|
|
|
- kuaishouInterfaceService.getVideoList(token, DateUtils.formatDate(DateUtils.addDay(date,-5)), DateUtils.formatDate(date));
|
|
|
+ kuaishouInterfaceService.getVideoList(token, DateUtils.formatDate(DateUtils.addDay(date, -5)), DateUtils.formatDate(date));
|
|
|
// 获取图片信息数据
|
|
|
// kuaishouInterfaceService.getImageList(token, DateUtils.getNowDate("yyyy-MM-dd"));
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@Autowired
|
|
|
IRuleByteDanceAccountService ruleByteDanceAccountService;
|
|
|
|
|
|
@Test
|
|
|
- public void cleanRuleDataAccount(){
|
|
|
+ public void cleanRuleDataAccount() {
|
|
|
List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
|
|
|
- for(CtopOauthToken oauthToken:tokens){
|
|
|
- ruleKuaiShouPlanService.cleanRuleDataTarget(oauthToken.getAccountId(),1);
|
|
|
+ for (CtopOauthToken oauthToken : tokens) {
|
|
|
+ ruleKuaiShouPlanService.cleanRuleDataTarget(oauthToken.getAccountId(), 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
IAiKuaishouNewCreateCampaign aiKuaishouNewCreateCampaign;
|
|
|
+ @Autowired
|
|
|
+ private IAiKuaishouAccountTargetTemplateService aiKuaishouAccountTargetTemplateService;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void createPlan() {
|
|
|
+ List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
|
|
|
+ if (null == accountTargetTemplates || accountTargetTemplates.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ accountTargetTemplates.forEach(targetTemplate -> aiKuaishouNewCreateCampaign.kuaishouAiAdsNewMaterialCreativity(targetTemplate));
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
|
- public void kuaishouAiTest(){
|
|
|
- aiKuaishouNewCreateCampaign.kuaishouAiAdsNewMaterialCreativity(null);
|
|
|
+ public void testCreatePlan() {
|
|
|
+// List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
|
|
|
+// if (null == accountTargetTemplates || accountTargetTemplates.isEmpty()) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+ AiKuaishouAccountTargetTemplate accountTargetTemplate1 = aiKuaishouAccountTargetTemplateService.getById(30002);
|
|
|
+ aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate1);
|
|
|
+
|
|
|
+ AiKuaishouAccountTargetTemplate accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(30001);
|
|
|
+ aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void etlKuaishouProjectData(){
|
|
|
+ String dateString = "2020-03-17";
|
|
|
+ Date startDate = DateUtils.parseDate(dateString,"yyyy-MM-dd");
|
|
|
+ for(int i=0;i<=365;i++){
|
|
|
+ Date getDate = DateUtils.addDay(startDate,i);
|
|
|
+ kuaishouVideoEtlInfoService.etlKuaishouVideoInfoGroupByProjectId(getDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|