SampleTest.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. package org.jeecg;
  2. import cn.com.ctop.common.module.entity.BindAccountLogin;
  3. import cn.com.ctop.common.module.entity.CtopOauthToken;
  4. import cn.com.ctop.common.module.entity.UserAllocation;
  5. import cn.com.ctop.common.module.service.IBindAccountLoginService;
  6. import cn.com.ctop.common.module.service.ICtopOauthTokenService;
  7. import cn.com.ctop.common.module.service.IUserAllocationService;
  8. import cn.com.ctop.common.module.utils.Check;
  9. import cn.com.ctop.common.module.utils.CtopAdConstant;
  10. import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
  11. import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
  12. import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
  13. import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
  14. import cn.com.ctop.kuaishou.modules.batch.service.*;
  15. import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
  16. import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
  17. import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
  18. import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
  19. import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
  20. import cn.com.ctop.oa.modules.service.IWechatNoListService;
  21. import cn.com.ctop.oa.modules.service.IWechatUserListService;
  22. import cn.com.ctop.toutiao.modules.link.service.IETLReportBytedanceVideoService;
  23. import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
  24. import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
  25. import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
  26. import cn.com.ctop.toutiao.modules.report.service.*;
  27. import com.alibaba.fastjson.JSONArray;
  28. import lombok.extern.slf4j.Slf4j;
  29. import org.apache.catalina.User;
  30. import org.jeecg.common.util.DateUtils;
  31. import org.junit.Test;
  32. import org.junit.runner.RunWith;
  33. import org.openqa.selenium.By;
  34. import org.springframework.beans.factory.annotation.Autowired;
  35. import org.springframework.boot.test.context.SpringBootTest;
  36. import org.springframework.test.context.ActiveProfiles;
  37. import org.springframework.test.context.junit4.SpringRunner;
  38. import javax.annotation.Resource;
  39. import java.text.ParseException;
  40. import java.text.SimpleDateFormat;
  41. import java.util.Date;
  42. import java.util.HashMap;
  43. import java.util.List;
  44. import java.util.Map;
  45. import java.util.concurrent.CountDownLatch;
  46. import java.util.concurrent.ExecutorService;
  47. import java.util.concurrent.Executors;
  48. import static org.jeecg.common.util.DateUtils.getAnotherDay;
  49. @RunWith(SpringRunner.class)
  50. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  51. @ActiveProfiles("wps")
  52. @Slf4j
  53. public class SampleTest {
  54. @Autowired
  55. private ICtopOauthTokenService oauthTokenService;
  56. @Autowired
  57. private IReportService reportService;
  58. @Autowired
  59. private IByteDanceAdvertiserDataService advertiserDataService;
  60. @Autowired
  61. private ICtopOauthTokenService tokenService;
  62. @Autowired
  63. private IKuaiShouVideoGetService videoGetService;
  64. @Autowired
  65. private IKuaishouVideoRelateCreativesService kuaishouVideoRelateCreativesService;
  66. @Autowired
  67. private IBindAccountLoginService bindAccountLoginService;
  68. @Autowired
  69. private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
  70. @Test
  71. public void loadBytedanceCreativeData() throws ParseException {
  72. List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
  73. if (!Check.isNull(KuaiShouVideoGets)) {
  74. JSONArray dateList = new JSONArray();
  75. JSONArray photoIds = new JSONArray();
  76. Map<String, Object> statdateMap = new HashMap<>();
  77. int count = 0;
  78. for (KuaiShouVideoGet video : KuaiShouVideoGets) {
  79. count++;
  80. if (count < 10) {
  81. photoIds.add(video.getPhotoId());
  82. statdateMap.put(video.getPhotoId(), video.getStatDate());
  83. } else {
  84. photoIds.add(video.getPhotoId());
  85. statdateMap.put(video.getPhotoId(), video.getStatDate());
  86. dateList.add(photoIds);
  87. photoIds = new JSONArray();
  88. count = 0;
  89. }
  90. }
  91. dateList.add(photoIds);
  92. kuaishouVideoRelateCreativesService.videoRelateCreatives(9743746L, dateList, statdateMap);
  93. }
  94. }
  95. @Test
  96. public void loadKuaishouCookie() {
  97. List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  98. if (list != null && !list.isEmpty()) {
  99. int i = 0;
  100. for (BindAccountLogin login : list) {
  101. if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
  102. kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
  103. i++;
  104. }
  105. }
  106. }
  107. }
  108. static ExecutorService executorService = null;
  109. static CountDownLatch countDownLatch = null;
  110. @Test
  111. public void deleteKuaishouComment() {
  112. Long start = System.currentTimeMillis();
  113. List<BindAccountLogin> loginList = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
  114. if (loginList != null && !loginList.isEmpty()) {
  115. executorService = Executors.newFixedThreadPool(5);
  116. countDownLatch = new CountDownLatch(loginList.size());
  117. loginList.forEach(login -> executorService.submit(() -> {
  118. try {
  119. kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
  120. } catch (Exception e) {
  121. log.error(e.getMessage(), e);
  122. } finally {
  123. countDownLatch.countDown();
  124. }
  125. }));
  126. try {
  127. countDownLatch.await();
  128. } catch (InterruptedException e) {
  129. e.printStackTrace();
  130. }
  131. Long end = System.currentTimeMillis();
  132. log.info("快手删评论所用时长:{}毫秒", end - start);
  133. }
  134. }
  135. @Autowired
  136. private IUserAllocationService allocationService;
  137. @Test
  138. public void testLoadBytedanceData() {
  139. List<UserAllocation> allocations = allocationService.getByParams(633L, null, 0);
  140. if (null != allocations && !allocations.isEmpty()) {
  141. for (UserAllocation allocation : allocations) {
  142. CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
  143. String startDate = "2020-11-10";
  144. String endDate = "2020-11-10";
  145. reportService.getAdvertiserReport(token, DateUtils.parseDate(startDate, "yyyy-MM-dd"), DateUtils.parseDate(endDate, "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
  146. }
  147. }
  148. System.out.println("任务结束");
  149. }
  150. @Test
  151. public void loadKuaishouPlanData() {
  152. Date getDate = DateUtils.addDay(new Date(), -1);
  153. //1:查询当日数据
  154. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  155. tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate));
  156. }
  157. @Autowired
  158. private IBytedanceFundDailyService bytedanceFundDailyService;
  159. @Test
  160. public void loadFoudData() {
  161. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  162. for (CtopOauthToken token : tokens) {
  163. System.out.println(token.getAccountId() + "############################");
  164. for (int i = 20; i < 130; i++) {
  165. Date date = DateUtils.addDay(new Date(), -i);
  166. bytedanceFundDailyService.loadFundDataByPage(token, DateUtils.formatDate(date), DateUtils.formatDate(date), 1);
  167. System.out.println(i + "############################");
  168. }
  169. }
  170. }
  171. @Autowired
  172. private IKuaiShouHistoryReportTaskService reportTaskService;
  173. /**
  174. * 测试获取快手图片消耗数据任务
  175. */
  176. @Test
  177. public void loadKuaishouImageTask() {
  178. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  179. for (int i = 1; i < 130; i++) {
  180. Date getDate = DateUtils.addDay(new Date(), -i);
  181. String getDateStr = DateUtils.formatDate(getDate);
  182. tokens.forEach(token -> reportTaskService.createTask(token.getAccountId(), token.getAccessToken(), getDateStr, getDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_DAILY));
  183. }
  184. }
  185. @Autowired
  186. private IKuaiShouDailyReportTaskService dailyReportTaskService;
  187. /**
  188. * 测试获取快手图片消耗数据入库
  189. */
  190. @Test
  191. public void loadKuaishouImageTaskFile() {
  192. String nowDate = DateUtils.getDate("yyyy-MM-dd");
  193. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  194. for (int i = 1; i < 15; i++) {
  195. String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -i);
  196. tokens.forEach(token -> dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate));
  197. }
  198. // 查询快手token
  199. }
  200. @Test
  201. public void testLoadBytedanceImageData() {
  202. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  203. countDownLatch = new CountDownLatch(tokens.size());
  204. executorService = Executors.newFixedThreadPool(8);
  205. tokens.forEach(token -> executorService.submit(() -> {
  206. try {
  207. advertiserDataService.getMaterialList(token);
  208. } catch (Exception e) {
  209. } finally {
  210. countDownLatch.countDown();
  211. }
  212. }));
  213. try {
  214. countDownLatch.await();
  215. } catch (InterruptedException e) {
  216. e.printStackTrace();
  217. }
  218. System.out.println("素材数据获取完成");
  219. }
  220. @Autowired
  221. private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
  222. @Test
  223. public void testData() {
  224. Date date = new Date();
  225. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  226. executorService = Executors.newFixedThreadPool(10);
  227. countDownLatch = new CountDownLatch(tokens.size());
  228. tokens.forEach(token -> executorService.submit(() -> {
  229. try {
  230. reportService.getAdvertiserPlanRuleData(token, date, date, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  231. } catch (Exception e) {
  232. } finally {
  233. countDownLatch.countDown();
  234. }
  235. }));
  236. try {
  237. countDownLatch.await();
  238. } catch (InterruptedException e) {
  239. e.printStackTrace();
  240. }
  241. }
  242. @Test
  243. public void testData11() {
  244. CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
  245. int dimeDiff = 5;
  246. Date now = new Date();
  247. String startTime = DateUtils.formatDate("2021-01-11 18:25:00");
  248. String endTime = DateUtils.formatDate(now, "2021-01-11 18:35:00");
  249. kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startTime, endTime);
  250. }
  251. @Test
  252. public void loadKuaishouAgentData() {
  253. kuaishouReportDailyAgentService.loginAgent();
  254. try {
  255. for (int i = 1; i < 30; i++) {
  256. kuaishouReportDailyAgentService.getAccount(i);
  257. }
  258. } catch (Exception e) {
  259. e.printStackTrace();
  260. }
  261. }
  262. @Test
  263. public void loadKuaishouData() {
  264. Date getDate = DateUtils.addDay(new Date(), -1);
  265. //1:查询当日数据
  266. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  267. for (CtopOauthToken token : tokens) {
  268. kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
  269. }
  270. }
  271. @Autowired
  272. private IBytedanceReportService bytedanceReportService;
  273. @Test
  274. public void loadBytedanceVideoReportData() {
  275. Date getDate = DateUtils.addDay(new Date(), -1);
  276. String date = DateUtils.formatDate(getDate);
  277. List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
  278. for (CtopOauthToken token : tokens) {
  279. bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
  280. }
  281. }
  282. @Test
  283. public void loadKuaishouHourlyReportData() {
  284. Date getDate = new Date();
  285. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
  286. String hour = simpleDateFormat.format(getDate);
  287. if ("00".equals(hour)) {
  288. getDate = DateUtils.addDay(getDate, -1);
  289. }
  290. //1:查询当日数据
  291. List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
  292. Date finalGetDate = getDate;
  293. tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate));
  294. }
  295. @Autowired
  296. private IKuaishouInterfaceService kuaishouInterfaceService;
  297. @Test
  298. public void loadKuaishouGroupData() throws ParseException {
  299. Date endDate = new Date();
  300. String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
  301. SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
  302. Date startDate = sim.parse(anotherDay);
  303. CtopOauthToken token = tokenService.getTokenByAccountId(7087890L);
  304. kuaishouInterfaceService.getGroupList(token, startDate, endDate);
  305. }
  306. @Test
  307. public void loadAccountData() {
  308. // List<UserAllocation> allocations = allocationService.getByParams(776L,null,0);
  309. // for (UserAllocation allocation:allocations) {
  310. CtopOauthToken token = tokenService.getTokenByAccountId(93238965516L);
  311. for (int i = 92; i < 100; i++) {
  312. Date getDate = DateUtils.addDay(new Date(), -i);
  313. reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  314. }
  315. // }
  316. }
  317. @Autowired
  318. private IWechatCheckinDataService wechatCheckinDataService;
  319. @Autowired
  320. private IWechatUserListService wechatUserInfoService;
  321. @Autowired
  322. private IWechatNoListService wechatNoListService;
  323. @Test
  324. public void getData() {
  325. //汇创 人员
  326. // wechatUserInfoService.getUserList();
  327. // //考勤记录
  328. // wechatCheckinDataService.getCheckinData("2020-11-01 00:00:00", "2020-12-01 23:59:59");
  329. //异常记录
  330. // wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "0");
  331. //优容
  332. wechatUserInfoService.getYRUserList();
  333. wechatCheckinDataService.getYRCheckinData("2020-11-01 00:00:00", "2020-11-30 23:59:59");
  334. wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "1");
  335. }
  336. @Autowired
  337. private IKuaiShouCommentService kuaiShouCommentService;
  338. @Test
  339. public void kuaishouDeleteComment() {
  340. kuaiShouCommentService.shieldComment(8018853L);
  341. }
  342. @Autowired
  343. private IByteDanceVideoReportDailyService videoReportDailyService;
  344. @Test
  345. public void formatVideoReportData() {
  346. for (int i = 1; i < 45; i++) {
  347. Date getDate = DateUtils.addDay(new Date(), -i);
  348. String date = DateUtils.formatDate(getDate);
  349. videoReportDailyService.videoInfoList(date, date);
  350. }
  351. }
  352. @Autowired
  353. private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
  354. @Autowired
  355. private IBytedanceAccountReportTaskRecordService reportTaskRecordService;
  356. @Test
  357. public void execute() {
  358. List<UserAllocation> allocations = allocationService.listByMediaId("3", 0);
  359. for (UserAllocation allocation : allocations) {
  360. BytedanceAccountReportTaskRecord reportTaskRecord1 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-10-01", "2020-10-31");
  361. reportTaskRecordService.save(reportTaskRecord1);
  362. BytedanceAccountReportTaskRecord reportTaskRecord2 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-11-01", "2020-11-30");
  363. reportTaskRecordService.save(reportTaskRecord2);
  364. BytedanceAccountReportTaskRecord reportTaskRecord3 = new BytedanceAccountReportTaskRecord(allocation.getAccountId(), "2020-12-01", "2020-12-31");
  365. reportTaskRecordService.save(reportTaskRecord3);
  366. }
  367. }
  368. @Test
  369. public void loadBDAccoutData() {
  370. CtopOauthToken token2 = tokenService.getTokenByAccountId(1674206482908163L);
  371. bytedanceReportService.bytedanceMaterialReport(token2, "2020-10-14", "2020-10-14");
  372. bytedanceReportMaterialDailyMapper.updateImageReportCode();
  373. bytedanceReportMaterialDailyMapper.updateImageReportProjectId();
  374. bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
  375. bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
  376. bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
  377. }
  378. @Resource
  379. private BytedanceReportMaterialDailyMapper bytedanceReportMaterialDailyMapper;
  380. private void load12AccountData(CtopOauthToken token) {
  381. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-10-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-10-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  382. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-11-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-11-30", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  383. reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-12-01", "yyyy-MM-dd"), DateUtils.parseDate("2020-12-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  384. }
  385. private void load12Data(CtopOauthToken token) {
  386. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-11", "2020-10-13");
  387. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-14", "2020-10-16");
  388. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-17", "2020-10-19");
  389. bytedanceReportService.bytedanceMaterialReport(token, "2020-10-20", "2020-10-21");
  390. }
  391. @Autowired
  392. private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
  393. @Test
  394. public void etlKuaishouData() {
  395. String dateString = "2021-01-05";
  396. Date startDate = DateUtils.parseDate(dateString, "yyyy-MM-dd");
  397. for (int i = 0; i <= 10; i++) {
  398. Date getDate = DateUtils.addDay(startDate, i);
  399. kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
  400. bytedanceVideoEtlInfoService.etlBytedanceVideoInfo(getDate);
  401. }
  402. }
  403. @Autowired
  404. private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
  405. @Test
  406. public void loadBytedanceVideo() {
  407. CtopOauthToken token = tokenService.getTokenByAccountId(1673731601820686L);
  408. for (int i = 15; i < 60; i++) {
  409. reportService.getAdvertiserReport(token, DateUtils.addDay(new Date(), -i), DateUtils.addDay(new Date(), -i), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  410. }
  411. }
  412. @Test
  413. public void loadKuaishouVideo() {
  414. Date date = new Date();
  415. CtopOauthToken token = tokenService.getTokenByAccountId(9556344L);
  416. // kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, new Date(), new Date(), null, null);
  417. kuaishouInterfaceService.getVideoList(token, DateUtils.formatDate(DateUtils.addDay(date, -5)), DateUtils.formatDate(date));
  418. // 获取图片信息数据
  419. // kuaishouInterfaceService.getImageList(token, DateUtils.getNowDate("yyyy-MM-dd"));
  420. }
  421. @Autowired
  422. IRuleByteDanceAccountService ruleByteDanceAccountService;
  423. @Test
  424. public void cleanRuleDataAccount() {
  425. List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
  426. for (CtopOauthToken oauthToken : tokens) {
  427. ruleKuaiShouPlanService.cleanRuleDataTarget(oauthToken.getAccountId(), 1);
  428. }
  429. }
  430. @Autowired
  431. IAiKuaishouNewCreateCampaign aiKuaishouNewCreateCampaign;
  432. @Autowired
  433. private IAiKuaishouAccountTargetTemplateService aiKuaishouAccountTargetTemplateService;
  434. @Test
  435. public void createPlan() {
  436. List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
  437. if (null == accountTargetTemplates || accountTargetTemplates.isEmpty()) {
  438. return;
  439. }
  440. accountTargetTemplates.forEach(targetTemplate -> aiKuaishouNewCreateCampaign.kuaishouAiAdsNewMaterialCreativity(targetTemplate));
  441. }
  442. @Test
  443. public void testCreatePlan() {
  444. // List<AiKuaishouAccountTargetTemplate> accountTargetTemplates = aiKuaishouAccountTargetTemplateService.getAllEffectTemplate();
  445. // if (null == accountTargetTemplates || accountTargetTemplates.isEmpty()) {
  446. // return;
  447. // }
  448. // for (AiKuaishouAccountTargetTemplate template:accountTargetTemplates){
  449. // if(template.getAccountId()!=9556344L){
  450. // AiKuaishouAccountTargetTemplate accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getByAccountId(template.getAccountId());
  451. // aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2,50);
  452. // }
  453. // }
  454. /**
  455. * 120002
  456. * 150001
  457. * 150002
  458. * 150003
  459. * 150004
  460. */
  461. AiKuaishouAccountTargetTemplate accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(120002);
  462. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  463. accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(150001);
  464. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  465. accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(150002);
  466. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  467. accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(150003);
  468. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  469. accountTargetTemplate2 = aiKuaishouAccountTargetTemplateService.getById(150004);
  470. aiKuaishouNewCreateCampaign.kuaishouAiAddNewMaterialCreativity(accountTargetTemplate2, 250);
  471. }
  472. @Autowired
  473. private IBytedancePlanDailyReportService planDailyReportService;
  474. @Test
  475. public void etlKuaishouProjectData() {
  476. CtopOauthToken token = tokenService.getTokenByAccountId(1660666858777607L);
  477. reportService.getAdvertiserPlanReport(token, DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-25", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
  478. }
  479. @Autowired
  480. IBytedanceVideoReportService bytedanceVideoReportService;
  481. @Test
  482. public void etlBytedanceVideoReport() {
  483. for (int i = 1; i <= 62; i++) {
  484. etlBytedanceVideo(DateUtils.formatDate(DateUtils.addDay(new Date(), -i)));
  485. }
  486. //etlBytedanceVideo("2021-02-01");
  487. }
  488. private void etlBytedanceVideo(String statDate) {
  489. List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
  490. executorService = Executors.newFixedThreadPool(30);
  491. countDownLatch = new CountDownLatch(tokens.size());
  492. tokens.forEach(token -> executorService.submit(() -> {
  493. try {
  494. bytedanceVideoReportService.pullVideoReport(token, statDate, statDate, 1);
  495. } catch (Exception e) {
  496. } finally {
  497. countDownLatch.countDown();
  498. }
  499. }));
  500. try {
  501. countDownLatch.await();
  502. } catch (InterruptedException e) {
  503. e.printStackTrace();
  504. }
  505. }
  506. @Autowired
  507. IETLReportBytedanceVideoService ietlReportBytedanceVideoService;
  508. @Test
  509. public void etlBytedanceVideoReportClean() {
  510. for (int i = 1; i <= 1; i++) {
  511. String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
  512. ietlReportBytedanceVideoService.cleanETL(statDate);
  513. }
  514. }
  515. @Test
  516. public void etlBytedanceVideoReportClean1() {
  517. //executorService = Executors.newFixedThreadPool(31);
  518. //countDownLatch = new CountDownLatch(31);
  519. for (int i = 3; i <= 31; i++) {
  520. String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
  521. ietlReportBytedanceVideoService.cleanETL(statDate);
  522. }
  523. }
  524. }